Skip to content

Instantly share code, notes, and snippets.

View kyryloz's full-sized avatar
🏠
Working from home

Kiril Zap kyryloz

🏠
Working from home
View GitHub Profile
git filter-branch --env-filter '
OLD_EMAIL="<old email>"
CORRECT_NAME="<correct name>"
CORRECT_EMAIL="<correct email>"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
return facebookService.validateFacebookUser(credentialsDto)
.map(this::findOrCreateChordUser)
.map(user -> jwtTokenService.generateToken(user))
.map(TokenDto::new)
.map(ResponseEntity::ok)
.orElseThrow(() -> new AuthorizationServiceException("Can't authenticate"));
@kyryloz
kyryloz / gradle-filter-types.groovy
Created February 1, 2017 09:51
filter unusable flavors or build types for gradle
variantFilter { variant ->
def names = variant.flavors*.name
if (names.contains("devBeta") && variant.buildType.name == "release") {
variant.ignore = true
}
}
// Return the set of products that were ordered by every customer
fun Shop.getSetOfProductsOrderedByEveryCustomer(): Set<Product> {
val allProducts = customers.flatMap { it.orders.flatMap { it.products }}.toSet()
return customers.fold(allProducts, {
orderedByAll, customer ->
orderedByAll.intersect(customer.orders.flatMap { it.products }.toSet())
})
}
@kyryloz
kyryloz / react-native-logs.md
Last active June 7, 2017 12:15
React Native: logs
@kyryloz
kyryloz / remote-port-check.sh
Created June 14, 2017 09:22
Check whether remote port is open
nc -zv 10.1.133.41 50001
@kyryloz
kyryloz / AndroidNumberPicker (react-native)
Last active February 28, 2018 15:21
NumberPicker react-native bridge (Android)
Wraps Android's `android.widget.NumberPicker`.
Supported 'Nothing' selection, which appears as first item in the NumberPicker.
import androidx.lifecycle.LiveData
import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.Transformations
fun <T, R> LiveData<T>.map(mapFunction: (T) -> R): LiveData<R> =
Transformations.map(this) { mapFunction(it) }
fun <T> LiveData<T>.filter(predicate: (T) -> Boolean): LiveData<T> =
MediatorLiveData<T>().apply {
addSource(this@filter) { if (predicate(it)) value = it }
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software