Skip to content

Instantly share code, notes, and snippets.

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

Kyrylo Zapylaiev kyryloz

🏠
Working from home
View GitHub Profile
@kyryloz
kyryloz / runIOS.js
Created December 3, 2019 06:32
Patched version of runIOS.js which sets the "iPhone X" by default instead of "iPhone 6"
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
const child_process = require('child_process');
const fs = require('fs');
@kyryloz
kyryloz / findMatchingSimulator.js
Created December 3, 2019 06:30
Patched version of findMatchingSimulator which fixes the error "Could not find iPhone 6 simulator"
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
/**
* Takes in a parsed simulator list and a desired name, and returns an object with the matching simulator.
import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView
class SpacingItemDecoration(
private val space: Int,
private val orientation: Int
) : RecyclerView.ItemDecoration() {
/*
* 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
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 }
@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.
@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 / react-native-logs.md
Last active June 7, 2017 12:15
React Native: logs
// 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())
})
}