Skip to content

Instantly share code, notes, and snippets.

@pchmielowski
pchmielowski / log_parsing.kt
Last active November 9, 2018 11:28
As parsing the date from string is the most complex task, this solution ensures, it is parsed lazily - as soon as the conditions are met, method returns and no unnecessary parsing is performed.
package net.chmielowski.recruitment
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
import java.time.Duration
import java.time.LocalDateTime
import java.time.Period
import java.time.format.DateTimeFormatter
import java.util.*
@pchmielowski
pchmielowski / loc.sh
Last active February 22, 2018 17:59
Lines of code vs time
#!/bin/sh
while true; do
git log -n 1 | grep Date >> loc
cloc . | grep Java >> loc
git checkout HEAD^1
done
cat loc | grep Java | awk '{ print $5 }'
cat loc | grep Date: | awk '{ print $3" "$4" "$5" "$6 }'
package net.chmielowski.rxtest;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import com.annimon.stream.Stream;
import com.jakewharton.rxbinding.view.RxView;
import com.jakewharton.rxbinding.widget.RxTextView;
@pchmielowski
pchmielowski / check-conflicts.bash
Created April 30, 2017 12:00
Script that checks if our branch has a conflict with any another
#!/bin/bash
function check() {
if [ `git rev-parse HEAD` == `git rev-parse "$1"` ]
then
# don't compare with the HEAD
return
fi
base=`git merge-base HEAD "$1"`
if [ "$base" == `git rev-parse "$1"` ]