Philip Thrasher
Web hacker at a private cyber security company.
| <?php | |
| class Simplate { | |
| private template_vars = array(); | |
| private template_include = '404'; | |
| /* | |
| * Sets include file name, and sanitizes vars. | |
| */ | |
| function __contruct($template_name = '404', $vars = array()) { |
| /* | |
| * For those who don't understand pointers fully: | |
| * Variables have addresses in memory. In C, you | |
| * define an integer like so: | |
| */ | |
| int my_int; | |
| my_int = 13; | |
| // -or in one line- | |
| int my_int = 13; |
| library = | |
| 'name':'My Library' | |
| '@open': '2007-17-7' | |
| 'address': | |
| 'city': 'Springfield' | |
| 'zip': '12345' | |
| 'state': 'MI' | |
| 'street': 'Mockingbird Lane' | |
| 'books':[ | |
| { |
| ### | |
| jPath - xpath-esque query tool for json. | |
| Also comes with backbone.js mixins | |
| ### | |
| query = (query, data) -> | |
| """ | |
| Takes xpath-esque input, and converts it to a path list for the |
| # Will only run for a max of 20 seconds | |
| # 2000 iterations. | |
| onImagesLoaded: (callback, runs=0) -> | |
| return unless runs <= 2000 | |
| #convenience method | |
| wait = (ms, fn) -> setTimeout fn, ms | |
| images = document.getElementsByTagName 'img' | |
| unless images? |
| /* | |
| * Allows using `up` on your coffeescript apps. To use, place this file in the | |
| * same directory as your app.coffee (or whatever file is exporting your http | |
| * server instance) and then run: | |
| * $ up [options] shim.js | |
| */ | |
| require('coffee-script'); | |
| exports = module.exports = require('./app'); |
| startsWith = (needle, haystack) -> | |
| haystack.indexOf(needle) is 0 | |
| istartsWith = (needle, haystack) -> | |
| needle = needle.toLowerCase() | |
| haystack = haystack.toLowerCase() | |
| startsWith needle, haystack | |
| endsWith = (needle, haystack) -> | |
| haystack.indexOf(needle) is haystack.length - needle.length |
<div>
<div id="myScrollableArea">
</div>
</div>#myScrollableArea {| /* | |
| * setTimeout(fn, 0) for realz, for modern browsers. | |
| * AKA nextTick from node. | |
| * Ripped from http://dbaron.org/log/20100309-faster-timeouts | |
| * Most browsers don't actually let you specify timeouts of 0, so the below | |
| * method is a better way of achieving this. | |
| * Philip Thrasher, 2012 | |
| */ | |
| (function(){ |