Skip to content

Instantly share code, notes, and snippets.

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
@bmschmidt
bmschmidt / lectureToOutline.hs
Created October 28, 2014 18:43
Markdown headers to outline conversion
import Text.Pandoc
import Text.Pandoc.Walk (walk,query)
import Text.Pandoc.Builder
--
--Functions to first build up a new document consisting of
--all the header blocks or all the bold entries outside of headers.
--These will be recombined into a new document.
@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
@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() {
!function(){function n(n){return null!=n&&!isNaN(n)}function t(n){return n.length}function e(n){for(var t=1;n*t%1;)t*=10;return t}function r(n,t){try{for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}catch(r){n.prototype=t}}function u(){}function i(n){return aa+n in this}function o(n){return n=aa+n,n in this&&delete this[n]}function a(){var n=[];return this.forEach(function(t){n.push(t)}),n}function c(){var n=0;for(var t in this)t.charCodeAt(0)===ca&&++n;return n}function s(){for(var n in this)if(n.charCodeAt(0)===ca)return!1;return!0}function l(){}function f(n,t,e){return function(){var r=e.apply(t,arguments);return r===t?n:r}}function h(n,t){if(t in n)return t;t=t.charAt(0).toUpperCase()+t.substring(1);for(var e=0,r=sa.length;r>e;++e){var u=sa[e]+t;if(u in n)return u}}function g(){}function p(){}function v(n){function t(){for(var t,r=e,u=-1,i=r.length;++u<i;)(t=r[u].on)&&t.apply(this,arguments);return n}var e=[],r=new u;return t.on=function(t,u){var i,o=r.get(t);return arguments
@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 / 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 / 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.
rm(list=ls())
source("SQLFunctions.R")
plotSet = function(filename,dck=701,alpha=.01,lwd=8) {
library(grid)
paths = tbl(tblsrc,"paths") %.%
filter(DCK==dck) %.%
arrange(voyagenum,yearday) %.%
select(LON,LAT,voyagenum) %.%
collect()
{"publisher": "T.B. Kalbfus", "paperid": "sn82016373", "searchstring": "<img src=\"http://chroniclingamerica.loc.gov/lccn/sn82016373/1891-10-04/ed-1/seq-7/thumbnail.jpg\"> <i>The Sunday herald and weekly national intelligencer</i> (Washington [D.C.]), Friday, October 04, 1891, p. 7. <a href=\"http://chroniclingamerica.loc.gov/lccn/sn82016373/1891-10-04/ed-1/seq-7\">Read page</a>", "lat": 38.8951118, "city": "Washington", "period": "1887/1896", "filename": "sn82016373/1891-10-04_7", "edition": "1", "state": "DC", "paper": "The Sunday herald and weekly national intelligencer", "location": "Washington [D.C.]", "lng": -77.0363658, "date": "1891-10-04", "subjects": [], "successors": [], "precedors": ["sn85042682"], "page": "7"}
{"publisher": "T.B. Kalbfus", "paperid": "sn82016373", "searchstring": "<img src=\"http://chroniclingamerica.loc.gov/lccn/sn82016373/1891-10-04/ed-1/seq-5/thumbnail.jpg\"> <i>The Sunday herald and weekly national intelligencer</i> (Washington [D.C.]), Friday, October 04, 1891, p. 5. <a href