Skip to content

Instantly share code, notes, and snippets.

def remaining_water(height)
# some boundary checking, height is nil, height is emtpy?
left_point = 0
right_point = 0
water_remaining = 0
left = 0
right = height.length - 1
'use strict';
const fs = require('fs');
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
@franzese
franzese / is-on-master-branch.sh
Created January 3, 2020 20:56
Simple script to determine if current git repo is on master (or specified branch)
#!/bin/sh
# get the current branch name
branchName=$(git symbolic-ref --short HEAD)
# get the branch name to match from params
# if no params, use `master`
if [ "$1" != "" ]; then
masterBranch="$1"
else
masterBranch="master"
fi
@franzese
franzese / generate-release-notes.sh
Created January 3, 2020 20:49
Generate git release notes from last tag to current HEAD
#!/bin/sh
# gets tag from current branch
# --abbrev set to 0 to find the closest tagname without any suffix
previousTag=$(git describe --abbrev=0 --tags)
messages=$(git log --pretty=format:"- %s (%h)" "$previousTag"...HEAD)
echo "## Commits in this release:"
echo "$messages"
/*************************
Array Cheatsheet
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#Browser_compatibility
**************************/
let tmp1 = []; // "literal notation"
let tmp2 = new Array(); // potentially could be overwritten
let tmp3 = [5]; // [5] - length is 1
let tmp4 = [1, 2, 3]; // [1, 2, 3] - length is 3
let tmp5 = new Array(3); // [undefined, undefined, undefined]
// Properties
function newsletterSubscribe (name, email) {
// code
}
const newsletterSubscribe = (name, email) => {
// code
}
@franzese
franzese / killport
Created September 9, 2016 08:47
Killport Bash Shell Script
#!/bin/bash
# How To Use:
# move this file to /usr/local/bin
# ensure script is executable `chmod +x killport`
# To kill any processes running on a known port use:
# > killport <port>
if [ $# -eq 0 ]
then
@franzese
franzese / Utility.css
Created August 25, 2016 05:11
CSS Utility Classes
.clearfix:before, .clearfix:after
{ content: "\0020"; display: block; height: 0; overflow: hidden; }
.clearfix:after { clear: both; }
.clearfix { zoom: 1; }
.hidden { display: none;}
.error { color: #D9311E;}
.flex-wide { flex-grow: 999; }
.tall { height: 100%; }
.bold, strong { font-weight: 700; }
.italic { font-style: italic; }
@franzese
franzese / DOM-Ready.js
Created June 29, 2016 01:30
Vanilla JavaScript Document Ready
Document.prototype.ready = function(callback) {
if(callback && typeof callback === 'function') {
document.addEventListener("DOMContentLoaded", function() {
if(document.readyState === "interactive" || document.readyState === "complete") {
return callback();
}
});
}
};
@franzese
franzese / IIFE.js
Last active June 29, 2016 01:37
Globally accessible IIFE structure
// ensure namescope is available.. define it globally
var Via = Via || {};
// pass global var
(function(Via) {
Via.startMsg = 'Ready!';
Via._isDev = true;
Via.init = function() {
Via.log(Via.startMsg);