Skip to content

Instantly share code, notes, and snippets.

View rusintez's full-sized avatar
💭
🍝

vlspopov rusintez

💭
🍝
View GitHub Profile
@sTiLL-iLL
sTiLL-iLL / scribbles.js
Last active August 29, 2015 14:12
my nonblocking, threadsafe file writer/appender for nodejs. works great with clustered servers, and child processes that write to shared or static file-stores
//scribbles.js
var fs = require('fs'),
pth = require('path'),
cueMngr = {};
function Scribbles(fileNm) {
this.handle = fileNm;
this.canWrite = false;
@sTiLL-iLL
sTiLL-iLL / embeddedWRKR.js
Created February 1, 2015 11:44
Spin a worker from within the original html/js file!
function worker() {
setInterval(function() {
postMessage({foo: "bar"});
}, 1000);
}
var code = worker.toString();
code = code.substring(code.indexOf("{")+1, code.lastIndexOf("}"));
@JeffSackmann
JeffSackmann / tennisMatchProbability.py
Created January 13, 2011 15:56
calculates probability of winning a tennis match from any given score dependent on the skill levels of the two players
## calculates probability of winning a tennis match from any given score dependent on the skill levels
## of the two players
## requires functions in other gists:
## gameProb: https://gist.github.com/768862
## setGeneral: https://gist.github.com/776986
## tiebreakProb: https://gist.github.com/776875
def fact(x):
if x in [0, 1]: return 1
@timoxley
timoxley / invert.js
Last active December 18, 2015 09:49
pausing a stream in shoejs
var http = require('http');
var ecstatic = require('ecstatic')(__dirname + '/static');
var shoe = require('../../');
var through = require('through')
var net = require('net')
// Goal:
// pipe connection on port 10000 to port 9999
// but do some async operation
// before doing so
@aredridel
aredridel / boot-coreos.sh
Last active January 4, 2016 18:12
Set up and boot CoreOS on top of a stock DigitalOcean Fedora 19 install. Abuses the Fedora 19 root as the CoreOS STATE partition. Still todo: copy SSH keys from Fedora install.
#!/bin/sh
kexec --load /boot/coreos_production_pxe.vmlinuz --initrd=/boot/coreos_production_pxe_image.cpio.gz --append='state=/dev/vda root=squashfs: sshkey="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAEAQCZ3fvhC7StXFdFRuXApBuXyS2phoH7ZVKMUMOi3DrbnZWC01GUq74WdalRDHtfq2dl0CPctLb8RHSD+/dKgWEH0gmoEOCio09ZAY5Ui4Cy+0cCGefXkUnJR4lgNOYD076BXjJwsCVCD8sMlFFT08Qn4/voP0jpL1uvvoWiC1KSvSjZf7sP/hRgsO633OuclXyVVq7mC6q+2QVg6hfO49Gt7TVXb+8lc8aUHAYyrXEVag6oICWqxWlSglbEpXCXhK4RB1f8h2vCaEPe2Kf1LNPYJ3dN5H5v+tnst9oZbFjo/qNSm4RvPBb3nsNARdcemdGcwiTjAiIn9gMxBMOyiYOYSgVwGd2U76FR0/RUFUORprynn6uebBhtpGzIAuFsUygMAPAM2tocO+t+h8AQviF6IeA9rKwf5bFTXV9HLy+iUoCWsVBmGypfGbsD7UNg3DIpXv4FdoLDDiCq+OV16ludjLk5pjknshH0cII+Q5b1fcITKSMrZ0CnMytkHHYPTvJ/uc2W9p3howAbMCs+WpNsSnLoCfq5ZjWclauV9Sn7OULQSMuKzTBF+bN7FOyolPbFrW+B3ESUpbonbLbKOubvsBjnUQLNoNjH4pa5Sg3Pluh1EoYLq/oKYU/C+SSwnbRy9N1h2z5UZy/CyrGNG8UomkuFIZWOAGH+zqwU1iCYaWHPgUNXM+4gSe0cGmVesFRpco5nhqvHGdDtw3OCC1U0f9jj6Pk+4jFmulj45+Hu4ZEL8wyMlftbycT8KtuqSVOD/yuytPFlvBzFrjP9s3V8ZN46y5rLpR9dAD+DJHYVESGxQV9lLq2g0p8IJ
@floehopper
floehopper / README.markdown
Created December 3, 2010 18:12
Generate, send, receive, and parse a multipart/related HTTP POST request in Ruby

Setup Apache to listen on a port and log incoming HTTP requests including body

terminal 1

$ cat /etc/apache2/sites-enabled/mms-test 
Listen 50690
LogLevel debug
DumpIOInput On
# DumpIOOutput On

$ sudo tail -f /var/log/apache2/error.log | grep "mod_dumpio.c(74)" | sed "s/.*HEAP.: //"

@billywhizz
billywhizz / script_test.js
Created February 6, 2011 09:42
testing vm script functionality in node.js
var vm = require('vm'),
code = 'var square = n * n;',
fn = new Function('n', code),
script = vm.createScript(code),
sandbox;
n = 5;
sandbox = { n: n };
benchmark = function(title, funk) {
@piatra
piatra / app.js
Created June 27, 2012 12:14
xhr2 + nodejs + filereader = resumable uploads
var http = require('http')
, formidable = require('formidable')
, fs = require('fs')
, qs = require('querystring')
, util = require('util')
, uploads = {};
http.createServer(function(req, res){
if(req.method == 'GET') {
if(req.url != '/favicon.ico') {
@bennadel
bennadel / angularjs-errors.htm
Created October 3, 2013 13:56
Logging Client-Side Errors With AngularJS And Stacktrace.js
<!doctype html>
<html ng-app="Demo" ng-controller="AppController">
<head>
<meta charset="utf-8" />
<title>
Logging Client-Side Errors With AngularJS And Stacktrace.js
</title>
<style type="text/css">
@ruthmarks151
ruthmarks151 / gitprint.js
Last active December 14, 2018 06:39 — forked from beevelop/gitprint.js
Print GitHub markdown files
document.querySelector('#readme').setAttribute('style', 'position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 100; background-color: white');
document.querySelector('body').appendChild(document.querySelector('#readme'));
document.querySelector('article').style.borderWidth = 0;
window.print();