Skip to content

Instantly share code, notes, and snippets.

View jasonmorganson's full-sized avatar

Jason Morganson jasonmorganson

View GitHub Profile
@josephg
josephg / bench-automerge.js
Last active March 4, 2024 19:03
benchmark code from blog post
// Run with node --expose-gc bench.js ../automerge-paper.json.gz
// automerge-paper.json.gz from https://github.com/josephg/crdt-benchmarks
// Read in a patch file and check that the patches all apply correctly.
const fs = require('fs')
const assert = require('assert')
const zlib = require('zlib')
const automerge = require('automerge')
const v8 = require('v8')
class BQDatasetAuthorizer(ContextDecorator):
def __init__(self, target, profile_file):
self.target = target
self.profile_file = profile_file
# this dict maps a dataset to a list of BigQuery Access entries defined by code.
# We expect groupByEmail and View.
# https://googleapis.dev/python/bigquery/latest/generated/google.cloud.bigquery.dataset.AccessEntry.html
self.auth_dict = defaultdict(list)
def __enter__(self):
@pcreux
pcreux / dbt_to_dbdiagram.rb
Created May 3, 2021 16:15
Generate an ERD via dbdiagram.io from a dbt project.
#!/usr/bin/env ruby
# Generate a dbdiagram for dbdiagram.io from a dbt project.
#
# Usage:
# 1. Run `dbt docs generate` first.
# 2. Run `dbt_to_dbdiagram.rb`
# 3. Paste the output in https://dbdiagram.io/
require 'yaml'
require 'json'
@amalmurali47
amalmurali47 / edit_commit_history.md
Last active March 31, 2025 23:00
Change ownership of selected older commits in Git
  1. Clone the repo.
  2. Use git rebase -i --root
  3. vim will open. Select the commits you want to modify by changing pick to edit. If you would like to change all the commits, perform the following replace: :%s/^pick/edit/g. This command changes all instances of "pick" at the start of lines to "edit".
  4. You will now be shown all the selected commits one by one. Each commit message will be displayed. You have two options:
    • If you would like to keep the commit author details the same, do a git rebase --continue.
    • If you would like to change it to a different name/email, do git commit --amend --reset-author. If --reset-author is specified, it will use the details from your git config. (If you need to specify an alternate name/email, you can do so with --author="John Doe <[email protected]>". If you would like to change the time to a previous date, you can do so with --date "2 days ago".)
  5. Do the same for all the commits and finish the rebase.
  6. Perform git push -f origin master to
@IamFaizanKhalid
IamFaizanKhalid / git-commit-author.md
Last active December 5, 2024 18:13
Change author information of previous commits.

Interactive rebase off of a point earlier in the history than the commit you need to modify (git rebase -i <earliercommit>). In the list of commits being rebased, change the text from pick to edit next to the hash of the one you want to modify. Then when git prompts you to change the commit, use this:

git commit --amend --reset-author --no-edit

For example, if your commit history is A-B-C-D-E-F with F as HEAD, and you want to change the author of C and D, then you would...

  1. Update author's info git config --global user.email [email protected]
  2. Specify git rebase -i B (here is an example of what you will see after executing the git rebase -i B command)
@eggbean
eggbean / eza-wrapper.sh
Last active February 23, 2025 23:08
Now moving from exa to eza fork. Wrapper script to give it nearly identical switches and appearance to ls. Also automatically adds --git switch when in a git repository.
#!/bin/bash
## Change following to '0' for output to be like ls and '1' for eza features
# Don't list implied . and .. by default with -a
dot=0
# Show human readable file sizes by default
hru=1
# Show file sizes in decimal (1KB=1000 bytes) as opposed to binary units (1KiB=1024 bytes)
meb=0
# Don't show group column
@ryuheechul
ryuheechul / Nix.md
Last active January 30, 2023 19:02
Personal micro wiki for nix(os)
@yolabingo
yolabingo / sdm-completion.bash
Last active November 4, 2022 20:49
strongDM bash completion of hostnames for "sdm ssh [hostname]"
#/usr/bin/env bash
# fetch server hostnames from `sdm status` to use as completions for `sdm ssh [hostname]`
# save the sdm status to a local file from a cron job to speed this up a lot:
# sdm status --filter 'TYPE:ssh*' | tail -n +2 | awk '{print $1}' | sort -u > /var/tmp/sdm-status
# h/t https://iridakos.com/programming/2018/03/01/bash-programmable-completion-tutorial
update_frequency=4h
compwords_file=/var/tmp/sdm-status
#!/bin/zsh
set -u
emulate -R ksh
sudo renice -10 $$ >/dev/null
time2sec() {
local time="$1"
shift
@christophermark
christophermark / jestSetSystemTime.js
Created December 7, 2020 19:38
Forcing system time for jest tests
/**
* Set the system time for our tests.
* This ensures that our tests can't fail based on the local time of the CI machine.
* This guards against app code where the behavior changes based on the device time.
* For example, a test might fail if we attempt to set the search time "before now".
*/
beforeAll(() => {
// @TODO: 'modern' is default once we upgrade to Jest 27 https://jestjs.io/blog/2020/05/05/jest-26#new-fake-timers
jest.useFakeTimers("modern");
const JS_DATE_11_AM = new Date(new Date().setHours(11, 0, 0, 0));