Skip to content

Instantly share code, notes, and snippets.

View tytydraco's full-sized avatar
🦆
Quack!

Tyler Nijmeh tytydraco

🦆
Quack!
View GitHub Profile
@tytydraco
tytydraco / sched_hz_calc.py
Last active May 24, 2019 19:31
Find the ideal HZ rate for the assumed data.
import math
import decimal
### BEGIN USER TUNABLS ###
tolerance = 14 # max ms for scheduling
tasks = 8 # avg tasks occurring at any instance
cores = 8 # cores allowed to contain tasks
hz_min = 1 # min hz allowed
hz_max = 2000 # max hz allowed
inc = 1 # hz increment
@tytydraco
tytydraco / covid.py
Created April 15, 2020 23:47
Cubic Spline of current data from WHO
import urllib.request, json
import matplotlib.pyplot as plt
import numpy
from scipy.interpolate import *
with urllib.request.urlopen("https://pomber.github.io/covid19/timeseries.json") as url:
data = json.loads(url.read().decode())
date = []
@tytydraco
tytydraco / defconfig_differ.py
Created June 21, 2020 17:41
Script do get all changes that differ from the original base defconfig, ideally to apply the changes to another device config in the future.
import re, sys
if len(sys.argv) != 3:
print(f"""Usage: {sys.argv[0]} <base_defconfig> <custom_defconfig>
For best results, use savedefconfig generated configs.""")
exit(1)
cfg_base = sys.argv[1]
cfg_custom = sys.argv[2]
@tytydraco
tytydraco / interp.py
Created May 7, 2019 00:30
Cubic + Linear Interpolation + Extrapolation for QCOM Energy Model Porting
#!/usr/bin/python
# Tyler Nijmeh <tylernij@gmail.com>
from scipy import interpolate
# P.S.: The default target values are from sdm660
# P.S.: The default source values are from sdm632
# Target frequencies
target_cluster0_freqs = [633600, 902400, 1113600, 1401600, 1536000, 1747200, 1843200]
@tytydraco
tytydraco / charch_wrapper.sh
Last active July 16, 2020 23:02
A wrapper for easy portable ChArch usage.
# Written by Draco (tytydraco) @ GitHub
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# ChArch local bin path
BINPATH="$SCRIPTPATH/bin"
# Options to pass to ChArch commands
CHARCH_OPTS="-d $SCRIPTPATH"
@tytydraco
tytydraco / cmdpatch.sh
Created August 6, 2020 04:19
An Android Linux Kernel command line patch tool using Magisk's magiskboot binary.
#!/system/bin/sh
# Written by Draco (tytydraco @ GitHub)
set -e
MAGISKBOOT="/data/adb/magisk/magiskboot"
err() {
echo -e "\e[91m[!] $@\e[39m"
exit 1
@tytydraco
tytydraco / charch_install.sh
Last active September 17, 2020 04:02
Setup ChArch for Linux machines in /usr/bin/.
#!/bin/bash
# Written by Draco (tytydraco) @ GitHub
# Check for root permissions
if [[ `id -u` -ne 0 ]]
then
echo "[!] No root permissions. Exiting."
exit 1
fi
@tytydraco
tytydraco / cleaner.sh
Last active June 4, 2021 23:52
Clear data and cache of disabled pacakges
#!/usr/bin/env bash
disabled_pks="$(pm list packages -d | sed 's/package://')"
for pkg in $disabled_pks
do
echo "----- $pkg -----"
pm uninstall "$pkg" &> /dev/null
echo "- UNINSTALLED UPDATES"
pm disable-user "$pkg" &> /dev/null
echo "- DISABLED AGAIN"
@tytydraco
tytydraco / hash.sh
Last active June 18, 2021 19:57
Open an ADB shell session on an Android system via netcat
#!/system/bin/sh
LOCAL=false
PORT=65432
usage() {
echo "Usage: $0 [-h] [-l] [-k] [-p PORT]
-h Show this screen
-l Only allow localhost connections
-k Kill any open netcat sessions
@tytydraco
tytydraco / chrome_keys.sh
Created June 26, 2021 05:51
Quick chrome audio control: "[" -15%; "]" +15%
#!/usr/bin/env bash
xinput test-xi2 --root 3 | \
gawk '/RawKeyRelease/ {getline; getline; print $2; fflush()}' | \
while read -r key
do
[[ "$key" -ne 34 && "$key" -ne 35 ]] && continue
VOL="+15%"
[[ "$key" -eq 34 ]] && VOL="-15%"