Skip to content

Instantly share code, notes, and snippets.

Kevin Thompson kevinthompson

Block or report user

Report or block kevinthompson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kevinthompson
kevinthompson / solution.rb
Created Dec 1, 2017
Advent of Code 2017 - Day 1 Solution
View solution.rb
input = File.open('./input.txt').read.strip
class RecursiveString < String
def [](i)
if i >= length
super(i - length)
else
super(i)
end
end
@kevinthompson
kevinthompson / README.md
Last active Jun 27, 2017
Script for Displaying Images on #SIGNALconf Interactive Display
View README.md

Notes

This requires you to have a few things:

  1. A Mac
  2. An iPhone
  3. A US Cell Phone Number
  4. Handoff Enabled on Your Mac/iPhone
  5. A generous text message plan
@kevinthompson
kevinthompson / .env
Last active May 26, 2017
Litmus Example – Tweets in CSS
View .env
TWITTER_CONSUMER_KEY=""
TWITTER_CONSUMER_SECRET=""
TWITTER_SEARCH_STRING="#tedc15 -rt"
View gist:695d2cea49435994e485
require 'open-uri'
require 'json'
##
# Add underscore method to string for simple JSON
# key manipulation.
class String
def underscore
self.gsub(/::/, '/').
@kevinthompson
kevinthompson / example.js.coffee
Created Jan 17, 2014
Potential Solution for Page-Specific JavaScript
View example.js.coffee
# ./app/assets/javascripts/app.js.coffee
@App ||= {}
# ./app/assets/javascripts/app/view.js.coffee
class @App.View
@where: (params = { controller: null, action: null }) ->
controller = @_parseClassName(params.controller)
action = @_parseClassName(params.action)
try
View SassMeister-input-HTML.haml
%form.comment__form
%button Submit
%form.product__form
%button Submit
View SassMeister-input-HTML.haml
/ person listing page
%div#person-list
%div.person
default
%div.person.person--active
active
%div.person.person--pending
pending
View SassMeister-input-HTML.html
<div id="people-show">
<div class="person">
<h1>This is a Person</h1>
</div>
</div>
<div id="plans-show">
<div class="plan">
<h1>This is a Plan</h1>
</div>
@kevinthompson
kevinthompson / commented_regex.rb
Last active Dec 19, 2015
An example of a commented regex block encapsulated in a method.
View commented_regex.rb
def email_pattern
%r{
^[A-Z0-9._%+-]+ # Beginning with one or more valid characters (letters, numbers, period, etc.)
@ # A literal "at" sign
[A-Z0-9.-]+ # One or more letters, numbers, period, or dash
\. # A literal period
[A-Z]{2,4}$ # Ending with a two to four character text domain extension
}ix # Flags: Ignore whitespace and ignore letter case
end
@kevinthompson
kevinthompson / proc_to_block.rb
Created Jul 6, 2013
Unary Ampersand Example: Proc to Block
View proc_to_block.rb
items = {
'a' => 'aardvark',
'b' => 'banana',
'c' => 'cookies',
'd' => 'dog'
}
criteria = Proc.new { |key, value| value == 'banana' }
items.select(&criteria) # => {"b"=>"banana"}
items.reject(&criteria) # => {"a"=>"aardvark", "c"=>"cookies", "d"=>"dog"}
You can’t perform that action at this time.