Friday, April 25, 2014

baudio by @substack

Eğer takip etmiyorsanız @substack takip edilecek kişilerdendir.

Javascript ile müzik yapmak için geliştirilmiş çok sevdiğim şu paketin de geliştiricisi : baudio

Yarım saatlik şu videosunu da izlerseniz bu paket hakkında daha çok fikre sahip olursunuz.



Baudio ile muzik yapmak javascript geliştiriciler için çok daha eğlenceli :)

Örnek :
var baudio = require('baudio');

var n = 0;
var b = baudio(function (t) {
    var x = Math.sin(t * 262 + Math.sin(n));
    n += Math.sin(t);
    return x;
});
b.play();

Saturday, April 19, 2014

Hroute.js

Tiny helper to catch hash changes

Demo : http://jsfiddle.net/hasantayyar/Wq7PC/2/embedded/result/

hroute({
        '': function(){
            content.innerHTML = "default page";
        },
        'about': function(){
            content.innerHTML = "about page";
        },
        '^video\/(.*)': function(params){
            content.innerHTML = '<iframe width="100%" height="315" '+
            'src="https://www.youtube.com/embed/'+params[1]+
            '" frameborder="0" allowfullscreen></iframe>';
        } 
    },{
    default: function(){
        console.log("404/notfound/default action"); 
    }, 
    beforeAction: function(){
        console.log("before action");
    }
});

Tuesday, April 15, 2014

Yalan api

http://yalan.herokuapp.com/

Üstelik Api'si de mevcut.

$ curl http://yalan.herokuapp.com/json 
{
  "lie": "Stajyer herşeyi bozmuş!"
}

Ayrıca bana daha fazla yalan lazım. Şurdan iletirseniz.

https://github.com/hasantayyar/yalan/issues

Monday, April 7, 2014

Turkey Internet Map

Alexa verileriyle her ay güncellediğim http://turkey-internet.herokuapp.com/







Maintenance page redirection with htaccess

RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /maintenance.html [R=503,L]
ErrorDocument 503 /maintenance.html 


When you want to disable maintenance mode just remname maintenance file to something else

mv maintenance.html maintenance.html.disabled"

Gist with sample maintenance page :

Wednesday, April 2, 2014

Symfony forms disable csrf protection

Şöyle iki şekilde yapılabilir. İlki formu olustururken, ikincisi de kökten çözüm EntityFormType içine yazarak. İkincisini yaparsanız ilgili tüm form kullanımlarında csrf olayını kapatmış oluyorsunuz.

Friday, February 28, 2014

#mongodb kill slow operations

home dizininizde tıpkı .vimrc gibi .mongorc olacak. Bu "mongo" konsolu her açıldığında çalışır tıpkı .vimrc'nin vim her açıldığında çalışması için.
.mongorc içine custom fonksiyonlar yazabilirsiniz. Bu da bir acil durum komutu killzombie(). 2 saniyeden fazla süren işlemleri öldürüyor. Dikkatli kullannakta fayda var :)


killzombie.js :

http://blog.mongolab.com/2014/02/mongodb-currentop-killop/

Tuesday, February 18, 2014

Rainy?

http://rainy-today.appspot.com sadece şuanda yağmurlu mu değil mi onu söyler. Tek hedef kitlesi pencereden bakmaya üşenenler (veya bodrumda çalışanlar)




Duruma uygun şarkılar seçin - songs-for app

Aslında benim kendim için bir youtube müzik bookmark servisi olarka düşünmüştüm.
Ama herkesin kullanmasında sakınca yok.

https://songs-for.herokuapp.com


Kaynak  : https://github.com/hasantayyar/songs-for

Wednesday, January 22, 2014

Benchmark of docx -> html coversation tools

Link to gist : gist.github.com/hasantayyar/8559594

NoSQL vs. SQL Summary

SQL DatabasesNoSQL Databases
TypesOne type (SQL database) with minor variationsMany different types including key-value stores, document databases, wide-column stores, and graph databases
Development HistoryDeveloped in 1970s to deal with first wave of data storage applicationsDeveloped in 2000s to deal with limitations of SQL databases, particularly concerning scale, replication and unstructured data storage
ExamplesMySQL, Postgres, Oracle DatabaseMongoDB, Cassandra, HBase, Neo4j
Data Storage ModelIndividual records (e.g., "employees") are stored as rows in tables, with each column storing a specific piece of data about that record (e.g., "manager," "date hired," etc.), much like a spreadsheet. Separate data types are stored in separate tables, and then joined together when more complex queries are executed. For example, "offices" might be stored in one table, and "employees" in another. When a user wants to find the work address of an employee, the database engine joins the "employee" and "office" tables together to get all the information necessary.Varies based on database type. For example, key-value stores function similarly to SQL databases, but have only two columns ("key" and "value"), with more complex information sometimes stored within the "value" columns. Document databases do away with the table-and-row model altogether, storing all relevant data together in single "document" in JSON, XML, or another format, which can nest values hierarchically.
SchemasStructure and data types are fixed in advance. To store information about a new data item, the entire database must be altered, during which time the database must be taken offline.Typically dynamic. Records can add new information on the fly, and unlike SQL table rows, dissimilar data can be stored together as necessary. For some databases (e.g., wide-column stores), it is somewhat more challenging to add new fields dynamically.
ScalingVertically, meaning a single server must be made increasingly powerful in order to deal with increased demand. It is possible to spread SQL databases over many servers, but significant additional engineering is generally required.Horizontally, meaning that to add capacity, a database administrator can simply add more commodity servers or cloud instances. The database automatically spreads data across servers as necessary
Development ModelMix of open-source (e.g., Postgres, MySQL) and closed source (e.g., Oracle Database)Open-source
Supports TransactionsYes, updates can be configured to complete entirely or not at allIn certain circumstances and at certain levels (e.g., document level vs. database level)
Data ManipulationSpecific language using Select, Insert, and Update statements, e.g. SELECT fields FROM table WHERE…Through object-oriented APIs
ConsistencyCan be configured for strong consistencyDepends on product. Some provide strong consistency (e.g., MongoDB) whereas others offer eventual consistency (e.g., Cassandra)
http://www.mongodb.com/learn/nosql

Tuesday, December 3, 2013

clone js object (lazy way)

var ax = {};
var bx = jQuery.extend(true, {}, ax);

Friday, November 22, 2013

console.table

tabular veri veya benzer duzenli verileri isledigimiz uygulamarda debugging amacli console.log yerine console.table kullanmak daha mantikli azizim.
Bunu da bugun ogrenmem buyuk kayip.

Mesela verimiz

var data = [ {"name":"Bob Dylan","date":"1977-10-01"}, {"name":"Janis Joplin","date":"1978-03-01"} ];


console.log(data) su ciktiyi veriri consola :

Ama console.table(data) dersem :






Bunu da surdan okudum az evvel.

Friday, October 4, 2013

Scroble with python / scroble.py

#!/usr/bin/env python
"""
usage 
python scroble.py <artist> <song> <timestamp>
"""
 
import sys
import time
import pylast
 
API_KEY = "api-key";
API_SECRET = "api-secret"
USERNAME = "lastfm-username"
PASSWORD = "lastfm-password"
 
 
 
 
def main(): 
  artist = sys.argv[1] 
  title = sys.argv[2]
  song_started = sys.argv[3]
  network = pylast.LastFMNetwork(api_key = API_KEY, api_secret = API_SECRET, username = USERNAME, password_hash = pylast.md5(PASSWORD))
  network.scrobble(artist = artist, title = title, timestamp = song_started)
 
if __name__ == "__main__":
  main()

#https://gist.github.com/hasantayyar/6826107

Tuesday, March 26, 2013

Redis Transactions ve Rollback

Azizim transaction denildiğinde iki ana başlık temeldir "Rollback" ve "Rollforward" [1]. Hatta bana sorarsan en önemli olay rollbak olayıdır. Bir şeyler fena halde sarpa sararsa bir şeyler kötü giderse rollback eylersin. 
Lakin benim de pek sevdiğim Redis'de işler böyle yürümüyor. 
Redis özelliklerinni listelendiği sayfada "Transaction" da yer alıyor : 

Fakat redis transaction ile şunu kastediyor :
  1. Failsafe query
  2. Sorgularınızın ya tamamı çalışır ya da hiç biri çalışmaz.
Aklınızda olsun her transaction özelliği rollback özelliği var demek olmuyor. Redis'de kendiniz rollback yapacaksınız. 
Redisin bu duruma mantıklı bir açıklaması var tabi 

Why Redis does not support roll backs?
If you have a relational databases background, the fact that Redis commands can fail during a transaction, but still Redis will execute the rest of the transaction instead of rolling back, may look odd to you.
However there are good opinions for this behavior:
  • Redis commands can fail only if called with a wrong syntax (and the problem is not detectable during the command queueing), or against keys holding the wrong data type: this means that in practical terms a failing command is the result of a programming errors, and a kind of error that is very likely to be detected during development, and not in production.
  • Redis is internally simplified and faster because it does not need the ability to roll back.
An argument against Redis point of view is that bugs happen, however it should be noted that in general the roll back does not save you from programming errors. For instance if a query increments a key by 2 instead of 1, or increments the wrong key, there is no way for a rollback mechanism to help. Given that no one can save the programmer from his errors, and that the kind of errors required for a Redis command to fail are unlikely to enter in production, we selected the simpler and faster approach of not supporting roll backs on errors.


Konuyla ilgili diğer bağlantılar






[1] Transaction processing : http://en.wikipedia.org/wiki/Transaction_processing