Skip to content

Instantly share code, notes, and snippets.

View iKlotho's full-sized avatar
🏠
Working from home

Umut Kahriman iKlotho

🏠
Working from home
  • İstanbul, Turkey
View GitHub Profile
@iKlotho
iKlotho / .pre-commit-config.yaml
Created March 6, 2023 15:17
pre-commit python
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-ast
- id: check-builtin-literals
- id: check-docstring-first
- id: check-merge-conflict
- id: check-yaml
- id: check-toml
@iKlotho
iKlotho / lengthreader.go
Last active February 24, 2023 11:49
Go JSON Decoder Access Size With Custom Reader
type LengthReader struct {
io.Reader
Length int
}
func (cw *LengthReader) Read(p []byte) (n int, err error) {
n, err = cw.Reader.Read(p)
cw.Length += n
return n, err
}
@iKlotho
iKlotho / split_chunks.py
Last active March 21, 2022 14:37
split given list to chunks most equally
def chunk_generator(chunks):
for chunk in chunks:
yield chunk
def split_to_chunks(paginate_list, chunk_size):
"""
It converts given list to mostly
equal sized arrays
@iKlotho
iKlotho / task.json
Created July 9, 2021 12:52
VSCODE Python Package Dev- Task
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build package",
"command": "${config:python.pythonPath} setup.py sdist",
"type": "shell",
"group": {
@iKlotho
iKlotho / blog_django_code.py
Created May 8, 2021 22:32
Using Django post_migrate signal
######################################
############# models.py ##############
######################################
from architect.commands import partition
from django.db import ProgrammingError
def create_partitions(sender, **kwargs):
"""
After running migrations, go through each of the models
@iKlotho
iKlotho / fishsetup.sh
Created January 8, 2021 22:39
FISH shell gotchas
# make sure the install lts
set -g -x EDITOR vim
# edit the config
# starship init fish | source
vim ~/.config/fish/config.fish
# when installing virtualfish make sure python exists
# add .local/bin to path if not exists
# virtual env exists at ~/.virtualenvs
@iKlotho
iKlotho / fs_answer_random.xml
Created December 23, 2020 21:05
fs_answer_random.xml
<extension name="DTMF_TEST">
<condition break="never">
<action application="set" data="rand_val=${expr(randomize(&x);ceil(random(1,4,&x)))}" inline="true"/>
<action application="log" data="INFO Random value is ${rand_val}"/>
</condition>
<!-- answer randomly -->
<condition field="${cond(${rand_val} > 2 ? YES : NO)}" expression="^YES$" inline="true">
<action application="set" data="rand_resp=${expr(randomize(&x);ceil(random(1,5,&x)))}"/>
<action application="sleep" data="100" />
<action application="start_dtmf" />
@iKlotho
iKlotho / definition.c
Created November 21, 2020 17:33
create
typedef struct __TABLE_UPC_SKILL
{
uint32_t dwID; // SKILL 고유 ID
std::string szEngName; // 스킬 영어 이름
std::string szName; // 스킬 한글 이름
std::string szDesc; // 스킬 이름
int iSelfAnimID1; // 시전자 동작시작
int iSelfAnimID2; // 시전자 동작끝
int idwTargetAnimID; // 타겟 동작
@iKlotho
iKlotho / dump.sh
Last active November 21, 2023 19:35
PostgreSQL Dump [Docker]
# dump from docker
docker exec dbname dockerinstance -d postgres -Fc -U postgres > dump.sql
# finding dump encoding
file dump.sql
# Output> dump.sql: Little-endian UTF-16 Unicode text, with very long lines, with CRLF line terminators
# convert it to utf-8
iconv -f utf-16 -t utf-8 dumb.sql > dumb-utf8.sql