Skip to content

Instantly share code, notes, and snippets.

@error454
error454 / Leap Explanation.md
Last active December 20, 2015 22:49
Leap joints etc for Payam.

leapFrame.js defines a function that helps you read and act on a single frame of leap data.
The leap device passes 'frames' of data as it sees objects in the world. A single frame of data has information on how many objects are seen, what direction they're pointing, where they're located in 3D space etc. Take time and look at leapFrame.js and the functions it provides:

  • palm position
  • palm direction
  • palm normal vector
  • finger position
  • finger angle
  • delta finger position

If you need some help figuring out what some of these vectors look like, take a look at the leap documentation, they have nice pictures showing all the axis etc.

@error454
error454 / themagic.java
Last active December 25, 2015 02:59
Birthday Code
public String doTheMagic(String person, int age){
int randomNumber = 2;
age *= randomNumber;
if(person = null){
person = "Horrible Person";
}
boolean isTheirBirthday = true;
@error454
error454 / randomTest.lua
Last active December 25, 2015 12:59
Random number test
function Misc.debugRandomUnitTest ( min, max )
local count = 10000
local tTest = table.newInstance ( )
table.reserve ( tTest, count )
local t_add = table.add
local rand = math.random
local round = math.roundToNearestInteger
for i = 0, count do
t_add(tTest, round ( rand ( min, max) ))
@error454
error454 / proguard-project.txt
Last active January 2, 2016 16:19
Android ShiVa Proguard config
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
@error454
error454 / quicksort.lua
Created February 11, 2014 02:45
Stonescript Quicksort
-- Adapted from http://rosettacode.org/wiki/Sorting_algorithms/Quicksort#Lua
function quicksort (t, start, endi)
start = start or 0
endi = endi or table.getSize ( t ) - 1
if(endi - start < 1) then return t end
local pivot = start
@error454
error454 / Game1.cs
Created March 1, 2014 02:45
Rain of Arrows
// Rain of Arrows
// Author: Zachary Burke
// 5/7/2010
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
@error454
error454 / achievementconvert.lua
Created May 2, 2014 23:52
Steam Achievement Image Converter
-- Author: Zachary Burke
-- License: MIT
--
-- Steam Achievement Image Converter
--
-- /-----------\ ----> Color JPG
-- (Color PNG) ----> |This script|
-- \-----------/ ----> Grayscale JPG
--
-- Each Steam Achievement requires two 64x64 JPG files. One image for the unachieved state and the
@error454
error454 / gist:4d4b15086c772c3f1bda
Created July 29, 2014 18:18
Local Space to Global Space
-- I have cube whose origin is in the center of the cube.
-- I want to place a joint on the end face of the cube, the +Z end.
-- --------------
-- | |
-- | |<--- Joint here
-- | |
-- --------------
--
-- I know that the width of the box is boxLength, so the localspace coordinate that gives me the
-- end of the box is 0, 0, boxLength * 0.5 (remember that the origin is in the center)
local ex,ey,ez = object.getTranslation ( hEnemy,object.kGlobalSpace )
local ox,oy,oz = object.getTranslation ( o,object.kGlobalSpace )
-- vector pointing at the enemy
local dx,dy,dz = math.vectorSubtract ( ex,ey,ez,ox,oy,oz )
-- distance between enemy and object
local dist = math.vectorLength ( dx,dy,dz )
-- vector pointing at enemy with length of half the distance
@error454
error454 / gist:0943cf7899c20f5f2b48
Created September 19, 2014 08:39
Delete JPGs that don't have a matching raw file
lfs = require "lfs"
local sPath = 'D:/temp photos/'
function hasExtension ( sFilename, sExt )
if sFilename then
return string.match ( string.lower ( sFilename ), "." .. string.lower( sExt ) ) ~= nil
end
return false
end