This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Small timer script by Nicolas Torres | |
(WIP: needs settings & a some few more helpers) | |
Usage: | |
<span id="chrono"></span> // set an element | |
chrono.start() // starts the timer | |
chrono.toggle() // play or pause the timer | |
chrono.stop() // stop and reset the timer | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# Chainable objects | |
# Ex: echo $films->filterBy('rating', 5)->sortBy('release')->flip()->first()->title(); | |
class obj implements Iterator { | |
private $_ = array(); | |
public function __construct($arr = array()) { $this->_ = is_array($arr[0]) ? array_map(function($a) { return is_object($a) ? $a : new obj($a); }, $arr) : $arr; } | |
public function __set($k, $v) { $this->_[$k] = $v; } | |
public function __get($k) { return $this->get($this->_, $k); } | |
public function __call($k, $args) { return $this->get($this->_, $k, $args[0]); } | |
private function get($arr, $k, $date = false) { return isset($arr[$k]) ? (($date AND !is_numeric($arr[$k]) AND strtotime($arr[$k]))?new DateTime($arr[$k]):$arr[$k]) : false; } |