Skip to content

Instantly share code, notes, and snippets.

View sjg's full-sized avatar

Steven Gray sjg

View GitHub Profile
@sjg
sjg / color-c
Created January 3, 2012 11:15
Color Lines in C
#include <stdio.h>
#define RESET 0
#define BRIGHT 1
#define DIM 2
#define UNDERLINE 3
#define BLINK 4
#define REVERSE 7
#define HIDDEN 8
@sjg
sjg / twitterProxy.js
Last active December 18, 2015 19:19
A small twitter proxy server (written in node) for all the developers who want to keep their Twitter applications running and let node do the heavy OAuth lifting for you.
#!/usr/bin/env node
// Before running install
// -- npm install -g optimist oauth step colors express
var serverPort = 8008;
var argv = require('optimist')
.usage('Usage: --key=[consumer key] -secret=[consumer secret]')
.demand(['key', 'secret'])
@sjg
sjg / twitter_collect.js
Last active December 23, 2015 23:49
Twitter Collect
#!/usr/bin/env node
var OAuth = require('oauth').OAuth;
var colors = require('colors');
var access_token = null;
var access_token_secret = null;
var key = null;
var secret = null;
@sjg
sjg / map3d.html
Last active December 27, 2015 20:09
Get Lat/Lng from Google Earth Web API
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<head>
<title>Google Earth - Get LatLng</title>
<script src="http://www.google.com/jsapi?key=APIKEY"></script>
<script>
google.load("earth", "1");
var ge = null;
@sjg
sjg / map.html
Created November 9, 2013 10:38
Basic Google Maps with some style
<html>
<head>
<style>
#map{
background-color: red;
height:100%;
width: 100%;
}
</style>
@sjg
sjg / serverTest.html
Created November 9, 2013 11:53
Server Interaction Code to send Lat/Lng to be saved
<html>
<head>
<script src="http://code.jquery.com/jquery-2.0.1.min.js"></script>
</head>
<body>
<script src="http://www.stevenjamesgray.com:9090/socket.io/socket.io.js"></script>
<script>
@sjg
sjg / parseCSVFile.js
Last active December 27, 2015 20:39
Parse CSV File
<script>
var mapOptions = {
center: new google.maps.LatLng(51.5, -0.11),
zoom: 10,
mapTypeId: google.maps.MapTypeId.TERRAIN
}
var getTweets;
$(function() {
@sjg
sjg / Constants.m
Created January 19, 2014 22:36
Various code samples for Google iOS SDK Blog Posts
NSString* const api_forecast_layers_cap = @"http://datapoint.metoffice.gov.uk/public/data/layer/wxfcs/all/json/capabilities?key=%@";
NSString* const api_obs_layers_cap = @"http://datapoint.metoffice.gov.uk/public/data/layer/wxobs/all/json/capabilities?key=%@";
@sjg
sjg / gist:bb4dfa190781a8f5fd62
Created December 11, 2014 14:02
imageServer.js
var imagesnap = require('imagesnap');
var fs = require('fs');
function grabImage(){
var imageStream = fs.createWriteStream('capture.jpg');
imagesnap().pipe(imageStream);
}
setInterval(function(){
grabImage();
"""
Pull Greater London Authority boundary definition (geojson) and derive the outer bounding box
"""
from operator import itemgetter
import json
import requests
r = requests.get('http://mapit.mysociety.org/area/2247.geojson')
coords = r.json()['coordinates'][0]