Skip to content

Instantly share code, notes, and snippets.

John Carrell saintsGrad15

Block or report user

Report or block saintsGrad15

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@saintsGrad15
saintsGrad15 / verticallCenter.css
Created Jun 11, 2019
Vertically Center an Element
View verticallCenter.css
vertical-align: top;
position: relative;
top: 50%;
transform: translateY(-50%);
@saintsGrad15
saintsGrad15 / client_secrets.json
Last active May 30, 2019
Basic Flask application using IBMid SSO
View client_secrets.json
client_secrets = {
"web": {
"auth_uri": "<Retrieve from IBMid registration>",
"client_id": "<your_client_id>",
"client_secret": "<your_client_secret>",
"token_uri": "<Retrieve from IBMid registration>",
"token_introspection_uri": "<Retrieve from IBMid registration>",
"issuer": "<Retrieve from IBMid registration>"
}
}
@saintsGrad15
saintsGrad15 / ColorCycler.js
Created Apr 9, 2019
A class that will cycle through a range of colors according to an internal map of "items" to "hsl" color values.
View ColorCycler.js
class ColorCycler
{
/**
* A class that will return a CSS-valid "hsl()" string, assigned to distinct items.
*
* An internal mapping of "items" (any valid Object key) to "hsl()" strings.
* If a color is requested for an existing item, the existing color is returned.
* If a color is requested for a non-existing item, a new color is generated, stored for future use and returned.
*
* When a new color is generated the "hue" value is rotated (0 - 360).
@saintsGrad15
saintsGrad15 / DefaultList.py
Created Feb 1, 2019
A simple list implementation that yields None or a defined default if an out-of-bounds index is referenced.
View DefaultList.py
class DefaultList(list):
def __init__(self, iterable=[], default=None):
super(self.__class__, self).__init__(iterable)
self.default = default
def __getitem__(self, index):
"""
If 'index' is outside of the bounds (including negative indexing) of the list,
return 'self.default.'
@saintsGrad15
saintsGrad15 / temporary_directory.py
Created Jan 18, 2019
A Class usabled directly or as a context manager that creates a temporary directory and enables its deletion.
View temporary_directory.py
class TemporaryDirectory(object):
"""
Produces a temporary directory on the system using tempfile.mkdtemp() under the hood.
Exposes a path attribute that will represent the path of the directory
until the instance has deleted the temporary directory.
TemporaryDirectory can be used as a context manager.
"""
View DEV Things to Remember
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
@saintsGrad15
saintsGrad15 / deleteBranch.bash
Created Oct 5, 2017
A function to delete a branch from git both locally and on the remote
View deleteBranch.bash
function deleteBranch()
{
git branch -d "$1"
if [ $? -ne 0 ]; then
echo "Trying with -D"
git branch -D "$1"
fi
if [ $? -ne 0 ]; then
@saintsGrad15
saintsGrad15 / newBranch.bash
Created Oct 5, 2017
A function to create a new git branch and set its upstream repo
View newBranch.bash
function newBranch()
{
git checkout -b "$1"
if [ $? -eq 0 ]; then
git push -u
fi
}
@saintsGrad15
saintsGrad15 / addAlias.bash
Created Oct 5, 2017
A function to add an alias declaration to ~/.bash_profile
View addAlias.bash
function addAlias()
{
echo "alias $1='$2'" >> ~/.bash_profile
. ~/.bash_profile #reload .bash_profile
}
@saintsGrad15
saintsGrad15 / decorator_reporter.py
Created Oct 3, 2017
A decorator function that will "report."
View decorator_reporter.py
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.
You can’t perform that action at this time.