Skip to content

Instantly share code, notes, and snippets.

@zbskii
zbskii / yc.py
Created April 10, 2012 03:38
Y-Combinator
# -*- coding: utf-8 -*-
# a functional is a function that takes a function for its input
def fact(factorial):
def fn(n):
if n == 0: return 1
else:
return n * factorial(n - 1)
return fn
char*a[]={
"40h50mfu2!epxo0svo>spv7b7eft?u20nblf2!dsz0tbz!hppeczf0ufmm>!mjf>7ivsu2",
"44Xf(wf8o!fbdi!pui?!gps!t<mpoh4Zpvs!ifbs=bdiA-!cvu2@;p<tiz;<tbz!ju4Jotj\
ef!xf!cpui8!xib=hpA!po4Xf8;if!hbnf>7xf@9qmbz!ju44","4Ofw?9",
"J!kvtu!xboob;fmm26Hpuub!nblf2!voe?tuboe.","!zpv","0hjwf-!ofw?9hjwf4)H5*","\v",
"jwf2!vq","!ipx!J(n!gffmA4","oe!","!lopx","!hpoob!",")Pppi-!h5*4","!u","p!",
"u(t!cffo!","!b","fs","(sf","joh"};
f(char*s){for(;*s;++s)*s>45&&*s<66?f(a[*s-46]):putchar(*s-1);}
main(){f("Xf@!o<tusboh?t;<mpwf4Zpv8;if!svmft>7t<e<J4B!gvmm!dpnnjunfou"
"(t!xibu!J(n;ijolA!pg4Zpv!xpvmeo(u!hfu;ijt!gspn>oz!pui?!hvz441/B7jg2>tl!nf6"
# Add gems from vendor dir
config.autoload_paths += Dir["#{config.root}/vendor/gems/**"].map do |dir|
File.directory?(lib = "#{dir}/lib") ? lib : dir
end
@zbskii
zbskii / gist:1364885
Created November 14, 2011 19:31
RBTools fucked
Traceback (most recent call last):
File "/usr/local/bin/post-review", line 9, in <module>
load_entry_point('RBTools==0.3.4', 'console_scripts', 'post-review')()
File "/usr/local/lib/python2.7/dist-packages/rbtools/postreview.py", line 3972, in main
if not server.check_api_version():
File "/usr/local/lib/python2.7/dist-packages/rbtools/postreview.py", line 511, in check_api_version
rsp = self.api_get(root_resource['links']['info']['href'])
File "/usr/local/lib/python2.7/dist-packages/rbtools/postreview.py", line 962, in api_get
return self.process_json(self.http_get(path))
File "/usr/local/lib/python2.7/dist-packages/rbtools/postreview.py", line 932, in http_get
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/bin/post-review", line 9, in <module>
load_entry_point('RBTools==0.3.2', 'console_scripts', 'post-review')()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rbtools/postreview.py", line 3794, in main
submit_as=options.submit_as)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rbtools/postreview.py", line 3460, in tempt_fate
parent_diff_content)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rbtools/postreview.py", line 769, in upload_diff
fields, files)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/rbtools/postreview.py", line 982, in api_post
./haskell-bcrypt.cabal has been changed. Re-configuring with most recently
used options. If this fails, please run configure manually.
Configuring haskell-bcrypt-0.1...
Dependency base ==4.3.1.0: using base-4.3.1.0
Dependency bytestring ==0.9.1.10: using bytestring-0.9.1.10
Using Cabal-1.10.1.0 compiled by ghc-7.0
Using compiler: ghc-7.0.3
Using install prefix:
/Users/brett/Library/Haskell/ghc-7.0.3/lib/haskell-bcrypt-0.1
Binaries installed in:
"debug.rb"
1
true
debug.rb:33: [BUG] Segmentation fault
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0]
-- control frame ----------
c:0007 p:---- s:0023 b:0023 l:000022 d:000022 CFUNC :frame_file
c:0006 p:0080 s:0019 b:0019 l:000018 d:000018 METHOD debug.rb:33
c:0005 p:0235 s:0013 b:0013 l:000012 d:000012 METHOD debug.rb:20
require 'ruby-debug'
module Debugger
class << self
def post_mortem
self.post_mortem = true
debug_at_exit do
handle_post_mortem($!) if $! && post_mortem?
end
Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await svctm %util
sda1 0.00 0.00 0.00 1.60 0.00 0.01 8.00 0.00 0.00 0.00 0.00
sdb 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sdf 0.00 1008.19 10.89 574.33 0.15 12.31 43.62 144.71 254.95 1.71 100.00
sdm 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
C FILE: FIB1.F
PROGRAM FIB1
INTEGER X
X = 12
WRITE(*,*), FIB(X)
END PROGRAM FIB1
FUNCTION FIB(N)
C
C CALCULATE THE NTH FIBONACCI NUMBER