Skip to content

Instantly share code, notes, and snippets.

View 20chan's full-sized avatar
🎸
rockin'

20chan 20chan

🎸
rockin'
View GitHub Profile
@20chan
20chan / contract.py
Created July 2, 2017 13:50
The Fun Of Reinvention - Contract 중간 코드
class Contract:
@classmethod
def check(cls, value):
pass
class Typed(Contract):
@classmethod
def check(cls, value):
assert isinstance(value, cls.type), f'Expected {cls.type}'
@20chan
20chan / 2d_array.c
Created June 21, 2017 00:24
c가 배열 메모리를 어떻게 처리하는가 + 신태틱 슈거 테스트
#include<stdio.h>
int main()
{
int data[3][3];
data[0][0] = 0; data[0][1] = 1; data[0][2] = 2;
data[1][0] = 3; data[1][1] = 4; data[1][2] = 5;
data[2][0] = 6; data[2][1] = 7; data[2][2] = 8;
printf("%d", data[1][2]);
printf("%d", data[0][5]);
foreach (string device in System.IO.Directory.GetLogicalDrives())
{
System.IO.DriveInfo dr = new System.IO.DriveInfo(device);
if (dr.DriveType != System.IO.DriveType.Removable) continue;
Console.WriteLine(dr.RootDirectory.ToString());
}

Keybase proof

I hereby claim:

  • I am phillyai on github.
  • I am adnim (https://keybase.io/adnim) on keybase.
  • I have a public key ASBXmfd-p-s02xrOEM9MV70yLb8eXT-on3u-XHN36E_ykgo

To claim this, I am signing this object:

from danbooru import pages
from PIL import Image
import requests
from io import BytesIO
def get(size=(300, 300)) :
''':returns PIL.Image, 0~2 raiting level. 0 is safe, 1 is questionable, 2 is explicit.'''
p = pages(limit=100)
while True:
@20chan
20chan / crawler.py
Last active February 17, 2017 17:14
단부루 크롤링 후 사이즈 자동 변환
import json
import urllib.request
from typing import Generator
def pages(limit: int = 10, page: int = 1) -> Generator:
cur = page
while True:
url = 'https://danbooru.donmai.us/posts.json?limit={}&page={}'.format(limit, cur)
res = json.loads(urllib.request.urlopen(url).read().decode('utf-8'))