Skip to content

Instantly share code, notes, and snippets.

@joshmvandercom
joshmvandercom / rails-template.rb
Created August 31, 2011 03:45
Most of the stuff u needz
## Rails App Template
## Updated for Rails 3.0.7
## Run using $ rails new [appname] -JT -m josh-template.rb
##
## Gems
gem 'mysql'
gem 'sass'
gem 'haml'
gem 'haml-rails'
@joshmvandercom
joshmvandercom / madeofcode.vim
Created August 31, 2011 16:59
Port of Made of Code Theme to VIM
" Port of my favorite theme Made of Code by Mark Dodwell
" For Textmate Theme visit - http://madeofcode.com/posts/29-photo-my-new-textmate-theme-8220-made-of-code-8221-mdash-download-9-feb-2010-update-t
" Vim color file
set background=dark
highlight clear
if exists("syntax_on")
syntax reset
@joshmvandercom
joshmvandercom / convert-colors.jsx
Created January 5, 2012 18:36
Change path colors
var colorObject;
var hexes = ['5b7f52', '6ea041', '62a04a', '5b7f52', '6cb84e'];
var colors = [];
for (var h = 0; h < hexes.length; h++) {
colorObject = new SolidColor();
colorObject.rgb['hexValue'] = hexes[h];
colors.push(colorObject);
}
@joshmvandercom
joshmvandercom / .htaccess
Created January 19, 2012 15:57
.htaccess redirect w/ hash
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} !ajax
RewriteRule ^(.*)$ /#/$1 [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
@joshmvandercom
joshmvandercom / gist:1847955
Created February 16, 2012 21:22
ruby_example.rb
class Person
def initialize(food = 0)
@next_feeding_time = Time.now
feed(food)
end
def hungry?
@next_feeding_time < Time.now
end
@joshmvandercom
joshmvandercom / dropdown_to.rb
Created February 27, 2012 21:39
Passing a block into a helper
# Creates a Bootstrap dropdown
# Ex:
# = dropdown_to "Auctions", auctions_path do
# %li= link_to 'Upcoming Auctions', auctions_path
# %li= link_to 'Past Auctions', past_auctions_path
#
# Returns:
# <li class="dropdown">
# <a class="dropdown-toggle" data-toggle="dropdown" href="/auctions">
# <span>Auction</span>
@joshmvandercom
joshmvandercom / test.scss
Created March 10, 2012 18:55
Scss Example
@mixin module{
background: white;
border: 1px solid #ccc;
box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
}
#content {
@include module;
float: left;
}
class UsersController < ApplicationController
def index
@users = User.all
respond_to do |format|
format.html # renders index.html.erb
format.json { render :json => @users }
format.xml { render :xml => @users }
end
jQuery.fn.autoresize = function (options) {
options = options || {}
return this.each(function () {
// Init Sizes
var parent = $(this).parent();
var imageWidth = $(this).width();
var imageHeight = $(this).height();
var parentWidth = parent.width();
var parentHeight = parent.height();
var ratio, newSide;
@joshmvandercom
joshmvandercom / engine.rb
Created October 18, 2012 23:48
Testing routes with Rails 3.2 mountable engines and RSpec 2
# your-engine/lib/magic/rails/engine.rb
module Magic
module Rails
module Engine
##
# Automatically append all of the current engine's routes to the main
# application's route set. This needs to be done for ALL functional tests that
# use engine routes, since the mounted routes don't work during tests.
#