float rand(float n){return fract(sin(n) * 43758.5453123);}
float noise(float p){
float fl = floor(p);
float fc = fract(p);
return mix(rand(fl), rand(fl + 1.0), fc);
}
This file contains hidden or 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
def shift_loss_fn(x): | |
return x_tile_scale * tf.reduce_sum(tf.square(x)) / float(width) / float(height) | |
x_tile_loss_layer = keras.layers.Lambda( | |
shift_loss_fn, | |
output_shape=lambda input_shape: [1] | |
) | |
x_tile_difference = keras.layers.add([pyramid_model.outputs[0], x_tile_shifter(pyramid_model.outputs[0])]) | |
This file contains hidden or 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 bs4 import BeautifulSoup | |
import requests | |
url = "https://leapmanifesto.org/en/whos-on-board/" | |
soup = BeautifulSoup(requests.get(url).text) | |
signatories = {} | |
for signatory_container in soup.find_all("div", class_="section-wrap signatories"): |
This file contains hidden or 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
'use strict'; | |
function convolve(arr, vs, size, x, y) { | |
const hl = parseInt(arr.length / 2); | |
return arr.map((row, offY)=>row.map((m, offX)=>vs[indexOf(x + offX - hl, y + offY - hl, size)] * m)) | |
} | |
function position(index, size) { | |
return [Math.floor(index % size), Math.floor(index / size)] | |
} |
This file contains hidden or 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
import sys | |
def is_valid(p): | |
# words must be at least 3 characters | |
padded = '1' + p + '1' | |
return "101" not in padded and "1001" not in padded | |
def groups(size): | |
current = "" |
This file contains hidden or 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
import turtle | |
import math | |
MIN_X = -math.pi * 2 | |
MIN_Y = -2 | |
MAX_X = math.pi * 2 | |
MAX_Y = 2 | |
TURTLE_STEP = 0.1 | |
This file contains hidden or 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
import turtle | |
import math | |
turtle.clear() | |
turtle.setposition(0, 0) | |
turtle.speed("fastest") | |
for i in range(500): | |
turtle.left(math.sin(i / (2*math.pi)) * (180 / math.pi)) | |
turtle.forward(math.sqrt(i)) |
This file contains hidden or 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 nltk.corpus import cmudict | |
def char_range(c1, c2): | |
for c in xrange(ord(c1), ord(c2)+1): | |
yield chr(c) | |
candidates = [e for e in cmudict.entries() if e[0][0].lower() != e[1][0][0].lower()] | |
separated = {} | |
for l in char_range('a', 'z'): | |
separated[l] = [e for e in candidates if e[0][0].lower() == l] |
This file contains hidden or 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
def dragon_generator(): | |
count = 0 | |
fold_index = 0 | |
curve = [] | |
while True: | |
fold_index -= 1 | |
count += 1 | |
if fold_index < 0: | |
fold_index = count - 1 |
This file contains hidden or 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
import requests | |
import simplejson | |
def getactors(): | |
baseurl = 'http://en.wikipedia.org/w/api.php?cmtitle=Category:American_film_actors&action=query&list=categorymembers&cmlimit=500&cmprop=title|sortkey|timestamp&format=json' | |
results = [] | |
cont = "" | |
while True: | |
r = requests.get(baseurl + cont) |
NewerOlder