Skip to content

Instantly share code, notes, and snippets.

View tinco's full-sized avatar

Tinco Andringa tinco

View GitHub Profile
How big is a tab?
about this big..
this is two spaces
four spaces
eight spaces
Caching on DM is a bit weird because of the lazy loading.
Modelname.all would return a query object instead of a result set. The result set would only be generated when an attribute would actually be accessed.
Modelname.caches.all using the existing cache_fu would just return a cached query, not the results.
Proposal: Have caches be proxy for Modelname, that overrides the actual load/write by the cached methods.
diff --git a/ug-gadget/vendor/gems/httparty-0.5.2/lib/httparty/request.rb b/ug-gadget/vendor/gems/httparty-0.5.2/lib/httparty/request.rb
index 67ac94f..a7089da 100644
--- a/ug-gadget/vendor/gems/httparty-0.5.2/lib/httparty/request.rb
+++ b/ug-gadget/vendor/gems/httparty-0.5.2/lib/httparty/request.rb
@@ -104,7 +104,12 @@ module HTTParty
def setup_raw_request
@raw_request = http_method.new(uri.request_uri)
- @raw_request.body = body if body
+ if body
# f(f') {f(1)}, g(x1, x2, x3) {}, main{ f(g(2, 3)}
def curry(*params, &block)
lambda {|*curry_params| block.call(*(params.dup.concat(curry_params)))}
end
##usage:
g = lambda {|x1, x2, x3| puts "x1: #{x1}, x2: #{x2}. x3 #{x3}"}
f(1, 2, &g).call(3)
#=> x1: 1, x2: 2. x3 3
diff --git a/vendor/gems/cache-money-0.2.5/lib/cash/query/abstract.rb b/vendor/gems/cache-money-0.2.5/lib/cash/query/abstract.rb
index 48a3476..9715a32 100644
--- a/vendor/gems/cache-money-0.2.5/lib/cash/query/abstract.rb
+++ b/vendor/gems/cache-money-0.2.5/lib/cash/query/abstract.rb
@@ -70,7 +70,8 @@ module Cash
end
def cache_keys(attribute_value_pairs)
- attribute_value_pairs.flatten.join('/')
+ #This is a hack to allow for extremely long queries:
--trace ree
rvm 0.1.38 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]
+ [[ -z '' ]]
+ [[ ! -z ree ]]
+ rvm_action=use
+ [[ ! -z '' ]]
+ [[ ! -z '' ]]
+ [[ 1 -gt 0 ]]
command -nargs=1 IndentStyle call IndentStyle("<args>")
let g:IndentStyle = "none"
fun IndentStyle(style)
if a:style == "ruby"
"ruby style:
set tabstop=2
set shiftwidth=2
set expandtab
@tinco
tinco / BuzzFizz.hs
Created May 4, 2012 21:39
Inverse of FizzBuzz implementation in Haskell
isFizz i = mod i 3 == 0
isBuzz i = mod i 5 == 0
isFizzBuzz i = isFizz i && isBuzz i
isFizzOrBuzz i = isFizz i || isBuzz i
isNeither i = (not.isBuzz) i && (not.isFizz) i
toFizzBuzz i
| isFizzBuzz i = "FizzBuzz"
| isFizz i = "Fizz"
| isBuzz i = "Buzz"
@tinco
tinco / gist:3773216
Created September 23, 2012 22:08
RVM openssl error
[tinco@MacBook ~] rvm pkg install openssl
Fetching openssl-1.0.1c.tar.gz to /Users/tinco/.rvm/archives
There is no checksum for 'http://www.openssl.org/source/openssl-1.0.1c.tar.gz' or 'openssl-1.0.1c.tar.gz', it's not possible to validate it.
If you wish to continue with unverified download add '--verify-downloads 1' after the command.
Extracting openssl-1.0.1c.tar.gz to /Users/tinco/.rvm/src
Error running 'tar', please read /Users/tinco/.rvm/log/openssl/extract.log
/Users/tinco/.rvm/scripts/functions/pkg: line 52: cd: /Users/tinco/.rvm/src/openssl-1.0.1c: No such file or directory
Configuring openssl in /Users/tinco/.rvm/src/openssl-1.0.1c.
Error running './Configure', please read /Users/tinco/.rvm/log/openssl/configure.log
@tinco
tinco / concurrent_sieve.hs
Created November 18, 2012 15:39 — forked from tmhedberg/concurrent_sieve.hs
Concurrent prime sieve translated from Go (http://play.golang.org/p/9U22NfrXeq)
-- Compile with `ghc -threaded -with-rtsopts=-N concurrent_sieve.hs`
import Control.Concurrent
import Control.Monad
import System.Environment
-- Map over [2..] (2 until infinity), putting the value in mOut. The putting operation will block until
-- mOut is empty. mOut will become empty when some other thread executes takeMVar (getting its value).
generate :: MVar Int -> IO ()