Skip to content

Instantly share code, notes, and snippets.

@bmschmidt
bmschmidt / bookwormFormat.py
Last active August 29, 2015 14:04
Quickly format strings for searchstring in the mysql client
"""
This uses a fake sprintf style construction to handle easily resetting searchstrings without rebuilding the whole database.
Anything in a string like this:
%(blah blah)s
will be broken out in mysql as a literal.
By default, this assumes you only need the "catalog" field: things will get strange if you try to use any non-unique fields.
@bmschmidt
bmschmidt / dates.md
Created July 31, 2014 19:49
Date functions

MySQL has a canonical implementation:

SELECT FROM_DAYS(730669);

+-------------------+
| FROM_DAYS(730669) |
+-------------------+
| 2000-07-03        |
@bmschmidt
bmschmidt / gist:a1c32e2d0260519a31d0
Created September 24, 2014 22:42
Corrected field_descriptions.json
[{"field":"date",
"datatype":"time",
"type":"numeric",
"unique":true,
"derived":[{"resolution":"month"}]},
{"field":"searchstring",
"datatype":"searchstring",
"type":"text",
"unique":true},
{"field":"series",
@bmschmidt
bmschmidt / gist:cc815e1734d048a9312a
Last active August 29, 2015 14:07
reveal.js bookworm plugin code
d3.selectAll("code")
.filter(function(d) {
try {JSON.parse(d3.select(this).text());
return true }
catch(exception) {
return false}})
.each(function(d) {
d3.select(this).on("click",function() {
@bmschmidt
bmschmidt / --etc--my.cnf
Created October 21, 2014 20:27
Working Mac My.cnf configuration for bookworm--replace double dashes with slashes to get locations
[client]
user = _www
password = mysecret
[mysqld]
myisam_sort_buffer_size = 512M
read_rnd_buffer_size = 8M
read_buffer_size = 4M
max_heap_table_size = 1024M
tmp_table_size = 1024M
ubuntu@ip-172-30-0-121:~/bookworm-setup$ cat install.sh
apt-get install emacs
apt-get install apache2
apt-get install mysql-server
apt-get install libmysqlclient-dev
apt-get install git
apt-get install make
MariaDB [DEGREES]> SELECT cip,cipTitle,SUM(count) FROM degrees NATURAL JOIN cip WHERE year=2010 AND school=186131 and variable="TOTAL" AND level=5 GROUP BY cip;
+---------+----------------------------------------------------------------------+------------+
| cip | cipTitle | SUM(count) |
+---------+----------------------------------------------------------------------+------------+
| 4.0201 | Architecture. | 15 |
| 5.0104 | East Asian Studies. | 10 |
| 5.0108 | Near and Middle Eastern Studies. | 13 |
| 14.0701 | Chemical Engineering. | 36 |
| 14.0801 | Civil Engineering, General. | 18 |
| 14.0901 | Computer Engineering, General. | 44 |
American Empire (1942) Western American __
American Teen (2008) Documentary American __
American Nymphette 2 (2001) (V) Adult American __
An American Journalist (2009) Drama An American __
An American Journalist (2009) Short An American __
American Arab (2013) Biography American __
American Arab (2013) Documentary American __
American Arab (2013) Family American __
American Arab (2013) News American __
An American Dream (1966) Drama An American __
@bmschmidt
bmschmidt / README.md
Created April 11, 2015 21:31
Changing Shapefiles

This is just a dummy file to get started

@bmschmidt
bmschmidt / gist:1eedbc2bcd21e059af4d
Last active August 29, 2015 14:19
Use Python instead of Apache to host a Bookworm
mkdir GUI
make linechartGUI webDirectory=GUI
git clone http://github.com/Bookworm-Project/BookwormAPI GUI/cgi-bin
git clone http://github.com/bmschmidt/BookwormD3 GUI/BookwormD3
cd GUI; python -m CGIHTTPServer 8000