Skip to content

Instantly share code, notes, and snippets.

@sharunkumar
sharunkumar / adbdns.bat
Created February 7, 2020 07:39
Windows batch file to toggle private dns setting in android via adb
@echo off
setlocal ENABLEDELAYEDEXPANSION
for /F %%i in ('adb shell settings get global private_dns_mode') do set dnsmode=%%i
for /F %%i in ('adb shell settings get global private_dns_specifier') do set dnshost=%%i
echo current dns setting is: !dnsmode!
if "!dnsmode!"=="hostname" (
echo current dns host is: !dnshost!
echo turning off private dns...
adb shell settings put global private_dns_mode off
@grational
grational / vim-recover.sh
Created March 2, 2020 09:37
vim-recover: recover all the vim orphan swap files
#!/usr/bin/env bash
# vim-recover: recover all the orphan swap files
# @version: 0.5b
# @require: set directory=~/.config/nvim/swap_files//
# @author: Giuseppe Ricupero
# @e-mail: [email protected]
set -euo pipefail
IFS=$'\n\t'
vim_flavour=/usr/bin/vim
@chrisanthropic
chrisanthropic / nixos-raspi4.md
Last active August 14, 2024 17:01
NixOS + Raspi4

Download the image builder

  • git clone [email protected]:Robertof/nixos-docker-sd-image-builder.git
  • cd nixos-docker-sd-image-builder

Configure for Raspi4

  • modify /config/rpi4/default.nix to increase size of boot partition
    • this step is optional but I ran out of space in /boot pretty quickly with the default setting since I'm still learning and rebuilding a lot. Let's leave some room for trial & error.
    • sdImage.firmwareSize = 1024;
  • modify /config/sd-image.nix
  • ./rpi3 becomes ./rpi4
@roalcantara
roalcantara / 0_tldr.zsh
Last active February 18, 2025 02:02
Glob (globbing)
## TL;DR
setopt extendedglob
ls *(<tab> # to get help regarding globbing
rm ../debianpackage(.) # remove files only
ls -d *(/) # list directories only
ls /etc/*(@) # list symlinks only
ls -l *.(png|jpg|gif) # list pictures only
ls *(*) # list executables only
ls /etc/**/zsh # which directories contain 'zsh'?
@dianoetic
dianoetic / README.md
Last active July 14, 2023 01:32
A GitHub Action for sending webmentions after your site builds

Send Webmentions with GitHub Actions

Action that uses curl to send your webmentions. It gets the most recent addition to a JSON feed (ideally, your latest post), looks for the value of a key called uri (ideally, your post's permalink) and sends webmentions for it.

The services currently in the file are webmention.app and brid.gy, but any service that can be triggered with a POST request will work fine with this.

This workflow file is run once another GitHub Action named "Build" completes successfully.

Usage

@abalta
abalta / Cryptography.kt
Last active July 20, 2023 00:24
AndroidKeystore Kotlin Usage
package com.marsathletic.android.macfit.app.base
import android.security.keystore.KeyGenParameterSpec
import android.security.keystore.KeyProperties
import android.util.Base64
import java.io.IOException
import java.nio.charset.StandardCharsets
import java.security.*
import java.security.cert.CertificateException
import javax.crypto.*
@stranger-danger-zamu
stranger-danger-zamu / convert_flac_for_usb.sh
Created November 7, 2021 19:33
Parallel convert FLAC files to MP3 with `fd` or `find`
#!/usr/bin/env bash
ffmepg -i "${1}" -ab 320k -map_metadata 0 -id3v2_version 3 "${2}"
kid3-cli -c 'fromtag "%{artist} - %{album} - %{track}. %{title}" 2' "${2}"
@agnostic-apollo
agnostic-apollo / Android-Phantom,Cached-And-Empty-Processes.md
Last active February 23, 2025 01:52
Android Phantom, Cached And Empty Processes
@InternetUnexplorer
InternetUnexplorer / command-not-found.sh
Last active March 17, 2024 11:53
Improved home-manager nix-locate configuration, with an auto-updated index and a better command-not-found handler
# Adapted from https://github.com/bennofs/nix-index/blob/master/command-not-found.sh
command_not_found_handle () {
if [ -n "${MC_SID-}" ] || ! [ -t 1 ]; then
>&2 echo "$1: command not found"
return 127
fi
echo -n "searching nix-index..."
ATTRS=$(@nix-locate@ --minimal --no-group --type x --type s --top-level --whole-name --at-root "/bin/$1")
@vvb2060
vvb2060 / am_proc_start.cpp
Created July 19, 2022 17:12
monitor app process start
#include <unistd.h>
#include <string>
#include <cinttypes>
#include <android/log.h>
#include <sys/system_properties.h>
using namespace std;
extern "C" {