Skip to content

Instantly share code, notes, and snippets.

@arcaduf
arcaduf / Find command from your terminal history
Last active May 25, 2018 07:36
Find command from your terminal history
history
Ctrl+R
Type the subject of your search, e.g. screen
Type Ctrl+R repeatedly until you find your match.
@arcaduf
arcaduf / Convert \t into 4 spaces in each file inside a folder (and viceversa)
Created January 29, 2018 09:23
Convert \t into 4 spaces in each file inside a folder (and viceversa)
From \t to 4 spaces:
find . -type f -exec sed -i.orig 's/\t/ /g' {} +
From 4 spaces to \t:
find . -type f -exec sed -i.orig 's/ /\t/g' {} +
@arcaduf
arcaduf / Create and save annotations with ImageJ
Last active January 26, 2018 09:55
Create and save annotations with ImageJ
Load image.
Duplicate it as many times as many types of ROI you want to draw.
GO --> Edit --> Selection --> Add to Manager.
Draw the ROI and add it to the manager.
Click on each ROI / each group of ROIs and then click "More" --> "Fill" inside the manager.
Save the resulting image as separate .png.
In case you want to work with the .roi format of ImageJ, use this python code to read the .zip and the .roi:
https://gist.githubusercontent.com/luispedro/3437255/raw/d3f0be5efbe37efe27946c5fa21f5ef523cdac43/readroi.py
@arcaduf
arcaduf / Sanitize python script by converting tabs into spaces
Created January 21, 2018 11:50
Sanitize python script by converting tabs into spaces
sudo apt-get install moreutils
expand -t 4 filein | sponge fileout
@arcaduf
arcaduf / Python: read and dump dictionary to YAML preserving order
Created January 15, 2018 10:08
Python: read and dump dictionary to YAML preserving order
```python
import collections , yaml
_mapping_tag = yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG
def dict_representer(dumper, data):
return dumper.represent_mapping(_mapping_tag, data.iteritems())
def dict_constructor(loader, node):
return collections.OrderedDict(loader.construct_pairs(node))
@arcaduf
arcaduf / Start an interactive CPU session with Slurm
Created January 12, 2018 16:30
Start an interactive CPU session with Slurm
interactive -c 24 -t 08:00:00
@arcaduf
arcaduf / Work with screen sessions
Last active August 9, 2018 12:34
Work with screen sessions
Start a screen session:
screen -S "vgg-regression"
To detach a screen session:
Ctrl-a d
To reattach the only screen session
Ctrl-a r
To reattach a session of given PID
@arcaduf
arcaduf / Install R package directly from main repository
Created December 20, 2017 15:53
Install R package directly from main repository
Example with 'mlbench':
install.packages('mlbench', dependencies=TRUE, repos='http://cran.rstudio.com/')
@arcaduf
arcaduf / Basic commands for Windows Prompt
Created October 20, 2017 13:03
Basic commands for Windows Prompt
Change disk:
cd /d C:\
Go back:
cd..
@arcaduf
arcaduf / Create symbolic links to a dataset maintaining its folder tree structure
Created October 16, 2017 09:49
Create symbolic links to a dataset maintaining its folder tree structure