Skip to content

Instantly share code, notes, and snippets.

@christianascone
christianascone / delete_old_s3_files.sh
Last active May 5, 2022 13:02
Delete files older than 15 days stored on S3 bucket
BUCKETNAME=$1
PROFILE=$2
URL=$3
aws s3 ls $BUCKETNAME/ --profile $PROFILE --endpoint-url=$URL | while read -r line;
do
createDate=`echo $line|awk {'print $1" "$2'}`
createDate=`date -d"$createDate" +%s`
olderThan=`date --date "15 days ago" +%s`
if [[ $createDate -lt $olderThan ]]
@christianascone
christianascone / rsaSignAndVerify.sh
Created November 28, 2020 14:10
RSA sign and verify using Openssl
#!/bin/bash
#https://medium.com/@bn121rajesh/rsa-sign-and-verify-using-openssl-behind-the-scene-bf3cac0aade2
openssl genrsa -out myprivate.pem 1024
openssl rsa -in myprivate.pem -pubout > mypublic.pem
openssl dgst -sha1 -sign myprivate.pem -out sha1.sign toSign
openssl dgst -sha1 -verify mypublic.pem -signature sha1.sign toSign
@christianascone
christianascone / create_and_enable_1G_swap.sh
Last active November 11, 2020 09:02
Create and enable/disable a swap file
#!/bin/bash
# Create 1GB swap file (change count if needed)
sudo dd if=/dev/zero of=/swapfile bs=1G count=1
# Fix permissions
sudo chmod 600 /swapfile
# Make swap with given file
sudo mkswap /swapfile
# Enable swap
sudo swapon /swapfile
# Check Swap
@christianascone
christianascone / bump_version.py
Created June 24, 2020 10:50
Simple script for version update using git flow for release
import os
from distutils.version import LooseVersion, StrictVersion
from argparse import ArgumentParser
import subprocess
parser = ArgumentParser()
parser.add_argument("-p", "--position", dest="position",
help="Position code. It can be numeric or a string: major, minor or patch", metavar="position")
args = parser.parse_args()
@christianascone
christianascone / resetXcode.sh
Created March 14, 2020 09:58 — forked from maciekish/resetXcode.sh
Reset Xcode. Clean, clear module cache, Derived Data and Xcode Caches. You can thank me later.
#!/bin/bash
killall Xcode
xcrun -k
xcodebuild -alltargets clean
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache"
rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf ~/Library/Caches/com.apple.dt.Xcode/*
open /Applications/Xcode.app
@christianascone
christianascone / .react_native_strip_unused_styles.py
Last active February 25, 2020 11:03
React Native: Remove unused styles from external file
import re
import sys
from argparse import ArgumentParser
"""
A script to check a React Native view class and its stylesheet external file, removing unused style classes.
It search occurrences of given variable name (which must be the name of imported stylesheet class), comparing usages with
stylesheet class.
It eventually removes unused style classes from style file.
"""
@christianascone
christianascone / gist:2bbba82c141bdf778cf01ffde50ea4f0
Created February 17, 2020 09:06
Add user to www-data group
grep ^www-data /etc/group
sudo adduser admin www-data
grep ^www-data /etc/group
@christianascone
christianascone / intellij_idea_copyright.txt
Created September 11, 2019 09:01
Jetbrains copyright notice examples
@christianascone
christianascone / .bashrc
Created June 7, 2019 10:59
.bashrc for colorful terminal
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@christianascone
christianascone / auto_rsync.sh
Created June 7, 2019 10:53
Automatic rsync between local and remote machine using a no-password ssh key
#!/bin/bash
echo "###########################"
echo $(date -u) "Starting rsync data"
eval `ssh-agent -s`
ssh-add ~/.ssh/key_name
rsync -vrahe ssh ~/www/local/data/upload ciolloadm@vps0228.00gate.com:/home/remote/dir
echo $(date -u) "Ended rsync data"
echo "###########################"