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
(notice space at the end of each!) | |
Find: ([a-zA-Z]+)='(.+)' | |
Replace with: \1="\2" | |
Fixes any single quote ids/classes/html attributes (eg. name='foo-bar' -> name="foo-bar", name='{{ foo._bar(bim) }}' -> name="{{ foo._bar(bim) }}") |
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
# Fallback for this issue, when using | |
# http://www.sublimetext.com/docs/3/osx_command_line.html and https://help.github.com/articles/associating-text-editors-with-git/ | |
# `subl -n -w: subl: command not found` | |
# `error: There was a problem with the editor 'subl -n -w'.` | |
# `Please supply the message using either -m or -F option.` | |
git config --global core.editor "subl -n -w" || git config --global core.editor "~/bin/subl -n -w" |
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
A visualization of perhaps the most inefficient algorithm - the recursive Levenshtein distance. | |
ks | |
ksi | | |
ksit ___/ | |
ksitt ____/ | |
ksitti _____/ | |
ksittin ______/ | |
ksitting _______/ |
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
Better recursion tree visualization | |
\____cd | |
cdo___/ | |
cdog____/ | |
cdoge_____/ | |
\____cd | |
cdo___/ | |
cdog____/ | |
\____cd |
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 agFileSearch() { | |
ag "$1" -l | xargs open | |
} | |
alias agfiles='agFileSearch' | |
# .. usage: | |
# agfiles 'mytext' |
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 checkVisibility(color1, color2) { | |
// http://www.w3.org/TR/AERT#color-contrast | |
// Color brightness is determined by the following formula: | |
// ((Red value X 299) + (Green value X 587) + (Blue value X 114)) / 1000 | |
// Note: This algorithm is taken from a formula for converting RGB values to | |
// YIQ values. This brightness value gives a perceived brightness for a color. |
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
from namebot import techniques as nb | |
from random_words import RandomWords | |
# https://pypi.python.org/pypi/RandomWords/0.1.5 | |
rw = RandomWords() | |
# https://github.com/Automotron/namebot | |
test = rw.random_words(count=10) | |
print(nb.make_portmanteau_default_vowel(test)) |
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
# https://en.wikipedia.org/wiki/Catalan_number | |
import math | |
prod = 1 | |
for n in range(2, 100): | |
prod = math.factorial((2 * n)) // ( | |
math.factorial((n + 1)) * math.factorial(n)) | |
print(prod) |
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
https://github.com/christabor/MoAL/blob/master/MOAL/maths/applied/computational/cryptography/ciphers/historical/transposition/railfence.py | |
Encoded with 2 rows: IAEVRBGERTHVAEYISCE | |
I . V . V . Y . G . C . T | |
H . E . E . B . S . R | |
A . A . R . I . E . E | |
Encoded with 3 rows: IVVYGCTHEEBSRAARIEE | |
I . E . R . G . R |
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
from random import randrange as rr | |
# Use with: http://mlpy.sourceforge.net/docs/3.5/dtw.html#id3 | |
def random_timesequence(start, end, steps=3): | |
seq = [] | |
for n in range(start, end): | |
# Randomize the number of sub-steps, | |
# but maintain the bounds and monotonicity |