Skip to content

Instantly share code, notes, and snippets.

View christopherhein's full-sized avatar

Christopher Hein christopherhein

View GitHub Profile
<style type="tex/css">
body { display:none }
</style>
<!-- Include jQuery -->
<script type="text/javascript">
$(document).ready(function() {
$("body").fadeIn(500);
$("a").click(function(event){
@christopherhein
christopherhein / Extending Moderizer
Created April 29, 2011 04:37
Extending Moderizer so that is adds browsers and operating systems
(function($){
$(function() {
var userAgent = navigator.userAgent.toLowerCase();
jQuery.browser = {
chrome: /chrome/.test( userAgent ),
safari: /webkit/.test( userAgent ) && !/chrome/.test( userAgent ),
opera: /opera/.test( userAgent ),
msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
};

source 'http://rubygems.org'

Rails

gem "rails"

Database

gem "mysql2"

Deploy with Capistrano

gem "capistrano"

(function($){
$.fn.confirm = function(params){
if($(this).length){
elem = $(this);
open = false;
elem.submit(function() {
valid = $(".global-form.confirm").valid();
@christopherhein
christopherhein / gist:956296
Created May 5, 2011 00:17
Getting placeholders anywhere
$("input[type=text]").each(function(){
var curr_value = $(this).val();
$(this).focus(function(){
if($(this).val() == curr_value) {
$(this).val('').removeClass("placeholders");
}
});
$(this).blur(function(){
if($(this).val() == '') {
$(this).val(curr_value).addClass("placeholders");
@christopherhein
christopherhein / Generating permalinks
Created May 5, 2011 18:20
Ruby on rails method to generate permalinks
@christopherhein
christopherhein / production.rb
Created May 14, 2011 19:11
Asset Packaging asset_hosts
ActionController::Base.asset_host = Proc.new { |source|
img = %w(.png .jpg .gif .jpeg)
ext = File.extname(source).split("?")[0]
if img.include?(ext)
"http://assets1.example.com"
elsif ext == '.js'
"http://assets2.example.com"
elsif ext == '.css'
"http://assets3.example.com"
@christopherhein
christopherhein / Gemfile
Created May 15, 2011 18:55
Gemfile, personal like-ings
source "http://rubygems.org"
# Rails
gem "rails", "3.1.0.beta1"
# Database
gem "mysql2"
gem "memcache-client"
# Front End
ruby-1.9.2-p290 :001 > Post.new
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
from /Users/ChristopherHein/.rvm/gems/ruby-1.9.2-p290@chrishein/gems/activerecord-3.1.0/lib/active_record/base.rb:717:in `column_defaults'
from /Users/ChristopherHein/.rvm/gems/ruby-1.9.2-p290@chrishein/gems/activerecord-3.1.0/lib/active_record/persistence.rb:327:in `attributes_from_column_definition'
from /Users/ChristopherHein/.rvm/gems/ruby-1.9.2-p290@chrishein/gems/activerecord-3.1.0/lib/active_record/locking/optimistic.rb:69:in `attributes_from_column_definition'
from /Users/ChristopherHein/.rvm/gems/ruby-1.9.2-p290@chrishein/gems/activerecord-3.1.0/lib/active_record/base.rb:1544:in `initialize'
from (irb):1:in `new'
from (irb):1
# Setup Spork
guard 'spork', bundler: true, cucumber_env: { 'RAILS_ENV' => 'test' }, rspec_env: { 'RAILS_ENV' => 'test' }, test_unit_env: { 'RAILS_ENV' => 'test' }, wait: 60 do
watch('config/application.rb')
watch('config/environment.rb')
watch(%r{^config/environments/.+\.rb$})
watch(%r{^config/initializers/.+\.rb$})
watch(%r{^spec/support/.+\.rb$})
watch('spec/spec_helper.rb')
watch('test/test_helper.rb')
watch(%r{^features/support/.+\.rb$})