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
@jgould22
jgould22 / Dockerfile
Last active June 19, 2024 18:52
Postgres 15 - Alpine - pg_partman with pg_jobmon
FROM postgres:15-alpine
LABEL maintainer="Jordan Gould <jordangould@gmail.com>"
# 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 April 27, 2024 16:31
개인적으로 사용했던 알고리즘 사이트들을 추천드립니다.

알고리즘이라고 많이 들어보셨을 겁니다. 알고리즘은 교과서식으로 정의해보면 '문제를 해결하는 일련의 절차'라고 할 수 있는데요. 컴퓨터로 어떤 문제를 해결해야 할 때, 코딩으로 어떻게 해결할지에 대한 구체적인 방법을 이야기합니다.

예를 들어, 숫자 배열을 정렬하는 문제가 있다고 합시다. 인간이 배열을 대충 보고 정렬하기는 쉽지만 원소의 개수가 수백만개에 달하는 배열에서 컴퓨터에게 일을 시켜서 컴퓨터가 정렬하게 하는 것은 쉽지 않습니다. 실제로 정렬은 알고리즘에서 매우 유명하고 기초적인 분야로 정렬을 하는 방법, 즉 알고리즘이 지금까지 알려진 것만 해도 수십가지가 됩니다.

알고리즘을 공부하는 것은 꽤 도움이 되는데요. 일단 코딩을 시작하시는 분들 입장에서는 코딩을 하게 되서 코딩과 문법에 익숙해지는 장점이 있고, 또 개발자적 사고를 하는 데 알고리즘 문제를 푸는 것이 도움이 됩니다. 어떤 개발 회사들은 알고리즘 능력을 테스트하기 때문에 취업을 목표로 공부하신다면 손해는 보지 않습니다.

저는 알고리즘을 좋아해서 조금씩 풀어왔는데요. 알고리즘을 풀 수 있도록 문제를 내주는 사이트들이 정말 많습니다. 오늘은 그중에서 몇 가지만 소개해드리겠습니다. 사이트는 정말 많은데요, 그중에서 제가 최소 몇 번이라도 써본 사이트들만 소개하겠습니다. 더 좋은 사이트들이 있으면 소개해주시면 추가할 수 있을 것 같습니다.


@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 June 5, 2024 11:26
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;
@scaryguy
scaryguy / change_primary_key.md
Last active July 6, 2024 02:45
How to change PRIMARY KEY of an existing PostgreSQL table?
-- Firstly, remove PRIMARY KEY attribute of former PRIMARY KEY
ALTER TABLE <table_name> DROP CONSTRAINT <table_name>_pkey;
-- Then change column name of  your PRIMARY KEY and PRIMARY KEY candidates properly.
ALTER TABLE <table_name> RENAME COLUMN <primary_key_candidate> TO id;