Skip to content

Instantly share code, notes, and snippets.

View biske's full-sized avatar

Ivan Bisevac (Иван Бишевац) biske

View GitHub Profile
@biske
biske / gist:29311825ba6e2ee02b45
Created October 5, 2015 16:13
Find delayed job fail jobs with certain error
Delayed::Job.where(queue: 'roundabout').where("last_error ilike ?", "%undefined method `email' for nil:NilClass\n/app/app/mailers/assessment_criterion_mailer.rb:12:in `notify_participant'%").order(updated_at: :desc).each do |job|
p YAML.load(job.handler).args.first
end
@biske
biske / restore-database.txt
Last active November 26, 2015 17:02
Restore database from Heroku to local environment
$ wget $(heroku pg:backups public-url -a legacy-next-staging) -O tmp/tti_legacy.dump
Remove all conections to database (for example shut down rails servers or rails console).
# From legacy project:
$ bundle exec rake db:drop db:create
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U ivanbisevac1 -d tti_development tmp/tti_legacy.dump
$ bundle exec rake db:migrate
# On roundabout project:
http://blog.blenderbox.com/2013/02/20/ssh-agent-forwarding-with-github/
https://help.ubuntu.com/community/PostgreSQL
sudo -u postgres psql
@biske
biske / backup and restore.txt
Last active September 25, 2015 13:38
backup and restore database from heroku to local env
$ heroku pg:backups -a tti-cedar
$ curl -o tmp/legacy-a665.dump "urlfrompreviouscommand"
Remove all conections to database (for example shut down rails servers or rails console).
# From legacy project:
$ bundle exec rake db:drop
$ bundle exec rake db:create
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U ivanbisevac1 -d tti_development tmp/legacy-a665.dump
$ bundle exec rake db:migrate
http://winstonyw.com/2014/03/03/time_now_vs_time_zone_now/
class CompressedRequests
def initialize(app)
@app = app
end
def method_handled?(env)
!!(env['REQUEST_METHOD'] =~ /(POST|PUT)/)
end
def encoding_handled?(env)
http://blog.mattwynne.net/2012/04/09/hexagonal-rails-introduction/
http://darwinweb.net/articles/modular-development-on-rails
+-----------------------+------------------+-----------------+
|                       | eager load paths | auto load paths |
+-----------------------+------------------+-----------------+
| Rails 3 (development) | auto loaded      | auto loaded     |
| Rails 4 (development) | auto loaded      | auto loaded     |
| Rails 3 (production)  | eager loaded     | auto loaded     |
| Rails 4 (production)  | eager loaded     | eager loaded    |
+-----------------------+------------------+-----------------+
require 'open-uri'
require 'nokogiri'
doc = Nokogiri::XML(open("http://www.blic.rs/rss/danasnje-vesti"))
items = doc.xpath("//item")
puts "Укупан број данашњих вести: #{items.count}"
items.each do |item|