Skip to content

Instantly share code, notes, and snippets.

View sheerlox's full-sized avatar
:shipit:
Getting things done (but not always the right ones)

Pierre Cavin sheerlox

:shipit:
Getting things done (but not always the right ones)
View GitHub Profile
@sheerlox
sheerlox / ash_date_compare.ex
Last active April 10, 2024 14:20
A custom "compare" validator for Elixir's Ash framework that works with Date strings, structs, attributes and arguments.
# Adapted from Ash.Resource.Validation.Compare
defmodule DateCompare do
use Ash.Resource.Validation
alias Ash.Error.Changes.InvalidAttribute
@compare_opts [
attribute: [
type: :atom,
@sheerlox
sheerlox / android-backup-apk-and-datas.md
Created January 30, 2024 22:56 — forked from AnatomicJC/android-backup-apk-and-datas.md
Backup android app, data included, no root needed, with adb

Backup android app, data included, no root needed, with adb

adb is the Android CLI tool with which you can interact with your android device, from your PC

You must enable developer mode (tap 7 times on the build version in parameters) and install adb on your PC.

Don't hesitate to read comments, there is useful tips, thanks guys for this !

Fetch application APK

Please avoid "me too" or "+1" comments. Instead, use a thumbs up reaction on enhancement requests. Maintainers will often prioritize work based on the number of thumbs on an issue.
@sheerlox
sheerlox / PULL_REQUEST_TEMPLATE.md
Created October 17, 2019 16:12
Pull Request template for Conventional Commits and Jira issues

Pull Request template

Please, go through these steps before you submit a PR.

  1. Make sure the title of the Pull Request title respects the Conventional Commits Spec:

    a. Must be in the following format: {type}({optional JIRA ticket}): {Description} (e.g. feat(EC-1063): Add missing Criteo variables, docs: Add PR template).

    b. Type must be one of the following:

    • feat: A new feature
  • improvement: A feature improvement
@sheerlox
sheerlox / build_and_publish_docker.sh
Last active October 9, 2019 23:22
Script to increment, build and push an image version from Dockerhub.
#!/bin/bash
# Script to increment, build and push an image version from Dockerhub.
# Copyright (C) 2019 Pierre Cavin (tech@sherlox.io)
# Permission to copy and modify is granted under the MIT License.
#################################################################################
# WARNING: You must use versions like "MAJOR.MINOR.PATCH" with digits only.
# Pre-release and build metadata labels are not supported (contribs are welcome).
#################################################################################
@sheerlox
sheerlox / knex-on-duplicate-key-update.js
Created May 27, 2019 09:40
How to use ON DUPLICATE KEY UPDATE with Knex.js insert
knex.raw(
await knex
.insert({
a: 1,
b: 2,
c: 3,
d: 4
})
.into('my_table')
.toQuery() +
@sheerlox
sheerlox / linkedin-remove-connections.js
Last active May 8, 2019 21:07
Navigate to this page: https://www.linkedin.com/search/results/people/?facetNetwork=%5B"F"%5D, then paste this code in your console (Ctrl + Shift + I, Console Tab), then do not touch anything on your computer. Remember to adjust your filters before.
/* global fetch */
// TODO: Brute API Method = Collect all IDs to remove, then rekt API limits
// Array of string that will lead to no
// deletion if found in a search result card
const filterTerms = [
'Toulouse',
'Midi-Pyrénées',
'Bordeaux',
@sheerlox
sheerlox / sshgpgperm.sh
Last active March 12, 2018 11:28 — forked from ChristopherA/sshgpgperm.sh
SSH & GPG Folders Permissions
chmod 755 ~
chmod 600 ~/.ssh/*
chmod 600 ~/.ssh/id_*
chmod 600 ~/.ssh/github_rsa
chmod 644 ~/.ssh/*.pub
chmod 644 ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.gnupg/*
chmod 700 ~/.gnupg
chmod 700 ~/.gnupg/openpgp-revocs.d/
@sheerlox
sheerlox / bitcoind-monitor.sh
Last active August 22, 2017 02:05
Bitcoind synchronization monitor
#!/bin/bash
clear
while true; do
BLOCKS=$(bitcoin-cli -datadir=/bitcoin getblockchaininfo | grep 'blocks' | cut -d' ' -f4 | cut -d',' -f1)
SYNC=$(bitcoin-cli -datadir=/bitcoin getblockchaininfo | grep 'progress' | cut -d' ' -f4 | cut -d',' -f1)
USED=$(df -h | grep bitcoin | sed -e's/ */ /g' | cut -d' ' -f3)
TOTAL=$(df -h | grep bitcoin | sed -e's/ */ /g' | cut -d' ' -f2)
echo -ne $BLOCKS blocks
echo -ne " | "
@sheerlox
sheerlox / ssh_fix.sh
Last active March 3, 2019 11:01
Fix for ssh-agent failing after disabling gnome-keyring in Ubuntu, execute after startup.
#!/bin/bash
SSH=$(ssh-agent -s)
SSH_AUTH_SOCK=$(echo "$SSH" | sed '2d' | sed '2d' | cut -d'=' -f2 | cut -d';' -f1)
SSH_AGENT_PID=$(echo "$SSH" | sed '1d' | sed '2d' | cut -d'=' -f2 | cut -d';' -f1)
export SSH_AUTH_SOCK;
export SSH_AGENT_PID;