Skip to content

Instantly share code, notes, and snippets.

View lgawin's full-sized avatar

Łukasz Gawin lgawin

  • FoQuS
  • Warsaw, Poland
View GitHub Profile
private inline val Calendar.year: Int
get() = get(Calendar.YEAR)
private inline val Calendar.month: Int
get() = get(Calendar.MONTH)
private inline val Calendar.day: Int
get() = get(Calendar.DAY_OF_MONTH)
@lgawin
lgawin / ic_android_black_24dp.xml
Created December 1, 2017 18:28
This is the way to have vector drawable that uses `?colorControlNormal`
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#ff000000"
android:pathData="M6,18c0,0.55 0.45,1 1,1h1v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L11,19h2v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L16,19h1c0.55,0 1,-0.45 1,-1L18,8L6,8v10zM3.5,8C2.67,8 2,8.67 2,9.5v7c0,0.83 0.67,1.5 1.5,1.5S5,17.33 5,16.5v-7C5,8.67 4.33,8 3.5,8zM20.5,8c-0.83,0 -1.5,0.67 -1.5,1.5v7c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5v-7c0,-0.83 -0.67,-1.5 -1.5,-1.5zM15.53,2.16l1.3,-1.3c0.2,-0.2 0.2,-0.51 0,-0.71 -0.2,-0.2 -0.51,-0.2 -0.71,0l-1.48,1.48C13.85,1.23 12.95,1 12,1c-0.96,0 -1.86,0.23 -2.66,0.63L7.85,0.15c-0.2,-0.2 -0.51,-0.2 -0.71,0 -0.2,0.2 -0.2,0.51 0,0.71l1.31,1.31C6.97,3.26 6,5.01 6,7h12c0,-1.99 -0.97,-3.75 -2.47,-4.84zM10,5L9,5L9,4h1v1zM15,5h-1L14,4h1v1z" />
</vector>
@lgawin
lgawin / RemoteObject.java
Last active August 29, 2015 14:15
Example usage of guava's Equivalence, when in some cases, we just want to compare host (authority) parts of URLs
package pl.lgawin.guavasandbox.equivalence;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Objects.equal;
import com.google.common.base.Objects;
import com.google.common.net.MediaType;
public class RemoteObject {
public static void main(String... args) throws IOException {
String host = args[0];
int port = Integer.parseInt(args[1]);
String botName = args[2];
String botKey = args[3];
System.out.println("Connecting to " + host + ":" + port + " as "
+ botName + "/" + botKey);
//final Socket socket = new Socket(host, port);
@lgawin
lgawin / gist:6118253
Created July 31, 2013 00:16
Sample code for xmpp client
'''
Created on Jul 31, 2013
@author: gawcio
'''
import sys, json, xmpp, random, string
SERVER = 'gcm.googleapis.com'
PORT = 5235