Skip to content

Instantly share code, notes, and snippets.

View hyfather's full-sized avatar

Nikhil Mungel hyfather

View GitHub Profile
@hyfather
hyfather / euler_two.rb
Created November 13, 2011 20:35
My solution to problem #2 on projecteuler.net
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
@hyfather
hyfather / euler_three.rb
Created November 14, 2011 06:20
My solution to problem #3 on projecteuler.net
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
@hyfather
hyfather / ssh-copy-id
Created December 16, 2011 08:05
ssh-copy-id
#!/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.
@hyfather
hyfather / github_stacktrace
Created June 20, 2012 11:17
github post receive hook stacktrace
% 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'
@hyfather
hyfather / init.el
Last active August 29, 2015 14:01
my_emacs_init.el
(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
@hyfather
hyfather / pipeline.go
Created April 6, 2018 23:13
Go Pipelines
package main
import (
"log"
"sync"
"time"
)
func main() {
log.Println("start")