Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View carlesso's full-sized avatar

Enrico Carlesso carlesso

View GitHub Profile
class Post
include Mongoid::Document
include Mongoid::Paranoia
include Mongoid::Timestamps
field :title, :type => String
attr_accessor :tags_string
accepts_nested_attributes_for :answers
@carlesso
carlesso / gist:1143274
Created August 12, 2011 23:47
Rails 3.1.0.rc5 clean Gemfile.lock
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.1.0.rc5)
actionpack (= 3.1.0.rc5)
mail (~> 2.3.0)
actionpack (3.1.0.rc5)
activemodel (= 3.1.0.rc5)
activesupport (= 3.1.0.rc5)
builder (~> 3.0.0)
@carlesso
carlesso / gist:1178149
Created August 29, 2011 10:26
Mod Rewrite
RewriteEngine On
Options Indexes FollowSymlinks Multiviews
RewriteBase /
RewriteCond %{HTTP_HOST} www.sito.com
RewriteCond %{REQUEST_URI} !drupal/
RewriteRule ^(.*)$ http://www.sito.com/drupal/$1 [L]
def hc_votes_per_ages
# 0-18 19-24 25-34 35-49 50-64 65-inf
now_s = Time.now.to_formatted_s(:db)
age_votes = {"0" => [], "1" => [], "2" => [], "3" => [], "4" => [], "5" => [], "6" => []}
age_labels = {"0" => "< 18", "1" => "18 - 25", "2" => "25 - 35", "3" => "35 - 50", "4" => "50 - 65", "5" => "> 65", "6" => "unknown"}
model.answers.each do |a|
query = "COUNT(users.id) as vote_count, CASE
WHEN users.birthday>(NOW() - INTERVAL '18 year') THEN 0
WHEN users.birthday<=(NOW() - INTERVAL '18 year') AND users.birthday>(NOW() - INTERVAL '25 year') THEN 1
WHEN users.birthday<=(NOW() - INTERVAL '25 year') AND users.birthday>(NOW() - INTERVAL '35 year') THEN 2
def hc_votes_per_ages(search_params = {})
# TODO apply search params
# 0-18 19-24 25-34 35-49 50-64 65-inf
now_s = Time.now.to_formatted_s(:db)
age_votes = {"0" => [], "1" => [], "2" => [], "3" => [], "4" => [], "5" => [], "6" => []}
age_labels = {"0" => "< 18", "1" => "18 - 25", "2" => "25 - 35", "3" => "35 - 50", "4" => "50 - 65", "5" => "> 65", "6" => "unknown"}
model.answers.each do |a|
query = "COUNT(users.id) as vote_count, CASE
WHEN users.birthday>(NOW() - INTERVAL '18 year') THEN 0
WHEN users.birthday<=(NOW() - INTERVAL '18 year') AND users.birthday>(NOW() - INTERVAL '25 year') THEN 1
@carlesso
carlesso / word_with_classes.html.erb
Created November 18, 2011 16:40
Inverted colors
<!DOCTYPE html>
<html>
<head>
<title>jQCloud Example</title>
<link rel="stylesheet" type="text/css" href="../jqcloud/jqcloud.css" />
<style type="text/css">
<%
def css_lines(color)
new_lines = []
r = color[:target][0..1].to_i(16)
@carlesso
carlesso / Preferences.sublime-settings
Created February 24, 2012 09:12
Sublime preferences by Enrico Carlesso
// Settings in here override those in "Default/Preferences.sublime-settings", and
// are overridden in turn by file type specific settings.
{
"color_scheme": "Packages/Color Scheme - Custom/Railscasts.tmTheme",
"gutter": true,
"fade_fold_buttons": false,
"tab_size": 2,
"translate_tabs_to_spaces": true,
"draw_centered": false,
"draw_minimap_border": true,
@carlesso
carlesso / .pryrc
Created March 7, 2012 14:06
Pry configuration
# Load plugins (only those I whitelist)
Pry.config.should_load_plugins = false
# Pry.plugins["doc"].activate!
# Launch Pry with access to the entire Rails stack.
# If you have Pry in your Gemfile, you can pass: ./script/console --irb=pry instead.
# If you don't, you can load it through the lines below :)
rails = File.join Dir.getwd, 'config', 'environment.rb'
if File.exist?(rails) && ENV['SKIP_RAILS'].nil?
window.Blog =
Models: {}
Collections: {}
Views: {}
Routers: {}
init: ->
console.log(Blog.Routers.Posts)
new Blog.Routers.Posts()
Backbone.history.start()
execve("/opt/bin/mediatomb", ["mediatomb"], [/* 11 vars */]) = 0
brk(0) = 0x181cdc
open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/lib/v5b/fast-mult/half/librt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/opt/lib/v5b/fast-mult/half", 0xbffff2a0) = -1 ENOENT (No such file or directory)
open("/opt/lib/v5b/fast-mult/librt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/opt/lib/v5b/fast-mult", 0xbffff2a0) = -1 ENOENT (No such file or directory)
open("/opt/lib/v5b/fast-librt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/opt/lib/v5b/fast", 0xbffff2a0) = -1 ENOENT (No such file or directory)
open("/opt/lib/halflibrt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)