Skip to content

Instantly share code, notes, and snippets.

@durango
durango / ev.rb
Created August 21, 2011 00:15 — forked from dkubb/ev.rb
Poor-man's Embedded Value
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
@durango
durango / about.md
Created August 21, 2011 18:59 — forked from jasonrudolph/about.md
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
@durango
durango / php-cgi.rb
Created September 3, 2011 02:04 — forked from ambethia/php-cgi.rb
Homebrew Formula for PHP 5.2.14 as php-cgi (for nginx, etc.)
# 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'
@durango
durango / google_speech_recognition.rb
Created December 11, 2011 15:33 — forked from pachacamac/google_speech_recognition.rb
google speech recognition with ruby
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
@durango
durango / dh-usage.js
Created February 5, 2012 17:45 — forked from bellbind/dh-usage.js
[nodejs][javascript] Diffie-Hellman key exchange by nodejs-0.5
// 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
@durango
durango / client.js
Created February 10, 2012 04:56 — forked from sbusso/client.js
Node + ZeroMQ + Redis
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"));
}
@durango
durango / hack.sh
Created March 31, 2012 17:58 — forked from erikh/hack.sh
OSX For Hackers
#!/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
#
@durango
durango / proxyServer
Created July 2, 2012 03:36 — forked from randylubin/proxyServer
Node.js Multi-App Proxy Server with Forwarding
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',
@durango
durango / advice.js
Created September 15, 2012 04:07 — forked from angus-c/advice.js
an advice functional mixin
//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);