Skip to content

Instantly share code, notes, and snippets.

View rjmcdonald83's full-sized avatar

Ryan McDonald rjmcdonald83

  • Freelance Responder Advocate
  • Boulder
View GitHub Profile
@rjmcdonald83
rjmcdonald83 / markdown_to_prawn
Created July 23, 2012 16:52
Markdown to Prawn Parser
class TermsPdf < Prawn::Document
def initialize(application)
super()
@application = application
@listing = @application.listing
@host = @listing.organization
@guest = @application.guest_organization
font "Times-Roman"
default_leading 2
@rjmcdonald83
rjmcdonald83 / anagram.rb
Created September 9, 2013 18:12
Ruby Solution to Anagram solved with @seeflanigan
class Anagram
attr_reader :source
attr_reader :match_chars
def initialize(source)
@source = source.downcase
@match_chars = self.source.split('').sort
end
def match(candidates)
@rjmcdonald83
rjmcdonald83 / Simple Tabs
Last active August 29, 2015 13:57
Simple Tabs
$('#tabs a').click(function() {
// Add prevent default
$('#tabs li').removeClass('active');
$(this).parent().addClass('active');
var tab_to_show = $(this).attr('href');
$("#tabs_container").children().addClass('hidden');
$(tab_to_show).removeClass('hidden');
});
@rjmcdonald83
rjmcdonald83 / railsconf_2014_schedule
Last active August 29, 2015 13:59
RailsConf 2014 Schedule
{"sessions":[{"conference_day":1,"start_time":"07:30","end_time":"09:15","title":"Registration","presenter":"","room_name":"Convention Registration","track_name":null},{"conference_day":3,"start_time":"15:50","end_time":"16:30","title":"Software Development Lessons from the Apollo Program","presenter":"Julian Simioni","room_name":"Ballroom 1-3","track_name":"Crafting Code"},{"conference_day":3,"start_time":"11:10","end_time":"11:50","title":"Front-End: Fun, Not Frustration","presenter":"Roy Tomeij","room_name":"Ballroom 5","track_name":null},{"conference_day":2,"start_time":"09:15","end_time":"10:20","title":"Announcements / Keynote","presenter":"Yehuda Katz","room_name":"Sheraton Ballroom","track_name":null},{"conference_day":4,"start_time":"13:30","end_time":"15:50","title":"Test Drive a Browser Game With JavaScript","presenter":"Zach Briggs, Todd Kaufman","room_name":"Superior","track_name":"Workshop"},{"conference_day":3,"start_time":"10:20","end_time":"11:10","title":"Morning Break","presenter":"","room_
@rjmcdonald83
rjmcdonald83 / ruby_hash_with_count
Last active August 29, 2015 13:59
Make a pretty sorted list of a counted hash
-if hash_with_count.present?
-# Take a hash formated like so { :a => 2, :b => 4, :c => 6...}, sort it highest to lowest and slice up and iterate over each row.
- hash_with_count.sort_by{|k,v| v}.reverse.each_slice(5).to_a.each do |row|
%ul#tags.list-inline
-row.each do |name, count|
%li
.label.label-success
= name
= count
-else
var connect = require('connect')
, exec = require('child_process').execFile
var app = connect()
.use(connect.json())
.use(function(req, res) {
if (!!~ req.body.ref.indexOf('gh-pages'))
return res.end("OK");
console.log("DEPLOYING...")
#scroll{
direction:rtl;
overflow:auto;
height:50px;
width:50px;}
#scroll div{
direction:ltr;
}
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@rjmcdonald83
rjmcdonald83 / gist:593ab2fc52ecb72f90e9
Created July 21, 2014 23:34
Basic structure for new layout
// Two Column setup
// markup
%secion.content
%article
%section
%h1 Main section
%aside
%section
var arr = [1,2,3,4];
for (var i = 0, len = arr.length; i < len; i++) {
var el = arr[i];
setTimeout(function () {
console.log(el);
}, 10);
}