Skip to content

Instantly share code, notes, and snippets.

View wrburgess's full-sized avatar
:shipit:
Shippin'

Randy Burgess wrburgess

:shipit:
Shippin'
View GitHub Profile
@wrburgess
wrburgess / gist:2187164
Created March 24, 2012 19:37
Setting up a Rails has_many :through relationship with meaningful relationship table #rails #activerecord #relations

##References

##Create Models

Create tables:

rails g model Location
rails g model User
rails g model Checkin
@wrburgess
wrburgess / gist:2187571
Created March 24, 2012 20:39
Rails rendering format strategies
render :text => @body #renders without layout as text/plain
# GET /page
def page
render :layout => 'layout_file_name'
end
@wrburgess
wrburgess / gist:2268303
Created March 31, 2012 20:41
Set up a monitor page with no tracking script in Rails #rails #layouts #monitoring

##Create a boring view at app/views/static/monitor.html.erb

Monitoring Page

##Create a boring template at app/views/layouts/monitor.html.erb <title>IndyCar Laps</title> <%= stylesheet_link_tag "application", :media => "all" %> <%= javascript_include_tag "application" %>

@wrburgess
wrburgess / gist:2277606
Created April 1, 2012 18:39
Bootstrap: Rails App with ActiveAdmin on Heroku

##Get the files

###Download or clone the rails-aa-heroku-bootstrap repo on Github

###Set up terminal command to clone bootstrap:

git clone git://github.com/wrburgess/rails-aa-heroku-bootstrap.git [app-name]
terminal command to switch to app dir:
cd [app-name]
terminal command:git remote set-url origin [new-github-repo-url]

@wrburgess
wrburgess / gist:2295223
Created April 3, 2012 20:14
Setting up a cron job for heroku with Scheduler and Rake files #heroku #scheduler #cron #rake #rails #ruby

##References

##Create a Rake Command file at lib/tasks/scheduler.rake

desc "This task is called by the Heroku scheduler add-on"
task :method_name => :environment do

  puts "starting method_name process"
@wrburgess
wrburgess / process.rb
Created April 4, 2012 19:38
refactoring
def process_mdn(mdn)
return "0" if mdn.nil? || mdn.length != 10
unless mdn.nil?
mdn = mdn[1..-1] #remove the leading "1"
else
"0"
end
@wrburgess
wrburgess / dabblet.css
Created April 13, 2012 20:26
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@wrburgess
wrburgess / gist:2424064
Last active October 3, 2015 08:18
Insert Blocks into Templates with Drupal 7 #php #drupal #block
<?php
$block = module_invoke('views', 'block_view', 'slider-block');
print render($block);
?>
<?php
$block = module_invoke('block','block_view','1');
print render($block['content']);
?>
@wrburgess
wrburgess / gist:2430228
Created April 20, 2012 16:43
Backup MySQL database and restore updated version

Backup current db

Terminal command:

backup db

Terminal command:

mysqldump -u root -p vibes2 > [filename].sql

Restore new db

Terminal command to pull in code updates:

git pull
Terminal command to pull in new db:

@wrburgess
wrburgess / gist:2438607
Created April 21, 2012 17:27
Notes from CodeSchool Journey into Mobile Course