Skip to content

Instantly share code, notes, and snippets.

@djeikyb
djeikyb / brew_packages_at_work.txt
Created April 1, 2021 21:57
list of macos homebrew packages i probably intentionally installed at some point
brew uninstall $(brew leaves | \grep --invert-match --line-regexp --file=keepers.txt | paste -sd\ -)
brew leaves | parallel brew desc
awscli: Official Amazon AWS command-line interface
bat: Clone of cat(1) with syntax highlighting and Git integration
bash-completion: Programmable completion for Bash 3.2
automake: Tool for generating GNU Standards-compliant Makefiles
arp-scan: ARP scanning and fingerprinting tool
coreutils: GNU File, Shell, and Text utilities
interface Stream {
file: string;
kind: "video" | "audio";
label?: string;
}
interface Job {
streams: Stream[];
dest: string;
}
@djeikyb
djeikyb / git_find_large_files.md
Last active February 10, 2021 18:18
git: find files larger than a megabyte

source: https://stackoverflow.com/a/42544963/659715

Sorts largest files last. First column is the git object id. Second column is size in bytes.

git rev-list --objects --all |
  git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' |
  sed -n 's/^blob //p' |
  sort --numeric-sort --key=2 |
 cut -c 1-12,41- |
@djeikyb
djeikyb / perl insert line.sh
Created January 28, 2021 00:01
perl oneliner: insert line at beginning of a bunch of files
for f in tables/*.sql; do echo "$f"; perl -0777 -pi -e 's/^/use my_database_name;\n\n/' "$f"; done
10:43:31 ~/dev/play/traefik % cat t/docker-compose.yml ; cat a/docker-compose.yml ; cat b/docker-compose.yml
version: '3'
services:
reverse-proxy:
image: traefik # The official Traefik docker image
command: --api --docker --keeptrailingslash # Enables the web UI and tells Traefik to listen to docker
ports:
- "80:80" # The HTTP port
- "8080:8080" # The Web UI (enabled by --api)
@djeikyb
djeikyb / browser_request_interceptors.ts
Created August 13, 2020 18:48
intercept requests to example.com, enable automatic cookie sending
type myfetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>;
function isRequest(rq: any): rq is Request {
return (rq as Request).url !== undefined;
}
(function (fetch: myfetch) {
window.fetch = async function (this: myfetch, input: RequestInfo, init) {
let url;
if (isRequest(input)) {
@djeikyb
djeikyb / InterceptAndDebugRequestMiddleware.cs
Created August 3, 2020 21:18
example of intercepting a request and logging the body and all its headers, dotnet core 3.0
public class InterceptAndDebugRequestMiddleware : IMiddleware
{
private readonly LogProps _props;
public InterceptAndDebugRequestMiddleware(LogProps props)
{
_props = props;
}
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
@djeikyb
djeikyb / JsonPrettily.vue
Created June 29, 2020 20:46
simple json display vue component
<template>
<pre><code>{{pretty}}</code></pre>
</template>
<script>
export default {
name: "JsonPrettily",
props: ["value"],
computed: {
pretty() {
return JSON.stringify(this.value, null, 1);
@djeikyb
djeikyb / docker-goto
Last active December 22, 2022 17:49
custom docker cli command to interactively connect to a container
#!/bin/bash
# official docs:
#
# https://docs.docker.com/engine/extend/cli_plugins/
#
#
# example plugin:
#
# https://github.com/SvenDowideit/docker-cli-plugins/blob/master/docker-env