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
type Coord = (Float, Float) | |
type Node = { label : String | |
, coord : Coord | |
} | |
type Edge = { color : Int | |
, n1 : Node | |
, n2 : Node | |
} |
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
# coding: utf-8 | |
# | |
# This is the Python/MoviePy code used to generate | |
# this video of me playing the Turkish March on my | |
# computer's keyboard. Enjoy ! | |
# | |
# https://www.youtube.com/watch?v=z410eauCnHc | |
# |
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
''' | |
Rewrite with Twittcher ;) | |
Result (every 20 seconds): | |
>>> Most common words: [('ferguson', 41), ('http', 28), ('protests', 9), | |
('missouri', 9), ('leave', 8), ('continue', 8),...] | |
''' | |
import re | |
from collections import Counter | |
from twittcher import SearchWatcher |
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
""" | |
Conformal animations with MoviePy and Scikit Image, after user u/spel3o on Reddit. | |
Links: | |
Reddit discussion: | |
http://www.reddit.com/r/math/comments/2o9wge/conformal_image_map_animation_of_1z_to/ | |
Original gif: | |
https://i.imgur.com/2W5dCvF.gif |
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
Show hidden characters
{ | |
"cmd": ["erd", "-i", "$file", "-o", "__build__.png"], | |
"path": "/usr/bin:/usr/local/bin" | |
} |
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 script checks the time accuracy of MoviePy. | |
First, a one-hour video is generated, where the frame | |
at time t displays t (in seconds, e.g. '1200.50') in white | |
on a black baground. | |
Then we ask MoviePy to open this video file, fetch | |
different times (1200.5, 850.2, 2000.3, 150.25, 150.25), | |
extract the corresponding frame as a JPEG image file, and |
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
""" | |
Transform the "static/some/file" of a HTML page | |
into Django-compatible {% static "some/file" %} | |
""" | |
import re | |
source = "some/template.html" | |
target = "new_template.html" | |
with open(source, "r") as f: |
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 mpl_toolkits.axes_grid.inset_locator import inset_axes | |
def place_inset_ax_in_data_coordinates(ax, bbox): | |
"""Return an ax inset in the given ax at the given bbox in | |
data coordinates (bottom, left, width, height)""" | |
bottom, left, width, height = bbox | |
pixels_data_00 = ax.transData.transform([0,0]) | |
pixels_data_11 = ax.transData.transform([1,1]) | |
iwidth, iheight = (pixels_data_11 - pixels_data_00) / ax.figure.dpi | |
return inset_locator.inset_axes( |
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
import urllib | |
import time | |
from Bio import Restriction | |
from bs4 import BeautifulSoup | |
from tqdm import tqdm | |
import pandas | |
def get_neb_soup(endpoint): | |
with urllib.request.urlopen("https://www.neb.com" + endpoint) as response: |
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
""" | |
Code for a music video where sheet music is | |
scrolled transparently on my hands playing the | |
piano. See that effect here: | |
https://www.youtube.com/watch?v=V2XCJNZjm4w | |
""" | |
from moviepy.editor import * |
OlderNewer