Skip to content

Instantly share code, notes, and snippets.

View zachpendleton's full-sized avatar

Zach Pendleton zachpendleton

View GitHub Profile
#header {
background: red;
height: 200px;
}
@zachpendleton
zachpendleton / application.hbs
Created August 24, 2013 04:20
Accessible Ember buttonset component.
<!-- see http://jsbin.com/erIBAba/1 -->
<h1>Buttonset example</h1>
{{#zp-buttonset bindTo=filter}}
{{zp-button label="Open"}}
{{zp-button label="Upcoming"}}
{{zp-button label="Closed"}}
{{/zp-buttonset}}
@zachpendleton
zachpendleton / rescue_bm.rb
Created August 13, 2013 16:07
Rescuing in Ruby sucks
require 'benchmark'
Benchmark.benchmark do |x|
x.report {
100_000.times { nil.to_sym rescue :or }
}
x.report {
100_000.times { nil.try(:to_sym) || :or
}
@zachpendleton
zachpendleton / inject_example.rb
Created June 5, 2013 14:55
Example of Ruby's Inject method.
Enrollment = Struct.new(:name, :type)
enrollments = [
Enrollment.new('Don Draper', 'Teacher'),
Enrollment.new('Peggy Olson', 'Student'),
Enrollment.new('Pete Campbell', 'Student'),
Enrollment.new('Roger Sterling', 'TA')
]
grouped_enrollments = enrollments.inject({}) do |result, enrollment|
require 'erb'
require 'json'
require 'net/https'
module Jira
class Service
JIRA_URL = 'https://instructure.atlassian.net/rest/api/2/search'
def initialize(username = ENV['JIRA_USERNAME'], password = ENV['JIRA_PASSWORD'])
self.username = username

1:

  description: I know the problem, I know the solution, and it's only a few lines.
  examples:
  - CNVS-4242
  - CNVS-4203
  - CNVS-3100

2:

  description: I know the problem and solution, but it isn't as trivial as a 1. Or the
    problem seems small and I know the code, but may not know exactly what's causing it.

web: bundle exec unicorn -c vendor/plugins/zachp-local/unicorn.rb
guard: bundle exec guard start --no-interactions
job: bundle exec script/delayed_job run > /dev/null
mail: bundle exec mailtrap run
use strict;
sub event_send_text {
my ($text, $server, $win_item) = @_;
$text =~ s/:-1:/👎/g;
$text =~ s/:\+1:/👍/g;
$text =~ s/:poop:/💩/g;
$text =~ s/:no_good:/🙅/g;
$text =~ s/:ok_woman:/🙆/g;
@zachpendleton
zachpendleton / pianobar-lastfm.rb
Created July 5, 2012 20:50
Pianobar/LastFM Integration
#!/usr/bin/env ruby
# coding: utf-8
require 'digest/md5'
require 'net/http'
class LastFM
attr_reader :api_key, :secret, :session_key, :base_uri, :namespace