From e0c0d4b38cde20e2300e86b69414dd9851b47456 Mon Sep 17 00:00:00 2001 From: neodarz Date: Thu, 5 Sep 2019 07:05:07 +0200 Subject: ooo --- README.md | 1 + config.yaml | 4 + dotfiles/cheat/RAID | 5 + dotfiles/cheat/Xresources | 2 + dotfiles/cheat/acl | 2 + dotfiles/cheat/ansible | 11 ++ dotfiles/cheat/borg | 23 +++ dotfiles/cheat/cal | 26 +++ dotfiles/cheat/commands | 24 +++ dotfiles/cheat/convert | 22 +++ dotfiles/cheat/corm | 1 + dotfiles/cheat/cryptsetup | 11 ++ dotfiles/cheat/css | 5 + dotfiles/cheat/django | 50 +++++ dotfiles/cheat/django-cms | 9 + dotfiles/cheat/django-oscar | 17 ++ dotfiles/cheat/djangocms | 29 +++ dotfiles/cheat/docker | 35 ++++ dotfiles/cheat/find | 50 +++++ dotfiles/cheat/gcc | 26 +++ dotfiles/cheat/git | 165 ++++++++++++++++ dotfiles/cheat/help | 10 + dotfiles/cheat/history | 10 + dotfiles/cheat/iperf | 1 + dotfiles/cheat/irc | 5 + dotfiles/cheat/kraken | 3 + dotfiles/cheat/magnetico | 5 + dotfiles/cheat/mkcert | 38 ++++ dotfiles/cheat/mongodb | 28 +++ dotfiles/cheat/network | 15 ++ dotfiles/cheat/news | 3 + dotfiles/cheat/pass | 43 ++++ dotfiles/cheat/pdf | 4 + dotfiles/cheat/phpbrew | 1 + dotfiles/cheat/ping | 8 + dotfiles/cheat/pip | 34 ++++ dotfiles/cheat/pipy | 21 ++ dotfiles/cheat/poezio | 2 + dotfiles/cheat/ponghaum | 2 + dotfiles/cheat/ports | 9 + dotfiles/cheat/power | 6 + dotfiles/cheat/pypi | 10 + dotfiles/cheat/python | 63 ++++++ dotfiles/cheat/python_ressources | 20 ++ dotfiles/cheat/qemu | 14 ++ dotfiles/cheat/rename | 2 + dotfiles/cheat/rust | 51 +++++ dotfiles/cheat/scp | 8 + dotfiles/cheat/security | 2 + dotfiles/cheat/sharing_internet | 44 +++++ dotfiles/cheat/space | 2 + dotfiles/cheat/spark | 417 +++++++++++++++++++++++++++++++++++++++ dotfiles/cheat/ssh | 54 +++++ dotfiles/cheat/ssl | 3 + dotfiles/cheat/su | 5 + dotfiles/cheat/suda.vim | 20 ++ dotfiles/cheat/svg | 17 ++ dotfiles/cheat/symfony | 17 ++ dotfiles/cheat/system_ingo | 1 + dotfiles/cheat/systemd | 28 +++ dotfiles/cheat/tail | 17 ++ dotfiles/cheat/tar | 34 ++++ dotfiles/cheat/taskwarrior | 18 ++ dotfiles/cheat/testing_app | 43 ++++ dotfiles/cheat/timew | 3 + dotfiles/cheat/tips | 61 ++++++ dotfiles/cheat/tmux | 165 ++++++++++++++++ dotfiles/cheat/traduction | 2 + dotfiles/cheat/tty | 5 + dotfiles/cheat/urxvt | 29 +++ dotfiles/cheat/vagrant | 37 ++++ dotfiles/cheat/vim | 80 ++++++++ dotfiles/cheat/vpn | 7 + dotfiles/cheat/watch | 2 + dotfiles/cheat/web_debug | 2 + dotfiles/cheat/webfont | 17 ++ dotfiles/cheat/wifi | 2 + dotfiles/cheat/wordpress | 21 ++ dotfiles/cheat/zip | 7 + 79 files changed, 2096 insertions(+) create mode 100644 dotfiles/cheat/RAID create mode 100644 dotfiles/cheat/Xresources create mode 100644 dotfiles/cheat/acl create mode 100644 dotfiles/cheat/ansible create mode 100644 dotfiles/cheat/borg create mode 100644 dotfiles/cheat/cal create mode 100644 dotfiles/cheat/commands create mode 100644 dotfiles/cheat/convert create mode 100644 dotfiles/cheat/corm create mode 100644 dotfiles/cheat/cryptsetup create mode 100644 dotfiles/cheat/css create mode 100644 dotfiles/cheat/django create mode 100644 dotfiles/cheat/django-cms create mode 100644 dotfiles/cheat/django-oscar create mode 100644 dotfiles/cheat/djangocms create mode 100644 dotfiles/cheat/docker create mode 100644 dotfiles/cheat/find create mode 100644 dotfiles/cheat/gcc create mode 100644 dotfiles/cheat/git create mode 100644 dotfiles/cheat/help create mode 100644 dotfiles/cheat/history create mode 100644 dotfiles/cheat/iperf create mode 100644 dotfiles/cheat/irc create mode 100644 dotfiles/cheat/kraken create mode 100644 dotfiles/cheat/magnetico create mode 100644 dotfiles/cheat/mkcert create mode 100644 dotfiles/cheat/mongodb create mode 100644 dotfiles/cheat/network create mode 100644 dotfiles/cheat/news create mode 100644 dotfiles/cheat/pass create mode 100644 dotfiles/cheat/pdf create mode 100644 dotfiles/cheat/phpbrew create mode 100644 dotfiles/cheat/ping create mode 100644 dotfiles/cheat/pip create mode 100644 dotfiles/cheat/pipy create mode 100644 dotfiles/cheat/poezio create mode 100644 dotfiles/cheat/ponghaum create mode 100644 dotfiles/cheat/ports create mode 100644 dotfiles/cheat/power create mode 100644 dotfiles/cheat/pypi create mode 100644 dotfiles/cheat/python create mode 100644 dotfiles/cheat/python_ressources create mode 100644 dotfiles/cheat/qemu create mode 100644 dotfiles/cheat/rename create mode 100644 dotfiles/cheat/rust create mode 100644 dotfiles/cheat/scp create mode 100644 dotfiles/cheat/security create mode 100644 dotfiles/cheat/sharing_internet create mode 100644 dotfiles/cheat/space create mode 100644 dotfiles/cheat/spark create mode 100644 dotfiles/cheat/ssh create mode 100644 dotfiles/cheat/ssl create mode 100644 dotfiles/cheat/su create mode 100644 dotfiles/cheat/suda.vim create mode 100644 dotfiles/cheat/svg create mode 100644 dotfiles/cheat/symfony create mode 100644 dotfiles/cheat/system_ingo create mode 100644 dotfiles/cheat/systemd create mode 100644 dotfiles/cheat/tail create mode 100644 dotfiles/cheat/tar create mode 100644 dotfiles/cheat/taskwarrior create mode 100644 dotfiles/cheat/testing_app create mode 100644 dotfiles/cheat/timew create mode 100644 dotfiles/cheat/tips create mode 100644 dotfiles/cheat/tmux create mode 100644 dotfiles/cheat/traduction create mode 100644 dotfiles/cheat/tty create mode 100644 dotfiles/cheat/urxvt create mode 100644 dotfiles/cheat/vagrant create mode 100644 dotfiles/cheat/vim create mode 100644 dotfiles/cheat/vpn create mode 100644 dotfiles/cheat/watch create mode 100644 dotfiles/cheat/web_debug create mode 100644 dotfiles/cheat/webfont create mode 100644 dotfiles/cheat/wifi create mode 100644 dotfiles/cheat/wordpress create mode 100644 dotfiles/cheat/zip diff --git a/README.md b/README.md index a9f892c..7e64100 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ aria2 > aria2 deamon alacritty > terminal config + cheat > cheatsheets management i3pystatus > i3 bar window manager replacement config systemd > user services for differents application ``` diff --git a/config.yaml b/config.yaml index 827ab28..53cc3b8 100644 --- a/config.yaml +++ b/config.yaml @@ -15,6 +15,9 @@ dotfiles: d_systemd: src: config/systemd dst: ~/.config/systemd + d_cheat: + src: cheat + dst: ~/.cheat profiles: unicorn: dotfiles: @@ -22,6 +25,7 @@ profiles: - d_alacritty - d_aria2 - d_systemd + - d_cheat fenec: dotfiles: - d_i3pystatus diff --git a/dotfiles/cheat/RAID b/dotfiles/cheat/RAID new file mode 100644 index 0000000..87cc9af --- /dev/null +++ b/dotfiles/cheat/RAID @@ -0,0 +1,5 @@ +# Tool for get info on disks +lsscsi + +# If LSILOGIC use: +storcli diff --git a/dotfiles/cheat/Xresources b/dotfiles/cheat/Xresources new file mode 100644 index 0000000..1b31533 --- /dev/null +++ b/dotfiles/cheat/Xresources @@ -0,0 +1,2 @@ +# Update .Xresources file +xrdb -merge ~/.Xresources diff --git a/dotfiles/cheat/acl b/dotfiles/cheat/acl new file mode 100644 index 0000000..615c093 --- /dev/null +++ b/dotfiles/cheat/acl @@ -0,0 +1,2 @@ +# Modofy acl on a folder recusivly +setfacl -Rm u:neodarz:rxw diff --git a/dotfiles/cheat/ansible b/dotfiles/cheat/ansible new file mode 100644 index 0000000..13fce19 --- /dev/null +++ b/dotfiles/cheat/ansible @@ -0,0 +1,11 @@ +# Troubleshoutting + +When the error is "Operation not permitted" when "chown: changing ownership" you +just need to activate the following options in file `ansible.cfg`: + +``` +allow_world_readable_tmpfiles = True +pipelining = True +``` + +Source: https://stackoverflow.com/questions/47873671/becoming-non-root-user-in-ansible-fails?rq=1 diff --git a/dotfiles/cheat/borg b/dotfiles/cheat/borg new file mode 100644 index 0000000..c5747da --- /dev/null +++ b/dotfiles/cheat/borg @@ -0,0 +1,23 @@ +# init +borg init --encryption=repokey /path/to/repo + +# first commit +borg create /path/to/repo::Monday ~/src ~/Documents + +# update archive +borg create --stats /path/to/repo::Tuesday ~/src ~/Documents + +# For archive name with data instead of simple name +borg create /Backups/Docs_importants::{now:%Y-%m-%d-%H:%M:%S.%f} ~/Docs_importants + +# Example +borg create -C lzma,6 ~/Backups/Docs_importants::{now:%Y-%m-%d-%H:%M:%S.%f} ~/Docs_importants + +# Tips +borg save fullpath, so if already in subfolder, remove some leading path elements +with `strip-components`. Exemple: + +borg extract --strip-components 3 ~/Backups/Docs_importants::2018-07-01-13:29:05.247461 + +# compression +lz4 < zstd < zlib < lzma diff --git a/dotfiles/cheat/cal b/dotfiles/cheat/cal new file mode 100644 index 0000000..f28b348 --- /dev/null +++ b/dotfiles/cheat/cal @@ -0,0 +1,26 @@ +# Auto update all agandas + +## vdirsync + +Just enable user service vdirsyncer.timer +/!\ Update 5 min after start and 15min after first vdirsync update + +## ikhal + +Create a ikhal service with the following content: + +``` +[Unit] +Description=Update khal's cache +Documentation=man:khal(1) +After=vdirsyncer.service +RefuseManualStart=true + +[Service] +ExecStart=/usr/bin/khal +Type=oneshot +StandardOutput=null + +[Install] +WantedBy=vdirsyncer.service +``` diff --git a/dotfiles/cheat/commands b/dotfiles/cheat/commands new file mode 100644 index 0000000..97300f2 --- /dev/null +++ b/dotfiles/cheat/commands @@ -0,0 +1,24 @@ +# For start a comands without aliased arguments +\ + +# Moving in cli + + +----(1)----------------+----------(2)-----+ -+ + | +-(3)----------------+----------(4)-+ | |- Moving + v v (5)v-+-v(6) v v -+ +$ cp monfidefoudefoudefou[c]hieffffffffffr dir + <----------------(7)-+-(8)----------> -+ + |- Erasing + <-------------------(9)-+-(10)-------------> -+ + + +(1) => Ctrl+A : Move from cursor to start of line +(2) => Ctrl-E : Move from cursor to end of line +(3) => Ctrl-B : Move from cursor to start of word +(4) => Alt-F : Move from cursor to end of word +(5) => Ctrl-B : Move from cursor to previous char +(6) => Ctrl-F : Move from cursor to next char +(7) => Ctrl-w : Erase from cursor to the start of word +(8) => Alt-D : Erase from cursor to the end of word +(9) => Ctrl-U : Erase from cursor to the start of line +(10) => Ctrl-K : Erase from cursor to the end of line diff --git a/dotfiles/cheat/convert b/dotfiles/cheat/convert new file mode 100644 index 0000000..6e99e5b --- /dev/null +++ b/dotfiles/cheat/convert @@ -0,0 +1,22 @@ +# To resize an image to a fixed width and proportional height: +convert original-image.jpg -resize 100x converted-image.jpg + +# To resize an image to a fixed height and proportional width: +convert original-image.jpg -resize x100 converted-image.jpg + +# To resize an image to a fixed width and height: +convert original-image.jpg -resize 100x100 converted-image.jpg + +# To resize an image and simultaneously change its file type: +convert original-image.jpg -resize 100x converted-image.png + +# To resize all of the images within a directory: +# To implement a for loop: +for file in `ls original/image/path/`; + do new_path=${file%.*}; + new_file=`basename $new_path`; + convert $file -resize 150 conerted/image/path/$new_file.png; +done + +# Resize multi-image and blur it from .jpg to _tiny.jpg: +for file in $(ls .); do convert $(echo "$(echo $file | cut -f 1 -d '.').jpg") -resize 5% -blur 0x8 $(echo "$(echo $file | cut -f 1 -d '.')_tiny.jpg") ; done diff --git a/dotfiles/cheat/corm b/dotfiles/cheat/corm new file mode 100644 index 0000000..1e04cd5 --- /dev/null +++ b/dotfiles/cheat/corm @@ -0,0 +1 @@ +For start corm you MUST start apache AND postgresql. diff --git a/dotfiles/cheat/cryptsetup b/dotfiles/cheat/cryptsetup new file mode 100644 index 0000000..a5ccc69 --- /dev/null +++ b/dotfiles/cheat/cryptsetup @@ -0,0 +1,11 @@ +# open encrypted partition /dev/sdb1 (reachable at /dev/mapper/backup) +cryptsetup open --type luks /dev/sdb1 backup + +# open encrypted partition /dev/sdb1 using a keyfile (reachable at /dev/mapper/hdd) +cryptsetup open --type luks --key-file hdd.key /dev/sdb1 hdd + +# close luks container at /dev/mapper/hdd +cryptsetup close hdd + +# create encrypted disk +cryptsetup luksFormat --type luks2 /dev/sdd diff --git a/dotfiles/cheat/css b/dotfiles/cheat/css new file mode 100644 index 0000000..58c90b9 --- /dev/null +++ b/dotfiles/cheat/css @@ -0,0 +1,5 @@ +# Permet de dire que la taille est interne est pas externe, permet d'éviter de foutre le bordel... +``` +* { +box-sizing: border-box; +} diff --git a/dotfiles/cheat/django b/dotfiles/cheat/django new file mode 100644 index 0000000..97efafc --- /dev/null +++ b/dotfiles/cheat/django @@ -0,0 +1,50 @@ +# Make a migration +change model in models.py +python manage.py makemigrations +python manage.py migrate + +#Django source code +python -c "import django; print(django.__path__)" + +# Enable virtual env: +mkvirtualenv --python=/usr/bin/python3 oscar + +# Don't forget to install +pip install django + +# Run dev server +python manage.py runserver 127.0.0.1:8000 + +# tinymce for django +https://github.com/romanvm/django-tinymce4-lite + +# For create a .po file for translation +# first create a locale folder in module folder or edit LOCALE_PATH in conf file + +# run command for generate the file +django-admin makemessages -l fr + +# update the file if there are new translation +django-admin makemessages -l fr + +# compil translations files +django-admin compilemessages + +# Pour tester avec debug=False et manage.py runserver +source : https://stackoverflow.com/a/49722734 + +In urls.py I added this line: + +``` +from django.views.static import serve +``` + +add those two urls in urlpatterns: + +``` +url(r'^media/(?P.*)$', serve,{'document_root': settings.MEDIA_ROOT}), +url(r'^static/(?P.*)$', serve,{'document_root': settings.STATIC_ROOT}), +``` + +and both static and media files were accesible when DEBUG=FALSE. +Hope it helps :) diff --git a/dotfiles/cheat/django-cms b/dotfiles/cheat/django-cms new file mode 100644 index 0000000..72770b6 --- /dev/null +++ b/dotfiles/cheat/django-cms @@ -0,0 +1,9 @@ +# dep +- python3-dev +- virtualenvwrapper + +mkvirtualenv --python=/usr/bin/python3 oscar + +pip install djangocms-installer + +python manage.py runserver 0.0.0.0:8000 diff --git a/dotfiles/cheat/django-oscar b/dotfiles/cheat/django-oscar new file mode 100644 index 0000000..a4e00cd --- /dev/null +++ b/dotfiles/cheat/django-oscar @@ -0,0 +1,17 @@ +#Dep for stretch: +- libpq-dev +- python3-dev + +# for mkvirtualenv +- virtualenvwrapper + +# DONT FORGET DO UPGRADE PIP !!!! +pip3 install -U setuptools pip + +mkvirtualenv --python=/usr/bin/python3 oscar + +# for pillow +- libjpeg-dev +pip3 install pillow + +sandbox/manage.py runserver 0.0.0.0:8000 diff --git a/dotfiles/cheat/djangocms b/dotfiles/cheat/djangocms new file mode 100644 index 0000000..76c0826 --- /dev/null +++ b/dotfiles/cheat/djangocms @@ -0,0 +1,29 @@ +# Apphook theme integration + +This is maybe not the best way to do this but it's work. + +First doc is here : http://docs.django-cms.org/en/latest/introduction/05-apphooks.html + +(`.` is the root of the django-cms project) +(`myApp` is the django app to be ingreted to django-cms) + +Create another django app specialy for integrate the wanted django app. +(ex: `./myApp_cms_integration/`) + +For apply the theme you need, in the cms app create a folder, to create a +`templates` folder for the integrated django app. +(ex: `./myApp_cms_integration/templates/myApp/`) + +Copy the base.html template of myApp django app and modify the file with this +code: + +``` +{% extends "base.html" %} + +{% block apps %} +# Here come all the code from the base.html of myApp (In this example) +{% endblock %} +``` + +You also need to add somewhere in the template of the django-cms project +`{% block apps %}{% endblock %}`. diff --git a/dotfiles/cheat/docker b/dotfiles/cheat/docker new file mode 100644 index 0000000..591eba4 --- /dev/null +++ b/dotfiles/cheat/docker @@ -0,0 +1,35 @@ +# Start docker daemon +docker -d + +# start a container with an interactive shell +docker run -ti /bin/bash + +# "shell" into a running container (docker-1.3+) +docker exec -ti bash + +# inspect a running container +docker inspect (or ) + +# Get the process ID for a container +# Source: https://github.com/jpetazzo/nsenter +docker inspect --format {{.State.Pid}} + +# List the current mounted volumes for a container (and pretty print) +# Source: +# http://nathanleclaire.com/blog/2014/07/12/10-docker-tips-and-tricks-that-will-make-you-sing-a-whale-song-of-joy/ +docker inspect --format='{{json .Volumes}}' | python -mjson.tool + +# Copy files/folders between a container and your host +docker cp foo.txt mycontainer:/foo.txt + +# list currently running containers +docker ps + +# list all containers +docker ps -a + +# list all images +docker images + +IF: dpkg: error: error creating new backup file '/var/lib/dpkg/status-old': Invalid cross-device link E: Sub-process /usr/bin/dpkg returned an error code (2) +DO: echo N | sudo tee /sys/module/overlay/parameters/metacopy diff --git a/dotfiles/cheat/find b/dotfiles/cheat/find new file mode 100644 index 0000000..aecacbd --- /dev/null +++ b/dotfiles/cheat/find @@ -0,0 +1,50 @@ +# To find files by case-insensitive extension (ex: .jpg, .JPG, .jpG): +find . -iname "*.jpg" + +# To find directories: +find . -type d + +# To find files: +find . -type f + +# To find files by octal permission: +find . -type f -perm 777 + +# To find files with setuid bit set: +find . -xdev \( -perm -4000 \) -type f -print0 | xargs -0 ls -l + +# To find files with extension '.txt' and remove them: +find ./path/ -name '*.txt' -exec rm '{}' \; + +# To find files with extension '.txt' and look for a string into them: +find ./path/ -name '*.txt' | xargs grep 'string' + +# To find files with size bigger than 5 Mebibyte and sort them by size: +find . -size +5M -type f -print0 | xargs -0 ls -Ssh | sort -z + +# To find files bigger than 2 Megabyte and list them: +find . -type f -size +200000000c -exec ls -lh {} \; | awk '{ print $9 ": " $5 }' + +# To find files modified more than 7 days ago and list file information +find . -type f -mtime +7d -ls + +# To find symlinks owned by a user and list file information +find . -type l --user=username -ls + +# To search for and delete empty directories +find . -type d -empty -exec rmdir {} \; + +# To search for directories named build at a max depth of 2 directories +find . -maxdepth 2 -name build -type d + +# To search all files who are not in .git directory +find . ! -iwholename '*.git*' -type f + +# To find all files that have the same node (hard link) as MY_FILE_HERE +find . -type f -samefile MY_FILE_HERE 2>/dev/null + +# To find all files in the current directory and modify their permissions +find . -type f -exec chmod 644 {} \; + +# Find last edited files and ignore .DS_Store file and #recycle path (fuck mac) +find . -type f -not \( -iname ".DS_Store" -o -path "*#recycle*" \) -print0 | xargs -0 stat --format '%Y :%y %n' | sort -nr | cut -d: -f2- | head diff --git a/dotfiles/cheat/gcc b/dotfiles/cheat/gcc new file mode 100644 index 0000000..6c3e2f1 --- /dev/null +++ b/dotfiles/cheat/gcc @@ -0,0 +1,26 @@ +# Compile a file +gcc file.c + +# Compile a file with a custom output +gcc -o file file.c + +# Debug symbols +gcc -g + +# Debug with all symbols. +gcc -ggdb3 + +# Build for 64 bytes +gcc -m64 + +# Include the directory {/usr/include/myPersonnal/lib/} to the list of path for #include <....> +# With this option, no warning / error will be reported for the files in {/usr/include/myPersonnal/lib/} +gcc -isystem /usr/include/myPersonnal/lib/ + +# Build a GUI for windows (Mingw) (Will disable the term/console) +gcc -mwindows + +# Change gcc version (for exemple if not work with the last version test the old last) +# Do this before ./configure or make command +CC=gcc-6 +CXX=gcc-6 diff --git a/dotfiles/cheat/git b/dotfiles/cheat/git new file mode 100644 index 0000000..9fad2c3 --- /dev/null +++ b/dotfiles/cheat/git @@ -0,0 +1,165 @@ +# To set your identity: +git config --global user.name "John Doe" +git config --global user.email johndoe@example.com + +# To set your editor: +git config --global core.editor emacs + +# To enable color: +git config --global color.ui true + +# To stage all changes for commit: +git add --all + +# To stash changes locally, this will keep the changes in a separate changelist +# called stash and the working directory is cleaned. You can apply changes +# from the stash anytime +git stash + +# To stash changes with a message +git stash save "message" + +# To list all the stashed changes +git stash list + +# To apply the most recent change and remove the stash from the stash list +git stash pop + +# To apply any stash from the list of stashes. This does not remove the stash +# from the stash list +git stash apply stash@{6} + +# To commit staged changes +git commit -m "Your commit message" + +# To edit previous commit message +git commit --amend + +# Git commit in the past +git commit --date="`date --date='2 day ago'`" +git commit --date="Jun 13 18:30:25 IST 2015" +# more recent versions of Git also support --date="2 days ago" directly + +# To change the date of an existing commit +git filter-branch --env-filter \ + 'if [ $GIT_COMMIT = 119f9ecf58069b265ab22f1f97d2b648faf932e0 ] + then + export GIT_AUTHOR_DATE="Fri Jan 2 21:38:53 2009 -0800" + export GIT_COMMITTER_DATE="Sat May 19 01:01:01 2007 -0700" + fi' + +# To removed staged and working directory changes +git reset --hard + +# To go 2 commits back +git reset --hard HEAD~2 + +# To remove untracked files +git clean -f -d + +# To remove untracked and ignored files +git clean -f -d -x + +# To push to the tracked master branch: +git push origin master + +# To push to a specified repository: +git push git@github.com:username/project.git + +# To delete the branch "branch_name" +git branch -D branch_name + +# To make an exisiting branch track a remote branch +git branch -u upstream/foo + +# To see who commited which line in a file +git blame filename + +# To sync a fork with the master repo: +git remote add upstream git@github.com:name/repo.git # Set a new repo +git remote -v # Confirm new remote repo +git fetch upstream # Get branches +git branch -va # List local - remote branches +git checkout master # Checkout local master branch +git checkout -b new_branch # Create and checkout a new branch +git merge upstream/master # Merge remote into local repo +git show 83fb499 # Show what a commit did. +git show 83fb499:path/fo/file.ext # Shows the file as it appeared at 83fb499. +git diff branch_1 branch_2 # Check difference between branches +git log # Show all the commits +git status # Show the changes from last commit + +# Commit history of a set of files +git log --pretty=email --patch-with-stat --reverse --full-index -- Admin\*.py > Sripts.patch + +# Import commits from another repo +git --git-dir=../some_other_repo/.git format-patch -k -1 --stdout | git am -3 -k + +# View commits that will be pushed +git log @{u}.. + +# View changes that are new on a feature branch +git log -p feature --not master +git diff master...feature + +# Interactive rebase for the last 7 commits +git rebase -i @~7 + +# Diff files WITHOUT considering them a part of git +# This can be used to diff files that are not in a git repo! +git diff --no-index path/to/file/A path/to/file/B + +# To pull changes while overwriting any local commits +git fetch --all +git reset --hard origin/master + +# Update all your submodules +git submodule update --init --recursive + +# Perform a shallow clone to only get latest commits +# (helps save data when cloning large repos) +git clone --depth 1 + +# To unshallow a clone +git pull --unshallow + +# Create a bare branch (one that has no commits on it) +git checkout --orphan branch_name + +# Checkout a new branch from a different starting point +git checkout -b master upstream/master + +# Remove all stale branches (ones that have been deleted on remote) +# So if you have a lot of useless branches, delete them on Github and then run this +git remote prune origin + +# The following can be used to prune all remotes at once +git remote prune $(git remote | tr '\n' ' ') + +# Revisions can also be identified with :/text +# So, this will show the first commit that has "cool" in their message body +git show :/cool + +# Undo parts of last commit in a specific file +git checkout -p HEAD^ -- /path/to/file + +# Revert a commit and keep the history of the reverted change as a separate revert commit +git revert + +# Pich a commit from a branch to current branch. This is different than merge as +# this just applies a single commit from a branch to current branch +git cherry-pick + +# Remove fucking '^M' at each of end of line (where 'file_fucked' is the file who contains '^M' char and 'file_ok' is the same file without this fucking char +tr -d $'\r' < file_fucked > file_ok + +# Push to current branch to another branch +# Here push local master on remote dreamer_theme +git push origin master:dreamer_theme + +# Create bare repo shared +git init --bare --shared=group + +# This is maybe because type mistake ! +error: src refspec masster does not match any. +error: failed to push some refs to 'ssh://bcorentin@192.168.1.45:8766/volume1/GIT/django-omrii.git' diff --git a/dotfiles/cheat/help b/dotfiles/cheat/help new file mode 100644 index 0000000..fc1a497 --- /dev/null +++ b/dotfiles/cheat/help @@ -0,0 +1,10 @@ +# Get help without open webbrowser from simple to complet help +howdoi +bro <- not installed, bugged +tldr +eg +s <- search on internet +man-pages + +# Good buts just grep man-pages for use so => usless +https://www.explainshell.com diff --git a/dotfiles/cheat/history b/dotfiles/cheat/history new file mode 100644 index 0000000..24e49e4 --- /dev/null +++ b/dotfiles/cheat/history @@ -0,0 +1,10 @@ +# To see most used top 10 commands: +history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10 + +# List all command in zsh bash with human readble date +# Aliased to `history` ! +IFS=$'\n'; for line in $(cat ~/.zhistory); do echo $(date --rfc-3339=ns -d @$(echo $line | cut -d' ' -f2 | cut -d':' -f1 | grep -e "^[0-9]") | cut -d'.' -f1)" : "$(echo $line | cut -d' ' -f2- | cut -d';' -f2-); done + +# Get top command used +# Aliased to `historyt` ! +cat .zhistory | cut -d' ' -f2- | cut -d';' -f2- | awk '{CMD[$1]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10 diff --git a/dotfiles/cheat/iperf b/dotfiles/cheat/iperf new file mode 100644 index 0000000..5be0952 --- /dev/null +++ b/dotfiles/cheat/iperf @@ -0,0 +1 @@ +iperf3 -p 5200 -c ping.online.net ; iperf3 -p 5200 -c ping.online.net -R diff --git a/dotfiles/cheat/irc b/dotfiles/cheat/irc new file mode 100644 index 0000000..a19489a --- /dev/null +++ b/dotfiles/cheat/irc @@ -0,0 +1,5 @@ +# Search for me please +rm log.txt; for i in {8..0};do echo Getting log from $(date --date="$i day ago" +"%Y-%m-%d")...; curl -s "https://khaganat.net/irc/logs/%23khanat/%23khanat.$(date --date="$i day ago" +"%Y-%m-%d").log" >> log.txt; done; pseudo="neodarz"; cat log.txt | grep -v "<$pseudo" | grep "$pseudo" + +# Close a buffer +/close diff --git a/dotfiles/cheat/kraken b/dotfiles/cheat/kraken new file mode 100644 index 0000000..58b3bd1 --- /dev/null +++ b/dotfiles/cheat/kraken @@ -0,0 +1,3 @@ +# bitcoin + +echo $(clikraken bal | grep XBT | awk '{print $2}')"*"$(clikraken t | grep XBTEUR | awk '{print $2}') | bc diff --git a/dotfiles/cheat/magnetico b/dotfiles/cheat/magnetico new file mode 100644 index 0000000..5fb96bf --- /dev/null +++ b/dotfiles/cheat/magnetico @@ -0,0 +1,5 @@ +# Get size file discovered +size=0; for el in $(sqlite3 ~/.local/share/magneticod/database.sqlite3 "select size from files"); do ((size+=el)); done; echo $size | awk '{ byte =$1 /1024/1024/1024; print byte " GB" }' + +# Get torrent number +sqlite3 ~/.local/share/magneticod/database.sqlite3 "select count(*) from torrents" diff --git a/dotfiles/cheat/mkcert b/dotfiles/cheat/mkcert new file mode 100644 index 0000000..2b673c8 --- /dev/null +++ b/dotfiles/cheat/mkcert @@ -0,0 +1,38 @@ +# Generate certs for localhost + some addresses +mkcert -cert-file localhost.pem -key-file localhost.key.pem localhost $(/sbin/ip -4 -o addr | /usr/bin/awk '{gsub(/\/.*/,"",$4); print $4}' | /usr/bin/sed ':a;N;$!ba;s/\n/ /g') + +# Auto generate cert from current apache conf and current ip addresses + +#!/usr/bin/python3 +import re +from subprocess import call +import netifaces as ni +import shutil + +url = [] + +# Search for all servername enable in apache conf +file = open("/etc/httpd/conf/httpd.conf") +for line in file: + if re.search("^Include", line): + conf = open("/etc/httpd/"+line.split()[1]) + for conf_line in conf: + if re.search("^ ServerName", conf_line): + if conf_line.split()[1] not in url: + url.append(conf_line.split()[1]) + conf.close() +file.close() + +# Add localhost +if "localhost" not in url: + url.append("localhost") + +# Get all current ip +for interfaces in ni.interfaces(): + ip = ni.ifaddresses(interfaces)[ni.AF_INET][0]['addr'] + if ip not in url: + url.append(ip) + +call(["mkcert", "-cert-file", "localhost.pem", "-key-file", "localhost.key.pem"] + url) +shutil.move("localhost.pem", "/etc/ssl/certs/localhost.pem") +shutil.move("localhost.key.pem", "/etc/ssl/certs/localhost.key.pem") diff --git a/dotfiles/cheat/mongodb b/dotfiles/cheat/mongodb new file mode 100644 index 0000000..54b8652 --- /dev/null +++ b/dotfiles/cheat/mongodb @@ -0,0 +1,28 @@ +# Create user, don't forget to use the correct database +use +db.createUser({user:"root", pwd:"root", roles: ["readWrite"]}) + +# Create use in another database: +db.createUser({user:"admin", pwd:"vIhVPwy81sdf5fPt3a2", roles: [{role: "readWrite" , db: "madbtest"}]}) + +# mongoshell get schema collection +# Source: https://medium.com/@ahsan.ayaz/how-to-find-schema-of-a-collection-in-mongodb-d9a91839d992 + +function printSchema(obj, indent) { + for (var key in obj) { + if(typeof obj[key] != "function"){ //we don't want to print functions + var specificDataTypes=[Date,Array]; //specify the specific data types you want to check + var type = typeof obj[key]; + for(var i in specificDataTypes){ // looping over [Date,Array] + if(obj[key] instanceof specificDataTypes[i]){ //if the current property is instance of the DataType + type = specificDataTypes[i].name; //get its name + break; + } + } + print(indent, key, type) ; //print to console (e.g roles object is_Array) + if (typeof obj[key] == "object") { //if current property is of object type, print its sub properties too + printSchema(obj[key], indent + "\t"); + } + } + } +}; diff --git a/dotfiles/cheat/network b/dotfiles/cheat/network new file mode 100644 index 0000000..57a6016 --- /dev/null +++ b/dotfiles/cheat/network @@ -0,0 +1,15 @@ +# Get internet on virtual machine + +## Set ip + +``` +ip addr add 10.1.1.2/16 dev eth1 +ip link set eth1 up +``` + +## Set route + +``` +ip route add 192.168.1.0/24 dev eth0 +ip route add default via 192.168.1.254 +``` diff --git a/dotfiles/cheat/news b/dotfiles/cheat/news new file mode 100644 index 0000000..b2c170b --- /dev/null +++ b/dotfiles/cheat/news @@ -0,0 +1,3 @@ +# For get the news +haxor <- news from hacker news +newsboat (rssblog here) diff --git a/dotfiles/cheat/pass b/dotfiles/cheat/pass new file mode 100644 index 0000000..b45b586 --- /dev/null +++ b/dotfiles/cheat/pass @@ -0,0 +1,43 @@ +# Autotype: +autotype: user :tab pass :enter + +# check if pawned + +Python de Dropper: +``` +import urllib2 +import hashlib + +CLEAN = 0 +PWNED = 1 +ERROR = -1 + +def check_password(password): + m = hashlib.sha1() + m.update(password.encode('utf-8')) + hx = m.hexdigest().upper() + + headers = { + 'User-Agent': 'pass-check', + 'api-version' : '2' + } + + try: + req = urllib2.Request('https://api.pwnedpasswords.com/range/' + hx[:5], headers=headers) + response = urllib2.urlopen(req) + for line in response.read().splitlines(): + if hx[5:] == line.split(":")[0]: + return PWNED + return CLEAN + + except: + return ERROR + +if __name__ == '__main__': + if check_password("Password1") == PWNED: + print("PWNED !") + else: + print("MAYBE") +``` + +https://gitlab.com/darnir/pass-audit diff --git a/dotfiles/cheat/pdf b/dotfiles/cheat/pdf new file mode 100644 index 0000000..6190692 --- /dev/null +++ b/dotfiles/cheat/pdf @@ -0,0 +1,4 @@ +# convert to pdf +# security risc : https://bugs.archlinux.org/task/60580 because of https://bugs.archlinux.org/task/59778 +# for enable remove 'PDF' from : /etc/ImageMagick-7/policy.xml + diff --git a/dotfiles/cheat/phpbrew b/dotfiles/cheat/phpbrew new file mode 100644 index 0000000..cc6f98d --- /dev/null +++ b/dotfiles/cheat/phpbrew @@ -0,0 +1 @@ +mcrypt ne fonctionne qu'avec une version de php <= 7.1.x ! diff --git a/dotfiles/cheat/ping b/dotfiles/cheat/ping new file mode 100644 index 0000000..a50198b --- /dev/null +++ b/dotfiles/cheat/ping @@ -0,0 +1,8 @@ +# ping a host with a total count of 15 packets overall. +ping -c 15 www.example.com + +# ping a host with a total count of 15 packets overall, one every .5 seconds (faster ping). +ping -c 15 -i .5 www.example.com + +# test if a packet size of 1500 bytes is supported (to check the MTU for example) +ping -s 1500 -c 10 -M do www.example.com diff --git a/dotfiles/cheat/pip b/dotfiles/cheat/pip new file mode 100644 index 0000000..9b438ea --- /dev/null +++ b/dotfiles/cheat/pip @@ -0,0 +1,34 @@ +# Search for packages +pip search SomePackage + +# Install some packages +pip install SomePackage + +# Install some package in user space +pip install --user SomePackage + +# Upgrade some package +pip install --upgrade SomePackage + +# Output and install packages in a requirement file +pip freeze > requirements.txt +pip install -r requirements.txt + +# Show details of a package +pip show SomePackage + +# List outdated packages +pip list --outdated + +# Upgrade all outdated packages, thanks to http://stackoverflow.com/a/3452888 +pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U + +# Upgrade outdated packages on latest version of pip +pip list --outdated --format=freeze | cut -d = -f 1 | xargs -n1 pip install -U + +# Install specific version of a package +pip install -I SomePackage1==1.1.0 'SomePackage2>=1.0.4' + +# Best pratice to use pip +# source: https://linuxfr.org/users/oliver_h/journaux/quelques-bonnes-pratiques-python-pour-2019 +python3 -m pip diff --git a/dotfiles/cheat/pipy b/dotfiles/cheat/pipy new file mode 100644 index 0000000..e9744fb --- /dev/null +++ b/dotfiles/cheat/pipy @@ -0,0 +1,21 @@ +# Fist check if pbr package is installed (if use tag for set version) +pip install pbr + +# Install necessary package for compil +python -m pip install --user --upgrade setuptools wheel + +# Build the package +python setup.py sdist bdist_wheel + +# For upload install necessary package +pip install twine + +# upload new version of a package +pip install artedv_dl + +# upload on test server +twine upload --repository-url https://test.pypi.org/legacy/ dist/* + +# install from test server +python3 -m pip install --index-url https://test.pypi.org/simple/ example_pkg + diff --git a/dotfiles/cheat/poezio b/dotfiles/cheat/poezio new file mode 100644 index 0000000..8b713c7 --- /dev/null +++ b/dotfiles/cheat/poezio @@ -0,0 +1,2 @@ +# Refresh srv +/server_cycle diff --git a/dotfiles/cheat/ponghaum b/dotfiles/cheat/ponghaum new file mode 100644 index 0000000..98d9884 --- /dev/null +++ b/dotfiles/cheat/ponghaum @@ -0,0 +1,2 @@ +sudo socat /dev/ttyACM0,b115200 - | tee /tmp/a | ./livehex +tail -f /tmp/a diff --git a/dotfiles/cheat/ports b/dotfiles/cheat/ports new file mode 100644 index 0000000..e7ac9a7 --- /dev/null +++ b/dotfiles/cheat/ports @@ -0,0 +1,9 @@ +#Trouver un port sans utiliser internet mais le système linux installé +#/etc/services Liste les ports par defauts utilisé + +# Pour avoir des infos sur les entrées de tels ou tels service +# La configuration ce trouve: /etc/nsswitch.conf +getent +# Ex: +getent services 80 + diff --git a/dotfiles/cheat/power b/dotfiles/cheat/power new file mode 100644 index 0000000..51fb4c4 --- /dev/null +++ b/dotfiles/cheat/power @@ -0,0 +1,6 @@ +# Close laptoper cover/lip + +in file /etc/systemd/logind.conf + +#HandleLidSwitch=suspend +HandleLidSwitch=ignore diff --git a/dotfiles/cheat/pypi b/dotfiles/cheat/pypi new file mode 100644 index 0000000..04c11ad --- /dev/null +++ b/dotfiles/cheat/pypi @@ -0,0 +1,10 @@ +More about packaging: +https://packaging.python.org/tutorials/packaging-projects/ + +# generated package + +python setup.py sdist bdist_wheel + +# upload package + +python -m twine upload dist/* diff --git a/dotfiles/cheat/python b/dotfiles/cheat/python new file mode 100644 index 0000000..7c8f0b2 --- /dev/null +++ b/dotfiles/cheat/python @@ -0,0 +1,63 @@ +# Desc: Python is a high-level programming language. + +# Basic example of server with python +# Will start a Web Server in the current directory on port 8000 +# go to http://127.0.0.1:8000 + +# Python v2.7 +python -m SimpleHTTPServer +# Python 3 +python -m http.server 8000 + +# SMTP-Server for debugging, messages will be discarded, and printed on stdout. +python -m smtpd -n -c DebuggingServer localhost:1025 + +# Pretty print a json +python -mjson.tool + +# Generate requirements.txt +pipreqs /path/to/project + +# Tips +# Ressources available in : cheat python_ressources + +Input: décoder avec `decode()`. +Output: encoder avec `encode('utf-8')` + +lors de l'ouverture d'un fichier: +``` +from codecs import open + +# open() de codec à exactement la même API, y compris avec "with" +f = open('fichier', encoding='encoding') +``` + +# Types + +bytes == bytearray + +# non mutable (non modifiable) +bytes +tuple + +# mutable (modifiable) +bytearray + +# For bytes and bytearray show hex value of each char +[hex(i) for i in header] + +# For string show hex value of each char +[hex(ord(c)) for c in header] + +# Opencv with gstreamer +# Gstreamer not on pipy but present when building... + +git clone --recursive https://github.com/skvark/opencv-python.git +git checkout -b 25 +ENABLE_CONTRIB=ON python setup.py install + +# package developement + +virtualenv .venv_dev +source .venv_dev/bin/activate +pip install -e . # for install package in dev mode diff --git a/dotfiles/cheat/python_ressources b/dotfiles/cheat/python_ressources new file mode 100644 index 0000000..cf8a350 --- /dev/null +++ b/dotfiles/cheat/python_ressources @@ -0,0 +1,20 @@ +# Python + +## Encoding python +http://sametmax.com/lencoding-en-python-une-bonne-fois-pour-toute/ + +## Prog par contre +http://sametmax.com/programmation-par-contrat-avec-assert/ + +## Critique ORM +http://sametmax.com/les-critiques-des-orm-sont-a-cote-de-la-plaque/ + +# For python > 3.8 + +## Expression designation +http://sametmax.com/lexpression-dassignation-vient-detre-acceptee/ + +# Version resumy + +## Python 3.7 +http://sametmax.com/python-3-7-sort-de-sa-coquille/ diff --git a/dotfiles/cheat/qemu b/dotfiles/cheat/qemu new file mode 100644 index 0000000..f749c29 --- /dev/null +++ b/dotfiles/cheat/qemu @@ -0,0 +1,14 @@ +# Prepare folder for images + +mkdir ~/.qemu_imgs + +# Creating hard disk + +qemu-img create -f qcow2 ~/.qemu_imgs/image_file.cow 4G + +# Install operating system + +qemu-system-x86_64 -cdrom ~/Download/image.iso -boot order=d -drive file=/home//.qemu_imgs/image_file.cow,format=qcow2 + +tips: Get the mouse after grabbed by qemu: Ctrl+Alt+g + diff --git a/dotfiles/cheat/rename b/dotfiles/cheat/rename new file mode 100644 index 0000000..46a017c --- /dev/null +++ b/dotfiles/cheat/rename @@ -0,0 +1,2 @@ +# Lowercase all files and folders in current directory +rename 'y/A-Z/a-z/' * diff --git a/dotfiles/cheat/rust b/dotfiles/cheat/rust new file mode 100644 index 0000000..41406ca --- /dev/null +++ b/dotfiles/cheat/rust @@ -0,0 +1,51 @@ +# Raw identifier + +Nommé (identifié en rust) un concept (variable, fonction) qui est le meme mots +qu'un mot clé rust: `r#`. + +# Shadow + +Fait de utilier la meme variable mais de le redacler. +Il faut utiliser cette méthode au lorsque que l'on soite changer le type d'une +variable mutable. + +Faire: +let spaces = " "; +let spaces = spaces.len() + +Ne pas faire: +let mut spaces = " "; +spaces = spaces.len() + +# scalar types + +Un type scalaire representer une seul veleur. + +- Integer (Signé et non-signé) +- Integer Literals (Decimal/Hex/Octal/Binary/Byte(u8)) +- Floating-Point (Float) +- Numeric Operation (Pas un type mais mis dedans ds le livres...) +- Boolean `let t = true` ou `let f: bool = false` +- Character (`char` type specified with single quotes) +- String (`string` type specified with double quotes) + +# Compound type + +Un type "compound" regroupe différent type de valeurs en une seul. + +- Tuple (multi type) ex: (1, 'z', 0.9) +- Array (same type) ex: [1, 2, 3] + +# outils + +voir pour `rustup` pour gérer cargo + +# components + +## clippy + +linter permer de donner des conseils en plus du compilateur + +## format + +permet de suivre les convetions de style diff --git a/dotfiles/cheat/scp b/dotfiles/cheat/scp new file mode 100644 index 0000000..0a632ec --- /dev/null +++ b/dotfiles/cheat/scp @@ -0,0 +1,8 @@ +# To copy a file from your local machine to a remote server: +scp foo.txt user@example.com:remote/dir + +# To copy a file from a remote server to your local machine: +scp user@example.com:remote/dir/foo.txt local/dir + +# Option for select port +-P diff --git a/dotfiles/cheat/security b/dotfiles/cheat/security new file mode 100644 index 0000000..0adb41f --- /dev/null +++ b/dotfiles/cheat/security @@ -0,0 +1,2 @@ +# `maybe` command can be used for test script +maybe