Skip to content

Instantly share code, notes, and snippets.

@parzonka
parzonka / clonebranch.sh
Created December 3, 2012 18:38
Clone git branch locally
#!/usr/bin/env bash
# usage:
# cd /directory/with/git/repo
# clonebranch <branchname>
# => branch is cloned to /directory/with/git/repo/../reponame-branchname
git clone -b $1 file://${PWD} ${PWD}/../${PWD##*/}-$1
@parzonka
parzonka / widescreen_with_thread_arcs.plist
Last active December 12, 2015 03:29
Custom MailMate (http://freron.com) layout for Mailboxes view. Extends the installed widescreen layout by adding a vertical thread arcs view at the right. See screen shot at https://www.dropbox.com/s/ujdz5mgifhpq8ke/mailmate-widescreen-threadarcs.png . Save it to `~/Library/Application Support/MailMate/Resources/Layouts/Mailboxes/widescreen_with…
/* Custom MailMate (http://freron.com) layout for Mailboxes view. Extends the installed widescreen
layout by adding a vertical thread arcs view at the right. Save it to
"~/Library/Application Support/MailMate/Resources/Layouts/Mailboxes/widescreen_with_thread_arcs.plist"
and it will be available after a restart of MailMate. */
{
name = "Widescreen with Thread Arcs";
rootViewer =
{
viewerType = "MmSplitView";
@parzonka
parzonka / getStackTrace.java
Created December 16, 2013 16:15
Gets the stack trace from the given throwable.
/**
* Gets the stack trace from the given throwable.
*
* @param throwable
* a throwable
* @return stack trace as string
*/
public static String getStackTrace(Throwable throwable) {
final StringWriter stringWriter = new StringWriter();
throwable.printStackTrace(new PrintWriter(stringWriter));
@parzonka
parzonka / substitute_strings_in_files_recursively.sh
Created February 26, 2016 23:41
find . -type f -name "*.*" -print0 | LC_ALL=en_US.CP437 xargs -0 sed -i '' -e 's/{{{name}}}/bar/g'
# substitute the string '{{{name}}}' with 'johndoe' in all files (including hidden ones) recursively and in-place
# tested on OSX, it does not creates any strange files based on .DS_STORE
find . -type f -name "*.*" -print0 | LC_ALL=en_US.CP437 xargs -0 sed -i '' -e 's/{{{name}}}/johndoe/g'
@parzonka
parzonka / DistributionTest.java
Last active July 27, 2016 18:38 — forked from MikhailGolubtsov/DistributionTest
Hazelcast map-reduce example - counting distribution
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import com.hazelcast.mapreduce.Combiner;
import com.hazelcast.mapreduce.CombinerFactory;
import com.hazelcast.mapreduce.Context;
import com.hazelcast.mapreduce.Job;
import com.hazelcast.mapreduce.JobCompletableFuture;
import com.hazelcast.mapreduce.JobTracker;
import com.hazelcast.mapreduce.KeyValueSource;
@parzonka
parzonka / _services.txt
Last active September 21, 2016 19:22
yoctoservices, ..., microservices, ..., yottaservices. Seen at https://news.ycombinator.com/item?id=9859544
Prefix Symbol Size Example
yocto y 1 bit Theoretical minimum
zepto z 1 byte (close enough to 10 bits) Really small APL program
atto a 10 chars nc -l 8080
femto f 1 line (roughly 100 chars) netcat piped into something else
pico p 10 lines tiny python service
nano n 100 lines small python service
micro μ 1000 lines typical "smallish" service
milli m 10,000 lines about as big as "microservices" would go these days, or a small monolithic app
centi c 100,000 lines decent-sized monolithic app
@parzonka
parzonka / jdk-mvn-ubuntu.sh
Last active December 20, 2016 17:39
install jdk and maven for ubuntu
#!/bin/bash
# jdk
sudo su root
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u73-b02/jdk-8u73-linux-x64.tar.gz
tar -zxf jdk-8u73-linux-x64.tar.gz -C /opt
update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_73/bin/java 100
echo 'export JAVA_HOME=/opt/jdk1.8.0_73' >> /home/ubuntu/.bash_profile
rm jdk-8u73-linux-x64.tar.gz
@parzonka
parzonka / sysinfo.sh
Created February 23, 2014 14:47
Get linux system info and version
# architecture #
lscpu
# release #
# RHEL, CentOS
cat /etc/redhat-release
# Ubuntu
cat /etc/issue
lsb_release -a
@parzonka
parzonka / installmavenoncentos.sh
Last active March 10, 2017 01:38
Install maven on linux
#!/bin/bash
#
# existing versions are not overwritten/deleted
# seamless upgrades/downgrades
# $M2_HOME points to latest *installed* (not released)
# config
mirror=http://mirror.cc.columbia.edu/pub
mvnversion=3.0.5
cscript /nologo wget.js http://example.com