Skip to content

Instantly share code, notes, and snippets.

View dbrack's full-sized avatar

Dominik Brack dbrack

View GitHub Profile
@dbrack
dbrack / random-filename-rename.sh
Last active September 21, 2017 12:24
Rename all files recursively by adding a random number to the current file
#!/bin/zsh
for f in **/*(.)
do
EXTENSION="${f##*.}"
CURRENT_NAME="${f%.*}"
NEW_NAME="${CURRENT_NAME}_${RANDOM}.$EXTENSION"
echo "Rename $f to $NEW_NAME"
# mv "$f" "$NEW_NAME"
done
@dbrack
dbrack / list-weekend-commits.sh
Last active August 3, 2017 13:48
List git commits for a specific author were committed on a weekend
git log --pretty=format:"%h%x09%an%x09%ad%x09%s" --author "John" | grep 'Sat\|Sun'
@dbrack
dbrack / pre-push-tslint-hook.sh
Last active July 19, 2017 14:12
Git pre push hook for tslint validation
#!/bin/sh
pass=true
RED='\033[1;31m'
GREEN='\033[0;32m'
NC='\033[0m'
echo "Running Linters:"
# Run tslint and get the output and return code
tslint=$(npm run lint)
ret_code=$?
# If it didn't pass, announce it failed and print the output
@dbrack
dbrack / pwValidation.ts
Last active July 19, 2017 13:11
Simple password validation
const validatePassword = (pw: string) => {
const minimumLength = 5;
const amountOfCriteria = 1;
const isLongEnough = (pw: string) => pw.length >= minimumLength;
const containsDigit = (pw: string) => (
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
.some(n => pw.includes(String(n)))
);
@dbrack
dbrack / select-cert.sh
Created November 17, 2016 14:19
Auto select certificate for a domain in chrome
defaults write com.google.Chrome AutoSelectCertificateForUrls -array-add -string '{"pattern":"https://[*.]my.domain:8090","filter":{"ISSUER":{"CN":"example.com"}}}'
@dbrack
dbrack / py-virtual-env.md
Last active May 16, 2016 18:32
Python virtual env OSX

#Python virtual env / Django OS X

Install virtualenv/virtualenvwrapper

pip install virtualenv

pip install virtualenvwrapper

Add the following to your .zshrc/bashrc

@dbrack
dbrack / keybase.md
Created April 6, 2016 12:03
Keybase identity

Keybase proof

I hereby claim:

  • I am dbrack on github.
  • I am dbr (https://keybase.io/dbr) on keybase.
  • I have a public key whose fingerprint is 69D6 2355 184E 214E 68E2 2BA4 577D 3E61 9394 E427

To claim this, I am signing this object:

@dbrack
dbrack / functor-definition.md
Last active July 19, 2017 13:26
Functors and higher order functions - definition

objects that implement map are functors. So, Array is a functor, and Array.filter is a higher order function

abstract

a functor is an object which acts as a container for a value, which then allows you to APPLY one or more functions to that value, and returns a new functor (in case of .map(), an Array) containing the transformed value.

See also here

@dbrack
dbrack / change-java-version.sh
Last active March 13, 2016 15:36
Change JDK/Java Version on OS X
/usr/libexec/java_home -v 1.7.0_45 --exec javac -version # http://docs.oracle.com/javase/7/docs/webnotes/install/mac/mac-jdk.html
@dbrack
dbrack / ChangeTextEncoding
Created September 29, 2013 16:26
Script to change text encoding of files
find . -type f -name "*.java" | xargs vim +"argdo set bomb | set fileencoding=utf-8 | w"
find . -type f -name "*.java" | xargs vim +"argdo set fileencoding=utf-8 | w"