Skip to content

Instantly share code, notes, and snippets.

plugins {
id 'org.jetbrains.kotlin.jvm'
}
apply plugin: 'java-library'
dependencies {
api "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
api "io.reactivex.rxjava2:rxjava:$rx_java_version"
}
class AppActivity {
....
override fun exec(command: UiCommand) {
when (command) {
is UiCommand.CloseLeftMenu -> closeLeftMenu()
is UiCommand.DisplayShopData -> displayShopData(command.shop)
is UiCommand.DisplayUserData -> setUser(command.user)
is UiCommand.ResetView -> resetView()
is UiCommand.ShowSplashScreen -> showSplashScreen(command.text)
class CityRepository @Inject constructor(
private val publicApi: PublicApi,
private val pool: SchedulersPool
) {
protected val parser = CriteriaParser()
fun getCities(criteria: Criteria): Single<CityCollection> {
return publicApi
.let {
if (criteria.page.isEmpty()) {
it.getCities(toQueryMap(criteria))
override fun panToBounds() {
val isSingleMarker = markerToShopStorage.count() == 1
try {
val move: CameraUpdate = when {
isSingleMarker -> CameraUpdateFactory.newLatLngZoom(boundsBuilder.build().center, 12f)
else -> {
val padding = 200
CameraUpdateFactory.newLatLngBounds(boundsBuilder.build(), padding)
}
}
@dmz9
dmz9 / BusinessTransactionHandler.php
Last active May 2, 2018 19:21
Sequence per entity for doctrine with pessimistic lock
<?php
class BusinessTransactionHandler{
public function persistOrder( Order $order, EntityManager $em ) {
$em->beginTransaction();
try {
$counter = $em->find( "AppBundle:ShopOrderCounter",
$order->getShop()
->getOrderCounter()
->getId(),
@dmz9
dmz9 / Filtering.php
Created April 8, 2018 21:50
url to criteria
<?php
/**
* Date: 02.03.2018
* Time: 0:16
*/
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\Expr\CompositeExpression;
use Doctrine\Common\Collections\Expr\Expression;
use Doctrine\Common\Collections\ExpressionBuilder;
@dmz9
dmz9 / CreateProductRequest.php
Last active April 26, 2018 09:38
subset symfony validator
<?php
namespace AppBundle\Rest\Request;
use AppBundle\Validator\Constraints\Subset;
use JMS\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Class CreateProductRequest