This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| class User | |
| include DataMapper::Resource | |
| property :id, Serial | |
| property :username, String, :required => true, :unique => true | |
| property :address_street_address, String | |
| property :address_location, String | |
| property :address_subdivision, String | |
| property :address_country, String |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| # Author: Pieter Noordhuis | |
| # Description: Simple demo to showcase Redis PubSub with EventMachine | |
| # | |
| # Update 7 Oct 2010: | |
| # - This example does *not* appear to work with Chrome >=6.0. Apparently, | |
| # the WebSocket protocol implementation in the cramp gem does not work | |
| # well with Chrome's (newer) WebSocket implementation. | |
| # | |
| # Requirements: | |
| # - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby |
| # 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' |
| 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 |
| // 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 |
| 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")); | |
| } |
| #!/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 | |
| # |
| 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', |
| //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); |