Skip to content

Instantly share code, notes, and snippets.

😀
😃

Zulko

😀
😃
Block or report user

Report or block Zulko

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Zulko
Zulko / matplotlib_axes_from_gridspec_array.py
Created Apr 25, 2019
Get complex matplotlib layouts by generating gridspac from a "layout array"
View matplotlib_axes_from_gridspec_array.py
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:
View make_random_restriction_part.py
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)
View rough-tests.html
<!-- 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;
View json_xml_simple_schema.py
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
Makes a GIF showing DNA Chisel's algorithm in action
View dna_chisel_animation.py
# 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 Apr 26, 2018
Draw any picture with plain circles
View draw_with_circles.py
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 Mar 17, 2018
some tests
We couldn’t find that file to show.
View docker-clean.sh
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -a -q)
@Zulko
Zulko / python_mermaid_class_tree.py
Created Apr 18, 2017
Automatic Python module class tree generation, using Mermaid for rendering
View python_mermaid_class_tree.py
import inspect
def class_name(cls):
"""Return a string representing the class"""
# NOTE: can be changed to str(class) for more complete class info
return cls.__name__
def classes_tree(module, base_module=None):
if base_module is None:
base_module == module.__name__
View text_clip_with_gizeh.py
"""
An alternative text clip for Moviepy, relying on Gizeh instead of ImageMagick
Advantages:
- Super fast (20x faster)
- no need to install imagemagick
- full-vector graphic, no aliasing problems
- Easier font names
Disadvantages:
You can’t perform that action at this time.