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 / ffmpeg-gif.sh
Created July 21, 2023 11:49
ffmpeg-gif.sh
#!/usr/bin/env bash
set -eou pipefail
if [ "$#" -ne 2 ]; then
echo "Usage: $0 input_file output_file"
exit 1
fi
input_file="$1"
@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 / display-wakeup.sh
Last active January 13, 2023 10:54
display-wakeup.sh
#!/bin/sh
/usr/bin/dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.SetActive boolean:true && /usr/bin/sleep 3 && /usr/bin/dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.SetActive boolean:false
@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")