Skip to content

Instantly share code, notes, and snippets.

@AoJ
AoJ / t.js
Created March 30, 2012 14:43 — forked from isaacs/t.js
var table=
["a:b:c:d:e"
,"x:y:z:d:w"
,"1:2:3:4:5"].join("\n")
table.replace(/:([^:]+)$/mg, function (_0, _1) {
console.error(_1)
})
var lasts = table.split("\n").map(function (line) {
@AoJ
AoJ / server.js
Created March 30, 2012 14:50 — forked from isaacs/server.js
var http = require("http")
// messages should be relatively short.
var maxLength = 1024
var server = http.createServer(function (req, res) {
// requests come in as json
// need to parse the json to get from, to, and body fields.
// JSON is probably generated by some native C JSON encoder
// on a device, or in some other language, or perhaps from
var query = {
method:'GET',
headers: {
'Accept': 'application/rss+xml;q=1,application/atom+xml;q=1,application/xml;q=0.7,text/xml;q=0.6,text/html;q=0.2',
'Accept-Encoding': 'gzip, deflate',
'User-Agent': 'nodejs bot', //'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0',
'Host': 'www.burdafashion.com'
},
@AoJ
AoJ / PSR-0-final-proposal.md
Created April 8, 2012 17:50 — forked from Thinkscape/PSR-0-final-proposal.md
PSR-0 Final Proposal (PHP Standards Working Group)

PSR-0 Final Proposal (PHP Standards Working Group)

The following describes the mandatory requirements that must be adhered to for autoloader interoperability.

Mandatory:

  • A fully-qualified namespace and class must have the following structure \ <Vendor Name> \ (<Namespace>)* \ <Class Name>
  • Each namespace must have a top-level namespace ("Vendor Name").
  • Each namespace can have as many sub-namespaces as it wishes.
  • Each namespace separator is converted to a DIRECTORY_SEPARATOR when loading from the file system.
  • Each "_" character in the CLASS NAME is converted to a DIRECTORY_SEPARATOR. The "_" character has no special meaning in the namespace.
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
@AoJ
AoJ / isAssocArrayBench.php
Created April 10, 2012 19:53 — forked from Thinkscape/isAssocArrayBench.php
A benchmark of several methods for checking if PHP array is associative
<?php
if(!isset($argv[1])){
echo "Usage: ".$argv[0]." (number of iterations)\n";
exit(1);
}
/**
* Arrays to check
*/
$tests = array(
@AoJ
AoJ / knockout-jquery-ui-widget.js
Created April 14, 2012 13:24 — forked from medmunds/knockout-jquery-ui-widget.js
Knockout binding for jQuery.ui.widget
// knockout-jquery-ui-widget.js
// Copyright (c) 2011, Planapple, Inc.
// License: MIT (http://www.opensource.org/licenses/mit-license.php)
//
// Knockout binding for jQuery UI widgets
//
// Examples:
// <input type="submit" value="OK" data-bind='jqueryui: "button"' />
//
// Attaches a jQuery UI button widget to this button, with default options.
@AoJ
AoJ / my-bootstrap.bat
Created June 16, 2012 13:52 — forked from anonymous/my-bootstrap.bat
twitter bootstrap compilation under windows
@echo off
rem
rem 03.02.2012, setup of directories may vary
rem
mkdir bootstrap\img
mkdir bootstrap\css
mkdir bootstrap\js
copy img\* bootstrap\img
node.exe f:\nodejs\node_modules\less\bin\lessc.js less\bootstrap.less > bootstrap\css\bootstrap.css
node.exe f:\nodejs\node_modules\less\bin\lessc.js -x less\bootstrap.less > bootstrap\css\bootstrap.min.css
@AoJ
AoJ / reqUrl.js
Created July 3, 2012 19:03 — forked from wilsonpage/reqUrl.js
A function I made that wraps the node http.request function to make it a little more friendly. In my case I am using it for API route testing.
// module dependencies
var http = require('http'),
url = require('url');
/**
* UrlReq - Wraps the http.request function making it nice for unit testing APIs.
*
* @param {string} reqUrl The required url in any form
* @param {object} options An options object (this is optional)