Skip to content

Instantly share code, notes, and snippets.

Jan Škrášek hrach

Block or report user

Report or block hrach

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hrach
hrach / share.kt
Last active Dec 4, 2019
Flow<T>.share() operator - caches the latest value
View share.kt
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.*
import java.util.concurrent.atomic.AtomicInteger
fun <T> Flow<T>.share(): Flow<T> {
val channel = ConflatedBroadcastChannel<T>()
val counter = AtomicInteger()
var job: Job? = null
return channel
@hrach
hrach / channel.kt
Last active Jan 29, 2020
Kotlin Channels Debounce & Throttle
View channel.kt
import kotlinx.coroutines.experimental.*
import kotlinx.coroutines.experimental.channels.ReceiveChannel
import kotlinx.coroutines.experimental.channels.consumeEach
import kotlinx.coroutines.experimental.channels.produce
import kotlin.coroutines.experimental.CoroutineContext
fun <E> ReceiveChannel<E>.debounce(
wait: Long = 50,
context: CoroutineContext = DefaultDispatcher
): ReceiveChannel<E> = produce(context) {
View .gitconfig
[user]
useconfigonly = true
email = ...
name = ...
[core]
excludesfile = ~/.gitignore_global
fscache = true
editor = 'C:/Soft_x86/NPP/notepad++.exe' -multiInst -notabbar -nosession -noPlugin
autocrlf = Input
[color]
@hrach
hrach / AdminerColors.php
Last active Apr 5, 2017
Adminer coloring for easy prod/dev recognition
View AdminerColors.php
<?php
class AdminerColors
{
function head()
{
static $colors = [
'alpha-adminer.example.com' => '#3C8DBC',
'prod-adminer.example.com' => '#DD4B39',
];
@hrach
hrach / style.css
Last active Nov 28, 2016
Custom Style for latest Build Monitor for Jenkins
View style.css
.build-monitor header .details {
display: none;
}
.build-monitor .slots {
position: absolute;
left: 0;
right: 0;
top: 0;
-webkit-flex: none;
flex: none;
@hrach
hrach / add_pull_request_to_issue_github.sh
Created Jun 6, 2016 — forked from JanTvrdik/add_pull_request_to_issue_github.sh
Add pull request to existing issue on github
View add_pull_request_to_issue_github.sh
#!/bin/bash
current_branch="$(git symbolic-ref HEAD 2>/dev/null)" || current_branch="(unknown)"
current_branch=${current_branch##refs/heads/}
github_username="JanTvrdik"
github_token="..."
if [[ $current_branch = "(unknown)" ]]
then
@hrach
hrach / style.css
Created Feb 26, 2016
Custom style for CircleCI
View style.css
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("circleci.com") {
.app-dominant {
background: #FFF;
}
.card {
border: 2px solid #ccc;
border-radius: 4px;
}
@hrach
hrach / preparation.md
Created Jan 4, 2016 — forked from wodCZ/force-http.tpl
vestacp cert letsencrypt
View preparation.md
# init & renew
# replace ikw.cz with domain AND admin with vesta user
letsencrypt certonly \
--authenticator webroot \
--renew-by-default \
--agree-tos \
--webroot-path /home/admin/web/ikw.cz/public_html \
--domains ikw.cz,www.ikw.cz
@hrach
hrach / config.neon
Created Dec 8, 2015
neon + aws sdk + guzzle + kdyby curl ca bundle
View config.neon
- Aws\Sdk({
credentials: {
key: %s3.key%,
secret: %s3.secret%,
},
version: latest,
region: 'eu-west-1',
http_handler: @Aws\Handler\GuzzleV6\GuzzleHandler,
})
- Aws\Handler\GuzzleV6\GuzzleHandler
@hrach
hrach / BaseMapper.php
Last active Aug 29, 2015
Orm: select entity for update
View BaseMapper.php
<?php
use Nextras\Orm\Collection\ICollection;
use Nextras\Orm\Entity\IEntity;
use Nextras\Orm\Mapper\Dbal\Mapper;
use Nextras\Orm\Mapper\Dbal\DbalCollection;
class BaseMapper extends Mapper
{
You can’t perform that action at this time.