Skip to content

Instantly share code, notes, and snippets.

Avatar

Tom Slankard twslankard

View GitHub Profile
@twslankard
twslankard / gist:760182
Created Dec 30, 2010
jquery load example
View gist:760182
<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>
View array_by_reference.cpp
#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
simple Mime/Multipart email class for sending attachments and a text or html body in the charset of your choosing
View mime.php
<?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 Sep 28, 2011
disable mouse acceleration on mac os x
View mousekiller.c
/**
* 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)
{
View gist:4707932
// 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 Mar 20, 2013
Simple Workflow node.js-based Decider test
View decider.js
var events = require('events');
var util = require('util');
function Decider(_domain, task_list) {
var aws = require('aws-sdk');
View gist:5214920
{ 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 Apr 2, 2013
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.
View mpu.rb
#!/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 Aug 29, 2013
soft lockups on t1.micro
View syslog
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
View donut.c
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*