Skip to content

Instantly share code, notes, and snippets.

View oleksiyp's full-sized avatar

Oleksiy Pylypenko oleksiyp

View GitHub Profile
#!/bin/bash
dig @208.67.222.220 myip.opendns.com | grep -A 1 "ANSWER SECTION" | tail -n 1 | cut -f 5
@oleksiyp
oleksiyp / gist:1c6b2203c52596dcfc5b
Created May 20, 2014 17:50
Making UncaughtExceptionHandler user friendly
package com.silverrail.utils;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
public class UncaughtExceptionHandlerForHumans implements Thread.UncaughtExceptionHandler {
@Override
public void uncaughtException(Thread t, Throwable e) {
List<Throwable> chain = new ArrayList<>();
@oleksiyp
oleksiyp / WhatsAmIDoingTracker.java
Last active August 29, 2015 14:05
Tracks thread execution point (stack traces) using polling and logs them to provided listener
package dataxu.learn.etl.repacking_tool;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
@oleksiyp
oleksiyp / watch-dev-deploy.sh
Last active August 29, 2015 14:05
Live deploy of classes using via ssh
#!/bin/bash
# required:
# sudo apt-get install inotify-tools
temp_dir=`mktemp -d`
target_host="...CHANGE..."
target_remote_dir="...CHANGE..."
pid="not_a_pid"
@oleksiyp
oleksiyp / System Design.md
Created April 18, 2016 10:18 — forked from vasanthk/System Design.md
System Design Cheatsheet

#System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

##Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@oleksiyp
oleksiyp / org.sh
Created July 15, 2016 18:08
Deduplicate and orgranize directories by date
find . -type f -print0 | \
while IFS='' read -r -d '' x; do
d=$(date -r "$x" +%Y-%m-%d)
mkdir -p "$d"
mv -f "$x" "$d/"
done
@oleksiyp
oleksiyp / ExampleMockK.kt
Created October 20, 2017 18:04
Example tests written with MockK usage
package io.github.oleksiyp.proxy.controller
import io.github.oleksiyp.netty.JsonScope
import io.github.oleksiyp.netty.RequestHttpHandlerScope
import io.github.oleksiyp.proxy.service.ProxyConnection
import io.github.oleksiyp.proxy.service.ProxyOps
import io.kotlintest.matchers.shouldBe
import io.kotlintest.specs.StringSpec
import io.netty.handler.codec.http.HttpMethod
import io.netty.handler.codec.http.HttpResponseStatus
@oleksiyp
oleksiyp / SimpleMatcherExample.kt
Created November 2, 2018 05:43
"MockK: intentions" example about matchers
data class ListWithoutOrderMatcher<T>(
val expectedList: List<T>,
val refEq: Boolean
) : Matcher<List<T>> {
val map = buildCountsMap(expectedList, refEq)
override fun match(arg: List<T>?): Boolean {
if (arg == null) return false
return buildCountsMap(arg, refEq) == map
}
@oleksiyp
oleksiyp / CompositeMatcher.kt
Created November 2, 2018 06:24
"MockK: intentions" example about composite matchers
/**
* Boolean logic "AND" and "OR" matcher composed of two other matchers
*/
data class AndOrMatcher<T : Any>(
val and: Boolean,
val first: T,
val second: T
) : Matcher<T>, CompositeMatcher<T>, CapturingMatcher {
override val operandValues: List<T>
get() = listOf(first, second)
@oleksiyp
oleksiyp / AndroidSupportedFeatures.md
Created November 2, 2018 06:46
"MockK: intentions" Android supported features.
Feature Unit tests Instrumetation test