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
@thesamesam
thesamesam / xz-backdoor.md
Last active May 12, 2024 19:28
xz-utils backdoor situation (CVE-2024-3094)

FAQ on the xz-utils backdoor (CVE-2024-3094)

This is a living document. Everything in this document is made in good faith of being accurate, but like I just said; we don't yet know everything about what's going on.

Background

On March 29th, 2024, a backdoor was discovered in xz-utils, a suite of software that

@wijayaerick
wijayaerick / slog_console_handler.go
Last active November 25, 2023 06:40
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"}}
@Deminder
Deminder / inhibit-screensaver.lua
Last active June 17, 2023 12:09
Inhibit screensaver: mpv flatpak on GNOME wayland (workaround)
-- ~/.var/app/io.mpv.Mpv/config/mpv/scripts/inhibit-screensaver.lua
--
-- Workaround for inhibiting screensaver for io.mpv.Mpv flatpak (if not paused)
-- Issue: [vo/gpu/wayland] GNOME's wayland compositor lacks support for the idle inhibit protocol. This means the screen can blank during playback.
-- Until this is merged: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/111
-- Non-flatpak version: https://gist.github.com/crazygolem/a7d3a2d3c0cee5d072c0cbbbdee69286
--
-- NOTE: if mpv does not exit cleanly (e.g. with SIGKILL), an orphan process will keep inhibiting the screensaver
--
-- Arch: x86_64
@bert
bert / Makefile.example
Last active February 23, 2024 05:52
GTK4 Building applications
CC ?= gcc
PKGCONFIG = $(shell which pkg-config)
CFLAGS = $(shell $(PKGCONFIG) --cflags gtk4)
LIBS = $(shell $(PKGCONFIG) --libs gtk4)
GLIB_COMPILE_RESOURCES = $(shell $(PKGCONFIG) --variable=glib_compile_resources gio-2.0)
GLIB_COMPILE_SCHEMAS = $(shell $(PKGCONFIG) --variable=glib_compile_schemas gio-2.0)
SRC = exampleapp.c exampleappwin.c exampleappprefs.c main.c
BUILT_SRC = resources.c
@SeyedMostafaAhmadi
SeyedMostafaAhmadi / reload udev rules without reboot
Last active November 28, 2023 06:45
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
@crazygolem
crazygolem / mpv-gnome-inhibit.lua
Last active May 6, 2024 18:07
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.
@shadmansaleh
shadmansaleh / colorscheme_generator.lua
Last active January 14, 2022 06:31
Genarates colorscheme for corrent highlights in neovim
-- This script has been succeeded by
-- https://github.com/shadmansaleh/colorsceme_generator.nvim
-- Thid script is nolonger maintained so please use the plugin version.
-- This file creates a colorscheme from aleady available colorscheme
-- Author : Shadman Saleh
-- Licence : You can do whatever you want with it but do provide proper cradit
-- Uses :
@wolfeidau
wolfeidau / embed.go
Created December 20, 2020 21:03
Golang embed with echo and tests
package server
import (
"embed"
"net/http"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
@bmcbm
bmcbm / setup-nvdia-suspend.sh
Last active April 24, 2024 22:18
NVIDIA Suspend fix
# Use systemd for managing NVIDIA driver suspend in drivers ====>>> PRIOR to version 470 <<<=====
# https://download.nvidia.com/XFree86/Linux-x86_64/450.66/README/powermanagement.html
# https://forums.developer.nvidia.com/t/unable-to-set-nvidia-kernel-module-parameters/161306
# Please note: In Fedora Linux you may need to just install the xorg-x11-drv-nvidia-power pakage
# as sugested by @goombah88 in the comments below.
TMP_PATH=/var/tmp
TMPL_PATH=/usr/share/doc/nvidia-driver-460/
echo "options nvidia NVreg_PreserveVideoMemoryAllocations=1 NVreg_TemporaryFilePath=${TMP_PATH}" | sudo tee /etc/modprobe.d/nvidia-power-management.conf
@sainnhe
sainnhe / gruvbox-material-alacritty.yml
Last active May 2, 2024 15:49
Gruvbox Material for Alacritty
# The definition of color schemes.
schemes:
gruvbox_material_hard_dark: &gruvbox_material_hard_dark
primary:
background: '0x1d2021'
foreground: '0xd4be98'
normal:
black: '0x32302f'
red: '0xea6962'
green: '0xa9b665'