Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# Pre-commit hook for git which removes trailing whitespace, converts tabs to spaces, and enforces a max line length.
if git-rev-parse --verify HEAD >/dev/null 2>&1 ; then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
@ltfschoen
ltfschoen / get_keys_from_associative_array.js
Last active April 18, 2021 00:51
Object(keys) Helper Function for ExtendScript
// Custom Helper function for ExtendScript (Adobe CEP) created as an alternative since JavaScript Object(keys) method does not work
var getKeysWithoutObjectKeysSupport = function(associativeArrayObject) {
var arrayWithKeys=[], associativeArrayObject;
for (key in associativeArrayObject) {
// Avoid returning these keys from the Associative Array that are stored in it for some reason
if (key !== undefined && key !== "toJSONString" && key !== "parseJSON" ) {
arrayWithKeys.push(key);
}
}
@ltfschoen
ltfschoen / bulletproof-git-workflow.md
Last active January 18, 2017 23:34 — forked from db/bulletproof-git-workflow.md
bulletproof git workflow

Bulletproof Git Workflow

start working

git checkout master
git pull
git checkout -b feature/my-work
# edit your files
@ltfschoen
ltfschoen / python_list_iterator_comparison.py
Created February 14, 2017 08:36
Python List Iterator Comparison Demo
# copy, paste, and execute this code in a python repl with python v2.7.12 or greater installed
import sys; assert sys.version_info >= (2,7,12)
# reimplement default repr function to return a module, name, and memory address of given object
def __repr__(self):
return '<%s.%s object at %s>' % (
self.__class__.__module__,
self.__class__.__name__,
hex(id(self))
)
@ltfschoen
ltfschoen / test_debug_levels_in_python.py
Created February 22, 2017 03:39
test_debug_levels_in_python
# Note: Some Python interpreters may prevent setting the severity level to certain levels below a threshold
import logging
logger = logging.getLogger('sudoku logger')
logger
def run_logger_calls():
logger.debug('debug message')
logger.info('info message')
logger.warning('warn message')
logger.error('error message')
@ltfschoen
ltfschoen / test_assertions_in_python.py
Created February 22, 2017 03:41
test_assertions_in_python.py
values = {}
assert type(values) is not object, "values is not an None: %r" % values
assert type(values) is bool, "values is not a Boolean: %r" % values
@ltfschoen
ltfschoen / main_function_that_takes_debug_level_from_cli_in_python.py
Created February 22, 2017 03:45
main_function_that_takes_debug_level_from_cli_in_python.py
#!/usr/bin/env python
import sys
import logging
import logging.config # import associated logging.conf. Refer to https://docs.python.org/3/howto/logging.html
import solution # import a file called say solution.py
def get_log_level(log_args):
valid_levels = ['DEBUG', 'INFO', 'WARNING', 'ERROR'] # numeric levels 10, 20, 30, 40
proposed_level = log_args[0].split("=", 1)[1].upper()
@ltfschoen
ltfschoen / launch.sh
Created March 7, 2017 04:03
Shell script that generates separate Terminal tabs to run a Ruby on Rails web server then automatically opens associated webpage in your web browser
#!/bin/bash
# File: ~/launch.sh
# Original Code Reference: http://dan.doezema.com/2013/04/programmatically-create-title-tabs-within-the-mac-os-x-terminal-app/
# New-BSD License by Original Author Daniel Doezema http://dan.doezema.com/licenses/new-bsd/
# Modified by Luke Schoen in 2017 to include loading new tabs for Rails Server and automatically open webpage in browser.
# References: https://developer.apple.com/library/content/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html
@ltfschoen
ltfschoen / lexical_sum.js
Created March 20, 2017 03:19
Lexically nested functions within enclosing function
// Lexically nested function definitions defined within enclosing function
function Sum(arg0) {
function Inner1(arg1) {
function Inner2(arg2) {
return arg0 + arg1 + arg2;
}
return Inner2;
}
return Inner1;
}
@ltfschoen
ltfschoen / merge_sort.js
Created March 27, 2017 09:08
Merge Sort
let mergeSort = (arr) => {
if (arr.length < 2) {
console.log("Merging len 1: ", arr);
return arr;
}
console.log("Merging len > 1: ", arr)
let mid = parseInt(arr.length / 2),
l = arr.slice(0, mid),