Skip to content

Instantly share code, notes, and snippets.

@mgurov
mgurov / nohup.run.sh
Created May 1, 2013 12:17
nohupped run with pid traced
#!/bin/bash -e
nohup ./cmd.sh &
NOHUP_PID=$!
echo $NOHUP_PID | tee nohup.pid
@mgurov
mgurov / firs.sh
Created January 13, 2014 10:33
for all first-level subdirectories execute e.g. `firs git svn fetch`
#!/bin/bash
for dir in */; do
echo $dir
cd $dir
($@)
cd ..
done
@mgurov
mgurov / gitstatall.sh
Last active January 3, 2016 02:49
git status + checked out maven pom version + git diff to given branch
#!/bin/bash -e
#depends on xml starlet, brew install xmlstarlet
if [ $1 ]; then
BASE_BRANCH=$1
else
BASE_BRANCH=origin/master
fi
@mgurov
mgurov / profile.sh
Last active November 23, 2015 16:39
export PS1="\w$ "
if [ $ITERM_SESSION_ID ]; then
export PROMPT_COMMAND='echo -ne "\033];${PWD#/Users/mgu}\007";';
fi
alias json="python -mjson.tool"
alias xmlcat="xmllint --format -"
alias grep="grep --color"
alias confluize='sed -E "s/([-\[\{\*\|])/\\\\\1/g" | sed "s/:)/\\\:)/"'
@mgurov
mgurov / .gitconfig
Last active January 20, 2020 16:04
[user]
name = Mykola Gurov
[apply]
ignorewhitespace = change
[alias]
lol = log --graph --decorate --pretty=oneline --abbrev-commit --all --date-order
gol = log --graph --oneline
# new = !git init . && git commit --allow-empty -m 'initial'
#via https://answers.atlassian.com/questions/179848/local-checkout-of-a-pull-request-in-stash
# prstash = "!f() { git fetch $1 refs/pull-requests/$2/from:$3; } ; f"
@mgurov
mgurov / gitchangedsince.sh
Created November 11, 2014 15:09
git changed since revision
git diff $1 --stat --name-only --diff-filter=ACMR -- *.php
@mgurov
mgurov / gist:a58c010889124a0095b6
Created December 29, 2014 07:43
dual table at apache spark
import org.apache.spark.sql._
val hc = new org.apache.spark.sql.hive.HiveContext(sc)
val schema = StructType(Seq(StructField("dual", StringType, true)))
val rowRDD = sc.parallelize(Seq(Row("dual")))
val schemaRDD = hc.applySchema(rowRDD, schema)
schemaRDD.registerTempTable("dual")
hc.hql("select 'hello world' from dual").collect
@mgurov
mgurov / gist:93062e3afaad5d09f0b2
Created June 8, 2015 21:15
.git/hooks/post-commit: sync remote automatically
#!/bin/sh
if git remote | grep autosync > /dev/null; then
for remote in $(git remote | grep autosync); do
git push $remote --all -f
done
fi
@mgurov
mgurov / gist:c333970b1f8ecd925b0e
Last active August 29, 2015 14:23
massive git remote migration
for GIT_DIR in $(find . -name ".git"); do git --git-dir=$GIT_DIR remote -v | cut -d ' ' -f 1 | uniq | grep old_repo | sed 's/old_repo/new_repo/' | xargs -n 2 git --git-dir=$GIT_DIR remote set-url; done