Skip to content

Instantly share code, notes, and snippets.

View aaronpk's full-sized avatar

Aaron Parecki aaronpk

View GitHub Profile
#!/bin/sh
EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
then
>&2 echo 'ERROR: Invalid installer signature'
rm composer-setup.php
@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;
@aaronpk
aaronpk / make-video-previews.sh
Created December 27, 2018 00:38
Make previews for a folder of .mov or .mp4 files that MacOS can open. Normalizes to 480x270 at 30fps and 96kbps audio.
#!/bin/bash
# Make previews for a folder of .mov or .mp4 files that MacOS can open.
# Normalizes to 480x270 at 30fps and 96kbps audio.
current_file=none
# Catch ctrl-c and stop the whole batch, otherwise ctrl-c just stops ffmpeg and the loop continues
trap ctrl_c INT
function ctrl_c() {
{
"Response": {
"status": 200,
"flightInfo": {
"logo": null,
"airlineName": null,
"airlineCode": "ASA",
"airlineCodeIata": null,
"tailNumber": "N248AK",
<?php
function is_valid_mf2_json($input) {
// Input to this function must be an array
if(!is_array($input))
return false;
// Keys type and properties are required at a minimum and must be arrays
if(!isset($input['type']) || !is_array($input['type']))
return false;
@aaronpk
aaronpk / indieweb-summit-rsvp.html
Last active June 2, 2018 19:33
Create an HTML page on your website and copy the below HTML into it. Replace the example URL and photo, and add your name. Then visit https://2018.indieweb.org/webmention and paste the link to your page!
<div class="h-entry">
<a class="p-author h-card" href="http://example.org">
<img src="http://example.org/photo.jpg" alt=""/>
Your Name Here</a>:
RSVP <span class="p-rsvp">yes</span>
to <a href="https://2018.indieweb.org/" class="u-in-reply-to">IndieWeb Summit</a>
</div>
@aaronpk
aaronpk / index.php
Last active February 7, 2018 19:37
IndieAuth Client Quickstart
<form action="/login.php" method="post">
<input type="url" name="url">
<input type="submit" value="Log In">
</form>
description "watchtower worker"
start on runlevel [2345]
stop on runlevel [016]
respawn
exec sudo -u ubuntu /usr/bin/php7.1 /web/sites/watchtower/scripts/watchtower.php >> /web/sites/watchtower/scripts/logs/init.log 2>&1
{
"media-endpoint": "...",
"types": {
"h-entry": {
"properties": ["like-of","bookmark-of","photo","name","content"]
},
"h-event": {
"properties": [...]
},
"h-review": {
@aaronpk
aaronpk / indieauth-client.php
Created September 9, 2012 16:44
Simple PHP example of using the indieauth.com API
<?php
session_start();
if(array_key_exists('token', $_GET)) {
// Verify the token with indieauth.com
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://indieauth.com/session?token=' . $_GET['token']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$auth = json_decode(curl_exec($ch));
// If we got a reply, store the domain in the session