Skip to content

Instantly share code, notes, and snippets.

View ashnur's full-sized avatar
🐢
fragments of scrolls surround me

Aron Gabor ashnur

🐢
fragments of scrolls surround me
View GitHub Profile
@ashnur
ashnur / ReplicatedRandomChrome.js
Created September 25, 2015 10:12 — forked from fta2012/ReplicatedRandomChrome.js
Demonstrates how to replicate a stream of Math.random() given two past observations for **Chrome**. Code was only tried on Chrome 43 (07/2015). Answers the question from this issue: https://github.com/fta2012/ReplicatedRandom/issues/2.
var rngstate;
function MathRandom() {
// Our own implementation of Math.random().
// Source code was copied from https://code.google.com/p/chromium/codesearch#chromium/src/v8/src/math.js&q=MathRandom&sq=package:chromium&type=cs&l=130
// You need to solve for the rngstate first before this can be used.
console.assert(rngstate, "You need to set the global variable `rngstate` first. For example: `rngstate = solve(Math.random(), Math.random());`");
if (!rngstate) return;
var r0 = (Math.imul(18030, rngstate[0] & 0xFFFF) + (rngstate[0] >>> 16)) | 0;
rngstate[0] = r0;
var r1 = (Math.imul(36969, rngstate[1] & 0xFFFF) + (rngstate[1] >>> 16)) | 0;
@ashnur
ashnur / gist:2063152
Created March 17, 2012 17:31 — forked from FireyFly/gist:2000920
Object inheritance
var Base = {}
Object.defineProperty(Base, 'extend', {
enumerable: false,
value: function(obj) {
var descs = {}
Object.getOwnPropertyNames(obj).forEach(function(key) {
descs[key] = Object.getOwnPropertyDescriptor(obj, key)
})
return Object.create(this, descs)
@ashnur
ashnur / tmEAaKsk
Created May 7, 2012 03:31 — forked from anonymous/tmEAaKsk
a guest on May 6th, 2012 - pastebin.com/tmEAaKsk
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
//$(document).ready(function(){
var context;
var dx= 4;
var dy=4;
var y=150;
var x=10;
var rightDown = false;
var leftDown = false;
@ashnur
ashnur / APPNAME
Created May 21, 2012 14:29 — forked from eculver/APPNAME
init.d script for node.js for debian
#! /bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28
@ashnur
ashnur / \\etc\\init\\APPNAME.conf
Created May 21, 2012 16:03 — forked from shimondoodkin/\\etc\\init\\APPNAME.conf
an Upstart script for node.js app I used once ago, it demonstrates how to use nave from within a script, just replace node with nave use with node version
#!upstart
description "APPNAME node.js server"
author "Shimon Doodkin"
# license: public domain
start on runlevel [2345]
stop on runlevel [06]
#pre-start script
# exec touch /var/log/APPNAME.nodejs.log
@ashnur
ashnur / git_notes.md
Created April 6, 2016 03:34 — forked from jaygooby/git_notes.md
Git, you bloody git

Ignore line-ending differences when diffing

(You can't use this with git difftool or merge though)

git diff --ignore-space-at-eol

Prefer one branch over another when merging

@ashnur
ashnur / common-consensus-protocols.md
Created October 10, 2016 21:19 — forked from nerdfiles/common-consensus-protocols.md
Common Consensus Protocols

Common Consensus Protocols

Infocologically-sane consensus protocols must satisfy the following conditions:

Factivity Order        : False information is not stored.  
                         (Rollback)  
                         √ Persistence

Motive Order           : Only purposeful information is stored.  

(Recovery/Checkpointing)

@ashnur
ashnur / web-servers.md
Created November 27, 2016 20:28 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@ashnur
ashnur / netst
Created October 2, 2017 10:10 — forked from thusoy/netst
Windows equivalent of netstat -tulpn
#!/bin/bash
# Normally windows doesn't give out the process name when you run netstat -ano, thus making it
# hard to figure out what process is bound to the different ports. This script extracts the PID
# from the netstat output, and fetches the corresponding binary name from the tasklist, and
# merges the two together. Needs a MinGW environment like Git Bash and python to work.
{ tasklist | tail -n +5; echo ===; netstat -ano | grep LIST; } | python -c "
import sys
pad = [0, 21, 9, 0, 5, 8, 0]
@ashnur
ashnur / netst
Created October 2, 2017 10:10 — forked from thusoy/netst
Windows equivalent of netstat -tulpn
#!/bin/bash
# Normally windows doesn't give out the process name when you run netstat -ano, thus making it
# hard to figure out what process is bound to the different ports. This script extracts the PID
# from the netstat output, and fetches the corresponding binary name from the tasklist, and
# merges the two together. Needs a MinGW environment like Git Bash and python to work.
{ tasklist | tail -n +5; echo ===; netstat -ano | grep LIST; } | python -c "
import sys
pad = [0, 21, 9, 0, 5, 8, 0]