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
# REQUIRES PACKAGES Numpy AND Scipy INSTALLED | |
import numpy as np | |
import scipy.integrate | |
import scipy.interpolate | |
class ddeVar: | |
""" special function-like variables for the integration of DDEs """ | |
def __init__(self,g,tc=0): | |
""" g(t) = expression of Y(t) for t<tc """ |
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 is a function to merge several nodes into one in a Networkx graph | |
def merge_nodes(G,nodes, new_node, attr_dict=None, **attr): | |
""" | |
Merges the selected `nodes` of the graph G into one `new_node`, | |
meaning that all the edges that pointed to or from one of these | |
`nodes` will point to or from the `new_node`. | |
attr_dict and **attr are defined as in `G.add_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
import matplotlib.pyplot as plt | |
import numpy as np | |
def graph_editor(grid=True, grid_N = 12): | |
""" | |
This function enables to draw a graph manually using | |
Matplotlib's interactive plotting capabilites. | |
In a first phase you are asked to place the nodes | |
(left-click to place a node, right-click to remove |
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 * |
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
# | |
# This Python script makes a summary of a football game by cutting | |
# the video around the 10 % loudest moments, which generally | |
# include the goals and other important events. | |
# For more details, see this blog post: | |
# http://zulko.github.io/blog/2014/07/04/automatic-soccer-highlights-compilations-with-python/ | |
# | |
# LICENCE: Creative Commons 0 - Public Domain | |
# I, the author of this script, wave any rights and place this work in the public domain. | |
# |
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
import numpy as np | |
def supersample(clip, d, nframes): | |
""" Replaces each frame at time t by the mean of `nframes` equally spaced frames | |
taken in the interval [t-d, t+d]. This results in motion blur.""" | |
def fl(gf, t): | |
tt = np.linspace(t-d, t+d, nframes) | |
avg = np.mean(1.0*np.array([gf(t_) for t_ in tt]),axis=0) | |
return avg.astype("uint8") | |
return clip.fl(fl) |
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
# Result: http://i.imgur.com/Lmj21mR.gif | |
import moviepy.editor as mpy | |
from moviepy.video.tools.drawing import color_split | |
# LOAD THE GIF SEVERAL TIMES | |
clip = VideoFileClip("./source.gif") | |
W,H = SIZE = clip.size | |
duration = clip.duration |
OlderNewer