Skip to content

Instantly share code, notes, and snippets.

View aciddust's full-sized avatar
:shipit:
Ram-G Thunder

Seongchuel Ahn aciddust

:shipit:
Ram-G Thunder
  • Seoul, Korea, Republic of
  • 05:38 (UTC +09:00)
View GitHub Profile
@aciddust
aciddust / main.py
Created July 11, 2022 06:06
generate secret key
def generate_secret_key():
from random import choices
from string import ascii_letters, digits
return "".join(choices(ascii_letters + digits, k=64))
if __name__ == "__main__":
generate_secret_key()
@aciddust
aciddust / README.md
Last active July 10, 2022 05:22
Python Multiprocess w/ ray

Python Multiprocess w/ Ray

Without Ray

image

Each iteration takes the same amount of time.

With Ray

apiVersion: v1
kind: ConfigMap
metadata:
name: redis-config
data:
redis.conf: |
# Redis configuration file example.
#
# Note that in order to read the configuration file, Redis must be
# started with the file path as first argument:
@aciddust
aciddust / Readme.md
Created June 30, 2022 05:05
Draw parabola
python main.py
Enter x velocity: 62.4
Enter y velocity: 120.5

image

@aciddust
aciddust / .zshrc
Last active July 23, 2022 11:30
Gooroom OS initial script, personal
# >>> java
export JAVA_HOME_8=$(/usr/libexec/java_home -v8)
export JAVA_HOME=$JAVA_HOME_8
# <<< java
@aciddust
aciddust / main.py
Created May 19, 2022 16:39
Get median
def get_median(arr):
arr.sort()
center = len(arr)//2
return (arr[center] + arr[-center - 1]) // 2
@aciddust
aciddust / README.md
Created May 16, 2022 09:17
Go call by value VS. call by ref

Call by [Value VS. Ref] in GO-lang

❯ go test ./test -bench=.
goos: darwin
goarch: amd64
pkg: promo-tables/test
cpu: VirtualApple @ 2.50GHz
BenchmarkFunctionA-10             424899              2735 ns/op
BenchmarkFunctionB-10 430348 2758 ns/op
@aciddust
aciddust / untitled.sql
Created April 29, 2022 07:50
Alter MySQL table's auto increment
-- Check auto increment
SELECT
table_name, auto_increment
FROM
information_schema.tables
WHERE
table_schema = 'YOUR_SCHEMA_NAME' AND auto_increment IS NOT NULL;
-- Alter auto increment
ALTER TABLE schema_name.table_name MODIFY id BIGINT NOT NULL AUTO_INCREMENT;
@aciddust
aciddust / README.md
Last active January 18, 2023 06:01
memory re-allocation when put element into dynamic array in Go w/ Python

Memory re-allocation when using dynamic array in Go w/ Python

memory reallocation (or doubling) when put element into dynamic array

동적 배열은 미리 초깃값을 작게 잡아 배열을 생성하고
데이터가 추가되어 배열이 꽉 찰 때마다, 배열의 크기를 늘려주고 값을 모두 복사하는 방식으로 구현됩니다.
이때, 배열의 크기를 늘려나가는 배율을 '그로스 팩터(Growth Factor, 성장 인자)'라고 함.
대개는 더블링(Doubling)이라 하여 그로스 팩터를 2로 한다.
(각 언어마다 늘려가는 비율은 상이하다.)

@aciddust
aciddust / main.go
Last active April 20, 2022 14:28
raw subquery builder
func SubQueryRawJoin(subQuery, aliasOfSubQuery, tableName, tableNameAlias string, filters []string, joinSet map[string][][]string, orderByInfo map[string][]string) string {
filter := "*"
if len(filters) > 0 {
filters = func() []string {
var result []string
for _, f := range filters {
if len(strings.Split(f, ".")) < 2 {
f = fmt.Sprintf("%s.%s", tableNameAlias, f)
}
result = append(result, f)