Skip to content

Instantly share code, notes, and snippets.

View larsxschneider's full-sized avatar

Lars Schneider larsxschneider

View GitHub Profile
dsf
@larsxschneider
larsxschneider / index.js
Last active August 5, 2021 10:02
GitHub app based on https://probot.github.io to demo Autolinks
/**
* This is the main entrypoint to your Probot app
* @param {import('probot').Probot} app
*/
module.exports = (app) => {
// Your code here
app.log.info("Yay, the app was loaded!");
app.on("issues.opened", async (context) => {
context.octokit.request(`GET /repos/${context.payload.repository.full_name}/autolinks`)
@larsxschneider
larsxschneider / enc4hub.sh
Created June 3, 2020 06:31
Encrypt a file to send it securely to another Hubber
#!/usr/bin/env bash
# Encrypt a file to send it securely to another Hubber
#
# Use https://gpgtools.org/ to an easy to use decryption UI.
#
# Usage:
# enc4hub larsxschneider /path/to/file
#
set -e
recipient=$1
@larsxschneider
larsxschneider / clone.sh
Last active July 15, 2023 08:54
Clone a repository with Git LFS files and leverage a local cache.
#!/usr/bin/env bash
#
# Clone a repository with Git LFS files and leverage a local cache.
#
# Usage:
#
# Clone and checkout any branch:
# $ clone.sh <repo-url> <cache-dir> <working-copy-dir> <branch-name>
#
# Clone and checkout a PR head:
@larsxschneider
larsxschneider / ghe-spring-cleaning.md
Created March 27, 2018 16:37
GitHub Spring Cleaning 2018 template

GitHub Spring Cleaning 2018

Over the last year, we at ACME have leveraged GitHub Enterprise more than ever. Amongst many other products, A, B, and C have already moved to Git, and D will follow them soon. As with every heavily used platform, we need to clean up once in a while. Therefore, we want to invite you to join our GitHub Spring Cleaning Initiative 2018.

How Can You Help?

GitHub is used by more than x ACME engineers every day, empowering them to develop effectively with little admin assistance. Developers can create repositories, branches, and pretty much everything else completely on their own. However, “with freedom comes responsibility”, and therefore, we need your help to clean up and follow best practices in the areas explained below.

Update Your Local Git Version

@larsxschneider
larsxschneider / ghe-sizer.sh
Created March 6, 2018 18:58
Run git-sizer on all repositories of a GitHub Enterprise appliance.
#!/usr/bin/env bash
#
# Run git-sizer (https://github.com/github/git-sizer) on all
# repositories of a GitHub Enterprise appliance.
#
# Attention:
# This script is not supported by or affiliated with GitHub. Use it at
# your own risk! The author assumes no responsibility for any data loss
# or hardship incurred directly or indirectly by using it.
# !!! DO NOT RUN THIS SCRIPT ON YOUR PRODUCTION APPLIANCE !!!
@larsxschneider
larsxschneider / script.sh
Created February 26, 2018 12:36
set commit name/email/date to author
git filter-branch --commit-filter '\
export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME";\
export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL";\
export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE";\
git commit-tree "$@"'
@larsxschneider
larsxschneider / rewrite.sh
Created February 10, 2018 16:20
Move all files and directories in a Git repo one level down
# Move all files and directories in a Git repo one level down into the "Core" directory
git filter-branch --index-filter 'git read-tree --prefix="Core/" $GIT_COMMIT && git ls-files | sed "s/\/.*//" | sort | uniq | grep -v "^Core" | xargs -L1 git rm -r --cached > /dev/null'
@larsxschneider
larsxschneider / readme.md
Last active October 10, 2024 16:49
Bookmarklet - Close all files in PR

Installation

Make a new bookmark in your browser. Set the name to Close all PR files (or something else you like) and set the URL to:

javascript:void((function(d){d.querySelectorAll('div:not(.Details--on) > div.file-header > div.file-actions > button').forEach(function(x){x.click()});})(document));

Usage

@larsxschneider
larsxschneider / dirsize.sh
Created January 17, 2018 16:09
Print directory sizes in a Git repo
find . -type d -not -path './.git/*' -print0 | while IFS= read -r -d '' i ; do echo "$(ls -l "$i" | wc -l) $i"; done | sort -n