Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View h2non's full-sized avatar

Tom h2non

  • Dissident
  • Decentralized
View GitHub Profile
@h2non
h2non / vock-client-error
Created November 17, 2012 23:11
Vock client error
root@dev:/opt/opew/projects/vock/app# vock set key-file rsa.key
/// Vock - VoIP on node.js ///
root@dev:/opt/opew/projects/vock/app# vock create
/// Vock - VoIP on node.js ///
Enter your private key password:
Room created!
Run this on other side:
vock connect 74d4ce2f7d355d9e98077cac8b0c434c8d7c6e42
Waiting for opponent...
.node.bin: ../src/audio/platform/linux.cc:99: void vock::audio::PlatformUnit::StartLoop(): Assertion `p a_state_ == 1' failed.
@h2non
h2non / bytesCounter.js
Last active December 13, 2015 21:18
Simple UTF8 string bytes counter
/**
* Simple UTF8 String bytes counter
* @author Tomas Aparicio
* @license MIT
* @param {String} str String to count
* @return {Number} Bytes
* @method bytesCounter
*/
function bytesCounter(str){
var code, i, bytes = 0;
@h2non
h2non / setInterval.html
Created February 20, 2013 09:10
Simple experimental wrapper for setInterval/clearInterval native JavaScript Functions
<html>
<head>
<title>setInterval/clearInterval Wrapper</title>
<script type="text/javascript">
/**
* Simple experimental wrapper for setInterval/clearInterval native JavaScript Functions
* @version 0.1 Alpha
* @author Tomas Aparicio
* @license WTFPL
*/
@h2non
h2non / requirejs-min-addon.js
Last active December 14, 2015 16:39
A simple RequireJS addon to automatically load minified script sources
/**
* A simple RequireJS addon to automatically load minified script sources
*
* @method applyMinification
* @param {Object} context RequireJS current context Object. Required
* @param {Array/String} deps Dependencies to process. Required
* @return {Array/String} Minified dependencies
* @private
*
* @cfg {Boolean} minification True to enable it
@h2non
h2non / deep-clone.js
Last active December 15, 2015 03:39
Simple function to create secure inmutable (recursive deep copy) JavaScript Objects
/**
* Simple function to create secure inmutable (recursive deep copy) JavaScript Objects
* @license WTFPL
* @param {Object/Array} obj Target Object. Required
* @param {Number} depth Depth level. Defaults to 1
* @return {Object/Array) Inmutable new Object
* @method deepClone
*/
function deepClone(obj, depth) {
var clone, key,
@h2non
h2non / deep-clone-underscore.js
Last active December 15, 2015 03:49
Simple underscore function to create secure "inmutable" (recursive deep copy) JavaScript Objects
/**
* Simple underscore function to create secure inmutable (recursive deep copy) JavaScript Objects
* @param {Object/Array} obj Target Object. Required
* @param {Number} depth Depth level. Defaults to 1
* @return {Object/Array) Super inmutable new Object
* @method deepClone
*/
_.deepClone = function deepClone(obj, depth) {
var clone, key;
depth = depth || 1;
@h2non
h2non / copyFiles.js
Created March 21, 2013 16:01
Simple Node.js recursivily copy/rename files with specific pattern
/**
* Simple Node.js recursivily copy/rename files with specific pattern
* @license WTFPL
* @usage $ node copyFiles.js
*/
var fs = require('fs'),
config;
// config options
config = {
@h2non
h2non / proto-inheritance-reflect.js
Last active December 16, 2015 01:19
Implement a recursive reflection in JavaScript prototype chain inheritance
// for ES5 compliant engines (tested in Chrome, FF and IE9+)
// Under WTFPL license ;)
function getObjectInheritance(obj) {
var hierarchy = [];
if (['boolean', 'number', 'string', 'undefined'].indexOf(typeof obj) !== -1 || obj === null) { // support for primitives types
obj = Object(obj);
} else if (typeof obj === 'function') {
hierarchy.push(obj.name || (obj.toString().match(/function (\w*)/) || obj.toString().match(/\[object (\w*)\]/))[1] || 'Anonymous Function');
obj = obj.prototype;
} else if (obj.toString() !== '[object Object]' && obj.prototype) { // fix Objects instances and IE
@h2non
h2non / inheritedMembers.js
Last active December 16, 2015 01:49
Simple Function to get inherited prototype Object members
// for ES5 compliant engines (tested in Chrome, FF and IE9+)
// Under WTFPL license ;)
function getObjectInheritedMembers(obj) {
var members = {};
if (['boolean', 'number', 'string', 'undefined'].indexOf(typeof obj) !== -1 || obj === null) { // support for primitives types
obj = Object(obj);
} else if (typeof obj === 'function') {
members[obj.name || (obj.toString().match(/function (\w*)/) || obj.toString().match(/\[object (\w*)\]/))[1] || 'Anonymous Function'] = Object.getOwnPropertyNames(obj);
obj = obj.prototype;
} else if (obj.toString() !== '[object Object]' && obj.prototype) { // fix Objects instances and IE
@h2non
h2non / jade.min.js
Created August 1, 2013 10:50
Adapted Jade library to compile in the browser
(function(){function require(p){var path=require.resolve(p),mod=require.modules[path];if(!mod)throw new Error('failed to require "'+p+'"');return mod.exports||(mod.exports={},mod.call(mod.exports,mod,mod.exports,require.relative(path))),mod.exports}require.modules={},require.resolve=function(path){var orig=path,reg=path+".js",index=path+"/index.js";return require.modules[reg]&&reg||require.modules[index]&&index||orig},require.register=function(path,fn){require.modules[path]=fn},require.relative=function(parent){return function(p){if("."!=p.charAt(0))return require(p);var path=parent.split("/"),segs=p.split("/");path.pop();for(var i=0;i<segs.length;i++){var seg=segs[i];".."==seg?path.pop():"."!=seg&&path.push(seg)}return require(path.join("/"))}},require.register("compiler.js",function(module,exports,require){function isConstant(val){if(/^ *("([^"\\]*(\\.[^"\\]*)*)"|'([^'\\]*(\\.[^'\\]*)*)'|true|false|null|undefined) *$/i.test(val))return!0;if(!isNaN(Number(val)))return!0;var matches;return(matches=/^ *\[(.*)\