Skip to content

Instantly share code, notes, and snippets.

View AntoineTurmel's full-sized avatar

Antoine Turmel AntoineTurmel

View GitHub Profile
@AntoineTurmel
AntoineTurmel / getInfos.php
Created May 15, 2020 10:09
Display PHP version with ?info=phpVersion or Raspberry Pi Revision Model with ?info=device (it needs pi-model.json from https://github.com/gablau/rpi-revision-codes-utility/blob/master/pi-model.json )
<?php
function getRaspberryPiVersion($revision) {
$fp = fopen('pi-model.json', 'r');
$filename = "pi-model.json";
$contents = fread($fp, filesize($filename));
fclose($fp);
$json = json_decode($contents);
foreach ($json as $item) {
if ($item->Code == $revision) {
@AntoineTurmel
AntoineTurmel / phpVersionSwitch.sh
Created August 26, 2020 07:36
Simple script to switch from a php version to another on Ubuntu
#!/bin/bash
phpver=`php -r "echo phpversion();"`
if [ "`echo $phpver | grep '7.4'`" ]; then
echo "Bascule sur PHP 5.6.x"
sudo a2dismod php7.4
sudo a2enmod php5.6
sudo update-alternatives --set php /usr/bin/php5.6
sudo service apache2 restart
fi
@AntoineTurmel
AntoineTurmel / musikG15.js
Created December 26, 2017 03:09
rough script to display artist/title and use media keys on musikCube/Linux
const WebSocket = require('ws');
var EventEmitter = require('events').EventEmitter;
const ws = new WebSocket('ws://127.0.0.1:7905');
var g15composer = require('g15composer').init('/home/antoine/dev/musikG15/pipe', 'notifications');
ws.on('open', function open() {
ws.send('{ "name": "authenticate", "type": "request", "id": "foobar", "options": { "password": "" }}');
@AntoineTurmel
AntoineTurmel / mv500px.sh
Created December 13, 2017 11:35
randomly rename 500px files with a proper file name
#!/bin/bash
start=0
for file in v2*; do
randomid=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1`
mv $file $randomid"-"$start.JPG
start=$((start + 1))
done
@AntoineTurmel
AntoineTurmel / missing_strings.py
Created January 5, 2014 03:23
Script to print missing strings on a specific Songbird locale (no more working since servers are down)
#!/usr/bin/python
import urllib
import sys
if len(sys.argv) == 1:
print "You must specify a locale"
else:
f = urllib.urlopen("http://translate.songbirdnest.com/languages/" + sys.argv[1])
@AntoineTurmel
AntoineTurmel / locales.xml
Created January 5, 2014 03:09
Nightingale locales.xml example for distributing langpacks
<?xml version="1.0" encoding="UTF-8"?>
<SongbirdInstallBundle version="2">
<XPI name="Afrikaans" id="langpack-af@getnightingale.com" languageTag="af" url="http://locales.getnightingale.com/langpacks/1.12.1/langpack-af-1.12.1.xpi"/>
<XPI name="عربي" id="langpack-ar@getnightingale.com" languageTag="ar" url="http://locales.getnightingale.com/langpacks/1.12.1/langpack-ar-1.12.1.xpi"/>
<XPI name="Български" id="langpack-bg@getnightingale.com" languageTag="bg" url="http://locales.getnightingale.com/langpacks/1.12.1/langpack-bg-1.12.1.xpi"/>
<XPI name="বাংলা (ভারত)" id="langpack-bn-IN@getnightingale.com" languageTag="bn-IN" url="http://locales.getnightingale.com/langpacks/1.12.1/langpack-bn-IN-1.12.1.xpi"/>
<XPI name="Català" id="langpack-ca@getnightingale.com" languageTag="ca" url="http://locales.getnightingale.com/langpacks/1.12.1/langpack-ca-1.12.1.xpi"/>
<XPI name="Čeština" id="langpack-cs@getnightingale.com" languageTag="cs" url="http://locales.getnightingale.com/langpacks/1.12.1/langpack-cs-1.12.1.
#!/bin/bash
bz_user=
bz_pass=
tx_api_url="http://beta.babelzilla.org/api/2/project/"
tx_project="ngaletest"
curl -L --user $bz_user:$bz_pass -X GET $tx_api_url$tx_project/resources/ > filelist.json
cat filelist.json | grep slug | sed -e 's/"slug": "//g' | sed -e 's/",//g' | sed -e 's/ //g' > filelist
@AntoineTurmel
AntoineTurmel / missings_strings.py
Last active December 20, 2015 17:59
Using python-beautifulsoup, parsing translate website for missing strings
#!/usr/bin/python
import urllib
import sys
if len(sys.argv) == 1:
print "You must specify a locale"
else:
f = urllib.urlopen("http://translate.songbirdnest.com/languages/" + sys.argv[1])
@AntoineTurmel
AntoineTurmel / reorder-dtd.sh
Last active December 16, 2015 19:49
Script to reorder strings based on a file pattern
#!/bin/bash
# This script allow reorder of strings from a foreign .dtd file
# based on the en-US file and keeping original comments
#en-US base folder
dtd_base_folder='/home/antoine/Dev/nightingale-l10n/locales/en-US/songbird/'
for lang_code in $(cat /home/antoine/Dev/songbird-l10n/shipped-locales)
do
@AntoineTurmel
AntoineTurmel / reorder-properties.sh
Last active December 10, 2015 12:19
Script to reorder strings based on a file pattern
#!/bin/bash
# This script allow reorder of strings from a foreign .properties file
# based on the en-US file and keeping original comments
#en-US basefile
prop_base_file='/home/antoine/Dev/nightingale-l10n/locales/en-US/songbird/songbird.properties'
for lang_code in $(cat /home/antoine/Dev/songbird-l10n/shipped-locales)
do