Skip to content

Instantly share code, notes, and snippets.

View 2BAB's full-sized avatar
☀️
What's happening?

El Zhang 2BAB

☀️
What's happening?
View GitHub Profile
@2BAB
2BAB / image-fetch.main.kts
Created January 25, 2021 14:26
Blog Images Replacement
@file:DependsOn("com.squareup.okhttp3:okhttp:4.9.0")
import okhttp3.*
import okhttp3.internal.closeQuietly
import okio.IOException
import java.io.File
import java.util.concurrent.CountDownLatch
import java.util.concurrent.atomic.AtomicInteger
// Please specify the post directory, static-host blog usually puts all posts in one dir like "./_post"
@ychescale9
ychescale9 / build.gradle.kts
Last active September 18, 2023 11:52
Customizing APK file name with new AGP variant APIs
android {
onVariantProperties {
val mainOutput = outputs.single { it.outputType == VariantOutputConfiguration.OutputType.SINGLE }
tasks.register<CreateRenamedApk>("createRenamedApkFor${name}") {
this.originalApkFolder.set(artifacts.get(ArtifactType.APK))
this.builtArtifactsLoader.set(artifacts.getBuiltArtifactsLoader())
this.newApkFolder.set(layout.buildDirectory.dir("outputs/renamed_apk/${this@onVariantProperties.name}"))
this.versionCode.set(mainOutput.versionCode)
this.versionName.set(mainOutput.versionName)
}
@gaerfield
gaerfield / EventBus.kt
Last active May 19, 2021 09:49
Simple Kotlin-EventBus including Unit-Tests
package infrastructure
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.ConflatedBroadcastChannel
import kotlinx.coroutines.flow.*
internal class EventBus {
// Initialize the bus with an empty Event, so we can drop the first element everytime on a new subscription
// This is neccesary, because on subscription usually the current element is send (although it was added
// before subscription)
@xujiaji
xujiaji / KeyboardTool.kt
Last active May 16, 2019 03:12
android 键盘监听工具 kotlin
import android.app.Activity
import android.graphics.Rect
import android.view.View
import android.view.ViewGroup
import android.view.ViewTreeObserver
import android.app.Application
import android.os.Bundle
object KeyboardTool {
@ilblog
ilblog / README.md
Last active April 17, 2024 07:49
Create mp4 video from set of images in the browser client side, using ffmpeg.js in worker thread
@wispborne
wispborne / Preferences.kt
Last active July 21, 2022 03:47
Android SharedPreferences helper class for Kotlin. Easy-to-use delegated properties, automatic database creation, and listening for property changes.
import android.content.Context
import android.content.SharedPreferences
import kotlin.reflect.KProperty
/**
* Represents a single [SharedPreferences] file.
*
* Usage:
*
* ```kotlin
@stecman
stecman / TimerModule.h
Created August 22, 2016 22:45
React Native get relative time
#import <Foundation/Foundation.h>
#import "RCTBridgeModule.h"
@interface TimerModule : NSObject <RCTBridgeModule>
@end
@jason5ng32
jason5ng32 / surge.conf
Last active April 7, 2024 13:04
Surge Configs ( for 2.x )
[General]
loglevel = notify
skip-proxy = 127.0.0.1, 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, 100.64.0.0/10, localhost, *.local, ::ffff:0:0:0:0/1, ::ffff:128:0:0:0/1
bypass-tun = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12
# dns-server = 119.29.29.29,223.5.5.5,114.114.115.115
# external-controller-access = PASSWORD@0.0.0.0:6155
# ipv6 = true
// REMEMBER TO CHANGE THE external-controller-access' PASSWORD
@bryanstern
bryanstern / OkHttpStack.java
Last active April 24, 2022 03:17
An OkHttp backed HttpStack for Volley
/**
* The MIT License (MIT)
*
* Copyright (c) 2015 Circle Internet Financial
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@chris95x8
chris95x8 / UIActivity.java
Created December 13, 2014 22:35
FAB expand
package com.materialdesign.chris.materialdesignexperimenting;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.ViewAnimationUtils;