Skip to content

Instantly share code, notes, and snippets.

View neworld's full-sized avatar
🇱🇹
Programming

Andrius Semionovas neworld

🇱🇹
Programming
  • Vinted
  • Vilnius, Lithuania
View GitHub Profile
@neworld
neworld / BreakDisposeChainObservable.kt
Created March 9, 2021 09:17
RxJava operator written in kotlin which breaks dispose chain
package com.vinted.feature.base.ui.rx
import io.reactivex.Observable
import io.reactivex.Observer
import io.reactivex.disposables.Disposable
/**
*
* Breaks dispose chain. Upstream will be not be disposed.
* This class should be used in cases where you need guarantee upstream will be executed at any price.
@neworld
neworld / howto.md
Last active September 15, 2020 11:32
How to make faster Android build without sacrificing new api lint check

Original solution sacrifices new api lint check.

Here my solution:

int minSdk = hasProperty('minSdk') ? minSdk.toInteger() : 16

apply plugin: 'com.android.application'

android {
 compileSdkVersion 23
@Test(timeout = 10000)
fun secondSubscription_returnsImmediate() {
val subject = PublishSubject.create<Int>()
val cachedSubject = subject.successOnlyCache()
cachedSubject.test() //first subscription
cachedSubject.test() //second subscription
//this method will never finishes if subscription is blocked.
}
@neworld
neworld / SearchViewFormatter.java
Last active April 14, 2020 17:08 — forked from ademar111190/SearchViewFormatter.java
Appcompat SearchView style formatter
package lt.mealdeal.android.utils;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.SearchView;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ImageSpan;
import android.view.View;
import android.widget.ImageView;
#!/bin/sh
# Copy templates to Android Studio in default location
TMP_PATH=`pwd`
TEMPLATES_PATH="/Applications/Android Studio.app/Contents/plugins/android/lib/templates/other"
DIRS=`find $TMP_PATH -type d -maxdepth 1 -not -name '.*' -not -path $TMP_PATH`
for f in $DIRS
package com.vinted.drawables
import android.content.res.ColorStateList
import android.graphics.*
import android.graphics.drawable.Drawable
import android.text.DynamicLayout
import android.text.Editable
import android.text.Layout
import android.text.TextPaint
// ==UserScript==
// @name Markdown img to html converter
// @namespace neworld
// @version 0.2.0
// @description Converts markdown img tag to html
// @author Neworld
// @match https://*.github.com/*
// @grant none
// @run-at context-menu
// ==/UserScript==
package com.neworldwar
import com.neworldwar.utils.Random
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.RepeatedTest
import org.junit.jupiter.api.TestInstance
const val REQUESTS = 100
const val TOTAL_DEPENDENCIES = 1000
const val DEPENDENCIES_PER_REQUEST = 100
val checkLock = Object()
val disposeLock = Object()
val completable = Completable.create { emitter ->
synchronized(checkLock) {
checkLock.notify()
}
if (!emitter.isDisposed) {
synchronized(disposeLock) {
try {
@neworld
neworld / duff.c
Created September 27, 2017 14:42
send(to, from, count)
register short *to, *from;
register count;
{
register n = (count + 7) / 8;
switch (count % 8) {
case 0: do { *to = *from++;
case 7: *to = *from++;
case 6: *to = *from++;
case 5: *to = *from++;