Skip to content

Instantly share code, notes, and snippets.

View scips's full-sized avatar

Sébastien Barbieri scips

View GitHub Profile
@scips
scips / docker.md
Last active December 6, 2018 20:59
Docker with ubuntu 16-04 movidius ncs2

Install a base docker

Search for it

Search for 16-04

docker search 16-04

Search for ubuntu

@scips
scips / GeoDistance.php
Last active February 28, 2018 20:28
Geo Distance between 2 coord
<?php
function sphericalDistance($lat1,$lon1,$lat2,$lon2){
$R = 6371.0; // km
$d = acos(
sin(deg2rad($lat1))*sin(deg2rad($lat2))
+ cos(deg2rad($lat1))*cos(deg2rad($lat2))
* cos(deg2rad($lon2-$lon1))
)
* $R;
return $d;
@scips
scips / get_slowest_test.sh
Created November 28, 2017 15:27
Get the slowest test case phpunit junit xml
xmllint --xpath '//testcase[@time>"0.1"]' test.xml
@scips
scips / quick_gist_xmlfile_upload_to_gist.md
Created November 28, 2017 14:45
Quickly upload an XML file to a gist command line

XML 2 secret gist + oauth

Why

I wanted to automatically retrieve an xml file (phpunit junit log) from a travis server.

I don't know why but rsync and scp failed so I assumed I could post it to pastebin but the pulbic api shut down years ago.

So I tried with github and gist...

@scips
scips / parse_json_xml_with_python.md
Last active November 27, 2017 14:56
Parse Json or Xml with python and return a signle value

Parse XML file and return a node text value

elementValue=`cat somefile.xml | python -c 'import sys, xml.etree.cElementTree as et;\
 tree = et.parse(sys.stdin); print tree.find("elementValue").text'`
@scips
scips / ssh_tunnel_http_to_vagrant.sh
Created November 27, 2017 13:54
Tunnel traffic from host to guest vagrant
# Tunnel the 443 port of your host to the vagrant machine you have
sudo ssh -g -L 443:localhost:443 -f -N [email protected]
<script src="https://unpkg.com/vue"></script>
<style>
.done {
text-decoration: line-through;
}
</style>
<div id="app">
<p>
<label v-for="m in modes">
@scips
scips / sphinx_search_crash_base64.awk
Last active October 12, 2017 13:04
print out Sphinx base 64 encoded string from sphinxsearch FATAL dump
# Usage Get base64 decoded from dump: cat searchd.* | awk -f crash.awk | base64 -d
# Usage Get specific term that caused the crash: cat searchd.* | awk -f crash.awk | base64 -d | awk 'match($0, /.*\^(\w+)\$.*/, a) {print a[1]}' | sort | uniq -c
BEGIN { RS=""; FS="\n" }
{
keep=0
for(i=1;i<=NF;i++) {
if ( $i ~ /request dump end/ ) {
keep=0
print temp
@scips
scips / rename_files.sh
Created October 10, 2017 19:00
rename files bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
for i in `ls | grep 360p`; do
NEWNAME=`echo $i | sed 's/ \[360p\]//'`;
echo $i " -> " $NEWNAME;
mv "$i" "$NEWNAME";
done
IFS=$SAVEIFS
@scips
scips / infiniteloop.sh
Created October 9, 2017 14:20
Make an infinite loop while true and set the xterm title the command executed
#!/bin/bash
TITLE="$@"
printf '\e]2;%s\a' "$TITLE";
while true
do
"$@"
sleep 30
done