Skip to content

Instantly share code, notes, and snippets.

@ezamelczyk
ezamelczyk / AutoSizeEditText.kt
Created January 8, 2020 07:52
Autosizing EditText kotlin extension.
fun EditText.setAutoSizing() {
initialTextSize = textSize
afterTextChanged { autoSizeText() }
}
private fun EditText.autoSizeText() {
if(text.isEmpty()) {
setTextSize(TypedValue.COMPLEX_UNIT_PX, initialTextSize)
return
}
@ezamelczyk
ezamelczyk / gitcount.sh
Created June 14, 2019 09:45
Git count lines by author
#!/bin/sh
git log --shortstat | grep -E "(Author: )(\b\s*([A-Z]\w+)){2}|fil(e|es) changed" | awk '
{
if($1 ~ /Author/) {
author = $2" "$3
} else {
files[author]+=$1
inserted[author]+=$4
deleted[author]+=$6
}
@ezamelczyk
ezamelczyk / DoubleXAxisRenderer.java
Created October 17, 2018 10:09
Custom XAxisRenderer for MPAndroidChart allowing us to display different labels for top and bottom axis.
public class DoubleXLabelAxisRenderer extends XAxisRenderer {
private IAxisValueFormatter topValueFormatter;
public DoubleXLabelAxisRenderer(ViewPortHandler viewPortHandler, XAxis xAxis, Transformer transformer, IAxisValueFormatter topValueFormatter) {
super(viewPortHandler, xAxis, transformer);
this.topValueFormatter = topValueFormatter;
}
@Override
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
01-04 12:02:45.251 5973-5973/com.example.ernest.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ernest.myapplication, PID: 5973
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ernest.myapplication/com.example.ernest.myapplication.MainActivity}: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter args
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
const readline = require('readline');
const readInterface = readline.createInterface({
input: process.stdin,
output: process.stdout
});
function getLastMondayMonths(startYear, endYear) {
if(!endYear) {
endYear = startYear;
import android.location.Location;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
import com.google.android.gms.location.LocationListener;
.marquee {
width: 30vw;
height: 10vh;
position: relative;
background-color: #222;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;