Skip to content

Instantly share code, notes, and snippets.

function *count(n) {
for (let i = 0; i < n; i++) {
yield i;
}
}
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
const asyncForEach = async (values, callback) => {
import { Credentials } from 'uport'
import { verifyJWT } from 'did-jwt'
async function mySigner (data) {
// bring up signing UX
// sign data with sha256/secpk256k1
// see https://github.com/uport-project/did-jwt#creating-custom-signers-for-integrating-with-hsm
return
}
@lmars
lmars / commands.txt
Last active January 22, 2016 20:43
Flynn Redis
# create a redis app
flynn create --remote "" redis
# create a release using the latest (at the time of writing) Docker Redis image
flynn -a redis release add -f config.json "https://registry.hub.docker.com?name=redis&id=868be653dea3ff6082b043c0f34b95bb180cc82ab14a18d9d6b8e27b7929762c"
# scale the server to one process. This may time out initially as the server pulls the image, but watch "flynn -a redis ps" and should come up.
flynn -a redis scale server=1
# redis should now be running in the cluster at redis.discoverd:6379
@guilherme
guilherme / gist:9604324
Last active July 23, 2024 08:28
Git pre-commit hook that detects if the developer forget to remove all the javascript console.log before commit.
#!/bin/sh
# Redirect output to stderr.
exec 1>&2
# enable user input
exec < /dev/tty
consoleregexp='console.log'
# CHECK
if test $(git diff --cached | grep $consoleregexp | wc -l) != 0
then
@quchen
quchen / trolling_haskell
Last active February 24, 2024 01:30
Trolling #haskell
13:15 <xQuasar> | HASKELL IS FOR FUCKIN FAGGOTS. YOU'RE ALL A BUNCH OF
| FUCKIN PUSSIES
13:15 <xQuasar> | JAVASCRIPT FOR LIFE FAGS
13:16 <luite> | hello
13:16 <ChongLi> | somebody has a mental illness!
13:16 <merijn> | Wow...I suddenly see the error of my ways and feel
| compelled to write Node.js!
13:16 <genisage> | hi
13:16 <luite> | you might be pleased to learn that you can compile
| haskell to javascript now
@mikolalysenko
mikolalysenko / gist:5085308
Created March 4, 2013 20:24
Skeletal animation in JavaScript

Here is a sketch of how one might go about doing skeletal animation in JavaScript, broken down into different npm modules that would need to be written:

  • A BVH to JSON converter.
    BVH is a standard format for representing skeletal animation, there is tons of data in the format, and many tools can consume/produce it. So getting things working in this space is priority #1. I think the best way to tackle this problem would be to write a simple module that takes a stream, and produce a JSON object that exactly represents the HIERARCHY and MOTION sections of a BVH file, along with some serialize method that can produce the same output.
  • A simple animation viewer. Outside voxel.js, we should probably have a stick figure animation viewer. this could be done in THREE.js using wires to draw each of the joints.
  • A motion tweening module Or basically some method to interpolate between per-frame motions. This is necessary to perform

High level style in javascript.

Opinions are like assholes, every one has got one.

This one is mine.

Punctuation: who cares?

Punctuation is a bikeshed. Put your semicolons, whitespace, and commas where you like them.

@paolorossi
paolorossi / html5-video-streamer.js
Created March 7, 2012 13:21
Node.js HTML5 video streamer
/*
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js
*/
var http = require('http'),
fs = require('fs'),
util = require('util');
http.createServer(function (req, res) {
var path = 'video.mp4';
@saetia
saetia / gist:1623487
Last active July 16, 2024 05:56
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat