Skip to content

Instantly share code, notes, and snippets.

View hamaluik's full-sized avatar
👋
I may be slow to respond.

Kenton Hamaluik hamaluik

👋
I may be slow to respond.
View GitHub Profile
@hamaluik
hamaluik / gist:3372567
Created August 16, 2012 18:44
Parsing XwXdXhXmXs time into number of seconds
private boolean isLong(String str) {
try {
Long.parseLong(str);
}
catch(NumberFormatException e) {
return false;
}
return true;
}
#!/bin/sh
# make sure the behaviour works
haxe test.hxml
exit
@hamaluik
hamaluik / tusk post-commit
Last active October 16, 2015 23:52
Git hook for updating the version file
#!/bin/sh
# find node
NODE=$(which node)
# get the latest commit
COMMIT=$(git rev-parse HEAD)
# if it cannot find a node installation
if [[ -z $NODE ]]; then
@hamaluik
hamaluik / minify.js
Created October 27, 2015 01:36
Flow hook to minify the resulting javascript code (stores it in {{app.name}}.min.js).
// ./hooks/minify.js
var UglifyJS = require("uglify-js"); // run "npm install uglify-js" in the hooks directory first!
var fs = require('fs');
exports.hook = function(flow, done) {
var basePath = flow.project.project.app.output + '/web/' + flow.project.project.app.name;
var result = UglifyJS.minify(basePath + '.js', {
mangle: true // set to false if you run into issues
});
fs.writeFile(basePath + '.min.js', result.code, function(err) {
@hamaluik
hamaluik / qaxisangle.m
Created November 6, 2015 22:30
Matlab Quaternion Functions
function [ result ] = qaxisangle( axis, ang )
%QAXISANGLE Generates a quaternion which rotates by ang around axis
% some helpers
c = cos(ang / 2);
s = sin(ang / 2);
axis = axis ./ norm(axis);
result = [
c,
@hamaluik
hamaluik / PID.cs
Last active November 19, 2015 16:51
class PID
{
public double KP { get; set; }
public double KI { get; set; }
public double KD { get; set; }
public double SetPoint { get; set; }
public double MinSet { get; set; }
public double MaxSet { get; set; }
@hamaluik
hamaluik / snowkit.sh
Last active December 7, 2015 06:28
Setup snowkit
#!/bin/sh
haxelib git flow https://github.com/underscorediscovery/flow.git
haxelib git snow https://github.com/underscorediscovery/snow.git
haxelib git luxe https://github.com/underscorediscovery/luxe.git
haxelib git mint https://github.com/underscorediscovery/mint.git
wget http://build.luxeengine.com/snow/latest.all.zip
@hamaluik
hamaluik / UnityLauncher
Created January 15, 2013 05:03
An application "shortcut" in Ubuntu Unity (modify and drag to launcher to setup)
[Desktop Entry]
Name=Dispay Name of App
GenericName=Basic Name of App
Comment=Comment
Keywords=keywords;separated;with;semi-colons
Exec=/path/to/file/to/run with parameters
Terminal=true|false
Type=Application
StartupNotify=true
Icon=/path/to/icon.png
@hamaluik
hamaluik / listOfSymbols.tex
Created January 30, 2013 23:16
List of symbols, taken from http://filer.case.edu/oxb6/listofsymbols.html for ease of use with Gists
%% Your packages
\usepackage{array} %for vertical thick lines in tables
\usepackage{multirow} %multirow tables
\usepackage{nicefrac} %for fractions like 1/4
%Package list ends here
% Macro for 'List of Symbols', 'List of Notations' etc...
\def\listofsymbols{\input{symbols} \clearpage}
\def\addsymbol #1: #2#3{$#1$ \> \parbox{5in}{#2 \dotfill \pageref{#3}}\\}
@hamaluik
hamaluik / secondsToHMS
Created November 15, 2013 00:54
This isn't something that is very difficult. However, I often find I need to do the conversion from total number of seconds (example: 5412s) to the number of hours, minutes, and seconds that is (hh:mm:ss - 1:30:12 in this case). Here is a little snippet in Python that does this.
# secs is the total number of seconds
secs = 5412
# calculate things..
hours = secs / 3600
minutes = (secs - hours * 3600) / 60
seconds = secs % 60
# now print the results!
print '%02d:%02d:%02d' % (hours, minutes, seconds)