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
@jwerle
jwerle / ready.js
Last active December 18, 2015 16:59
ready function
var app = {}
!function (app) {
// boolean to indicate whether
// the `app` is ready
var isReady = false;
// the ready stack to house
// all of the callbacks pushed
// to it
var app = {}
!function (app) {
// container to push booleans
// for each event to indicate whether
// the `app` is ready
var isReady = [];
// the ready stack to house
// all of the callbacks pushed
@jwerle
jwerle / gist:5978791
Created July 11, 2013 20:11
match div ids with filter
[].filter.call(document.querySelectorAll('div'), function (div) { return (/^foo_*/).test(div.id); })
@jwerle
jwerle / stop-animation-frame.js
Last active December 19, 2015 21:49
stop animation frame
function stopAnimations () {
// Get the Body Element
var body = document.body
body.addEventListener('webkitAnimationStart', stopAnimation, false);
body.addEventListener('webkitAnimationIteration', stopAnimation, false);
body.addEventListener('animationstart', stopAnimation, false);
body.addEventListener('animationiteration', stopAnimation, false);
function stopAnimation (e) {
var target = e.target;
@jwerle
jwerle / log.c
Last active December 24, 2015 00:49
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int
main (void) {
double v, r;
v = 1000.0;
r = log10(v);
printf("%f\n", r);
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 / 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
'use strict'
import { UPDATE, createContainer } from 'stardux'
let domElement = document.createElement('div')
let template = '#{spinner}'
let initialState = {spin: false, spinner: ''}
let container = createContainer(domElement, initialState, reducer)
domElement.innerHTML = template
function reducer (state, action) {
switch (action.type) {
case UPDATE: