Skip to content

Instantly share code, notes, and snippets.

bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
source .bash_profile
type rvm | head -1
# this command should say 'rvm is a function'
rvm install 1.9.2
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-preview3.tar.gz
tar -xvf ruby-1.9.2-preview3.tar.gz
cd ruby-1.9.2-preview3
./configure
make
sudo make install
ruby -v #just checking to make sure it installed.. output = ruby 1.9.2dev (2010-05-31 revision 28117) [x86_64-linux]
cd ..
sudo rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
sudo yum -y install gcc gcc-c++ make zlib zlib-devel openssl openssl-devel git expect pcre pcre-devel readline-devel mysql mysql-devel libxml2 libxml2-devel libxslt libxslt-devel
useradd app_user
passwd app_user
vi /etc/sudoers #open sudoers in your favorite text edit
# add the following line below "root ALL=(ALL) ALL" :
# app_user ALL=(ALL) ALL
# save file and exit
#disable root login from ssh, so nobody is able to brute force a root login
vi /etc/ssh/sshd_config
#uncomment "PermitRootLogin yes" and change it to "PermitRootLogin no"
@cowboycoded
cowboycoded / round_by_fraction.rb
Created April 27, 2011 19:24
Round by a fraction
def round_to_fraction(number,fraction = 0.5)
multiplier = 1.0 / fraction
(multiplier*number).round / multiplier
end
@cowboycoded
cowboycoded / create_paper_trail_versions.rb
Created April 19, 2011 18:54
This rake task/monkeypatch creates the inital paper_trail version for existing records.
namespace :app_tasks do
desc "create initial paper_trail version for existing records"
task(:create_paper_trail_versions => :environment) do
#MONKEY PATCH
module PaperTrail
module Model
module InstanceMethods
def create_initial_pt_version
record_create if versions.blank?
class WidgetsController < ApplicationController
caches_action :show, :if => Proc.new { |x| x.cacheable? }
def show
#...
end
end
<% private_cache("my_private_cache") do %>
module ApplicationHelper
def private_cache (name = {}, &block)
if @user.blank?
yield and return #note.. I had to add this return..otherwise it rendered twice
else
cache(name, &block)
end
end
end
expire_fragment(:controller=>"widget",:action=>"index", :action_prefix=>"some_prefix")
expire_fragment("some_name")