From 15a404e6a0d95383f02423860a599ad987830424 Mon Sep 17 00:00:00 2001 From: neodarz Date: Tue, 27 Nov 2018 15:37:48 +0100 Subject: Add some cheat --- cheat/.cheat/RAID | 5 ++ cheat/.cheat/django | 16 ++++ cheat/.cheat/django-cms | 9 +++ cheat/.cheat/django-oscar | 17 +++++ cheat/.cheat/git | 3 + cheat/.cheat/iperf | 1 + cheat/.cheat/pdf | 4 + cheat/.cheat/phpbrew | 1 + cheat/.cheat/ping | 8 ++ cheat/.cheat/pipy | 21 ++++++ cheat/.cheat/ponghaum | 2 + cheat/.cheat/sharing_internet | 44 +++++++++++ cheat/.cheat/ssl | 3 + cheat/.cheat/su | 5 ++ cheat/.cheat/svg | 5 ++ cheat/.cheat/tmux | 165 ++++++++++++++++++++++++++++++++++++++++++ cheat/.cheat/vagrant | 37 ++++++++++ cheat/.cheat/watch | 2 + 18 files changed, 348 insertions(+) create mode 100644 cheat/.cheat/RAID create mode 100644 cheat/.cheat/django create mode 100644 cheat/.cheat/django-cms create mode 100644 cheat/.cheat/django-oscar create mode 100644 cheat/.cheat/iperf create mode 100644 cheat/.cheat/pdf create mode 100644 cheat/.cheat/phpbrew create mode 100644 cheat/.cheat/ping create mode 100644 cheat/.cheat/pipy create mode 100644 cheat/.cheat/ponghaum create mode 100644 cheat/.cheat/sharing_internet create mode 100644 cheat/.cheat/ssl create mode 100644 cheat/.cheat/su create mode 100644 cheat/.cheat/svg create mode 100644 cheat/.cheat/tmux create mode 100644 cheat/.cheat/vagrant create mode 100644 cheat/.cheat/watch diff --git a/cheat/.cheat/RAID b/cheat/.cheat/RAID new file mode 100644 index 0000000..87cc9af --- /dev/null +++ b/cheat/.cheat/RAID @@ -0,0 +1,5 @@ +# Tool for get info on disks +lsscsi + +# If LSILOGIC use: +storcli diff --git a/cheat/.cheat/django b/cheat/.cheat/django new file mode 100644 index 0000000..5771985 --- /dev/null +++ b/cheat/.cheat/django @@ -0,0 +1,16 @@ +# 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 diff --git a/cheat/.cheat/django-cms b/cheat/.cheat/django-cms new file mode 100644 index 0000000..72770b6 --- /dev/null +++ b/cheat/.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/cheat/.cheat/django-oscar b/cheat/.cheat/django-oscar new file mode 100644 index 0000000..a4e00cd --- /dev/null +++ b/cheat/.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/cheat/.cheat/git b/cheat/.cheat/git index 9364438..8903fa2 100644 --- a/cheat/.cheat/git +++ b/cheat/.cheat/git @@ -156,3 +156,6 @@ 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 diff --git a/cheat/.cheat/iperf b/cheat/.cheat/iperf new file mode 100644 index 0000000..5be0952 --- /dev/null +++ b/cheat/.cheat/iperf @@ -0,0 +1 @@ +iperf3 -p 5200 -c ping.online.net ; iperf3 -p 5200 -c ping.online.net -R diff --git a/cheat/.cheat/pdf b/cheat/.cheat/pdf new file mode 100644 index 0000000..6190692 --- /dev/null +++ b/cheat/.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/cheat/.cheat/phpbrew b/cheat/.cheat/phpbrew new file mode 100644 index 0000000..cc6f98d --- /dev/null +++ b/cheat/.cheat/phpbrew @@ -0,0 +1 @@ +mcrypt ne fonctionne qu'avec une version de php <= 7.1.x ! diff --git a/cheat/.cheat/ping b/cheat/.cheat/ping new file mode 100644 index 0000000..a50198b --- /dev/null +++ b/cheat/.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/cheat/.cheat/pipy b/cheat/.cheat/pipy new file mode 100644 index 0000000..e9744fb --- /dev/null +++ b/cheat/.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/cheat/.cheat/ponghaum b/cheat/.cheat/ponghaum new file mode 100644 index 0000000..98d9884 --- /dev/null +++ b/cheat/.cheat/ponghaum @@ -0,0 +1,2 @@ +sudo socat /dev/ttyACM0,b115200 - | tee /tmp/a | ./livehex +tail -f /tmp/a diff --git a/cheat/.cheat/sharing_internet b/cheat/.cheat/sharing_internet new file mode 100644 index 0000000..8dca3b5 --- /dev/null +++ b/cheat/.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/cheat/.cheat/ssl b/cheat/.cheat/ssl new file mode 100644 index 0000000..f89777e --- /dev/null +++ b/cheat/.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/cheat/.cheat/su b/cheat/.cheat/su new file mode 100644 index 0000000..06799c0 --- /dev/null +++ b/cheat/.cheat/su @@ -0,0 +1,5 @@ +# Switch to another user account +su USERNAME + +# Login to an account with special shell +su - -s /bin/bash diff --git a/cheat/.cheat/svg b/cheat/.cheat/svg new file mode 100644 index 0000000..baa48da --- /dev/null +++ b/cheat/.cheat/svg @@ -0,0 +1,5 @@ +# CSS + +`background-image: url("data:image/svg+xml;charset=utf8, + +# move one page up +Ctrl-b + +# move one page down +Ctrl-f + +# Search in buffer (use and ) +? + +# For search downward +/ + +# Select some text +# Use 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 : + +# Mouve pane to another window +join-pane -s :. + +# Move pane from pane to another +join-pane -s :. : + +# Move window between sessions +move-window -s : -t + +# 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 . diff --git a/cheat/.cheat/vagrant b/cheat/.cheat/vagrant new file mode 100644 index 0000000..8c0b6c0 --- /dev/null +++ b/cheat/.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/cheat/.cheat/watch b/cheat/.cheat/watch new file mode 100644 index 0000000..87afe8d --- /dev/null +++ b/cheat/.cheat/watch @@ -0,0 +1,2 @@ +# For watch size of directory +ls -alh cd.backup | tail -1 | awk '{print $(NF-5),"\t",$(NF)}' -- cgit v1.2.1