Skip to content

Instantly share code, notes, and snippets.

@jaydee2991
jaydee2991 / DraggableOverlay.java
Created October 23, 2011 06:49 — forked from k-goto/DraggableOverlay.java
draggable overlay item
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
@bjoernQ
bjoernQ / AndroidManifest.xml
Created October 14, 2013 13:02
Creating a System Overlay (Always on Top over all Apps) in Android
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.mobilej.overlay"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" />
<application android:label="SystemOverlay" >
<activity
@JakeWharton
JakeWharton / ShampooRule.java
Last active August 31, 2023 15:47
Got flaky tests? Shampoo them away with a quick JUnit rule. Apache 2.
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
/** Got flaky tests? Shampoo them away. */
public final class ShampooRule implements TestRule {
private final int iterations;
public ShampooRule(int iterations) {
if (iterations < 1) throw new IllegalArgumentException("iterations < 1: " + iterations);
class ReverseProxyDispatcher extends Dispatcher {
private final OkHttpClient client;
private final HttpUrl serverUrl;
public ReverseProxyDispatcher(HttpUrl url) {
serverUrl = url;
client = new OkHttpClient.Builder().build();
}
@Override
@paour
paour / ReverseProxyDispatcher.java
Created October 14, 2016 07:40
An OkHttp MockWebServer dispatcher that makes it possible to proxy requests to an upstream server while checking the request and response in tests.
interface ReverseProxyValidator {
void validate(RecordedRequest request, Response response);
}
class ReverseProxyDispatcher extends Dispatcher {
private final OkHttpClient client;
private final HttpUrl serverUrl;
private final ReverseProxyValidator validator;
public ReverseProxyDispatcher(HttpUrl url, ReverseProxyValidator validator) {
@dennisstritzke
dennisstritzke / fileEncryption.md
Last active March 6, 2023 21:00
A very short documentation on using OpenSSL keys to encrypt and decrypt files.

Procedure

  1. Create a random key.
  2. Encrypt the random key via an SSH RSA public key
  3. Send the encrypted file and encrypted key
  4. Encrypt the key
  5. Encrypt the file

Create key via

openssl genrsa -out rsa.private 4096
@antonshilov
antonshilov / TreeRenderer.kt
Last active July 1, 2024 18:49
Simple tree hierarchy rendering with Jetpack Compose
package com.example.myapplication
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.Box
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
@epool
epool / BuildXcFramework.kt
Last active December 5, 2023 13:11
Builds a XcFramework from a shared module in KMM.
//region XcFramework tasks
val xcFrameworkPath = "xcframework/${project.name}.xcframework"
tasks.create<Delete>("deleteXcFramework") { delete = setOf(xcFrameworkPath) }
val buildXcFramework by tasks.registering {
dependsOn("deleteXcFramework")
group = "build"
val mode = "Release"
val frameworks = arrayOf("iosArm64", "iosX64")
@MarkusKramer
MarkusKramer / Base64.kt
Last active October 29, 2024 14:53
Kotlin Multiplatform Base64 - no extra dependencies. Based on Java's implementation.
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
@bmc08gt
bmc08gt / monkey.gradle
Created July 20, 2021 19:40
Gradle task to piggyback off install task allowing CLI opening of the app.
android.applicationVariants.all { variant ->
task "open${variant.name.capitalize()}" {
dependsOn "install${variant.name.capitalize()}"
doLast {
exec {
commandLine "adb shell monkey -p ${variant.applicationId} -c android.intent.category.LAUNCHER 1".split(" ")
}
}
}