Skip to content

Instantly share code, notes, and snippets.

View brandoncordell's full-sized avatar

Brandon Cordell brandoncordell

View GitHub Profile
@brandoncordell
brandoncordell / gist:1941247
Created February 29, 2012 14:37
saving habtm, many associated records at a time
<?php
// saving habtm, many associated records at a time
// Audit hasAndBelongsToMany User
// table: audits_users
$audit = array(
'Audit' => array(
'name' => 'My Audit',
'start_date' => '2012-02-10,
@brandoncordell
brandoncordell / javascript-fu
Created February 29, 2012 04:21
My javascript-fu
/*
* jQuery - Singleton
*/
var App;
App = {
awesomeLink: null,
ready: function() {
this.awesomeLink = $('#next-link');
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:443 atlas.brandon (/Applications/MAMP/conf/apache/extra/httpd-ssl.conf:89)
Syntax OK
ShowOffYourStash::Application.routes.draw do
root :to => 'pages#home'
devise_for :users do
get 'dashboard' => 'users#dashboard', as: :user_root
get 'users/sign_up' => 'users#new'
get 'users/sign_in' => 'devise/sessions#new', as: :new_user_session
post 'users/sign_in' => 'devise/sessions#create', as: :user_session
get 'users/:id' => 'users#show', as: :user_profile
end
@brandoncordell
brandoncordell / gist:1383767
Created November 21, 2011 20:08
to_param not working in model
# user.rb
class User
include Mongoid::Document
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
field :username
.
.
.
@brandoncordell
brandoncordell / gist:1360922
Created November 12, 2011 18:36
rspec generator
config.generators do |g|
g.test_framework :rspec, :fixture => true, :views => false
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
end
createToolbar : function(editor){
var me = this,
items = [],
tipsEnabled = Ext.tip.QuickTipManager && Ext.tip.QuickTipManager.isEnabled(),
baseCSSPrefix = Ext.baseCSSPrefix,
fontSelectItem, toolbar, undef;
function btn(id, toggle, handler){
return {
itemId : id,
@brandoncordell
brandoncordell / gist:1159943
Created August 21, 2011 01:21
Loading a plist into an array
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Info"
ofType:@"plist"];
NSFileManager *fm = [NSFileManager defaultManager];
if ([fm fileExistsAtPath:plistPath])
NSLog(@"File Exists");
else
NSLog(@"File not found");
NSArray *tmpArray = [[NSArray alloc] initWithContentsOfFile:plistPath];
@brandoncordell
brandoncordell / .gitignore
Created August 11, 2011 08:27
My standard .gitignore for Rails projects
.bundle
db/*.sqlite3
log/*.log
tmp/
.sass-cache/
# rails ignores
*.rbc
*.sassc
.sass-cache
alert 'test'
jQuery('.new-page').click (e) ->
e.preventDefault()
alert e