This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// serialization of hierarchical object/array/int/str to a flat object and back | |
// | |
// useful to store an object in compressed column store | |
// so it will be compressed by type and not as blob. | |
// the resulting object values and keys can be escaped and converted to a sql query | |
//example: | |
// var xx=['test',{data:[1,2,"asd"]}] | |
// result=flat(xx) | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//suppose you want to insert 15000000 rows to database | |
// i can tell you the future your program will crush | |
// because of background processes will be full to to the limits of the buffers for I/O | |
// so to not crush the system you have to let go everynow and then | |
// | |
//for(var i=0;i<a.length;i++) | |
//{ | |
//} | |
function forloop(from_i,to_i,fn,done,max_continious_loops_i) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cbguard by Shimon Doodkin - license: public domain | |
function cbguard(cb,printerr){ //kind of filter for callbacks. it prevents a callback to be called twice | |
var cb1=cb; | |
return function() { | |
if(cb1) { var cb2=cb1; cb1=false; return cb2.apply(this,arguments); } | |
else if(printerr)console.log(new Error('cb called twice').stack); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this grown up to a module - | |
// https://github.com/shimondoodkin/efficient-rolling-stats |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//try take advantage of inacurate large exponent of double floating point to compare decimal numbers. | |
var large_detable_float=function(point){ if(point){this.maxfloat=parseFloat("1"+Array((Number.MAX_SAFE_INTEGER*point).toFixed(0).length+1).join("0"));}this.a=0; this.b=0;}; | |
large_detable_float.prototype={ | |
maxfloat:100000000, | |
add:function(a){ if(a<0) return this.sub(-a); | |
if(this.a+a<this.maxfloat)this.a+=a; | |
else {this.a-=this.maxfloat;this.b+=this.maxfloat;this.a+=a;} | |
}, | |
sub:function(a){ if(a<0) return this.add(-a); | |
if(this.a-a>-this.maxfloat)this.a-=a; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apt-get install fail2ban | |
apt-get install iptables-persistent | |
apt-get install ufw | |
ufw default deny incoming | |
ufw default allow outgoing | |
ufw allow ssh/tcp | |
ufw allow www | |
ufw allow smtp | |
ufw allow pop3 | |
ufw enable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.nini; | |
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.Comparator; | |
import java.util.HashMap; | |
import java.util.LinkedList; | |
import java.util.List; | |
import java.util.Map.Entry; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys=require('sys'); | |
var Route={}; | |
//var Route=function (){}; | |
sys.puts(Route); | |
Route.prototype.toString1= function() { return "it is a string i swear" } | |
var Newroute=new Route(); | |
sys.puts(Route); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
project structure | |
admin | |
-webpages | |
- edit | |
- add | |
- list | |
- delete | |
-some other list | |
data - ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://www.google.com/search?q=libcrypto.so+memory+leaks | |
//this is a wild guess however see the output of simple script | |
var http = require('http') | |
, fs = require('fs') | |
, sys = require('sys') | |
, server = http.createServer(function(req, res) { | |
if(req.url=='/exit'){ http.close(); return;} | |
res.writeHead(200, {"Content-Type": "text/plain"}) |
OlderNewer