Skip to content

Instantly share code, notes, and snippets.


Alexander Elias vokeio

View GitHub Profile
nooges /
Created Oct 11, 2017
Script for flashing .hex file onto Pro Micro with avrdude
#!/usr/bin/env bash
if grep -q -s Microsoft /proc/version; then
echo 'ERROR: Pro Micros can not be flashed within the Windows Subsystem for Linux (WSL) currently. Instead, take the .hex file generated and flash it using AVRDUDE, AVRDUDESS, or XLoader.'
exit 1
if [ "$#" -ne 1 ]; then
vlucas / encryption.js
Last active Aug 7, 2020
Stronger Encryption and Decryption in Node.js
View encryption.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
jung-kim / map-perf.js
Last active Jul 8, 2020
es6 map vs array vs obj performance test
View map-perf.js
"use strict";
let looper = (callback) => {
let n = 2000000;
while (n > 0) {
skeggse / crypto-pbkdf2-example.js
Last active Jun 23, 2020
Example of using crypto.pbkdf2 to hash and verify passwords asynchronously, while storing the hash and salt in a single combined buffer along with the original hash settings
View crypto-pbkdf2-example.js
var crypto = require('crypto');
// larger numbers mean better security, less
var config = {
// size of the generated hash
hashBytes: 32,
// larger salt means hashed passwords are more resistant to rainbow table, but
// you get diminishing returns pretty fast
saltBytes: 16,
// more iterations means an attacker has to take longer to brute force an
WebReflection / String.prototype.template.js
Last active Jun 30, 2020
ES6 Template like strings in ES3 compatible syntax.
View String.prototype.template.js
// this is now a module:
var template = require('backtick-template');
// just string
const info = 'template';
`some ${info}` === template('some ${info}', {info});
videlais / accelerometer.js
Created Dec 25, 2013
Complete Accelerometer.js code
View accelerometer.js
* An accelerometer object for detecting device orientation
* and motion (if supported)
* Chrome 7+, Firefox 6+, IE11+, iOS Safari 4.0+, Android Browser 3.0, Blackberry 10.0
* The DeviceOrientationEvent.alpha value represents the motion of the device around the z axis,
* represented in degrees with values ranging from 0 to 360.


  • C-a == Ctrl-a
  • M-a == Alt-a


:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
gordonbrander / ID.js
Created Mar 28, 2012
ID - a unique ID/name generator for JavaScript
View ID.js
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <>.
// The goals of this function are twofold:
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`

Test the performance of TreeWalker compared to other DOM walker methods. Ran each test 1000 times. Try it yourself.

Chrome 17

Method                  Total ms    Average ms
document.TreeWalker     911         0.911
Iterative Traverser     2945        2.945
You can’t perform that action at this time.