Skip to content

Instantly share code, notes, and snippets.

@orip
orip / Python-3.4.3-macos.patch
Created November 23, 2020 11:22
Patch for Python 3.4.x for macos, based on https://bugs.python.org/issue28676
diff --git a/Python/random.c b/Python/random.c
index 93d300d..396041d 100644
--- a/Python/random.c
+++ b/Python/random.c
@@ -3,6 +3,9 @@
#include <windows.h>
#else
#include <fcntl.h>
+#if defined(HAVE_GETRANDOM) || defined(HAVE_GETENTROPY)
+#include <sys/random.h>
@orip
orip / log_http_headers.py
Last active February 19, 2024 13:42 — forked from phrawzty/2serv.py
simple python http server to dump request headers
#!/usr/bin/env python3
import http
import http.server
import socketserver
import sys
def _log(s):
print(s)
@orip
orip / GsonHelper.java
Created September 5, 2012 11:22
Gson type adapter to serialize and deserialize byte arrays in base64
import java.lang.reflect.Type;
import android.util.Base64;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
@orip
orip / orip_macbook_setup_tips.md
Created January 30, 2023 09:05
orip's MacBook setup tips

Install and manage utilities and applications

homebrew (https://brew.sh/)

Applications

Terminals

Standard option: iterm2

brew install iterm2
@orip
orip / diff_big_sizes.py
Created October 6, 2022 21:30
Diff two runs of nm on similar executables to find large symbol size increases
#! /usr/bin/env python3
"""
Build to compare two outputs of this line on fairly identical executables
nm --print-size --radix=d <executable> | grep ' .* .* ' | cut -d' ' -f 2-10
To just see the top symbols, can run e.g
nm --print-size --size-sort --radix=d <executable>
"""
@orip
orip / worktrees.py
Created October 3, 2022 08:24
Simple git worktree filters in Python. Sample usage: `cd $(worktrees.py ~/myrepo max_path)`
#!/usr/bin/env python3
import argparse
import os
import subprocess
import sys
from dataclasses import dataclass
@dataclass
@orip
orip / wt.zsh
Last active September 5, 2022 11:19
`wt` zsh function to switch between git worktrees using fzf
wt() {
if [ "$#" -eq 0 ]; then
local -a extra_fzf_args
elif [ "$#" -eq 1 ]; then
extra_fzf_args=(
--query
"'$1"
)
else
echo "Unknown arguments $@"
@orip
orip / jrpc_curl.sh
Last active September 5, 2022 09:39
helper script to make JSON-RPC (JRPC) 2.0 calls using curl
#!/bin/bash
usage_exit() {
echo "$0 <target-url> <jrpc-method> [jrpc-params] [extra-curl-args]"
exit 1
}
target="$1"
shift
method="$1"
shift
if [[ -z $target ]] || [[ -z $method ]]; then
@orip
orip / passgen.go
Created June 9, 2022 09:19
Generate secure passwords in Go
package main
import (
"crypto/rand"
"flag"
"fmt"
"math/big"
)
func GenerateSecurePassword(n int, alphabet string) (string, error) {
@orip
orip / build.gradle
Created February 14, 2013 09:52
Print Gradle test results to console
/*
Sample output:
> gradle test ruby-1.9.3-p194 testing_with_gradle 9179829 ✗
...
:test
Results: SUCCESS (84 tests, 74 successes, 0 failures, 10 skipped)
*/
test {
testLogging {