This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if object.asin.present? | |
"http://www.amazon.it/gp/product/#{object.asin}/ref=as_li_qf_br_asin_il_tl?ie=UTF8&camp=3370&creative=23322&creativeASIN=#{object.asin}&linkCode=as2&tag=swdaniele-21" | |
else | |
"http://www.amazon.it/s/ref=nb_sb_noss_1?__mk_it_IT=%C3%85M%C3%85%C5%BD%C3%95%C3%91&url=search-alias%3Ddvd&field-keywords=#{CGI::escape title}&tag=swdaniele-21" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"code": "fr", | |
"name": "French", | |
"status": "production" | |
}, | |
{ | |
"code": "en", | |
"name": "English", | |
"status": "production" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'bundler/setup' | |
require 'faye/websocket' | |
require 'eventmachine' | |
require 'json' | |
require 'pry' | |
EM.run { | |
url = ARGV[0] | |
headers = {'Origin' => 'http://faye.jcoglan.com'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WelcomeController < ApplicationController | |
def index | |
@xhr = request.xhr? | |
render :index, change: 'variable' | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0 info it worked if it ends with ok | |
1 verbose cli [ 'node', '/usr/bin/npm', 'start' ] | |
2 info using npm@2.12.1 | |
3 info using node@v0.12.6 | |
4 verbose run-script [ 'prestart', 'start', 'poststart' ] | |
5 info prestart learning-react@1.0.0 | |
6 info start learning-react@1.0.0 | |
7 verbose unsafe-perm in lifecycle true | |
8 info learning-react@1.0.0 Failed to exec start script | |
9 verbose stack Error: learning-react@1.0.0 start: `node --harmony server` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# :nocov: | |
if defined?(Rails) | |
module MyGem | |
module Rails | |
class Engine < ::Rails::Engine | |
end | |
end | |
end | |
end | |
# :nocov: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Post | |
include Mongoid::Document | |
include Mongoid::Paranoia | |
include Mongoid::Timestamps | |
field :title, :type => String | |
attr_accessor :tags_string | |
accepts_nested_attributes_for :answers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |