Skip to content

Instantly share code, notes, and snippets.

@gmilby
gmilby / oo.php
Created July 27, 2013 17:51 — forked from dhotson/oo.php
<?php
// Define the 'class' class
$class = Obj()
->fn('new', function ($class) {
$newClass = Obj($class->methods)
->fn('new', function($class) {
$obj = Obj($class->imethods);
$args = func_get_args();
array_shift($args);
/*
Loading dot dot dot
*/
body {
padding: 100px;
font-size: 62.5%;
}
.loading {
<?php
require_once("PHPExcel/PHPExcel.php");
$phpExcel = new PHPExcel();
$styleArray = array(
'font' => array(
'bold' => true,
)
);
// using a promise
$.when(doStuff('eat'), doStuff('sleep')).then(function(a, b){
console.log(a + ' and ' + b +' are done');
});
// define the function that returns a promise
function doStuff (subject) {
var defer = new $.Deferred();
/**
* Creates or decorates an object with observable behavior.
* @param {[type]} o object to decorate
* @return {[type]} the observable object
*/
function makeObservable (o) {
var undef;
o = o || {};
/*
jQuery.reduce - a jQuery plugin for functional programming
@author John Hunter
created 2010-09-17
use: $.reduce(arr, fnReduce, valueInitial);
fnReduce is called with arguments: [valueInitial, value, i, arr]
reduce will never be jQuery core - its not prototype :p (http://dev.jquery.com/ticket/1886)
*/
(function ($) {
(function(str){
var maxPalin='';
for(var i=0,len=str.length;i<len;++i){
var letter=str[i],substr;
for(var j=i;j<len;++j){
if(letter == str[j]){
maxPalin=(function(substr){
return (function(substr){
// from http://kriszyp.name/2010/01/16/imperative-functional-and-declarative-programming/
// imperative
function bestPrices(inputArray){
var outputArray = [];
for(var i = 0; i < inputArray.length; i++){
if(inputArray[i].price<10){
outputArray.push(inputArray[i]);
}
}
(function($){
$.widget("ui.mywidget", {
options: {
autoOpen: true
},
_create: function(){
// by default, consider this thing closed.
@gmilby
gmilby / jQuery.ajaxQueue.min.js
Created August 8, 2012 17:19 — forked from gnarf/jQuery.ajaxQueue.min.js
jQuery.ajaxQueue - A queue for ajax requests
/*
* jQuery.ajaxQueue - A queue for ajax requests
*
* (c) 2011 Corey Frang
* Dual licensed under the MIT and GPL licenses.
*
* Requires jQuery 1.5+
*/
(function(a){var b=a({});a.ajaxQueue=function(c){function g(b){d=a.ajax(c).then(b,b).done(e.resolve).fail(e.reject)}var d,e=a.Deferred(),f=e.promise();b.queue(g),f.abort=function(h){if(d)return d.abort(h);var i=b.queue(),j=a.inArray(g,i);j>-1&&i.splice(j,1),e.rejectWith(c.context||c,[f,h,""]);return f};return f}})(jQuery)