Skip to content

Instantly share code, notes, and snippets.

View glefait's full-sized avatar

Guillem Lefait glefait

View GitHub Profile
@glefait
glefait / 0_reuse_code.js
Created May 22, 2014 07:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@glefait
glefait / alias.sh
Created January 31, 2018 12:38
delete and recreate virtualenv then install current python package
alias delgenvenv="current_env=`pwd | sed -nr 's#^.*?/([^/]+)$#\1#p'` \
&& echo \"destroy virtualenv $current_env\" \
&& (deactivate || echo 'skip deactivate') \
&& (rm -Rf ~/.virtualenvs/$current_env/ || echo 'skip rm') \
&& virtualenv ~/.virtualenvs/$current_env \
&& source ~/.virtualenvs/$current_env/bin/activate \
&& pip install -r requirements.txt"
@glefait
glefait / qrcode-rtl.py
Last active March 9, 2018 02:00
right to left unicode character to pown qrcode reader
# Use RTL unicode to trick QrCode reader
# Idea from Dylan Katz: https://twitter.com/Plazmaz
import qrcode
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=10,
border=4,
)
import base64
print(base64.b64encode(''.join(['{:08b}'.format(ord(c))for c in input()[::-1]]).encode('ascii')).decode('ascii'))
#decode
#s=base64.b64decode(input());print(''.join([chr(int(s[i:i+8],2))for i in range(0,len(s),8)][::-1]))
@glefait
glefait / entite-publiques.csv
Created August 31, 2018 14:47
Entités publiques référencées sur adullact (2018-08-31)
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
Entités publiques
PASSAGE (LE) (38490 - LE PASSAGE)
A.C.T.I.S GRENOBLE (38000 - GRENOBLE)
A.GE.D.I (77440 - DHUISSY)
ABAUCOURT HAUTECOURT (55400 - ABAUCOURT HAUTECOURT)
ABRESCHVILLER (57560 - ABRESCHVILLER)
ABRETS (LES) (38490 - LES ABRETS)
ADINFER (62116 - ADINFER)
ADRETS (LES) (38190 - LES ADRETS)
ADULLACT (34000 - Montpellier)
@glefait
glefait / get_resource_url.py
Created March 14, 2019 17:27
get xattr url of objects (downloaded resources)
for (o, url) in [(x, os.getxattr(x, 'user.xdg.origin.url')) for x in os.listdir('.') if 'user.xdg.origin.url' in os.listxattr(x)]: print(o, url)
@glefait
glefait / decode.js
Last active April 12, 2019 15:48
decode Google Code Competition data
var googleCodeDecode = function (e) {
return JSON.parse(atob(e.replace(/[-_]/g, function(e) { return "-" == e ? "+" : "/" }).replace(/[^A-Za-z0-9\+\/]/g, "")));
}
var googleCodeEncode = function (e) {
return btoa(JSON.stringify(e)).replace(/[+/]/g, function(e) { return "+" == e ? "-" : "_" }).replace(/[^A-Za-z0-9\+\/]/g, "")));
}
params = {"min_rank": 1, "num_consecutive_users": 100};
// url example to get the first 100 results:
@glefait
glefait / ladocumentationfrancaise.fr.json
Created October 22, 2019 20:33
Scan 2019-10-22 https://www.ladocumentationfrancaise.fr : stealth pupeeter - single page & no action
{
"cookie": {
"route": "cfd2bfd3459b299d8a4ed95df56eda81",
"xtvrn": "$486404$",
"__trossion": "1571692868_1800_1__aafa479d-4d93-445a-a529-5831f28b43ad%3A1571692868_1571692868_1",
"__troRUID": "aafa479d-4d93-445a-a529-5831f28b43ad",
"__troSYNC": "1"
},
"localStorage": {},
"scripts": [
#!/bin/bash
for i in {1..1000}; do
line="$(date +'%F %T') $(ping -c 25 193.252.148.140|tail -n 2|tr '\n' '\t')";
echo $line >> ~/sfr_ping.txt;
echo $line;
done
@glefait
glefait / solaar_autostart.sh
Created May 12, 2020 12:22
raspian + solaar : stop annoying window
$ cat /etc/xdg/autostart/solaar.desktop
[Desktop Entry]
Name=Solaar
Comment=Logitech Unifying Receiver peripherals manager
Exec='solaar --window=hide'
Icon=solaar
StartupNotify=false
Terminal=false
Type=Application
Keywords=logitech;unifying;receiver;mouse;keyboard;