Skip to content

Instantly share code, notes, and snippets.

View jedisct1's full-sized avatar

Frank Denis jedisct1

View GitHub Profile
@jedisct1
jedisct1 / agcc.pl
Created May 27, 2012 23:59
Android gcc wrapper
#!/usr/bin/perl -w
use strict;
# Copyright 2008, Andrew Ross [email protected]
# Distributable under the terms of the GNU GPL, see COPYING for details
#
# 25-10-2011 [email protected] -- Support android NDK r6. Changes
# - Directory in /usr/local/android-ndk symlink to /usr/local/android-ndk-r6
# - change arm-eabi-agcc to arm-linux-androideabi-gcc
@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 / ftell-glibc
Created July 21, 2012 01:50
Yay, glibc!
// C libraries print the file size.
// well, except glibc, that always prints 0.
#include <stdio.h>
int main(void)
{
FILE *fp = fopen("/tmp/aaa", "a+");
printf("%ld\n", ftell(fp));
fputc('x', fp);
@jedisct1
jedisct1 / nyan.diff
Created August 2, 2012 22:31
Use a Nyan cat as a placeholder for images lazily loaded by mod_pagespeed
--- lazyload_images_filter.cc.orig 2012-08-02 15:29:47.000000000 -0700
+++ lazyload_images_filter.cc 2012-08-02 15:30:10.000000000 -0700
@@ -44,10 +44,9 @@
} // namespace
-// base64 encoding of a blank 1x1 gif with GIF comment "PSA".
-const char* LazyloadImagesFilter::kBlankImageSrc = "data:image/gif;base64"
- ",R0lGODlhAQABAIAAAP///////yH+A1BTQQAsAAAAAAEAAQAAAgJEAQA7";
-
@jedisct1
jedisct1 / ipsucks.rb
Created August 22, 2012 17:16
IPSec connection time breakdown
#! /usr/bin/env ruby
require 'time'
VPN_SERVER = '67.215.68.68'
LAST_STATE = :s8
class Client
attr_reader :last_ts, :states, :done, :client_ip
[12:23:13.491][MQSessionManager.m:287]
[SESSION MANAGER] Launching login request [email protected], *mypassword*
[12:23:14.113][MQCredentialsManager.m:104]
--> credential manager storing username [email protected] and password *mypassword*
errorcode=1102, code=200, success=false, time=524, NSErrorFailingURLStringKey=https://fbprod.flipboard.com/v1/users/xauthLogin/5235?udid=676b4caaed1ed74edce5c117f0323d170896708d&tuuid=DAA54AA1-576C-47E4-89DA-406FF15B9602&userid=5235&ver=1.9.2&device=ipad-5.1.1&lang=en&locale=en_US&username=myusername&loginService=instapaper&password=mypassword, errormessage=auth failed: myusername, NSLocalizedDescription=auth failed: myusername}
@jedisct1
jedisct1 / wrong-rrset.txt
Created August 23, 2012 19:24
OpenDNS NS bug
$ drill ns sy. @sy.cctld.authdns.ripe.net
sy. 86400 IN NS sy.cctld.authdns.ripe.net.
sy. 86400 IN NS ns1.tld.sy.
sy. 86400 IN NS ns2.tld.sy.
$ drill ns sy. @208.67.222.222
sy. 170339 IN NS ns2.tld.sy.
sy. 170339 IN NS sy.cctld.authdns.ripe.net.
sy. 170339 IN NS ns1.tld.sy.
@jedisct1
jedisct1 / fix-timeout-comp.diff
Created August 27, 2012 07:10
fix-timeout-comp.diff
diff --git a/opendnscache/lib-opendnscache/fdevent_kqueue.c b/opendnscache/lib-opendnscache/fdevent_kqueue.c
index df3d645..f77c015 100644
--- a/opendnscache/lib-opendnscache/fdevent_kqueue.c
+++ b/opendnscache/lib-opendnscache/fdevent_kqueue.c
@@ -92,7 +92,7 @@ fdevent_wait(int64_t deadline, int64_t now)
timeout = 0;
}
timeout_ts.tv_sec = timeout / 1000;
- timeout_ts.tv_nsec = timeout % 1000;
+ timeout_ts.tv_nsec = (timeout % 1000) * 1000000;
@jedisct1
jedisct1 / 1995.html
Created September 1, 2012 01:59
1995
<img src=image.gif>