Skip to content

Instantly share code, notes, and snippets.

View constantine-nikolaou's full-sized avatar

Constantine Nikolaou constantine-nikolaou

View GitHub Profile
@killercup
killercup / README.md
Created March 16, 2012 11:03
Unicorn, RVM Wrapper, Init.d

You have your Rails Apps with specific Gemsets in RVM.

The following commands creates a wrapped unicorn_rails bin. Be sure to replace the variables and that you have unicorn in your bundle.

rvmsudo rvm wrapper [RUBY VERSION]@[GEMSET] [GEMSET] unicorn_rails

Now you have a /usr/local/rvm/bin/[GEMSET]_unicorn_rails I will refer to [GEMSET]_unicorn_rails as [WRAPPED_NAME]

@croaky
croaky / single_recipient_smtp.rb
Created March 15, 2012 06:32
Set staging environment email to go to a single email address you control in order to not accidentally send production email addresses staging data.
module SingleRecipientSmtp
def self.included(clazz)
clazz.class_eval do
cattr_accessor :single_recipient_smtp_settings
end
end
def perform_delivery_single_recipient_smtp(mail)
mail.to = single_recipient_smtp_settings[:to]
mail.cc = nil
@kevinSuttle
kevinSuttle / meta-tags.md
Last active May 1, 2025 21:56 — forked from lancejpollard/meta-tags.md
List of Usable HTML Meta and Link Tags
@pheuter
pheuter / sc-dl.js
Created March 5, 2012 20:44
Bookmarklet that generates download link for a Soundcloud upload
(function(d) {
var dl = d.createElement('a');
dl.innerText = 'Download MP3';
dl.href = "http://media.soundcloud.com/stream/"+d.querySelector('#main-content-inner img[class=waveform]').src.match(/\.com\/(.+)\_/)[1];
dl.download = d.querySelector('em').innerText+".mp3";
d.querySelector('.primary').appendChild(dl);
dl.style.marginLeft = '10px';
dl.style.color = 'red';
dl.style.fontWeight = 700;
})(document);
@jadehopepunk
jadehopepunk / upgrade_to_refinery_two.rb
Created March 3, 2012 07:00
Migration to convert from refinery 1.0.8 to refinery 2.0
class UpgradeToRefineryTwo < ActiveRecord::Migration
def self.up
# For refinerycms-authentication
rename_table :roles_users, :refinery_roles_users
rename_table :roles, :refinery_roles
rename_table :user_plugins, :refinery_user_plugins
rename_table :users, :refinery_users
remove_column :refinery_users, :persistence_token
remove_column :refinery_users, :perishable_token
remove_column :refinery_users, :remember_token
@hernamesbarbara
hernamesbarbara / .bash_profile
Created February 29, 2012 04:59
bash_profile with terminal colors and useful aliases
#!/bin/bash
export TERM=xterm-color
export CLICOLOR=1
export GREP_OPTIONS='--color=auto'
# export LSCOLORS=Exfxcxdxbxegedabagacad
export LSCOLORS=gxfxcxdxbxegedabagacad # Dark lscolor scheme
# Don't put duplicate lines in your bash history
export HISTCONTROL=ignoredups
# increase history limit (100KB or 5K entries)
export HISTFILESIZE=100000
@ryandotsmith
ryandotsmith / event_buffering.md
Created February 14, 2012 04:10
event buffering

Event Buffering

Eventually platforms outgrow the single-source-tree model and become distributed systems. A common pattern in these distributed systems is distributed composition via event buffering. Here we motivate and describe this event buffering pattern.

The Problem

@yaronw
yaronw / can_can_rspec_macros.rb
Created January 17, 2012 16:47
An RSpec Macro for Testing That Controller Actions Perform CanCan Authorization
=begin
# This RSpec Macro is for use with the authorization plugin CanCan. It lets you test that a controller checks for a
# specific authorization, and if it fails, that the controller performs a certain action, such as redirecting to a
# different page.
# Example Usages in specs:
it_should_authorize_access_for(:new, Company)
it_should_authorize_access_for(:edit, Company.new) { get :edit, id: @company }
# For more on using it_should_authorize_access_for, see comment block above the definition of it_should_authorize_access_for
# in the code below.
@cwise
cwise / gist:1575082
Created January 7, 2012 15:46
EngineYard resque-web
require 'resque/server'
resque_constraint = lambda do |request|
request.env['warden'].authenticate? and request.env['warden'].user.admin? # or whatever manner your admin role can be determined
end
constraints resque_constraint do
mount Resque::Server.new, :at => "/resque"
end
@rstacruz
rstacruz / index.md
Last active April 28, 2025 21:24
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one