Skip to content

Instantly share code, notes, and snippets.

View iansan5653's full-sized avatar

Ian Sanders iansan5653

View GitHub Profile
@iansan5653
iansan5653 / readme.md
Last active July 12, 2018 16:02
USF Colored Slack Sidebar Themes

These sidebar themes for Slack were created with the USF Colors in mind. To use them, on desktop, go to Prefences -> Sidebar and then paste the values into the Custom Theme box. Alternatively, you should be able to paste them into any channel and a button to apply the theme will appear.

Dark Green and Gold

#006747,#009374,#cfc493,#444444,#009374,#f6f6f6,#9ccb3b,#db6668

Light Gray and Green

#f9f9f9,#d9d9d9,#006747,#ffffff,#d9d9d9,#383838,#9ccb3b,#c75b5d
@iansan5653
iansan5653 / templateLiteralTagGenerator.js
Last active July 25, 2018 18:09
Template literal tag function generator
/**
* @file generateTemplateLiteralTag gist.
* @author Ian Sanders <iansan5653@gmail.com>
* @license
* Public Domain - Attribution is nice but not at all required. Feel free to do
* anything with this code.
*/
/**
* Generate a template literal tag that simply applies the given function on
@iansan5653
iansan5653 / closest_factors.py
Created October 24, 2018 14:58
Calculate the two closest factors of an integer in Python
def calc_closest_factors(c: int):
"""Calculate the closest two factors of c.
Returns:
[int, int]: The two factors of c that are closest; in other words, the
closest two integers for which a*b=c. If c is a perfect square, the
result will be [sqrt(c), sqrt(c)]; if c is a prime number, the result
will be [1, c]. The first number will always be the smallest, if they
are not equal.
<?xml version="1.0" ?>
<coverage branch-rate="0" branches-covered="0" branches-valid="0" complexity="0" line-rate="0.6792" lines-covered="1116" lines-valid="1643" timestamp="1548423375804" version="4.5.2">
<!-- Generated by coverage.py: https://coverage.readthedocs.io -->
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
<sources>
<source>{PATH}</source>
</sources>
<packages>
<package branch-rate="0" complexity="0" line-rate="0.4267" name=".">
<classes>
@iansan5653
iansan5653 / ansi-test.py
Last active January 4, 2024 14:56
ANSI Console Formatting Test File (Python)
"""Test ANSI formatting codes for console applications."""
print('\x1b[0m Reset / Normal \x1b[0m')
print('\x1b[1m Bold or increased intensity \x1b[0m')
print('\x1b[2m Faint (decreased intensity) \x1b[0m')
print('\x1b[3m Italic \x1b[0m')
print('\x1b[4m Underline \x1b[0m')
print('\x1b[5m Slow Blink \x1b[0m')
print('\x1b[6m Rapid Blink \x1b[0m')
print('\x1b[7m reverse video \x1b[0m')
@iansan5653
iansan5653 / suppress_logs.py
Last active June 14, 2019 18:15
Temporarily Disable Logging
import contextlib
import logging
@contextlib.contextmanager
def suppress_logs(logger: logging.Logger = logging.getLogger()):
"""Context manager to temporarily disable logs.
# Arguments
logger (logging.Logger): #logging.Logger object to disable. Defaults
to the root logger.
@iansan5653
iansan5653 / debounce.js
Created June 14, 2019 18:07
Debounce a function in JavaScript
/**
* Either returns a function that won't execute until it hasn't been called for
* `delay` milliseconds, or returns a function that will execute immediately but
* not again until it hasn't been called in `delay` milliseconds.
* @param {function(...any)} func The function to execute only once.
* @param {number} delay Number of milliseconds to wait after the last call
* before executing the function.
* @param {boolean} immediate If true, will execute immediately rather than
* waiting, but won't execute again until it hasn't been called in `delay` ms.
* @return {function(...any)} A function that, when called, will execute `func`
@iansan5653
iansan5653 / promise-parse.ts
Created July 17, 2019 13:33
Promisified csv-parse method
/**
* Promisified `parse()` from `csv-parse`.
* @param input The raw CSV data.
* @param options The options object to pass through to the `parse()` function.
* @returns Promise that resolves upon completion with an object containing the
* results and information about those results.
* @see {@link https://csv.js.org/parse/} For info about the options and info
* objects.
*/
export function promiseParse(
@iansan5653
iansan5653 / gulpfile.js
Created August 14, 2019 15:33
Configuration for packing electron app into a single exe file
/* eslint @typescript-eslint/no-var-requires: 0 */
const gulp = require("gulp");
const ts = require("gulp-typescript");
const clean = require("gulp-clean");
const replace = require("gulp-replace");
const tsProject = ts.createProject("tsconfig.json");
const paths = {
web: ["src/*.html", "src/*.css"]
@iansan5653
iansan5653 / media.ahk
Created August 16, 2019 18:08
AutoHotKey to map Windows media keys: scroll lock -> skip, pause/break -> pause/play.
sc046::Media_Next
Pause::Media_Play_Pause