Skip to content

Instantly share code, notes, and snippets.

View wearethefoos's full-sized avatar

Wouter de Vos wearethefoos

View GitHub Profile
def show_menu
puts "
Catalogue
-------------
1) Cat
2) Goldfish
3) Dog
4) Horse
Pick a product (1 - 4):"
@wearethefoos
wearethefoos / Setup.md
Created May 7, 2015 15:21
Configurable Bootstrap Setup With Rails And Bower For Sass & JS Dependencies

First add the bower-rails and the compass-rails gems to your project's Gemfile:

# Gemfile
gem 'compass-rails'
gem 'bower-rails'

Run bundle install and then the generator that comes with bower-rails to set everything up:

#!/usr/bin/env bash
#
# Rails console script that can be run on AWS Elastic Beanstalk.
#
# Run this script from the app dir (/var/app/current) as root (sudo script/aws-console)
#
set -xe
EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
class Profiler
def self.profile(&block)
result = RubyProf.profile do
block.call
end
printer = RubyProf::GraphPrinter.new(result)
printer.print(STDOUT, {})
end
end
ssl_certificate Definition
define :ssl_certificate, action: :create do
cert_dir = File.expand_path("../../files/default", __FILE__)
# Find the host certificate
host_cert = File.join( cert_dir, "*.#{params[:name]}.crt" )
Chef::Logger.error("Could not locate host certificate for #{params[:name]}!")
# Find the intermediate certificate
def assets_same_since?(old_assets_version = nil)
return false if old_assets_version.nil? || old_assets_version.empty?
return false if ENV['FORCE_ASSETS_COMPILATION']
changed = %x(git diff #{old_assets_version}.. \
vendor/assets/ \
app/assets/ \
config/javascript_translations.yml \
config/javascript.yml | wc -l).chomp
@wearethefoos
wearethefoos / check_resque_current.sh
Last active December 27, 2015 18:39
Check with bash whether your Resque workers run from the current release folder.
releases=`ps aux | grep resque- | sudo pwdx \`awk '{print $2}'\` | sed 's/\(.*\)\/path\/to\/releases\/\(.*\)/\2/' | sed 's/.*No such process//'`
current_release=`readlink /path/to/current | sed 's/\/path\/to\/releases\/\(.*\)/\1/'`
for r in $releases; do
if [ $r = $current_release ]; then
echo 'yes'
else
echo 'no'
fi
# Prefix to C-a
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# Vim bindings
set -g status-keys vi
# Use vim keybindings in copy mode
setw -g mode-keys vi
@wearethefoos
wearethefoos / rendering.rb
Created June 18, 2013 12:07
Render templates without double render errors
# render in before_filter
before_filter
render 'template' and return
end
# Render conditional
def index
respond_to do |format|

Percona and Rails

From the Percona site:

Percona XtraDB Cluster is a high availability and high scalability solution for MySQL users. Percona XtraDB Cluster integrates Percona Server with the Galera library of high availability solutions in a single product package. Percona XtraDB Cluster enables users to save money through:

  • Less downtime and higher availability
  • Reduced investment in high availability architectures
  • Lower DBA training and education costs
  • No investment in third-party, high availability solutions