Skip to content

Instantly share code, notes, and snippets.

View ttys3's full-sized avatar
💭
sad, ttyS0 has been taken by other user

ttys3

💭
sad, ttyS0 has been taken by other user
View GitHub Profile
@ttys3
ttys3 / xz-backdoor.md
Created March 30, 2024 17:27 — forked from thesamesam/xz-backdoor.md
xz-utils backdoor situation

FAQ on the xz-utils backdoor

Background

On March 29th, 2024, a backdoor was discovered in xz-utils, a suite of software that gives developers lossless compression. This package is commonly used for compressing release tarballs, software packages, kernel images, and initramfs images. It is very widely distributed, statistically your average Linux or macOS system will have it installed for

@ttys3
ttys3 / reload udev rules without reboot
Created November 28, 2023 06:45 — forked from SeyedMostafaAhmadi/reload udev rules without reboot
How to reload udev rules without reboot?
# When i was faced with this warning in lvm when i run lvm command it works but it took
# WARNING: Device /dev/dm-20 not initialized in udev database even after waiting 10000000 microseconds.
# It look my problem is solved by reloading udev rules without reboot with this command:
udevadm control --reload-rules && udevadm trigger
@ttys3
ttys3 / ANSI.md
Created August 31, 2023 03:26 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@ttys3
ttys3 / string-conversion.rs
Created March 19, 2023 17:24 — forked from jimmychu0807/string-conversion.rs
Conversion between String, str, Vec<u8>, Vec<char> in Rust
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();
// to vec of byte
@ttys3
ttys3 / slog_console_handler.go
Created February 2, 2023 15:29 — forked from wijayaerick/slog_console_handler.go
Example ConsoleHandler for golang.org/x/exp/slog Logger
// ConsoleHandler formats slog.Logger output in console format, a bit similar with Uber's zap ConsoleEncoder
// The log format is designed to be human-readable.
//
// Performance can definitely be improved, however it's not in my priority as
// this should only be used in development environment.
//
// e.g. log output:
// 2022-11-24T11:40:20+08:00 DEBUG ./main.go:162 Debug message {"hello":"world","!BADKEY":"bad kv"}
// 2022-11-24T11:40:20+08:00 INFO ./main.go:167 Info message {"with_key_1":"with_value_1","group_1":{"with_key_2":"with_value_2","hello":"world"}}
// 2022-11-24T11:40:20+08:00 WARN ./main.go:168 Warn message {"with_key_1":"with_value_1","group_1":{"with_key_2":"with_value_2","hello":"world"}}
@ttys3
ttys3 / jpodaudio.go
Created December 23, 2022 14:47 — forked from funayman/jpodaudio.go
Simple JapanesePod101 Audio Downloader
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
)
@ttys3
ttys3 / ffmpeg_example.rs
Created September 25, 2022 10:02 — forked from yongkyuns/ffmpeg_example.rs
FFMPEG usage in rust using command and raw pixels
use std::io::prelude::*;
use std::process::{Command, Stdio};
fn main() {
let mut child = Command::new("ffmpeg")
// Overwrite file if it already exists
.arg("-y")
// Interpret the information from stdin as "raw video" ...
.arg("-f")
.arg("rawvideo")
@ttys3
ttys3 / mpv-gnome-inhibit.lua
Created May 8, 2022 04:14 — forked from crazygolem/mpv-gnome-inhibit.lua
Prevent the screen from blanking under GNOME+Wayland while a video is playing
--[[
Prevent the screen from blanking while a video is playing.
This script is a workaround for the GNOME+Wayland issue documented in the
[Disabling Screensaver] section of the mpv manual, and depends on
gnome-session-inhibit (usually provided by the gnome-session package) to set up
the inhibitors.
@ttys3
ttys3 / fstab-generate-arch.md
Created April 6, 2022 09:37 — forked from Brainiarc7/fstab-generate-arch.md
Generate fstab in Arch Linux

First, install arch-install-scripts:

sudo pacman -S --needed arch-install-scripts

Secondly, mount your partitions in all the internal hard drives.

Thirdly, generate and validate your config by piping it out to stdout: