Skip to content

Instantly share code, notes, and snippets.

View ymollard's full-sized avatar
🐧
Art, engineering & digital training

Yoan Mollard ymollard

🐧
Art, engineering & digital training
View GitHub Profile
@ymollard
ymollard / xrandr.bash
Last active September 25, 2024 12:02
Set the screen to a custom resolution with xrandr
# 1. Select first the resolution you would like to get the modeline (preferably the screen native resolution)
$ cvt 1920 1080
# 1920x1080 59.96 Hz (CVT 2.07M9) hsync: 67.16 kHz; pclk: 173.00 MHz
Modeline "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
# 2. Identify your screen name (here VGA-0 with a low res)
$ xrandr
Screen 0: minimum 8 x 8, current 2560 x 1080, maximum 16384 x 16384
VGA-0 connected 640x480+1920+0 (normal left inverted right x axis y axis) 0mm x 0mm
640x480 59.9*+
@ymollard
ymollard / clean_git_repository.bash
Created February 4, 2016 00:54
Clean a git repository by deleting history and data of old deleted files
#!/bin/bash
# This script, executed at the root of a git repository, deletes traces of every old file in this repository, index + blob on all branches
# It can take 10-30 minutes to run and will print regular warning stating than some references are unchanged
# time ./clear_git_repositor.bash >cleaning.log
# We need several passes to clean files renamed multiple times (git log --find-renames prevents its deletion for each renaming)
# MAXIMUM_PASSES should be more than the maximum number of renamings/movings for any file, if not then we might keep some traces of former files
MAXIMUM_PASSES=10 # Maximum number of passes
@ymollard
ymollard / profile_module.sh
Created August 22, 2016 18:07
Profile a python module and plot
pip install pyprof2calltree
sudo apt-get install kcachegrind
python -mcProfile -o module.cprof $(python -c 'import runpy; print runpy.__file__.rstrip("co")') the.module.to.profile
pyprof2calltree -k -i module.cprof
@ymollard
ymollard / freecad_svg_to_board.md
Last active August 28, 2016 21:56
Freecad to Inkscape board
  1. Objet vers Chemin
  2. Redimensionner à L+0.1, H+0.1, épaisseur de ligne = 0.1
  3. Dégrouper
  4. Sur chaque couple de noeuds superposés, les sélectionner, ils disparaissent
  5. Maj + J sur chaque couple
  6. Dupliquer la forme globale
  7. Appliquer un miroir (attention : est-ce symétrique ?)
  8. Sur chaque segment partagé de la forme dupliquée -> Alt+Suppr (pas Alt Gr)
  9. Lors de la dernière suppression, la largeur est réduite de 0.05
  10. Aligner verticalement
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ymollard
ymollard / autoipd.md
Created December 17, 2016 20:59
Getting an auto IP

sudo /usr/sbin/avahi-autoipd -w eno1

@ymollard
ymollard / rename_ROS_pkg.md
Last active June 23, 2017 16:44
Rename ROS package
  • Replace upper case and lower case name occurences with KFilereplace on files: *.md;*.py;*.launch;*.xml;*.txt;*.srv;*.msg;*.action
  • Replace name occurences in folders and files:
    shopt -s globstar  # Enables **
    rename 's/old_name/new/' **  # Run it several times until there's no new error
    
@ymollard
ymollard / two_pass_ffmpeg.md
Created May 19, 2017 14:45
Two pass FFMPEG

Your video is 10 minutes (600 seconds) long and an output of 200 MiB is desired. Since bitrate = file size / duration:

(200 MiB * 8192 [converts MiB to kBit]) / 600 seconds = ~2730 kBit/s total bitrate 2730 - 128 kBit/s (desired audio bitrate) = 2602 kBit/s video bitrate

ffmpeg -y -i input -c:v libx264 -preset medium -b:v 2600k -pass 1 -c:a aac -b:a 128k -f mp4 /dev/null
ffmpeg -i input -c:v libx264 -preset medium -b:v 2600k -pass 2 -c:a aac -b:a 128k output.mp4
@ymollard
ymollard / systemd_history.md
Created June 26, 2017 13:37
Read SystemD history
sudo systemctl status apex.service -l  # Summary of the execution and success/failure state
sudo journalctl -u apex --all  # Displays the full log
# Long version: journalctl _SYSTEMD_UNIT=apex.service --all  # Full output
$ sudo nmap -sS 192.168.43.1 --osscan-guess -O
Starting Nmap 7.01 ( https://nmap.org ) at 2017-09-16 19:26 CEST
Nmap scan report for 192.168.43.1
Host is up (0.040s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
53/tcp open domain
7676/tcp open imqbrokerd
9001/tcp open tor-orport