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
/** | |
* Takes a decimal value and changes it by the specified percentage (based off of the distance | |
* from 0 or 255, depending on whether the percentage change is negative or positive, respectively) | |
* @param {Number} value - number from [0, 255] | |
* @param {Number} percent - number from [0.0, 1.0] | |
* @return {Number} - number from [0, 255] | |
*/ | |
function updateValue(value, percent) { | |
// Absolute distance from reference value | |
var distance = percent > 0 ? (255 - value) : 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
/** | |
* Expand a string using a supplied regex to denote the properties and a | |
* possibly nested object to supply the values. | |
* | |
* inputString - The string to be formatted. | |
* valuesObject - An Object holding either values stored as strings or other Objects | |
* nestSeparator - The marker used to indicated a nested property | |
* propRegex - Regex used to indicate the property in the inputString. Assumes the actual | |
* key value will be indicated by using (). | |
* |
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
// Rotate an array to right by n. | |
function rotate(a, n) { | |
// Convert negative to positive. | |
if (n < 0) n = ((n % a.length) + a.length); | |
n = n % a.length; | |
reverse(a, 0, a.length); // Move to bottom to reverse to the left. | |
reverse(a, 0, n); | |
reverse(a, n, a.length); | |
} |
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 choice | |
''' | |
Some quick code to try out applying Q-Learning to Nim game in Python. | |
''' | |
def get_best_action(q, s): | |
''' | |
Given the q table and state, | |
pick the best action. | |
''' |
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
@echo off | |
REM Dependency: | |
REM SoX: http://sox.sourceforge.net/ | |
mkdir converted_wav | |
for %%f in (*.aiff) do ( | |
"C:\Program Files (x86)\sox-14-4-1\sox" %%~nf.aiff "converted_wav/%%~nf.wav" | |
) | |
pause |
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
# Dependency: | |
# sudo apt-get install librsvg2-bin | |
find . -type f -name "*.svg" -exec bash -c 'rsvg-convert -f pdf -o $0.pdf $0' {} \; |