Skip to content

Instantly share code, notes, and snippets.

Avatar

A.A monolithed

View GitHub Profile
View tsn_call.js
var TSN = require('TSN');
var fs = require("fs");
var template = TSN.load('template.xml');
var file = fs.createWriteStream('template.html', {
flags: 'a',
encoding: 'utf-8',
mode: 0666
});
@monolithed
monolithed / range.js
Last active Oct 7, 2015
Range function
View range.js
/*
* Range
* @author: Alexander Guinness
* @version: 1.0
* @license: MIT
* @date: 7/20/12 9:28 PM
*/
function range (from, to, step) {
var array = [];
View dabblet.css
/**
* rating stars
*/
.rating {
height: 18px;
width: 82px;
}
.rating_star {
View gist:3229123
/*
Object.setPrototypeOf is not going to happen. Writable __proto__
is a giant pain to implement (must serialize to cycle-check)
and it creates all sorts of type-confusion hazards (Brendan Eich).
*/
Object.setPrototypeOf = function (object, proto) {
var __proto__ = proto;
do {
View gist:3229208
/**
* Object.deepFreeze
* Licensed under the MIT
* @author: Alexander Guinness
* @version: 1.1
* @date: Fri Jun 27 17:26:00 2011
**/
if (!Object.deepFreeze && Object.freeze && Object.isFrozen) {
Object.deepFreeze = function(object)
@monolithed
monolithed / gist:3800591
Created Sep 28, 2012
DOM Level 2 Events: handleEvent
View gist:3800591
/*
* DOM Level 2 Events: handleEvent
* @author Alexander Guinnes, Thomas Aylott (original author)
* @description http://ajaxian.com/archives/an-alternative-way-to-addeventlistener
**/
function EventListener(element, phase)
{
var listener = {
addEvent: function (type, callback)
@monolithed
monolithed / main.mm
Created Oct 11, 2012 — forked from iamleeg/main.mm
Using operator overloading with Objective-C. Erm, ++.
View main.mm
#include "objc_id.hpp"
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSString *s1 = @"hello";
NSString *s2 = [@"hell" stringByAppendingString: @"o"];
if ((objc_id(s1) == objc_id(s2))) {
NSLog(@"win");
View extend.js
/* extend
*
* @param {object} from
* @param {object} to
* @param {Array} [ array ] - array of properties
*
* using:
* extend(object_1, object_2); // clone object
* extend(object_1, object_2, ['foo', 'bar']); // take some properties
@monolithed
monolithed / gist:4096202
Created Nov 17, 2012 — forked from biot023/gist:2318842
Failing cppcms build
View gist:4096202
~/src/cppcms-1.0.1/build$ make
[ 0%] Building CXX object booster/CMakeFiles/booster.dir/lib/ptime/src/posix_time.cpp.o
[ 0%] Building CXX object booster/CMakeFiles/booster.dir/lib/ptime/src/ctime.cpp.o
[ 1%] Building CXX object booster/CMakeFiles/booster.dir/lib/regex/src/pcre_regex.cpp.o
[ 1%] Building CXX object booster/CMakeFiles/booster.dir/lib/system/src/posix_error.cpp.o
[ 1%] Building CXX object booster/CMakeFiles/booster.dir/lib/system/src/windows_error.cpp.o
[ 2%] Building CXX object booster/CMakeFiles/booster.dir/lib/aio/src/aio_category.cpp.o
[ 2%] Building CXX object booster/CMakeFiles/booster.dir/lib/aio/src/deadline_timer.cpp.o
[ 2%] Building CXX object booster/CMakeFiles/booster.dir/lib/aio/src/endpoint.cpp.o
[ 3%] Building CXX object booster/CMakeFiles/booster.dir/lib/aio/src/io_service.cpp.o
View range vs. xrange.py
### range
python -m timeit -c 'for x in range(100): pass'
#100000 loops, best of 3: 3.17 usec per loop
python -m timeit -c 'for x in range(10000): pass'
1000 loops, best of 3: 314 usec per loop
### xrange