Skip to content

Instantly share code, notes, and snippets.

View jpesce's full-sized avatar

João Pesce jpesce

View GitHub Profile
@jpesce
jpesce / css-rule-inventory.sh
Created June 21, 2021 18:58
[CSS Inventory] Find all used values for a CSS property in the project
# Exclude node_modules and .git directory
rg --no-ignore-vcs --glob '!{node_modules/*,.git/*}' --follow --no-filename --no-line-number "font-weight" * | sed 's/^[ \t]*//;s/[ \t]*$//' | sort | uniq
@jpesce
jpesce / redirect-analyzer.sh
Created May 5, 2021 13:09
[Redirect chain] View all redirects a URL perform before resolving
curl -sLD - http://picasaweb.google.com -o /dev/null
@jpesce
jpesce / bootable-usb-in-macos.md
Last active September 17, 2020 13:58
[Bootable USB in MacOS] Create a bootable Linux USB in MacOS

How to create a bootable USB stick in MacOS

Download the ISO

This is just and example for an arbitrary Arch Linux iso, always check for latest version and best mirror for you in https://www.archlinux.org/download/ or on the website of your distribution of choice.

curl http://br.mirror.archlinux-br.org/iso/2020.09.01/archlinux-2020.09.01-x86_64.iso -o archlinux-2020.09.01-x86_64.iso -#

Convert the ISO to UDRW Format

@jpesce
jpesce / color-hex2term.py
Last active June 3, 2022 01:33
[Hex to 256 colors] Convert values between RGB hex codes and terminal 256 color codes.
#! /usr/bin/env python
""" Convert values between RGB hex codes and xterm-256 color codes.
Nice long listing of all 256 colors and their codes. Useful for
developing console color themes, or even script output schemes.
Resources:
* http://en.wikipedia.org/wiki/8-bit_color
* http://en.wikipedia.org/wiki/ANSI_escape_code
* /usr/share/X11/rgb.txt
I'm not sure where this script was inspired from. I think I must have
@jpesce
jpesce / enable-iterm-italics.sh
Last active September 17, 2020 13:02
[Iterm With Italics] Enable italics in iTerm
#!/bin/bash
# Override the local entry for xterm-256color
# See https://eddieantonio.ca/blog/2015/04/16/iterm-italics/
# Only affects your machine so remote machines simply won’t display italics
# which is better than having to create workarounds for ssh and tmux
infocmp xterm-256color > /tmp/xterm-256color.terminfo
printf '\tsitm=\\E[3m, ritm=\\E[23m,\n' >> /tmp/xterm-256color.terminfo
tic /tmp/xterm-256color.terminfo
@jpesce
jpesce / serializer.rb
Last active August 14, 2020 14:16
[Serializer] Prints serializer on console #Ruby #Rails
# default serializer
ActiveModelSerializers::SerializableResource.new(record_or_collection).as_json
# custom serializer
ActiveModel::SerializableResource.new(record, serializer: CustomSerializer).as_json
ActiveModel::SerializableResource.new(collection, each_serializer: CustomSerializer).as_json
@jpesce
jpesce / resizeImages.sh
Last active June 4, 2020 13:59
[Resize and compress images] Batch resize and compress JPGs #Image
find . -maxdepth 1 -iname "*.jpg" | xargs -L1 -I{} convert -resize x1080 -quality 60% "{}" _resized/"{}"
@jpesce
jpesce / convertTIFF2JPG.sh
Last active June 4, 2020 14:00
[TIFF to JPG] Batch convert TIFF files to JPG #Image
find . -iname "*.tif" -exec convert {}[0] -set filename:f "%d/%t" "%[filename:f].jpg" \;
# Max depth: 2
find . -iname "*.tif" -maxdepth 2 -exec convert {}[0] -set filename:f "%d/%t" "%[filename:f].jpg" \;