Skip to content

Instantly share code, notes, and snippets.

View zenlor's full-sized avatar
⚖️
balancing terrain generation

Lorenzo Giuliani zenlor

⚖️
balancing terrain generation
View GitHub Profile
#!/usr/bin/env bash
#
#
# rai.tv - mplayer per rai.tv :P
#
#~$> ./rai.tv.sh http://www.rai.tv/dl/RaiTV/programmi/media/ContentItem-6b72f482-f5bf-4d28-bb1a-f04d1f99a984.html?p=0
#
#cheers :)
#
PLIST=
module Sinatra
class Base
def call!(env)
@env = env
@request = Request.new(env)
@response = Response.new
@params = indifferent_params(@request.params)
force_encoding(@params)
@zenlor
zenlor / app.rb
Created April 15, 2011 12:48
app.rb
require 'sinatra/base'
require 'padrino-helpers'
class SimpleObject
attr_accessor :foo, :bar, :moo, :goo
end
class App < Sinatra::Base
register Padrino::Helpers
@zenlor
zenlor / app.rb
Created April 15, 2011 12:49
Padrino form_for bug ?
require 'sinatra/base'
require 'padrino-helpers'
class SimpleObject
attr_accessor :foo, :bar, :moo, :goo
end
class App < Sinatra::Base
register Padrino::Helpers
Rubinius Crash Report #rbxcrashreport
Error: signal SIGSEGV
[[Backtrace]]
0 rbx 0x000000010000f1d0 _ZN8rubiniusL12segv_handlerEi + 160
1 libSystem.B.dylib 0x00007fff883df66a _sigtramp + 26
2 ??? 0x00007fff5fbf36e0 0x0 + 140734799754976
3 libSystem.B.dylib 0x00007fff883c0ad7 vsnprintf + 355
4 rbx 0x00000001001a7173 rb_raise + 211
@zenlor
zenlor / config.json
Created June 13, 2011 16:53
simple config-keeper for Padrino and MongoMapper
{
"site":{
"locales":["it"],
"acl":{
"admin":["links","photos","posts","pages","taxonomy"]
}
}
}
<% taxons.each do |t| -%>
<% if t.class == Array -%>
<%= partial "taxonomy/chooser", :locals => { :f => f, :taxons => t } %>
<% else -%>
<span style="margin-left: <%= 15*t.depth %>px">&nbsp;</span>
<input type='checkbox' name="taxonomy[]" value="<%= t.id %>" <%= tax_checked?(t.id, f.object.taxonomy) %> ><%= t.title %><br>
<% end -%>
<% end -%>
/* settings */
var showDuration = 6000,
container = $('#yoga_wrapper'),
images = container.find('img').css({"opacity":"0"}),
currentIndex = 0;
/* worker */
var show = function() {
$(images[currentIndex]).animate({"opacity":0});
$(images[currentIndex = currentIndex < images.length - 1 ? currentIndex + 1 : 0]).animate({"opacity":1});
};
@zenlor
zenlor / Rakefile
Created June 25, 2011 15:10
deployer per uomini poveri e molto lazy
require "yajl/json_gem"
JSON_TEMPLATE = {
mongo:{
host:"127.0.0.1",
name:"user",
user:"user",
password:"password"
},
deploy:{
@zenlor
zenlor / mongo_pubsub.rb
Created August 30, 2011 13:58 — forked from octplane/mongo_pubsub.rb
Simple Pub/Sub system using MongoDB, capped collections and tailable cursors in ruby
require 'rubygems'
require 'mongo'
module MongoPubSub
QUEUES_COLLECTION = 'queues'
class EndSubscriptionException < Exception; end
class Publisher
def initialize(queue_name, mongo_connection)
# Initialize queue collection as a capped collection
if not mongo_connection[QUEUES_COLLECTION].collection_names.include?(queue_name)