Skip to content

Instantly share code, notes, and snippets.

IC :
Jenkins
Sonar
Git : Giblit
Project:
https://github.com/taigaio
@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
/**
* Computes the md5 sum (or lookups from a .md5 file) for the provided file.
*
* @param f file path
* @return the base64ed md5 sum of the file
* @throws IOException
* @throws NoSuchAlgorithmException
* @throws DecoderException
*/
private String getMd5(Path f) throws IOException, NoSuchAlgorithmException, DecoderException {
@jrialland
jrialland / android_video_capture.sh
Created July 28, 2016 13:54
capture screen video from a running android device, and convert to animated gif (needs vlc and imagemagick)
#!/bin/bash
set -e
#ADB=`which adb`
ADB=$ANDROID_HOME/platform-tools/adb
TMPMP4=$(mktemp).mp4
TMPFILE=/sdcard/$(basename $TMPMP4)