Skip to content

Instantly share code, notes, and snippets.

View Sannis's full-sized avatar
🎯
Focusing

Oleg Efimov Sannis

🎯
Focusing
View GitHub Profile
@Sannis
Sannis / screencast.sh
Created March 15, 2012 21:22 — forked from pomeo/screencast.sh
script to make screencasts on Linux
#!/bin/bash
# list of programs we depend on
progs="xdpyinfo grep head sed ffmpeg pacat parec sox"
# check for programs we depend on
result=0
for prog in $progs
do
type -p $prog > /dev/null
@Sannis
Sannis / json-protocol.js
Created December 7, 2011 09:24 — forked from joekim/json-protocol.js
A simple carriage-return, line-feed delimited JSON protocol.
/*
A simple carriage-return, line-feed delimited JSON protocol.
Receiving Usage:
protocol = require('./json-protocol');
// parsing data
parser = protocol.StreamParser();
@Sannis
Sannis / LICENSE.txt
Created May 16, 2011 16:24 — forked from jed/LICENSE.txt
calculate # of ms/seconds/minutes/hours/days in the past
Copyright (c) 2011 Jed Schmidt, http://jed.is
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
// Copyright 2009 Ryan Dahl <ry@tinyclouds.org>
#include <v8.h>
#include <node.h>
#include <node_os.h>
#include <sys/types.h>
#include <sys/time.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
var util = require('util')
function hook_stdout(callback) {
var old_write = process.stdout.write
process.stdout.write = (function(write) {
return function(string, encoding, fd) {
write.apply(process.stdout, arguments)
callback(string, encoding, fd)
}
@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\)/"
}
@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 / 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);