Skip to content

Instantly share code, notes, and snippets.

View luikore's full-sized avatar

luikore luikore

View GitHub Profile
@luikore
luikore / rsec is faster than parsec!
Created December 30, 2010 06:46
rsec is faster than parsec
user system total real
rsec result: 32918.38
0.109000 0.000000 0.109000 ( 0.107006)
rsec rpn: 32918.38
0.140000 0.000000 0.140000 ( 0.154009)
treetop result: 32918.38
1.638000 0.000000 1.638000 ( 1.638094)
@luikore
luikore / 1.part.md
Created March 17, 2011 08:56
runt unit/functional test of current file and output html for textmate

Playing with TextMate is fun, but I can't find any bundle that can make running a single-file unit test or functional test easily.

Effect

So I want to custom a command:

  • By pressing key, TextMate will figure out which test to run.

    When the opened file is app/controllers/abc_controller.rb, the test file is test/functional/abc_controller_test.rb

@luikore
luikore / bash prompt
Created March 25, 2011 04:13
lambda-like bash prompt with git / rvm hints
# mac port installs bash_completion in /opt/local
if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
# *
export GIT_PS1_SHOWDIRTYSTATE=1
# $
export GIT_PS1_SHOWSTASHSTATE=1
# %
# export GIT_PS1_SHOWUNTRACKEDFILES=1
export PS1='\[\e[32m\]λ \w\[\e[36m\]$(__git_ps1 " (%s)") [$(~/.rvm/bin/rvm-prompt i v)]\[\e[0m\]\n\[\e[32m\]→\[\e[0m\] '
@luikore
luikore / sniff_ssl.rb
Created March 25, 2011 05:22
inspect http connect request
require "eventmachine"
module SSLHandler
# an SSLHandler is created for every request
def initialize
@state = :head
end
def receive_data data
case @state
@luikore
luikore / pager.rb
Created March 30, 2011 12:30
pagination with grouped index, just proof of concept, should use uuid instead of mutex
require "mongo"
class Pager
db = Mongo::Connection.new.db 'pager'
DOCS = db.collection 'docs'
INDEX = db.collection 'index'
STATE = db.collection 'state'
THRESHOLD = 1000
STATE_LOCK = Mutex.new
@luikore
luikore / gist:895967
Created March 31, 2011 07:36
encrypt
alias base64="openssl base64"
alias aes="openssl aes-256-cbc"
@luikore
luikore / hoptoad-link.js
Created April 19, 2011 07:05
This bookmarklet makes all hoptoad trace openable by textmate. Change prj and gem for different projects.
@luikore
luikore / tex.js
Created June 9, 2011 04:40
bookmarklet for latex formula wrapped with [;...;], \[...\], $$...$$, $...$
javascript:(function(){
var R = /\[;.+?;\]|\\\[.+?\\\]|\$\$.+?\$\$|\$.+?\$|./g;
/* var R = /\[;.+?;\]|\\\[.+?\\\]|\$\$.+?\$\$|./g; */
var spanClick = function(){
this.nextElementSibling.style.display = 'inline';
this.style.display = 'none'
};
var imgClick = function() {
@luikore
luikore / gc.hpp
Created September 24, 2011 15:52
Incremental tri-color GC
#pragma once
#include <stdlib.h>
#include <stdint.h>
#include <stack>
#include "obj.hpp"
using namespace std;
class GC {
Obj head;
@luikore
luikore / clean_url.user.js
Created January 18, 2012 05:06
Stop google tracking search click with redirect
// ==UserScript==
// @match https://www.google.com/*
// ==/UserScript==
interval = 400
clean = function(){
console.log('cleaning')
var links = document.querySelectorAll('#search h3 a')
var i
for(i=0; i<links.length; i++){