Skip to content

Instantly share code, notes, and snippets.

Michael van Rooijen mrrooijen

Block or report user

Report or block mrrooijen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mrrooijen
mrrooijen / Capistrano-Deployment-Recipe.rb
Created Jul 29, 2009
a "base" Capistrano Rails Deployment Recipe. Use it to deploy your Rails application. It is also easily expandable. So feel free to grab this Recipe and add your own tasks/customization!
View Capistrano-Deployment-Recipe.rb
# Guide
# Configure the essential configurations below and do the following:
#
# Repository Creation:
# cap deploy:repository:create
# git add .
# git commit -am "initial commit"
# git push origin master
#
# Initial Deployment:
@mrrooijen
mrrooijen / Git-Ignore
Created Jul 29, 2009
Git Ignore File for my Capistrano recipe
View Git-Ignore
# Author: Michael van Rooijen
# Description:
# If you are using my Capistrano Recipe, be sure to add these lines to your .gitignore file.
# It will prevent problems when deploying incase your generated the all.js/all.css, assets, database.yml etc.
# Assets and Database yaml should be stored in the "shared" section of the application, not inside the actual application with every release.
.DS_Store
log/*.log
tmp/**/*
config/database.yml
@mrrooijen
mrrooijen / nginx
Created Jul 29, 2009
A script to enable easy start/stop functionality for the NginX Web Server.
View nginx
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@mrrooijen
mrrooijen / jQuery-Plugin-Template.js
Created Jul 29, 2009
A jQuery Plugin Template.
View jQuery-Plugin-Template.js
(function($){
/**
* jQuery PluginName
*
* @plugin {PluginName}
* @description {PluginDescription}
*
* @changelog
* @{mm/dd/yyyy} {version} {author} {changedescription}
View Rails - Remove Form Error Decorations.rb
# Place this line below in your environment.rb to remove the Form Error Decorations that display when the form validation failed.
ActionView::Base.field_error_proc = proc { |input, instance| input }
View Paperclip-Simple-Template.rb
# Inside the model.rb
has_attached_file :image,
:url => "/assets/images/:style/:id.:basename.:extension",
:path => ":rails_root/public/assets/images/:style/:id.:basename.:extension",
:styles => {
:small => '50x45#',
:medium => '150x150',
:large => '300x300'
}
View CodeRay-Railscasts-like-CSS.css
.CodeRay {
background-color: #232323;
border: 1px solid black;
font-family: 'Courier New', 'Terminal', monospace;
color: #E6E0DB;
padding: 3px 5px;
overflow: auto;
font-size: 12px;
margin: 12px 0;
}
View Rails-Method-Nestable-(For-Nested-Forms).rb
# Add this snippet into your ApplicationHelper to make it available to all views
# This method enables a simple but clean way to handle nested forms when a :has_many relationship
# along with the :accepts_nested_attributes_for methods are invoked in the model.
# Instead of making a method for each of the first arguments of the form_for() method, you can now just
# invoke the "nestable()" method and pass in the object in the first argument, followed by any associated/nested models.
# See the method and example comments below
module ApplicationHelper
# Call on first argument of the "form_for" method
View sortable_list_without_javascript.rb
# index.html.erb
<ul id="projects">
<% @projects.each_with_index do |project, index| %>
<% content_tag_for :li, project do %>
<%= project.name %>
<%= button_to('up', :action => 'sort', :projects => @projects.swap(index, index -1)) if index > 0 %>
<%= button_to('down', :action => 'sort', :projects => @projects.swap(index, index +1)) if index < @projects.length - 1 %>
<% end %>
<% end %>
@mrrooijen
mrrooijen / 9.04.sh
Created Sep 4, 2009
Rails Stack Installer for Ubuntu 8.04/9.04. Ruby Enterprise Edition, Phusion Passenger, NginX, MySQL
View 9.04.sh
# Author: Michael van Rooijen
# Description:
# A Rails Stack Installer for Ubuntu 8.04/9.04 with the light-weight and fast NginX Web Server.
# This shell script will install a basic Rails Stack with a bunch of useful and commonly used utilities.
# It will install Ruby Enterprise Edition with Phusion Passenger (Reduces Rails Application Memory Usage By Approx. 33%)
# It will install some essential gems like mysql, sqlite, postgres etc.
# It will install NginX Web Server
# It will install the MySQL database
# It will install Git
# It will install these utilities: ImageMagick, FFMpeg, Memcached
You can’t perform that action at this time.