Skip to content

Instantly share code, notes, and snippets.

View hirokiky's full-sized avatar

Hiroki Kiyohara hirokiky

View GitHub Profile
@hirokiky
hirokiky / python_jp_hackathon_guide.md
Created July 27, 2019 02:56
Python.jpもくもく会のガイドライン

会場のアナウンス

BeProud開催時

  • 飲食は可能です
    • キレイに使ってください
    • 食べこぼしの多そうなものは、なるべく避けてくれると嬉しいです
  • 電源はあります
    • 足りない場合は譲り合って使ってください
  • 私物のタップを使ってくれると助かります
@hirokiky
hirokiky / cmindent.js
Last active April 19, 2019 13:39
A CodeMirror command to delete 4-space indent or charactor before.
/**
* > if foo:
* > | <= The cursor is here and hit delCharOrIndent command, it willbe
* > | <= here
*
* This command will delete at most 4 spaces before, if text before charactor is all spaces.
* If not on the case, this command will delete charactor as usual.
*/
(function(mod) {
@hirokiky
hirokiky / dataclass_model.py
Last active February 22, 2019 07:56
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(
default=default,
metadata={
@hirokiky
hirokiky / recursiveClass.js
Last active February 4, 2019 11:27
experiment
> 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 / README.md
Created October 13, 2015 01:35
Trying falcon for proxy server
@hirokiky
hirokiky / dirtydecector.py
Created April 26, 2018 05:44
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
hirokiky / autoBottom.js
Created June 17, 2016 05:46
Vue.js directive to scroll bottom when the applied value updated.
module.exports = function(Vue) {
Vue.directive('auto-bottom', {
update: function() {
this.el.scrollTop = this.el.scrollHeight;
}
})
};
@hirokiky
hirokiky / custom.js
Created March 14, 2018 03:46
tried to inject Authorization header for each request, but couldn't.
// 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 / fib.py
Created April 7, 2013 14:50
Getting fibonacci series using block-chain (https://github.com/podhmo/block-chain)
from block.chain import chain, MaybeF
def fib(ctx, x):
x.append(x[-2] + x[-1])
return x
print chain.chain.do(fib).do(fib).do(fib).do(fib).value(MaybeF(), [1, 1])
@hirokiky
hirokiky / plt.ipynb
Last active December 27, 2017 09:08
Importing matplotlib.pyplot and calling show() method won't work properly. Originally reported by @SaitoTsutomu
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.