Skip to content

Instantly share code, notes, and snippets.

View rlidwka's full-sized avatar

Alex Kocharin rlidwka

  • Tbilisi, Georgia
View GitHub Profile
squogre:/tmp:% cat test.js
(function ThisIsFunctionName() {throw new Error()})()
squogre:/tmp:% node test.js
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error
at ThisIsFunctionName (/tmp/test.js:1:101)
try {
(function ThisIsFunctionName() {
throw new Error()
})()
} catch(x) {
console.log(x.stack)
}
Error
at ThisIsFunctionName (unknown source)
define('test', {
task1: function(cb) {
require('dep', function() {
// do smth
cb();
});
},
});
class WrapFunc
constructor: ->
for key of @
do (key) =>
old_fn = @[key]
@[key] = =>
console.log('wrapping call to ' + key)
old_fn.apply(@, arguments)
#!/usr/bin/node
var net = require('net');
var fs = require('fs');
var server = require('net').createServer(function(conn) {
var upsock = new net.Socket();
var send = [];
var connected = false;
var connecting = false;
console.log('===== CONNECT =====');
var net = require('net');
net.createServer(function (socket) {
socket.setEncoding("ascii");
socket.on("data", function (data) {
data = data.trim();
console.log('Serving: ', data);
if (data == 'img') {
socket.write('The reference images:\r\n');
socket.write('\r\n');
var crypto = require('crypto');
var crc32 = require('crc').crc32;
var x = 1;
while(1){
var string = '';
for (var j=0; j<x; j++) {
string += String(Math.random());
var cookie = require('./')
var acc, x;
console.log(x = cookie.sign('hello', 'test'))
function quantile(arr, from, to) {
from = Math.floor((arr.length) * from)
to = Math.ceil((arr.length) * to)
var s = 0
arr = arr.sort()
var eve = require('EVE')
var type = eve.type
schema = type.object({
number: type.number().min(5),
something: type.string().trim().notEmpty().required()
})
console.log(schema.val({number:'123'}).validate())
function get_global() {
if (typeof(window) === 'undefined' && typeof(window) === 'object' && window != null && window.window === window)
return window
if (typeof(global) === 'undefined' && typeof(global) === 'object' && global != null && global.global === global)
return global
}