Skip to content

Instantly share code, notes, and snippets.

View haarts's full-sized avatar

Harm Aarts haarts

View GitHub Profile
#!/bin/bash
export JRUBY_HOME=/opt/jruby/bin/
case $1 in
start)
/opt/jruby/bin/jruby --server -J-Xmx256M -J-Xms256M /var/www/calculator.delaagsterekening.nl/httpdocs/current/main.rb & 2>>/tmp/calculator.out
;;
stop)
kill `cat /var/run/calculator.pid` ;;
*)
#any of these calls can fail in which case I want to continue with the remainder
#padding each call with a begin rescue block seems stupid. Moreover this feels like a loop over an array...
def check_sites
write "checking hi..."
check_site(HI_MET_TOESTEL) { |doc| (doc/"table.collapsable") }
check_site(HI_SIM_ONLY) { |doc| (doc/"table.collapsable") }
write "checking t-mobile..."
check_site(T_MOBILE_FLEX) { |doc| (doc/'tbody') }
check_site(T_MOBILE_RELAX) { |doc| (doc/'tbody') }
check_site(T_MOBILE_MYFAVES) { |doc| (doc/'tbody') }
[["2008-08-25","14"],["2008-11-24","7"],["2008-11-27","61"],["2008-12-04","17"],["2008-12-08","64"],["2008-12-17","1"],["2009-01-06","30"],["2009-03-02","1"],["2009-03-03","45"],["2009-03-04","2"],["2009-03-06","1533"],["2009-03-09","169"],["2009-03-16","41"],["2009-03-31","2"],["2009-04-01","1"],["2009-04-20","1"],["2009-05-04","470"],["2009-05-09","59"],["2009-05-12","763"],["2009-05-13","1336"],["2009-05-14","2088"],["2009-05-17","554"],["2009-05-18","1426"],["2009-05-19","711"],["2009-05-20","1378"],["2009-05-22","928"],["2009-05-23","168"],["2009-05-25","10384"],["2009-05-26","9868"],["2009-05-27","2626"],["2009-05-29","807"],["2009-05-31","82"],["2009-06-01","59"],["2009-06-02","239"],["2009-06-03","2458"],["2009-06-04","569"],["2009-06-06","141"],["2009-06-07","392"],["2009-06-09","1028"],["2009-06-14","29"],["2009-06-16","1052"],["2009-06-18","16882"],["2009-06-20","40"],["2009-06-21","387"],["2009-06-22","3193"],["2009-06-23","5"],["2009-06-26","1109"],["2009-06-27","573"],["2009-06-28","314"],["2009
return true if some_condition
return true if some_other_condition
return true if bla
return true if aap
return true if noot
return true if mies
return true if foo
return true if bar
return false
<item title="Apple iPhone 3G 16GB Black" link="http://ds1.nl/c/?wi=69557&si=860&li=77503&dl=%2Faanbieding_informatie%2FApple-iphone-3G-16GB-zwart%2FFlex100-1jaar-Verlenging%3Futm_source%3D1001%26utm_medium%3D1&ws=" daisycon_unique_id="D27029d204c15cb272fe1721975c2a178" description="Apple iPhone 3G 16GB Black slechts 411 euro bij T-Mobile" img_medium="http://bsimg.nl/images/2/2_Aplleiphone3G16GBzwart_1.jpg" internal_id="885909254040/TMOBCVF10012" minimum_price="411.00" shipping_costs="4.95" subscription_price="100.00" category="GSM + Abonnement" gsm_brand="Apple" gsm_model="Apple iPhone 3G 16GB Black" shipping_duration="2-5 dagen" subscription_duration="12" subscription_name="Verlenging Flex 100 1 jaar" provider="T-Mobile" subscription_renewal="ja" priority="" subscription_allowance_type="" subscription_allowance_sms="" subscription_allowance_minutes="" subscription_installation_costs="" gsm_ean="" sub_category="" specification="" ean="" gsm_type="" delivery_time="" />
<item>
<title><![CDATA[Apple iPhone 3G 16GB Black]]></title>
<link><![CDATA[http://ds1.nl/c/?wi=69557&si=860&li=77503&dl=%2Faanbieding_informatie%2FApple-iphone-3G-16GB-zwart%2FFlex100-1jaar-Verlenging%3Futm_source%3D1001%26utm_medium%3D1&ws=]]></link>
<daisycon_unique_id><![CDATA[D27029d204c15cb272fe1721975c2a178]]></daisycon_unique_id>
<description><![CDATA[Apple iPhone 3G 16GB Black slechts 411 euro bij T-Mobile]]></description>
<img_medium><![CDATA[http://bsimg.nl/images/2/2_Aplleiphone3G16GBzwart_1.jpg]]></img_medium>
<internal_id><![CDATA[885909254040/TMOBCVF10012]]></internal_id>
<minimum_price><![CDATA[411.00]]></minimum_price>
<shipping_costs><![CDATA[4.95]]></shipping_costs>
<subscription_price><![CDATA[100.00]]></subscription_price>
CREATE TABLE `affiliate_new_contracts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`plan_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`contract_length` int(11) DEFAULT NULL,
`phone_brand` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`phone_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`phone_price` float DEFAULT NULL,
`price` float DEFAULT NULL,
`average_price_per_month` float DEFAULT NULL,
`phone_price_guestimate` float DEFAULT NULL,
@haarts
haarts / gist:1056741
Created June 30, 2011 17:38
One slow query
# This query takes only a fraction of a second locally and looong on heroku
# Heroku app name: floating-moon-774
# MongoHQ 'eko', app: 'app558262'
Marker.where(:finished => true, :operator_comment => false).desc(:created_at).limit(4)
# via 'heroku console':
>> puts Time.now ; 100.times { Marker.where(:finished => true, :operator_comment => false).desc(:created_at).limit(4).entries} ; puts Time.now
Thu Jun 30 07:22:40 -0700 2011
Thu Jun 30 07:23:29 -0700 2011
@haarts
haarts / gist:1640182
Created January 19, 2012 14:06
Failing Rack::Cors Rspec
# in config/application.rb
config.middleware.use Rack::Cors do
allow do
origins '*'
resource '/search*', :headers => :any, :methods => :get
end
end
# in spec/requests/cors_spec.rb
@haarts
haarts / rbenv-install-system-wide.sh
Created January 30, 2012 10:20
rbenv install and system wide install on Ubuntu 10.04 LTS.
#!/bin/bash
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential
apt-get -y install vim git-core curl zlib1g-dev libreadline-dev libssl-dev
# Install rbenv
if [ ! -d "/usr/local/rbenv" ]; then
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv