Skip to content

Instantly share code, notes, and snippets.

  1. If you haven't before, follow these instructions to get set up in Amazon EC2.

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/get-set-up-for-amazon-ec2.html

  1. Follow these instructions to launch a new Amazon EC2 Instance. Use the Ubuntu AMI: Ubuntu Server 14.04 LTS (HVM) and the m3.medium instance type. As part of this process, you'll download a .pem file, which you'll need to connect to the instance.

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-instance_linux.html

  1. Connect to the instance by opening a terminal in the same directory as the .pem file you saved in step 2 and typing this command, replacing xxx.pem with the name of your .pem file, and xxx.amazonaws.com with the public DNS name of your server, which is available on the EC2/Instances dashboard page.

sudo apt-get install -y apache2

sudo a2enmod rewrite

sudo a2enmod headers

sudo apt-get install -y git

sudo apt-get install nodejs

@tmaybe
tmaybe / parse.py
Created February 24, 2013 05:02
Simple Python script for reading from a file, changing something about it with a regular expression, and writing the result to a new file.
import re
read_in = open("original.plist")
write_out = open("new.plist","w")
minus = 280
pat = re.compile('\t\t\t\t<real>([0-9]*)<')
for line in read_in:
mo = pat.search(line)
if mo:
value = int(mo.group(1))
@tmaybe
tmaybe / gist:5357731
Created April 10, 2013 19:34
Snippet for a quick UIButton in Objective-C
UIButton *tmpButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
tmpButton.frame = CGRectMake(0, 0, 100, 50);
[tmpButton addTarget:self action:@selector(pressButton:) forControlEvents:UIControlEventTouchUpInside];
[tmpButton setTitle:@"TEST" forState:UIControlStateNormal];
[self.view addSubview:tmpButton];
@tmaybe
tmaybe / PROCESS.md
Last active December 19, 2015 17:09
Afghanistan Albers

Convert shape file to GeoJSON file

ogr2ogr -f GeoJSON provincial.json admin2_poly_32.shp

Convert and combine GeoJSON files into a single TopoJSON file, making the contents of either DIST_32_NA or PRV_NAME the id attribute, renaming the PROV_32_NA property to province, and preserving the province property

topojson --id-property DIST_32_NA,PRV_NAME -p province=PROV_32_NA -p province -o combined.json international-geo.json provinces-geo.json districts-geo.json

@tmaybe
tmaybe / README.md
Last active December 20, 2015 11:39 — forked from tommaybe/LICENSE.md
Heat Grid Showing Survey Results
@tmaybe
tmaybe / README.md
Last active December 21, 2015 03:59
two methods of displaying data from a Google spreadsheet compared

Testing two different methods for pulling data from a google spreadsheet for display on a web page:

  • using a direct link to the automatically generated csv as described by Kristin Henry.

  • using Tabletop.js to parse the spreadsheet automatically generated in 'Web page' format.

It appears that the csv version of the data generated by Google updates less frequently than the 'Web page' version, so using Tabletop.js is more reliable if you need immediate updates on data without manual refresh.

@tmaybe
tmaybe / app.yaml
Last active June 14, 2016 18:49
sample code for caching API requests in GAE
application: apipemilucache
version: 0-1-3
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: cache.application
@tmaybe
tmaybe / strip_quoted_newlines.py
Last active September 27, 2016 20:30
strip quoted newlines from a folder-full of CSV files
import csv
import re
import glob
for input_filename in glob.glob("./*.csv"):
print("working on {}".format(input_filename))
with open(input_filename, 'rU') as infile:
output_filename = "./strp-{}.csv".format(input_filename.lower().rstrip(".csv").lstrip("./"))
with open(output_filename, 'a') as outfile:
output_writer = csv.writer(outfile)
@tmaybe
tmaybe / init.lua
Last active September 1, 2017 21:33
--
-- HAMMERSPOON CONFIG MANAGEMENT
--
-- reload the config when this file changes
function reloadConfig(files)
doReload = false
for _, file in pairs(files) do
if file:sub(-4) == ".lua" then