Skip to content

Instantly share code, notes, and snippets.

View pt2121's full-sized avatar

Prat pt2121

View GitHub Profile
@pt2121
pt2121 / gist:5534887
Created May 7, 2013 18:25
Verify a certificate in Java
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.PublicKey;
import java.security.SignatureException;
import sbt._
import sbt.Keys._
import android.Keys._
object JavaAndroidBuild extends Build {
lazy val rootSettings = Seq(
packageT in Compile <<= packageT in Android in app3,
packageRelease <<= packageRelease in Android in app3,
packageDebug <<= packageDebug in Android in app3
### Keybase proof
I hereby claim:
* I am prt2121 on github.
* I am prat (https://keybase.io/prat) on keybase.
* I have a public key whose fingerprint is B33B 76D2 DEEB 1DF3 AF0A 0786 F4BB B96C 1B23 D899
To claim this, I am signing this object:
@pt2121
pt2121 / OAuthActivity.java
Last active September 18, 2015 09:56 — forked from lethargicpanda/OAuthActivity.java
OAuthActivity implements OAuth logg in in your Android application
public class OAuthActivity extends Activity {
public static String OAUTH_URL = "https://github.com/login/oauth/authorize";
public static String OAUTH_ACCESS_TOKEN_URL = "https://github.com/login/oauth/access_token";
public static String CLIENT_ID = "YOUR_CLIENT_ID";
public static String CLIENT_SECRET = "YOUR_CLIENT_SECRET";
public static String CALLBACK_URL = "http://localhost";
@Override
@pt2121
pt2121 / AndroidManifest.xml
Created September 29, 2015 22:32 — forked from xrigau/AndroidManifest.xml
Disable animations for Espresso tests - run with `gradle cATDD`
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.novoda.espresso">
<!-- For espresso testing purposes, this is removed in live builds, but not in dev builds -->
<uses-permission android:name="android.permission.SET_ANIMATION_SCALE" />
<!-- ... -->
@pt2121
pt2121 / AndroidManifest.xml
Created September 30, 2015 00:27 — forked from danielgomezrico/AndroidManifest.xml
Android - AndroidJUnitRunner that disable animations, disable screen lock and wake processor all the time to avoid Tests to fail because of test device setup. Note that my test buildType is mock to have a manifest just for tests (dont want to ship an app with SET_ANIMATION_SCALE permissions...).
<?xml version="1.0" encoding="utf-8"?>
<!-- This file should be outside of release manifest (in this case app/src/mock/Manifest.xml -->
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tests">
<!-- For espresso testing purposes, this is removed in live builds, but not in dev builds -->
<uses-permission android:name="android.permission.SET_ANIMATION_SCALE" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
@pt2121
pt2121 / introrx.md
Created November 14, 2015 14:32 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@pt2121
pt2121 / tmp.log
Created January 1, 2016 23:47
How to make a HTTP GET request on Google Glass GDK
01-01 18:46:06.352 10240 10258 D App : <!doctype html>
01-01 18:46:06.352 10240 10258 D App : <html>
01-01 18:46:06.352 10240 10258 D App :
01-01 18:46:06.352 10240 10258 D App : <head>
01-01 18:46:06.352 10240 10258 D App :
01-01 18:46:06.352 10240 10258 D App : <meta charset="utf-8"/>
01-01 18:46:06.352 10240 10258 D App : <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
01-01 18:46:06.352 10240 10258 D App : <meta name="viewport" content="width=device-width, initial-scale=1"/>
01-01 18:46:06.352 10240 10258 D App :
01-01 18:46:06.352 10240 10258 D App :
@pt2121
pt2121 / scanTest.kt
Created January 5, 2016 12:12
Simple scanl in Kotlin
import com.google.common.truth.Truth.assertThat
import org.junit.Test as test
/**
* Created by pt2121 on 11/22/15.
*/
class scanTest {
fun <A, B> Iterable<A>.scanl(initial: B, f: (B, A) -> B): List<B> {
return listOf(initial).plus(if (this.count() == 0) {