Skip to content

Instantly share code, notes, and snippets.


Gavin Engel gavinengel

View GitHub Profile
View brolog.js
// party til you puke, dawg.
console.brolog = function(bromessage) {
awesomeizers = ['bro', 'dawg', 'my man'];
brogreeting = awesomeizers[ Math.floor(Math.random() * awesomeizers.length) ];
console.log(bromessage + ', ' + brogreeting + '.');
console.brolog('application complete');
gavinengel / how-are-you.js
Last active Mar 8, 2016
Paste this into your Google Chrome Devtools console
View how-are-you.js
var css = "text-shadow: -1px -1px hsl(0,100%,50%), 1px 1px hsl(5.4, 100%, 50%), 3px 2px hsl(10.8, 100%, 50%), 5px 3px hsl(16.2, 100%, 50%), 7px 4px hsl(21.6, 100%, 50%), 9px 5px hsl(27, 100%, 50%), 11px 6px hsl(32.4, 100%, 50%), 13px 7px hsl(37.8, 100%, 50%), 14px 8px hsl(43.2, 100%, 50%), 16px 9px hsl(48.6, 100%, 50%), 18px 10px hsl(54, 100%, 50%), 20px 11px hsl(59.4, 100%, 50%), 22px 12px hsl(64.8, 100%, 50%), 23px 13px hsl(70.2, 100%, 50%), 25px 14px hsl(75.6, 100%, 50%), 27px 15px hsl(81, 100%, 50%), 28px 16px hsl(86.4, 100%, 50%), 30px 17px hsl(91.8, 100%, 50%), 32px 18px hsl(97.2, 100%, 50%), 33px 19px hsl(102.6, 100%, 50%), 35px 20px hsl(108, 100%, 50%), 36px 21px hsl(113.4, 100%, 50%), 38px 22px hsl(118.8, 100%, 50%), 39px 23px hsl(124.2, 100%, 50%), 41px 24px hsl(129.6, 100%, 50%), 42px 25px hsl(135, 100%, 50%), 43px 26px hsl(140.4, 100%, 50%), 45px 27px hsl(145.8, 100%, 50%), 46px 28px hsl(151.2, 100%, 50%), 47px 29px hsl(156.6, 100%, 50%), 48px 30px hsl(162, 100%, 50%), 49px 31px hsl(167.4, 100%, 5
gavinengel /
Created Feb 25, 2016 — forked from gschema/
Basic JavaScript MVC Implementation

Basic JavaScript MVC Implementation

Despite being derived from classical MVC pattern JavaScript and the environment it runs in makes Javascript MVC implementation have its own twists. Lets see how typical web MVC functions and then dive into simple, concrete JavaScript MVC implementation.

How Web MVC typically works

Typical server-side MVC implementation has one MVC stack layered behind the singe point of entry. This single point of entry means that all HTTP requests, e.g. or etc., are routed, by a server configuration, through one point or, to be bold, one file, e.g. index.php.

At that point, there would be an implementation of Front Controller pattern which analyzes HTTP request (URI at first place) and based on it decides which class (Controller) and its method (Action) are to be invoked as a response to the request (method is name for function and member is name for a variable when part of the class/object).

gavinengel /
Last active Jun 28, 2016
Headless Selenium tests on your server
# you want to be able to do browser testing, but in an automated way. here is how!
# Step 1: create your selenium script, using, Firefox, and your text editor.
# Step 2: install some npm's:
# I was able to install selenium-standalone without sudo, using this method
npm install selenium-standalone;
View docker-notes.txt
# productive Docker host?
1. and select HVM AMI
2. create single node (open TCP and UDP all)
3. ssh into node
4. install Rancher, see below
gavinengel /
Created Dec 8, 2015 — forked from isaacs/
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl | sh
gavinengel / index.js
Created Aug 26, 2015
generate a six char password suffix (64bit)
View index.js
#!/usr/bin/env node
* hash the std and in (6) base64 for appending to a password, perhaps yearly
* example: base password is `foobarbaz`, and this year's append is: tU68/+, final password is: `foobarbaztU68/+`,
* this means you can use a single `base password`
* 64^6 = 68,719,476,736 so it makes each password very difficult to "guess"
var fs = require('fs')
var crypto = require('crypto')
var home = process.env['HOME']

Keybase proof

I hereby claim:

  • I am gavinengel on github.
  • I am gavinengel ( on keybase.
  • I have a public key whose fingerprint is A25A 07F1 A0C7 CAF9 1836 FA5E 2898 73B1 4558 D9C9

To claim this, I am signing this object:

gavinengel / daemonic.stub.js
Last active Aug 29, 2015
daemonic: wrapper stub for turning a normall shell command into a node.js daemon
View daemonic.stub.js
#!/usr/bin/env node
// source:
// example usage: $ pm2 start jade-watch.js;
var shelld = 'jade -w index.jade' // EDIT ONLY THIS LINE
var terminal = require('oh-my-terminal')
terminal.exec(shelld, function(err, stdout, stderr) {
if(err) console.log(err)
else console.log(stdout) + console.log(stderr) ;
gavinengel / class-and-attr-manipulation.js
Last active Aug 29, 2015
Eventscript (proposed concise, nested script for DOM event handling) vs Javascript
View class-and-attr-manipulation.js
// jQuery
$('h1, h2, p').addClass('blue')
$('#foo').attr('alt', 'Lorem Ipsum')
// Eventscript
button:click {