Skip to content

Instantly share code, notes, and snippets.

View 20chan's full-sized avatar
๐ŸŽธ
rockin'

20chan 20chan

๐ŸŽธ
rockin'
View GitHub Profile
@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'))
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:

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:

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());
}
@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]);
@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 / contract.py
Created July 3, 2017 06:25
The Fun of Reinvention ์ตœ์ข…
_contracts = {}
class Contract:
@classmethod
def __init_subclass__(cls):
_contracts[cls.__name__] = cls
def __set__(self, instance, value):
self.check(value)
@20chan
20chan / ImageFlatten.py
Created July 8, 2017 15:56
Bitmap ์„ Flattenํ•˜๊ฒŒ ๋งŒ๋“ค์–ด์„œ 1์ฐจ์› ๋ฐฐ์—ด๋กœ ๋งŒ๋“ค์–ด๋ฒ„๋ฆฌ๊ธฐ
Bitmap b = new Bitmap(@"D:\Image\design\์น˜์›Œ\ํžˆ์˜ค์Šค.png");
var bitmapData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, b.PixelFormat);
var length = bitmapData.Stride * bitmapData.Height;
byte[] bytes = new byte[length];
// Copy bitmap to byte[]
Marshal.Copy(bitmapData.Scan0, bytes, 0, length);
b.UnlockBits(bitmapData);
@20chan
20chan / Flatten.cs
Last active July 8, 2017 16:19
์ด๋ฏธ์ง€๋ฅผ Flattenํ•œ ๋ฐฐ์—ด๋กœ ๊ฐ€์ ธ์˜ฌ ๋•Œ ์†๋„ ๋น„๊ต
static Bitmap b;
static void Main(string[] args)
{
var methods = typeof(Program).GetMethods(BindingFlags.Static | BindingFlags.NonPublic);
foreach (var method in methods)
{
if (method.GetCustomAttribute<GetRuntime>() != null)
{
int range = 10;
DateTime before = DateTime.Now;
@20chan
20chan / ๊ตฌ์ƒ.md
Created August 1, 2017 07:09
๋งŒ๋“ค๊ณ  ์‹ถ์€ ์—ด์ฐจ ๊ฒŒ์ž„ ๊ตฌ์ƒ

๊ธฐ์ฐจ ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ

Train Simulator๋Š” 1์ธ์นญ ๊ธฐ์ฐจ ์šด์ „์— ์ค‘์ ์„ ๋‘๊ณ  ์žˆ๊ณ , ๋ฏธ๋‹ˆ ๋ฉ”ํŠธ๋กœ๋Š” ๋…ธ์„  ๋””์ž์ธ์— ์ค‘์ ์„ ๋‘๊ณ  ์žˆ์Œ.

https://www.youtube.com/watch?v=VzIQuzoMlqk ๊ฐ™์€ ์˜์ƒ์„ ๋ณด๋ฉด ๋Š๋‚„ ์ˆ˜ ์žˆ๋Š” ์พŒ๊ฐ์„ ์ œ์ž‘/์‹œ๋ฎฌ ๋‘˜์—์„œ ๋†“์น˜์ง€ ์•Š๊ฒŒ ๋Š๋‚„ ์ˆ˜ ์žˆ๋„๋ก ํ•˜๊ณ  ์‹ถ์Œ.


๊ฒŒ์ž„ ๋ฐฉ์‹