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 / 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 / clean-systemd-logs.sh
Created May 5, 2022 08:09
clean-systemd-logs.sh
#!/bin/sh
# ref https://unix.stackexchange.com/a/457902
journalctl --rotate
journalctl --vacuum-time=1s
@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:

@ttys3
ttys3 / keyboard-keys.md
Created March 4, 2022 12:37 — forked from bittner/keyboard-keys.md
Keyboard keys markup in MarkDown

Ctrl + Alt + Space

@ttys3
ttys3 / eatmem.c
Last active February 4, 2022 04:26 — forked from pfigue/eatmem.c
Eat Memory. In C. For testing memory limits.
// Compile with e.g. `gcc -o /tmp/eatmem /tmp/eatmem.c`
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define DEFAULT_SLEEP_SECONDS 600
#define DEFAULT_ALLOC_MB 1024
@ttys3
ttys3 / podman-create-container-via-api.sh
Last active February 3, 2022 08:51
create a podman container with fifo named pipe as log file
#!/bin/sh
# create a podman container with fifo named pipe as log file
# for demonstrate issue https://github.com/containers/podman/issues/13081
CTR_NAME="redis-demo"
function print_title() {
title=$1
echo ""
echo "|=================== $title ===================>>>"
@ttys3
ttys3 / latency.markdown
Created December 15, 2021 12:48 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@ttys3
ttys3 / luasocket-scm-3.rockspec
Last active October 19, 2021 09:52
luasocket lua 5.4.3 buffer fix err: luasocket receive() call fails on Lua 5.4.3 with "bad argument #1 to 'receive' (string expected, got light userdata)"
-- see http://lua-users.org/lists/lua-l/2021-06/msg00084.html
-- https://github.com/diegonehab/luasocket/pull/334
-- https://github.com/diegonehab/luasocket/issues/331
-- install command:
-- cd /tmp/ && curl -LO https://gist.github.com/ttys3/31dbf88ee7d708294d8ae5b0a4954424/raw/c74afc3edc1a48c0f7e1c2c9992750301bbb74ff/luasocket-scm-3.rockspec
-- luarocks install ./luasocket-scm-3.rockspec
package = "LuaSocket"
version = "scm-3"
source = {
@ttys3
ttys3 / curl_post_json.md
Created October 6, 2021 23:20 — forked from ungoldman/curl_post_json.md
post a JSON file with curl

How do you POST a JSON file with curl??

You can post a json file with curl like so:

curl -X POST -H "Content-Type: application/json" -d @FILENAME DESTINATION

so for example: