Skip to content

Instantly share code, notes, and snippets.

View jim3ma's full-sized avatar
🎯
Focusing

Jim Ma jim3ma

🎯
Focusing
View GitHub Profile
@darfink
darfink / ld64
Last active November 22, 2023 15:01
Drop-in replacement/wrapper around macOS' linker (ld) that respects segprot's `max_prot` value
#!/usr/bin/python2
import argparse
import sys
import subprocess
from itertools import takewhile
from macholib import MachO, ptypes
def parse_rwx(text):
return ('r' in text and 1) | ('w' in text and 2) | ('x' in text and 4)
@marcan
marcan / linux.sh
Last active December 1, 2023 15:18
Linux kernel initialization, translated to bash
#!/boot/bzImage
# Linux kernel userspace initialization code, translated to bash
# (Minus floppy disk handling, because seriously, it's 2017.)
# Not 100% accurate, but gives you a good idea of how kernel init works
# GPLv2, Copyright 2017 Hector Martin <marcan@marcan.st>
# Based on Linux 4.10-rc2.
# Note: pretend chroot is a builtin and affects the current process
# Note: kernel actually uses major/minor device numbers instead of device name
@jpillora
jpillora / sshd.go
Last active December 17, 2023 16:27
Go SSH server complete example - Read more here https://blog.gopheracademy.com/go-and-ssh/
// A small SSH daemon providing bash sessions
//
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
//
// Client:
@aojea
aojea / Dockerfile
Last active December 27, 2023 16:11
Using crio runtime in KIND
ARG IMAGE=kindest/node
ARG VERSION=1.19
ARG MINOR=1
ARG OS=xUbuntu_20.04
FROM ${IMAGE}:v${VERSION}.${MINOR}
ARG VERSION
ARG OS
@joyrexus
joyrexus / README.md
Last active January 20, 2024 22:01
nested templates in go

Example of nested templates.

Given this file layout ...

.
├── server.go
└── templates
    ├── profiles.html
    └── layout.html
@nuxlli
nuxlli / unix_socket_request.sh
Last active January 25, 2024 04:37
Examples of http request in unix domain socket with shell, using socat, netcat or curl
#!/bin/bash
# References
# http://www.computerhope.com/unix/nc.htm#03
# https://github.com/daniloegea/netcat
# http://unix.stackexchange.com/questions/26715/how-can-i-communicate-with-a-unix-domain-socket-via-the-shell-on-debian-squeeze
# http://unix.stackexchange.com/questions/33924/write-inside-a-socket-open-by-another-process-in-linux/33982#33982
# http://www.linuxjournal.com/content/more-using-bashs-built-devtcp-file-tcpip
# http://www.dest-unreach.org/socat/
# http://stuff.mit.edu/afs/sipb/machine/penguin-lust/src/socat-1.7.1.2/EXAMPLES
@lyoshenka
lyoshenka / ngrok-selfhosting-setup.md
Last active February 1, 2024 20:14
How to setup Ngrok with a self-signed SSL cert

Intro

The plan is to create a pair of executables (ngrok and ngrokd) that are connected with a self-signed SSL cert. Since the client and server executables are paired, you won't be able to use any other ngrok to connect to this ngrokd, and vice versa.

DNS

Add two DNS records: one for the base domain and one for the wildcard domain. For example, if your base domain is domain.com, you'll need a record for that and for *.domain.com.

Different Operating Systems

@Russtopia
Russtopia / go-cgi-upload.go
Last active February 16, 2024 11:29
Golang CGI file upload example using net/http/cgi
// Simple demo of a GO CGI program that takes
// file uploads.
//
// NOTE NOTE DANGER DANGER
// Absolutely No filename/path sanitizing is done,
// don't run this in production unless you want hackers
// to overwrite your server. This is only a demo of
// how to untangle the go stdlib form-related datatypes
// and use them to take file uploads.
//
@mrunkel
mrunkel / zfs_cheatsheet.md
Last active March 10, 2024 20:23
My ZFS cheatsheet

ZFS commands cheatsheet

Devices and Pools

List all devices in the server

lsblk -S

List all pools

zpool list

@r10r
r10r / README.md
Created August 14, 2016 11:22 — forked from eliquious/README.md
Golang OpenPGP examples

Building

go build -o goencrypt main.go

Generating Keys