Skip to content

Instantly share code, notes, and snippets.

View listrophy's full-sized avatar

Brad Grzesiak listrophy

View GitHub Profile
@listrophy
listrophy / composeAndApply.swift
Last active August 29, 2015 14:02
composeAndApply in swift
func composeAndApply<T>(funcs: (T -> T)[], val: T) -> T {
return funcs.reduce(val, combine: { (memo, aFunc) in aFunc(memo) })
}
func square(val: Int) -> Int {
return val * val
}
func double(val: Int) -> Int {
return val * 2
@listrophy
listrophy / shrink_plus_ones.js
Created September 22, 2013 02:49
Shrink +1's on github comments
$('.discussion-bubble').filter(function() {
var body = $(this).find('.comment-body').text().trim();
return body === "+1" ||
body === '' && $(this).find('.comment-body img.emoji[title=":+1:"]').length > 0;
}).each(function() {
$(this).find('.comment-content').remove().end().
find('.comment-header-action-text a').html("+1'ed");
});
@listrophy
listrophy / gist:6530215
Created September 11, 2013 21:46
bwoken v2 alpha instructions

In your Gemfile, change the bwoken line to:

gem 'bwoken', :github => 'bendyworks/bwoken', :branch => 'deprecate_rake'

Then run bundle and try running:

bwoken test

See the flags available with:

ATID 2718 # personal area network ID (must match other XBee's ATID)
ATMY 1 # my address (must match other XBee's ATIA)
ATDH 0 # destination address high
ATDL 2 # destination address low (must match other XBee's ATMY)
ATD0 3 # Set AD/DIO 0 (pin 20) to digital input
ATIR 14 # sample rate
ATPR 0 # no pull-up resistors
ATWR # save settings
@listrophy
listrophy / application.rb
Last active December 15, 2015 14:09
Quick, roll-your-own key-boolean caching
module MyApplication
class Application < Rails::Application
config.cache_store = :memory_store, {:size => 4.megabytes}
end
end
@listrophy
listrophy / project_lookup_constraint.rb
Created March 6, 2013 21:43
GitHub-style URL matching, with only one query. Is this belt-and-suspenders if ActiveRecord caches the query?
class ProjectLookupConstraint
def matches? request
Project.where(request.params.slice(:account_name, :project_name)).first.tap do |project|
request.flash.now['project'] = project
end
end
end
@listrophy
listrophy / Rakefile
Created January 21, 2013 19:57
Rakefile + watchr script for asset compilation (kinda specialized for http://restaurantweekmap.com)
require 'yaml'
require 'active_support/core_ext/object'
desc 'Compile all the things'
task :compile => 'compile:all'
SASS_FILES = FileList['sass/*.{sass,scss}']
COFFEE_FILES = FileList['coffee/*.coffee']
JS_FILES = COFFEE_FILES.pathmap('tmp/js/%n.js')
@listrophy
listrophy / Custom.css
Created January 3, 2013 15:40
Put this in "~/Library/Application Support/Google/Chrome/Default/User StyleSheets/Custom.css" to highlight your blocked stories.
.projects_stories_page .storyLabels a[title="blocked"] {
background-color: red;
color: white !important;
padding: 0 3px;
display: inline-block;
}
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=local
@listrophy
listrophy / head.html
Created October 18, 2012 00:42
OMG! You Gotta See HTML
<head>
<meta charset='utf-8'>
<meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible'>
<meta content='on' http-equiv='cleartype'>
<title>Omg</title>
<meta content='True' name='HandheldFriendly'>
<meta content='320' name='MobileOptimized'>
<meta content='width=device-width, initial-scale=1' name='viewport'>
<meta content='' name='description'>
<link href="/assets/application-[hash].css" media="all" rel="stylesheet" type="text/css" />