Skip to content

Instantly share code, notes, and snippets.

View IanChen83's full-sized avatar

Ian Chen IanChen83

  • Taipei, Taiwan
View GitHub Profile
@IanChen83
IanChen83 / gdrive-download.py
Created March 22, 2018 11:12
A python script to download files from Google Drive
# https://stackoverflow.com/a/39225039/5540600
import requests
def download_file_from_google_drive(id, destination):
def get_confirm_token(response):
for key, value in response.cookies.items():
if key.startswith('download_warning'):
return value
@IanChen83
IanChen83 / mp.py
Created March 13, 2018 17:54 — forked from NelsonMinar/mp.py
multiprocessing Pool example
#!/usr/bin/env python2
"Demonstrate using multiprocessing.Pool()"
import multiprocessing, time, logging, os, random, signal, pprint, traceback
logging.basicConfig(level=logging.DEBUG)
_L = logging.getLogger()
class JobTimeoutException(Exception):
@IanChen83
IanChen83 / config.py
Last active March 11, 2018 08:37
A python class that handles configurations easily
__all__ = ('Config', )
class Config:
def __init__(self, **kwargs):
self._options = set()
for key, value in kwargs.items():
setattr(self, key, value)
@IanChen83
IanChen83 / my_class.py
Created November 19, 2017 15:22
Python class: the right way
class ArtisanalClass(object):
def __init__(self, a, b):
self.a = a
self.b = b
def __repr__(self):
return "ArtisanalClass(a={}, b={})".format(self.a, self.b)
def __eq__(self, other):
if other.__class__ is self.__class__:
@IanChen83
IanChen83 / hackmd_style.html
Last active July 30, 2017 07:06
HackMD style
<style type="text/css">
@import url(https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/styles/github-gist.min.css);
@import url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css);
@import url(//fonts.googleapis.com/earlyaccess/cwtexfangsong.css);
@import url(//fonts.googleapis.com/earlyaccess/notosanstc.css);
.markdown-body blockquote {
padding: 0 1em;
color: #777;
border-left: 0.25em solid #ddd;
}