Skip to content

Instantly share code, notes, and snippets.

View vassilis's full-sized avatar

Vassilis Terzopoulos vassilis

View GitHub Profile
@nabucosound
nabucosound / heroku_env_copy.sh
Created December 30, 2013 12:40
Script to copy environment variables from an existing heroku app to another one
#!/bin/bash
# Source: http://blog.nonuby.com/blog/2012/07/05/copying-env-vars-from-one-heroku-app-to-another/
set -e
sourceApp="$1"
targetApp="$2"
while read key value; do
@glebm
glebm / async_emails_i18n.rb
Last active August 8, 2017 09:42
Inject locale into Resque::Mailer and Devise::Async
require 'resque_mailer'
require 'devise/async'
# pop and set locale from the args before running
module PerformWithLocale
def perform(*args)
I18n.with_locale(args.pop) do
super(*args)
end
end
function humanize(num){
var ones = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine',
'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen',
'seventeen', 'eighteen', 'nineteen'];
var tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty',
'ninety'];
var numString = num.toString();
if (num < 0) throw new Error('Negative numbers are not supported.');
@paulsturgess
paulsturgess / reset_primary_key.md
Created February 27, 2013 19:49
Reset postgres primary key index using Rails
$ ActiveRecord::Base.connection.reset_pk_sequence!('table_name')

If you need the table names:

$ ActiveRecord::Base.connection.tables

=> ["accounts", "assets", ...]

@roberto
roberto / _flash_messages.html.erb
Created August 13, 2012 22:47
Rails flash messages using Twitter Bootstrap
<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>
@thorn
thorn / paginated_collection.js.coffee
Created May 17, 2012 09:56 — forked from zerowidth/paginated_collection.js
backbone pagination with coffeescript
# coffeescript rules
# Pagination is sticked with model
#
# Server should response in that way:
# {
# articles: [{category_id:null, id:308,…}, {category_id:null, id:307,…}, {category_id:null, id:306,…},…]
# pagination: {total:34, page:2, per_page:15, cat_id:-1, source_id:-1}
# }
# To achieve this controller should look like (using will_paginate gem):
# per_page = params[:per_page].to_i || 15
@activefx
activefx / spec_helper.rb
Created October 10, 2011 20:19
Spec helper for use with guard, spork, rspec, factory girl, devise, capybara, and mongoid
require 'rubygems'
def start_simplecov
require 'simplecov'
SimpleCov.start 'rails' unless ENV["SKIP_COV"]
end
def spork?
defined?(Spork) && Spork.using_spork?
end
task :deploy => ['deploy:push', 'deploy:restart', 'deploy:tag']
namespace :deploy do
task :migrations => [:push, :off, :migrate, :restart, :on, :tag]
task :rollback => [:off, :push_previous, :restart, :on]
task :push do
puts 'Deploying site to Heroku ...'
puts `git push heroku`
end