This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To backup portainer volume | |
_backup_time=$(date +"%F_%H_%M%P"); sudo tar cvfz /mnt2/docker/backups/portainer/portainer_backup_${_backup_time}.tar.gz /var/lib/docker/volumes/portainer_data | |
# To run new portainer container with ports and volumes and local docker.sock | |
docker run -p 8000:8000 -p 9000:9000 --name portainer -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create database prisoners; | |
CREATE USER 'prisoners'@'%' IDENTIFIED BY '???????????'; | |
GRANT ALL PRIVILEGES ON prisoners.* TO 'prisoners'@'%' WITH GRANT OPTION; | |
FLUSH PRIVILEGES; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# on host (eg: 192.168.0.111) | |
sudo apt-get install samba samba-common-bin | |
sudo vi /etc/samba/smb.conf | |
# create directory with correct permissions that can be exposed via Samba | |
sudo mkdir -p /mnt/drive01 | |
sudo chown -R pi:pi /mnt/drive01 | |
# add sections within /etc/samba/smb.conf | |
[Pi Media Share] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
_now=$(date +"%F_%H_%M%P") | |
pushd /mnt2/backups/mysql/ | |
for db_name in `mysql -h 127.0.0.1 -u root -e "show databases;" | grep "\|" | grep -v "_schema" | grep -v "mysql" | tail -n +2`; do | |
echo "Backing up ${db_name}" | |
filename="${db_name}_${_now}.sql" | |
mysqldump -h 127.0.0.1 -u root $db_name > ${filename} | |
done | |
tar cvfz mysql_pi_${_now}.tar.gz $(ls *${_now}*.sql) && rm *${_now}*.sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# originally a solution for Codewars.com: Path Finder #3: the Alpinist | |
class PathFinder | |
# Options for display_strategy: [nil, :highlight, :animate] | |
def initialize(display_strategy =nil) | |
@display_strategy = display_strategy | |
end | |
# Options for display_strategy: [nil, :highlight, :animate] | |
def path_finder(maze, display_strategy = nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for effect in useState useEffect useContext useReducer useCallback useMemo useRef useImperativeHandle useLayoutEffect useDebugValue; do RESULT=`find client/src -iname "*.js" | xargs grep -s -E "import React.*use.*from" | grep $effect | wc -l`; echo "$RESULT $effect"; done | sort -n -r | |
# 166 useState | |
# 128 useEffect | |
# 23 useCallback | |
# 8 useRef | |
# 1 useReducer | |
# 1 useContext | |
# 0 useMemo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# our flags ordered by the bit that they'll toggle | |
# new flags MUST be added to the BEGINNING of the array! | |
FLAGS = [:a, :b, :c, :d, :e, :f] | |
build_flags = -> (*performed) { n = FLAGS.length; val = 0; FLAGS.each{|v| n -= 1; val += 2 ** n if performed.index(v)}; val} | |
required = build_flags.(:a, :b, :c, :f) | |
=> 57 | |
required.to_s(2) | |
=> "111001" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IFS=$'\n' | |
for line in `ps -o pid,etime,%mem,command ax | grep launch | grep -v "grep"`; do echo "---------------------------------"; echo $line; echo $line | awk '{print $1}' | xargs pmap | grep "total"; done; echo "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for ns in `kubectl get pods -A | grep my_project_name | grep "^.*[4-9]\dd$" | awk {'print $1'} | uniq`;do kubectl delete namespace $ns --namespace $ns; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To build music_log.txt | |
# ------------------------------------ | |
# sudo apt-get install ffmpeg | |
# SAVEIFS=$IFS | |
# IFS=$(echo -en "\n\b") | |
# for file in `find . -iname "*.mp3"`;do echo "=========================="; echo $file; ffprobe $file 2>&1 | grep -A 12 'Metadata:'; done > music_log.txt | |
require 'awesome_print' | |
# require 'byebug' |
NewerOlder