Skip to content

Instantly share code, notes, and snippets.

@allex
allex / gcpl.sh
Created August 14, 2020 04:34 — forked from nickboldt/gcpl.sh
git cherry pick latest (or multiple latest) commits
#!/bin/bash
#
#script to make it easier to git cherry-pick the latest commit to another branch
numCommits=1 # but we can cherry-pick more than one if needs be
red="\033[1;31m"
norm="\033[0;39m"
grey="\033[0;37m"
green="\033[0;32m"
@allex
allex / git-rev
Last active May 18, 2022 11:51
git-rev
#!/bin/bash
set -euE
# Similar as `npm version`, bump version by git tags or custom version file
#
# by @allex_wang <https://iallex.com> | MIT
#
# Usage:
#
# git-rev
@allex
allex / docker-machine-rename
Created April 26, 2020 07:45 — forked from alexproca/docker-machine-rename
Rename docker-machine
#!/usr/bin/env bash
#copy this in a folder from path ex: /usr/local/bin
#usage: docker-machine-rename default my-default
# Authors
#
# alexproca initial script
# eurythmia sed magic
@allex
allex / pushimage.sh
Last active November 19, 2024 08:37
#!/bin/bash
# vim: set ft=sh fdm=manual ts=2 sw=2 sts=2 tw=85 et:
# ================================================
# Description: sync push local docker images to remote
# Last Modified: Tue Nov 19, 2024 16:36
# Author: Allex Wang ([email protected])
# GistID: 42f93720be61ec33c0542855f5a0f543
# GistURL: https://gist.github.com/42f93720be61ec33c0542855f5a0f543
# ================================================
@allex
allex / git-quote-string-multiline
Created March 6, 2020 10:26 — forked from HaleTom/git-quote-string-multiline
Quote a single- or multi-line string for use in git's aliases
#!/bin/bash -eu
# Quote a single- or multi-line string for use in git's aliases
# Copyright (c) 2016 Tom Hale under https://en.wikipedia.org/wiki/MIT_License
quote() {
printf %s "$1" | sed -r 's/(["\\])/\\\1/g';
}
IFS=$(printf '\n')
// Uses bit operation to reduce your codes (by allex)
// GistID: 459aaa91c9b584e127f3f45890026303
const ADD = 4
const UPDATE = 2
const DELETE = 1
const checkFlag = (v, mask) => (v & mask) === mask
const print = (v, desc) => {
-- print all nginx variables
-- author: allex_wang
-- GistID: b9f5206b58570d7686c6f22b8fed3144
local inspect = require('inspect')
local keys = {
"args",
"binary_remote_addr",
"body_bytes_sent",
@allex
allex / json.lua
Created February 11, 2020 09:18 — forked from tylerneylon/json.lua
Pure Lua json library.
--[[ json.lua
A compact pure-Lua JSON library.
The main functions are: json.stringify, json.parse.
## json.stringify:
This expects the following to be true of any tables being encoded:
* They only have string or number keys. Number keys must be represented as
strings in json; this is part of the json spec.
@allex
allex / post-checkout
Created January 7, 2020 11:23 — forked from betorobson/post-checkout
git hook to run a command after `git pull` and `git checkout` if a specified file was change for example, package.json or bower.json
#!/usr/bin/env bash
# fork from https://gist.github.com/jakemhiller/d342ad51505addf78ec628a16fd3280f
changed_files="$(git diff-tree -r --name-only --no-commit-id $1 $2)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
}
check_run package.json "npm prune && npm install"
#!/bin/sh
# GistID: 8f9a8a45e86f0edef6caea81f0795031
set -eE
echoerr() {
echo "$@" 1>&2;
}
error() {
if [ -t 1 ]; then
echoerr "\033[1;31m$@\033[0m"