Skip to content

Instantly share code, notes, and snippets.

View jeremyfix's full-sized avatar

Jeremy Fix jeremyfix

View GitHub Profile
@jeremyfix
jeremyfix / env.yml
Last active September 19, 2022 07:08
Experimentation of pytorch 1.12 gradient descent with complex tensors
name: torchcomplex
channels:
- pytorch
- defaults
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- blas=1.0=mkl
- brotli=1.0.9=h5eee18b_7
- brotli-bin=1.0.9=h5eee18b_7
@jeremyfix
jeremyfix / test_stanford.py
Created April 10, 2022 21:02
Loading the semantic labels of the stanford 2D 3D S dataset
import pathlib
import PIL.Image as Image
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
import json
# Code taken from utils.py on https://github.com/alexsax/2D-3D-Semantics
def get_index(color):
@jeremyfix
jeremyfix / binary.py
Created March 10, 2022 12:50
Writting/reading a binary file in python with string, ints and numpy arrays
# coding: utf-8
# External imports
import numpy as np
FIELD_WIDTHS = {
'int': 16
}
ENDIAN = 'big'
@jeremyfix
jeremyfix / gist:afbdae585afc42dd6e77c6d0d038dfd2
Created November 20, 2021 15:29
Transform a scanned colored 2 pages book into single pages gray
# The margins were on the right and bottom parts (hence the first rotation to ease margin removal)
convert -rotate 180 -crop +130+210 +repage -density 130 -rotate -90 -colorspace gray +repage source.pdf tmp.pdf && mutool poster -x 2 tmp.pdf target.pdf
@jeremyfix
jeremyfix / Installation
Last active May 6, 2024 18:34
Turtlebot2 on ROS Noetic Ubuntu 20.04
# Make the workspace
mkdir ~/catkin_ws
cd catkin_ws
mkdir -p src
catkin_make
cd src
# Clone the required repositories
git clone https://github.com/turtlebot/turtlebot.git
To run a jupyter lab with a specific token, just :
jupyter lab --NotebookApp.token='toto'
This is handfull to use a custom token , for example when running a batch of jupyter lab for students working remotely to which you just want to provide a token and not the quite complicated instance specific URL.
@jeremyfix
jeremyfix / gist:95bcbab6d11834638720462e430737a4
Created December 21, 2020 21:36
Preprocessing of wikisources
Given texts from wikisource, the raw one , with the markup, from here https://fr.wikisource.org/w/index.php?title=Fables_et_opuscules_p%C3%A9dagogiques&action=edit
and suppose the whole wiki text is copied in fenelon.txt , we can somehow get rid of the markup and so on with the following
cat fenelon.txt | sed '/^</d' | perl -pe 's|\[\[Auteur.*?\]\]||' | sed 's/\[\[//g' | sed 's/\]\]//g' | sed 's/==//g' | sed '/^$/d' | perl -pe 's|<ref>.*?</ref>||' | perl -pe 's|<ref>.*?</ref>||' | perl -pe 's|<sup>.*?</sup>||' | perl -pe 's|</.*?>||' | sed "s/\’/'/g" | sed 's/»/"/g' | sed 's/«/"/g' | perl -pe 's|\{\{.*?\}\}||' | sed 's/œ/oe/g' | sed 's/Œ/OE/g' > fenelon2.txt
there are still some markup though.
# Description of the issue :
After pushing a text file, which was UTF-8 encoded (as indicated by the file command) on github and pulling it back on another computer on which I was connected through ssh ,
I was unable to see the accents in the files (these appeared either as _ _ _ or <C5><A9>, etc..)
Then , I added to my bashrc
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
@jeremyfix
jeremyfix / gist:16ce73828f96cc022a9517818d6aa15b
Created December 6, 2020 11:48
Extracting a page from a PDF, scaling it up and splitting in multiple A4 pages
# Extract, e.g., the second page
pdftk input-file.pdf cat 2 output pageA3.pdf
# Scale it up
pdfjam --outfile pageA4.pdf --paper a3paper pageA3.pd
# Split it in mutiple A4 pages
pdfposter pageA3.pdf multipleA4.pdf -m a4 -p 2x1a4
@jeremyfix
jeremyfix / HowToVNC.md
Last active December 2, 2020 12:43
Configuring remote accounts for using vnc

For copying your ssh keys to facilitate the configuration

for i in {1..59}; do sshpass -p THE_SECRET_PASSWORD ssh-copy-id myacount_$i@mymachine.mydomain.com ; done

For setting up the xstartup script

  for i in {1..59}; do ssh myacount_$i@mymachine.mydomain.com << 'EOF'