Skip to content

Instantly share code, notes, and snippets.

View nordringrayhide's full-sized avatar

Nodrin Grayhide nordringrayhide

  • home
  • Worldwide
View GitHub Profile
require 'fileutils'
namespace :db do
desc 'pull the production PostgreSQL database into the development SQLite'
task :pull do
Rake::Task['db:download_pg_dump'].invoke
Rake::Task['db:optimze_pg_dump_for_sqlite'].invoke
Rake::Task['db:recreate_with_dump'].invoke
end
@nordringrayhide
nordringrayhide / input.conf
Last active August 29, 2015 14:08
Mplayer key mapping config
# key-bindings:
left seek -4
right seek 2
up speed_incr 0.01
down speed_incr -0.01
- volume -1
= volume 1
require "xmlsimple"
def transactions(filename)
data = XmlSimple.xml_in(filename)
data["LIST_G_CLIENT"][0]['G_CLIENT'][0]['LIST_G_ACC_CURR'][0]['G_ACC_CURR'][0]['LIST_G_TRANS_CARD'][0]['G_TRANS_CARD'][1]['LIST_G_TRANS_DETAILS'][0]['G_TRANS_DETAILS']
end
fields = %w(TRANS_DATE_XML TRANS_AMOUNT TRANS_CURR ACC_AMOUNT TRANS_DETAILS )
puts fields.join(", ")
[core]
...
[remote "dokku"]
url = git@remote:appname
fetch = +refs/heads/*:refs/remotes/dokku/*

Deploy Rails 4 app with Dokku on DigitalOcean

Install dokku

First create a Ubuntu 13.04 x64 droplet on DigitalOcean Control Panel

Then ssh with root account, run this in termianl:

$ wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | sudo bash
@nordringrayhide
nordringrayhide / user_spec.rb
Created February 8, 2013 09:49
factory girl build_stubbed example
class User < ActveRecord::Base
def full_name
"#{ last_name } #{ first_name }"
end
end
describe User do
# in this case a real AR object needless
# profit => speed up, more test isolation(test does not fail when database connection is broken)
@nordringrayhide
nordringrayhide / routes.rake
Created August 12, 2012 15:43 — forked from masterkain/routes.rake
Journey + Graphviz
namespace :routes do
desc "Writes doc/routes.html. Requires Graphviz (dot)"
task :visualizer => :environment do
File.open(Rails.root.join('doc', 'routes.html'), 'wb') do |f|
f.write Rails.application.routes.router.visualizer
end
end
end
@nordringrayhide
nordringrayhide / multiple_inheritance.rb
Created August 10, 2012 07:51
Ruby Multiple inheritance
module A
def foo
'A#foo'
end
end
module B
def foo
'B#foo'
end
@nordringrayhide
nordringrayhide / gist:3143858
Created July 19, 2012 13:18
Kaminary, пагинация массива
По дефолту для Mongoid он пагинирует Criteria. Если нужно Ruby-Array-массив:
Kaminary.paginate_array(...)
@nordringrayhide
nordringrayhide / deploy.rb
Created July 5, 2012 16:13 — forked from mikhailov/0. nginx_setup.sh
Nginx+Unicorn (production-ready setup)
# Capistrano configuration
#
# require 'new_relic/recipes' - Newrelic notification about deployment
# require 'capistrano/ext/multistage' - We use 2 deployment environment: staging and production.
# set :deploy_via, :remote_cache - fetch only latest changes during deployment
# set :normalize_asset_timestamps - no need to touch (date modification) every assets
# "deploy:web:disable" - traditional maintenance page (during DB migrations deployment)
# task :restart - Unicorn with preload_app should be reloaded by USR2+QUIT signals, not HUP