Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeremiah Johnson naikrovek

View GitHub Profile
@AnomalRoil
AnomalRoil / go-switch-bash
Last active Jul 1, 2022
The `go switch` function allows you to easily switch you current Go version
View go-switch-bash
# to add to your ~/.bashrc or your ~/.zshrc file. Usage: $ go switch 1.18.1
function go() {
case $* in
switch* )
shift 1
gobindir=$(go env GOBIN)
# adapt to a valid directory at the beginning of your $PATH if you're not on systemd
homebindir=$(systemd-path user-binaries)
go install golang.org/dl/go"$@"@latest
$gobindir/go"$@" download
@moyix
moyix / killbutmakeitlooklikeanaccident.sh
Created Feb 5, 2022
Script to inject an exit(0) syscall into a running process. NB: only x86_64 for now!
View killbutmakeitlooklikeanaccident.sh
#!/bin/bash
gdb -p "$1" -batch -ex 'set {short}$rip = 0x050f' -ex 'set $rax=231' -ex 'set $rdi=0' -ex 'cont'
@binji
binji / LICENSE
Last active Oct 23, 2022
pokegb.cc w/o macros
View LICENSE
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
@danvy
danvy / WSL2-Net-Fix.ps1
Created Sep 5, 2020
Reset your WSL network connection trying to fix WSL2 media disconnected error
View WSL2-Net-Fix.ps1
# Check these threads before proceeding:
# https://github.com/microsoft/WSL/discussions/5857
# https://github.com/microsoft/WSL/issues/5821
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
$CmdLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CmdLine
Exit
}
# Restart the Host Network Service
Restart-Service -Force -Name hns
@vegard
vegard / kernel-dev.md
Last active Jan 26, 2023
Getting started with Linux kernel development
View kernel-dev.md

Getting started with Linux kernel development

Prerequisites

The Linux kernel is written in C, so you should have at least a basic understanding of C before diving into kernel work. You don't need expert level C knowledge, since you can always pick some things up underway, but it certainly helps to know the language and to have written some userspace C programs already.

It will also help to be a Linux user. If you have never used Linux before, it's probably a good idea to download a distro and get comfortable with it before you start doing kernel work.

Lastly, knowing git is not actually required, but can really help you (since you can dig through changelogs and search for information you'll need). At a minimum you should probably be able to clone the git repository to a local directory.

@daehahn
daehahn / wsl2-network.ps1
Last active Jan 26, 2023
WSL 2 TCP NETWORK FORWARDING
View wsl2-network.ps1
# WSL2 network port forwarding script v1
# for enable script, 'Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser' in Powershell,
# for delete exist rules and ports use 'delete' as parameter, for show ports use 'list' as parameter.
# written by Daehyuk Ahn, Aug-1-2020
# Display all portproxy information
If ($Args[0] -eq "list") {
netsh interface portproxy show v4tov4;
exit;
}
@windytan
windytan / plot_rpm.pl
Created Apr 15, 2020
Plot the amplitude in an audio file as a grayscale image
View plot_rpm.pl
#!/usr/bin/perl
use strict;
use warnings;
# Perl script to plot the amplitude in an audio file as a grayscale image.
# Uses SoX and ImageMagick via shell.
#
# Note that the height of the image is only limited by the length of the
# audio file.
View asm_x64.c
// x64 encoding
enum Reg {
RAX, RCX, RDX, RBX, RSP, RBP, RSI, RDI,
R8, R9, R10, R11, R12, R13, R14, R15,
};
enum XmmReg {
XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15,
View not terrible lerp godbolt.asm
double not_retarded_lerp<double>(double, double, double):
push rbp
mov rbp, rsp
movsd QWORD PTR [rbp-8], xmm0
movsd QWORD PTR [rbp-16], xmm1
movsd QWORD PTR [rbp-24], xmm2
movsd xmm0, QWORD PTR [rbp-16]
subsd xmm0, QWORD PTR [rbp-8]
mulsd xmm0, QWORD PTR [rbp-24]
addsd xmm0, QWORD PTR [rbp-8]
View terrible lerp c++ godbolt.asm
std::isfinite(double):
push rbp
mov rbp, rsp
movsd QWORD PTR [rbp-8], xmm0
movsd xmm0, QWORD PTR [rbp-8]
movq xmm1, QWORD PTR .LC0[rip]
andpd xmm1, xmm0
movsd xmm0, QWORD PTR .LC1[rip]
ucomisd xmm0, xmm1
setb al