Skip to content

Instantly share code, notes, and snippets.

Jo Potts jopotts

Block or report user

Report or block jopotts

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
@jopotts
jopotts / set_partitioner.rb
Created Jun 24, 2014
Find combinations of sets built from a range that add to a given value
View set_partitioner.rb
class SetPartitioner
def initialize(min, max, total)
@min = min
@max = max
@total = total
end
def any?
sets.present?
View keybase.md

Keybase proof

I hereby claim:

  • I am jopotts on github.
  • I am jopotts (https://keybase.io/jopotts) on keybase.
  • I have a public key whose fingerprint is DEAA 7CA2 5BEE FBB7 B3B5 F9FE 4498 EE2E D41F 7DB6

To claim this, I am signing this object:

View random_string.rb
module RandomString
HUMAN = %w{2 3 4 6 7 9 a c d e f g h j k m n p q r t v w x y}
LOWER = [*'a'..'z']
PARAM = [*'a'..'z', *0..9]
FULL = [*'a'..'z', *'A'..'Z', *0..9]
MIXED = [*'a'..'z', *'A'..'Z']
def self.by_rand(length = 8, set = :full)
chars = get_chars(set)
@jopotts
jopotts / default_values.rb
Last active Dec 27, 2015
Simple default values on creation of ActiveRecord models
View default_values.rb
module DefaultValues
def has_default_values(default_values = {})
class_attribute :default_values
self.default_values = default_values
after_initialize :assign_default_values
include InstanceMethods
@jopotts
jopotts / lookups.rb
Last active Dec 26, 2015
A module for the definition of lookup lists
View lookups.rb
require "active_support/inflector"
module Lookups
# Allows the definition of lookup values
def define_lookup(const_name, lookup_codes)
mod = Module.new do
extend self
You can’t perform that action at this time.