Skip to content

Instantly share code, notes, and snippets.

def_dataset_method :remove! do
update(:deleted => true)
end
def_dataset_method :remove!
SELECT r.created_dt as "date", sum(clicks) as "clicks", sum(impressions) as "impressions",
sum(actions) as "actions", sum(spend)/1000000 as "spend",
sum(spend)/1000000 / sum(actions) as CPA
class << self
attr_accessor :cdn, :cdn_version, :root, :js_path, :write_path
end
if defined? Merb
JSCompilation.root = Merb.root_path
JSCompilation.js_path = File.join('public','javascripts')
elsif defined? RAILS_ROOT
JSCompilation.root = RAILS_ROOT
JSCompilation.js_path = File.join('public','javascripts')
require 'rubygems'
require 'pp'
require 'faster_csv'
num = 0
file = "t.csv"
data = []
columns = []
def category=(cat)
changed_columns << :meta
self.meta ||= {}
self.meta[:category] = cat
end
user system total real
json dump 0.090000 0.010000 0.100000 ( 0.099900)
yajl parse 0.100000 0.000000 0.100000 ( 0.112986)
json parse 0.130000 0.010000 0.140000 ( 0.160023)
marshal dump 0.060000 0.000000 0.060000 ( 0.057489)
marshal parse 0.070000 0.000000 0.070000 ( 0.072296)
require 'rubygems'
require 'soap/wsdlDriver'
wsdl_url = 'https://ccuapi.akamai.com/ccuapi-axis.wsdl'
user = '[email protected]'
pass = '...'
urls = ['http://staticcdn.omgpop.com/embed/v1/omgpop-external-embed.js']
driver = SOAP::WSDLDriverFactory.new(wsdl_url).create_rpc_driver
module QikLog
def self.method_missing meth
unless logger = instance_variable_get(:"@#{meth}")
logger = Logger.new(File.join('log',"#{meth}.log"))
instance_variable_set(:"@#{meth}", logger)
end
logger
end
end
server:
:start: "merb -p 80{{instance%2}}"
:instances: 40
:environment:
merb_env: production
workers:
:start: rake resque:work
:instances: 1
:arg0: '*'
@tal
tal / gist:739427
Created December 13, 2010 19:06
Stack class with built in min value
class Stack
def initialize
@main = []
@min = []
end
def push val
@main << val