Skip to content

Instantly share code, notes, and snippets.

@Zulko
Zulko / testelm.elm
Last active August 29, 2015 14:01
Tests for elm
type Coord = (Float, Float)
type Node = { label : String
, coord : Coord
}
type Edge = { color : Int
, n1 : Node
, n2 : Node
}
@Zulko
Zulko / turkish_march_video.py
Created June 9, 2014 06:07
The Turkish March on a computer keyboard - source code of the video editing
# 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
#
@Zulko
Zulko / analyze.py
Last active August 29, 2015 14:05 — forked from seanmckaybeck/analyze.py
'''
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
@Zulko
Zulko / conformal_falling.py
Last active August 29, 2015 14:10
Animation with complex tranformation 1/Z - t
"""
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
@Zulko
Zulko / erd.sublime-build
Created October 2, 2015 10:43
Sublime file to build erd diagrams (at least on Macs)
{
"cmd": ["erd", "-i", "$file", "-o", "__build__.png"],
"path": "/usr/bin:/usr/local/bin"
}
@Zulko
Zulko / moviepy_time_accuracy.py
Created November 13, 2014 15:55
Checking MoviePy's time accuracy
"""
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
@Zulko
Zulko / static_to_django.py
Last active September 9, 2016 17:29
Transform the "static/some/file" of a HTML page into Django-compatible {% static "some/file" %}
"""
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:
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(
@Zulko
Zulko / nebscraper.py
Created November 21, 2016 14:54
Goes through the NEB website and compiles all enzymes prices into one spreadsheet
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:
@Zulko
Zulko / limehouse_nights_moviepy.py
Last active September 14, 2017 20:37
Source for my music video on Gershwin's Limehouse Nights
"""
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 *