Skip to content

Instantly share code, notes, and snippets.

@i
i / func_ptr.c
Created September 24, 2013 05:01
Function pointer example
#include <stdio.h>
int main(int argc, char **argv) {
int (*zzz)(const char *k, ...);
zzz = printf;
zzz("hello world\n");
return 0;
}
@i
i / fn_ptr2.c
Last active December 23, 2015 20:09
Another example of function pointers in C.
#include <stdio.h>
int add(int a, int b) {
return a + b;
}
int main(int argc, char **argv) {
int ret;
int (*fn_ptr)(int a, int b);
@i
i / gist:6851979
Created October 6, 2013 10:03
zombie help
var Browser = require('zombie');
var assert = require('assert');
var browser = new Browser();
logIn();
console.log('logged in successfully');
function logIn() {
@i
i / npowerk.c
Created December 17, 2013 22:43
Sexy way to calculate numbers raised to some exponent
#include <stdio.h>
#include <stdlib.h>
int total;
void npowerk(int n, int k) {
int i;
if (k > 0)
for (i = 0; i < n; i++)
npowerk(n, k - 1);
@i
i / gist:9224676
Created February 26, 2014 06:36
twitch script
INRES="1366x768" # input resolution
FPS="20" # target FPS
QUAL="fast"
URL="rtmp://live-jfk.twitch.tv/app/key"
ffmpeg -f x11grab -s "$INRES" -r "$FPS" -i :0.0 \
-f alsa -i hw:0,0 -ac 2 -vcodec libx264 -crf 30 -preset "$QUAL" -s "$INRES" \
-acodec libmp3lame -ab 96k -ar 44100 -threads 0 -pix_fmt yuv420p \
-f flv "$URL"
@i
i / fallacy.js
Created March 30, 2014 19:24
JavaScript fallacy
if ('0')
console.log("'0' is true")
if (0)
console.log("0 is true")
else
console.log("0 is false")
if ('0' == 0)
console.log("'0' is 0")
@i
i / gist:10574214
Last active August 29, 2015 13:59
authenticate with venmo webhook
require 'sinatra'
set :port, 3000
get '/webhook_url' do
return params[:venmo_challenge].to_s
end
@i
i / factorial.js
Created May 8, 2014 23:31
corecursive factorial
function fact(x) {
return (function f(n, m, x) {
if (n == x) return m;
return f(n+1, m*(n+1), x)
})(0, 1, x);
}
@i
i / gist:538f9c61c7d6386185a7
Created September 30, 2014 05:47
pthread example
#include <stdio.h>
#include <pthread.h>
#define THREAD_COUNT 10
// Each thread will run an
// instance of this function
void *worker(void *arg) {
printf("I'm worker #%d\n", (int)arg);
return NULL;
#include <stdio.h>
#include <pthread.h>
#define THREAD_COUNT 30
// Each thread will run an
// instance of this function
void *worker(void *arg) {
printf("I'm worker #%d\n", (int)arg);
return NULL;