Skip to content

Instantly share code, notes, and snippets.

@connrs
connrs / qsa-polyfill-ie7.js
Created May 18, 2012 09:49
IE7 querySelectorAll polyfill
if (!document.querySelectorAll) {
document.querySelectorAll = function(selector) {
var doc = document,
head = doc.documentElement.firstChild,
styleTag = doc.createElement('STYLE');
head.appendChild(styleTag);
doc.__qsaels = [];
styleTag.styleSheet.cssText = selector + "{x:expression(document.__qsaels.push(this))}";
window.scrollBy(0, 0);
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@eirikbacker
eirikbacker / addEventListener-polyfill.js
Created June 3, 2012 19:30
addEventListener polyfill for IE6+
//addEventListener polyfill 1.0 / Eirik Backer / MIT Licence
(function(win, doc){
if(win.addEventListener)return; //No need to polyfill
function docHijack(p){var old = doc[p];doc[p] = function(v){return addListen(old(v))}}
function addEvent(on, fn, self){
return (self = this).attachEvent('on' + on, function(e){
var e = e || win.event;
e.preventDefault = e.preventDefault || function(){e.returnValue = false}
e.stopPropagation = e.stopPropagation || function(){e.cancelBubble = true}
@daichan4649
daichan4649 / ListTestActivity.java
Created June 18, 2012 06:22
ListFragment sample
package test.fragment.list;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
public class ListTestActivity extends Activity {
private static final String TAG_LIST = "list";
import time
import win32api, win32con
VK_CODE = {'left_arrow':0x25,
'spacebar':0x20,
'right_arrow':0x27}
def press(x):
win32api.keybd_event(VK_CODE[x], 0,0,0)
win32api.keybd_event(VK_CODE[x],0 ,win32con.KEYEVENTF_KEYUP ,0)
@cjgiridhar
cjgiridhar / tornadowebsocket.py
Created August 18, 2012 17:14
Tornado - WebSockets
import tornado.ioloop
import tornado.web
import tornado.websocket
class Socket(tornado.websocket.WebSocketHandler):
def open(self):
print "Socket opened"
def on_message(self, message):
self.write_message("Msg is " + message)
@jasondavies
jasondavies / LICENSE
Last active October 6, 2018 08:54
Zoom by Rectangle
Copyright 2012 Jason Davies https://www.jasondavies.com
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
@newgiin
newgiin / Sublime_Monokai.xml
Last active June 29, 2018 20:43
This theme emulates the Monokai theme found in the Sublime Text 2 editor. Must enable global-{font, fontsize, bold} and global background colour.
<?xml version="1.0" encoding="Windows-1252" ?>
<!--
Notepad++ Custom Style
Style name: Sublime Monokai
Author: Andrew Nguyen, Joni Eskelinen
Date: 2009-04-06 (last changed 2013-08-29)
Languages: php, html, css, xml, javascript, python, sql, c, c++,
assembly, bash, batch, lua at least for detail. Everything else more or less...
Info: Using Joni Eskelinin's Obsidian theme as a base, this theme
@esfand
esfand / nginxvarcore.md
Last active May 17, 2021 16:39
Nginx Variables

Embedded Variables

The ngx_http_core_module module supports embedded variables with names matching the Apache Server variables. First of all, these are variables representing client request header fields, such as $http_user_agent, $http_cookie, and so on. Also there are other variables:

  • $arg_name
    argument name in the request line
# alias to edit commit messages without using rebase interactive
# example: git reword commithash message
reword = "!f() {\n GIT_SEQUENCE_EDITOR=\"sed -i 1s/^pick/reword/\" GIT_EDITOR=\"printf \\\"%s\\n\\\" \\\"$2\\\" >\" git rebase -i \"$1^\";\n git push -f;\n}; f"
# edit all commit messages
git rebase -i --root
# clone all your repos with gh cli tool
gh repo list --json name -q '.[].name' | xargs -n1 gh repo clone