Skip to content

Instantly share code, notes, and snippets.

View enif-lee's full-sized avatar
😁

enif.lee enif-lee

😁
View GitHub Profile
@monosoul
monosoul / TracingUtils.kt
Created March 27, 2023 11:18
DataDog Tracing utils for Kotlin coroutines
import datadog.trace.api.DDTags
import io.opentracing.Span
import io.opentracing.Tracer
import io.opentracing.log.Fields
import io.opentracing.tag.Tags
import io.opentracing.util.GlobalTracer
suspend fun <T : Any, O> T.coRunTraced(
methodName: String,
block: suspend T.(Span) -> O,
@anandpathak
anandpathak / pg12_partman_dockerfile
Created October 26, 2021 12:38
docker file for postgres 12 with partman
FROM postgres:12
RUN apt-get update && \
apt-get install -y git make gcc
RUN git clone https://github.com/pgpartman/pg_partman
RUN cd pg_partman && make NO_BGW=1 install
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.channelFlow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
private suspend fun <T> getChunk(channel: Channel<T>, maxChunkSize: Int): List<T> {
// suspend until there's an element in the buffer
@seanh
seanh / bw-open
Last active April 15, 2025 00:48
Log in and unlock your Bitwarden vault (shell script)
#!/usr/bin/env sh
#
# Log in to and unlock Bitwarden CLI.
#
# If you save the returned session key in a BW_SESSION envvar that will unlock
# your Bitwarden vault for the current shell session. Once BW_SESSION has been
# set in one shell session it'll also be inherited by any commands or scripts
# run from that shell session.
#
# Usage (sh):
@jgould22
jgould22 / Dockerfile
Last active April 2, 2025 13:10
Postgres 15 - Alpine - pg_partman with pg_jobmon
FROM postgres:15-alpine
LABEL maintainer="Jordan Gould <[email protected]>"
# Based on https://github.com/andreaswachowski/docker-postgres/blob/master/initdb.sh
ENV PG_JOBMON_VERSION v1.4.1
ENV PG_PARTMAN_VERSION v4.7.1
# Install pg_jobmon
RUN set -ex \
\
@mp911de
mp911de / StatementBenchmarks.java
Created October 29, 2019 15:20
R2DBC Postgres benchmarks
/*
* Copyright 2019 the original author or authors.
*
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@shoark7
shoark7 / algorithm-sites.md
Last active February 10, 2025 02:30
개인적으둜 μ‚¬μš©ν–ˆλ˜ μ•Œκ³ λ¦¬μ¦˜ μ‚¬μ΄νŠΈλ“€μ„ μΆ”μ²œλ“œλ¦½λ‹ˆλ‹€.

μ•Œκ³ λ¦¬μ¦˜μ΄λΌκ³  많이 듀어보셨을 κ²λ‹ˆλ‹€. μ•Œκ³ λ¦¬μ¦˜μ€ κ΅κ³Όμ„œμ‹μœΌλ‘œ μ •μ˜ν•΄λ³΄λ©΄ '문제λ₯Ό ν•΄κ²°ν•˜λŠ” 일련의 절차'라고 ν•  수 μžˆλŠ”λ°μš”. μ»΄ν“¨ν„°λ‘œ μ–΄λ–€ 문제λ₯Ό ν•΄κ²°ν•΄μ•Ό ν•  λ•Œ, μ½”λ”©μœΌλ‘œ μ–΄λ–»κ²Œ 해결할지에 λŒ€ν•œ ꡬ체적인 방법을 μ΄μ•ΌκΈ°ν•©λ‹ˆλ‹€.

예λ₯Ό λ“€μ–΄, 숫자 배열을 μ •λ ¬ν•˜λŠ” λ¬Έμ œκ°€ μžˆλ‹€κ³  ν•©μ‹œλ‹€. 인간이 배열을 λŒ€μΆ© 보고 μ •λ ¬ν•˜κΈ°λŠ” μ‰½μ§€λ§Œ μ›μ†Œμ˜ κ°œμˆ˜κ°€ μˆ˜λ°±λ§Œκ°œμ— λ‹¬ν•˜λŠ” λ°°μ—΄μ—μ„œ μ»΄ν“¨ν„°μ—κ²Œ 일을 μ‹œμΌœμ„œ 컴퓨터가 μ •λ ¬ν•˜κ²Œ ν•˜λŠ” 것은 쉽지 μ•ŠμŠ΅λ‹ˆλ‹€. μ‹€μ œλ‘œ 정렬은 μ•Œκ³ λ¦¬μ¦˜μ—μ„œ 맀우 유λͺ…ν•˜κ³  기초적인 λΆ„μ•Όλ‘œ 정렬을 ν•˜λŠ” 방법, 즉 μ•Œκ³ λ¦¬μ¦˜μ΄ μ§€κΈˆκΉŒμ§€ μ•Œλ €μ§„ κ²ƒλ§Œ 해도 μˆ˜μ‹­κ°€μ§€κ°€ λ©λ‹ˆλ‹€.

μ•Œκ³ λ¦¬μ¦˜μ„ κ³΅λΆ€ν•˜λŠ” 것은 κ½€ 도움이 λ˜λŠ”λ°μš”. 일단 코딩을 μ‹œμž‘ν•˜μ‹œλŠ” λΆ„λ“€ μž…μž₯μ—μ„œλŠ” 코딩을 ν•˜κ²Œ λ˜μ„œ μ½”λ”©κ³Ό 문법에 μ΅μˆ™ν•΄μ§€λŠ” μž₯점이 있고, 또 개발자적 사고λ₯Ό ν•˜λŠ” 데 μ•Œκ³ λ¦¬μ¦˜ 문제λ₯Ό ν‘ΈλŠ” 것이 도움이 λ©λ‹ˆλ‹€. μ–΄λ–€ 개발 νšŒμ‚¬λ“€μ€ μ•Œκ³ λ¦¬μ¦˜ λŠ₯λ ₯을 ν…ŒμŠ€νŠΈν•˜κΈ° λ•Œλ¬Έμ— 취업을 λͺ©ν‘œλ‘œ κ³΅λΆ€ν•˜μ‹ λ‹€λ©΄ μ†ν•΄λŠ” 보지 μ•ŠμŠ΅λ‹ˆλ‹€.

μ €λŠ” μ•Œκ³ λ¦¬μ¦˜μ„ μ’‹μ•„ν•΄μ„œ μ‘°κΈˆμ”© ν’€μ–΄μ™”λŠ”λ°μš”. μ•Œκ³ λ¦¬μ¦˜μ„ ν’€ 수 μžˆλ„λ‘ 문제λ₯Ό λ‚΄μ£ΌλŠ” μ‚¬μ΄νŠΈλ“€μ΄ 정말 λ§ŽμŠ΅λ‹ˆλ‹€. μ˜€λŠ˜μ€ κ·Έμ€‘μ—μ„œ λͺ‡ κ°€μ§€λ§Œ μ†Œκ°œν•΄λ“œλ¦¬κ² μŠ΅λ‹ˆλ‹€. μ‚¬μ΄νŠΈλŠ” 정말 λ§Žμ€λ°μš”, κ·Έμ€‘μ—μ„œ μ œκ°€ μ΅œμ†Œ λͺ‡ λ²ˆμ΄λΌλ„ 써본 μ‚¬μ΄νŠΈλ“€λ§Œ μ†Œκ°œν•˜κ² μŠ΅λ‹ˆλ‹€. 더 쒋은 μ‚¬μ΄νŠΈλ“€μ΄ 있으면 μ†Œκ°œν•΄μ£Όμ‹œλ©΄ μΆ”κ°€ν•  수 μžˆμ„ 것 κ°™μŠ΅λ‹ˆλ‹€.


@rdarder
rdarder / optional.ts
Created December 28, 2015 19:51
Optional<T> a la Java in typescript
///<reference path="iterator.ts"/>
///<reference path="checks.ts"/>
import AbstractIterator = Iterators.AbstractIterator;
import Iterator = Iterators.Iterator;
import checkNotNull = Preconditions.checkNotNull;
abstract class Optional<T> {
static absent<T>():Optional<T> {
@michelsalib
michelsalib / deprecated.ts
Created April 23, 2015 13:17
Typescript @deprecated annotation
class Dog {
@deprecated('Dogs don\'t roar, they talk.')
roar() {
console.log('RRRRR');
}
@deprecated()
smile() {
console.log('smile');
}
@DingGGu
DingGGu / stream.js
Last active November 23, 2024 18:21
NodeJS Mp3 Streaming ExpressJS
var express = require('express');
var app = express();
var fs = require('fs');
app.listen(3000, function() {
console.log("[NodeJS] Application Listening on Port 3000");
});
app.get('/api/play/:key', function(req, res) {
var key = req.params.key;