Giter Club home page Giter Club logo

misc's Introduction

This repo contains all random things I'm doing, some are usefull some aren't This README also contain several oneliners used time to time

Summary

Scripts

Dictannabinol.py

Python object reminder, long time no object in python Python dict-like class that forgets things. I need to rename this... This script is based on https://github.com/gitpan/Tie-Hash-Cannabinol


Functions_automatic_Integration_roxygen_doc

Python3; automatic generation for some part of roxygen documentation See inside for more details


robotguide2urscript

Python3; convert robotguide waypoints files to URscript Quickly done


DMS2DD

Python3; transform GPS Degrees Minutes Seconds locations into Decimal Degrees


Oneliners

Concat files without their 1st line

find . -name "*.txt" | xargs -n 1 tail -n +2 > outfile

Extract all columns but the one matching regex

awk 'NR==1{for(i=1;i<=NF;i++)if(!($i~/REGEX_HERE:_[kv][0-9]+$/)){a[i]=1;m=i}}{for(i=1;i<=NF;i++)if(a[i])printf "%s%s",$i,(i==m?RS:FS)}' FILE.tsv |column -t

Create N files of size S

# Create 20 000 files of size = 1MB; change bs to change size
for i in $(seq 1 20000); do touch $i; dd if=/dev/urandom of=$i bs=1024 count=1024 >/dev/null 2>&1; done

Python, create a test email server that prints mail in terminal instead of sending them

# Mail is sent to localhost on port 8025 in this example
python -m smtpd -n -c DebuggingServer localhost:8025

Extract only even/odd lines from a file

# even
sed -n '0~2p' file.csv > output.csv
# odd
sed -n '1~2p' file.csv > output.csv

Count number of reads in fasta/fastq files

# Fasta
grep '>' file.fasta | wc -l
# Fastq
awk '{lines++}END{print lines/4}' file.fastq

Extract sequences from a fasta based on a list of IDs

# Change the value in 'cut' to strip unneccessary characters before your id
cut -c 1- FILE_IDs.TXT | xargs -n 1 samtools faidx FILE.FASTA

Extract specific regions from a fasta file (using bedtools)

bedtools getfasta -fi file.fasta -bed file.bed -fo output.fasta -name

# See the bed file format here: https://felixfan.github.io/bedtools/

Rename a tilda (or xterm compatible terminal programs) tab

NAME="tab name here"
echo -e  "\e]2;$NAME\a  tab --> [$NAME]"

Create multiple screens to run several commands in it

#!/bin/bash
# Run this script with this command: screen -c "./SCRIPT_NAME" && pkill screen
# && pkill screen will just kill all the existing screens once you detach; on macos use pkill SCREEN instead

# split is going to split your window; the -v option is for vertical splitting and only available for screen > 4.01.0
# focus gonna change the focus to the newly created window
# using ;sh as the final bash command will allow you to keep the screen running. Otherwise it will terminate itself once the command is done running

screen -t "YOUR TITLE 1" bash -c "<your bash command>; sh"
split -v
focus
screen -t "YOUR TITLE 2" bash -c "<your bash command>; sh"
split -v
focus
screen -t "YOUR TITLE 3" bash -c "<your bash command>; sh"
split -v
focus
screen -t "YOUR TITLE 4" bash -c "<your bash command>; sh"

misc's People

Contributors

piplopp avatar

Watchers

 avatar

misc's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.