Skip to content

Instantly share code, notes, and snippets.

View sirpengi's full-sized avatar

shu.chen sirpengi

View GitHub Profile
@sirpengi
sirpengi / demobuild.php
Created July 27, 2012 07:42 — forked from jkuroiwa/demobuild.php
Demo for Socrata API JSON import into MySQL
<?php
function hobo_escape($val){
// because there is no good way to escape a dynamic table/field name
$ret = preg_replace('/[^a-zA-Z _]+/', '', $val);
$ret = preg_replace('/\s+/', '_', $ret);
return $ret;
}
// Credentialing for MySQL server if you want the code to create table and load data automatically
import string
import sys
class count_dict(dict):
"""
stub object used to simplify tracking
the number of letters encountered.
this expects to be initialized with an uppercase letter yo.
"""