Skip to content

Instantly share code, notes, and snippets.

var video = document.getElementById("video");
var c1 = document.getElementById("roundy");
var ctx = c1.getContext("2d");
$('#button').click(function(){
video.play();
});
video.addEventListener("play", function() {
timerCallback();
@niklasvh
niklasvh / DataViewer.js
Created April 27, 2012 12:39
Helper class for DataView, primarily for consistent use of same endian type, storing position of buffer and transforming buffers to strings/bits
/*
* @author Niklas von Hertzen <niklas at hertzen.com>
* @created 30.12.2011
* @website http://hertzen.com
*/
function DataViewer( data, littleEndian ) {
var pos = 0,
@niklasvh
niklasvh / gist:3171278
Created July 24, 2012 17:15
__set__get_005.phpt
<?php
class Test
{
protected $x;
function __get($name) {
echo __METHOD__ . "\n";
if (isset($this->x[$name])) {
return $this->x[$name];
}
<?php
class C
{
function __call($name, $values)
{
$values[0][0] = 'changed';
}
}
$a = array('original');
<?php
class setter {
public $n;
public $x = array('a' => 1, 'b' => 2, 'c' => 3);
function __get($nm) {
echo "Getting [$nm]\n";
if (isset($this->x[$nm])) {
$r = $this->x[$nm];
<?php
$func = create_function('','
static $foo = 0;
return $foo++;
');
var_dump($func());
var_dump($func());
var_dump($func());
?>
<?php
$func = create_function('','
static $foo = 0;
return $foo++;
');
var_dump($func());
var_dump($func());
var_dump($func());
?>
<?php
class object implements ArrayAccess {
public $a = array('1st', 1, 2=>'3rd', '4th'=>4);
function offsetExists($index) {
echo __METHOD__ . "($index)\n";
return array_key_exists($index, $this->a);
}
function offsetGet($index) {
<?php
// simple case with missing element
$f = array("hello","item2","bye");
list($a,,$b) = $f;
echo "A=$a B=$b\n";
// Warning: Cannot use a scalar value as an array in %s on line %d
$c[$c=1] = 1;
<?php
function f($x) {
echo "f($x) ";
return $x;
}
echo "Function call args:\n";
var_dump(f($i=0) < f(++$i));
var_dump(f($i=0) <= f(++$i));
var_dump(f($i=0) > f(++$i));