Skip to content

Instantly share code, notes, and snippets.

View jack-webb's full-sized avatar

Jack Webb jack-webb

View GitHub Profile
@jack-webb
jack-webb / install.sh
Last active October 1, 2022 14:59
Installing Oh My Zsh
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
@jack-webb
jack-webb / adb-screen-commands.sh
Created October 1, 2022 15:06
Change screen configuration with ADB
# Emulate any screen config
adb shell wm size 3200x1440 # The pixel size of the display
adb shell wm density 288 # Called "Display Size" or "Screen Zoom" in Settings
adb shell settings put system font_scale 0.5 # Any floating point number, common values are between 0.85 and 1.3
# Reset screen config back to default
adb shell wm size reset
adb shell wm density reset
adb shell settings put system font_scale 1.0
@jack-webb
jack-webb / adb-xargs-commands.sh
Last active October 1, 2022 15:34
Using ADB and xargs to interact with multiple devices
# Install an app and keep it's data, on all connected devices
adb devices | tail -n +2 | cut -sf 1 | xargs -IX adb -s X install -r {me.jackwebb.app}
# Grant a permission to your app, on all connected devices
adb devices | tail -n +2 | cut -sf 1 | xargs -IX adb grant {me.jackwebb.app} {READ_CONTACTS}
# Run an intent, on all connected devices
adb devices | tail -n +2 | cut -sf 1 | xargs -IX adb start {me.jackwebb.app} {my intent here}
@jack-webb
jack-webb / prepare-commit-msg.sh
Last active October 1, 2022 15:47
Prepend the branch name to your commit message automatically
#!/bin/bash
# Produces output like "[my-branch] My Commit" or "[TICKET] Add foo and bar"
# Use "BRANCHES_TO_SKIP" if you don't want to prepend
# the branch name onto commits on a certain branch
if [ -z "$BRANCHES_TO_SKIP" ]; then
 BRANCHES_TO_SKIP=(main develop my-special-branch)
fi
@jack-webb
jack-webb / scrcpy-install.sh
Last active October 7, 2022 06:36
Install and use scrcpy on MacOS
# Install scrcpy with brew.
brew install scrcpy
# Check your device is connected with adb.
adb devices
# Run scrcpy and start mirroring! Use Ctrl+C to exit.
scrcpy
# Record your scrcpy session with --record.
@jack-webb
jack-webb / basic-url-intent.kt
Created June 1, 2023 10:41
Opening a URI with ACTION_VIEW
val url = Uri.parse("https://www.asos.com/")
val browserIntent = Intent(Intent.ACTION_VIEW, url))
startActivity(browserIntent)
@jack-webb
jack-webb / better-url-intent.kt
Created June 1, 2023 10:44
A better way to open a link in the user's browser
val url = Uri.parse("https://www.asos.com/")
val browserSelectorIntent = Intent()
  .setAction(Intent.ACTION_VIEW)
  .addCategory(Intent.CATEGORY_BROWSABLE)
  .setData(Uri.parse("http:"))
val targetIntent = Intent()
  .setAction(Intent.ACTION_VIEW)
  .addCategory(Intent.CATEGORY_BROWSABLE)
@jack-webb
jack-webb / better-email-intent.kt
Created June 1, 2023 10:45
An intent for sending plain text in an email
val message = "Hello world!"
val emailSelectorIntent = Intent(Intent.ACTION_SENDTO).apply {
  setData(Uri.parse("mailto:"))
}
val targetIntent = Intent(Intent.ACTION_SEND).apply {
  putExtra(Intent.EXTRA_TEXT, message)
  type = "text/plain"
}