Skip to content

Instantly share code, notes, and snippets.

View kevinw's full-sized avatar

Kevin Watters kevinw

View GitHub Profile
@kevinw
kevinw / gist:2364414
Created April 12, 2012 03:12
v8Js segfault with nested callbacks
<?php
$v8=new v8Js('SERVER');
$v8->serverCb = function($cb) { return call_user_func_array($cb, array(1,2,3))."42"; };
$v8->log = function($msg) { print $msg; };
for ($i =0; $i < 10; ++$i) {
$v8->executeString("var res = SERVER.serverCb(function() {return 'fromJSCB' }); SERVER.log(res); ");
}
@kevinw
kevinw / gist:2839668
Created May 30, 2012 23:58
harsh php vibes
$ perl -e 'print "cool" && "bro"'; echo
bro
$ python -c 'print "cool" and "bro"'
bro
$ node -e 'console.log("cool" && "bro")'
bro
$ php -r 'print "cool" && "bro";'; echo
@kevinw
kevinw / gist:3549855
Created August 31, 2012 07:22
Paul Graham on copyright and how "files move around like smells"

Paul Graham on copyright and how "files move around like smells"

from his PyCon 2012 Keynote video at http://www.youtube.com/watch?v=R9ITLdmfdLI&t=33m43s

Questioner:

"In one of your recent things online, you said "The answer for the music industry, for example, is probably to give up insisting on payment for recorded music, and focus on licensing and live shows.

Alright I've been talking to Vint Cerf and some people about this--licensing exactly WHAT when copyrights mean NOTHING? You know the internet and software are on a viable business train only because software enjoys these copyrights. So HOW can you just sort of throw away the music industries product and copyright, and yet tell ALL these people to work on things that must be protected by copyright--trademark, a form of copyright--and process patents?"

test
local cardinals = {
up = new(0, 1),
down = new(0, -1),
left = new(-1, 0),
right = new(1, 0)
}
function vector:closestCardinal(v)
local maxDistance = 0
local longestVec
local script = function()
wait(5)
end
local scriptFuncs = {
wait = function(secs)
print (entity, 'is waiting', secs)
assert(entity ~= nil) -- FAILS HERE
end,
}
local NUM_BULLETS = 10
return {
startState = 'wandering',
states = {
wandering = function()
while true do
walk(chooseRandomDirection())
wait(1)
end
end,
@kevinw
kevinw / strict.lua
Created February 6, 2013 08:22
catch misspelled variables—put 'require "strict"' at the top of your code.
--
-- strict.lua
-- checks uses of undeclared global variables
-- All global variables must be 'declared' through a regular assignment
-- (even assigning nil will do) in a main chunk before being used
-- anywhere or assigned to inside a function.
--
local mt = getmetatable(_G)
if mt == nil then
// Type: FezGame.Components.TempleOfLoveHost
// Assembly: FEZ, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// Assembly location: C:\Program Files (x86)\Steam\SteamApps\common\FEZ\FEZ.exe
using FezEngine;
using FezEngine.Components;
using FezEngine.Effects;
using FezEngine.Services;
using FezEngine.Structure;
using FezEngine.Structure.Geometry;
diff --git a/js/roadtrip.js b/js/roadtrip.js
index d738c95..f76cfe2 100644
--- a/js/roadtrip.js
+++ b/js/roadtrip.js
@@ -346,9 +361,15 @@ function addTube(planeMesh, cb) {
function updateFromPoints(points) {
var spline = new THREE.SplineCurve3(points);
spline = layCurveOn(planeMesh, spline);
+
+ var rotMat = new THREE.Matrix4().makeRotationY(Math.PI/2);