Skip to content

Instantly share code, notes, and snippets.

View code-n-roll's full-sized avatar

Roman Karanchuk code-n-roll

View GitHub Profile
@ishikawa
ishikawa / gist:88599
Created April 1, 2009 07:49
Java Sample Code for Calculating HMAC-SHA1 Signatures
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SignatureException;
import java.util.Formatter;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
/**
@raultm
raultm / StretchVideoView.java
Created September 16, 2012 17:03
Android : How to stretch video to use whole area of VideoView (sode snippets)
package com.raulete.dev.stretchvideoview.utils;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.VideoView;
public class StretchVideoView extends VideoView {
public StretchVideoView(Context context) {
super(context);
}
@benjchristensen
benjchristensen / FuturesA.java
Last active November 13, 2022 18:34
FuturesA.java Simple example of using Futures.
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class FuturesA {
public static void run() throws Exception {
@benjchristensen
benjchristensen / FuturesB.java
Last active December 12, 2023 09:36
FuturesB.java Example of using Futures for nested calls showing how it blocks inefficiently.
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@staltz
staltz / introrx.md
Last active June 26, 2024 10:24
The introduction to Reactive Programming you've been missing
@vganin
vganin / GridLayoutManager.java
Created October 17, 2015 18:57
Workaround for bug with RecycleView focus scrolling when navigating with d-pad (http://stackoverflow.com/questions/31596801/recyclerview-focus-scrolling)
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
/**
* {@link GridLayoutManager} extension which introduces workaround for focus finding bug when
* navigating with dpad.
*
* @see <a href="http://stackoverflow.com/questions/31596801/recyclerview-focus-scrolling">http://stackoverflow.com/questions/31596801/recyclerview-focus-scrolling</a>
@KANGOD
KANGOD / build.gradle
Created February 24, 2016 03:39
Generate signed and aligned apk without putting keystore info in build.gradle. via http://stackoverflow.com/a/20573171/1819810
android {
// omitting...
signingConfigs {
release {
readKeystoreProperties()
}
}
@lopspower
lopspower / README.md
Last active June 27, 2024 14:14
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

Hiding API keys in local.properties

  1. Add the API key to your local.properties file:
apiKey=<value>
  1. Add to the root level of your app-level build.gradle file:
@aakashns
aakashns / PermissionHandler.java
Created November 27, 2016 17:31
Utility class to assist with requesting permissions at run time on Android.
import android.content.pm.PackageManager;
import android.os.Build;
/**
* {@link PermissionHandler} provides a simple API to request Android permissions
* at runtime. The class exposes one static method: {@link #request} which the
* requesting activity should call to request or check for permission. The requesting
* activity must implement {@link PermissionActivity}.
*/
public class PermissionHandler {