Skip to content

Instantly share code, notes, and snippets.

@vladimir-e
vladimir-e / gist:e6d21e37c01841fc2314
Created September 16, 2014 14:36
Rake db drop create migrate one-liner
bin/rake db:{drop,create,migrate}
Ember.Test.registerHelper('selectFrom',
function(app, selector, value, description) {
// choose an option
find(selector).val(value);
// trigger the change
find(selector).change();
// assert the selected option
equal(find(selector+" option:selected").val(), value, description||"makes the selection");
// promise
return wait();
@vladimir-e
vladimir-e / static_classes.handlebars
Created August 30, 2014 12:46
Combining Static and Dynamic CSS Class Names in ember handlebars
{{!-- http://codebrief.com/2012/03/eight-ember-dot-js-gotchas-with-workarounds/ --}}
<div {{bindAttr class="myProperty:dynamicClass :staticClass"}}></div>
@vladimir-e
vladimir-e / gist:b8b1c52953a6fa98a355
Created August 29, 2014 08:52
A really lowlevel plumbing error occured. Please contact your local Maytag(tm) repair man. #puma #deploy
Set up secret_key_base for current environment in config/secrets.yml
@vladimir-e
vladimir-e / example_controller.rb
Created August 11, 2014 09:00
Orderable concern rails 3
class Admin::SizesController < Admin::AdminController
include OrderableController
end
@vladimir-e
vladimir-e / seeds.rb
Created June 26, 2014 04:39 — forked from seyhunak/seeds.rb
Rails - Import SQL file as seed
unless Rails.env.production?
connection = ActiveRecord::Base.connection
connection.tables.each do |table|
connection.execute("TRUNCATE #{table}") unless table == "schema_migrations"
end
sql = File.read('db/import.sql')
statements = sql.split(/;$/)
statements.pop
@vladimir-e
vladimir-e / vsftpd.sh
Last active August 29, 2015 14:02
install vsftpd ubuntu #ftp
sudo apt-get install vsftpd
sudo vim /etc/vsftpd.conf
# Uncomment #local_umask=022
sudo service vsftpd restart
@vladimir-e
vladimir-e / gsub.rb
Last active August 29, 2015 14:02
capture regex pattern with ruby gsub
str = "number 5"
str.gsub(/number\ (\d+)/, '#\1')
# => "#5"
@vladimir-e
vladimir-e / nginx.sh
Created June 12, 2014 22:09
nginx error digitalocean when adding second virtual host
sudo service nginx configtest
* Testing nginx configuration [fail]
sudo nginx -t
nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32
nginx: configuration file /etc/nginx/nginx.conf test failed
server_names_hash_bucket_size = 64
sudo service nginx restart
@vladimir-e
vladimir-e / vps.md
Last active June 10, 2016 18:48
Deploy Rails 4 app to Ubuntu VPS using capistrano 3 (rbenv/puma)

Server Commands

apt-get -y update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties vim mc ImageMagick

# nginx
add-apt-repository ppa:nginx/stable
apt-get -y update
apt-get -y install nginx