Skip to content

Instantly share code, notes, and snippets.

View tylor's full-sized avatar

Tylor Sherman tylor

View GitHub Profile
@tylor
tylor / gist:2892478
Created June 7, 2012 23:52
Quick CSS fix for echomemoirs.com
/* Full length pages, remove fancy scroll bar, and add clearfix */
#Faux:after,
.Faux:after,
#FauxInside:after,
.FauxInside:after,
#Main:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
@tylor
tylor / gist:2792879
Created May 26, 2012 08:14
Carto style for parking meters in Vancouver
Map {
background-color: #b8dee6;
}
#countries {
::outline {
line-color: #85c5d3;
line-width: 2;
line-join: round;
}
@tylor
tylor / index.js
Created March 7, 2012 23:03
JSON to CSV
var fs = require('fs');
var csv = require('csv');
var data = fs.readFileSync('all_reports.json', 'utf8');
var lines = data.split("\n");
var all = [];
for (var i = 0; i < lines.length; i++) {
console.log(i);
var items = JSON.parse(lines[i]).items;
@tylor
tylor / gist:1719855
Created February 1, 2012 22:24
Facebook IPO filing word frequency analysis
Quick and dirty word frequency analysis of the Facebook IPO filing document found here: http://www.sec.gov/Archives/edgar/data/1326801/000119312512034517/d287954ds1.htm
Using command from: https://josephhall.org/nqb2/index.php/word_frequency
$ tr '[A-Z]' '[a-z]' < facebook_ipo.txt | tr -cd '[A-Za-z0-9_ \012]' | tr -s '[ ]' '\012' | sort | uniq -c | sort -nr
Or copy passage to clipboard and paste to command line:
$ pbpaste | tr '[A-Z]' '[a-z]' | tr -cd '[A-Za-z0-9_ \012]' | tr -s '[ ]' '\012' | sort | uniq -c | sort -nr
@tylor
tylor / package.json
Created January 25, 2012 03:41
Read all CSVs in a directory and do something with them
{
"author": "tylor",
"name": "csv_street_trees",
"version": "0.0.0",
"repository": {
"url": ""
},
"main": "trees.js",
"engines": {
"node": "~v0.4.9"
@tylor
tylor / results.txt
Created January 9, 2012 06:57
Try DanielRapp/twss.js against The Office
true - How about a big round of applause for Mr. Dwight Schrute. This is huge.
true - Come on, let's gangbang this thing and go home.
true - Hold it in your mouth if you can't swallow.
true - It was easy to get in but impossible to rise up.
false - And you were directly under her the entire time?
true - Come again.
true - I need two men on this.
false - You're hardly my first.
true - The thought of popping one of your beets into my mouth makes me want to vomit.
true - Does the skin look red and swollen.
@tylor
tylor / qr.php
Created November 24, 2011 19:27
Get an email anytime someone visits this page
<?php
if (!isset($_COOKIE['mailed'])) {
$to = 'email@example.com';
$subject = 'QR code was used!';
$body = print_r($_SERVER, true);
if (mail($to, $subject, $body)) {
setcookie("mailed", true);
}
}
?>
@tylor
tylor / README.txt
Created October 25, 2011 19:20
JSLint validation in Textmate
Quick and dirty JSLint validator for Textmate:
1. Install node and npm
2. Install jslint module: npm install -g jslint
3. Create a new command named jslint for Javascript in the Bundle Editor
- Input: 'Entire Document'
- Output: 'Show as Tool Tip'
- Activation: Key Equivalent, something like Command+j
- Command(s), probably have to change your node path:
@tylor
tylor / multilingual_box.inc
Created October 9, 2011 04:00
Extend boxes box, implement hook_boxes_plugins().
<?php
/**
* Simple custom text box.
*/
class multilingual_box extends boxes_box {
/**
* Implementation of boxes_content::options_defaults().
*/
public function options_defaults() {
@tylor
tylor / wktFromZip.php
Created September 29, 2011 22:10
Simple PHP class to get shapefile rows using ogr
<?php
/**
* Could also look at parsing shapefiles manually: http://en.wikipedia.org/wiki/Shapefile#Shapefile_shape_format_.28.shp.29
*/
class wktFromZip {
function __construct($fid) {
// Extract zip file to tmp.
$file = file_load($fid);