diff options
author | neodarz <neodarz@neodarz.net> | 2019-09-05 07:05:07 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2019-09-05 07:05:07 +0200 |
commit | e0c0d4b38cde20e2300e86b69414dd9851b47456 (patch) | |
tree | 5df65243447352a9637d1f783247bfd5ccff2ef4 /dotfiles/cheat | |
parent | dc45bf89a66ec6c8cd25cf5605deb853f6984705 (diff) | |
download | dotfiles_dotdrop-e0c0d4b38cde20e2300e86b69414dd9851b47456.tar.xz dotfiles_dotdrop-e0c0d4b38cde20e2300e86b69414dd9851b47456.zip |
ooo
Diffstat (limited to 'dotfiles/cheat')
77 files changed, 2091 insertions, 0 deletions
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 <dir> 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 +\<command> + +# 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 <filename>.jpg to <filename>_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<path>.*)$', serve,{'document_root': settings.MEDIA_ROOT}), +url(r'^static/(?P<path>.*)$', 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 <image_name> /bin/bash + +# "shell" into a running container (docker-1.3+) +docker exec -ti <container_name> bash + +# inspect a running container +docker inspect <container_name> (or <container_id>) + +# Get the process ID for a container +# Source: https://github.com/jpetazzo/nsenter +docker inspect --format {{.State.Pid}} <container_name_or_ID> + +# 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}}' <container_id> | 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 <commit SHA> | 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 <remote-url> + +# 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 <commit SHA> + +# 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 <commit SHA1> + +# 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 <string> <- 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') <addresses> + +# 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_name> +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 +<policy domain="coder" rights="none" pattern="{PS,PS2,PS3,EPS,PDF,XPS}" /> 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 <same syntax as above> 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/<user>/.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#<identifieur>`. + +# 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 <port> 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 <script> diff --git a/dotfiles/cheat/sharing_internet b/dotfiles/cheat/sharing_internet new file mode 100644 index 0000000..8dca3b5 --- /dev/null +++ b/dotfiles/cheat/sharing_internet @@ -0,0 +1,44 @@ +# First connect machines ! + +# Enable port fowrading +sysctl net.ipv4.ip_forward=1 + +# fowrwarding Wifi -> Ethernet +iptables -t nat -A POSTROUTING -o internet0 -j MASQUERADE +iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT +iptables -A FORWARD -i net0 -o internet0 -j ACCEPT + +# First setup of device +sudo ip link set up dev enp0s25 +sudo ip addr add 192.168.2.100/24 dev enp0s25 # arbitrary address + +# /etc/dhcpd.conf +option domain-name-servers 80.67.169.12, 80.67.169.40; +option subnet-mask 255.255.255.0; +option routers 192.168.4.100; +subnet 192.168.4.0 netmask 255.255.255.0 { + range 192.168.4.150 192.168.4.250; + + host fenec { + hardware ethernet 5c:ff:35:09:ac:6a; + fixed-address 192.168.4.100; + } + +} + +# Service +# /etc/systemd/system/dhcpd4@.service +[Unit] +Description=IPv4 DHCP server on %I +Wants=network.target +After=network.target + +[Service] +Type=forking +PIDFile=/run/dhcpd4.pid +ExecStart=/usr/bin/dhcpd -4 -q -pf /run/dhcpd4.pid %I +KillSignal=SIGINT + +[Install] +WantedBy=multi-user.target + diff --git a/dotfiles/cheat/space b/dotfiles/cheat/space new file mode 100644 index 0000000..b3d11c5 --- /dev/null +++ b/dotfiles/cheat/space @@ -0,0 +1,2 @@ +# List all file who are 3 digit and follow by M like 300M +du -sh ~/Downloads/* | grep -P "^[0-9]{3}M.*" diff --git a/dotfiles/cheat/spark b/dotfiles/cheat/spark new file mode 100644 index 0000000..62b1dd4 --- /dev/null +++ b/dotfiles/cheat/spark @@ -0,0 +1,417 @@ +Got any wicked cool usage of spark up your sleeve? Drop your code snippets here. + +### Add a sparkline "header" to your terminal ([@jaybosamiya](https://github.com/jaybosamiya/)) + +Shows a random sparkline at the top of your terminal each time you clear. Use the `lolcat` version if you want a rainbow coloured line + +```sh +alias clear='clear; echo; echo; seq 1 $(tput cols) | sort -R | spark; echo; echo' # Non coloured +alias clear='clear; echo; echo; seq 1 $(tput cols) | sort -R | spark | lolcat; echo; echo' # Coloured +``` + +### Display precipitation data from [forecast.io](http://forecast.io) ([@davidcelis](https://github.com/davidcelis/)) + +Show the intensity of oncoming precipitation for the next hour. This requires an [API Key for forecast.io](http://developer.forecast.io), as well as `jq` and `whereami` (`brew install jq whereami`). + +```sh +curl -Ss https://api.forecast.io/forecast/$FORECAST_API_KEY/$(whereami) | + jq ".minutely.data[].precipIntensity * 1000" | + spark +▅▇█▆▄▃▃▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ +``` + +### Display stock data for S&P 500 ([@arawde](https://github.com/arawde)) +You can replace ^GPSC with other symbols (GOOG, etc), and it should work the same. -A 31 gets one month after given date. Dividing field 5 by varying numbers scales the graph to more readable form. +```sh +curl http://www.optiontradingtips.com/resources/historical-data/sp500/%5EGSPC.TXT --silent | + grep "20100331" -A 31 | + awk -F' ' '{print $5/20}' | + spark +``` +### Record how much time you spend on daily practice (guitar, etc.) ([@dbalatero](https://github.com/dbalatero)) + +Add this script to your `$PATH`: https://gist.github.com/dbalatero/6443380 + +```sh +practice record 120 # 2 hours, today +practice | spark # dump out graph +``` + +### Number of commits in a repo, by author ([@holman](https://github.com/holman)) +```sh +git shortlog -s | + cut -f1 | + spark +``` + +### Number of commits in a repo, by author, over time plus consistent scaling ([@kablamo](https://github.com/kablamo)) + +Usually, you cannot compare spark graphs, because the scale not consistent between any two graphs. [git-spark](https://github.com/kablamo/git-spark) solves this problem with its --scale option. + + git spark --days 14 Stegosaurus + Commits by Stegosaurus over the last 14 days + total: 95 avg: 7 max: 23 + 10 15 6 23 5 0 0 1 15 0 17 3 0 0 + ▄▅▂█▂▁▁▁▅▁▆▁▁▁ + +### Total run time of processes ([@daveycrockett](https://github.com/daveycrockett)) +```bash +ps -e | + tail -n +2 | + cut -c 16-23 | + sed -e "s/$/))))/" -e "s/:/ + (60 * (/" -e "s/:/ + (60 *(/" | + bc | + spark +``` + +### Letter frequencies in a text file ([@daveycrockett](https://github.com/daveycrockett)) +```bash +cat <file> | + awk -vFS="" '{for(i=1;i<=NF;i++){ if($i~/[a-zA-Z]/) { w[tolower($i)]++} } }END{for(i in w) print i,w[i]}' | + sort | + cut -c 3- | + spark +``` + +### Users' login time since last reboot ([@ghedamat](https://github.com/ghedamat)) + +```bash + # get users for a specific group + # needs to be improved + users=$(getent group uquota | cut -d ':' -f 4 | tr ',' '\n') + gr="" + for i in $users + do + gr="$gr$(last | sort | grep $i | cut -c 67-71 | tr ":" " " | awk 'BEGIN {sum=0; } {sum += $1*60+$2; } END { print sum}')," + done + spark $gr +``` + +### Number of HTTP requests per day ([@Eyjafjallajokull](https://github.com/Eyjafjallajokull)) + +```bash +cat /var/log/nginx/access.log | + cut -d\ -f 4 | + cut -d/ -f 1 | + uniq -c | + awk '{print $1}'| + spark +``` + +### Histogram of commits throughout the day by author ([@vrish88](https://github.com/vrish88)) +```bash +git log --pretty=format:'%an: %at' --author="Bob" | + awk '{system("date -r "$NF" '+%H'")}' | + sort | + uniq -c | + ruby -e 'puts STDIN.readlines.inject(Hash[Array("00".."23").map{|x| [x,0]}]) {|h, x| h.merge(Hash[*x.split(" ").reverse])}.sort.map(&:last)' | + spark +``` + +### Visualize your hg commit history ([@sunng87](https://github.com/sunng87)) + +I wrote a [hg extension](https://gist.github.com/1366606) to aggregate commits by week and generate summary for spark. + +```bash +hg summary | spark +``` + +### Silly example of random data +```bash +seq 0 100 | sort -R | spark +``` + +### Print a Git participation graph of last 52 weeks like in GitHub ([@shurizzle](https://github.com/shurizzle)) +```ruby +#!/usr/bin/env ruby + +require 'ruby-let' + +class Time + def week + strftime('%U').to_i + end +end + +puts IO.popen('spark', 'w+') {|f| + f.write Time.now.let {|now, min=(now - 31536000)| + `git log --pretty=format:'%an: %at'`.split(/\r?\n/).map {|line| + Time.at(line.split(' ').last.to_i).let {|c| + ((c.year == min.year && c.week >= min.week) || (c.year == now.year && c.week <= now.week)) ? c : nil + } + }.compact.group_by {|x| x.strftime('%G%U') }.inject({}) {|res, (k, v)| + res[k] = v.size + res + }.let {|act| + (0...52).map {|i| + act[(min + 604800 * i).strftime('%G%U')] || 0 + }.join(',') + } + } + f.close_write + f.read +} +``` + +### Beijing Air Quality Index, PM2.5 ([@freewizard](https://github.com/freewizard), updated by [@djbender](https://github.com/djbender)) +#### Note: No longer working, because the Twitter v1 API is no longer active. +```bash +curl -s https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=beijingair | + grep /description | + perl -nle "print \$1 if /PM2.5;[^;]+; (\d+)/" | spark +``` + +### One more Git related: commits for last 2 weeks +```bash +for day in $(seq 14 -1 0); do + git log --before="${day} days" --after="$[${day}+1] days" --format=oneline | + wc -l +done | spark +``` + +### (Based on above) Git commits over the last 8 hours for a given author (~ today's activity) ([@trisweb](https://github.com/trisweb)) +```sh +for hour in $(seq 8 -1 0); do + git log --author "Author Name" --before="${hour} hours" --after="$[${hour}+1] hours" --format=oneline | + wc -l; +done | spark +``` + +### Changes in LOC per Git commit ([@eush77](https://github.com/eush77)) + +```sh +git log --stat |ack '^ \d' |cut -f5,7 -d' ' |tr ' ' '+' |bc |tac |spark +``` + +### Visualize filesize inside a directory([@lemen](https://github.com/lemen)) +```bash + du -BM * | + cut -dM -f1 | + spark +``` + +### Animation and colors with [Lolcat](https://github.com/busyloop/lolcat) ([@secondplanet](https://github.com/secondplanet)) + +```bash +spark 1 18 9 4 10 | lolcat -p 0.5 # Colored graph +spark 1 18 9 4 10 | lolcat -a # Animated rainbow graph +``` + +### Visualize users created by week on a rails project [Caleb Thompson](https://github.com/calebthompson) +```bash + bundle exec rails r "User.all.group_by{|u| u.created_at.strftime('%W')}.sort.each{|w,u| puts u.count}" | + spark +``` + +### WiFi link quality ([@cryptix](https://github.com/cryptix)) +```bash + if [ $(ifconfig wlan0 | grep UP | wc -l) -eq 1 ] + then + _linkQual="`iwconfig wlan0 | grep Quality | cut -d'=' -f2 | cut -d' ' -f1 | cut -d'/' -f1`" + + if [ $_linkQual -gt 52 ] # >75% link qual + then + _linkSparked=$(spark 1 2 3 4) + elif [ $_linkQual -gt 35 ] # >50% link qual + then + _linkSparked=$(spark 1 2 3 0) + elif [ $_linkQual -gt 17 ] # 25% link qual + then + _linkSparked=$(spark 1 2 0 0) + elif [ $_linkQual -gt 7 ] # 25% link qual + then + _linkSparked=$(spark 1 0 0 0) + else # < 25% + _linkSparked=$(spark 0 0 0 0) + fi + + echo $_linkSparked + fi +``` + +### Load average ([@tsujigiri](https://github.com/tsujigiri)) + +```bash +echo "$(cat /proc/loadavg | cut -d ' ' -f 1-3) $(egrep -c '^processor' /proc/cpuinfo)00 0" | sed 's/\(0\.\|0\.0\|\.\)//g' | spark | tail -n 1 | cut -b 1-9 +``` + +### Load history from `atop` + +``` +atop -P CPL -b 16:00 -e 18:00 -r /var/log/atop/atop_20130215 | + grep -v SEP | + awk '{print $8}' | + spark +``` +### Memory usage ([@tsujigiri](https://github.com/tsujigiri)) + +```bash +total=$(grep 'MemTotal' /proc/meminfo | egrep -o '[0-9]+') +not_apps=0 +for mem in $(egrep '(MemFree|Buffers|Cached|Slab|PageTables|SwapCached)' /proc/meminfo | egrep -o '[0-9]+'); do + not_apps=$((not_apps+mem)) +done +spark $((total-not_apps)) $total 0 | tail -n 1 | cut -b 1-3 +``` + +### Current SVN status in your prompt ([Evan Powell](https://github.com/epowell)) +svnstatgraph.sh: +```bash +if [ -d .svn ]; then + GRAPH=`svn stat | awk '{ split($0, a, " ") arr[a[1]]++ }END{ print arr["M"] ? arr["M"] : "0", arr["A"] ? arr["A"] : "0", arr["?"] ? arr["?"] : "0", arr["D"] ? arr["D"] : "0", arr["!"] ? arr["!"] : "0" }' | spark` + # More descriptive prompt: + #echo "[MA?D!|$GRAPH]" + echo "[$GRAPH]" +fi +``` + +~/.bashrc: +```bash +PS1 = '<your_prompt_here>`svnstatgraph.sh`\$' +``` + + +### Visualize bubble sort ([@onesuper](https://github.com/onesuper)) +``` +#!/bin/bash + +array=(4 3 2 5 1) +arrayLen=${#array[@]} + +for ((j=0; j<$arrayLen-1; j++)); do + for ((i=0; i<$arrayLen-$j-1; i++)); do + if [ "${array[$i]}" -gt "${array[$i+1]}" ]; then + temp=${array[$i]} + array[$i]=${array[$i+1]} + array[$i+1]=$temp + fi + spark ${array[@]} + done + echo '---------------------' +done +``` + +### Visualize ping times ([@jnovinger](https://github.com/jnovinger)) +```ping -c 10 google.com | tee >(grep "bytes from" | cut -d " " -f 8 | cut -d "=" -f 2 | spark)``` + +Or perhaps +```ping -c 10 google.com | tee >(grep -oP 'time=\K\S*' | spark)``` + +### Show ping times to a bunch of hosts with [fping](https://github.com/schweikert/fping) ([@joshuar](https://github.com/joshuar)) + +```fping -C 5 -q google.com gmail.google.com drive.google.com plus.google.com 2>&1 | awk '{print int($3)}' | xargs spark``` + +### Show stats of commits per day by given author ([@kstep](https://github.com/kstep)) +```git log --author="Author Name" --format=format:%ad --date=short | uniq -c | awk '{print $1}' | spark``` + +### Disk file usage ([@gfelisberto](https://twitter.com/gfelisberto)) +```df -P -x devtmpfs -x tmpfs | grep dev | awk '{print $5}' | sed s'/.$//' | spark``` + +### Hourly wind speed data from an NOAA buoy, by author ([@efg34](https://github.com/efg34)) +```curl -s http://www.ndbc.noaa.gov/station_page.php?station=wpow1 | grep "<tr bgcolor=\"#f" | awk -F\<td\> '{print $6}' | cut -c -5 | spark``` + +### Weather via http://openweathermap.org ([@leoboiko](https://github.com/leoboiko)) + +```bash +#!/bin/bash +# dumb json "parsing", could be better with jshon or similar +city="São Paulo,BR" # city="$1" +cityid=$(wget -q -O - "http://openweathermap.org/data/2.1/find/name?q=$city" \ + | python -mjson.tool \ + | sed -n -e 's/.*\<id.: *\([0-9]*\).*/\1/p' \ + | head -n 1) + + +wget -q -O - "http://openweathermap.org/data/2.1/history/city/?id=$cityid&cnt=80" \ + | python -mjson.tool \ + | sed -n -e "s/.*\<temp.: *\\(([0-9.]*\)).*/\1/p" \ + | spark +``` + + +### Zabbix API history graph results ([@christianchristensen](https://github.com/christianchristensen)) + +(more info: https://gist.github.com/christianchristensen/7406950) + +```bash +curl -s -H 'Content-type: application/json' https://www.zabbix.org/zabbix/api_jsonrpc.php -d '{ "jsonrpc": "2.0", "method": "history.get", "params":{ "output":"extend", "history":0, "time_from":"1384134836", "time_till":"1384138446", "itemids":["16"] }, "id": 123,"auth":"ac905749516dd173668f3dbf7b0cac0a" }' \ +| grep -o "\"value\":\"[0-9\.]*\"," \ +| awk -F\" '{print $4*100}' \ +| spark +▃▄▃▂▃▂▁▁▃▃▂▂▂▁▂▁▄▂▄▄▃▁▂▂▂▂█▇▅▃▂▂▃▂▃▂▁▁▁▅▅▆▄▂▁▁▂▄▄▂▄▂▁▁▃▁▂▂▁▁ +``` + +### A moving wave through the terminal ([@lemen](https://github.com/lemen)) + +```bash +function sine_wave() { + + i=0 + while true + do + SIN=$(python -c "from math import *;print map( lambda x: ceil(6*sin((x+$i)*pi/5)), range($(tput cols)) )" | tr -d '[]' | spark) + echo -ne $SIN\\r + let i=i+1 + sleep 0.05 + done + echo +} +``` + +### UptimeRobot response time ([@dlc](https://github.com/dlc)) +```bash +$ curl -sS "http://api.uptimerobot.com/getMonitors?apiKey=${UPTIMEROBOT_TOKEN}&format=xml&responseTimes=1&monitors=${MON_ID}" | \ + xmllint --xpath '//responsetime/@value' - | \ + tr -c '0-9 ' "\n" | \ + grep -v "^$" | \ + head -n $COLUMNS | \ + spark +▃▇▁▂▄▃▂▂▅▁▂█▃▂▃▃▃▁▂▂▃▂▅▁▁▁▃▂▁▃▂▁▄▁▁▃▂▆▁▃▃▃▁▁▃▁▁▂▄▅▅▄▂▂▃▁▄▂▃▁ + +``` + +### Bitcoin value over the last 24 hours ([@monkeyinmysoup](https://gist.github.com/monkeyinmysoup)) + +Python script in [this Gist](https://gist.github.com/monkeyinmysoup/ce0b28ef337aec01d1ea). + + +### Keen IO [open data set](https://github.com/keenlabs/open-data-collectors) visualization ([@dzello](https://github.com/dzello)) + +``` +# Bitcoin value over the last 30 minutes +$ gem install keen-cli +$ keen average \ + --project 53f3a8687d8cb95095000001 \ + --collection bitcoin-prices \ + --target-property "USD.averages.last" \ + --timeframe last_30_minutes \ + --interval minutely \ + --read-key 99a06e48fd7fb1279bc40995160eb0b61a9e0efaab8b651b029f0d895f77c0a804ba089282eff28bf8ad07f337422441d0542b7feaac9fea1e92fc153ee7efc51afad3276bda8d7754a338b349d540bfb402cba0dfdc82498c217054efd8abd0f47a0c0bc963bbdf0dc938c91b17d9f2 \ + --spark | spark +▁▂▂▂▂▂▂▂▁▁▁▂▂▂▂▄▄▂▂▄▄▂▂▄▆█████ +``` + +### Visualize streaming data with a scrolling spark line.([@iandow)](https://github.com/iandow) +Save this script as scroll.sh and invoke with `./scroll.sh datafile`. + +``` +#!/bin/bash +while true; do + printf "%${COLUMNS}s" + echo -ne "\r" + tail -n $(tput cols) $1 | spark | tr -d "\n" + echo -ne "\r" + sleep 1 +done +``` + + +### Monitor Bitcoin price ([@overtorment](https://github.com/overtorment/)) + +Monitor Bitcoin price in hourly popups via crontab + +```sh +1 * * * * curl https://www.bitstamp.net/api/v2/ticker/btcusd/ 2>/dev/null | sed 's/\,/\n/g' | grep last | awk -F':' '{print $2}' | sed 's/\"//g' >> ~/btcusd +2 * * * * export DISPLAY=:0; cat ~/btcusd | tail -n 23 | /usr/local/bin/spark | xargs /usr/bin/notify-send -t 30000 "btc/usd change graph (hourly)" +``` + diff --git a/dotfiles/cheat/ssh b/dotfiles/cheat/ssh new file mode 100644 index 0000000..d667af4 --- /dev/null +++ b/dotfiles/cheat/ssh @@ -0,0 +1,54 @@ +# To ssh via pem file (which normally needs 0600 permissions): +ssh -i /path/to/file.pem user@example.com + +# To connect on an non-standard port: +ssh -p 2222 user@example.com + +# To connect and forward the authentication agent +ssh -A user@example.com + +# To execute a command on a remote server: +ssh -t user@example.com 'the-remote-command' + +# To tunnel an x session over SSH: +ssh -X user@example.com + +# Redirect traffic with a tunnel between local host (port 8080) and a remote +# host (remote.example.com:5000) through a proxy (personal.server.com): +ssh -f -L 8080:remote.example.com:5000 user@personal.server.com -N + +# To launch a specific x application over SSH: +ssh -X -t user@example.com 'chromium-browser' + +# To create a SOCKS proxy on localhost and port 9999 +ssh -D 9999 user@example.com + +# -X use an xsession, -C compress data, "-c blowfish" use the encryption blowfish +ssh user@example.com -C -c blowfish -X + +# For more information, see: +# http://unix.stackexchange.com/q/12755/44856 + +# Copy files and folders through ssh from remote host to pwd with tar.gz compression +# when there is no rsync command available +ssh user@example.com "cd /var/www/Shared/; tar zcf - asset1 asset2" | tar zxf - + +# Mount folder/filesystem through SSH +# Install SSHFS from https://github.com/libfuse/sshfs +# Will allow you to mount a folder securely over a network. +sshfs name@server:/path/to/folder /path/to/mount/point + +# Emacs can read file through SSH +# Doc: http://www.gnu.org/software/emacs/manual/html_node/emacs/Remote-Files.html +emacs /ssh:name@server:/path/to/file + +# Generate ssh key +ssh-keygen -t rsa -C "your_email@example.com" -P "" -q -f ~/.ssh/gitlab_rsa + +# ed25519 key +# Added in OpenSSH 6.5 +ssh-keygen -t ed25519 + +ssh-keygen -t ed25519 -C "user@example.com" -q -f ~/.ssh/user@example.com + +ssh-copy-id -i ~/.ssh/id_dsa.pub user@machine diff --git a/dotfiles/cheat/ssl b/dotfiles/cheat/ssl new file mode 100644 index 0000000..f89777e --- /dev/null +++ b/dotfiles/cheat/ssl @@ -0,0 +1,3 @@ +echo | openssl s_client -servername NAME -connect HOST:PORT 2>/dev/null | openssl x509 -noout -dates + +https://www.shellhacks.com/openssl-check-ssl-certificate-expiration-date/ diff --git a/dotfiles/cheat/su b/dotfiles/cheat/su new file mode 100644 index 0000000..06799c0 --- /dev/null +++ b/dotfiles/cheat/su @@ -0,0 +1,5 @@ +# Switch to another user account +su USERNAME + +# Login to an account with special shell +su - <user> -s /bin/bash diff --git a/dotfiles/cheat/suda.vim b/dotfiles/cheat/suda.vim new file mode 100644 index 0000000..2d6d274 --- /dev/null +++ b/dotfiles/cheat/suda.vim @@ -0,0 +1,20 @@ +" Open a current file with sudo +:e suda://% + +" Save a current file with sudo +:w suda://% + +" Edit /etc/sudoers +:e suda:///etc/sudoers + +" Read /etc/sudoers (insert content under the cursor) +:r suda:///etc/sudoers + +" Read /etc/sudoers at the end +:$r suda:///etc/sudoers + +" Write contents to /etc/profile +:w suda:///etc/profile + +" Save contents to /etc/profile +:saveas suda:///etc/profile diff --git a/dotfiles/cheat/svg b/dotfiles/cheat/svg new file mode 100644 index 0000000..5df2da4 --- /dev/null +++ b/dotfiles/cheat/svg @@ -0,0 +1,17 @@ +# CSS + +`background-image: url("data:image/svg+xml;charset=utf8,<svg [...]");` + +Don't use `#` but `%23`. + +# svg inline +Source de l'idée: https://stackoverflow.com/a/33833561 + +Pour inclure svg en mode inline mais sans l'avoir en mode sale ds +le code il faut l'inclure ds le template. + +Par exemple sous django possibilité de faire: + +``` +{% include 'file.svg' %} +``` diff --git a/dotfiles/cheat/symfony b/dotfiles/cheat/symfony new file mode 100644 index 0000000..c76bc7a --- /dev/null +++ b/dotfiles/cheat/symfony @@ -0,0 +1,17 @@ +# Generated a crud +php bin/console generate:doctrine:crud + +# Genenrates entities +php bin/console doctrine:generate:entities AppBundle:Film + +# Run dev server +php bin/console server:run + +# Drop database +php bin/console doctrine:database:drop --force + +# Create database +php bin/console doctrine:database:create + +# Create schema +php bin/console doctrine:schema:create diff --git a/dotfiles/cheat/system_ingo b/dotfiles/cheat/system_ingo new file mode 100644 index 0000000..caa4f9b --- /dev/null +++ b/dotfiles/cheat/system_ingo @@ -0,0 +1 @@ +sudo inxi -Fxxxdfilmopru diff --git a/dotfiles/cheat/systemd b/dotfiles/cheat/systemd new file mode 100644 index 0000000..4389bb6 --- /dev/null +++ b/dotfiles/cheat/systemd @@ -0,0 +1,28 @@ +# Display process startup time +systemd-analyze + +# Display process startup time at service level +systemd-analyze blame + +# List running units +systemctl list-units + +# Load a unit at startup +systemctl enable foo.service + +# Start or Stop a unit +systemctl <start | stop> foo.service + +# Unit file locations +/etc/systemd/system +/usr/lib/systemd/system + +# Manage service with battery status +ConditionACPower= + +True is AC connecter and false if on battery. + +# Modify unit file without altering upstring unit file +# Source: https://serverfault.com/questions/840996/modify-systemd-unit-file-without-altering-upstream-unit-file +Use commande `systemctl edit --full <unit>` for example +For `--user` : `systemctl edit --full <unit>` diff --git a/dotfiles/cheat/tail b/dotfiles/cheat/tail new file mode 100644 index 0000000..2649315 --- /dev/null +++ b/dotfiles/cheat/tail @@ -0,0 +1,17 @@ +# To show the last 10 lines of file +tail file + +# To show the last N lines of file +tail -n N file + +# To show the last lines of file starting with the Nth +tail -n +N file + +# To show the last N bytes of file +tail -c N file + +# To show the last 10 lines of file and to wait for file to grow +tail -f file + +# To show the last 5 lines of file +tail -5 file diff --git a/dotfiles/cheat/tar b/dotfiles/cheat/tar new file mode 100644 index 0000000..41173b2 --- /dev/null +++ b/dotfiles/cheat/tar @@ -0,0 +1,34 @@ +# To extract an uncompressed archive: +tar -xvf /path/to/foo.tar + +# To create an uncompressed archive: +tar -cvf /path/to/foo.tar /path/to/foo/ + +# To extract a .gz archive: +tar -xzvf /path/to/foo.tgz + +# To create a .gz archive: +tar -czvf /path/to/foo.tgz /path/to/foo/ + +# To list the content of an .gz archive: +tar -ztvf /path/to/foo.tgz + +# To extract a .bz2 archive: +tar -xjvf /path/to/foo.tgz + +# To create a .bz2 archive: +tar -cjvf /path/to/foo.tgz /path/to/foo/ + +# To extract a .tar in specified Directory: +tar -xvf /path/to/foo.tar -C /path/to/destination/ + +# To list the content of an .bz2 archive: +tar -jtvf /path/to/foo.tgz + +# To create a .gz archive and exclude all jpg,gif,... from the tgz +tar czvf /path/to/foo.tgz --exclude=\*.{jpg,gif,png,wmv,flv,tar.gz,zip} /path/to/foo/ + +# To use parallel (multi-threaded) implementation of compression algorithms: +tar -z ... -> tar -Ipigz ... +tar -j ... -> tar -Ipbzip2 ... +tar -J ... -> tar -Ipixz ... diff --git a/dotfiles/cheat/taskwarrior b/dotfiles/cheat/taskwarrior new file mode 100644 index 0000000..4f47680 --- /dev/null +++ b/dotfiles/cheat/taskwarrior @@ -0,0 +1,18 @@ +# tnext +Voire tout les tâches suivante: + +``` +tnext +``` + +Voir les tâches suivante d'un projet en question: + +``` +tnext project:<nom_du_projet> +``` + +Exemple: + +``` +tnext project:pro +``` diff --git a/dotfiles/cheat/testing_app b/dotfiles/cheat/testing_app new file mode 100644 index 0000000..c737854 --- /dev/null +++ b/dotfiles/cheat/testing_app @@ -0,0 +1,43 @@ +# App list to test + +Why ? I hate GUI so can I code uslfull something with the following app ? + +## Usefull because I have some idea + +https://github.com/borgbackup/borg => Test this! It's work for backup? + +https://github.com/sshuttle/sshuttle => To test! For the moment, this +not work on scaleway vps! + +https://github.com/dutchcoders/transfer.sh => This can be usefull ? + +http://guacamole.apache.org/ => Test this, can replace teamviewer ? + +https://github.com/home-assistant/home-assistant => Install this on the +raspberry pi and test the API function and android/HTML client. This is +good for scripting/using every day ? + +https://github.com/kibitzr/kibitzr => Test it, can it crawl the web for +me ? How it works ? + +https://github.com/danielquinn/paperless => interisting... Utility ? + +https://github.com/CouchPotato/CouchPotatoServer/ => Ask to the service to +download the file in the best quality possible ? If it's work how can I use +it ? + +https://github.com/beniz/seeks => This is work ? Can it be improve ? + +http://git-annex.branchable.com/ => This is maybe interresting, test it! + +## Maybe usefull + +https://github.com/pastapojken/Myflix => Like kodi, can I use it for make a +good home cinema environnement ? + +## Usless but cool ! + +https://github.com/shazow/ssh-chat => Simple chat with ssh, test the server +can be very cool ! And what is the security behind this ? + + diff --git a/dotfiles/cheat/timew b/dotfiles/cheat/timew new file mode 100644 index 0000000..f742284 --- /dev/null +++ b/dotfiles/cheat/timew @@ -0,0 +1,3 @@ +# Exemple for add track + +timew track 2018-01-29T14:30 - 2018-01-29T18:00 Devis, smartdiet diff --git a/dotfiles/cheat/tips b/dotfiles/cheat/tips new file mode 100644 index 0000000..e648853 --- /dev/null +++ b/dotfiles/cheat/tips @@ -0,0 +1,61 @@ +# Tips 1 +Care About You Craft + +# Tips 2 +Think! About Your Work + +# Tips 3 +Provide Options, Don't Make Lame Excuses + +# Tips 4 +Don't Live With Broken Windows + +# Tips 5 +Be a Catalyst for Change + +# Tips 6 +Remenber the Big Picture + +# Tips 7 +Make Quality a Requirements Issue + +# Tips 8 +Invest Regularly in Your Knowledge Portfolio + +# Tips 9 +Critically Analyze What You Read and Hear + +# Tips 10 +It's Both Wath You Say and the Way You Say It + +# Tips 11 +DRY - Don't Repeat Yourself + +# Tips 12 +Make It Easy to Reuse + +# Tips 13 +Eliminate Effects Between Unrelateed Things + +# Tips +There Are No Final Decisions + +# Tips 15 +User Trace Bullets to Find the Target + +# Tips 16 +Prototype to Learn + +# Tips 17 +Program Close to the Problem Domain + +### --- Other tips + +# WISDOM acrostic - understanging an audience + + |W|hat do you want them to learn? + What is their |i|nterest in what you've got to say? + How |s|ophisticated are they? + How much |d|etail to thew want? +Whom do you want to |o|wn th information? + How can you |m|otivate them to listen to you? diff --git a/dotfiles/cheat/tmux b/dotfiles/cheat/tmux new file mode 100644 index 0000000..161e4ff --- /dev/null +++ b/dotfiles/cheat/tmux @@ -0,0 +1,165 @@ +# Start tmux: +tmux + +# Prefix == Ctrl-b or Ctrl-w + +# Detach from tmux: +Prefix d + +# Restore tmux session: +tmux attach + +# Detach an already attached session (great if you are moving devices with different screen resolutions) +tmux attach -d + +# Display session: +tmux ls + +# Rename session: +Prefix $ + +# Switch session: +Prefix s + +# Start a shared session: +tmux -S /tmp/your_shared_session +chmod 777 /tmp/your_shared_session + +# Help screen (Q to quit): +Prefix ? + +# Scroll in window: +Prefix PageUp/PageDown + +# Reload configuation file +Prefix : source-file /path/to/file + +# lauch command +Prefix : + +# Zoom in tab +Prefix z + +# Open pane in the current directory (alias configured) +# Vertical +Prefix _ +# Horizontal +Prefix / + +# Toggle recording terminal into a file +Prefix P + +# Window management +# ================= + +# Create window: +Prefix c + +# Destroy window: +Prefix & + +# Switch between windows: +Prefix [0-9] +or +Prefix Arrows + +# Split windows horizontally: +Prefix % + +# Split windows vertically: +Prefix " + +# Turn a pane into a Window +Prefix ! + +# Pane management +# =============== + +# kill pane +Prefix x + +# Buffer with vim keys +# ==================== + +# jump to next word +w + +# jump back one word +b + +# jump to the next character +f <char> + +# move one page up +Ctrl-b + +# move one page down +Ctrl-f + +# Search in buffer (use <n> and <N>) +? + +# For search downward +/ + +# Select some text +# Use <Enter> to quit and copy selected text in buffer +space + +# paste content captured +Prefix ] + +# commands +# ======== + +# Copy the entire visible contents pane to the paste buffer +capture-pane + +# show the content of the paste buffer +show-buffer + +# list all pasted buffer +list-buffers + +# Choos a buffer and past +choose-buffer + +# Turn Window into a pane, take window of a session and join it to the current +# session +join-pane <session_name>:<window_id> + +# Mouve pane to another window +join-pane -s <session_name>:<window_id>.<pane_id> + +# Move pane from pane to another +join-pane -s <session_name>:<window_id>.<pane_id> <session_name>:<window_id> + +# Move window between sessions +move-window -s <session_name>:<session_id> -t <session_id> + +# Multi user +# ========== + +# For use multi user you must make different session for have habilty to +# seperate window + +# first create a simple session +tmux new-session -s groupedsession + +# And connect to it with another session +tmux new-session -t groupedsession -s mysession + +# Session management +# ================== + +# Switch between session +# Go to previous section +Prefix ( +# Go to next section +Prefix ) + +# Display list of sessions +Prefix s + +# Move window betweeb sessions +Prefix . <session_name> diff --git a/dotfiles/cheat/traduction b/dotfiles/cheat/traduction new file mode 100644 index 0000000..a2553a1 --- /dev/null +++ b/dotfiles/cheat/traduction @@ -0,0 +1,2 @@ +# Compil po file +msgfmt fr_FR.po -o fr_FR.mo diff --git a/dotfiles/cheat/tty b/dotfiles/cheat/tty new file mode 100644 index 0000000..4e2e538 --- /dev/null +++ b/dotfiles/cheat/tty @@ -0,0 +1,5 @@ +Message d'erreur : Cannot open your terminal '/dev/pts/0' - please check. +C'est parceque un autre utilisateur (soit même) à initié le terminal +actuel - Problament en utilisant `sudo su` pour lancer screen. +Pour régler le problème sans se connecter avec le bon user : script /dev/null +plus d'info : https://serverfault.com/questions/116775/sudo-as-different-user-and-running-screen/116830#116830 diff --git a/dotfiles/cheat/urxvt b/dotfiles/cheat/urxvt new file mode 100644 index 0000000..f16dc45 --- /dev/null +++ b/dotfiles/cheat/urxvt @@ -0,0 +1,29 @@ +# yank url in term +Alt+u Enter selection mode. The last URL on your screen will be selected. You can repeat Alt+u to select the next upward URL. +k Select next upward URL +j Select next downward URL +Return Open selected URL in browser and quit selection mode +o Open selected URL in browser without quitting selection mode +y Copy (yank) selected URL and quit selection mode +Esc Cancel URL selection mode + +# Tab management +Shift+Down New tab +Shift+Left Go to left tab +Shift+Right Go to right tab +Ctrl+Left Move tab to the left +Ctrl+Right Move tab to the right +Ctrl+d Close tab + +# keyboard select with meta-escape +h/j/k/l: Move cursor left/down/up/right (also with arrow keys) +g/G/0/^/$/H/M/L/f/F/;/,/w/W/b/B/e/E: More vi-like cursor movement keys +'/'/?: Start forward/backward search +n/N: Repeat last search, N: in reverse direction +Ctrl-f/b: Scroll down/up one screen +Ctrl-d/u: Scroll down/up half a screen +v/V/Ctrl-v: Toggle normal/linewise/blockwise selection +y/Return: Copy selection to primary buffer, Return: quit afterwards +Y: Copy selected lines to primary buffer or cursor line and quit +q/Escape: Quit keyboard selection mode + diff --git a/dotfiles/cheat/vagrant b/dotfiles/cheat/vagrant new file mode 100644 index 0000000..8c0b6c0 --- /dev/null +++ b/dotfiles/cheat/vagrant @@ -0,0 +1,37 @@ +# Initate Vagrant +mkdir vag-vm; cd vag-vm +vagrant init + +# Add a box to vagrant repo +vagrant box add hashicorp/precise32 + +# Add a box Vagrant file +config.vm.box = "hashicorp/precise32" + +# Add vm to public network as host +config.vm.network "public_network" + +# Add provision script to vagrant file +config.vm.provision :shell, path: "provision.sh" + +# Start vm +vagrant up + +# Connect to started instance +vagrant ssh + +# Shutdown vm +vagrant halt + +# Hibernate vm +vagrant suspend + +# Set vm to initial state by cleaning all data +vagrant destroy + +# Restart vm with new provision script +vagran reload --provision + +# List status of each VM +# --prune invalid entries from the list. This is much more time consuming than simply listing the entries. +vagrant global-status --prune diff --git a/dotfiles/cheat/vim b/dotfiles/cheat/vim new file mode 100644 index 0000000..ebc509d --- /dev/null +++ b/dotfiles/cheat/vim @@ -0,0 +1,80 @@ +# File management + +:e reload file +:q quit +:q! quit without saving changes +:w write file +:w {file} write new file +:x write file and exit + +# Movement + + k + h l basic motion + j + +w next start of word +W next start of whitespace-delimited word +e next end of word +E next end of whitespace-delimited word +b previous start of word +B previous start of whitespace-delimited word +0 start of line +$ end of line +gg go to first line in file +G go to end of file +gk move down one displayed line +gj move up one displayed line + +# Insertion +# To exit from insert mode use Esc or Ctrl-C +# Enter insertion mode and: + +a append after the cursor +A append at the end of the line +i insert before the cursor +I insert at the beginning of the line +o create a new line under the cursor +O create a new line above the cursor +R enter insert mode but replace instead of inserting chars +:r {file} insert from file + +# Editing + +u undo +yy yank (copy) a line +y{motion} yank text that {motion} moves over +p paste after cursor +P paste before cursor +<Del> or x delete a character +dd delete a line +d{motion} delete text that {motion} moves over + +# Search and replace with the `:substitute` (aka `:s`) command + +:s/foo/bar/ replace the first match of 'foo' with 'bar' on the current line only +:s/foo/bar/g replace all matches (`g` flag) of 'foo' with 'bar' on the current line only +:%s/foo/bar/g replace all matches of 'foo' with 'bar' in the entire file (`:%s`) +:%s/foo/bar/gc ask to manually confirm (`c` flag) each replacement + +# Preceding a motion or edition with a number repeats it 'n' times +# Examples: +50k moves 50 lines up +2dw deletes 2 words +5yy copies 5 lines +42G go to line 42 + +# Multi line select and edit +1. Press Esc to enter 'command mode' +2. Use Ctrl + V to enter visual block mode. +3. Move Up / Down to select the columns of text in the lines you want to comment. +4. Then hit Shift + i and type the text you want to insert. +5. Then hit Esc , wait 1 second and the inserted text will appear on every line. + +# Use normal copy pase +`"`; `+` ; `y` <= yank +`"`; `+` ; `p` <= paste + +# SimpleWorkspaces.vim +To add the current dir in a Workspace: `:WorkspaceInit` +And save it in a better name: `:WorkspaceSave {name}` diff --git a/dotfiles/cheat/vpn b/dotfiles/cheat/vpn new file mode 100644 index 0000000..141e9cd --- /dev/null +++ b/dotfiles/cheat/vpn @@ -0,0 +1,7 @@ +nmcli device show wlp3s0 + +#Know other ip +/etc/openvpn/ipp.txt + +#Server perso +script is in /root/OpenVPN-install diff --git a/dotfiles/cheat/watch b/dotfiles/cheat/watch new file mode 100644 index 0000000..87afe8d --- /dev/null +++ b/dotfiles/cheat/watch @@ -0,0 +1,2 @@ +# For watch size of directory +ls -alh cd.backup | tail -1 | awk '{print $(NF-5),"\t",$(NF)}' diff --git a/dotfiles/cheat/web_debug b/dotfiles/cheat/web_debug new file mode 100644 index 0000000..a7a3cbf --- /dev/null +++ b/dotfiles/cheat/web_debug @@ -0,0 +1,2 @@ +# Web redirection testing with wget +wget -O/dev/null --no-check-certificate http://noria.lan/board 2>&1 | grep -P "(301|Location)" diff --git a/dotfiles/cheat/webfont b/dotfiles/cheat/webfont new file mode 100644 index 0000000..c8504a8 --- /dev/null +++ b/dotfiles/cheat/webfont @@ -0,0 +1,17 @@ +# https://github.com/google/woff2 +# Permet de générer un woff2 +woff2_compress mafont.ttf + +# https://github.com/ananthakumaran/webify +# Permet de générer un woff sans EOT et SVG car il le fait par défaut +webify mafont.ttf ---no-eot --no-svg + +# https://github.com/hanikesn/woff2otf +# Permet de génener un ttf à partir d'un woff +./woff2otf.py font.woff font.otf + +# En une seul ligne +$font=mafont.ttf; woff2_compress $font; webify $font --no-eot --no-svg + +# Css tips: +If webfont is loaded with "?xxxxx" at the end of the file, the "xxxxx" must be changed. diff --git a/dotfiles/cheat/wifi b/dotfiles/cheat/wifi new file mode 100644 index 0000000..59c517f --- /dev/null +++ b/dotfiles/cheat/wifi @@ -0,0 +1,2 @@ +# network manager from cli +nmtui diff --git a/dotfiles/cheat/wordpress b/dotfiles/cheat/wordpress new file mode 100644 index 0000000..c9bd1ce --- /dev/null +++ b/dotfiles/cheat/wordpress @@ -0,0 +1,21 @@ +#Create database +console doctrine:database:create + +#update database +console doctrine:schema:update --force + +# Enable WP_DEBUG mode +define( 'WP_DEBUG', true ); + +# Enable Debug logging to the /wp-content/debug.log file +define( 'WP_DEBUG_LOG', true ); + +# Disable display of errors and warnings +define( 'WP_DEBUG_DISPLAY', false ); +@ini_set( 'display_errors', 0 ); + +# Use dev versions of core JS and CSS files (only needed if you are modifying these core files) +define( 'SCRIPT_DEBUG', true ); + +# Change url in database +wp search-replace 'http://example.com' 'https://example.com' diff --git a/dotfiles/cheat/zip b/dotfiles/cheat/zip new file mode 100644 index 0000000..6cc9ec6 --- /dev/null +++ b/dotfiles/cheat/zip @@ -0,0 +1,7 @@ +# Create zip file +zip archive.zip file1 directory/ + +# Don't recursive by default + +# To list, test and extract zip archives, see unzip +cheat unzip |