Skip to content

Instantly share code, notes, and snippets.

@micwehrle
micwehrle / cross-origin-local-storage.js
Created September 2, 2021 05:33 — forked from buren/cross-origin-local-storage.js
Cross origin local storage sharing example (using an iframe and postMessage)
const CrossOriginLocalStorage = function(currentWindow, iframe, allowedOrigins, onMessage) {
this.allowedOrigins = allowedOrigins;
let childWindow;
// some browser (don't remember which one) throw exception when you try to access
// contentWindow for the first time, it works when you do that second time
try {
childWindow = iframe.contentWindow;
} catch(e) {
childWindow = iframe.contentWindow;

Keybase proof

I hereby claim:

  • I am micwehrle on github.
  • I am micwehrle (https://keybase.io/micwehrle) on keybase.
  • I have a public key ASCyXYnY99NfgJ8NBPHm7t87FMxS4p9qJfxrmRTBqseZSQo

To claim this, I am signing this object:

import { ClientConfig } from '../Core/types';
import Http from '../utils/Http';
import Url from '../utils/Url';
import { ResourceResult, AutofiServices } from './types';
import Resource from './AbstractResource';
export interface MetricOpts extends ClientConfig {
autofiService: string;
metadata: any;
processInterval: number;

Automatically Prepend a Jira Issue ID to Git Commit Messages

Use a git hook to match a Jira issue ID from the current branch, and prepend it to every commit message

Assuming the current branch contains a Jira issue ID, you can use a git hook script to prepend it to every commit message.

  1. Create an empty commit-msg git hook file, and make it executable. From your project's root directory:

     install -b -m 755 /dev/null .git/hooks/commit-msg
    
  2. Save the following script to the newly-created .git/hooks/commit-msg file:

@micwehrle
micwehrle / pre-commit.sh
Created October 24, 2017 03:57 — forked from dahjelle/pre-commit.sh
Pre-commit hook for eslint, linting *only* staged changes.
#!/bin/bash
for file in $(git diff --cached --name-only | grep -E '\.(js|jsx)$')
do
git show ":$file" | node_modules/.bin/eslint --stdin --stdin-filename "$file" # we only want to lint the staged changes, not any un-staged changes
if [ $? -ne 0 ]; then
echo "ESLint failed on staged file '$file'. Please check your code and try again. You can run ESLint manually via npm run eslint."
exit 1 # exit with failure status
fi
done
.wrapper {
height: 100vh;
width: 100vw;
background-color: green;
}
@micwehrle
micwehrle / remove-container-by-image.sh
Created November 16, 2015 04:08
Remove docker containers based on image name
#!/bin/bash
IMAGE=$1
docker ps -a | awk '{ print $1,$2 }' | grep $IMAGE | awk '{print $1 }' | xargs -I {} docker rm {}
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
# Git autocomplete stuff. Nifty.
source ~/.git-completion.bash
# Aliases
alias pull='git fetch -v; git merge origin/`echo $(__git_ps1 "%s")`'
alias push='git push origin HEAD'
alias gits='git status'
@micwehrle
micwehrle / .git-completion.bash
Created September 25, 2015 15:47
Auto completion for git commandline
#!bash
#
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
@micwehrle
micwehrle / .gitignore
Created September 20, 2015 07:24
.gitignore Ignore all files inside direcotry except the directory and the .gitignore file
[^.]*
!.gitignore