Skip to content

Instantly share code, notes, and snippets.

View jwerle's full-sized avatar
🔨
Working on @socketsupply/socket

Joseph Werle jwerle

🔨
Working on @socketsupply/socket
View GitHub Profile
while true; do printf "%.0f\n" $(echo "`ps -eo pcpu | head -2 | tail -n +2` * 100" | bc) ; sleep .5; done | histo
function p (s, b, e, d) {
var c = null;
var i = 0;
var n = 0;
var r = [];
var x = 0;
var y = 0;
while (null != (c = s[i++])) {
// got first brace
@jwerle
jwerle / cpu-stream.sh
Last active September 11, 2019 10:47
Stream CPU usage with `umq(1)' to a `histo(1)' histogram. See `umq(1)': https://github.com/jwerle/umq See `histo(1)': https://github.com/visionmedia/histo
#!/bin/bash
# ps -eo pcpu,pid,user,args | sort -r -k1
PS="ps"
VERSION="0.0.1"
version () {
echo $VERSION
}
@jwerle
jwerle / push.sh
Last active January 1, 2016 03:19
Push messages to a browser with `umq(1)` and `wscat(1)` via web sockets
#!/bin/sh
PORT=5000
## accept data from stdin
while read -r chunk; do
echo "$chunk" | umq push localhost $PORT
done
@jwerle
jwerle / .gitignore
Last active January 2, 2016 04:09
Node.js Application to apply for a job a perka (getperka.com)
node_modules/
resume.pdf
.DS_STORE
@jwerle
jwerle / example.js
Created April 9, 2014 15:45
Grep a function's source body
function beep () {
var b = 2;
var c = 10;
var foo = 'foo';
var biz = foo;
var str = foo +' '+ biz;
var sum = b + c;
return [str, sum];
}
# redirect tcp to fifo
$ while true; do nc -l 6000 > fifo; done
# redirect fifo to cat and prefix with "> "
$ while true; do printf "> "; cat < fifo; done
>
# write to tcp
$ echo abc | nc localhost 6000
$ echo 123 | nc localhost 6000
@jwerle
jwerle / output
Last active August 29, 2015 14:01
C struct initializations
$ cc s-struct-initalization.c && ./a.out
foo 1 bar
biz 2 baz
beep 3 boop
jwerle:~/repos/libhttp ☂ (modifications) master
× clib install hash
fetch : https://raw.github.com/clibs/hash/master/package.json
fetch : https://raw.github.com/clibs/hash/master/hash.c
save : ./deps/hash/hash.c
fetch : https://raw.github.com/clibs/hash/master/hash.h
error : unable to fetch https://raw.github.com/clibs/hash/master/hash.h
clib-install(72753,0x7fff7d37f310) malloc: *** error for object 0x7fa619501b20: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
@jwerle
jwerle / out.php
Created May 21, 2014 14:32
php interpolated buffer values
<? $a = array(); ?>
// should yield `null'
"unset element in array" = <?= json_encode($a['foo']); ?>
// should yield nothing
"false" = <?= false; ?>
// should yield `1'
"true" = <?= true; ?>