Skip to content

Instantly share code, notes, and snippets.

View gnat's full-sized avatar
:shipit:
ez pz lemon squeezy

Nathaniel Sabanski gnat

:shipit:
ez pz lemon squeezy
View GitHub Profile
@gnat
gnat / sample.md
Last active June 16, 2022 09:39
Odysee does not have trivial embeds yet

You can generate YouTube embed codes by just re-using the ID found in the browser bar. Typical users know only the link they see in the browser bar.

We need a way to get an embed link without scraping please! Youtube and Vimeo both allow it.

This is a note for the devs at Odysee. Hello :)

Vimeo

The URL from the browser window itself: https://vimeo.com/35477260 With 35477260 we can trivially generate the embedded code:

  • FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. Typically you can use it in command lines or GUI, and many popular video editors are developed based on FFmpeg. Some usage examples are as follows:
    • Transcoding: ffmpeg -i input.mp4 output.avi
    • Video clipping: ffmpeg -i input.mkv -ss 11 -to 15 out.mkv to get a video clip from 11 second to 15 second. You can also replace -ss 11 -to 15 with -ss 00:00:11 -to 00:00:15 or -ss 00:11 -to 00:15 or -ss 00:11 -t 5 where parameter -t devotes time duration.
    • Video Frame screenshot: ffmpeg -i input.mkv -ss 5 -vframes 1 img.jpg to get the 1st frame in the selected second.
    • Watermark: ffmpeg -i input.mkv -i logo.png -filter_complex "[1]scale=192:108[b];[0][b]overlay=20:20" output.mkv with parameter scale for resizing watermark and overlay for watermark location (top-left pixel location). Use -filter_complex "overlay=20:20" instead if you don't need to scale wat
@gnat
gnat / 30_ubuntu-unity.gschema.override
Created January 3, 2023 16:07
Ubuntu Unity patch for sane window snapping defaults during installation.
# Needs review, but goes in: /usr/share/glib-2.0/schemas/30_ubuntu-unity.gschema.override
[org.compiz.grid]
bottom-edge-action = 2
bottom-left-corner-action = 1
bottom-right-corner-action = 3
top-left-corner-action = 7
[org/compiz/profiles/unity/plugins/grid]
bottom-edge-action = 2
@gnat
gnat / quick_ssh.md
Last active January 6, 2023 16:19
Server / Ubuntu SSH quickstart changme.

Setup SSH

  • sudo apt install ssh curl -y
  • mkdir -p ~/.ssh; curl https://github.com/gnat.keys >> ~/.ssh/authorized_keys; chmod 600 ~/.ssh/authorized_keys
  • sudo echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
  • sudo systemctl reload ssh

You can now use ssh to do a proper setup.

This is can also be done at install time in the Ubuntu Server GUI.

@gnat
gnat / ufw_limit_raise.md
Last active January 31, 2023 13:03
ufw limit raise on ubuntu 22.04

Raise the default limit for ufw

Allows you to benefit from ufw's limit protection without being too restrictive.

tl;dr: increase --hitcount 6 to something larger in /etc/ufw/user.rules for your rule.

Example for SSH

  • Make rule ufw limit from YOUR_IP to any port 22 proto tcp
  • Increase limit
@gnat
gnat / kernel.6.2.md
Created February 20, 2023 12:28
Ubuntu 23.04 upgrade to Kernel 6.2

Installation

Linux Kernel 6.2 Final for Ubuntu 23.04

wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v6.2/amd64/linux-headers-6.2.0-060200-generic_6.2.0-060200.202302191831_amd64.deb
wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v6.2/amd64/linux-headers-6.2.0-060200_6.2.0-060200.202302191831_all.deb
wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v6.2/amd64/linux-image-unsigned-6.2.0-060200-generic_6.2.0-060200.202302191831_amd64.deb
@gnat
gnat / trello_discord.md
Last active April 6, 2023 20:54
Trello notification to Discord webhook using trigger (NO zapier or bs)

NO ZAPIER!

Select Board

➡️ Automation

➡️ Rules

➡️ Create Rule

PHP Scaling Notes
* Keeping latency down is #1 priority when using PHP.
* Lots of workers = thread swapping will tank CPU.
* 100-200 workers = they will all fill up and CPU will be unused.
* Ideally you just want to keep most requests UNDER 1 Second.
* Best under 0.1 Second. You start to hit Sqlite cap at that point.
* “Jobs” would just be a cron that runs in the background one at a time.
* Every page that goes over this latency will become a bottleneck.
* Most efficient by far for low-blocking is one big static FPM process.
* Adjusting static pm.max_children is superior to multiple VM’s.
{
"ignored_packages":
[
"Vintage",
],
"color_scheme": "InvaderZim.sublime-color-scheme",
"theme": "Adaptive.sublime-theme",
"gtk_client_side_window_decorations": false,
"font_face":"SF Mono Semibold",
"line_padding_bottom": -1,
@gnat
gnat / pyinfra_vs_bash.md
Last active July 17, 2023 20:40
Pyinfra vs Shell over SSH (also Fabric, Ansible).

Overview (tl;dr:)

  • For local dev, shell scripts are pretty much always preferred. See: https://github.com/gnat/doit
    • Because 1:1 native equivalent with what is actually run on the system.
  • For inventory management, pyinfra starts paying off.

Details

Shell + SSH advantages:

  • Shines because 1:1 equivalent with what is actually run on the system.
  • A few orders of magnitude less code.