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
#!python3 | |
""" | |
A simple script which converts all the images in | |
the folder it is run from into a single image. | |
Images should be in a directory <searchDir>, with | |
the tiles binned into folders based on their | |
Y-axis identity, named as their X-axis identity. | |
In other words, they should be folders of rows | |
containing column-items for that row of images. |
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
#!python3 | |
import numpy as np | |
from typing import Union | |
def smooth(inputSignal:Union[list, np.ndarray], windowLength:int= 11, window:str= 'flat') -> np.ndarray: | |
""" | |
Smooth the data using a window with requested size. | |
This method is based on the convolution of a scaled window with the signal. | |
The signal is prepared by introducing reflected copies of the signal |
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
#!python3 | |
""" | |
Convert a requirements.txt file to a Poetry project. | |
Just place in the root of your working directory and run! | |
""" | |
sourceFile = "./requirements.txt" | |
import re | |
import os |
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
######### | |
# Casting Helper | |
######### | |
def isSimpleIterable(thing) -> bool: | |
""" | |
Check if the thing is a basic iterable type | |
""" | |
return isinstance(thing, (list, set, tuple, frozenset)) |
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
function file_get_contents_curl($url) { | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE); | |
curl_setopt($ch, CURLOPT_HEADER, 0); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); | |
# Actual fetch | |
$data = curl_exec($ch); |
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
#!python3 | |
""" | |
@author Philip Kahn | |
@license MIT | |
""" | |
def getBarebonesAddress(dirtyAddress): | |
""" | |
Will take most forms of addresses, and return an address of form |
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
#!python3 | |
def baseN(num, b, numerals="0123456789abcdefghijklmnopqrstuvwxyz"): | |
""" | |
Convert a number to an arbitrary base | |
Parameters | |
---------------- | |
num: int, float | |
A numeric non-complex value |
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
String::noExponents = (explicitNum = true) -> | |
### | |
# Remove scientific notation from a number | |
# | |
# After | |
# http://stackoverflow.com/a/18719988/1877527 | |
### | |
data = @.split /[eE]/ | |
if data.length is 1 | |
return data[0] |
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
### | |
# This was created as part of an attempt to handle well-formatted but regular URL input from the client | |
# | |
# In my specific use case, it was just fetching license URLs so it frankly just needed to work for | |
# Creative Commons, GPL, MIT, and other common license URLS | |
# | |
# Longer, more robust patterns like | |
# https://gist.github.com/gruber/8891611 | |
# | |
# Were proving fussy when integrating a pattern with <paper-input> |
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/bash | |
find . -type f -iregex .*\.html$ | while read line | |
do | |
printf 'Converting >>>%s<<<\n' "$line" | |
P_MD=${line%".html"}.markdown | |
pandoc --ignore-args -r html -w markdown < "${line}" | awk 'NR > 130' | sed '/<div class="site-info">/,$d' > "${P_MD}" | |
done |