Skip to content

Instantly share code, notes, and snippets.

@f00lin
f00lin / extension.sh
Last active August 29, 2015 14:06
Add file extension to all files in a folder
for f in *; do;
mv "$f" "${f}.png";
done
@f00lin
f00lin / roulette-wheel.py
Last active August 29, 2015 14:06
roulette wheel selection function
# selects a single genome proportionally based on its fitness using a
# roulette wheel-style selection procedure
def select_parents(src_pop):
# pick random number between 0 and total fitness
ran = random.uniform(0.0, total_fitness(src_pop))
# set a counter
count = 0
for i in src_pop:
# add fitness total from [3] position to counter
@f00lin
f00lin / normalize.py
Created September 16, 2014 15:41
normalizes a set of probabilities by making them sum to 1
def normalize(lst):
norm = []
tot = sum(lst)
for i in lst:
temp = ((i*100)/tot)/100
norm.append(temp*1)
return norm
@f00lin
f00lin / duplicates
Last active August 29, 2015 14:06
regular expression find duplicate words
\b(\w+)\s+\1\b
@f00lin
f00lin / tabtext.html
Created September 16, 2014 10:02
creates a basic editor in a browser window
data:text/html;charset=utf-8, <title>TextEditor</title><body contenteditable style="font-size:1rem;font-family:monaco;line-height:1.4;max-width:60rem;margin:0 auto;padding:4rem;" spellcheck="true">
@f00lin
f00lin / manifest.json
Last active August 29, 2015 14:06
chrome hosted app sample manifest
{
"name": "App Name",
"description": "App description",
"version": "App Version",
"manifest_version": 2,
"icons": {
"128": "Large Icon File",
"16": "Small Icon File"
},
"app": {
@f00lin
f00lin / cover.html
Last active August 29, 2015 14:06
epub cover code that adjusts to screen size
<div>
<svg xmlns="http://www.w3.org/2000/svg" height="100%" preserveAspectRatio="xMidYMid meet" version="1.1" viewBox="0 0 600 800" width="100%" xmlns:xlink="http://www.w3.org/1999/xlink">
<image height="800" width="600" xlink:href="../Images/name.jpg"></image>
</svg>
</div>