Skip to content

Instantly share code, notes, and snippets.

View maxrodrigo's full-sized avatar

Max Rodrigo maxrodrigo

View GitHub Profile
for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done
tar zvcf ~/modified_and_new_files.tar.gz ` git status --short | sed 's/^ *[^ ]* \(.*\)/\1/g' `
@maxrodrigo
maxrodrigo / install-chrome-headless.sh
Last active October 26, 2024 12:10
Puppeteer/Chrome Headless on EC2 Amazon Linux AMI
#!/bin/env bash
# Install 3rd party repositories
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/atk-2.22.0-3.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/at-spi2-atk-2.22.0-2.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/at-spi2-core-2.22.0-1.el7.x86_64.rpm
# Install dependencies
sudo yum install -y nodejs gcc-c++ make cups-libs dbus-glib libXrandr libXcursor libXinerama cairo cairo-gobject pango libXScrnSaver gtk3
@maxrodrigo
maxrodrigo / docker-cleanup.sh
Created November 9, 2018 15:38
Docker cleanup script
#!/bin/bash
docker rm -v $(docker ps -a -q -f status=exited)
docker rmi $(docker images -f "dangling=true" -q)
@maxrodrigo
maxrodrigo / git-split-and-push.sh
Last active August 28, 2024 08:29
Split a repository into batches to avoid `pack exceeds maximum allowed size` on push
# Split a repository into batches to avoid `pack exceeds maximum allowed size` on git push
REMOTE=origin
BRANCH=$(git rev-parse --abbrev-ref HEAD)
BATCH_SIZE=500
# check if the branch exists on the remote
if git show-ref --quiet --verify refs/remotes/$REMOTE/$BRANCH; then
# if so, only push the commits that are not on the remote already
range=$REMOTE/$BRANCH..HEAD
@maxrodrigo
maxrodrigo / csv-to-json.sh
Created January 7, 2019 09:29
Convert csv to json with jq
jq --slurp --raw-input --raw-output \
'split("\n") | .[1:] | map(split(",")) |
map({"id": .[0],
"example": .[1],
"attribute": .[2]})' \
example.csv > example.json
@maxrodrigo
maxrodrigo / iso-3166-1-database.json
Created April 5, 2019 11:25
ISO 3166-1 - Codes for the representation of names of countries and their subdivisions.
{
"3166-1": [
{
"alpha_2": "AW",
"alpha_3": "ABW",
"name": "Aruba",
"numeric": "533"
},
{
"alpha_2": "AF",

rsync -avhW --no-compress --progress /src/ /dst/

  • -a is for archive, which preserves ownership, permissions etc.
  • -v is for verbose, so I can see what's happening (optional)
  • -h is for human-readable, so the transfer rate and file sizes are easier to read (optional)
  • -W is for copying whole files only, without delta-xfer algorithm which should reduce CPU load
  • --progress so I can see the progress of large files (optional)
@maxrodrigo
maxrodrigo / reintall-macos-lion.md
Created March 3, 2020 17:16
Reinstall MacOS Lion 10.6 Without AppleID

Boot your laptop in Recovery Mode (cmd+R)

  1. Open the Terminal and find the Apple_Boot Recovery HD.
# diskutil list
/dev/disk0
 #:                       TYPE NAME               SIZE       IDENTIFIER
 0:      GUID_partition_scheme                   *250.1 GB   disk0
 1:                        EFI                    209.7 MB   disk0s1
 2:                  Apple_HFS Macintosh HD       249.2 GB   disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
@maxrodrigo
maxrodrigo / conky_objects_and_variables.md
Created March 31, 2020 16:59
Conky Objects and Variables

Conky OBJECTS/VARIABLES

Some objects may create threads, and sometimes these threads will not be destroyed until Conky terminates. There is no way to destroy or clean up threads while Conky is running. For example, if you use an MPD variable, the MPD thread will keep running until Conky dies. Some threaded objects will use one of the parameters as a key, so that you only have 1 relevant thread running (for example, the $curl, $rss and $weather objects launch one thread per URI).

acpiacadapter (adapter)
ACPI ac adapter state. On linux, the adapter option specifies the subfolder of /sys/class/power_supply con‐