Skip to content

Instantly share code, notes, and snippets.

View igorb's full-sized avatar

Igor Bilan igorb

View GitHub Profile
namespace :db do desc "Backup project database. Options: DIR=backups RAILS_ENV=production MAX=7"
task :backup => [:environment] do
datestamp = Time.now.strftime("%Y-%m-%d_%H-%M-%S")
base_path = Rails.root
base_path = File.join(base_path, ENV["DIR"] || "backups")
backup_base = File.join(base_path, 'db_backups')
backup_folder = File.join(backup_base, datestamp)
backup_file = File.join(backup_folder, "#{RAILS_ENV}_dump.sql")
FileUtils.mkdir_p(backup_folder)
db_config = ActiveRecord::Base.configurations[RAILS_ENV]

Debugging & Profiling Node.js

This is a maintained listing of all the different ways to debug and profile Node.js applications. If there is something missing or an improvement, post a comment! :)

Interactive Stack Traces with traceGL - Shareware

  1. Guide here
def login_as(user)
raise "Was expecting a User. Got a #{user.class} instead. Exiting." if user.class != User
@controller.request.env['warden'] = mock(
Warden,
:authenticate => user,
:authenticate! => user,
:authenticated? => true,
:authenticate? => true
)
user.last_sign_in_at = Time.now
@igorb
igorb / dump_restore_scp.md
Created August 23, 2013 07:55
backup/restore mysql backup/restore redis scp

1. backup/restore mysql

backup: mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql

restore: mysql -u root -p[root_password] [database_name] < dumpfilename.sql

mysqldump -u appzone -pP@rtnerpedia appzone_qa > 1.sql

2. backup/restore redis(http://code.google.com/p/redis-dump/)

@igorb
igorb / Rename_S3_resources.rb
Created September 4, 2013 09:06
rake task to rename old S3 resources according to new URL encoding
# Maintenance script needed to rename old S3 resources according to new URL encoding
desc "One-time renaming of all the amazon s3 content"
task :rename_s3_files do |t, args|
require 'aws/s3'
require Rails.root.join('app', 'helpers', 'paperclip_sanitization_helper.rb')
cred = YAML.load(File.open("#{Rails.root}/config/s3.yml"))[Rails.env].symbolize_keys!
attr_bucket = cred.delete(:bucket)
AWS::S3::Base.establish_connection! cred
@igorb
igorb / links.textile
Created September 30, 2013 12:00 — forked from ilatif/links.textile

In order to demo your feature specs, follow these steps:

  1. Add capybara, poltergeist, launchy and selenium-webdriver to your Gemfile under test and development group.
  2. Add the attached demo helper to your spec/support.
  3. Add the capybara config to your spec_helper file.
  4. Run bundle install.
  5. Write your feature with its scenario specs.
  6. Put a demo filter on each scenario you want to demo. ( refer to the example below )
  7. Run bundle exec rspec spec.
require 'spec/support/grep_matcher'
describe do
disallow_presence_of pattern: "send(.*#",
location: "app/",
description: "Do not use dynamic method invocations",
failure: "Please change dynamic method call to something more sane."
end
@igorb
igorb / gist:8696fab31ef8e409913e
Created March 5, 2015 10:04
remove branches & temporary files
git checkout master && git branch | grep -v "master" | xargs git branch -D
find . -name \*.swo -type f -delete
find . -name \*.swp -type f -delete
2015-09-27T16:49:32.499Z 20607 TID-oxqcy0uyc Gnip::DownloadWorker JID-a5fe6232f54b78156e1068a4 INFO: done: 5.392 sec
2015-09-27T16:49:32.506Z 20607 TID-oxqdn2bn0 Gnip::DownloadWorker JID-6c6935f07def12d984bb7b82 INFO: start
2015-09-27T16:49:32.515Z 20607 TID-oxqcy0uyc Gnip::DownloadWorker JID-232e8e816a9b956bc7221669 INFO: start
2015-09-27T16:49:32.516Z 20607 TID-oxqdn67x0 Gnip::DownloadWorker JID-376da939d0e1b0c915b59a1c INFO: start
downloading /Users/igorb/work/verifeed-twitter/downloads/7q29mfvq74/2015/08/01/01_40_activities.json...
2015-09-27T16:49:33.225Z 20607 TID-oxqe01c8w Gnip::DownloadWorker JID-1686444e5f46ee87f5ca8db5 INFO: done: 6.133 sec
2015-09-27T16:49:33.232Z 20607 TID-oxqe01c8w Gnip::DownloadWorker JID-10cdf58624f007f44bbb48f3 INFO: start
downloading /Users/igorb/work/verifeed-twitter/downloads/7q29mfvq74/2015/08/01/01_50_activities.json...
2015-09-27T16:49:34.791Z 20607 TID-oxqe01myg Gnip::DownloadWorker JID-c2e53aacf2a8eee9efeac039 INFO: done: 7.645 sec
2015-09-27T16:49:34.805Z 20607 TID-ox