Skip to content

Instantly share code, notes, and snippets.

John Nunemaker jnunemaker

Block or report user

Report or block jnunemaker

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
jnunemaker / gist:4495290
Created Jan 9, 2013
Web And Mobile Revenue Models
View gist:4495290
jnunemaker / authentication.rb
Created Jul 15, 2009
a starting point for authentication with mongomapper and rails
View authentication.rb
# include this in application controller
module Authentication
# Inclusion hook to make #current_user and #signed_in?
# available as ActionView helper methods.
def self.included(base)
base.send :helper_method, :current_user, :signed_in?, :authorized? if base.respond_to? :helper_method
# Returns true or false if the user is signed in.
jnunemaker / harmony.rb
Created Nov 10, 2009
simple app configuration
View harmony.rb
module Harmony
# Allows accessing config variables from harmony.yml like so:
# Harmony[:domain] =>
def self.[](key)
unless @config
raw_config = + "/config/harmony.yml")
@config = YAML.load(raw_config)[RAILS_ENV].symbolize_keys
jnunemaker / database.yml
Created Nov 12, 2009
mongo initializer to load config from database.yml, authenticate if needed and ensure indexes are created
View database.yml
development: &global_settings
database: textual_development
port: 27017
database: textual_test
<<: *global_settings
jnunemaker / gist:468109
Created Jul 8, 2010 — forked from jseifer/gist:468075
rvm version and git branch/dirtyness in prompt
View gist:468109
function __git_dirty {
git diff --quiet HEAD &>/dev/null
[ $? == 1 ] && echo "!"
function __git_branch {
__git_ps1 "(%s)"
function __my_rvm_ruby_version {
jnunemaker / gist:87fb475129c0601fa72695afe912b02f
Created Sep 7, 2017
sha256 hexdigest to number for use in mapping a string to a partition number (not consistent hashing, but just in simple hash => partition)
View gist:87fb475129c0601fa72695afe912b02f
irb(main):001:0> require "digest"
=> true
irb(main):002:0> Digest::SHA256.hexdigest("asdf")
=> "f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b"
irb(main):003:0> Digest::SHA256.hexdigest("asdf").to_i(16)
=> 108959270400061671294053818573968651411470832267186275529291850190552309358907
irb(main):004:0> Digest::SHA256.hexdigest("asdf").to_i(16).to_s(16)
=> "f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b"
irb(main):005:0> Digest::SHA256.hexdigest("asdf").to_i(16) % 10
=> 7

Keybase proof

I hereby claim:

  • I am jnunemaker on github.
  • I am jnunemaker ( on keybase.
  • I have a public key whose fingerprint is 2F06 D8EA 2B19 8EAB 40C2 7379 7BF1 39D1 EC76 CA82

To claim this, I am signing this object:

jnunemaker / mute_all_unread.js
Last active Feb 3, 2016
terrible github web notifications #protip: command + click any notifications you care about to open in new tab, then run the following in js console to mute the rest
View mute_all_unread.js
$('li.unread button.mute-note').each(function() { });
jnunemaker / blocking_with_check.rb
Created Aug 9, 2013
Kestrel blocking client with signal checks for the kestrel-client gem.
View blocking_with_check.rb
module Kestrel
class Client
class BlockingWithCheck < Blocking
attr_accessor :return_check
def get(*args)
count = 0
while count += 1
jnunemaker / Gemfile
Created Mar 11, 2013
Eventually consistent alternate indexes using cassanity.
View Gemfile
source ''
gem 'cassanity'
You can’t perform that action at this time.