Skip to content

Instantly share code, notes, and snippets.

View joncode's full-sized avatar
🏠
Launching Apps

Jon Anders joncode

🏠
Launching Apps
  • Agent1 / Suma / Squad.fyi / Splice / Lucera / Couchtour.tv / Hedera / Giftlocal / Sarson Funds / Dial / Manifest.ai
  • Philadelphia, PA
View GitHub Profile
@joncode
joncode / gist:354fdec19a2a18feb11b
Created September 9, 2014 17:32
Launching a dev resque server
run the redis server
1. in the command line
redis-server
2. start the rails server
rs
3. start the resque rake task
QUEUE=* rake resque:work
@joncode
joncode / gist:b5232631d8227c3ab7d0
Last active August 29, 2015 14:05
Heroku Platform-api commands
heroku = PlatformAPI.connect_oauth('f04asdfbd-18e5-4486-b4df-873asdfa')
heroku.app.info('dbappdev')
heroku.formation.list('dbappdev')
heroku.dyno.list('dbappdev')
heroku.dyno.info('dbappdev', dyno_id)
@joncode
joncode / gist:ba9325652ab51bf32c70
Last active August 29, 2015 14:05
Resque commands
http://www.rubydoc.info/gems/resque/frames
Resque.info
{:pending=>0, :processed=>157473, :queues=>7, :workers=>21, :working=>0, :failed=>0, :servers=>["redis://barb.redistogo.com:9497/0"], :environment=>"production"}
Resque.workers
returns an array of workers available
Resque.workers.each {|w| w.prune_dead_workers }
kills dead workers
w = Resque.workers[0]
@joncode
joncode / gist:4887c23a894731e79fff
Created August 7, 2014 00:06
to see what foreign keys in your app havent been indexed
c = ActiveRecord::Base.connection
c.tables.collect do |t|
columns = c.columns(t).collect(&:name).select {|x| x.ends_with?("_id" || x.ends_with("_type"))}
indexed_columns = c.indexes(t).collect(&:columns).flatten.uniq
unindexed = columns - indexed_columns
unless unindexed.empty?
puts "#{t}: #{unindexed.join(", ")}"
end
end
@joncode
joncode / gist:9dcb021e2ef11c632b14
Created July 24, 2014 23:04
Retry code for resque jobs
module RetryOnTermJob
def around_perform_retry_on_term(*args)
begin
yield *args
rescue Exception => e
if e.message =~ /SIGTERM/
# when a worker `extend`s this class, self is that worker class
Resque.enqueue(self, *args)
else
raise
@joncode
joncode / gist:6980048
Last active December 25, 2015 12:59
changing databases heroku psql

go to heroku.com the site you are upgrading

  1. add the new database - we chose 'CRANE' for 50$ / month

     heroku addons:add heroku-postgresql:crane        
    
  2. in console

     heroku pg:wait --remote staging
    
@joncode
joncode / gist:6702230
Created September 25, 2013 16:28
MOVING A BRANCH POINTER
git reset --hard 10123974102937840192374
this moves the pointer to that commit. This is what you want most of the time
git reset --soft 0238947293842937429384723
this moves the pointer and via an index that you commit , very strange.
@joncode
joncode / gist:6601579
Created September 17, 2013 22:30
STASH apply
git stash
stash the last commit
git stash apply
applies the last stash
git stash apply stash@{2}
if you want one of the older ones
git stash drop with the name of the stash to remove:
@joncode
joncode / gist:6300104
Last active December 21, 2015 11:38
Creating a .CSR and making a domain SSL
@joncode
joncode / gist:6274015
Last active December 21, 2015 07:49
Attachinary how to add ...

Setup


  1. add the cloudinary and attachinary Rails 4 gems

    gem 'cloudinary'

    gem 'attachinary', git: 'git://github.com/rochers/attachinary.git', branch: 'rails4'