Skip to content

Instantly share code, notes, and snippets.

View jpowell's full-sized avatar

Justin Powell jpowell

View GitHub Profile
@jpowell
jpowell / fizzbuzz.rb
Created November 5, 2013 21:08
FizzBuzz
SPECIAL_MODS = [[3, 'Fizz'], [5, 'Buzz']]
(1..100).each do |i|
output = SPECIAL_MODS.reduce([]) { |a, (n, s)| a.push(s) if i % n == 0; a }
puts output.empty? ? i : output.join
end
@jpowell
jpowell / phone_format.js
Created April 16, 2013 20:12
http://www.phoneformat.com/js/PhoneFormat.js - wrapper for googles Libphonenumber JS library guy said he was taking the site down soon.
/*
Copyright (C) Alan Beebe (alan.beebe@gmail.com).
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@jpowell
jpowell / update_classification.json
Created March 19, 2013 23:41
OrgSync API: Classifications: Update School Classification
{
"id":5,
"name":"Foreign Exchange"
}
@jpowell
jpowell / show_classification.json
Created March 19, 2013 23:15
OrgSync API: Classifications: List Single Classification Information
{
"id":2,
"name":"Alumni"
}
@jpowell
jpowell / list_classifications.json
Created March 19, 2013 23:09
OrgSync API: Classifications: List School Classifications
[
{
"id":2,
"name":"Alumni"
},
{
"id":3,
"name":"Faculty"
},
{
@jpowell
jpowell / create_classification.json
Created March 19, 2013 23:01
OrgSync API: Classifications: Create School Classification
{
"id":1,
"name":"Students"
}
@jpowell
jpowell / clear_branches.rb
Created November 20, 2012 00:36
list and clear branches match a prefix
#! /usr/bin/ruby
class BranchList < Struct.new(:name_prefix)
require 'set'
COMMANDS = {
:remote => {
:list => 'git remote show origin',
:remove => 'git push origin :%s'
},
@jpowell
jpowell / my.cnf
Created April 21, 2012 19:12
MySQL config optimized for importing a dump
[mysqld]
max_allowed_packet=128M
#innodb_force_recovery=1
# fast import settings
key_buffer_size=2G
innodb_flush_log_at_trx_commit = 2
innodb_flush_method=O_DSYNC
innodb_buffer_pool_size=64M
@jpowell
jpowell / nbuilder.rb
Created April 21, 2012 18:58 — forked from sishen/gist:1019347
Nokogiri Template Builder. (Rails 3.0)
require 'action_view'
module ActionView::Template::Handlers
class NokogiriBuilder
class_attribute :default_format
self.default_format = Mime::XML
def call template
require 'nokogiri'
"xml = ::Nokogiri::XML::Builder.new { |xml|" +
@jpowell
jpowell / email_tokenizer.rb
Created February 9, 2012 16:58
simple tokenizers for ruby
class EmailTokenizer < StringTokenizer
def initialize text
super text, /(\s|,|;)+/
end
def self.filter array=[]
result = []
array.each do |item|
result << item.downcase if item =~ /.+@.+/
end