Skip to content

Instantly share code, notes, and snippets.

View RowanH's full-sized avatar

Rowan Hick RowanH

View GitHub Profile
@RowanH
RowanH / arduino-mega-aasd.c
Last active July 2, 2020 18:41
Cubexxx's Arduino Mega controller
// All code by @cubexxx
// Refer to https://www.xsimulator.net/community/threads/4dof-controller-code-for-arduino-mega-for-aasd-15a-and-similar-driver.14421/
/*
1 period = 0.5us
*/
// 2ms = 0.5 us * 4000 (can be adapted to needs)
const unsigned int samplePeriod = 4000;
// 20us == 50kHz (should not be changed, faster is not possible)
const unsigned int minPeriod = 39;
@RowanH
RowanH / hampton_downs_sectors.kml
Created November 14, 2015 22:52
Hampton Downs Sectors
<!-- Used same sectors as Racechrono, lots of guys use Racechrono self included so good to carry it over
http://www.racechrono.com/tracks/?lang=en&country=New+Zealand
-->
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document><name>My document</name>
<description>Content</description>
<Style id="Lump">
<LineStyle><color>CD0000FF</color><width>2</width></LineStyle>
<PolyStyle><color>9AFF0000</color></PolyStyle>
@RowanH
RowanH / hampton_downs.kml
Last active November 25, 2015 08:32
KML file for Hampton downs, track centerline for Racecapture. Work in progress
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document><name>My document</name>
<description>Content</description>
<Style id="Lump">
<LineStyle><color>CD0000FF</color><width>2</width></LineStyle>
<PolyStyle><color>9AFF0000</color></PolyStyle>
</Style>
<Style id="Path">
<LineStyle><color>FF0000FF</color><width>3</width></LineStyle>
@RowanH
RowanH / backup_android.sh
Created May 4, 2014 23:18
Pull backup locally of an Android app
adb backup -f ~/work/data.ab -noapk com.my.app.name
dd if=data.ab bs=1 skip=24 | python -c "import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))" | tar -xvf -
@RowanH
RowanH / app.js
Created May 9, 2012 19:03 — forked from skypanther/app.js
Cache Remote Images
var Utils = {
/* modified version of https://gist.github.com/1243697
* adds detection of file extension rather than hard-coding .jpg as in the original
*/
_getExtension: function(fn) {
// from http://stackoverflow.com/a/680982/292947
var re = /(?:\.([^.]+))?$/;
var tmpext = re.exec(fn)[1];
return (tmpext) ? tmpext : '';
},
@RowanH
RowanH / paperclip.rake
Created April 6, 2012 12:03 — forked from mrrooijen/paperclip.rake
A Fix for Paperclip Rake Task (paperclip:refresh:thumbnails) - Compatible with ActiveRecord and Mongoid
def obtain_class
class_name = ENV['CLASS'] || ENV['class']
raise "Must specify CLASS" unless class_name
@klass = Object.const_get(class_name)
end
def obtain_attachments
name = ENV['ATTACHMENT'] || ENV['attachment']
raise "Class #{@klass.name} has no attachments specified" unless @klass.respond_to?(:attachment_definitions)
if !name.blank? && @klass.attachment_definitions.keys.include?(name)
@RowanH
RowanH / Instrument Anything in Rails 3.md
Created December 14, 2011 14:25 — forked from mnutt/Instrument Anything in Rails 3.md
How to use Rails 3.0's new notification system to inject custom log events

Instrument Anything in Rails 3

With Rails 3.0 released a few weeks ago I've migrated a few apps and I'm constantly finding useful new improvements. One such improvement is the ability to log anything in the same way that Rails internally logs ActiveRecord and ActionView. By default Rails 3 logs look slightly spiffier than those produced by Rails 2.3: (notice the second line has been cleaned up)

Started GET "/" for 127.0.0.1 at Mon Sep 06 01:07:11 -0400 2010
  Processing by HomeController#index as HTML
  User Load (0.2ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1

Rendered layouts/_nav.html.erb (363.4ms)

@RowanH
RowanH / test_ldap_rds.rb
Created July 29, 2011 16:47
Testing Net::LDAP against Redhat Directory Server
# Script to manipulate LDAP with common operations
require 'rubygems'
require 'net/ldap'
require 'sha1'
require 'base64'
HOST = 'somehost'
PORT = 636
UID = 'uid=admin,ou=Administrators,ou=TopologyManagement,o=NetscapeRoot'
PASSWORD = 'somepass'