Skip to content

Instantly share code, notes, and snippets.

View wickedev's full-sized avatar

Jeong-Yun Ryan Yang wickedev

  • Greenlabs
  • Anyang si, South Korea
View GitHub Profile
@wickedev
wickedev / CoroutineTests.kt
Last active August 14, 2023 19:46
CoroutineTests
package com.example.coroutine
import io.kotest.core.spec.style.DescribeSpec
import io.kotest.matchers.shouldBe
import kotlinx.coroutines.*
import kotlinx.coroutines.reactive.awaitFirstOrNull
import kotlinx.coroutines.reactor.mono
import org.jooq.DSLContext
import org.jooq.impl.DSL
import kotlin.coroutines.CoroutineContext
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.20796161890029907</real>
#!/bin/bash
EXTERNAL_IP=$(dig +short myip.opendns.com @resolver1.opendns.com)
curl -sfL https://get.k3s.io | sh -s - \
--disable=traefik \
--no-deploy=traefik \
--write-kubeconfig-mode=644 \
--tls-san=${EXTERNAL_IP}
@wickedev
wickedev / apollo-client.ts
Last active November 18, 2023 22:46
GraphQL(apollo) relative path setup
import { ApolloClient, ApolloLink, HttpLink, InMemoryCache, split } from '@apollo/client'
import { WebSocketLink } from '@apollo/client/link/ws'
const httpLink = new HttpLink({
uri: '/graphql',
})
const wsLink = new WebSocketLink({
uri: `${getWebsocketURI()}/subscriptions`,
options: {
@wickedev
wickedev / react-app-env.d.ts
Last active July 26, 2021 11:13
react-router generic Location hack
/// <reference types="react-scripts" />
declare module 'react-router' {
import type { Location, State } from 'history'
export type * from 'react-router'
export declare function useLocation<S extends State = State>(): Location<S>
}
@wickedev
wickedev / App.tsx
Last active July 19, 2021 02:33
valtio sample
import React from "react";
import { proxy, useSnapshot } from "valtio";
class Store {
public counter = 0;
public text = "";
get double() {
return this.counter * 2;
}
@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 {