Skip to content

Instantly share code, notes, and snippets.

@jnf
jnf / level_2.rb
Created July 27, 2014 05:54
Ruby Warrior, Intermediate
class Player
def play_turn(warrior)
@warrior = warrior
@preferred_direction = @warrior.direction_of_stairs
wat_do?
end
protected
@jnf
jnf / wat.haml
Last active August 29, 2015 14:05
- x = 7
.div1
.div2
.div4
- if x == 4
Totes a four.
- else
Prolly not a four.
.div3
A third div, nested in div2.

Keybase proof

I hereby claim:

  • I am jnf on github.
  • I am jnf (https://keybase.io/jnf) on keybase.
  • I have a public key whose fingerprint is 8913 A2F3 8073 86C9 F367 3752 148A E504 F827 DA56

To claim this, I am signing this object:

@jnf
jnf / osd-request-for-quote-visual-design.md
Last active August 29, 2015 14:18
OS&F: Request for Quote, Visual Design

Hello!

Open Source & Feelings (OS&F) is a new technology conference focused on providing tools and support for people seeking to implement and improve technology %w(access tools education).sample in their communities.

We're early in the planning process, but some language describes our mission as:

Open Source & Feelings is a two-day event exploring the Humanities & Arts through the lens of open source technology, those tools and products we use to richly experience & interact with each other, our communities, and the world.

One of our most immediate needs is visual identity for the project. The goal of this document is to describe our need well enough to jump-start conversation. Given that this is the first year, we have no existing brand materials for you to reference.

Deliverables

@jnf
jnf / mergesort.rb
Last active August 29, 2015 14:25 — forked from sudocrystal/mergesort.rb
Starting ground for mergesort in ruby -- with recursive and iterative solutions.
def mergesort(a)
# if the array size is 0|1 then the list is considered sorted, return sorted
return a if a.length <= 1
# split the list in half
left, right = split_array a
# merge sort each half
sorted_left = mergesort left
sorted_right = mergesort right
//sometimes, you just want the copy inside an element.
function $T(element) {
var t = $(element);
return t == null ? t : t.innerHTML.gsub(/<\/?[^>]*>/, '');
}
//is fetching the innerHTML bad form? Most of the time, yeah.
function $M(element) {
var m = $(element);
return m == null ? m : m.innerHTML;
/*
* @author jnf http://github.com/jnf
* other_select, when attached to a select box, pops a sibling input field with similar
* attributes. Use it to record user input that falls outside the options provided in a
* select box.
*/
$.fn.other_select = function(options) {
var defaults = {
speed: 'normal', //rate at which the alternate input field appears/disappears
nameSuffix: '_other', //suffix appended to the alternate input's name attribute
@jnf
jnf / zepto.scrollBoth.js
Created October 25, 2012 16:22
Extending ZeptoScroll (https://github.com/suprMax/ZeptoScroll) to support horizontal and vertical scrolling.
;(function($) {
var interpolate = function (source, target, shift) {
return (source + (target - source) * shift);
};
var easing = function (position) {
return (-Math.cos(position * Math.PI) / 2) + .5;
};
$.scrollBoth = function(XY, duration, easingF) {
@jnf
jnf / story.rb
Created November 14, 2012 05:42
Color layering for Stories
class Story < ActiveRecord::Base
...
before_save :setColor
...
private
def setColor
@jnf
jnf / pgpass.rake
Last active December 11, 2015 11:38
Example rake task to generate ~/.pgpass based on info fetched from heroku:config
namespace :db do
require 'uri'
desc "Uses heroku:config for APP to forcefully create ~/.pgpass"
task :create_pgpass do
app = ENV['APP'] || 'whatever-your-default-app-is'
uri = URI(`heroku config:get DATABASE_URL -a #{app}`)
entry = "*:5432:#{uri.path.gsub /\//, ''}:#{uri.user}:#{uri.password}"
`echo '#{entry}' > ~/.pgpass; chmod 0600 ~/.pgpass`
end