Skip to content

Instantly share code, notes, and snippets.

View natematias's full-sized avatar

J. Nathan Matias natematias

View GitHub Profile
@natematias
natematias / extract_baby_names.rb
Last active December 12, 2015 08:19
Scrape baby names from the infochimps US census site download
#scraper requires the SSN scraped babynames dataset from infochimps
#www.infochimps.com/datasets/popular-baby-names-by-year-top-1000-us-social-security-administr
require 'nokogiri'
for year in (1880..2009)
f = File.open("babynames/top-1000-#{year}-num.html")
html = f.read
doc = Nokogiri::HTML(html)
@natematias
natematias / httpd2.conf extract
Created January 28, 2013 22:03
What I added to my OSX /etc/apache2/httpd.conf to proxy CouchDB through Apache and overcome the cross-site scripting problem when developing my own couch apps.
## just for context, here's the Directory entry from /etc/apache2/httpd.conf
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
</Directory>
# Turn on mod_rewrite
@natematias
natematias / top_uk_books
Created August 16, 2012 18:54
Top UK Books
[{"Rank":1,"Title":"Da Vinci Code,The","Author":"Brown, Dan","Volume Sales":"5,094,805","Editions Combined":7,"Imprint":"Corgi Books","Publisher":"Transworld Grp","Publication Date":"Monday, March 1, 2004","Genre":"F2.1 Crime, Thriller & Adventure"},
{"Rank":2,"Title":"Harry Potter and the Deathly Hallows","Author":"Rowling, J.K.","Volume Sales":"4,475,152","Editions Combined":8,"Imprint":"Bloomsbury Publishing PLC","Publisher":"Bloomsbury Grp","Publication Date":"Saturday, July 21, 2007","Genre":"Y2.1 Children's Fiction"},
{"Rank":3,"Title":"Harry Potter and the Philosopher's Stone","Author":"Rowling, J.K.","Volume Sales":"4,200,654","Editions Combined":8,"Imprint":"Bloomsbury Publishing PLC","Publisher":"Bloomsbury Grp","Publication Date":"Thursday, June 26, 1997","Genre":"Y2.1 Children's Fiction"},
{"Rank":4,"Title":"Harry Potter and the Order of the Phoenix","Author":"Rowling, J.K.","Volume Sales":"4,179,479","Editions Combined":5,"Imprint":"Bloomsbury Publishing PLC","Publisher":"Bloomsbury Grp","Publ
@natematias
natematias / wordpress_key_value_query.sql
Created December 1, 2010 16:11
one record per WordPress user account
SELECT wp_users.user_login, wp_users.user_nicename, wp_users.user_email
GROUP_CONCAT(CONCAT(meta_key, ": ", meta_value)),
FROM wp_users JOIN wp_usermeta ON wp_users.id = wp_usermeta.user_id
GROUP BY wp_users.user_login;
find . -type f \( -iname "*.cpp" -or -iname "*.java" \)
# from IRB
require 'rexml/document'
include REXML
doc = Document.new(File.new('Strings.xml'))
elements = doc.root.elements.collect
# Get a wordcount:
#This script will change the existing card database for wagn so that the root template card specifies that reads will require an authenticated user rather than anonymous access as was the default
# The role encapsulating read needs authenticated user
Card.find_by_name("Basic+*tform").permit(:read, Role[:auth])