Skip to content

Instantly share code, notes, and snippets.

View wickedev's full-sized avatar

Jeong-Yun Ryan Yang wickedev

  • ProtoPie
  • Anyang si, South Korea
View GitHub Profile
@wickedev
wickedev / schema.graphql
Created July 8, 2021 16:03
typegraphql-prisma sample
type Query {
post(where: PostWhereUniqueInput!): Post
findFirstPost(
where: PostWhereInput
orderBy: [PostOrderByInput!]
cursor: PostWhereUniqueInput
take: Int
skip: Int
distinct: [PostScalarFieldEnum!]
): Post
@wickedev
wickedev / ServerWebExchangeMatcher.kt
Last active March 23, 2021 04:10
webflux reactor API vs webflux kotlin coroutine
// Before Coroutine
fun matches(exchange: ServerWebExchange): Mono<MatchResult> {
return Mono.just(exchange)
.map(ServerWebExchange::getRequest)
.map(ServerHttpRequest::getHeaders)
.filter { header -> header.containsKey(HttpHeaders.AUTHORIZATION)) }
.flatMap { MatchResult.match() }
.switchIfEmpty { MatchResult.notMatch() }
}
@wickedev
wickedev / pubsub.ts
Last active February 23, 2021 10:23
interface IPubSub<T> {
publish(value: T): void;
subscribe(subscriber: Subscriber<T>): Disposer;
}
type Subscriber<T> = (value: T): void;
type Disposer = () => void;
@wickedev
wickedev / DBContainer.kt
Last active February 12, 2021 07:13
testcontainer + spring-data-r2dbc + spek + kotlin coroutine
class DatabaseContainer(spek: LifecycleAware) {
private val connectionFactory = ConnectionFactories.get("r2dbc:tc:postgresql:///test?TC_IMAGE_TAG=13")
private val repositoryFactory by spek.memoized {
val operations = R2dbcEntityTemplate(connectionFactory)
R2dbcRepositoryFactory(operations)
}
fun create() {
runBlocking {
@wickedev
wickedev / fzftail.sh
Last active October 24, 2021 15:02
fzf + tail + nl
#!/bin/bash
tail -n +0 $1 \
| nl -ba \
| fzf --multi \
--ansi \
--no-sort \
--reverse \
--tac \
--preview 'sed -n "$(({n}-4)),$(({n}+6))p" '$1' | nl -v $(({n}-4)) -ba' \
@wickedev
wickedev / bitwise-config.test.ts
Last active December 16, 2020 02:06
Handling complex condition without if statements with bitwise operators and bit masks
/*
+--------------------------------+---------------+
| type | bitmask |
+--------------------------------+---------------+
| mode (light, dark) | 0b0100 |
| screen size (xs, sm, md, lg) | 0b0011 |
+--------------------------------+---------------+
*/
type Bits = number;
@wickedev
wickedev / Main.ktx
Last active December 16, 2021 05:09
kotlin extension language for type safe macro
import react.dom.*
import react.styled
import kotlinx.browser.document
import org.w3c.dom.Window
import io.grpc
import org.graphql
val greetStub = grpc.stub!("proto/greeter.proto") // Type Inference & Code Generation from file contents
val Content = styled.div! {
#!/bin/bash
gitlab_ci () {
gitlab-runner exec docker "$1" \
--cache-dir=/tmp/gitlab-cache \
--docker-cache-dir=/tmp/gitlab-cache \
--docker-volumes=/tmp/gitlab-cache \
--docker-volumes="$PWD"/deploy:/deploy \
--env=DOCKER_CONFIG_JSON=/deploy/config.json \
--env=DEPLOY_KUBECONFIG=/deploy/kubeconfig \
#!/bin/bash
helm upgrade -i efk stable/elastic-stack -n kube-system \
--set elasticsearch.image.tag=6.7.0 \
--set kibana.image.tag=6.7.0 \
--set fluent-bit.backend.type=es \
--set fluent-bit.backend.es.host=efk-elasticsearch-client.kube-system.svc.cluster.local \
--set kibana.env.ELASTICSEARCH_HOSTS=http://efk-elasticsearch-client.kube-system.svc.cluster.local:9200 \
--set fluent-bit.enabled=true \
--set logstash.enabled=false
export function TodoView() {
const state = useState<State>(State.PENDING)
const handleCreateTask(e: React.SyntheticEvent) {
// TODO
}
return <div>
<ol>
{tasks.map((task) => <Task task={task} />)}