Skip to content

Instantly share code, notes, and snippets.

@LongClipeus
LongClipeus / HashUtils.kt
Last active January 15, 2025 06:32
How to generate checksum hash for a file in Kotlin
import StringUtils.encodeHex
import java.io.File
import java.io.FileInputStream
import java.io.InputStream
import java.security.MessageDigest
object HashUtils {
const val STREAM_BUFFER_LENGTH = 1024
@gtomek
gtomek / RotatingGradientView.kt
Last active February 1, 2021 09:48
example of how to rotate sweep gradient in android view
/**
* View showing rotating SweepGradient.
*/
class RotatingGradientView @JvmOverloads constructor(
context: Context?,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr) {
private val paint = Paint(Paint.ANTI_ALIAS_FLAG)
private var middleX = 0f
@xanscale
xanscale / RoundedBarChart.java
Last active May 30, 2025 19:43
MPAndroidChart BarChart with rounded corner (based from v3.1.0). Just replaced drawRect with drawRoundRect
package com.scarozza;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.RectF;
import android.util.AttributeSet;
import com.github.mikephil.charting.animation.ChartAnimator;
import android.app.Activity;
import android.content.Context;
import android.graphics.Rect;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewTreeObserver;
public class KeyboardEventListener implements ViewTreeObserver.OnGlobalLayoutListener {
private final Activity activity;
@gusenov
gusenov / git-cheat-sheet.sh
Last active June 13, 2025 12:59
Шпаргалка по Git.
#---------------------------------------------------------------------
# НАСТРОЙКИ
#---------------------------------------------------------------------
# Показать глобальную конфигурацию:
git config --global --list
git config --local user.name "user name"
git config --local user.email "user@email.com"
git config --local core.fileMode false
@objcode
objcode / ConcurrencyHelpers.kt
Last active September 22, 2025 10:56
Helpers to control concurrency for one shot requests using Kotlin coroutines.
/* Copyright 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@mileskrell
mileskrell / build.gradle.kts
Created April 19, 2019 04:26
Example of declaring Android signing configs using Gradle Kotlin DSL
android {
signingConfigs {
getByName("debug") {
keyAlias = "debug"
keyPassword = "my debug key password"
storeFile = file("/home/miles/keystore.jks")
storePassword = "my keystore password"
}
create("release") {
keyAlias = "release"
@karntrehan
karntrehan / DataFragment.kt
Created March 4, 2019 11:03
NestedScrollView + Paginated Recyclerview Android
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import androidx.core.view.ViewCompat
import androidx.core.widget.NestedScrollView
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.synthetic.main.fragment_data.nsvData
import kotlinx.android.synthetic.main.fragment_data.rvData
@limitedeternity
limitedeternity / m.vk.audio.js
Last active July 20, 2025 15:03
Delete VK audio from profile
new Promise(resolve => {
var offset = -100;
let pageScroll = () => {
window.scrollBy(0, 50);
if (window.pageYOffset === offset) {
return resolve(true);
}
offset = window.pageYOffset;
setTimeout(pageScroll, 50);
@mega-arbuz
mega-arbuz / .gitlab-ci.yml
Last active October 30, 2020 12:38
GitLab CI yml
image: jangrewe/gitlab-ci-android
before_script:
- export GRADLE_USER_HOME=$(pwd)/.gradle
- chmod +x ./gradlew
cache:
key: ${CI_PROJECT_ID}
paths:
- .gradle/