Skip to content

Instantly share code, notes, and snippets.

View gavinengel's full-sized avatar

Gavin Engel gavinengel

View GitHub Profile
@gavinengel
gavinengel / brolog.js
Created February 26, 2016 21:27
(⌐■_■)
// 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
gavinengel / how-are-you.js
Last active March 8, 2016 21:17
Paste this into your Google Chrome Devtools console
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
gavinengel / intro.md
Created February 25, 2016 22:57 — forked from gschema/intro.md
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. http://www.example.com or http://www.example.com/whichever-page/ 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
gavinengel / runner.sh
Last active June 28, 2016 16:15
Headless Selenium tests on your server
#!/bin/sh
# you want to be able to do browser testing, but in an automated way. here is how!
# Step 1: create your selenium script, using https://saucelabs.github.io/sb-sauce-plugin/, Firefox, and your text editor.
# Step 2: install some npm's:
# I was able to install selenium-standalone without sudo, using this method https://gist.github.com/gavinengel/1842179837823dc25730
lib;
npm install selenium-standalone;
@gavinengel
gavinengel / docker-notes.txt
Last active April 14, 2017 23:18
Docker notes
# productive Docker host?
1. https://coreos.com/os/docs/latest/booting-on-ec2.html and select HVM AMI
2. create single node (open TCP and UDP all)
3. ssh into node
4. install Rancher, see below
###
@gavinengel
gavinengel / node-and-npm-in-30-seconds.sh
Created December 8, 2015 18:49 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ 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 http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@gavinengel
gavinengel / index.js
Created August 26, 2015 18:53
generate a six char password suffix (64bit)
#!/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']
@gavinengel
gavinengel / keybase.md
Created May 27, 2015 01:45
keybase.md

Keybase proof

I hereby claim:

  • I am gavinengel on github.
  • I am gavinengel (https://keybase.io/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
gavinengel / daemonic.stub.js
Last active August 29, 2015 14:20
daemonic: wrapper stub for turning a normall shell command into a node.js daemon
#!/usr/bin/env node
// source: https://gist.github.com/gavinengel/98c069197baf6a55dd2b
// 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
gavinengel / class-and-attr-manipulation.js
Last active August 29, 2015 14:18
Eventscript (proposed concise, nested script for DOM event handling) vs Javascript
// jQuery
$('button').click(function(){
$('h1, h2, p').addClass('blue')
$('div').removeClass('important')
$('h3').toggleClass('error')
$('#foo').attr('alt', 'Lorem Ipsum')
});
// Eventscript
button:click {