Skip to content

Instantly share code, notes, and snippets.

View ok3141's full-sized avatar

Oleksii ok3141

View GitHub Profile
import com.shamanland.annotations.NonNull;
import com.shamanland.annotations.Nullable;
public final class ImmutableByteArray {
@NonNull
private final byte[] bytes;
@NonNull
public byte[] getBytes() {
return bytes.clone();
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
@ok3141
ok3141 / ffmpeg.md
Created August 7, 2019 16:32 — forked from protrolium/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

@ok3141
ok3141 / openssl_commands.md
Created July 11, 2019 13:10 — forked from p3t3r67x0/openssl_commands.md
Some list of openssl commands for check and verify your keys

openssl

Install

Install the OpenSSL on Debian based systems

sudo apt-get install openssl
@ok3141
ok3141 / SimpleEncoder.java
Created May 15, 2019 09:00
Simple XOR encoder
public class SimpleEncoder {
private static final byte[] SECRET = {
(byte) 0x9e, (byte) 0x40, (byte) 0x5e, (byte) 0xdf,
(byte) 0xd5, (byte) 0x92, (byte) 0x90, (byte) 0x60,
(byte) 0xfe, (byte) 0x4a, (byte) 0xaf, (byte) 0x50,
(byte) 0x74, (byte) 0xed, (byte) 0xcb, (byte) 0x74,
};
public static void xor(@NonNull byte[] input, @NonNull byte[] secret, boolean x) {
if (input.length < 1 || secret.length < 1) {
@ok3141
ok3141 / CustomTypefaceSpan.java
Created May 7, 2019 09:13
CustomTypefaceSpan
import android.graphics.Paint;
import android.graphics.Typeface;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextPaint;
import android.text.style.MetricAffectingSpan;
/**
* @see android.text.style.TypefaceSpan
*/
@ok3141
ok3141 / themes.md
Created May 7, 2019 09:10 — forked from ricardoalcocer/themes.md
Changing Android ActionBar Theme and Android Style

Customizing the overall App Style

This guide has been updated for Titanium SDK 3.3.0 which uses AppCompat to bring the ActionBar to Android 2.3.x

Android has a build-in theming system. Using this feature you can easily change the base color Android uses for its controls across your app, allowing you to provide better branding and personalization, while maintaining Android's UI and UX.

Android built-in themes are:

  • Holo (Mostly Black and Cyan)
  • Holo Light (Mostly White and Gray)
@ok3141
ok3141 / DrawablesValidator.java
Created April 16, 2019 09:43
Solution which helps to avoid crashes of sideloaded APK generated from AAB
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
@ok3141
ok3141 / JsonUtils.java
Last active January 29, 2020 13:27
The simplest Json parser (Android)
import android.util.JsonReader;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.io.IOException;
import java.io.StringReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
@ok3141
ok3141 / Promise.java
Last active January 23, 2020 11:48
Java implementation of Promise based on LiveData + lambda in Android
import android.os.Handler;
import android.util.Pair;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.arch.core.util.Function;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.Observer;