Skip to content

Instantly share code, notes, and snippets.

View bendmorris's full-sized avatar

Ben Morris bendmorris

View GitHub Profile
@bendmorris
bendmorris / gist:5076354
Last active December 14, 2015 10:59
Part of the Bininda-Emonds mammal tree, with inner nodes labelled for higher taxa
This is a taxonomy, which contains information on higher taxa for each species (genus, family, order, etc.)
____________________ Pan paniscus
________________Pan_|
| |____________________ Pan troglodytes
_____________________|
Hominidae |________________Gorilla__________________ Gorilla gorilla
|
|________________Homo_____________________ Homo sapiens
@bendmorris
bendmorris / AssetData.hx
Last active December 23, 2015 05:49
nme/AssetData.hx: needed for openfl asset embedding when running headless and compiling without openfl
package nme;
import sys.FileSystem;
import openfl.Assets;
enum LibraryType {
@bendmorris
bendmorris / potrace
Last active August 1, 2024 12:23
Potrace script designed for making FontForge pixel fonts
#!/bin/bash
# To use, move the potrace binary to potrace-bin, then place this script
# somewhere on the path so that it'll be found by fontforge.
# After autotracing, you'll need to apply the following transformation:
# scale uniform 10%, using glyph origin as the origin
# get the last parameter passed by fontforge - the name of the temp img file
for last; do true; done
# get all of the other parameters
length=$(($#-1))
@bendmorris
bendmorris / gist:7534559
Created November 18, 2013 20:15
PhyloCommons web API use
import urllib2
my_query_url = 'http://phylocommons.org/query/prune=True&format=newick&taxa=Homo+sapiens%2CGorilla+gorilla%2CPan+paniscus%2CPan+troglodytes&tree=bininda-emonds_mammals'
result = urllib2.urlopen(my_query_url)
tree = result.read()
print tree
# ((('Pan paniscus':3.90000,'Pan troglodytes':3.90000)Pan:5.80000,'Homo sapiens':9.70000):3.00000,'Gorilla gorilla':12.70000)Homininae:7.00000;
@bendmorris
bendmorris / float_test.py
Created January 26, 2014 16:52
Testing whether Python's json module correctly outputs floating point numbers without loss of precision
import random
import json
digits = '0123456789'
for i in range(10000):
ndigits = 10
number = '0.' + ''.join([random.choice(digits) for j in range(ndigits)])
number = number.rstrip('0')
if number.endswith('.'): number += '0'
json_number = json.dumps(float(number))
@bendmorris
bendmorris / gist:2f3013c32fd2c6baccf4
Created December 27, 2014 20:49
Count # of files and total lines by file type, in all git repos starting from the current directory
#!/bin/bash
DIR=$(pwd)
REPOS=$(find . -type d -name .git)
echo "-- Directory: " $DIR
echo "-- Repos: " $REPOS
for i in hx py xml; do
echo $i
@bendmorris
bendmorris / MapArray.hx
Last active August 29, 2015 14:19
MapArray - array with linked hashmap for fast existence/position lookups
class MapArray<T>
{
public static function main()
{
var x = new MapArray<Int>(new Map<Int, Int>());
for (i in 1 ... 100001)
x.push(i);
x.remove(5002);
@bendmorris
bendmorris / gist:5219affdd32efc08eedc
Created August 11, 2015 03:40
Replace member in Graphiclist (HaxePunk)
function replace(graphicList:Graphiclist, search:Graphic, replace:Graphic) {
var children = graphicList.children;
var index = children.indexOf(search);
if (index > -1) {
children[index] = replace;
}
}
@bendmorris
bendmorris / Flx9SliceSprite.hx
Created September 4, 2016 16:29
Flx9SliceSprite, which simply moves and scales 9 other FlxSprites
package flixel;
import flixel.FlxSprite;
import flixel.graphics.FlxGraphic;
import flixel.graphics.frames.FlxImageFrame;
import flixel.math.FlxPoint;
import flixel.math.FlxRect;
import flixel.system.FlxAssets;
import flixel.util.FlxColor;
@bendmorris
bendmorris / Dockerfile
Last active February 23, 2018 17:22
try-haxe Dockerfile
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y haxe php7.0 apache2 libapache2-mod-php7.0
RUN mkdir -p /var/www/try-haxe
RUN a2enmod php7.0
RUN a2enmod rewrite
COPY try-haxe.conf /etc/apache2/sites-enabled/000-default.conf
EXPOSE 80