Skip to content

Instantly share code, notes, and snippets.

@stripe-q
stripe-q / e005.py
Created June 19, 2017 11:52
최소공배수와 최대공약수
from lcd import lcd
from functools import reduce
def main():
n = reduce(lcd, range(1, 21))
print(n)
if __name__ == '__main__':
main()
@stripe-q
stripe-q / recent-docs-short.sh
Created October 20, 2016 11:36
최근 문서 찾기
#!/bin/zsh
read rcd # get root directory
find $rcd -type d -ctime +180 -prune -o -type f -name "*.ppt*" -print
@stripe-q
stripe-q / update-pip.sh
Created October 20, 2016 11:04
update all pip packages (shell)
#!/bin/bash
packs=($(pip list | awk '{ print $1 }'))
length=${#packs[@]}
num=1
for p in "${packs[@]}
do
echo "[$num / $length]: update package: $p"
pip install -U $p
num=$(( $num + 1 ))
@stripe-q
stripe-q / destruct.swift
Created July 13, 2016 12:51
Array의 원소들을 개별 변수로 분해하는 함수.
enum DesctructError: ErrorProtocol {
case outOfIndex(String)
}
func desctruct<A> (array: [A]) throws -> (A, A) {
guard array.count > 1 else {
throw DesctructError.outOfIndex("the array doesn't have enough elements.")
}
return (array[0], array[1])
}
@stripe-q
stripe-q / quickSort.swift
Created July 13, 2016 04:01
quicksort (inplace, swift3)
/*
46319725 를 정렬해본다.
46319725 : pivot = 4
> <
46319725
> < -> 교환! (교환후에는 무조건 1칸씩 전진한다)
26319745
@stripe-q
stripe-q / myAction0.hs
Last active May 24, 2016 09:45
myAction.hs -> n 을 입력받고, n 줄만큼의 문자열을 입력받아 이를 공백으로 연결하여 출력한다.
main = do
n <- readLn :: IO Int
a <- sequence . replicate n $ getLine
putStrLn . unwords $ a
-- do 가 아닌 모나드 연산자를 이용한 결합.
main' = (readLn :: IO Int) >>= (\n -> (sequence . replicate n $ getLine) >>= (\a -> puStrLn . unwords $ a))
private func perms <T>(pos: Int, _ arr:[T]) -> [T] {
let divmod: (Int, Int) -> (Int, Int)? = { a, b in
guard b != 0 else { return nil }
return (a / b, a % b)
}
let factorial: (Int) -> Int = { x in
if x < 2 { return nil }
return Array(2...x).reduce(1, combine: *)
}
@stripe-q
stripe-q / weather.ipynb
Created March 31, 2015 04:25
기상청 정보 파싱
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stripe-q
stripe-q / app.py
Last active August 29, 2015 14:17
섭씨화씨변환기(Qt) 2
import sys
from PyQt5.QtWidgets import QApplication, QWidget
from temperature_object import Ui_Form
class MyForm(QWidget):
def __init__(self):
super(MyForm2, self).__init__()
# UI 셋업 과정을 위해서는 Ui_Form 인스턴스를 만들고, setupUi를 호출해야 한다.
# 이 때 넘겨지는 인자는 자신 혹은 특정한 QWidget 인스턴스이다.
self.ui = Ui_Form()
@stripe-q
stripe-q / air2.py
Created March 17, 2015 10:47
지역별 미세먼지 지수
#!c:/python34/python.exe
#coding:utf-8
from urllib.request import urlopen
from bs4 import BeautifulSoup
from datetime import datetime
URL = "http://www.airkorea.or.kr/sido_compare_p01?itemCode=10007&ymd={}%2023&areaCode=031"
def make_datestamp():
now = datetime.now()