Skip to content

Instantly share code, notes, and snippets.

View filipechagas's full-sized avatar
🏖️
...

Filipe Chagas filipechagas

🏖️
...
View GitHub Profile
@filipechagas
filipechagas / twitter-inspector-scrapping.js
Last active September 5, 2024 18:33
Twitter Followers Inspector-Scrapping
// Source: https://x.com/FelippeRegazio/status/1829529731320160675
const result = [];
const running = { interval: null };
const $column = document.querySelector('[data-testid="primaryColumn"]');
function scrap() {
const $user = $column.querySelector('[data-testid="cellInnerDiv"]');
if (!$user && running.interval) {
@filipechagas
filipechagas / dnsmasq OS X.md
Created July 27, 2022 11:24 — forked from ogrrd/dnsmasq OS X.md
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.

Requirements

Install

@filipechagas
filipechagas / docker-remote-host-api.md
Created July 26, 2022 18:54
Configuring a Docker Server for local development with Docker Remote Host API

Configuring a Docker Server for local development with Docker Remote Host API

This assumes both machines, server and client, are on the same network and the port that will be used is open for network connections.

On the server

Assuming you already have docker installed

vi /lib/systemd/system/docker.service

@filipechagas
filipechagas / pg-advisory-lock.sql
Created September 2, 2021 17:11
Postgres Advisory Lock - Pessimistic application enforced lock
SELECT version, json_content, pg_try_advisory_xact_lock(s.id) as locked, s.id as id
FROM snapshots s
WHERE ar_id = $1
-- from https://github.com/crabzilla/crabzilla/blob/f66e43ca4d7c119a00fab68c48386aa7672b0e95/crabzilla-engine-postgres/src/main/java/io/github/crabzilla/engine/command/CommandController.kt#L48
-- more at https://hashrocket.com/blog/posts/advisory-locks-in-postgres
@filipechagas
filipechagas / sendtotmux.vim
Created July 15, 2021 19:26
VI mapping to execute tests on tmux
map <leader>t :call SendToTmux("clear\ryarn test:unit " . expand('%') . "\r")<cr>
@filipechagas
filipechagas / setuppsql.sh
Created July 1, 2021 19:44
Setting up PostgreSQL in Manjaro
sudo pacman -S postgresql postgis
sudo su postgres -l # or sudo -u postgres -i
initdb --locale $LANG -E UTF8 -D '/var/lib/postgres/data/'
exit
sudo systemctl enable --now postgresql.service
sudo su postgres -c psql
CREATE USER deployer WITH PASSWORD 'eldeployerloco';
@filipechagas
filipechagas / arch-caps-map.md
Created June 29, 2021 20:35
Arch - Map Caps to Esc (press) and Control (press and hold)

pacman -S interception-tools interception-caps2esc

Create /etc/interception/udevmon.d/caps2esc.yaml with the following content:

- JOB: "intercept -g $DEVNODE | caps2esc | uinput -d $DEVNODE"
  DEVICE:
    EVENTS:
      EV_KEY: [KEY_CAPSLOCK, KEY_ESC]
@filipechagas
filipechagas / smallest.rb
Created April 23, 2021 17:48
Smallets Positive Integer
class Smallest
def self.resolve(array_size, array_of_numbers)
( (1..array_size + 1).to_a - array_of_numbers ).min
end
end
@filipechagas
filipechagas / git-filter-branch.md
Created August 26, 2020 18:32
Git filter-branch

Git filter-branch

So today I noticed my git repository was taking too much disk space and discovered it was due to bundler caching gems. At first I thought I'd just remove vendor/cache directory it be done with it. But that's not how git works, is it?

That's how I came across git filter-branch.

The following command will remove the vendor/cache directory and all its references throughout your repository history.

git filter-branch --force --index-filter "git rm --cached --ignore-unmatch -r vendor/cache"

@filipechagas
filipechagas / mysql-docker.sh
Created July 29, 2020 16:07 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE