Skip to content

Instantly share code, notes, and snippets.

View denji's full-sized avatar
🇺🇦

Denis Denisov denji

🇺🇦
View GitHub Profile
@denji
denji / git-cheatsheet.md
Last active December 1, 2023 00:50 — forked from jeremypage/git-cheatsheet.md
Git cheatsheet
View git-cheatsheet.md

Git cheatsheet

Find all instances of text in all commits

git grep "text to look for" $(git rev-list --all)

List commit messages since given commit

@denji
denji / readme.md
Created June 4, 2023 20:35 — forked from ShannonScott/readme.md
[Moving efficiently in the CLI] Key-combination reference for movement in the shell. #tags: mac, linux, bash
@denji
denji / Video Screen Capture with GStreamer.md
Created June 4, 2023 20:34 — forked from ShannonScott/Video Screen Capture with GStreamer.md
[Video Screen Capture with GStreamer] Capture a Linux desktop window video with gsteramer. #tags: gstreamer, linux, xwindows, video
View Video Screen Capture with GStreamer.md

Capture a video of a given X Window with gstreamer.

X Window ID

Get the target window ID with the following:

xwininfo
@denji
denji / nvenc-install.sh
Last active January 30, 2024 19:39 — forked from lucaspar/nvenc-install.sh
Installation script of CUDA-accelerated `ffmpeg` with NVIDIA Encoder ( docker NVIDIA Encoder https://github.com/markus-perl/ffmpeg-build-script )
View nvenc-install.sh
#!/bin/bash
# =========================================================================
# Source: https://gist.github.com/lucaspar/27f5e108b80524b315be10b2a9049817
# =========================================================================
# This script will compile and install a static FFmpeg build with
# support for NVENC in Ubuntu. Developed in Ubuntu 23.10,
# with NVIDIA Drivers v535.129.03 and CUDA v12.2 with a GPU
# with CUDA capability 8.6 (RTX 3080) (see ccap below).
# It assumes NVIDA drivers are installed and that you have a
# CUDA-compatible GPU. You can check installed drivers with:
@denji
denji / nvidia.conf
Created May 21, 2023 02:21
/etc/modprobe.d/nvidia.conf
View nvidia.conf
# https://wiki.archlinux.org/title/NVIDIA/Tips_and_tricks
# https://forums.developer.nvidia.com/t/does-modprobe-d-nvidia-conf-nvreg-enablestreammemops-need-to-be-set-for-gpudirect-to-work/79511
# https://github.com/NVIDIA/open-gpu-kernel-modules/blob/main/src/nvidia/interface/nvrm_registry.h
# Requires nvidia.ko >= 510.40.3 loaded with PeerMappingOverride=1. https://docs.nvidia.com/nvshmem/install-guide/index.html
# https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers/en
# https://github.com/ventureoo/nvidia-tweaks
# https://nvdam.widen.net/s/k8vrp9xkft/tech-overview-magnum-io-1790750-r5-web
# https://developer.download.nvidia.com/devzone/devcenter/cuda/docs/GPUDirect_Technology_Overview.pdf
# https://docs.nvidia.com/nvshmem/pdf/NVSHMEM-Installation-Guide.pdf
@denji
denji / disable-fb.sh
Created May 14, 2023 16:08 — forked from null-dev/disable-fb.sh
Disable efifb at runtime
View disable-fb.sh
#!/usr/bin/env bash
# 1. Download and install the QEMU hook helper from here: https://github.com/PassthroughPOST/VFIO-Tools
# 2. Place this file in /etc/libvirt/hooks/qemu.d/NAME OF YOUR VM/prepare/begin/disable-fb.sh
# 3. Make disable-fb.sh executable.
VM_NAME="$1"
echo "libvirt-qemu disable-fb: Disabling efi-framebuffer to prepare to pass GPU to VM $VM_NAME" > /dev/kmsg 2>&1
echo "efi-framebuffer.0" > /sys/bus/platform/devices/efi-framebuffer.0/driver/unbind
@denji
denji / ffmpeg-hevc-encode-nvenc.md
Created May 9, 2023 18:57 — forked from jbboehr/ffmpeg-hevc-encode-nvenc.md
This gist shows you how to encode specifically to HEVC with ffmpeg's NVENC on supported hardware, with a two-pass profile and optional CUVID-based hardware-accelerated decoding.
View ffmpeg-hevc-encode-nvenc.md

Encoding high-quality HEVC content in a two-pass manner with FFmpeg - based NVENC encoder on supported hardware:

If you've built ffmpeg as instructed here on Linux and the ffmpeg binary is in your path, you can do fast HEVC encodes as shown below, using NVIDIA's NPP's libraries to vastly speed up the process.

Now, to do a simple NVENC encode in 1080p, (that will even work for Maxwell Gen 2 (GM200x) series), start with:

ffmpeg  -i <inputfile> -pass 1 \
-filter:v hwupload_cuda,scale_npp=w=1920:h=1080:format=nv12:interp_algo=lanczos,hwdownload,format=nv12 \

-c:v hevc_nvenc -profile main -preset slow -rc vbr_2pass \

@denji
denji / nvidia-x-server-settings.txt
Created March 13, 2023 05:16 — forked from DavidMetcalfe/nvidia-x-server-settings.txt
Documents the PowerMizer CLI for potential cron jobs, etc.
View nvidia-x-server-settings.txt
Because PowerMizer settings in NVIDIA X Server Settings doesn't persist across sessions,
attempts to overclock can become a nuisance.
The following documents the three CLI settings to modify the Preferred Mode as desired:
# Auto:
nvidia-settings -a [gpu:0]/GPUPowerMizerMode=2
# Adaptive:
nvidia-settings -a [gpu:0]/GPUPowerMizerMode=0
@denji
denji / TypeClipboard.md
Created March 13, 2023 04:04 — forked from ethack/TypeClipboard.md
Scripts that simulate typing the clipboard contents. Useful when pasting is not allowed.
View TypeClipboard.md

It "types" the contents of the clipboard.

Why can't you just paste the contents you ask? Sometimes pasting just doesn't work.

  • One example is in system password fields on OSX.
  • Sometimes you're working in a VM and the clipboard isn't shared.
  • Other times you're working via Remote Desktop and again, the clipboard doesn't work in password boxes such as the system login prompts.
  • Connected via RDP and clipboard sharing is disabled and so is mounting of local drives. If the system doesn't have internet access there's no easy way to get things like payloads or Powershell scripts onto it... until now.

Windows

The Windows version is written in AutoHotKey and easily compiles to an executable. It's a single line script that maps Ctrl-Shift-V to type the clipboard.