Skip to content

Instantly share code, notes, and snippets.

View brunetton's full-sized avatar
🏠
Working from home

Bruno Duyé brunetton

🏠
Working from home
View GitHub Profile
@brunetton
brunetton / make_livret_from_svg.rb
Created February 5, 2018 22:46
Old old old code to make a book from a serie of svg files
#!/usr/bin/ruby
require 'fileutils'
require 'enumerator'
# crée le livret à partir des fichiers svg double page contenus dans le répertoire PagesRep
# nécessite :
# - des doubles pages dans pages/, dont
# - une page de garde (à droite dans le fichier 0.svg)
# - un fichier 'pages_blanches.svg' contenant deux pages blanches
#
@brunetton
brunetton / zenity.rb
Created January 19, 2018 14:55
Ruby Zenity progress bar
zenity_with_options = 'zenity --progress --title="Working..." --text="Analyse des journaux de mail... --auto-close'
IO.popen(zenity_with_options.split(' '), 'w') do |io|
for i in 1..10
io.puts(i * 10)
sleep(1)
end
end
@brunetton
brunetton / gist:146614dfd10f6fbeeaeefa3bc2e81ac8
Created January 17, 2018 10:56
Custom csv DictReader, as an iterator, that trunck "too long" lines
def custom_dict_reader(csv_filename, delimiter="\t"):
with open(csv_filename) as csv_file:
header = list(map(str.strip, csv_file.readline().split(delimiter)))
line_num = 2
for line in csv_file.readlines():
splitted = list(map(str.strip, line.split(delimiter)))
if len(splitted) != len(header):
print("WARNING: the number of rows in line ({}) doesn't match the number of elements in header ({}) ! Row will be truncated".format(
len(splitted), len(header)
))
@brunetton
brunetton / correct_waves.py
Created January 9, 2018 01:12
Truncated waves files after photorec restore from Zoom h2n in 4ch mode - correction
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
Tris *experimental* program tries to "re-hash" waves files in "good order" after deletion then recover with photorec
on a FAT SD card; recorded in 4 chanels mode with Zoom H2n.
Does the job, but probably not compatible with other situations.
"""
import sys
@brunetton
brunetton / touchpas_switch.py
Last active September 18, 2015 13:35
Touchpad on/off switch
#!/usr/bin/python
import re
import subprocess
on_command = "synclient TouchpadOff=0"
off_command = "synclient TouchpadOff=1"
# TouchpadOff = 2
match = re.search("=\s(\d)", subprocess.check_output("synclient | grep TouchpadOff", shell=True))
@brunetton
brunetton / fish_prompt.fish
Created August 6, 2015 17:38
Fish shell prompt
function fish_prompt --description 'Write out the prompt'
# save last status
set -l last_status $status
# last status
set last_status_string ""
if [ $last_status -ne 0 ]
set last_status_string (set_color --bold $fish_color_error)"($last_status)"
end
@brunetton
brunetton / style.css
Last active August 29, 2015 14:09
Atom editor - emphasis trailing whitespaces
/* Red trailing whitespaces (https://gist.github.com/brunetton/a55c6e8735eeee68067b) */
atom-text-editor::shadow .lines .line {
.trailing-whitespace {
color: #ff2a2a;
background: #342022;
}
// Disable highlight for lines with a cursor on them
&.cursor-line .trailing-whitespace {
color: inherit;