Skip to content

Instantly share code, notes, and snippets.

View nightwolf738's full-sized avatar

Night Wolf nightwolf738

View GitHub Profile
@gowthamgts
gowthamgts / DrawableExtension.kt
Created October 14, 2018 07:59
A kotlin extension to convert a Drawable object to Bitmap
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
fun Drawable.toBitmap(): Bitmap {
if (this is BitmapDrawable) {
return this.bitmap
}
/**
* An simple counter implementation of that determines idleness by
* maintaining an internal counter. When the counter is 0 - it is considered to be idle, when it is
* non-zero it is not idle. This is very similar to the way a Semaphore
* behaves.
* This class can then be used to wrap up operations that while in progress should block tests from
* accessing the UI.
*/
public final class SimpleCountingIdlingResource implements IdlingResource {
/**
* Contains a static reference IdlingResource, and should be available only in a mock build type.
*/
public class EspressoIdlingResource {
private static final String RESOURCE = "GLOBAL";
private static SimpleCountingIdlingResource mCountingIdlingResource =
new SimpleCountingIdlingResource(RESOURCE);
@nieldeokar
nieldeokar / AudioRecordThread.java
Last active October 20, 2024 04:43
Recording an Audio with .aac extension using AudioRecord android.
package com.nieldeokar.whatsappaudiorecorder.recorder;
import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaFormat;
import android.media.MediaRecorder;
import android.os.Build;
import android.util.Log;
@robertpainsi
robertpainsi / commit-message-guidelines.md
Last active October 30, 2024 19:51
Commit message guidelines

Commit Message Guidelines

Short (72 chars or less) summary

More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).

Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
@zach-klippenstein
zach-klippenstein / ChangePassword.java
Last active June 23, 2024 19:01
The keystore password on Java keystore files is utterly pointless. You can reset it without knowing it, as shown by this code. Note that private keys are still secure, as far as I know. The JKS implementation is copyright Casey Marshall (rsdio@metastatic.org), and the original source is available at http://metastatic.org/source/JKS.java. I've in…
import java.util.*;
import java.io.*;
import java.security.*;
public class ChangePassword
{
private final static JKS j = new JKS();
public static void main(String[] args) throws Exception
{