Skip to content

Instantly share code, notes, and snippets.

View petitJAM's full-sized avatar
🤖
beep boop Androids

Alex Petitjean petitJAM

🤖
beep boop Androids
View GitHub Profile
@petitJAM
petitJAM / launch.sh
Created June 9, 2023 18:48
Launch an Activity with ADB
// Ensure the activity has android:exported="true" in the manifest
adb shell am start -n my.package.name/my.package.path.to.MyActivity
@petitJAM
petitJAM / ddcutil_cheat_sheet.md
Last active August 14, 2022 14:25
`ddcutil` Cheat Sheet

ddcutil

winddcutil This implements a slightly different API, so the commands are similar to what's below, but not quite the same.

Run everything with sudo.

List displays:

ddcutil detect
@petitJAM
petitJAM / update_zoom.sh
Created April 26, 2022 14:58
Automatically install Zoom on Ubuntu/Debian
#!/bin/bash
if [ "$EUID" -ne 0 ]
then
echo "Root required to install"
exit
fi
file=/tmp/zoom_amd64.deb
@petitJAM
petitJAM / prepare-commit-msg.md
Last active August 3, 2023 17:43
Git hook for preparing commit message with ticket ID from branch name

Place the following in .git/hooks/prepare-commit-msg and mark it as executable (chmod +x .git/hooks/prepare-commit-msg).

#!/bin/bash

is_amend=$(ps -ocommand= -p $PPID | grep -e '--amend')
if [ -n "$is_amend" ]; then
  exit 0
fi
@petitJAM
petitJAM / containerize.md
Created December 14, 2021 16:33
Containerize Bookmark

Source: mozilla/multi-account-containers#854 (comment)

  1. Install this extension it requires no permissions.
  2. Open bookmark manager Library -> Bookmarks > All Bookmarks
  3. Create a bookmarklet by clicking Organize -> New Bookmark,
  4. Name: Containerize a Bookmark
  5. Location:
    javascript:(function(c,u){c&&(c=c.trim())&&(u=prompt('URL?',location))&&(u=u.trim())&&prompt('Contained URL to copy and bookmark:','ext+container:name='+encodeURIComponent(c)+'&url='+encodeURIComponent(u))})(prompt('Container name?','Personal'))
    
@petitJAM
petitJAM / remove-videos.js
Last active April 29, 2021 18:03
Remove videos from YouTube channel Videos tab
// Filter videos by title containing this text.
var text = "Repentance"
document.querySelectorAll('ytd-grid-video-renderer').forEach((video) => {
if (video.querySelector('a#video-title').text.includes(text)) {
video.remove()
}
});
// A loading indicator gets stuck after deleting a bunch of stuff, so this deletes them all.
@petitJAM
petitJAM / cheetsheet.md
Last active January 5, 2021 18:07
Tmux / Tmuxinator Cheat Sheet

Show the layout strings: list-windows

@petitJAM
petitJAM / gist:b3bf2df3a06369d56c20eb7e3c8e6161
Created November 10, 2020 03:29
uBlock Origin - Twitch Fix
# https://github.com/uBlockOrigin/uAssets/pull/3517
twitch-videoad.js application/javascript
(function() {
if ( /(^|\.)twitch\.tv$/.test(document.location.hostname) === false ) { return; }
var realFetch = window.fetch;
window.fetch = function(input, init) {
if ( arguments.length >= 2 && typeof input === 'string' && input.includes('/access_token') ) {
var url = new URL(arguments[0]);
url.searchParams.forEach(function(value, key) {
url.searchParams.delete(key);
@petitJAM
petitJAM / post-merge.bash
Last active May 22, 2019 15:36
Post-merge check for Rails things (migrations, gems, yarn packages)
#!/bin/bash
# https://gist.github.com/petitJAM/7f3cb7de846cbe1878d1f8b2945e03e2
DIFF=`git diff --name-only HEAD@{1} HEAD`
YARN=`expr "$DIFF" : ".*package\.json.*"`
MIGRATE=`expr "$DIFF" : ".*db/migrate.*"`
BUNDLE=`expr "$DIFF" : ".*Gemfile*"`
adb shell screencap -p /sdcard/screencap.png
# Get the screenshot and redirect command output to nowhere so it's quiet.
adb pull /sdcard/screencap.png /tmp/adbcp.png > /dev/null
xclip -selection clipboard -t image/png -i /tmp/adbcp.png
echo Screenshot copied to clipboard!