Skip to content

Instantly share code, notes, and snippets.

View hrach's full-sized avatar

Jan Škrášek hrach

View GitHub Profile
@hrach
hrach / BaseMapper.php
Last active August 29, 2015 14:21
Orm: select entity for update
<?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
{
@hrach
hrach / config.neon
Created December 8, 2015 08:42
neon + aws sdk + guzzle + kdyby curl ca bundle
- 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 / preparation.md
Created January 4, 2016 23:07 — forked from wodCZ/force-http.tpl
vestacp cert letsencrypt
# 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 / style.css
Created February 26, 2016 11:44
Custom style for CircleCI
@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 / add_pull_request_to_issue_github.sh
Created June 6, 2016 19:25 — forked from JanTvrdik/add_pull_request_to_issue_github.sh
Add pull request to existing issue on github
#!/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
Last active November 28, 2016 11:46
Custom Style for latest Build Monitor for Jenkins
.build-monitor header .details {
display: none;
}
.build-monitor .slots {
position: absolute;
left: 0;
right: 0;
top: 0;
-webkit-flex: none;
flex: none;
@hrach
hrach / AdminerColors.php
Last active April 10, 2025 06:26
Adminer coloring for easy prod/dev recognition
<?php
class AdminerColors
{
function head()
{
static $colors = [
'alpha-adminer.example.com' => '#3C8DBC',
'prod-adminer.example.com' => '#DD4B39',
];
[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 / channel.kt
Last active May 24, 2021 08:52
Kotlin Channels Debounce & Throttle
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) {
@hrach
hrach / share.kt
Last active December 4, 2019 10:42
Flow<T>.share() operator - caches the latest value
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