Skip to content

Instantly share code, notes, and snippets.

View twslankard's full-sized avatar

Tom Slankard twslankard

  • Ouster Inc.
  • San Francisco, CA
View GitHub Profile
@twslankard
twslankard / gist:637020
Created October 20, 2010 18:35
Verifying Amazon SNS Notification Signatures
<?php
// get the raw HTTP post data
$postdata = file_get_contents('php://input');
// the post data is JSON, so let's decode it and grab the various fields
$json = json_decode($postdata);
$subject = $json->Subject;
$message = $json->Message;
$signature = $json->Signature;
@twslankard
twslankard / gist:760182
Created December 30, 2010 19:33
jquery load example
<html>
<head>
<script src="jquery.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
</div>
<script type="text/javascript">
$('#container').load('hello.txt');
</script>
#include <cstdio>
template <std::size_t N>
void printArray(const int (&arr)[N]) {
for (int i = 0; i < N-1; i++) {
printf("%d, ", arr[i]);
}
printf("%d\n", arr[N-1]);
}
@twslankard
twslankard / mountpoint.c
Created January 14, 2011 22:25
Using stat to determine programmatically whether a file is a mount point.
#include <assert.h>
#include <sys/stat.h>
#include <stdint.h>
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char * argv[]) {
@twslankard
twslankard / mime.php
Created May 24, 2011 17:51
simple Mime/Multipart email class for sending attachments and a text or html body in the charset of your choosing
<?php
/*
* simple Mime/Multipart email class for sending attachments and a text or html body in the charset of your choosing
* 2011 tom slankard, earthmine inc
*/
class Mime {
private $boundary = null;
@twslankard
twslankard / getaddrinfo.c
Created May 31, 2011 20:24
getaddrinfo / inet_ntop example
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netdb.h>
int main(int argc, char * argv[]) {
struct addrinfo * _addrinfo;
struct addrinfo * _res;
@twslankard
twslankard / mousekiller.c
Created September 28, 2011 18:43
disable mouse acceleration on mac os x
/**
* to build: gcc -o mousekiller mousekiller.c -framework CoreFoundation -framework IOKit
*/
#include <stdio.h>
#include <IOKit/hidsystem/IOHIDLib.h>
#include <IOKit/hidsystem/IOHIDParameter.h>
int main(int argc, char **argv)
{
// create a list of flags
std::vector<bool> flags;
for(int i = 0; i < 10; i++)
flags.push_back(false);
// set some flags
flags[1] = true;
flags[3] = true;
flags[4] = true;
flags[8] = true;
@twslankard
twslankard / decider.js
Created March 20, 2013 23:24
Simple Workflow node.js-based Decider test
var events = require('events');
var util = require('util');
function Decider(_domain, task_list) {
var aws = require('aws-sdk');
{ events:
[ { eventId: 1,
eventTimestamp: 1363887002.226,
eventType: 'WorkflowExecutionStarted',
workflowExecutionStartedEventAttributes: [Object] },
{ decisionTaskScheduledEventAttributes: [Object],
eventId: 2,
eventTimestamp: 1363887002.226,
eventType: 'DecisionTaskScheduled' },
{ decisionTaskStartedEventAttributes: [Object],