Skip to content

Instantly share code, notes, and snippets.

View sergchil's full-sized avatar

Sergey Chilingaryan sergchil

View GitHub Profile
@sergchil
sergchil / EmojiRegex.java
Last active March 17, 2022 09:01
Regex for finding all emojis in string including surrogate pairs
public static final String sEmojiRegex = "(?:[\\u2700-\\u27bf]|" +
"(?:[\\ud83c\\udde6-\\ud83c\\uddff]){2}|" +
"[\\ud800\\udc00-\\uDBFF\\uDFFF]|[\\u2600-\\u26FF])[\\ufe0e\\ufe0f]?(?:[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]|[\\ud83c\\udffb-\\ud83c\\udfff])?" +
"(?:\\u200d(?:[^\\ud800-\\udfff]|" +
"(?:[\\ud83c\\udde6-\\ud83c\\uddff]){2}|" +
"[\\ud800\\udc00-\\uDBFF\\uDFFF]|[\\u2600-\\u26FF])[\\ufe0e\\ufe0f]?(?:[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]|[\\ud83c\\udffb-\\ud83c\\udfff])?)*|" +
@sergchil
sergchil / FlattenArraysTetst.java
Created December 4, 2017 18:07
Flatten nested arrays
public static void main() {
Object[] array1 = new Object[]{3}; // [3]
Object[] array2 = new Object[]{1, 2, array1}; // [ 1, 2, [3] ]
Object[] nestedArrays = new Object[]{array2, 4, null}; // [ [ 1, 2, [3] ] 4 ]
ArrayList<Integer> flatOutput = new ArrayList<>();
try {
flatten(nestedArrays, flatOutput);
System.out.println("flatOutput = " + flatOutput);
@sergchil
sergchil / BaseRecyclerViewAdapter.java
Created December 23, 2017 22:55
Recycler View Utils
/**
* A general RecyclerViewAdapter which supports OnItemClickListener and OnItemLongClickListener.
*
*/
public abstract class BaseRecyclerViewAdapter<VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private RecyclerViewListener.OnItemClickListener itemClickListener;
private RecyclerViewListener.OnItemLongClickListener itemLongClickListener;
public void setOnItemClickListener(
@sergchil
sergchil / ProfilingUtil.java
Last active January 31, 2018 07:44
Simple Mathod Profiling util forked from Android's TimingLogger
/**
* Created by sergey on 1/29/18.
*/
import android.os.SystemClock;
import java.util.ArrayList;
public class ProfilingUtil {
private static final String PROFILING = "PROFILING";
package pl.kpob.utils.extensions
import android.app.Activity
import android.content.Context
import android.graphics.Color
import android.support.v4.content.ContextCompat
import android.view.WindowManager
import flow.Flow
import org.jetbrains.anko.AlertDialogBuilder
import pl.sisms.gminformix.utils.extensions.supportsLollipop
@sergchil
sergchil / Once.kt
Created July 25, 2018 10:59
Helper class that invokes once
import java.util.concurrent.atomic.AtomicBoolean
/**
* Created with ❤ by Sergey Chilingaryan
*/
// Yes, I made class for this simple call
// but this is more readable than having booleans and checking ifs
// I hate using booleans with ifs to do things once
@sergchil
sergchil / build.gradle
Last active August 20, 2018 07:33
Change Android Studio'd genereted app-release to something like "devRelease-1.0.0.109.apk"
android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "${variant.name}-${variant.versionName}.${variant.versionCode}.apk"
}
}
@sergchil
sergchil / GpsUtils.kt
Last active August 13, 2019 09:09
Quickly written GPS util class to help you enable GPS and get the coordinates
package com.chilisoft.myapplication
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.location.LocationManager
import androidx.appcompat.app.AppCompatActivity
import com.google.android.gms.common.api.ApiException
import com.google.android.gms.common.api.ResolvableApiException

Download Audio from YouTube

-i - ignore errors

-c - continue

-t - use video title as file name

--extract-audio - extract audio track

@sergchil
sergchil / adbwificonnect.sh
Created September 26, 2019 11:42 — forked from amanshuraikwar/adbwificonnect.sh
Shell script to connect a USB connected device via adb over WiFi MacOS
# Purpose: Shell script to connect a USB connected device via adb over WiFi
#
# Author: Amanshu Raikwar
#
# Assumptions:
# 1. USB debugging is enabled in the Android device
# 2. The Android device is connected to the computer via USB
# 3. The Android device is connected to the same wifi as the computer
# 4. The Android device is accessible through port 5555 over the wifi network
#