Skip to content

Instantly share code, notes, and snippets.

View jeromeetienne's full-sized avatar

Jerome Etienne jeromeetienne

View GitHub Profile
@jeromeetienne
jeromeetienne / dir_scan_symlinkok.rb
Created April 28, 2010 09:33
scan dir + symlink ok
#!/usr/bin/env ruby
# reccursively scan the rootdir directory
# - if a block is given, the fullpath are yielded. They are kept IIF the block return true
# - Find.find and Dir dont follow symlinks. BUT this one does
def dir_scan(rootdir, &block)
results = []
dirnames = []
Dir.entries(rootdir).each do |entry|
next if entry == "."
@jeromeetienne
jeromeetienne / template_ezmustache.rb
Created May 16, 2010 08:42
template based on mustache
#!/usr/bin/env ruby
# system of template which are based on mustache
# - http://mustache.github.com/
# - it seems serious work. Just i dont like to have more dependancies
module TemplateEzmustache
def self.patch(template, variables)
variables.each { |key, val|
template.gsub!("{{#{key}}}", val)
}
$ cat .asoundrc
pcm.!default iec958:U0xccd0x77
TO GET ARECORD (good to test if mic work)
$ arecord -fcd -Dplughw:U0xccd0x77 -vv /dev/null
- apparently this is hard to put that in the .asoundrc
TO GET OUTPUT DEVICE
$ aplay -L
@jeromeetienne
jeromeetienne / twitter to irc from maushu
Created June 10, 2010 14:48
twitter to irc from maushu
#!/usr/local/bin/node
var sys = require('sys'),
http = require('http'),
querystring = require('querystring'),
base64 = require('./lib/base64'),
Buffer = require('buffer').Buffer,
Irc = require('./vendor/IRC/lib/irc');
var twitter_auth = { user: "<YOUR_TWITTER_USERNAME>", pass: "<YOUR_TWITTER_PASSWORD>"};
@jeromeetienne
jeromeetienne / 0001-Support-of-console.dir-console.assert.patch
Created July 7, 2010 10:01
nodejs: Support of console.dir + console.assert
From 25844820ac27eecad46bbf98841c9b97a3b784d6 Mon Sep 17 00:00:00 2001
From: Jerome Etienne <[email protected]>
Date: Wed, 7 Jul 2010 11:58:33 +0200
Subject: [PATCH] Support of console.dir + console.assert
---
src/node.js | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/node.js b/src/node.js
@jeromeetienne
jeromeetienne / 0001-Support-of-console.log-o-append-unparsed-params-nopa.patch
Created August 3, 2010 13:54
[PATCH] Support of %o console.log format + append non converted args
From 2fc85ee6b1b5dbc78328f94b539340dc2e15c1fc Mon Sep 17 00:00:00 2001
From: Jerome Etienne <[email protected]>
Date: Tue, 3 Aug 2010 21:15:19 +0200
Subject: [PATCH] Support of console.log %o + append unparsed params + noparam-ok
---
src/node.js | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/node.js b/src/node.js
@jeromeetienne
jeromeetienne / 0001-Support-of-console.trace.patch
Created August 3, 2010 15:12
[PATCH] Support of console.trace()
From a66f80208c56e6677073965ca799763958d514ff Mon Sep 17 00:00:00 2001
From: Jerome Etienne <[email protected]>
Date: Tue, 3 Aug 2010 17:08:02 +0200
Subject: [PATCH] Support of console.trace()
---
src/node.js | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/node.js b/src/node.js
@jeromeetienne
jeromeetienne / node-ssl-server.js
Created August 6, 2010 09:44
example of node.js ssl server
// You can generate the privatekey.pem and certificate.pem files using the following commands:
//
// openssl genrsa -out privatekey.pem 1024
// openssl req -new -key privatekey.pem -out certrequest.csr
// openssl x509 -req -in certrequest.csr -signkey privatekey.pem -out certificate.pem
const crypto = require('crypto'),
fs = require("fs"),
http = require("http");
@jeromeetienne
jeromeetienne / run module only once
Created August 10, 2010 21:09
node.js module fun
jerome@jmebox:/tmp/sloti$ cat A.js
console.log("foo");
jerome@jmebox:/tmp/sloti$ cat a.js
require('./A');
jerome@jmebox:/tmp/sloti$ cat b.js
require("./a");
require("./A");
jerome@jmebox:/tmp/sloti$ node b.js
foo
@jeromeetienne
jeromeetienne / gist:518027
Created August 10, 2010 21:17
node.js module fun
jerome@jmebox:/tmp/slotu$ cat A.js
var hello = 42;
exports.hello = hello;
jerome@jmebox:/tmp/slotu$ cat a.js
require('./A').hello = "hello";
jerome@jmebox:/tmp/slotu$ cat b.js
require("./a");
console.log(require("./A").hello);
jerome@jmebox:/tmp/slotu$ node b.js
hello