Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Alexander Elias vokeio

🎯
Focusing
Block or report user

Report or block vokeio

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nooges
nooges / avrdude-flash.sh
Created Oct 11, 2017
Script for flashing .hex file onto Pro Micro with avrdude
View avrdude-flash.sh
#!/usr/bin/env bash
MCU=atmega32u4
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
fi
if [ "$#" -ne 1 ]; then
@vlucas
vlucas / encryption.js
Last active Oct 19, 2019
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
jung-kim / map-perf.js
Last active Jul 6, 2019
es6 map vs array vs obj performance test
View map-perf.js
"use strict";
let looper = (callback) => {
let n = 2000000;
while (n > 0) {
callback(n);
n--;
}
}
@skeggse
skeggse / crypto-pbkdf2-example.js
Last active Jun 19, 2019
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
WebReflection / String.prototype.template.js
Last active Feb 17, 2019
ES6 Template like strings in ES3 compatible syntax.
View String.prototype.template.js
// this is now a module:
// https://github.com/WebReflection/backtick-template#es2015-backticks-for-es3-engines--
var template = require('backtick-template');
// just string
const info = 'template';
`some ${info}` === template('some ${info}', {info});
@videlais
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
* http://caniuse.com/#feat=deviceorientation
*
* The DeviceOrientationEvent.alpha value represents the motion of the device around the z axis,
* represented in degrees with values ranging from 0 to 360.
*
@hueniverse
hueniverse / gist:7686452
Last active Oct 2, 2019
Walmart Mobile node.js Setup
View gist:7686452

Overview

We run multiple server processes in two data centers. Each process listens on two ports, one for HTTP and one for HTTPS. HTTPS is terminated by Apache prior to reaching node.js. HTTP goes directly from the client to node.js (through a master load balancer). We do not use clusters. We slice our physical servers into thin virtual machines running SmartOS, each with about 3GB of memory designed for a single node.js process.

Our node.js servers are hapi.js servers using the composer functionality and plugins architecture. We have three sets of plugins loaded: mobile web front end experience (single page app), legacy API reverse proxy, and monitoring.

We also serve original node.js services off another server zone which runs closed source plugins using hapi.

Analytics

View vim_cheatsheet.md

Introduction

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

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
@gordonbrander
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
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// 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`
You can’t perform that action at this time.