Skip to content

Instantly share code, notes, and snippets.

View uu59's full-sized avatar

uu59

View GitHub Profile
# https://github.com/igrigorik/em-http-request/blob/master/examples/fibered-http.rb
require "pp"
require "rubygems"
require "eventmachine"
require "em-http"
require "fiber"
module Foo
EM < ::EventMachine
defscrollback 5000
escape ^Jj
msgwait 1
logfile "/tmp/log-screen-%Y%m%d-%n.log"
deflog on
cjkwidth on
caption always "%{= Kw}%n %t"
hardstatus alwayslastline "%{= kw}%`%-w%{=b rw}%n %t%{-}%+w %= [%Y-%m-%d %02c]"
@uu59
uu59 / b.rb
Created January 5, 2012 18:04
# http://patshaughnessy.net/2012/1/4/never-create-ruby-strings-longer-than-23-characters
require 'benchmark'
ITERATIONS = 2000000 # original script was 1000000
def run(str, bench, op=nil)
p = case op
when :<<
lambda { new_string = str << "x" } # String#<< は破壊的なので毎回strも変わる
#!/bin/bash
source $HOME/.bash_profile
ulimit -m 4194304
ulimit -v 1024000
ulimit -a
/usr/bin/google-chrome $CHROME_OPTIONS
# -- coding: utf-8
require "pp"
require "rubygems"
require 'sinatra'
require 'sinatra/base'
module Sinatra
module Helpers
class Stream
#!/bin/bash
# https://gist.github.com/634586
ID=$1
if [ -z "$ID" ];then
echo "Usage: ${0} [snowflake id]"
exit 0
fi
<!DOCTYPE html>
<html lang="ja">
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
var LS = {
_: {},
_timer: null,
from http://project-p.jp/halt/?p=1726
$ sed -r 's/^.+;| .+$//g' ~/.zsh-history|sort |uniq -c |sort -nr|head -n 30
2224 git
1869 ruby
1390 sudo
1364 vim
1117 cd
889 ls
755 find
@uu59
uu59 / gist:2375573
Created April 13, 2012 10:09
filter_var vs. preg_match
<?php
// http://nob-log.info/2012/04/12/phper-filter-validate-email/
$times = 10000;
$result = array();
// preg_match
// regexp is stolen from:
// https://github.com/php/php-src/blob/master/ext/filter/logical_filters.c#L525
@uu59
uu59 / gist:2667131
Created May 12, 2012 15:15
https://gist.github.com/2651961 `if count < 5; break`, setopt hist_ignore_all_dups in .zshrc
ci: 395
-m: 334
"added: 51
"fix: 19
"remove: 18
"fixed: 12
"changed: 6
"improve: 6
"update: 5
"use: 5