Skip to content

Instantly share code, notes, and snippets.

View brennie's full-sized avatar
💭
🔥 🦊

Barret Rennie brennie

💭
🔥 🦊
View GitHub Profile
#!/bin/bash
column -t -s$'\t' < <(
readarray -t BRANCHES < <(git branch --list --format "%(refname:short)")
for BRANCH in "${BRANCHES[@]}"; do
SUMMARY=$(git log --oneline -1 "${BRANCH}" --pretty="format:%s")
echo -e "${BRANCH}\t${SUMMARY}"
done
)
@brennie
brennie / demo.c
Created December 14, 2023 04:46
libgit2 push error demo
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "git2/errors.h"
#include "git2/global.h"
#include "git2/remote.h"
#include "git2/repository.h"
#include "git2/strarray.h"
# ~/.config/fish/functions/fish_user_key_bindings.fish
function __fzf_git_tags
if [ ! git rev-parse HEAD >/dev/null 2>&1 ]
return
end
git tag --sort -version:refname | \
fzf-tmux --multi --preview-window right:70% \
--preview 'git show --color=always {} | head -'$LINES
@brennie
brennie / bikeshare.js
Created June 9, 2019 22:35
Tabulate total time spend on Toronto Bikeshare
(function () {
const days = new Map();
Array.prototype.forEach.call(
document.querySelectorAll('tbody tr'),
el => {
const start = new Date(el.querySelector('td:nth-child(3)').textContent);
const end = new Date(el.querySelector('td:nth-child(5)').textContent);
const duration = (end - start) / 1000; // in seconds
@brennie
brennie / awsrun
Created March 4, 2018 02:21
Run a command with AWS credentials
#!/usr/bin/env bash
#
# awsrun - Run a command with AWS credentials.
#
# Credentials are read from lastpass using `lastpass-cli`. The key id for your
# account (which can be found via `lpass ls` is expected to be in the file
# `.lastpass-key-id`.
#
# Released as CC0 1.0.
# Full license available: https://creativecommons.org/publicdomain/zero/1.0/
@brennie
brennie / aws-shell
Last active March 4, 2018 02:23
Launch a shell with access to AWS credentials
#!/usr/bin/env bash
#
# aws-shell - Launch a shell with access to AWS credentials.
#
# Credentials are read from lastpass using `lastpass-cli`. The key id for your
# account (which can be found via `lpass ls` is expected to be in the file
# `.lastpass-key-id`.
#
# Released as CC0 1.0.
# Full license available: https://creativecommons.org/publicdomain/zero/1.0/
#!/bin/bash
set -euo pipefail
if (( $# != 1 )); then
echo "usage: ${0} PYSVN_ARCHIVE"
exit 1
fi
OUTPUT_DIR="$(pwd)"
PYSVN_ARCHIVE="${1}"
#!/bin/bash
# git-setup-mirror
#
# Set up a repository to sync to and from a mirror.
#
# This is useful for working on a project from several machines.
set -euo pipefail
if [[ $# -ne 1 ]]; then
### Keybase proof
I hereby claim:
* I am brennie on github.
* I am brennie (https://keybase.io/brennie) on keybase.
* I have a public key whose fingerprint is FD75 3599 8064 39F3 5D5F 2E1E 44ED 5735 647A B5F2
To claim this, I am signing this object:
template<class T> class Range
{
public:
Range(T initial, T final, T step = T(1)) : _initial(initial), _final(final), _step(step) {}
class Iterator;
Iterator begin() const
{
return Iterator(_initial, _step);