Skip to content

Instantly share code, notes, and snippets.

View riffraff's full-sized avatar

Gabriele Renzi riffraff

View GitHub Profile
Total 1 (delta 0), reused 0 (delta 0)
remote: /data/github/current/lib/github.rb:34: undefined method `env' for Rails:Module (NoMethodError)
remote: from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
remote: from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
remote: from /data/github/current/lib/rock_queue.rb:46
remote: from hooks/post-receive:14:in `require'
remote: from hooks/post-receive:14
To git@github.com:riffraff/project.git
cd2c1ce..5ded3e2 master -> master
trait Htmlizable {
def safeStr(obj:Any):String = if (obj == null) "" else obj.toString
def persistentFields: Array[Field] =
getClass.getDeclaredFields.filter( f=>
f.getAnnotation(classOf[Persistent]) != null &&
f.getAnnotation(classOf[PrimaryKey]) == null
)
def toForm(action:String): scala.xml.Elem =
<data> <# visit-unique aka unique pair ip & user agent)> (<# ip> <# UA>) <# cities> <city names>
12/Nov/2010 4 (2 * 4) 2 (Malgrate,Milan)
13/Nov/2010 2 (1 * 2) 1 (Malgrate)
14/Nov/2010 2 (2 * 1) 2 (Como,Malgrate)
15/Nov/2010 5 (3 * 3) 1 (Milan)
16/Nov/2010 6 (2 * 5) 1 (Milan)
17/Nov/2010 4 (1 * 4) 1 (Milan)
18/Nov/2010 3 (2 * 3) 1 (Milan)
mecbucpro:likex (master) riffraff$ cat >> tmp.rb
ENV['PATH']+=':ciao'
system('echo $PATH')
mecbucpro:likex (master) riffraff$ ruby tmp.rb
/Users/riffraff/.rvm/gems/ruby-1.8.7-p334/bin:/Users/riffraff/.rvm/gems/ruby-1.8.7-p334@global/bin:/Users/riffraff/.rvm/rubies/ruby-1.8.7-p334/bin:/Users/riffraff/.rvm/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:ciao
mecbucpro:likex (master) riffraff$
task 'run' => :environment do
RubyProf.start
Bullet.enable=true
Bullet.start_request
20.times do
r = Rating.limit(20).includes(:comment => :post).to_a
end
Bullet.end_request
results = RubyProf.stop
Suggestions from 2011/08/05 for non-obvious SF/Fantasy movies, with many thanks to anyone who answered. Apparently thee isn't much new for me but they were all great suggestions!
- gattaca (suggested twice. Great movie, but also quite known imho)
- dark city (loved it, generally underrated imho)
- primer (mindbending, cheaply made, very geeky)
- La jetée (TBD)
- pandorum (arguably the best "in space" movie to come out recently
- I'm a cyborg, but that's ok (not sci-fi but very enjoyable)
- Videodrome (masterpiece, very old but very famous)
- Aeon Flux (real actors movie: meh; animation: kewl)
mecbucpro:~ riffraff$ ruby -e "Float('0.0')"
_____________________________________________________________________________
| Configuration Files |
| |
| System File: /Users/riffraff/.rvm/rubies/maglev-head/etc/system.conf |
| |
| Executable File: /Users/riffraff/gem.conf |
| Warning: File not found (errno=2,ENOENT, The file or directory specified cannot
| be found) |
>> 'asd'.pronounceable?
=> 0.3333333333333333
>> 'sdf'.pronounceable?
=> 0.3333333333333333
>> 'skdf'.pronounceable?
=> 0.25
>> 'skadf'.pronounceable?
=> 0.6
>> 'skadkf'.pronounceable?
=> 0.5
@riffraff
riffraff / gist:1883670
Created February 22, 2012 09:47
ruby 1.9 regex to match s-expressions
#matches something like an s-expression
R = %r@
(?<atom> [-\w]+){0}
(?<quote> '\g<expr>){0}
(?<expr>
\g<atom> |
\g<quote> |
\(
\g<expr>
(?<exprs> (\s+ \g<expr>)* )
@riffraff
riffraff / input data
Created April 22, 2012 21:36
crash with nokogiri 1.5.2 on osx with finalizers
<!DOCTYPE html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<meta charset="utf-8">
<title>
All Topics
- The Latest News Headlines, Videos and Images