git checkout master
git pull
git checkout -b feature/my-work
# edit your files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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)) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Given a sorted array as input (ascending order only | |
* and without duplicates) that may be rotated | |
* and return the minimum value. | |
*/ | |
let getMin = (x, y) => { return x <= y ? x : y; } | |
let getMid = (l, h) => { return parseInt((l + h)/2, 10); } | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def reply(user_id, msg): | |
resp = requests.post("https://graph.facebook.com/v2.6/me/messages", | |
params={"access_token": fb_AT}, | |
data=json.dumps({ | |
"recipient": {"id": user_id}, | |
"message": {"text": msg} | |
}), | |
headers={'Content-type': 'application/json'}) |
OlderNewer