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: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 / 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 / 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],
@twslankard
twslankard / mpu.rb
Created April 2, 2013 20:53
Ruby S3 multi-part uploader with resume capability. Usage: ruby mpu.rb [file to upload] [bucket] [key] My knowledge of Ruby isn't great, so I offer my apologies for the bad code.
#!/usr/bin/env ruby
require 'rubygems'
require 'aws-sdk'
def readPart(file_name, file_size, part_size, part)
file_offset = part_size * ( part - 1 )
bytes_to_read = [ part_size, file_size - file_offset ].min
part_contents = File.read( file_name, bytes_to_read, file_offset )
part_md5 = Digest::MD5.hexdigest( part_contents )
@twslankard
twslankard / syslog
Created August 29, 2013 16:03
soft lockups on t1.micro
Aug 29 04:28:45 ip-10-245-130-205 kernel: [11693.450207] BUG: soft lockup - CPU#0 stuck for 40s! [ps:17019]
Aug 29 04:28:45 ip-10-245-130-205 kernel: [11693.450221] Modules linked in: isofs acpiphp
Aug 29 04:28:45 ip-10-245-130-205 kernel: [11693.450226] CPU 0
Aug 29 04:28:45 ip-10-245-130-205 kernel: [11693.450227] Modules linked in: isofs acpiphp
Aug 29 04:28:45 ip-10-245-130-205 kernel: [11693.450230]
Aug 29 04:28:45 ip-10-245-130-205 kernel: [11693.450233] Pid: 17019, comm: ps Not tainted 3.2.0-52-virtual #78-Ubuntu
Aug 29 04:28:45 ip-10-245-130-205 kernel: [11693.450236] RIP: e030:[<ffffffff8100122a>] [<ffffffff8100122a>] hypercall_page+0x22a/0x1000
Aug 29 04:28:45 ip-10-245-130-205 kernel: [11693.450248] RSP: e02b:ffff880023c8bdc8 EFLAGS: 00000246
Aug 29 04:28:45 ip-10-245-130-205 kernel: [11693.450249] RAX: 0000000000030004 RBX: ffff880023c8bf58 RCX: ffffffff8100122a
Aug 29 04:28:45 ip-10-245-130-205 kernel: [11693.450251] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
@twslankard
twslankard / donut.c
Created January 24, 2014 00:32
donut!
k;double sin()
,cos();main(){float A=
0,B=0,i,j,z[1760];char b[
1760];printf("\x1b[2J");for(;;
){memset(b,32,1760);memset(z,0,7040)
;for(j=0;6.28>j;j+=0.07)for(i=0;6.28
>i;i+=0.02){float c=sin(i),d=cos(j),e=
sin(A),f=sin(j),g=cos(A),h=d+2,D=1/(c*
h*e+f*g+5),l=cos (i),m=cos(B),n=s\
in(B),t=c*h*g-f* e;int x=40+30*D*