This file contains 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
<DOCTYPE!> | |
<html> | |
<head> | |
<title>Filtered Search</title> | |
<script type="text/javascript" src="https://raw.github.com/rmcvey/jsper/master/jsper.js"></script> | |
<script type="text/javascript"> | |
window.onload = function(){ | |
var saved = document.getElementById('saved'); | |
jsper.each('filters', function(item){ | |
var element = document.createElement('option'); |
This file contains 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
var element = { | |
create: function(tag_type, attributes){ | |
var el = document.createElement(tag_type) | |
, styles = attributes['style'] || [] | |
, i | |
, x | |
, style_string = ''; | |
delete attributes['style']; | |
This file contains 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
String.prototype.supplant = function (o) { | |
o = o || {}; | |
return this.replace(/{([^{}]*)}/g, function(bracketed, clean){ | |
var object_value = o[clean]; | |
return ['string', 'number'].indexOf((typeof object_value)) > -1 ? object_value : bracketed; | |
}) | |
} | |
//example | |
var text = "{name} is feeling {feeling}".supplant({ |
This file contains 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
// versatile method | |
Object.prototype.pushEvent = function(action, fn, bubbleStage) { | |
fn = fn || function(ev){}; | |
bubbleStage = bubbleStage || false; | |
if('length' in this) { | |
for(var x = 0; x < this.length; x++){ | |
this[x].pushEvent(action, fn, bubbleStage) | |
} | |
} else { | |
this.addEventListener(action, fn, bubbleStage || false); |
This file contains 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
/** | |
* I wrote a much more robust storage facade called jsper <https://github.com/rmcvey/jsper>, this is more lightweight | |
* javascript html5 storage wrapper with fallback to cookies | |
* @author Rob McVey | |
* @license MIT License | |
*/ | |
var storage = ( function( context ) { | |
// just use cookies if not HTML5 | |
var fallback; | |
This file contains 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
$.fn.placeholder = function(text){ | |
if(typeof text !== 'undefined'){ | |
this.attr('data-placeholder', text); | |
} else { | |
return this.attr('data-placeholder'); | |
} | |
var that = $(this) | |
if(that.val('')){ | |
that.val(text); | |
} |
This file contains 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
cd /tmp | |
curl -O http://us3.php.net/distributions/php-5.3.13.tar.bz2 | |
tar -xjvf php-5.3.13.tar.bz2 | |
cd php-5.3.13 | |
sudo ./configure --prefix=/opt/amp --with-libdir=lib --with-config-file-path=/opt/amp/etc \ | |
--with-config-file-scan-dir=/opt/amp/etc/php.d --enable-phar --disable-debug --enable-inline-optimization \ | |
--with-bz2 --without-gdbm --enable-cli --enable-gd-native-ttf --with-xmlrpc --with-pcre-regex --with-zlib \ | |
--with-layout=GNU --enable-bcmath --enable-exif --enable-ftp --enable-sockets --enable-sysvsem --enable-sysvshm \ | |
--enable-sysvmsg --enable-wddx --with-pear --enable-shmop --enable-calendar --enable-mbstring --enable-mbregex \ | |
--with-apxs2=/opt/amp/bin/apxs --with-openssl --with-gd --with-jpeg-dir=/opt/amp --with-png-dir=/opt/amp \ |
This file contains 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 | |
class MessageStorage extends Base_Mongo | |
{ | |
protected $_database = 'some_database'; | |
// this attribute must be defined | |
protected $_table = 'some_table'; | |
// this is a hook into the constructor, if you want to add your own constructor, make sure you call parent::__construct() first | |
public function init() |
This file contains 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
var endpoints = ['/data/step1', '/data/step2', '/data/step3']; | |
var run_cnt = 0; | |
var success_cnt = 0; | |
function final_action(){ | |
console.log('completed!'); | |
} | |
function fail_action(){ | |
console.log("something went wrong!"); |
This file contains 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
var endpoints = ['/data/step1', '/data/step2', '/data/step3']; | |
// this will hold our promises | |
var promises = []; | |
$.each(endpoints, function(index, url){ | |
// push the returned promise from $.get to our array | |
promises.push($.get(url)); | |
}) | |
// $.when takes a list of promises, we will use apply to pass an arbitrary number of arguments |
OlderNewer