Skip to content

Instantly share code, notes, and snippets.

View andynu's full-sized avatar

Andrew Nutter-Upham andynu

View GitHub Profile
@andynu
andynu / encoding_discovery.rb
Created August 24, 2016 18:14
Encoding error details
str = "ó bhí mé óg, thaitin leabhair liom"
bytes = str.bytes
targets = ["贸","铆","茅","贸"].uniq
p :original, str
w = str.force_encoding('ISO-8859-1')
#p :iso88591, w
#p :utf8,w.encode("UTF-8")
{
"response": {
"version":"0.1",
"termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
"features": {
"hourly": 1
}
}
,
@andynu
andynu / hourly.json
Created November 30, 2015 20:05
Parsing JSON Issue
{
"response": {
"version":"0.1",
"termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
"features": {
"hourly": 1
}
}
,
"hourly_forecast": [
@andynu
andynu / Spirograph-v2.markdown
Created January 27, 2014 23:27
A Pen by Andrew Nutter-Upham.

Spirograph v2

A Spirograph is a geometric drawing toy that produces mathematical roulette curves of the variety technically known as hypotrochoids and epitrochoids. It was developed by British engineer Denys Fisher and first sold in 1965.

"Spirograph" has also been used to describe a variety of software applications that display similar curves. It has also been applied to the class of curves that can be produced with the drawing equipment, and therefore may be regarded as a synonym of hypotrochoid. The name has been a registered trademark of Hasbro, Inc., since it bought the Denys Fisher company.

A Pen by Andrew Nutter-Upham on CodePen.

License.

@andynu
andynu / ytget.py
Created January 3, 2013 21:56
Search youtube. Download the first page of videos. Convert to mp3s. requires curl, youtubedown, and soundconverter
#!/usr/bin/env python
from subprocess import check_output, CalledProcessError, call
import re
import glob
# Search youtube
search_term = 'Chordettes'
youtube_search_url = 'https://www.youtube.com/results?search_query=' + search_term
youtube_search_results = check_output(["curl", youtube_search_url])
@andynu
andynu / generate_glyphicons_pro_css.rb
Created May 14, 2012 15:28
Generate css for Glyphicons Pro.
#!/usr/bin/env ruby
#
# Generate css for the pro glyphicons.
# Run this script in the glyphicons_pro/glyphicons/png folder
# from the purchased zip file.
#
# see http://glyphicons.com/ for purchase/license information.
#
render = (ARGV.include? "--html") ? :html : :css
@andynu
andynu / gist:1477485
Created December 14, 2011 17:08
A array of hashes summing method
def sum_by(arr_hash, value_key, group_key=nil, &block)
if group_key.instance_of? Proc
block = group_key
group_key = nil
end
arr_hash.inject({}) do |sums, row|
group_key = (block_given?) ? block.call(row) : group_key
sums[group_key] ||= 0.0
sums[group_key] += row[value_key] || 0.0
sums
@andynu
andynu / rest_api.sh
Created November 30, 2011 05:51
Bare bones, no auth, json rest server in rails.
#!/bin/bash -x
rvm install 1.9.3-head
rvm use 1.9.3-head
rvm gemset create rails31
rvm use 1.9.3-head@rails31
gem install bundler rails
rails new rest_api
@andynu
andynu / falling_balls.js.coffee
Created September 28, 2011 12:31
a coffeescript clone of the processing's bouncybubbles example
#
# a coffeescript port of http://processing.org/learning/topics/bouncybubbles.html
#
ids = 0
spring = 0.02
gravity = 0.01
friction = -0.2
force_field = 1.5
balls = []
@andynu
andynu / active_record_by_inference.rb
Created September 24, 2011 21:56
Reverse engineer ActiveRecord definitions by examining an existing (mysql) database.
#!/usr/bin/env ruby
# encoding: utf-8
#
# Reverse engineer ActiveRecord definitions
# by examining an existing database.
#
# This is mysql spesific at the moment.
#
# % active_record_by_inference -h
# Usage: active_record_by_inference.rb [options] [table] [table] ...