Skip to content

Instantly share code, notes, and snippets.

@daejinseok
daejinseok / solution.py
Created August 29, 2022 15:39
코딩테스트 연습 2022 KAKAO TECH INTERNSHIP 코딩 테스트 공부
# https://school.programmers.co.kr/learn/courses/30/lessons/118668#qna
import math
def solution(alp, cop, problems):
# 필요 능력 구하기
alp_max = 0
cop_max = 0
@daejinseok
daejinseok / json_stringify.js
Created July 22, 2021 13:07
대충~~ json stringify 짠거 ie8버전용
//https://gist.github.com/andrew8088/6f53af9579266d5c62c8
function stringify2(obj){
var result = [];
var k
for(k in obj){
if(typeof obj[k] === 'object'){
result.push('"' + k + '":' + stringify2(obj[k]));
@daejinseok
daejinseok / datetime_example.py
Created July 20, 2021 08:54
python, datetime example
import datetime
datetime.datetime.today()
# datetime.datetime(2021, 7, 20, 17, 48, 37, 529267)
datetime.datetime(2021, 9, 3) - datetime.timedelta(days=30)
# datetime.datetime(2021, 8, 4, 0, 0)
datetime.datetime.today() - datetime.datetime(2021, 9, 3)
# datetime.timedelta(days=-45, seconds=64206, microseconds=234744)
@daejinseok
daejinseok / base64.ps1
Created June 17, 2021 01:37
binary 파일을 base64 파일로 변환하고 다시 binary파일로 변경
# encode from binary file to base64txt
$outpath = (Join-Path (pwd) 'out_base64.txt');
$inpath = (Join-Path (pwd) 'data.jpg');
[IO.File]::WriteAllText($outpath, ([convert]::ToBase64String(([IO.File]::ReadAllBytes($inpath)))))
# decode from base64txt to binary file
$outpath = (Join-Path (pwd) 'outdata2.jpg');
$inpath = (Join-Path (pwd) 'out_base64.txt');
[IO.File]::WriteAllBytes($outpath, ([convert]::FromBase64String(([IO.File]::ReadAllText($inpath)))))
@daejinseok
daejinseok / file_rename_and_run.py
Created June 13, 2021 05:39
파일 확장자를 변경하고, cli 실행 하기
import os
import glob
for l in glob.glob('*.webm'):
fname, ext = os.path.splitext(l.strip())
cli = f'ffmpeg -i "{l}" "{fname}.mp4"'
os.system(cli)
function makeHashCount( arr ){
const m = new Map();
arr.forEach( k => {
m.set(k, (m.get(k)||0) + 1 );
})
return m;
}
@daejinseok
daejinseok / re.py
Created June 16, 2020 13:24
python 정규식 split, sub
a = "daejin dae aaa"
import re
re.split(' +', a)
['daejin', 'dae', 'aaa']
b = "daejin aaa # daejidna;kdj"
re.sub('#.*$', '', b)
'daejin aaa '
@daejinseok
daejinseok / rename.py
Created January 1, 2019 12:15
파일 이름 변경
import glob
import os
l = glob.glob('*.jpg')
for nm in l :
print(nm[:26], '{:04d}'.format(int(nm[26:-4])), '.jpg')
os.rename(nm, nm[:26]+'{:04d}'.format(int(nm[26:-4]))+'.jpg')
@daejinseok
daejinseok / pycon_kr_2018_download.bat
Last active November 10, 2018 05:39
PyCon KR 2018 영상 다운 받기
# pip install youtube-dl
# 해서 youtube-dl 설치하시고
#import subprocess
#def dn(i):
# u = r'https://www.youtube.com/watch?v=UOunv9V14cA&list=PLZPhyNeJvHRmnMr5yucZ9Eu-yVhjRRsOM&index='
# subprocess.call('youtube-dl ' + u+str(i))
#[ dn(x) for x in range(1,73)]
@daejinseok
daejinseok / gist:57357a5419e8a7f60f7d36ccfc6a0a5a
Created August 23, 2018 13:31
offline에서 pip사용하기
일단 인터넷이 되는 곳
mkdir openpyxl & cd openpyxl
pip download openpyxl
해당 폴더에 아래와 같은 압축파일 몇개가 생긴다.
et_xmlfile-1.0.1.tar.gz
jdcal-1.4-py2.py3-none-any.whl