Skip to content

Instantly share code, notes, and snippets.

View jedisct1's full-sized avatar

Frank Denis jedisct1

View GitHub Profile
@jedisct1
jedisct1 / Twitter OAuth2
Created March 15, 2011 13:01
Twitter API with OAuth2
Browse:
https://oauth.twitter.com/2/authorize?oauth_callback_url=http://www.example.com/&oauth_mode=flow_web_client&oauth_client_identifier=7ynojZQ3uVE2DifWftbS3w
After authentication, user gets redirected to:
http://www.example.com/#oauth_access_token=RnEJAQAAAABpYH8NAAAAAGKSBQAAAAAAr9G2hLrnXaznri8LlSIaR0HuNBI=HLx1r47oqpobPncAm9DNeRCdySaMqoTKJcCLwnhIP&oauth_bridge_code=2wxWDd3IIZ0UW1y4oFpioWfbzTeaAlSGoJk5L6qMpGQ
...Use the API:
@jedisct1
jedisct1 / Reduce, Kaffeine, NodeJS and Redis
Created March 22, 2011 08:35
Tiny recommendation engine using Map/Reduce, Kaffeine, NodeJS and Redis
sys = require "sys";
http = require "http";
url = require "url";
connect = require "connect";
redis = require "redis";
hashRing = require "hash_ring";
Sharding = {
servers = { "127.0.0.1 10000 6378": 1 };
ring = new hashRing.HashRing servers;
@jedisct1
jedisct1 / pig 0.6 + json with elephant bird
Created April 5, 2011 12:25
Just a personal cheatsheet on pig+json
git clone https://github.com/kevinweil/elephant-bird.git
ant nonothing
cp lib/google-collect*jar lib/json-simple*jar /tmp/x
cd build/classes
jar -cf /tmp/x/elephant-bird.jar com
REGISTER google-collect-1.0.jar;
REGISTER json-simple-1.1.jar;
REGISTER elephant-bird.jar;
@jedisct1
jedisct1 / Greplin challenge 3.rb
Created April 5, 2011 18:17
My attempt at solving the Greplin puzzle #3
SET = [ 3, 4, 9, 14, 15, 19, 28, 37, 47, 50, 54, 56, 59, 61, 70, 73, 78, 81, 92, 95, 97, 99 ]
def find_with(set, target, expr = [ ], res = [ ])
lowset = set.select { |e| e <= target }
lowset.each do |n|
expr2 = expr + [n]
if n == target
res << "#{expr2.sort.join(' + ')} = #{expr2.inject(:+)}" unless expr.empty?
else
find_with(lowset - [n], target - n, expr2, res)
@mtigas
mtigas / gist:952344
Last active April 3, 2024 07:57
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.


Updated Apr 5 2019:

because this is a gist from 2011 that people stumble into and maybe you should AES instead of 3DES in the year of our lord 2019.

some other notes:

@jedisct1
jedisct1 / const_pnt_vs_const_array.txt
Created September 17, 2011 20:50
const char * vs const char []
#include <string.h>
size_t zob1(const char *c)
{
const char *s = "abcdefghijklmnopqrstuvwxyz";
return strspn(c, s);
}
size_t zob2(const char *c)
{
@jedisct1
jedisct1 / ldns-signzone.sh
Created March 19, 2012 19:40
ldns-signzone wrapper that understands $INCLUDE statements #dnssec #nsd
#! /bin/sh
LDNS_SIGNZONE="ldns-signzone"
errx() {
echo "$1" >&2
exit 1
}
parse_opts() {
@vjt
vjt / README.md
Last active November 25, 2020 18:45
[POC] Temporal database system on PostgreSQL with Active Record in mind

This has become a Ruby gem: https://github.com/ifad/chronomodel

A temporal database system on PostgreSQL using table inheritance and the rule system.

This is a data structure for a Slowly-Changing Dimension Type 2 temporal database, implemented using only PostgreSQL >= 9.0 features.

Any application code is completely unaware of the temporal features: queries are done against a view that behaves exactly like a plain table (it can be SELECTed, UPDATEd, INSERTed INTO and DELETEd FROM), but behind the scenes the database redirects the queries to backend tables holding actual data, using the PostgreSQL rule system.

@jedisct1
jedisct1 / latency.txt
Created July 8, 2012 04:18 — forked from h2oai/latency.txt
Latency numbers every programmer should know
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD 150,000 ns 0.15 ms
Read 1 MB sequentially from memory 250,000 ns 0.25 ms
Round trip within same datacenter 500,000 ns 0.5 ms
@jedisct1
jedisct1 / ptrace-interposing.c
Created October 4, 2012 20:19
ptrace interposing
#include <sys/types.h>
#include <sys/ptrace.h>
int ptrace_interposed(int request, pid_t pid, caddr_t addr, int data)
{
return 0;
}
const struct { void *hook_func; void *real_func; }
interposers[] __attribute__ ((section("__DATA, __interpose"))) = {