Skip to content

Instantly share code, notes, and snippets.

View Sannis's full-sized avatar
🎯
Focusing

Oleg Efimov Sannis

🎯
Focusing
  • Bumble Inc.
  • London, UK
View GitHub Profile
@Sannis
Sannis / gist:337019
Created March 18, 2010 22:56
node_string_concat_vs_array_join_benchmark.js
var
sys = require('sys'),
chunk = "1234567890htcje,stdl",
chunk_length = parseInt(process.ARGV[2]),
count = parseInt(process.ARGV[3]),
i;
function doBenchmark(title, execute_function) {
var
start,
@Sannis
Sannis / Node-mysql-libmysqlclient v0.0.7 example.js
Created August 19, 2010 13:26
Node-mysql-libmysqlclient v0.0.7 example using
var sys = require("sys");
var mysql_libmysqlclient = require("mysql-libmysqlclient");
var conn = mysql_libmysqlclient.createConnection(host, user, password, database);
if (!conn.connected()) {
sys.puts("Connection error: " + conn.connectErrno() + ", " + conn.connectError());
process.exit(1);
}
var string = conn.escape("Sannis's code");
@Sannis
Sannis / fs.walk.js
Created September 16, 2010 23:31 — forked from vilmibm/fs.walk.js
Recursive directories walk
var fs = require('fs'),
sys = require('sys');
function walk(path, callback) {
var recur_or_cb = function( abspath ) {
return function(err, stats) {
if ( stats.isDirectory() )
walk(abspath, callback);
else
callback(err, abspath);
@Sannis
Sannis / zerolengthbufferbug.js
Created September 29, 2010 19:45 — forked from kadirpekel/zerolengthbufferbug.js
Zero length buffer bug
var http = require('http');
var Buffer = require('buffer').Buffer;
http.createServer(function (req, res) {
res.writeHead(200,
{'Content-Type': 'text/html',
'Content-Length': 0});
res.end(new Buffer(0), 'binary');
}
).listen(3000);
@Sannis
Sannis / output.txt
Created October 5, 2010 11:26
wdk-axial grid accuracy tests
Impulse parameters:
Sr: ~5
St: ~5
Initial step: 1e-3
Simple:
00100 0.010000 1.000000 0.499973642552 0.500000000000 1.000032834871
Error: 0.000052715 (reference)
With 1 buffer step:
@Sannis
Sannis / means.txt
Created October 5, 2010 15:41
Means
x = 0.1
y = 10
Arithmetic_mean(x, y) = 5.05
Geometric_mean(x, y) = 1
Harmonic_mean(x, y) = 0.198019802
Quadratic_mean(x, y) = 7.071421356
@Sannis
Sannis / script-fu-saturation-contrast-unsharp.scm
Created October 5, 2010 19:20
Gimp script: add saturation and contrast, unsharp image
(define (script-fu-saturation-contrast-unsharp image drawable)
(let*
(
(saturation +20)
(contrast 3)
(unsharp-radius 3)
(unsharp-amount 0.5)
(unsharp-threshold 0)
)
; Start
@Sannis
Sannis / Add-DESTDIR-support-to-Makefile.patch
Created October 30, 2010 11:39
Node.js patch: Add-DESTDIR-support-to-Makefile.patch
From 39538a7584f87ad204bdbb57592d8235b568f032 Mon Sep 17 00:00:00 2001
From: Oleg Efimov <[email protected]>
Date: Fri, 29 Oct 2010 17:07:27 +0400
Subject: [PATCH 1/2] Add DESTDIR support to Makefile
---
Makefile | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile
@Sannis
Sannis / Add-node-headers-installation.patch
Created October 30, 2010 11:41
Node.js patch: Add-node-headers-installation.patch
From c980b2e11f5a477b63fc797e4ebf37b4a19c876c Mon Sep 17 00:00:00 2001
From: Oleg Efimov <[email protected]>
Date: Fri, 29 Oct 2010 18:10:37 +0400
Subject: [PATCH 2/2] Add node headers installation
---
Makefile | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
@Sannis
Sannis / .bashrc
Created November 5, 2010 01:17 — forked from henrik/.bashrc
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_branch_name {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1/"
}
function parse_git_push_queue {
git log --no-color --oneline origin/$(parse_git_branch_name)...$(parse_git_branch_name) 2> /dev/null | wc -l | grep -v -P "^0$" | sed -e "s/\(.*\)/\(+\1\)/"
}