Skip to content

Instantly share code, notes, and snippets.

View volontarian's full-sized avatar

Mathias Gawlista volontarian

View GitHub Profile
@hopsoft
hopsoft / db.rake
Last active May 6, 2024 14:00
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@parndt
parndt / gist:11381872
Last active May 29, 2019 11:59
Asset precompilation from an Engine's initializer
### RAILS 4.1
# Doesn't work, due to the error:
# Asset filtered out and will not be served: add
# `Rails.application.config.assets.precompile += %w( refinery/refinery.css )`
# to `config/initializers/assets.rb` and restart your server
class MyEngine < Rails::Engine
# set the manifests and assets to be precompiled
initializer "refinery.assets.precompile" do |app|
@fightingtheboss
fightingtheboss / deploy.rb
Last active August 30, 2016 07:58
Capistrano deploy script for deploying multiple app instances of a Meteor app to a single private VPS on different ports.
# This deploy script takes a parameter to define the number of instances to deploy (default is 1)
# ex: cap deploy -s instances=3
set :application, "YOUR_APP_NAME"
set :repository, "git@YOUR_GIT_REPOT.git"
set :scm, :git
set :deploy_via, :remote_cache
set :user, "deploy"
set :deploy_to, "/home/deploy/www/#{application}"
@SachaG
SachaG / AsynchronousFunctionWithinMeteorMethod.js
Last active November 17, 2016 09:32
Call an asynchronous function and use its returned value from within a Meteor method using Future.
if(Meteor.isServer){
Meteor.methods({
myMeteorMethod: function() {
// load Future
Future = Npm.require('fibers/future');
var myFuture = new Future();
// call the function and store its result
SomeAsynchronousFunction("foo", function (error,results){
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
@joequery
joequery / gist:1635318
Created January 18, 2012 20:23
Nginx config for use with multiple rails apps
worker_processes 1;
user nobody nogroup;
pid /tmp/nginx.pid;
error_log /tmp/nginx.error.log;
events {
worker_connections 1024;
accept_mutex off;
}
http {
default_type application/octet-stream;
@joequery
joequery / gist:1607063
Created January 13, 2012 15:49
Convient bash functions for managing nginx and Unicorn
# Kill and restart nginx
function restart_nginx(){
pids=$(pidof nginx)
if [[ -n $pids ]];
then
sudo kill -9 $pids
sudo service nginx restart
fi
}
@erichurst
erichurst / database.yml.example mysql2
Created May 9, 2011 02:58
Rails 3 database.yml examples
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8