This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def fibselect(&block) | |
o, i, array = 0, 1, [] | |
while i < length | |
o, i = i, i+o | |
array << self[i] | |
end | |
array.compact.select &block | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def factorize(list, num, p) | |
while true | |
list.each_with_index { |e, i| list[i] = 0 if e!=p && e%p == 0 } | |
list.each{|e| p = e and break if e > p} | |
if num % p == 0 | |
# p num | |
return factorize(list[p..Math.sqrt(num/=p)], num, p) | |
end | |
return num if list.empty? | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ssh-add | |
ssh $1 "mkdir -p .ssh && touch .ssh/authorized_keys && echo `ssh-add -L` >> .ssh/authorized_keys" | |
# keep this file in the PATH. like in /usr/bin. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% git push | |
Counting objects: 26, done. | |
Delta compression using up to 8 threads. | |
Compressing objects: 100% (14/14), done. | |
Writing objects: 100% (15/15), 20.28 KiB, done. | |
Total 15 (delta 9), reused 0 (delta 0) | |
remote: /data/github/current/vendor/gems/ruby/1.8/gems/redis-2.2.0/lib/redis/connection/hiredis.rb:23:in `connect': Timeout::Error (Timeout::Error) | |
remote: from /data/github/current/vendor/gems/ruby/1.8/gems/redis-2.2.0/lib/redis/client.rb:204:in `establish_connection' | |
remote: from /data/github/current/vendor/gems/ruby/1.8/gems/redis-2.2.0/lib/redis/client.rb:23:in `connect' | |
remote: from /data/github/current/vendor/gems/ruby/1.8/gems/redis-2.2.0/lib/redis/client.rb:224:in `ensure_connected' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'package) | |
(add-to-list 'package-archives | |
'("marmalade" . "http://marmalade-repo.org/packages/") t) | |
(package-initialize) | |
;; Use Shift + <Arrow Keys> for moving between buffers | |
(windmove-default-keybindings) | |
(setq windmove-wrap-around t) | |
;; Because Shift-Up is broken on xterm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"sync" | |
"time" | |
) | |
func main() { | |
log.Println("start") |
OlderNewer