Skip to content

Instantly share code, notes, and snippets.

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 — forked from crazygolem/mpv-gnome-inhibit.lua
Prevent the screen from blanking under GNOME+Wayland while a video is playing
View mpv-gnome-inhibit.lua
--[[
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
clean-systemd-logs.sh
View 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 Apr 6, 2022 — forked from Brainiarc7/fstab-generate-arch.md
Generate fstab in Arch Linux
View fstab-generate-arch.md

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:

View Hyperlinks_in_Terminal_Emulators.md
@ttys3
ttys3 / keyboard-keys.md
Created Mar 4, 2022 — forked from bittner/keyboard-keys.md
Keyboard keys markup in MarkDown
View keyboard-keys.md

Ctrl + Alt + Space

@ttys3
ttys3 / eatmem.c
Last active Feb 4, 2022 — forked from pfigue/eatmem.c
Eat Memory. In C. For testing memory limits.
View eatmem.c
// 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 Feb 3, 2022
create a podman container with fifo named pipe as log file
View podman-create-container-via-api.sh
#!/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 Dec 15, 2021 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know
View latency.markdown

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 Oct 19, 2021
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)"
View luasocket-scm-3.rockspec
-- 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 Oct 6, 2021 — forked from ungoldman/curl_post_json.md
post a JSON file with curl
View curl_post_json.md

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: