Skip to content

Instantly share code, notes, and snippets.

''' Shows a couple of ideas around coroutines for event handling.
'''
import asyncio
from asyncio import sleep, ensure_future, Future
import os
os.environ['KIVY_EVENTLOOP'] = 'async'
'''async needs to be set so that asyncio will be used for the event loop. '''
from kivy.app import App
@akloster
akloster / caption_tool.sh
Created March 31, 2017 17:24
Caption Tool Bash Script
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
echo $DIR
@akloster
akloster / make_caption_part3.py
Created March 31, 2017 17:19
create an image caption in blender python part 3
# Open template .blend
path = os.path.dirname(__file__)
template_path="/"+os.path.join(path,"blends",template+".blend")
if not os.path.exists(template_path):
print(prog_name + "could not find this template file: '%s'" % template_path)
sys.exit(1)
bpy.ops.wm.open_mainfile(filepath=template_path)
# Change text
@akloster
akloster / make_caption_part2.py
Created March 31, 2017 17:17
create an image caption in blender python part 2
# Parse arguments
arguments = sys.argv[sys.argv.index("--")+1:]
parser = argparse.ArgumentParser(description="Create captions")
parser.add_argument('--template')
parser.add_argument('--text')
parser.add_argument('--output')
args = parser.parse_args(arguments)
text = args.text
output = args.output
@akloster
akloster / make_caption_part1.py
Created March 31, 2017 17:14
create an image caption in blender python part 1
import os
import sys
import argparse
try:
import bpy
except ImportError:
print("Module 'bpy' could not be imported. This probably means you are not using Blender to run this script.")
sys.exit(1)
@akloster
akloster / make_caption_part1.py
Last active March 31, 2017 17:13
create an image caption in blender python
import os
import sys
import argparse
try:
import bpy
except ImportError:
print("Module 'bpy' could not be imported. This probably means you are not using Blender to run this script.")
sys.exit(1)
@akloster
akloster / screw_all.py
Last active December 24, 2015 14:49
Script to download all "complete" bacterial genomes from NCBI and prepare GC skew plots from them.
# -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>
# <codecell>
from numpy import *
from pandas import *
from scipy.signal import argrelextrema