Skip to content

Instantly share code, notes, and snippets.

Anthony Rodriguez thonyx

Block or report user

Report or block thonyx

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@thonyx
thonyx / run.sh
Last active Apr 10, 2019
reload a running php-fpm in a docker container
View run.sh
docker exec -it container_name kill -USR2 1
@thonyx
thonyx / add_column_rows.sh
Created Sep 30, 2018
add up all column values
View add_column_rows.sh
res=0; for dir in $a; do val=$(du -s /dir_path | awk '{ print $1 }'); res=$(($val+$res)); done;
#The result is in KB by default
@thonyx
thonyx / filesystems-resizing.sh
Last active Sep 29, 2018
Dealing with filesytems resizing
View filesystems-resizing.sh
# 1 - Report file system disk space usage
# note: -h: human readable. print sizes in power of 1024.
$ df -h
# would print:
# Filesystem Size Used Avail Use% Mounted on
# udev 7.7G 0 7.7G 0% /dev
# tmpfs 1.6G 9.0M 1.6G 1% /run
# /dev/nvma1n1p1 59G 34G 25G 59% /
@thonyx
thonyx / traffic.js
Created Sep 3, 2018
a traffic light system
View traffic.js
let states = {
'red': {'nextSlot':'green', 'await':10000, 'exec':function(element){
element.className = 'red'
setTimeout(function(){
element.className = ''
states.green.exec(document.getElementById(states.red.nextSlot))
}, states.red.await)
}},
'green': {'nextSlot':'yellow','await':10000, 'exec':function(element){
@thonyx
thonyx / git-blame-a-set-of-lines.sh
Last active Jul 28, 2018
Git blame a set of lines in a file
View git-blame-a-set-of-lines.sh
git blame -L 2014,+20 -- <file path>
@thonyx
thonyx / securesshcopy.sh
Created Jul 19, 2018
Copy files over ssh using secure ssh (scp)
View securesshcopy.sh
scp -r -i mykey.pem [from_directory_or_file] [host_name]:[destination_location]
@thonyx
thonyx / redis-insert-unique-value.sh
Last active May 18, 2018
Store in a sorted set in Redis all unique values from keys matching a pattern using a shell command
View redis-insert-unique-value.sh
redis="redis-cli -h host_name" \
$redis keys "*matching_key_pattern*" | awk -F':' '{print $2}' | awk '!x[$0]++' | xargs -I{} $redis zadd temp-user_ids {} {}
@thonyx
thonyx / awk-remove-duplicated.sh
Created May 18, 2018
remove duplicates with awk
View awk-remove-duplicated.sh
$ awk '!x[$0]++'
#which is a shorthand for:
$ awk ' !seen[$0] { print $0 } 1 { seen[$0]++ }'
@thonyx
thonyx / server.sh
Last active May 4, 2018
NGINX: Handle request with different PHP version driven by the URI resource name
View server.sh
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ^~ /endpoint {
alias /home/www/html;
try_files $uri $uri/ @nested;
@thonyx
thonyx / s3s-deploy.sh
Created Mar 13, 2018
deploy files into an s3 bucket from the cli
View s3s-deploy.sh
#s3 server deployment
aws s3 cp --acl public-read --content-type=text/html --metadata-directive REPLACE index.html s3://bucketname/index.html
You can’t perform that action at this time.