Skip to content

Instantly share code, notes, and snippets.

@antonshilov
antonshilov / SwipeButton.kt
Created January 15, 2022 13:04
Swipeable Button created with Jetpack Compose
package com.antonshilov.swipebutton
import androidx.compose.animation.Crossfade
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
@antonshilov
antonshilov / Swipeable.kt
Created August 22, 2021 16:41
Swipeable
fun <T> Modifier.swipeable(
state: SwipeableState<T>,
anchors: Map<Float, T>,
...
)
@antonshilov
antonshilov / TreeRenderer.kt
Last active April 1, 2024 08:30
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
@antonshilov
antonshilov / RxExtensions.kt
Created April 25, 2019 09:44
RxJava 2 extension function to do something and retry after error
package com.antonshilov.rxextensions
import io.reactivex.Single
fun <T, R> Single<T>.doOnErrorAndRetry(action: Single<R>): Single<T> =
onErrorResumeNext {
it.printStackTrace()
action.flatMap { this }
}
@antonshilov
antonshilov / NullableExtensions.kt
Last active May 1, 2024 07:11
Kotlin extension function for nullable types to cast them to non-null or get a default value
/**
* Kotlin extension function for nullable types to cast them to non-null or get a default value
*/
public inline fun <T> T?.or(default: T): T = this ?: default
@antonshilov
antonshilov / Dockerfile
Created April 18, 2018 16:40
JamSpell Dockerized
FROM python:3.6.5-stretch
RUN apt-get update && \
apt-get -y install swig3.0
RUN pip3 install jamspell
#include <time.h>
#include <windows.h>
#include <iostream>
#include <string>
using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::to_string;
#include <time.h>
#include <windows.h>
#include <iostream>
#include <string>
using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::to_string;
print "Hello! Input format HH:MM"
time = str(raw_input("Time - "))
splittedTime = time.split(":")
try:
splittedTime = [int(i) for i in splittedTime]
except ValueError:
print "Invalid input"
exit()
splittedTime = [int(i) for i in splittedTime]
if splittedTime[0] > 23 or splittedTime[1] > 59:
@antonshilov
antonshilov / Gun class
Created March 1, 2015 13:07
Lab3 question
#include "gun.h"
class gun {
public:
gun() {
mutex = PTHREAD_MUTEX_INITIALIZER;
setisloaded(true);
}