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 / 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*
@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 / 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 )
{ events:
[ { eventId: 1,
eventTimestamp: 1363887002.226,
eventType: 'WorkflowExecutionStarted',
workflowExecutionStartedEventAttributes: [Object] },
{ decisionTaskScheduledEventAttributes: [Object],
eventId: 2,
eventTimestamp: 1363887002.226,
eventType: 'DecisionTaskScheduled' },
{ decisionTaskStartedEventAttributes: [Object],
@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');
// 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 / 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)
{
@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 / 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 / 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[]) {