This file contains hidden or 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
| Python | |
| - A directory that contains a __main__.py file can be executed directly by the python interpreter | |
| - If that directory contains a __init__.py file it can be executed as a module. | |
| - If using MatPlotLib you might receive a "Python was not installed as a framework..." error. | |
| - Create a file `~/.matplotlib/matplotlibrc` and populate it with `backend: TkAgg` to solve the problem. | |
| - Why? Who fuckin knows? | |
| Jupyter | |
| - When installing a Javascript Jupyter kernel following the following page: | |
| - https://github.com/n-riesco/ijavascript |
This file contains hidden or 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
| function deleteBranch() | |
| { | |
| git branch -d "$1" | |
| if [ $? -ne 0 ]; then | |
| echo "Trying with -D" | |
| git branch -D "$1" | |
| fi | |
| if [ $? -ne 0 ]; then |
This file contains hidden or 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
| function newBranch() | |
| { | |
| git checkout -b "$1" | |
| if [ $? -eq 0 ]; then | |
| git push -u | |
| fi | |
| } |
This file contains hidden or 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
| function addAlias() | |
| { | |
| echo "alias $1='$2'" >> ~/.bash_profile | |
| . ~/.bash_profile #reload .bash_profile | |
| } |
This file contains hidden or 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 decorator_reporter(report_string="Running...", period=1, reporting_function=None): | |
| """ | |
| A decorator function that will "report." | |
| This function returns 'function_wrapper.' | |
| :param report_string: The string to "report." | |
| :param period: The number of seconds between reports. | |
| :param reporting_function: The reporting function to use instead of 'print.' | |
| This could be a logging function like 'logging.debug' for instance. | |
| This must be capable of taking no more than one string argument. |
This file contains hidden or 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
| class Reporter(Heartbeater): | |
| """ | |
| Behaves like a Heartbeater but specifically designed to print statements periodically. | |
| """ | |
| def __init__(self, report_string, period=1, reporting_function=None): | |
| """ | |
| Every 'period' seconds 'report_string' will be passed to 'reporting_function.' | |
| If 'reporting_function' is None it will print 'report_string' instead. |
This file contains hidden or 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
| class Compose(object): | |
| """ | |
| Return a function that, when called, will execute each function in 'functions' | |
| in order, passing the return value of each to the next one | |
| and returning the result of the last one. | |
| NOTE: Generator functions cannot be used. | |
| :param functions: A list of functions. | |
| NOTE: Ensure that the output of one function makes sense | |
| as an input to the next function. A list of values can be |
This file contains hidden or 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
| function compose(...funcs) | |
| { | |
| function _compose(...args) | |
| { | |
| let result = args; | |
| for (func of funcs) | |
| { | |
| if ( !Array.isArray(result) ) | |
| result = [result]; | |
This file contains hidden or 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
| function getObjectValueFromDottedNotation(object, dottedString) | |
| { | |
| /* | |
| * Given an object 'object' and a string 'dottedString' that contains a dot-delimited path | |
| * down the object's members, return the value at that path or false if the entire path does not exist. | |
| * | |
| * For example: | |
| * obj = { | |
| * "person": { | |
| * "name": "john", |
This file contains hidden or 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
| from threading import Thread | |
| from time import sleep | |
| class Heartbeater(Thread): | |
| """ | |
| A class that adheres to the Thread and Context Manager interfaces. | |
| """ | |
| def __init__(self, work=None, work_args=None, work_kwargs=None, period=1, daemon=False): | |
| """ |