Skip to content

Instantly share code, notes, and snippets.


Hiroki Kiyohara hirokiky

View GitHub Profile
import random
data = [
hirokiky /
Last active Feb 12, 2020
Just a scrap.
import re
import time
from pathlib import Path
from urllib.request import urlretrieve
from PIL import Image
ROOT_DIR = Path("path/to/repo")
PATH_GLOB = "**/*.md"
hirokiky / editor.vue
Created Aug 22, 2019
Quill Editor with Vue.js by using vue-quill-editor
View editor.vue
<quill-editor :content="value"
hirokiky / models.js
Last active Aug 12, 2019
Dataclass like utility.
View models.js
function makeModel (fields) {
return class BaseModel {
constructor(options) {
options = options || {}
var v;
for (var [key, value] of Object.entries(fields)) {
if (options.hasOwnProperty(key)) {
v = options[key]
} else {
hirokiky /
Created Jul 27, 2019



  • 飲食は可能です
    • キレイに使ってください
    • 食べこぼしの多そうなものは、なるべく避けてくれると嬉しいです
  • 電源はあります
    • 足りない場合は譲り合って使ってください
    • 私物のタップを使ってくれると助かります
hirokiky /
Last active Feb 22, 2019
Model (for validators, ORM, form library) by using dataclass
from dataclasses import dataclass, field as dc_field
# Library
def field(default, verbose_name="", help_text=""):
return dc_field(
View recursiveClass.js
> class F {
... constructor (a) {
..... if (a > 0) {
....... this.child = new F(a-1)
....... }
..... }
... }
> new F(3)
F { child: F { child: F { child: F {} } } }
hirokiky /
Created Apr 26, 2018
Detecting changes of model field values.
""" Detect changes of Django Models.
class ChangeDetector:
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._dirty_fields = {f: False for f in self._get_field_names()}
self._inited = True
hirokiky / custom.js
Created Mar 14, 2018
tried to inject Authorization header for each request, but couldn't.
View custom.js
// This way didn't work.
// Cause this custom.js or nbextensions files will be loaded after initializing JupyterNotebookApp.
// It means this code won't affect to it's initializing Ajax requests.
// Sending token on each XHRs too.
// Because Safari won't handle Cookie and localStorage
// on iframes.
// Jupyter Client expects it's cookie, so it will be forbidden
// Instead, sending "token" by manually on each XHRs.
hirokiky / plt.ipynb
Last active Dec 27, 2017
Importing matplotlib.pyplot and calling show() method won't work properly. Originally reported by @SaitoTsutomu
View plt.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.