Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am markhuge on github.
  • I am markhuge (https://keybase.io/markhuge) on keybase.
  • I have a public key whose fingerprint is 6450 7421 25CF B80C C9EA 6BB6 8EA2 79E6 5667 3B23

To claim this, I am signing this object:

@markhuge
markhuge / class.js
Last active August 29, 2015 14:04
Javascript prototypal pitfalls
// Pseudoclassical class pattern
// Constructor
function myThing() {
// under the hood 'this' is mapped to a new object
// created from myThing's prototype and NOT to myThing
this.name = "myThing";
}
@markhuge
markhuge / chef.template.erb
Last active August 29, 2015 14:07
Node.js app Upstart Script example
# <%= @app_name %>.conf
# This file is generated by Chef for <%= node[:fqdn] %>
description "<%= @app_name %>"
start on filesystem or runlevel [2345]
stop on runlevel [06]
expect fork
respawn
  • When this app is started with node index, a SIGINT (Ctrl+c) is caught by the app and it continues running.
  • When this app is started with npm start, a SIGINT causes npm to exit, detaching the still running node process from the foreground.
@markhuge
markhuge / travis.yml
Last active August 29, 2015 14:09 — forked from tgrrtt/travis.yml
# Set up notification options
notifications:
email:
recipients:
- one@example.com
- other@example.com
# change is when the repo status goes from pass to fail or vice versa
on_success: change
on_failure: always
@markhuge
markhuge / gist:6038456
Created July 19, 2013 11:22
Handlebars Helper - Time Since <date>
Handlebars.registerHelper 'timesince', (date) ->
seconds = Math.floor((new Date() - new Date(date)) / 1000)
interval = Math.floor seconds / 31536000
if interval > 1
return new Handlebars.SafeString interval + " years"
interval = Math.floor seconds / 2592000
if interval > 1
return new Handlebars.SafeString interval + " months"
@markhuge
markhuge / README.md
Last active March 25, 2016 12:57
Fix failing node deployments on AWS Elastic Beanstalk

Fix failing node deployments on AWS Elastic Beanstalk

Elastic beanstalk runs npm install with a system user that has no homedir. During the npm install step, it's expecting a $HOME env variable for the npm cache (which doesn't exist). add this file to your project's .ebextensions directory to have it use root's homedir as a temporary path.

This workaround was provided by AWS support, but it doesn't appear to be documented anywhere. Determining root cause on this was a massive pain in the ass. Sharing this so others don't need to feel the pain.

@markhuge
markhuge / tmux-cheatsheet.markdown
Created May 24, 2016 18:17 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname

This was fucking annoying.

  1. Create GPT on device
  2. Create new partition
  3. Set type as ef00 (EFI)
  4. Write partition table
  5. mkfs.vfat -F32 /dev/< device >
  6. mount Windows10.iso to dir
  7. mount usb drive to dir
  8. copy files from ISO to USB drive
@markhuge
markhuge / README.md
Last active July 16, 2016 01:55
Generate random password with openssl

For the pedants (which I can totally be at times):

Base64 uses a reduced character set, so we're generating a less computationally complex string for something like hashcat to chew on, than say, the full ascii character set. Base64 also typically ends with = or == making the pattern even more predictable.

It's still better than hex, and orders of magnitude better than your initials + your grandma's birthday.