Skip to content

Instantly share code, notes, and snippets.

View timtrueman's full-sized avatar

Tim Trueman timtrueman

View GitHub Profile
@timtrueman
timtrueman / xplane.py
Created November 8, 2009 00:49
This is just meant as an example to get you started. You will need to install Twisted ("sudo easy_install twisted").
#!/usr/bin/env python
# encoding: utf-8
import socket
from struct import *
from twisted.internet.protocol import DatagramProtocol
from twisted.internet import reactor
import math
UDP_IP="127.0.0.1"
@timtrueman
timtrueman / heading.py
Created March 5, 2010 08:13
Tilt-compensated heading from magnetometer readings, roll and pitch
def wrap(angle):
if angle > pi:
angle -= (2*pi)
if angle < -pi:
angle += (2*pi)
if angle < 0:
angle += 2*pi
return angle
def magnetometer_readings_to_tilt_compensated_heading(bx, by, bz, phi, theta):
@timtrueman
timtrueman / ksp-checklist.md
Last active January 10, 2018 22:19
KSP checklist

Vehicle assembly

  1. Install MapSat GPS radio
  2. Verify sufficient power for electric rover (solar panel or RTG that doesn't fall off in dynamic environments)
  3. Does gear touch the ground when extended?
  4. Did you pack enough delta-v? (No.)
  5. Are you planning on returning?
  6. Is your shit manned or did that little probe body ruin the day?
  7. How many crew do you want?
  8. Did you remember ASAS and SAS?
  9. Is RCS needed?
@timtrueman
timtrueman / LICENSE
Created January 1, 2012 18:25
Facebook-style superfast, preloading photo viewer
Copyright (c) 2011 Tim Trueman @timtrueman
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@timtrueman
timtrueman / amnesia.sh
Created August 27, 2011 11:38
Give Lion Amnesia
defaults write com.apple.Preview NSRecentDocumentsLimit 0
defaults delete com.apple.Preview.LSSharedFileList RecentDocuments
defaults write com.apple.Preview.LSSharedFileList RecentDocuments -dict-add MaxAmount 0
def sendThrottle(self, throttle):
data_selection_packet = "DATA0\x19\x00\x00\x00" # throttle
data = pack('ffffffff', throttle, throttle, throttle, throttle, throttle, throttle, throttle, throttle)
data_selection_packet += data
self.sock.sendto(data_selection_packet,(safe_get_ip_address(),49000))
def sendJoystick(self, joystick, rudder):
data_selection_packet = "DATA0\x08\x00\x00\x00" # joystick
data = pack('ffffffff', joystick[1], joystick[0], rudder, 0, 0, 0, 0, 0)
data_selection_packet += data
@timtrueman
timtrueman / rainbow.js
Created July 19, 2011 02:06
Rainbowify text in HTML
// I'm a JavaScript noob, take it easy on me...
// mathematical color rotation function thingies
function decrease(degree) { return (60 - degree % 60) * 4.25; }
function increase(degree) { return (degree % 60) * 4.25; }
function zero(degree) { return 0; }
function maximum(degree) { return 255; }
// We would use better templating/rendering but I'm totally lazy and this is a hacky prototype demo script
function render_span(r, g, b, character) { return '<span style="color: rgb(' + Math.round(r) + ', ' + Math.round(g) + ', ' + Math.round(b) + ');">' + character + '</span>'; }
$(document).ready(function() {
$(':text,:password').live('focus',function(event) {
if (typeof event.target.original_value == "undefined") {
event.target.original_value = event.target.value;
}
if (event.target.value == event.target.original_value) {
event.target.value = '';
}
$(event.target).css('color','#000')
});
@timtrueman
timtrueman / django_cached_count_proxy.py
Created November 18, 2010 00:15
Django cached .count() proxy for querysets that is generic and works with pagination in object_list (which clones and overrides any monkeypatched count method so you have to override the clone method first).
class CachedCountCloneProxy(object):
''' This allows us to monkey-patch count() on QuerySets so we can cache it and speed things up.
._clone is called so we have to monkey-patch that first...
'''
def __init__(self, queryset):
self._queryset = queryset
self._queryset._clone_original = self._queryset._clone
def __call__(self):
#!/usr/bin/python
#encoding:utf-8
from telnetlib import Telnet
import time
import sys
"""
Usage