Skip to content

Instantly share code, notes, and snippets.

View wearethefoos's full-sized avatar

Wouter de Vos wearethefoos

View GitHub Profile
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
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
class Profiler
def self.profile(&block)
result = RubyProf.profile do
block.call
end
printer = RubyProf::GraphPrinter.new(result)
printer.print(STDOUT, {})
end
end
@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:

@wearethefoos
wearethefoos / CakePHP: Access SessionComponent from everywhere
Created February 11, 2011 17:43
A question a lot of people seem to ask about the CakePHP Session Component is how to access it from e.g. a Model. There are quite a few suggestions to be found on Google, but none of them strike me as very elegant. I came up with this one, and it works fr
App::import('Core', 'Controller');
App::import('Component', 'Session');
$Controller = new Controller();
$Session = new SessionComponent();
$Session->startup($Controller);
$Session->read('Auth.User');
@wearethefoos
wearethefoos / OSX Lion pecl and pear.mdown
Created September 8, 2011 10:27
Native OSX Lion pecl and pear config
$ sudo /usr/bin/php /usr/lib/php/install-pear-nozlib.phar

$ cat >> ~/.bashrc <<'EOF' 

alias pear="php /usr/lib/php/pear/pearcmd.php" 
alias pecl="php /usr/lib/php/pear/peclcmd.php" 
EOF

$ . ~/.bashrc
@wearethefoos
wearethefoos / 0-Readme.md
Created November 23, 2012 14:39
Fixed Rbenv Ruby 1.9.3 falcon patch with CFLAGS for Rackspace Cloud servers

Rbenv Ruby 1.9.3 p194 - Falcon patched on Rackspace Ubuntu 12.04 LTS (Precise Pangolin)

Install these packages:

  $ apt-get install build-essential zlib1g zlib1g-dev \
     libreadline6 libreadline6-dev libssl-dev libyaml-dev \
     libffi-dev libgdbm-dev libx11-dev aptitude libtidy-dev \
     libxml2-dev libevent-dev libev-dev autoconf
def show_menu
puts "
Catalogue
-------------
1) Cat
2) Goldfish
3) Dog
4) Horse
Pick a product (1 - 4):"

Carrierwave Example Uploader

Steps

  • Add gem 'carrierwave' to Gemfile
  • Run bundle install to install the new gem
  • Stop spring: spring stop
  • Run rails generate uploader Image
  • Mount the newly generated ImageUploader on your Model. I mounted it on the string type column image by adding this in my model's class:
@wearethefoos
wearethefoos / commands.sh
Last active December 17, 2015 07:09
Install Ruby 2.0, Nginx, Postgres, Passenger, NodeJS, ElasticSearch on Ubuntu 12.10
# Install Ruby 2.0
apt-get -y update
apt-get -y -m install build-essential zlib1g-dev libssl-dev libreadline-gplv2-dev libyaml-dev libxslt1-dev libxml2-dev libcurl4-openssl-dev libffi-dev libgdbm-dev libncurses5-dev
cd /tmp
wget http://ftp.ruby-lang.org/pub/ruby/ruby-2.1.0.tar.gz
tar xzvf ruby-2.1.0.tar.gz
cd ruby-2.1.0/
./configure --prefix=/usr/local
make