Skip to content

Instantly share code, notes, and snippets.

@neerajkanhere
neerajkanhere / tmux.md
Created February 17, 2025 21:40 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@neerajkanhere
neerajkanhere / addbr0ubunmcli.md
Created November 7, 2024 21:53 — forked from plembo/addbr0ubunmcli.md
Add br0 to Ubuntu desktop using nmcli

Add a bridge interface to Ubuntu desktop using nmcli

Had to do this for some advanced networking with KVM, and couldn't figure out how to do it using the Nework Manager gui. Did find an article later that showed how to do it with nmtui, but it's so much easier to record what you did when using the cli.

In the examples below "eth0" is the name of my physical interface. By default on Ubuntu and most distributions that will almost certainly be different, for example: "eno1", "ens1", or "enp2s0".

To see what everything looks like before starting:

@neerajkanhere
neerajkanhere / main.cpp
Created August 12, 2024 00:59 — forked from vietanhdev/main.cpp
C++ OpenCV Image classification from ONNX model
#include <chrono>
#include <cmath>
#include <exception>
#include <fstream>
#include <iostream>
#include <limits>
#include <numeric>
#include <opencv2/dnn/dnn.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
@neerajkanhere
neerajkanhere / readme.md
Created July 22, 2024 16:20 — forked from 17twenty/readme.md
Using systemd-networkd

For those of you who want to try out systemd-networkd, you can read on, and find out in this tutorial how to switch from NetworkManager to systemd-networkd on Linux.

Requirement systemd-networkd is available in systemd version 210 and higher. Check the version of your systemd before proceeding.

$ systemctl --version

Switch from Network Manager to Systemd-Networkd

It is relatively straightforward to switch from Network Manager to systemd-networkd (and vice versa).

JS REPL

There's not a good, simple embeddable REPL for JS out there that I could find. I wanted one for presentations on JavaScript concepts. The developer tools' console would be ideal, but bailing out of my presentation and opening a console brakes the flow. Tools like codepen.io et al. are great, but more overhead and set up than I need. I just want to type JS and show the result. This is a decent first step for my needs.

A Pen by Cory on CodePen.

License.

@neerajkanhere
neerajkanhere / keycloak_get_idp_token.md
Created December 9, 2023 05:15 — forked from luszczynski/keycloak_get_idp_token.md
Keycloak - Get IDP Token using Curl

Keycloak - Get IDP Token

Get Access Token

export TKN=$(curl -X POST 'http://127.0.0.1:8080/auth/realms/your-realm/protocol/openid-connect/token' \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -d "username=your-user" \
 -d 'password=your-pass' \
 -d 'grant_type=password' \
@neerajkanhere
neerajkanhere / NodeJS D3 with JSDOM
Created November 12, 2023 17:37 — forked from hubertgrzeskowiak/NodeJS D3 with JSDOM
Using d3.js (aka Data-Driven Documents) without browser with help of jsdom. This allows for server-side rendering or programmatic use in any other contexts than browser.
d3 = require("d3");
jsdom = require("jsdom");
document = jsdom.jsdom();
window = document.parentWindow;
var sampleSVG = d3.select(document.body)
.append("svg")
.attr("width", 100)
.attr("height", 100)
@neerajkanhere
neerajkanhere / gcc-security.txt
Created August 18, 2023 19:41 — forked from jrelo/gcc-security.txt
GCC security related flags reference.
Source material:
http://security.stackexchange.com/questions/24444/what-is-the-most-hardened-set-of-options-for-gcc-compiling-c-c
https://wiki.gentoo.org/wiki/Hardened_Gentoo
https://wiki.debian.org/Hardening
================================================================================================================>
GCC Security related flags and options:
CFLAGS="-fPIE -fstack-protector-all -D_FORTIFY_SOURCE=2"
LDFLAGS="-Wl,-z,now -Wl,-z,relro"
@neerajkanhere
neerajkanhere / align.c
Created April 6, 2023 02:17 — forked from dblalock/align.c
C / C++ portable aligned memory allocation
/* Allocate aligned memory in a portable way.
*
* Memory allocated with aligned alloc *MUST* be freed using aligned_free.
*
* @param alignment The number of bytes to which memory must be aligned. This
* value *must* be <= 255.
* @param bytes The number of bytes to allocate.
* @param zero If true, the returned memory will be zeroed. If false, the
* contents of the returned memory are undefined.
* @returns A pointer to `size` bytes of memory, aligned to an `alignment`-byte
@neerajkanhere
neerajkanhere / stepbystep.txt
Created February 14, 2023 03:16 — forked from golomidov/stepbystep.txt
FFmpeg - custom filter addition
//
// ffmpeg_customfilter
// - base name - ainfoda (audio filter)
// - base name - vinfoda (video filter)
//
// 1. create new filein libavfilter/infoda_af.c
// use any filters as template, simplest is af_afnull.c
// filename is arbitrary (all recent named as af_name), but for me all my stuff called with