Skip to content

Instantly share code, notes, and snippets.

View jpbochi's full-sized avatar
🦔

JP Bochi jpbochi

🦔
View GitHub Profile
@jpbochi
jpbochi / try-acquire-lock-s3.sh
Created July 25, 2017 12:56
bash script to lock/unlock resources by using an S3 bucket with file versioning
#!/usr/bin/env bash
set -eu
log () {
echo >&2 "[lock] $@"
}
putLock () {
aws s3api put-object --region $REGION --bucket $BUCKET --key $LOCK_KEY --output text --query 'VersionId'
}
@brettinternet
brettinternet / check-git-2.sh
Created July 6, 2017 23:54
Check if directory is a git repo or not
# from https://stackoverflow.com/questions/2180270/check-if-current-directory-is-a-git-repository
[ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1
@davidfurlong
davidfurlong / JSON.stringify-replacer-sort-keys.js
Last active May 5, 2024 06:00
JSON.stringify replacer function for having object keys sorted in output (supports deeply nested objects)
// Spec http://www.ecma-international.org/ecma-262/6.0/#sec-json.stringify
const replacer = (key, value) =>
value instanceof Object && !(value instanceof Array) ?
Object.keys(value)
.sort()
.reduce((sorted, key) => {
sorted[key] = value[key];
return sorted
}, {}) :
value;
@epelc
epelc / cleanup-images.md
Last active October 17, 2019 15:14
Delete Gitlab Registry Images

Soft-delete the images

Generate a script to delete all images using the following. Copy paste into chrome console on the registry page of a project.

NOTE you must update the textToSave template string before running.

// Options(fill these out with your info)

// GITLAB_INSTANCE is the url to your custom instance or `gitlab.com`
const GITLAB_INSTANCE = 'gitlab.yourwebsite.com'
const GROUP = 'yourGroup'
@BretFisher
BretFisher / docker-for-mac.md
Last active April 26, 2024 09:38
Getting a Shell in the Docker Desktop Mac VM

2021 Update: Easiest option is Justin's repo and image

Just run this from your Mac terminal and it'll drop you in a container with full permissions on the Docker VM. This also works for Docker for Windows for getting in Moby Linux VM (doesn't work for Windows Containers).

docker run -it --rm --privileged --pid=host justincormack/nsenter1

more info: https://github.com/justincormack/nsenter1


@stavxyz
stavxyz / sjs.md
Last active November 6, 2018 17:01
Shit Janus Says

mozair

this hopefully won't break all the things we've ever built

integration tests passed
I don't know if I should be happy or sad

On the release of AWS Edge Location in Vienna

schnitzel shops rejoice

@indiesquidge
indiesquidge / objects-over-classes.md
Last active January 17, 2024 09:30
We are better off avoiding ES6 classes in JavaScript when possible

Plain JavaScript objects are better than classes when they can be used, and many popular modern frameworks have adopted their use.

Consider that in React a component can be created as either a class or as an object.

// using a class
class Welcome extends React.Component {
  render() {
 Hello, {this.props.name}
@mkrakauer-rio
mkrakauer-rio / disable-full-sync-on-flush.sh
Last active June 12, 2022 14:52
Docker for Mac - Disable full disk sync on flush
cd ~/Library/Containers/com.docker.docker/Data/database/
git reset --hard
cat com.docker.driver.amd64-linux/disk/full-sync-on-flush
# if you see true, continue
echo false > com.docker.driver.amd64-linux/disk/full-sync-on-flush
cat com.docker.driver.amd64-linux/disk/full-sync-on-flush
# you should now see false
git add com.docker.driver.amd64-linux/disk/full-sync-on-flush
git commit -s -m "Disable flushing"
# wait for docker to restart
@rjz
rjz / ngrok_hostname.sh
Created August 9, 2016 16:20
Get ngrok hostname from command line
#!/bin/sh
# ngrok's web interface is HTML, but configuration is bootstrapped as a JSON
# string. We can hack out the forwarded hostname by extracting the next
# `*.ngrok.io` string from the JSON
#
# Brittle as all get out--YMMV. If you're still reading, usage is:
#
# $ ./ngrok_hostname.sh <proto> <addr>
#