Skip to content

Instantly share code, notes, and snippets.

@tsterker
tsterker / gist:2408855
Created April 17, 2012 20:40
[js] argument unpacking
// Taken from:
// http://readystate4.com/2008/08/17/javascript-argument-unpacking-converting-an-array-into-a-list-of-arguments/
var item1 = ['Jack', '39', 'Panda'];
function hi(name, age, type){
console.log('Hi ' + name + '! You are ' + age + ' and a ' + type + '!');
}
@tsterker
tsterker / removeRandom.js
Created June 25, 2012 23:23
[js] remove random elements from array
var l = [1,2,3,4,5,6,7,8,9,10];
while(l.length){
var r = (Math.random()*1000)%l.length;
var removed = l.splice(r, 1);
console.log('Removed: ' + removed);
}
@tsterker
tsterker / fancyhdr_template.tex
Created August 9, 2012 19:38
[LaTeX] fancyhdr template
\usepackage{fancyhdr}
\setlength{\headheight}{15.2pt}
\pagestyle{fancy}
\fancyhf{}
\rhead{\bfseries\nouppercase\leftmark}
\cfoot{\bfseries\thepage}
1) tabs to spaces
:set tabstop=4 shiftwidth=4 expandtab
:retab
2) Whitespace found at end of line
:%s/^M\+$//g
:%s/\s\+$//g
NOTE: ^M must be inserted using CTRL-v RETURN
# helpers
function branchExists(){ git show-ref --verify --quiet refs/heads/"$1"; }
function currentBranch(){ git rev-parse --abbrev-ref HEAD; }
function isCurrentBranch() { [ "$(currentBranch)" == "$1" ]; }
# colors
Color_Off='\e[0m' # Text Reset
BWhite='\e[1;37m' # White
Red='\e[0;31m' # Red
function whitePrompt(){ echo -en "${BWhite}$@${Color_Off}"; read value; }
void drawFaceNormals()
{
glColor3f(0,0,1); // The colour we will be drawing is white (red = 1, green = 1, blue = 1).
vector<vec3> verts = trig.Vertices();
vector<vec3> fnorms = trig.FaceNormals();
vec3 fnorm, pos, from, to;
glBegin(GL_LINES);
for(int i = 0; i < fnorms.size(); i++){
var episode = window.location.href.match(/[0-9]{2}/g)[1];
var next = +episode + 1;
next = (next+'').length === 1 ? '0'+next : next;
window.location.href = window.location.href.replace('e'+episode, 'e'+next);
// using first frame for testing
Skeleton* frame0 = rest_animation->GetFrame(0);
// for each joint in skeleton...
for (int i = 0; i < frame0->NumJoints(); i++) {
// current joint
Joint jnt = frame0->GetJoint(i);
// "global" transformation that should be applied to current joint
Matrix_4x4 totalTransform = Matrix_4x4::Id();
javascript: var episode = window.location.href.match(/[0-9]{2}/g)[1]; var next = +episode + 1; next = (next+'').length === 1 ? '0'+next : next; window.location.href = window.location.href.replace('e'+episode, 'e'+next);
N = 0;
E = 1;
S = 2;
W = 3;
% for example a 4x4 grid:
policy = [S W W W;
S W W N;
S N E E;
E N W W];