Skip to content

Instantly share code, notes, and snippets.

View etozzato's full-sized avatar
💀
I work hard so my cat doesn't have to

Emanuele Tozzato etozzato

💀
I work hard so my cat doesn't have to
View GitHub Profile
class Integration < Remote
has_many :queries
has_many :clicks, :finder_sql => 'SELECT DISTINCT clicks.* FROM clicks c, queries q WHERE c.query_id = q.id AND q.integration_id = #{id}'
end
function scroll(direction) {
var newsHeight = ($('#home_news_list').height());
var newsContainerHeight = 190;
if (direction == "up"){
topVal += increment;
if (topVal > 0){
topVal = 0;
var stop = true;
class String
def to_path
return self.gsub('http://', '').gsub(/[@\.]/, '_').gsub(/[^a-zA-Z0-9_]/, '').strip.downcase
end
end
module Indexes
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def indexes
@indexes ||= ActiveRecord::Base.connection.indexes(table_name).map(&:name)
end
# expires_at '21:30', :public => true, :private => false
# will set max-age to the amount of seconds between now and tomorrow at 9:30PM
module ExpiresAt
def self.included(base)
base.send(:include, InstanceMethods)
end
module InstanceMethods
class Tag < ActiveRecord::Base
attr_accessor :name
def self.localized_tags(type)
@localized_tags ||= {}
@localized_tags[:tags] ||= find(:all, :select=> "`key`, 'name', `tag_type`")
language = I18n.locale.to_sym
if @localized_tags[language].nil?
@localized_tags[language] ||= []
@localized_tags[:tags].each do |tag|
def start(&block)
raise ServerError, "already started." if @status != :Stop
server_type = @config[:ServerType] || SimpleServer
server_type.start{
@logger.info \
"#{self.class}#start: pid=#{$$} port=#{@listeners[0].addr[1]}"
call_callback(:StartCallback)
thgroup = ThreadGroup.new
// NOTE: all the form items call make_ssid(); onChange
function true_false(value){
if (value == false)
return '0'
else
return '1'
}
function make_ssid(){
class Team
def self.nickname_by_id(id=nil)
return 'n/a' unless id
@nicknames ||= ["Orioles",
"Red Sox",
"Yankees",
"Rays",
"Blue Jays",
"White Sox",
#!/usr/bin/ruby
apps = %w(my-audi my-bmw my-ferrari my-ford my-jeep my-landrover my-toyota my-volvo myacura mycadillac mychevrolet mychrysler mydodge mygmc myhonda myhummer myjaguar mylexus mylotus mymaserati mymazda mymercedes-benz mymini mymitsubishi mynissan myporsche myrover mysaab mysmart mysubaru myvolkswagen)
if File.exist?('/home/etozzato/my/logs/feed.id')
feed_id = File.read('/home/etozzato/my/logs/feed.id').to_i
`echo '#{feed_id + 1}' > /home/etozzato/my/logs/feed.id`
if feed_id > webs.size-1
feed_id = 0
`echo '#{feed_id + 1}' > /home/etozzato/my/logs/feed.id`