Skip to content

Instantly share code, notes, and snippets.

@rencire
rencire / commit-msg
Created September 7, 2019 06:45
git hooks
#!/usr/bin/env bash
COMMIT_EDITMSG=$1
BRANCH_REF=$(git rev-parse --abbrev-ref HEAD)
COMMIT_REGEX='\[[A-Z]{2,}-[0-9]{1,6}\]' # regex to validate in commit msg
ERROR_MSG="Aborting commit. Your commit message is missing a valid Jira Issue descriptor of the form /$COMMIT_REGEX/ (e.g. [ECHO-616])."
if [ "$BRANCH_REF" = "master" ] || [ "$BRANCH_REF" = "dev" ]
then
exit
@rencire
rencire / gist:e96e61f50fc2e9f4ee29ad4bd26fc44c
Created September 7, 2019 06:42
.git/hooks/prepare-commit-msg
#!/usr/bin/env bash
COMMIT_EDITMSG=$1
TYPE=$2 # one of message, template, merge, squash, commit
REF=$3 # optional, when TYPE is commit
COMMIT_REGEX='([A-Z]{2,}-[0-9]{1,6})'
BRANCH_REF=$(git rev-parse --abbrev-ref HEAD)
if [ "$BRANCH_REF" = "master" ] || [ "$BRANCH_REF" = "dev" ]; then
@rencire
rencire / gist:a7ab0224ac901b59e71244c4d5be1df3
Created March 25, 2018 18:56
simple package.json. 0 conf webpack. postcss
{
"name": "static",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build.js.dev": "webpack --mode development -o static/main.js",
"build.js.prod": "webpack --mode production -o static/main.js",
"clean": "rm -rf static/",
git clone --bare [email protected]:user/repo.git
cd repo.git
```
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="[email protected]"
#!/bin/bash
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo -e "\nCreate a PR at:"
echo "https://github.com/<org>/<repo>/compare/dev...$CURRENT_BRANCH?expand=1"
echo -e "\n"
function checkMd5 {
md5 $1 | sed -e 's/^MD5 (\(.*\)) = \(.*\)/\2 \1/' | diff $2 -
}
@rencire
rencire / .zshrc
Last active November 11, 2016 04:26
useful custom shell functions
## Custom Functions
function pgc
{
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log $1
}
function dit {
@rencire
rencire / raspbian (debian)
Last active October 14, 2016 02:34
setting up terminal env
# centos 6
sudo yum install zsh -y
# load 'zim' from https://github.com/Eriner/zim
git clone --recursive https://github.com/Eriner/zim.git ${ZDOTDIR:-${HOME}}/.zim
setopt EXTENDED_GLOB
for template_file ( ${ZDOTDIR:-${HOME}}/.zim/templates/* ); do
user_file="${ZDOTDIR:-${HOME}}/.${template_file:t}"
@rencire
rencire / gist:dce7bbf79bca6b7f2ab0e93ee6d837ba
Last active July 19, 2016 22:00
find exported functions from file B in file A
#! /usr/bin/ruby
# Simple script to help with modularizing js files.
# This script find lines in a file w/ functions from a commmon.js library file
def get_funcs(file,libraryfile)
funcs = open(libraryfile) do |f|
content = f.read
content.scan(/exports\.(.*)=\s?function/)
@rencire
rencire / gist:178b37e2d238360d01be
Created March 3, 2015 20:45
gen script payload
# type in js code to execute
js_str = gets.chomp
c = js_str.split('').map { |char| char.ord }
js_code = "var c=#{c.to_s};var code='';for(var i=0;i<c.length;i++){code=code+String.fromCharCode(c[i]);}eval(code);"
puts "<script>#{js_code}</script>"