Skip to content

Instantly share code, notes, and snippets.

View aaronpk's full-sized avatar

Aaron Parecki aaronpk

View GitHub Profile
$(document).keydown(function(e){
// Ignore the keypress if any meta keys were pressed along with the arrows
if(e.metaKey || e.ctrlKey || e.altKey || e.shiftKey) return;
// Left arrow
if(e.keyCode == 37) {
// Find a rel="prev" link on the page
if($("a[rel='prev']").length > 0){
// Highlight it briefly
$("a[rel='prev']").addClass('hover');
$ target="http://waterpigs.co.uk/notes/4RvAFv/"
$ source="http://aaronparecki.com/replies/2013/09/07/2/indiewebcampuk"
$ curl -i -s $target | grep 'rel="http://webmention.org/"'
Link: <http://waterpigs.co.uk/mentions/webmention/>; rel="http://webmention.org/"
$ endpoint="http://waterpigs.co.uk/mentions/webmention/"
$ curl -i -d "source=$your_url&target=$target_url" $endpoint
@aaronpk
aaronpk / nginx
Created September 11, 2013 18:10
nginx init.d script
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: nginx init.d dash script for Ubuntu <=9.10.
# Description: nginx init.d dash script for Ubuntu <=9.10.
### END INIT INFO
$ grep -r "\[Weather\]" . | cut -f4 -d: | cut -f 3- -d " " | sed -e 's/(.*$//g' -e 's/ for the.*//g' -e 's/ /_/g' | awk '{x[$0]++}END{for(i in x){printf("%s\t%d\n", i, x[i])}}' | sort -nk2| column -t -s " " | gtac
Light_rain 46
Clear 44
Drizzle 24
Possible_drizzle 8
Sprinkling 5
Rain 4
Possible_sprinkling 4
Possible_light_rain 1
@aaronpk
aaronpk / gist:6693579
Created September 25, 2013 00:54
Center a MKMapView given a GeoJSON bounding box
double lng1 = [bbox[0] doubleValue];
double lat1 = [bbox[1] doubleValue];
double lng2 = [bbox[2] doubleValue];
double lat2 = [bbox[3] doubleValue];
MKCoordinateSpan span;
span.latitudeDelta = fabs(lat2 - lat1);
span.longitudeDelta = fabs(lng2 - lng1);
CLLocationCoordinate2D center;
{
"game": {
"game_id": "pj9Zb8okVfqEHUCt",
"name": "Aaron Test Board 10",
"bbox": [
-122.688703536987,
45.511970901574,
-122.669649124146,
45.5231270146092
],
@aaronpk
aaronpk / browser.js
Created October 13, 2013 06:51
Sample code for real-time comments using http://indiewebcamp.com/webmention, Redis and Websockets.
var commentContainerSelector = '.references ul';
if($(commentContainerSelector).length > 0 && "WebSocket" in window) {
var ws = new WebSocket(window.location.origin.replace("http","ws")+":8077");
ws.onopen = function(event) {
// Send the current window URL to the server to register to receive notifications about this URL
ws.send(window.location);
};
ws.onmessage = function(event) {
// Whatever comes back from the websockets connection is rendered in the list
RewriteEngine on
RewriteRule ([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})\.png img.php?r=$1&g=$2&b=$3 [QSA,L]
$ch = curl_init('https://www.arcgis.com/sharing/oauth2/token');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(
'grant_type' => 'client_credentials',
'client_id' => $client_id,
'client_secret' => $client_secret
)));
$response = json_decode(curl_exec($ch));
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.