Skip to content

Instantly share code, notes, and snippets.

@eee-c
eee-c / gist:4154626
Created November 27, 2012 14:52
Ebok mobi
#!/bin/sh
echo -n "doing post mobi things..."
ebook-convert book.mobi book_ebok.mobi --chapter-mark=none --page-breaks-before='/'
mv book.mobi book.mobi.pre-calibre
mv book_ebok.mobi book.mobi
echo "done!"
@eee-c
eee-c / zlib_inflate.py
Created May 20, 2011 03:18
Inflating Multiple SPDY packets in Python and Ruby
import struct
import ctypes as C
from ctypes import util
_zlib = C.cdll.LoadLibrary(util.find_library('libz'))
class _z_stream(C.Structure):
_fields_ = [
("next_in", C.POINTER(C.c_ubyte)),
("avail_in", C.c_uint),
@eee-c
eee-c / gist:836583
Created February 21, 2011 02:19
var declarations are undefined
> var foo = "Bar"
undefined
> foo
"Bar"
> bar = "Foo"
"Foo"
diff --git a/lib/cucumber/js_support/js_language.rb b/lib/cucumber/js_support/js_language.rb
index 06ced38..c1e858f 100644
--- a/lib/cucumber/js_support/js_language.rb
+++ b/lib/cucumber/js_support/js_language.rb
@@ -24,7 +24,7 @@ module Cucumber
end
end
- @world.eval("(#{js_function.ToString})(#{js_args.join(',')});")
+ @world.eval("(#{js_function.to_s})(#{js_args.join(',')});")
@eee-c
eee-c / Canvas Tag Demo.
Created May 1, 2010 04:14
Canvas Tag Demo
<html>
<head>
<style type="text/css">
#canvas {
border: 1px solid black;
}
</style>
<script type="application/javascript">
// key codes / directions
var left = 37,
fun({Doc}) ->
case {proplists:get_value(<<"id">>, Doc)} of
{undefined} ->
ok;
{Id} ->
Emit(Id, Doc);
_ ->
ok
end
end.
bash$ irb
>> class Foo; @@foo = :foo; class << self; def inside_foo; @@foo; end end end
=> nil
>> class << Foo; def outside_foo; @@foo; end end
=> nil
>> Foo.inside_foo
=> :foo
>> Foo.outside_foo
(irb):2: warning: class variable access from toplevel singleton method
NameError: uninitialized class variable @@foo in Object
@eee-c
eee-c / Stupid class variable tricks
Created June 4, 2009 12:33
Stupid class variable "trick"
bash$ irb
>> class Foo; @@foo = :foo; class << self; def inside_foo; @@foo; end end end
=> nil
>> class << Foo; def outside_foo; @@foo; end; def outside_get_foo; send(:class_variable_get, :@@foo); end end
=> nil
>> Foo.inside_foo
=> :foo
>> Foo.outside_foo
(irb):2: warning: class variable access from toplevel singleton method
NameError: uninitialized class variable @@foo in Object