aboutsummaryrefslogtreecommitdiff
path: root/cheat
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2019-02-14 12:49:30 +0100
committerneodarz <neodarz@neodarz.net>2019-02-14 12:49:30 +0100
commitc57807815e7b2183b766d5f2b52222c30a116475 (patch)
treedfd5fba005e14e3fabb3baa22da12ebb04e9e2d2 /cheat
parentbc3f5659576aa0d2803a4cd933079b1393537be5 (diff)
downloaddotfiles_ascii-c57807815e7b2183b766d5f2b52222c30a116475.tar.xz
dotfiles_ascii-c57807815e7b2183b766d5f2b52222c30a116475.zip
Add more good cheats
Diffstat (limited to 'cheat')
-rw-r--r--cheat/.cheat/find50
-rw-r--r--cheat/.cheat/magnetico5
-rw-r--r--cheat/.cheat/mkcert38
-rw-r--r--cheat/.cheat/python_ressources20
4 files changed, 113 insertions, 0 deletions
diff --git a/cheat/.cheat/find b/cheat/.cheat/find
new file mode 100644
index 0000000..680abb3
--- /dev/null
+++ b/cheat/.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
+find $1 -type f \( \! -iname ".DS_Store" \) -print0 | xargs -0 stat --format '%Y :%y %n' | sort -nr | cut -d: -f2- | head
diff --git a/cheat/.cheat/magnetico b/cheat/.cheat/magnetico
new file mode 100644
index 0000000..5fb96bf
--- /dev/null
+++ b/cheat/.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/cheat/.cheat/mkcert b/cheat/.cheat/mkcert
new file mode 100644
index 0000000..2b673c8
--- /dev/null
+++ b/cheat/.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/cheat/.cheat/python_ressources b/cheat/.cheat/python_ressources
new file mode 100644
index 0000000..cf8a350
--- /dev/null
+++ b/cheat/.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/