Skip to content

Instantly share code, notes, and snippets.

View jrialland's full-sized avatar

Julien Rialland jrialland

View GitHub Profile
@jrialland
jrialland / dscan.py
Created August 19, 2015 09:08
algorithm for scanning cells in an array in diagonal, may be used for ordering drawing of sprites in an isometric 3d game.
def dscan(w, h):
""" scans a 2-dimensions array of width 'w', height 'h', in diagonal, starting at the upper-left corner.
example for w=3,h=3 :
+---+---+---+
|000|002|003|
|001|004|007|
|005|006|008|
+---+---+---+
IC :
Jenkins
Sonar
Git : Giblit
Project:
https://github.com/taigaio
@jrialland
jrialland / cross-compile.txt
Created September 22, 2015 16:25
Recipe that allows to cross-compile a window(32bits) .exe out of a python script under linux.
#recipe from https://milkator.wordpress.com/2014/07/19/windows-executable-from-python-developing-in-ubuntu/
# allows to cross-compile a window(32bits) .exe out of a python script under linux.
cat > test.py <<< EOF
print "hello world !"
EOF
apt-get install scons wine
git clone https://github.com/pyinstaller/pyinstaller
@jrialland
jrialland / gist:85a0256a8a96c83f412c
Created September 25, 2015 10:12
increase swap on the go
dd if=/dev/zero of=swapfile bs=1024 count=6553600
mkswap swapfile
swapon swapfile
@jrialland
jrialland / outputToGif.sh
Created October 2, 2015 12:16
Converts the successive outputs of a program into a splendid animated gif
#!/bin/bash
start=$1
end=$2
command=$3
outputfile=$4
delay=10
rm -rf /tmp/outputToGif 2>/dev/null
mkdir -p /tmp/outputToGif
@jrialland
jrialland / pacproxy.groovy
Created October 6, 2015 09:36
small script that uses a proxy.pac js configuration file and credentials for simplifying proxy connections
#!/usr/bin/env groovy
/*######################################################################*/
//Configuration
/** username & password for proxy authentication */
username = "user"
password = "p@zzW0rD"
/** Location of the Proxy configuration file (http://, and file:// urls are supported) */
@jrialland
jrialland / get_intersection.py
Last active November 4, 2015 11:06
Gives the intersection point between 2 2d segments, handling all cases
def get_intersection(line1, line2):
xdiff = (line1[0][0] - line1[1][0], line2[0][0] - line2[1][0])
ydiff = (line1[0][1] - line1[1][1], line2[0][1] - line2[1][1]) #Typo was here
def det(a, b):
return a[0] * b[1] - a[1] * b[0]
div = det(xdiff, ydiff)
if div == 0:
return None
d = (det(*line1), det(*line2))
p = det(d, xdiff) / div, det(d, ydiff) / div
@jrialland
jrialland / simplify_path.py
Created November 9, 2015 21:43
simplifies a list a points
def simplify_path(p):
direction = p[1][0]-p[0][0], p[1][1]-p[0][1]
yield p[0]
current = p[1]
if len(p)>2:
for pos in p[2:]:
rdir = pos[0]-current[0], pos[1]-current[1]
if direction != rdir:
yield current
current = pos
@jrialland
jrialland / gist:38110b1d59c94b8e1b4a
Created March 11, 2016 10:14
bash -> gets a random free tcp port to bind
FREE_TCP_PORT=`python -c "from socket import*;s=socket(AF_INET,SOCK_STREAM);s.bind(('',0));s.listen(1);print s.getsockname()[1];s.close()"`
@jrialland
jrialland / sendemail.py
Created May 3, 2016 12:33
python send smtp emails
#!/usr/bin/env python2
# -*- encoding:utf-8 -*-
import sys
import os
import os.path
import smtplib
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText