Skip to content

Instantly share code, notes, and snippets.

--- Log opened Sat Feb 23 03:34:59 2019
03:34 johnhcock (~john@174.90-149-141.nextgentel.com) has joined ##music
03:34 Irssi: ##music: Total of 56 nicks (1 ops, 0 halfops, 0 voices, 55 normal)
03:35 Irssi: Join to ##music was synced in 3 secs
03:49 <artao> ... totally off-topic ...
03:49 <artao> Is it okay to sell something on eBay if you don't immediately have the funds to ship it?
04:02 Cuckoo (~Cuckoo@unaffiliated/cuckoo) has joined ##music
04:11 <johnhcock> Hi! Anybody seen xybre recently? Or perhaps have his contact info?
04:30 StarPulse (~UserNick@cpe-172-90-170-157.socal.res.rr.com) has joined ##music
root@HP:/home/myuser# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0 2:0 1 4K 0 disk
sda 8:0 0 149,1G 0 disk
├─sda1 8:1 0 148,1G 0 part /
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 1022M 0 part [SWAP]
sdb 8:16 1 1,8G 0 disk
└─sdb1 8:17 1 1,8G 0 part /media/myuser/0C2C-FFEF
sr0 11:0 1 1024M 0 rom
@dt1973
dt1973 / 0.md
Last active October 10, 2015 12:12
def c
puts "Some content"
end
def b
puts "Some content"
end
def a
puts "Some content"

Run external scripts randomly according to probabilities ranging from 0.1 to 1.0

NOW WORKING: It shouldn't consecutively repeat the same item

Old script, working fine, but consecutively repeats the same item

airplane.rb

% ruby airplane.rb
== 20120921162512 AddMetaDataToForumThreads: migrating ========================
-- execute("CREATE EXTENSION IF NOT EXISTS hstore")
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::InvalidParameterValue: ERROR: version to install must be specified
: CREATE EXTENSION IF NOT EXISTS hstore/usr/home/www/_myapp/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.10/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `async_exec'
/usr/home/www/_myapp/vendor/bundle/ruby/2.2.0/gems/activerecord-4.1.10/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `block in execute'
@dt1973
dt1973 / test.md
Last active August 29, 2015 14:22

routes.rb

get "affiliate-products" => "application#affiliate_products"

application_controller.rb

def affiliate_products
  @products = AffiliateProducts.fetch
end

Trying to load some items from this external API in the background and save to database. When done, show them to the client using Ajax.

Live app which you can run on the fly: http://runnable.com/VXIdQ6KuRrYPdhKs/rest-client-ajax (remember to run bin/delayed_job start before hitting the big green Run button)

config/routes.rb

get '/check_items_loaded', to: 'main#check_items_loaded', as: :check_items_loaded