Skip to content

Instantly share code, notes, and snippets.

Eric Kok erickok

  • Contractor at VRT Sporza & open-source dev as 2312 development
  • Leuven, Belgium
View GitHub Profile
View OperatorFreeze.java
/*
* Copyright 2016 Maxim Tuev.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@erickok
erickok / OkHttpGzippedLoggingInterceptor.java
Last active May 12, 2020
Simple logging interceptor for OkHttp that logs full request headers and response headers + body (useful for use with Retrofit 2 where logging was removed)
View OkHttpGzippedLoggingInterceptor.java
if (BuildConfig.DEBUG) {
httpclient.interceptors().add(new LoggingInterceptor());
}
public class LoggingInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
long t1 = System.nanoTime();
@erickok
erickok / SelfSignedCrtCertificate.java
Last active Jun 27, 2020
Loading a self-signed SSL certificate .crt file and packaging it into a SSLSocketFactory for use with a HttpsURLConnection.
View SelfSignedCrtCertificate.java
// Usage example...
HttpsURLConnection connection = (HttpsURLConnection) new URL("https://someurl.com").openConnection();
connection.setSSLSocketFactory(buildSslSocketFactory());
private static SSLSocketFactory buildSslSocketFactory(Context context) {
// Add support for self-signed (local) SSL certificates
// Based on http://developer.android.com/training/articles/security-ssl.html#UnknownCa
try {
@erickok
erickok / diff-online-translations-ftp
Last active May 3, 2020
Set of simple shell/php scripts to send the base translation and retrieve updated translations from a PASTT (https://github.com/erickok/pastt) installation. FTP (using ncftp) and SSH (using scp) versions are given. All scripts should be *run in a separate directory*, for example if your application 'myapp' resides in /home/myusername/dev/myapp/m…
View diff-online-translations-ftp
echo 'Get remote translation files from the server.'
rm -rf res
ncftpget -u myusername -R -F mydomain.org . www/translate/res
rm -rf res/values
php diff-online-translations.php
echo 'Copy new translation files to our local working copy.'
cp -rf res /home/myusername/dev/myapp/myandroidapp/
@erickok
erickok / OnOffPageIndicator.java
Created Aug 30, 2012
A simple ViewPagerIndicator that shows an 'on' or 'off' image per page appropriately
View OnOffPageIndicator.java
package nl.nl2312.android.components;
import nl.nl2312.android.R;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.ImageView;
You can’t perform that action at this time.