Skip to content

Instantly share code, notes, and snippets.

View shimondoodkin's full-sized avatar

Shimon Doodkin shimondoodkin

View GitHub Profile
@shimondoodkin
shimondoodkin / rtconsole.js
Last active December 18, 2015 22:59
realtime console in nodejs. node.js enables to integrate tooling into the application. for a quick tab refresh to build front end tooling.
//functions.js
//f.rtconsole('generate.py build','/mnt/hda1/www/bursa/public/charts/generate.py',['build'],req,res,purl)
var tempstreams={};
function rtconsole(streamname,command,command_args,req,res,purl)
{
//var streamname='genbuild';
//if(global.tempstreams===undefined)tempstreams={}; // ceate some global to store text and status
if(tempstreams[streamname]===undefined)tempstreams[streamname]={};
var tempstream=tempstreams[streamname];
if(tempstream.text===undefined)tempstream.text="";
@shimondoodkin
shimondoodkin / goals.md
Last active January 9, 2023 08:17
plain vanilla node.js intro tutorial to learn a lot in the shortest time.

The plan is to take a simple nodejs server. and add to it simple file serving capabilities. also to have a custom responce to a certien url. to be able to make a simple api in addition of serving files.

goals:

  • to learn read the documentation
  • to understand the whole concept
  • to use some api for hands on expirience
  • streach goal: learn basic npm usage.
@shimondoodkin
shimondoodkin / SearchAndReplaceInText.cs
Last active September 9, 2021 04:47
search and replace in an Open XML word document.
/*
references:
WindowsBase
Open XML Format SDK 2.5 - from NuGet
*/
using System;
using System.Collections.Generic;
using System.Linq;
/* based off of tinyxhr by Shimon Doodkin - license: public doamin - https://gist.github.com/4706967
Added ontop of Simon's code:
- Serialization of the object
- Moved some arguments to line up with jQuery( url, data, callback )
- Will attempt to parse JSON from the response if it's valid JSON
- Added a tinyPost and tinyGet method
Some other things that'd be good:
- Seprate error callback for failed responses
var express = require('express'),
passport = require('passport'),
LocalStrategy = require('passport-local').Strategy,
connect = require('connect'),
http = require('http'),
path = require('path'),
util = require('util'),
fs = require('fs'),
redis = require('redis'),
cookie = require('cookie'),
@shimondoodkin
shimondoodkin / app.js
Last active May 7, 2024 13:34 — forked from katanacrimson/app.js
nodejs app - expressjs 3.0 + socket.io v9 + passport + redis (made to work)
var express = require('express'),
passport = require('passport'),
GoogleStrategy = require('passport-google').Strategy,
connect = require('express/node_modules/connect'),
http = require('http'),
path = require('path'),
util = require('util'),
fs = require('fs'),
redis = require('redis'),
cookie = require('cookie'),
@shimondoodkin
shimondoodkin / flat_object.js
Last active August 29, 2015 14:01
serialization of hierarchical object/array/int/str to a flat object and back
// 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)
//
//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)
{
@shimondoodkin
shimondoodkin / cbguard.js
Last active August 29, 2015 14:03
javascript callback guard - prevents a callback to be called twice
// 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);
}
}
@shimondoodkin
shimondoodkin / module developed.js
Last active August 29, 2015 14:07
rolling/running min in readable javascript
// this grown up to a module -
// https://github.com/shimondoodkin/efficient-rolling-stats