Skip to content

Instantly share code, notes, and snippets.

View johnschult's full-sized avatar
🧠
Debugging reality with applied AI. Results may vary.

John Schult johnschult

🧠
Debugging reality with applied AI. Results may vary.
View GitHub Profile
@johnschult
johnschult / git.rb
Created April 17, 2009 16:07
Returns the git tag that has the same hash as the head of the branch parameter
require 'rubygems'
require 'git'
module Git
class Lib
# finds a tag with the same hash as the specified branch's head (if any)
def tag_for_head(branch)
tag = nil
head_hash = command('show-ref', ['--hash', "#{branch}"])
command('show-ref', ['--tags']).each do |r|
def extended_encode(data_arr, max_value)
# Douglas F Shearer 2007
# http://douglasfshearer.com/blog/ruby-google-charts-api-data-encoding
characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.'.split(//)
data = ''
data_arr.each do |value|
if value.is_a?(Integer) && value >= 0
new_value = ((4095 * value.to_f / max_value.to_f).to_i)
sixtyfours = new_value/64
units = new_value%64