Skip to content

Instantly share code, notes, and snippets.

View cypressious's full-sized avatar
🤖
beep bop

Kirill Rakhman cypressious

🤖
beep bop
View GitHub Profile
@cypressious
cypressious / MarkerMapFragment.java
Created July 23, 2014 15:44
Retrolambda build fail
package com.cypressworks.retrolambdafailure;
import com.google.android.gms.maps.SupportMapFragment;
public class MarkerMapFragment extends SupportMapFragment {
Runnable r = () -> {
};
}
@cypressious
cypressious / HockeySender.kt
Last active August 29, 2015 14:27 — forked from ashtom/HockeySender.java
Custom ReportSender for HockeyApp and ACRA with OkHTTP in Kotlin
package net.hockeyapp.android.demo
import com.squareup.okhttp.FormEncodingBuilder
import com.squareup.okhttp.OkHttpClient
import com.squareup.okhttp.Request
import org.acra.ACRA
import org.acra.ReportField
import org.acra.collector.CrashReportData
import org.acra.sender.ReportSender
import java.util.Date
fun <T> Observable<T>.delayUntil(value: T): Observable<T> {
val replaySubject = ReplaySubject.create<T>()
val sharedObservable = this.publish().autoConnect(2)
sharedObservable.subscribe(replaySubject)
val delayObservable = sharedObservable
.first { it == value }
.concatWith(Observable.error(IllegalArgumentException()))
val mutex = Semaphore(0)
val source = Observable.interval(200, TimeUnit.MILLISECONDS).take(10)
val delayed = source.delayUntil(3L)
println("${System.currentTimeMillis()}: start")
delayed.subscribe(
{ println("${System.currentTimeMillis()}: $it") },
{ println("Failed with $it") },
{ mutex.release() }
)
@cypressious
cypressious / ExampleApplication.java
Last active November 24, 2016 08:50 — forked from pepyakin/ExampleApplication.java
Gist which should prevent leaks of Activity in ClipboardUIManager.
public class ExampleApplication extends Application {
@Override public void onCreate() {
super.onCreate();
if (Build.VERSION.SDK_INT >= 21) {
try {
Class<?> cls = Class.forName("android.sec.clipboard.ClipboardUIManager");
Method m = cls.getDeclaredMethod("getInstance", Context.class);
m.setAccessible(true);
Object o = m.invoke(null, this);
} catch (Exception ignored) { }
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red_50">#fde0dc</color>
<color name="red_100">#f9bdbb</color>
<color name="red_200">#f69988</color>
<color name="red_300">#f36c60</color>
<color name="red_400">#e84e40</color>
<color name="red_500">#e51c23</color>
<color name="red_600">#dd191d</color>
<color name="red_700">#d01716</color>
@cypressious
cypressious / build.gradle
Last active November 18, 2017 18:52
Firefox Webextension in Kotlin
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.1.60'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
buildscript {
ext.kotlin_version = '1.1.60'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
{
"manifest_version": 2,
"name": "Beastify",
"version": "1.0",
"permissions": [
"activeTab"
],
"browser_action": {
"default_icon": "icons/beasts-32.png",
const val SCRIPT_PATH = "/content_script/build/classes/kotlin/main/min"
fun main(args: Array<String>) {
Promise.all(arrayOf(
browser.tabs.executeScript(Script("$SCRIPT_PATH/kotlin.js")),
browser.tabs.executeScript(Script("$SCRIPT_PATH/content_script.js"))
))
.then({ listenForClicks() })
.catch(::reportExecuteScriptError)
}