Skip to content

Instantly share code, notes, and snippets.

@maxterry
maxterry / get-article-for-word.js
Last active December 6, 2019 21:13
Is it "a" or "an"?
// Whether string starts with vowel sound
function isLeadingVowel(it) {
return ['a', 'e', 'i', 'o', 'u'].includes(it[0].toLowerCase());
}
// "A" or "an" for given string
function getArticle(it) {
return isLeadingVowel(it) ? 'an' : 'a';
}
#!/bin/bash
# This script installs the dependencies required by cypress.io tool
# on amazon linux AMI as the required dependencies are not easily available.
# path of dynamic executable of cypress
# for ex. /home/ec2-user/.cache/Cypress/3.0.1/Cypress/
CYPRESS_EXECUTABLE_FOLDER="/home/ec2-user/.cache/Cypress/3.1.5/Cypress"
exitError() {
@maxterry
maxterry / moment-utc.js
Created April 27, 2017 02:12
Moment local datetime to UTC
var d = new Date();
var lastModified = "Last Modified " + moment(d).fromNow() + " (" + moment.utc(d).format('MMMM Do YYYY, h:mm:ss A UTC') + ")";
@maxterry
maxterry / sync.sh
Last active April 17, 2017 17:45
Sync local directory with server over SSH on a custom port using rsync
rsync -av -e 'ssh -p PORT' --update ~/directory user@IP:directory
@maxterry
maxterry / keybase.md
Created February 8, 2017 20:04
keybase.md

Keybase proof

I hereby claim:

  • I am 1083 on github.
  • I am maxwell (https://keybase.io/maxwell) on keybase.
  • I have a public key ASAxxqOBYC3e3e-tp8oRkleM5p_Mu_Fk1mbbzB1SMUTdFwo

To claim this, I am signing this object:

@maxterry
maxterry / new-mac-setup.sh
Last active June 9, 2016 02:53
New Mac setup
# Change screenshot directory
defaults write com.apple.screencapture location ~/Screenshots
killall SystemUIServer
# Show dotfiles
defaults write com.apple.finder AppleShowAllFiles -bool YES
killall Finder
@maxterry
maxterry / center-vertically-and-horizontally.css
Created May 30, 2016 14:18
Center content in an element without static line-height and vertical-align
#element {
display: flex;
align-items: center;
justify-content: center;
}
@maxterry
maxterry / lightbox
Last active February 28, 2016 17:31
Simple Lightbox (modal window with semi-transparent background)
Simple Lightbox (modal window with semi-transparent background)
@maxterry
maxterry / parse.js
Created June 23, 2012 19:36 — forked from aaronksaunders/parse.js
Titanium Appcelerator Quickie: Parse API : parse.js
//Public client interface
function Client(applicationId, masterKey) {
this.applicationId = "applicationId";
this.masterKey = "masterKey";
}
exports.Client = Client;
//Parse API endpoint
var ENDPOINT = 'https://api.parse.com/1/classes/';
@maxterry
maxterry / gist:1689788
Created January 27, 2012 17:01
Naive memoized query param lookup
function param(key) {
var params = {}
window.location.search.substr(1).split("&").forEach(function(it) {
var slots = it.split("=")
params[slots[0]] = slots[1] == "true"? true :
slots[1] == "false"? false :
slots[1]
})
param = function(key) {
return params[key]