This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var chainer = new Sequelize.Utils.QueryChainer() | |
| Artist.find({ where: {name: name} }).success(function(artist) { | |
| if (artist) { | |
| // get all tracks | |
| artist.getTracks().success(function (tracks) { | |
| if (tracks.length > 0) { | |
| tracks.forEach(function(track) { | |
| chainer.add(track.getArtists()) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //usage | |
| withAdvice.call(targetObject); | |
| //mixin augments target object with around, before and after methods | |
| //method is the base method, advice is the augmenting function | |
| withAdvice: function() { | |
| ['before', 'after', 'around'].forEach(function(m) { | |
| this[m] = function(method, advice) { | |
| if (typeof this[method] == 'function') { | |
| return this[method] = fn[m](this[method], advice); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //usage | |
| withAdvice.call(targetObject); | |
| //mixin augments target object with around, before and after methods | |
| //method is the base method, advice is the augmenting function | |
| withAdvice: function() { | |
| ['before', 'after', 'around'].forEach(function(m) { | |
| this[m] = function(method, advice) { | |
| if (typeof this[method] == 'function') { | |
| return this[method] = fn[m](this[method], advice); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var http = require('http'), | |
| httpProxy = require('http-proxy'); | |
| // | |
| // Setup proxy server with forwarding | |
| // | |
| var options = { | |
| router: { | |
| 'proxytest.randylubin.com': '127.0.0.1:7200', | |
| 'randylubin.com': '127.0.0.1:7200', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function money_commands($dep) { | |
| $total = 0; | |
| $dep = str_replace(',', '', $dep); | |
| preg_match_all('#[0-9]{1,}(m|M)#', $dep, $matches); | |
| foreach($matches AS $v) { | |
| foreach($v AS $val) { | |
| $x = str_ireplace('m', '', $val); | |
| $dep = str_replace($val, '', $dep); | |
| $total += $x*1000000; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env sh | |
| ## | |
| # This is script with usefull tips taken from: | |
| # https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
| # | |
| # install it: | |
| # curl -sL https://raw.github.com/gist/2267151/hack.sh | sh | |
| # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var zmq = require('zeromq'); | |
| s = zmq.createSocket('push'); | |
| s.connect('tcp://127.0.0.1:15000'); | |
| while (true) { // ZOMG he did it again! | |
| s.send(new Buffer("test")); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // node.js 0.5 Diffie-Hellman example | |
| var assert = require("assert"); | |
| var crypto = require("crypto"); | |
| // the prime is shared by everyone | |
| var server = crypto.createDiffieHellman(512); | |
| var prime = server.getPrime(); | |
| // sharing secret key on a pair |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rest_client' | |
| require 'json' | |
| a = `sox -d --norm -t .flac - silence -l 1 0 1% 1 6.0 1% rate 16k` | |
| #a = `arecord -q -d 3 -c 1 -f S16_LE -r 22050 -t wav | flac - -f --totally-silent -o-` | |
| r = RestClient.post 'https://www.google.com/speech-api/v1/recognize?lang=en-US', a, | |
| :content_type => 'audio/x-flac; rate=16000' | |
| if j = JSON.parse(r) | |
| (p j; `espeak 'you said: #{j['hypotheses'].first['utterance']}'`) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Homebrew Formula for PHP 5.2.14 as php-cgi (for nginx, etc.) | |
| require 'formula' | |
| class PhpCgi <Formula | |
| @url='http://www.php.net/get/php-5.2.14.tar.bz2/from/www.php.net/mirror' | |
| @version='5.2.14' | |
| @homepage='http://php.net/' | |
| @md5='bfdfc0e62fe437020cc04078269d1414' |