Skip to content

Instantly share code, notes, and snippets.

tluyben /
Last active Sep 10, 2015 — forked from reusee/
Python to php translator, compile python script to php
import ast
from cStringIO import StringIO
import sys
INFSTR = '1e308'
def interleave(inter, f, seq):
seq = iter(seq)
tluyben / gist:4168379
Created Nov 29, 2012
JQuery enter as tab
View gist:4168379
$('input').live('keypress', function(eInner) {
if (eInner.keyCode == 13)
var el = null; // element to jump to
// if we have a tabindex, just jump to the next tabindex
var tabindex = $(this).attr('tabindex');
if (tabindex) {
tabindex ++;
tluyben / gist:4171243
Created Nov 29, 2012
Working Draw2d touch Bezier curve route
View gist:4171243
draw2d.layout.connection.NewBezierConnectionRouter = draw2d.layout.connection.ManhattanConnectionRouter.extend({
NAME : "draw2d.layout.connection.NewBezierConnectionRouter",
init : function()
this.cheapRouter = null;
this.iteration = 5;
route : function(conn)
tluyben / FeatureContext.php
Last active Oct 17, 2015
FeatureContext.php for Behat + Laravel 5 testing, fixed/improved from
View FeatureContext.php
use Behat\Behat\Context\ClosuredContextInterface;
use Behat\Behat\Context\TranslatedContextInterface;
use Behat\Behat\Context\Context;
use Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Illuminate\Routing\UrlGenerator;
use Behat\MinkExtension\Context\MinkContext;
tluyben /
Created Feb 4, 2013
iOS distribution; make an .ipa from an .app file.
mkdir Payload
mv $ Payload/
zip -r $1.ipa Payload
rm -fR Paypload
tluyben / csv Parse
Created Feb 15, 2013
Simple Monkey language CVS parser
View csv Parse
Method Parse() ' csv parser
Local _inc:Bool = False
Local afc:Bool = False
Local quote:=New Quote
Local c:String, c1:String = ""
raw = raw + "~n" ' make sure we catch the last one
For Local i := 0 To raw.Length
c = raw[i..i+1]
If i+2 < raw.Length
c1 = raw[i+1..i+2]
View angelfont wrap
Method DrawWrap(t:String, x:Float, y:Float, width:Float, align:Int = AngelFont.ALIGN_CENTER)
' do some calculations and splitting
Local splits:StringList = New StringList
Local lw := Floor(width / font.TextWidth("W")) ' about how many letters fit in the width?
Local enters:String[] = t.Split("~n")
' check if any split string is too long to fit
For Local i:=0 Until enters.Length
Local s := enters[i]
tluyben / gist:5046420
Created Feb 27, 2013
Resolution test Monkey
View gist:5046420
Import mojo
Import diddy
Class TestScreen Extends Screen
Method Start:Void()
Method Update:Void()
tluyben / gist:5098910
Created Mar 6, 2013
Resize all images in a directory. Images should be of the format xxx_WIDTHxHEIGHT.ext, so bla_2048x1536.png, run as : ./ 2048 1536 and all images are resized to 1024x768.
View gist:5098910
$x = $ARGV[0];
$y = $ARGV[1];
if (not $x or not $y) {
print "./ width height\n";
tluyben / GLES return issue
Created Mar 7, 2013
OpenPandora GLES return Null for the version; workaround
View GLES return issue
// Parses the client API version string and extracts the version number
static GLboolean parseGLVersion(int* api, int* major, int* minor, int* rev)
int i, _api = GLFW_OPENGL_API, _major, _minor = 0, _rev = 0;
const char* version;
const char* prefixes[] =
"OpenGL ES-CM ",
"OpenGL ES-CL ",