Skip to content

Instantly share code, notes, and snippets.

@acg
acg / combine-repos-into-mono-repo.md
Created July 10, 2023 17:31
How to combine two git repos into a monorepo without `git merge`

Use Case

Suppose you have local checkouts of two git repositories, a and b. You'd like to combine them into a new git repo c ("the monorepo"). More specifically, you'd like to:

  1. Preserve the combined commit history.
  2. Keep the commits from a and b ordered chronologically in c, interleaving as necessary.
  3. Avoid new merge commits, because you're a rebase-only freak like me. Most answers on the internet use git merge.
  4. Ignore all branches of a and b other than master. It's possible to port them over, but would significantly complicate these instructions. So for now that's an exercise left for the reader.

Preliminaries

@acg
acg / delete-old-s3-markers.sh
Created August 25, 2021 23:16
Delete all old version markers in an S3 bucket. Be extremely careful!
#!/bin/sh
set -e
BUCKET="$1" ; shift
BATCH_SIZE=100
aws s3api list-object-versions --bucket "$BUCKET" |
jq '[.DeleteMarkers[] | {Key, VersionId}]' |
jq -c "_nwise($BATCH_SIZE) | {Objects:., Quiet:false}" |
@acg
acg / delete-old-s3-versions.sh
Last active August 25, 2021 23:17
Delete all old object versions in an S3 bucket. Be extremely careful!
#!/bin/sh
set -e
BUCKET="$1" ; shift
BATCH_SIZE=100
aws s3api list-object-versions --bucket "$BUCKET" |
jq '[.Versions[] | select(.IsLatest == false) | {Key, VersionId}]' |
jq -c "_nwise($BATCH_SIZE) | {Objects:., Quiet:false}" |
<html>
<head>
<style lang="text/css">
body {
margin: 0;
padding: 0;
}
@acg
acg / spam.js
Created April 27, 2016 17:50
Obfuscated Javascript Spam
var slothful = 0;
String.prototype.hotels = function () {
return this.replace("U","S").replace(":",".");
};
var tatata = "S";
String.prototype.hotels2 = function () {
return this.replace("R","c").replace("+","t").replace("3","veX");
};
var lll = +!![];

Keybase proof

I hereby claim:

  • I am acg on github.
  • I am acg (https://keybase.io/acg) on keybase.
  • I have a public key ASDACiSbpawajMuFGCDc4pEUrKZlmefyKLfRtsZ7XmZp7wo

To claim this, I am signing this object:

$ grep -iHn poop netcat.c
netcat.c:94:struct host_poop {
netcat.c:99:#define HINF struct host_poop
netcat.c:101:struct port_poop {
netcat.c:106:#define PINF struct port_poop
netcat.c:143:HINF ** gates = NULL; /* LSRR hop hostpoop */
netcat.c:149:PINF * portpoop = NULL; /* for getportpoop / getservby* */
netcat.c:299: cross-check the host_poop we have so far against new gethostby*() info,
netcat.c:303:int comparehosts (poop, hp)
@acg
acg / unixlisten
Created December 18, 2013 03:09
Factoring out the listen(2) half of an ucspi unixserver.
#!/usr/bin/env python
'''
Like unixserver(1), but just listen and exec the subordinate program
with the listening socket as stdin. The subordinate program still needs
to call accept(2) on stdin.
'''
import sys
import os
import socket
@acg
acg / flask-stdio
Last active December 4, 2022 19:29
Exercise a flask app on stdio instead of a socket.
#!/usr/bin/env python
'''
Most flask examples use a socket.
This flask example reads HTTP from stdin and writes HTTP to stdout.
A single HTTP request is processed.
Usage:
printf "GET / HTTP/1.1\r\nHost: localhost\r\n\r\n" | ./flask-stdio
Note: not working yet under tcpserver, wants to read until EOF.
@acg
acg / tsv2csv
Last active January 10, 2019 05:00
Convert tsv to csv with optional unescaping.
#!/usr/bin/env perl
use Text::CSV;
use Getopt::Long qw/ GetOptionsFromArray :config pass_through /;
use warnings;
use strict;
my $usage = "usage: $0 [-e] < file.tsv\n";
exit main( @ARGV );