This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lxml.html | |
def get_incidents(): | |
incidents = [] | |
url = "http://slonews.thetribunenews.com/police_log/slo_log.php" | |
tree = lxml.html.parse(url) | |
for inc in tree.xpath("//table[@class='report']"): | |
inc_keys = inc.xpath("tr/td[@class='c1']") | |
inc_keys = [key.text_content() for key in inc_keys] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python2 | |
import os | |
import mutagen | |
def getinfo(song): | |
artist = "Unknown" | |
if song.has_key("ALBUMARTIST"): | |
artist = song.get("ALBUMARTIST").pop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from sys import argv, stdin, stdout | |
import re | |
translate = { | |
'em': 'enterMove', | |
'sm': 'showMove', | |
'show': 'showBoard', | |
'am': 'applyMove', | |
'dm': 'doMove', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Status = (function() { | |
function Status() { | |
this.$status = $('#status'); | |
} | |
Status.prototype.set = function(str) { | |
var _this = this; | |
this.$status.text(str); | |
if (this.timeoutID) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Original */ | |
var setIcon = function (evt) { | |
var base = "http://incidents.slocountyfire.org/static/img/"; | |
if (evt.properties.category === "Medical") { | |
evt.layer.options.icon = new L.Icon(base + "m-marker.png"); | |
} else if (evt.properties.category === "Fire") { | |
evt.layer.options.icon = new L.Icon(base + "f-marker.png"); | |
} else if (evt.properties.category === "Hazard") { | |
evt.layer.options.icon = new L.Icon(base + "h-marker.png"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import time | |
import difflib | |
import sys | |
import os | |
from string import rstrip | |
def run(command, infile_path, timeout=10): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
fs.readFile('README.md', (err, data) ⇨ { | |
if (err) { | |
console.error("Could not open file: %s", err); | |
process.exit(1); | |
} | |
console.log(data); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Shorter function syntax. | |
// | |
// This version does not respect "Tennent's correspondence principle" -- it's nothing | |
// more than syntactic sugar for the traditional function syntax. That means when you | |
// see the normal braced body of a function, whether it's a longhand function or this | |
// shorthand version, there's no difference: return, this, and arguments are all tied | |
// to the new function body, and there's no implicit returning of the last expression | |
// result. | |
a.some((x) → { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// non-TCP, shorter function | |
a.some((x) → { | |
if (invalid(x)) | |
return true; | |
console.log(x); | |
}) | |
// maximally concise, implicit return | |
a.map((x) → x * 17) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
export GDAL_TIFF_INTERNAL_MASK=YES | |
for f in /media/LAR_HD/6Inch/*.tif | |
do | |
nearblack -co TILED=YES -setmask -nb 0 -of GTiff -o ./prewarp.tif $f | |
gdalwarp -co TILED=YES -dstalpha -s_srs EPSG:2229 -t_srs EPSG:4326 prewarp.tif warped.tif | |
rm prewarp.tif | |
gdal_translate -co TILED=YES -co JPEG_QUALITY=80 -co COMPRESS=JPEG -co PHOTOMETRIC=YCBCR -b 1 -b 2 -b 3 -mask 4 warped.tif final.tif |