Skip to content

Instantly share code, notes, and snippets.

View Sannis's full-sized avatar
🎯
Focusing

Oleg Efimov Sannis

🎯
Focusing
View GitHub Profile
@TooTallNate
TooTallNate / README.md
Created November 16, 2011 00:57
A C header file to make your node bindings backwards and forwards compatible that use eio_custom()

node_async_shim.h

Use this header file to conditionally invoke eio_custom() or uv_queue_work(), depending on the node version that the module is being compiled for.

See the usage.cc file for a partial example.

Comments, forks, and improvements are welcome!

@jbenet
jbenet / current_utc_time.c
Created July 17, 2011 16:17
work around lack of clock_gettime in os x
/*
author: jbenet
os x, compile with: gcc -o testo test.c
linux, compile with: gcc -o testo test.c -lrt
*/
#include <time.h>
#include <sys/time.h>
#include <stdio.h>
@DTrejo
DTrejo / .gitignore
Created April 4, 2011 03:32
How to Readline - an example and the beginnings of the docs
node_modules/
@xavi-
xavi- / gist:633341
Created October 19, 2010 00:15
Interview gist -- Can candidate write code?

Instructions

  • Solve all problems using JavaScript

Problems

  1. Write a function that returns an array with the first n powers of 2. Call it twoPow.

  2. Use twoPow and Array.prototype.reduce to the sum of the first 10 powers of 2.

  3. Describe this call signature:

@xavi-
xavi- / gist:633087
Created October 18, 2010 21:21 — forked from jimbojw/gist:583389
Interview gist -- Can candidate read, debug, and fix code?
// For each of the following code fragments:
// a. what does the code do?
// b. what did the author intend for it to do?
// c. how would you fix it?
// NOTE: all code samples work exactly the same in all browsers
// 1. object literals
var data = [ { high: 100, low: 81 }, { high: 93, low: 73 }, { high: 60, low: 32 } ];
function getAverages(data) {
var avgs = [];
Buffer.prototype.pprint = function() {
var line = "";
if(this.length > 0) {
for(var i=0; i<this.length; i++) {
if(i%8==0) {
sys.print(" ");
}
if(i%16==0) {
sys.print(line);
line = "";
@woods
woods / git_svn_bash_prompt.sh
Created December 4, 2008 15:37 — forked from halbtuerke/gist:31934
Set color bash prompt according to git/svn branch, and return status of last command.
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the branch/status of the current git repository
# * the branch of the current subversion repository
# * the return value of the previous command
#
# USAGE: