Skip to content

Instantly share code, notes, and snippets.

View KSXGitHub's full-sized avatar
🏠
Working from home

Khải KSXGitHub

🏠
Working from home
  • Earth, Solar System, Orion Arm, Milky Way
  • X @hvksmr1996
View GitHub Profile
@KSXGitHub
KSXGitHub / hex.rs
Created October 27, 2024 14:32
Hex manipulation
use core::mem::size_of;
pub trait ParseHex: Sized {
fn parse_hex(input: &str) -> (&'_ str, Self);
}
macro_rules! impl_parse_hex {
($($num:ident)*) => {$(
impl<const LEN: usize> ParseHex for [$num; LEN] {
fn parse_hex(input: &str) -> (&str, Self) {
@KSXGitHub
KSXGitHub / uad_exported_selection.txt
Last active October 27, 2024 18:46
Samsung Galaxy bloatware list
com.google.android.gms.supervision
com.microsoft.skydrive
com.samsung.android.game.gametools
com.samsung.android.game.gos
com.samsung.android.knox.zt.framework
com.samsung.android.peripheral.framework
com.samsung.cmfa.AuthTouch
com.sec.android.app.samsungapps
com.sec.spp.push # <-- this is the annoying notifications that "recommended" apps to have
@KSXGitHub
KSXGitHub / SmartTube on Android x86 on virt-manager on Linux.md
Last active October 19, 2023 16:41
notes: How to create best experience with SmartTube on Android x86 virtualization on virt-manager on Linux

Prerequisites

  • Host OS: Linux
  • Program: virt-manager
  • Intel Virtualization Technology (to enable OpenGL for good framerate)

OpenGL for good FPS

  1. Enable Intel Virtualization Technology in the BIOS.
  2. Add intel_iommu=on iommu=pt to your kernel parameters (of the host OS).
@KSXGitHub
KSXGitHub / Share
Created August 29, 2022 16:26
~/.local/share/nautilus/scripts/Share
#!/bin/bash
set -o errexit -o pipefail -o nounset
if [[ "${TERMINAL_OPENED:-false}" == 'false' ]]; then
exec gnome-terminal -- env TERMINAL_OPENED=true "$0" "$@"
fi
storage=$(mktemp -d)
echo "🛈 Created $storage" >&2
@KSXGitHub
KSXGitHub / spike-ram.sh
Created February 10, 2022 11:43
Consume 2GiB of RAM
#!/bin/bash
set -o errexit -o pipefail -o nounset
echo 'Consuming RAM. Press Ctrl-C to stop.' >&2
while true; do
echo {0..8388608} >/dev/null
done
@KSXGitHub
KSXGitHub / 2021-05-28-announce-parallel-disk-usage-pdu.blog.md
Last active May 29, 2021 15:48
Announcement: Parallel Disk Usage (pdu) — A highly parallelized, blazing fast disk usage visualizer

Announcement: Parallel Disk Usage (pdu) — A highly parallelized, blazing fast disk usage visualizer

Here is the link to the git repository in case you desire none of my ramblings: https://github.com/KSXGitHub/parallel-disk-usage.

About dust

In the past few months, I have always used dust to visualize disk usages of heavy directories. It displays an intuitive bottom-up tree from heavier items to lighter ones. Every item is attached with a percentage bar that allow me to compare the relative size 2 sibling items as well as their parent. I quite like it.

I would soon discover its limits however.

import { createReadStream } from 'fs'
import { createInterface } from 'readline'
const READ_STREAM_OPTIONS = { encoding: 'utf8' } as const
export function firstLine (filename: string) {
const stream = createReadStream(filename, READ_STREAM_OPTIONS)
const reader = createInterface(stream)
let result: string
reader.once('line', line => {
@KSXGitHub
KSXGitHub / tmp.zsh
Last active February 27, 2020 11:30
#! /usr/bin/env zsh
script=https://ksxgithub.github.io/my-deno-scripts/cmd/insert-object-key.ts
deno fetch $script
run=(deno run $script)
insert=($run --before dependencies)
args-to-list packages/*/package.json | while read filename; do
echo '>>>' $filename
< $filename |
$insert browser '"index.mjs"' |
$insert module '"index.mjs"' |
import xs from 'xstream'
import spawn from 'advanced-spawn-async'
import { Option, Some, some, none, match } from '@tsfun/option'
export enum Status {
Plugged = 'Plugged',
Unplugged = 'Unplugged'
}
type UnknownStatus = Status | 'Unknown'