Skip to content

Instantly share code, notes, and snippets.

Avatar

Hiroki Kiyohara hirokiky

View GitHub Profile
View jaljal.py
import random
data = [
"分け目ぴっしー",
"背筋ぴーん",
"ワイシャツパリ",
"ネクタイギュッ",
"ネクタイピンパチ",
"背広ファッ",
@hirokiky
hirokiky / scrap.py
Last active Feb 12, 2020
Just a scrap.
View scrap.py
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
hirokiky / editor.vue
Created Aug 22, 2019
Quill Editor with Vue.js by using vue-quill-editor
View editor.vue
<template>
<quill-editor :content="value"
@change="onChange"
ref="myQuillEditor"
:options="editorOption"
@blur="onEditorBlur($event)"
@focus="onEditorFocus($event)"
@ready="onEditorReady($event)">
</quill-editor>
</template>
@hirokiky
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
hirokiky / python_jp_hackathon_guide.md
Created Jul 27, 2019
Python.jpもくもく会のガイドライン
View python_jp_hackathon_guide.md

会場のアナウンス

BeProud開催時

  • 飲食は可能です
    • キレイに使ってください
    • 食べこぼしの多そうなものは、なるべく避けてくれると嬉しいです
  • 電源はあります
    • 足りない場合は譲り合って使ってください
    • 私物のタップを使ってくれると助かります
@hirokiky
hirokiky / dataclass_model.py
Last active Feb 22, 2019
Model (for validators, ORM, form library) by using dataclass
View dataclass_model.py
from dataclasses import dataclass, field as dc_field
# Library
def field(default, verbose_name="", help_text=""):
return dc_field(
default=default,
metadata={
View recursiveClass.js
> class F {
... constructor (a) {
..... if (a > 0) {
....... this.child = new F(a-1)
....... }
..... }
... }
undefined
> new F(3)
F { child: F { child: F { child: F {} } } }
@hirokiky
hirokiky / dirtydecector.py
Created Apr 26, 2018
Detecting changes of model field values.
View dirtydecector.py
""" 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
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
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.