Skip to content

Instantly share code, notes, and snippets.

from moviepy.editor import *
from moviepy import *
video = VideoFileClip(r"[MYFILE]").subclip(50,60)
# Make the text. Many more options are available.
txt_clip = ( TextClip("My Holidays 2013",fontsize=70,color='white')
.set_position('center')
.set_duration(10) )
@Zulko
Zulko / cube_solver.py
Created December 26, 2019 20:12
A cube puzzle resolution script
import numpy as np
segments_lengths = [3, 2, 2, 2, 1, 1, 1, 2, 2, 1, 1, 2, 1, 2, 1, 1, 2]
assert sum(segments_lengths) == 27
def solve(cube, position, direction, segment_number):
if segment_number == len(segments_lengths):
return cube
x, y, z = direction
a1, a2 = np.array([y, z, x]), np.array([z, x, y])
@Zulko
Zulko / matplotlib_axes_from_gridspec_array.py
Created April 25, 2019 16:39
Get complex matplotlib layouts by generating gridspac from a "layout array"
import numpy as np
from matplotlib.gridspec import GridSpec
def matplotlib_gridspecs_from_array(arr):
arr = np.array(arr)
h, w = arr.shape
values_in_arr = sorted(set(arr.flatten()))
result = []
grid = GridSpec(h, w)
for v in values_in_arr:
import dnachisel as dc
def make_random_restriction_part(part_length, left_overhang, right_overhang,
enzyme, forbidden_enzymes,
assembly_enzyme='BsmBI'):
"""Create a random sequence with just a single wanted restriction
site in the middle, no forbidden enzyme site, and flanked by BsmBI
sites."""
l_left = len(left_overhang)
l_right = len(right_overhang)
<!-- saved from url=(0044)http://roughjs.com/examples/sampler-svg.html -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>RoughJS SVG sample</title>
<script src="./sample_files/rough.min.js"></script>
<style>
svg {
display: block;
width: 800px;
height: 600px;
import json
def schema(json_object):
if hasattr(json_object, 'items'):
result = {}
for k, v in json_object.items():
if hasattr(v, 'items'):
result[k] = schema(v)
elif isinstance(v, list):
result[k] = [schema(v[0]), '...']
@Zulko
Zulko / dna_chisel_animation.py
Created May 9, 2018 10:48
Makes a GIF showing DNA Chisel's algorithm in action
# Warning: quick and dirty code.
import dnachisel as dc
import proglog
proglog.notebook()
import matplotlib.pyplot as plt
from dna_features_viewer import BiopythonTranslator, GraphicFeature
counter = [0]
@Zulko
Zulko / draw_with_circles.py
Created April 26, 2018 19:30
Draw any picture with plain circles
import gizeh as gz
from PIL import Image
import numpy as np
def draw_with_circles(image_path, min_r=2, max_r=10, skew=0.2,
padding=0.5, bg_color=(1, 1, 1),
draw_bg_color=False,
pdf_path=None, png_path=None):
image = np.array(Image.open(image_path)) / 255.0
@Zulko
Zulko / tests.md
Last active March 17, 2018 22:12
some tests
We couldn’t find that file to show.
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -a -q)