Skip to content

Instantly share code, notes, and snippets.

@LintaoAmons
LintaoAmons / .ideavimrc
Last active April 5, 2023 16:44
ideavimrc
" ================================================================================================
" = Extensions =====================================
" ================================================================================================
Plug 'tpope/vim-surround'
Plug 'preservim/nerdtree'
" ================================================================================================
" = Basic settings =====================================
" ================================================================================================
set clipboard+=unnamed
@Zheaoli
Zheaoli / Jetbrains JVM Config
Last active July 27, 2022 05:37
This is a JVM config for Jetbrains IDE on my laptop(With i9 10th CPU and 64G RAM)
-Xms128m
-Xmx8182m
-XX:ReservedCodeCacheSize=512m
-XX:CICompilerCount=2
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-XX:+UnlockExperimentalVMOptions -XX:+UseZGC
-XX:ZCollectionInterval=120 -XX:ZAllocationSpikeTolerance=5
-XX:+UnlockDiagnosticVMOptions -XX:-ZProactive
@mike-myers-tob
mike-myers-tob / Working GDB on macOS 11.md
Last active May 21, 2025 14:15
Steps to get GDB actually working in April 2021 on macOS (Intel x86-64 only)

Debug with GDB on macOS 11

The big reason to do this is that LLDB has no ability to "follow-fork-mode child", in other words, a multi-process target that doesn't have a single-process mode (or, a bug that only manifests when in multi-process mode) is going to be difficult or impossible to debug, especially if you have to run the target over and over in order to make the bug manifest. If you have a repeatable bug, no big deal, break on the fork from the parent process and attach to the child in a second lldb instance. Otherwise, read on.

Install GDB

Don't make the mistake of thinking you can just brew install gdb. Currently this is version 10.2 and it's mostly broken, with at least two annoying bugs as of April 29th 2021, but the big one is https://sourceware.org/bugzilla/show_bug.cgi?id=24069

$ xcode-select install  # install the XCode command-line tools

ELF Format Cheatsheet

Introduction

Executable and Linkable Format (ELF), is the default binary format on Linux-based systems.

ELF

Compilation

@david-martin
david-martin / gist:6ac8a8fd2498d9defcb4829a83bdd709
Created September 14, 2020 15:29
prometheus self metrics
{
"prometheus-k8s": [
"count:up1",
"go_gc_duration_seconds",
"go_gc_duration_seconds_count",
"go_gc_duration_seconds_sum",
"go_goroutines",
"go_info",
"go_memstats_alloc_bytes",
"go_memstats_alloc_bytes_total",
@StevenACoffman
StevenACoffman / opa-vs-casbin.md
Last active April 17, 2025 09:04
OPA vs Casbin

Information in this Gist originally from this github issue, which is outdated.

As @RomanMinkin mentioned, you can also consider Casbin (https://github.com/casbin/casbin). It is the most starred authorization library in Golang. There are several differences between Casbin and OPA.

Feature Casbin OPA
Library or service? Library/Service Library/Service
How to write policy? Two parts: model and policy. Model is general authorization logic. Policy is concrete policy rule. A single part: Rego
RBAC hierarchy Casbin supports role hierarchy (a role can have a sub-role) Role hierarchies can be encoded in data. Also with the new graph.reachable() built-in function queries over those hierarchies are much more feasible now.
RBAC separation of duties Not supported Supported: two roles cannot be assigned together
use std::thread;
use std::net::SocketAddr;
use socket2::{Socket, Domain, Type};
use std::net::Shutdown;
use std::sync::Arc;
fn main() {
let socket = Arc::new(Socket::new(Domain::ipv4(), Type::stream(), None).unwrap());
socket.bind(&"127.0.0.1:8080".parse::<SocketAddr>().unwrap().into()).unwrap();
@afdalwahyu
afdalwahyu / http_proxy.go
Last active February 13, 2025 19:46
golang http proxy server CONNECT method
package main
import (
"bufio"
"encoding/base64"
"flag"
"io"
"io/ioutil"
"log"
"net"
@Daniel-ltw
Daniel-ltw / from.yaml
Last active August 25, 2023 21:11
Github Actions repository_dispatch example
name: Build Artifacts
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps: