Skip to content

Instantly share code, notes, and snippets.

View paulhayes's full-sized avatar

Paul Hayes paulhayes

View GitHub Profile
@paulhayes
paulhayes / gist:8888586
Last active December 7, 2015 15:41
Linear least square solver using svd, written for numeric js
function svd_solve(A,b){
var A_svd,r,s,ut,d,x;
A_svd = numeric.svd(A);
s = numeric.transpose( [ A_svd.S ] );
r = 1;
while( r < numeric.dim(A)[1] & s[r] >= Math.max.apply( Math, numeric.dim(A) )*numeric.epsilon*s[0] ) r++;
d = numeric.dot( numeric.transpose( A_svd.U ), b);
#!/bin/bash
NUM_BANKS=E
while [[ "$input" != "\e" ]] ; do
networks=$(iwlist wlan0 scanning | awk 'BEGIN{ FS="[:=]"; OFS = " " }
/ESSID/{
#gsub(/ /,"\\ ",$2)
#gsub(/\"/,"",$2)
@paulhayes
paulhayes / Unity MonoBehaviour Attribute Examples.cs
Last active August 29, 2015 14:02
Unity MonoBehaviour Attribute Examples
using UnityEngine;
[SelectionBase]
public class Character : MonoBehaviour
{
[Header("Info")]
public string name;
[Space(10)]
[TextArea(3,8)] // or the more basic alternative [Multiline(3)]
@paulhayes
paulhayes / RandArrayExt.cs
Last active November 30, 2015 17:57
Written with Unity3d in mind, this adds a few simple seedable Randomization extention methods to Arrays and Lists.
using System.Collections.Generic;
static class RandArrayExt
{
public static System.Random random = new System.Random();
public static T[] Shuffle<T> (this T[] array)
{
if (array == null)
class RandomShuffleSequence
{
public static int Shuffled(int cycleLength, int seed, int index)
{
int shuffleRange = cycleLength;
int output = index % shuffleRange;
int cycleIndex = index / cycleLength;
while (output < shuffleRange)
{
using UnityEngine;
using System.Collections;
public class SimpleFramePlayer : MonoBehaviour {
public float fps;
public Texture[] frames;
private float spf;
private float timeElapsed;
using UnityEngine;
using System.Collections;
using UnityEngine.Events;
public class CheatCode : MonoBehaviour
{
public string code;
public UnityEvent onCodeEntered;
protected int current;
@paulhayes
paulhayes / colorToIChing.js
Last active August 29, 2015 14:22
Converts 24bit colour value to I Ching unicode representation ;)
colorToIChing = function(value){
r=function(n,r,i){for(;3-i++;r=r*2|n&1,n>>=1);return r;};
var s='';
for(var i=0;i<8;i++){
s=String.fromCharCode(9776+r(7&(value>>(i*3)),0,0))+s;
}
return s;
};
@paulhayes
paulhayes / .bash_profile
Created August 6, 2015 19:15
My custom bash profile script
export PATH="$PATH:~/bin:/Users/$USER/adt-bundle-mac-x86_64/sdk/tools:/Users/$USER/adt-bundle-mac-x86_64/sdk/platform-tools:/Applications/TEE-CLC-10.0.0:/usr/textbin"
export PYTHONPATH=/usr/local/lib/python2.7/site-packages
export EDITOR="subl -w"
alias pull="git pull origin"
alias push="git push origin"
function title () { echo -ne "\033]0;$@\007"; }
#include <CapacitiveSensor.h>
CapacitiveSensor cs = CapacitiveSensor(9,2); // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
int minValue = 32767;
int maxValue = 0;
void setup(){
cs.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example
Serial.begin(9600);
}