Skip to content

Instantly share code, notes, and snippets.

$(document).ready(function() {
//$.cookie('mri', null);
var mri_numChilds = $('body').data('numChilds');
var mri_id = mri_numChilds ? $('body').data('id') : $('body').data('pid');
var mri_pid = $('body').data('pid');
var mri_pos = 0;
var mri_max = 5;
var mri = [];
$('#menu-right > div').hide().each(function() {
mri.push($(this));
@oleics
oleics / example.bat
Created February 9, 2012 15:55
Let vcbuild.bat create a zip-archive of node and npm
rem Use curl and 7za
set NPM_VERSION=1.1.0-3
curl -o "%temp%\npm.zip" "http://nodejs.org/dist/npm-%NPM_VERSION%.zip"
if not exist "%temp%\npm" ( mkdir "%temp%\npm" )
7za x "%temp%\npm.zip" -o"%temp%\npm"
7za a -tzip "Release\node-v%NODE_VERSION%-win.zip" "Release\node.exe" "%temp%\npm\*" -mx9
rem Same but with wget and zip/unzip
set NPM_VERSION=1.1.0-3
wget -O "%temp%\npm.zip" "http://nodejs.org/dist/npm-%NPM_VERSION%.zip"
@oleics
oleics / client.js
Created April 22, 2012 18:08
UNIX domain sockets
var net = require('net');
connect();
function connect() {
var client = net.connect('/tmp/test.sock', function() { //'connect' listener
console.log('client connected');
client.write('world!');
function ping() {
@oleics
oleics / coolstreams.js
Created April 28, 2012 18:51
Cool nodejs streams
var Stream = require('stream').Stream
, Lazy = require('lazy')
var timeout = -1
, rndMax = 10000
// create two streams and emit random JSON data strings (objects)
var s1 = createStream()
, s2 = createStream()
emit_random_data(s1, 's1', timeout, rndMax)
@oleics
oleics / useyourimagination.plugin.js
Created June 12, 2012 20:26
dustjs: chunk WriteStream Interface
module.exports = plugin
var request = require('request')
function plugin(chunk, context, bodies, params) {
return chunk.map(function(chunk) {
request
( { method: 'GET'
, uri: 'http://localhost:2001/useyourimagination/'
}
@oleics
oleics / npm-1.1.25
Created June 19, 2012 21:01
npm install restify
admin@199069:~/tmp$ node -v
v0.7.10
admin@199069:~/tmp$ npm -v
1.1.25
admin@199069:~/tmp$ npm install restify
npm http GET https://registry.npmjs.org/restify
npm http 200 https://registry.npmjs.org/restify
npm http GET https://registry.npmjs.org/restify/-/restify-1.4.3.tgz
npm http GET https://registry.npmjs.org/async/0.1.22
npm http GET https://registry.npmjs.org/bunyan/0.8.0
@oleics
oleics / moduleofmodule.js
Created June 28, 2012 15:03
module of module
var foo = require('./foo')
, barOfFoo = moduleOfModule('./bar', './foo')
function moduleOfModule(module, ofModule) {
var c = require.cache[require.resolve(ofModule)]
, f = require.resolve(module, c)
, r
c.children.some(function(c) {
if(c.filename === f) {
r = c.exports
@oleics
oleics / child.html
Last active December 17, 2015 14:49
.postMessage
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<!-- Simulate a dynamically changing page -->
<div id="main"></div>
<script>
var el = document.getElementById('main');
@oleics
oleics / jsonschema.json
Created January 22, 2014 15:59
JSONSchema Example
{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"description": {
"type": "string",
"optional": true
},
@oleics
oleics / jsonschema-angular.html
Last active March 21, 2017 17:25
jsonschema, metawidget & angular
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.9/angular.min.js"></script>
<script src="http://metawidget.sourceforge.net/js/3.7/metawidget-core.min.js"></script>
<script src="http://metawidget.sourceforge.net/js/3.7/metawidget-angular.min.js"></script>