Skip to content

Instantly share code, notes, and snippets.

@hachibeeDI
hachibeeDI / debounced-action-call-middleware.js
Created April 28, 2017 08:53
debounced-action-call-middleware.js
import debounce from 'lodash.debounce';
export default function validationDebounceMiddlewareGenerator ({triggerActionTypes, validatorActionType, wait}) {
const createValidateActionDebounced = debounce(
dispatch => dispatch({type: validatorActionType}),
wait
);
@hachibeeDI
hachibeeDI / file0.txt
Last active November 1, 2016 13:11
Pythonで単語の数え上げとかするならCounterを使うと便利なはなし ref: http://qiita.com/hatchinee/items/a904c1f8d732a4686c9d
data = ['aaa', 'bbb', 'ccc', 'aaa', 'ddd']
word_and_counts = {}
for word in data:
if word_and_counts.has_key(word):
word_and_counts[word] += 1
else:
word_and_counts[word] = 1
for w, c in sorted(word_and_counts.iteritems(), key=lambda x: x[1], reverse=True):
@hachibeeDI
hachibeeDI / widget.styl
Created January 21, 2014 05:44
stylus mix-in for widgets
// require: npm install nib
@import 'nib/vendor'
support-for-ie = false // disable old browser support
topstand-triangle()
width: 0
height: 0
border-top: 25px solid bg-color
border-left: 20px solid transparent
@hachibeeDI
hachibeeDI / measure_heap.py
Created January 8, 2014 08:53
guppyでのヒープ測定をwithとかデコレータで出来るようにするスニペット
# -*- coding: utf-8 -*-
from __future__ import print_function
from guppy import hpy
class measure_heap(object):
'''
メモリ消費量を測定する。
@hachibeeDI
hachibeeDI / file0.js
Created January 7, 2014 10:51
押すと上にスルスルっと戻るJavaScriptモジュール ref: http://qiita.com/hatchinee/items/9e1ad803c4c57069ee39
var ns = (function(exports) {
var Raise = function constructor() {
this._init_handler = function(func) {
window.addEventListener('load', func);
};
};
Raise.prototype.register = function(id) {
var to_top = function(e) {
var scroll_top = document.documentElement.scrollTop || document.body.scrollTop;
@hachibeeDI
hachibeeDI / flexsidebar.html
Created December 17, 2013 11:06
サイドバーをよしなにするやつ。 li要素を消したりしてみてくれやす
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>aaaa</title>
<link rel="stylesheet" href="./main.css" type="text/css" media="screen" charset="utf-8">
</head>
<body>
<div id="container">
<div id="header">header</div>
@hachibeeDI
hachibeeDI / index.html
Created December 17, 2013 06:36
フォーカスがあたるとリセットされるinput。何もいじらなければ、直前の内容が保持される。 coffeeと、コンパイル後のjs両方を添付。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>aaaa</title>
<link rel="stylesheet" href="./css/main.css" type="text/css" media="screen" charset="utf-8">
</head>
<body>
<input type="text" class="reset_onfocus" placeholder="aaaaaaaaa">
<input type="text" class="reset_onfocus" placeholder="aaaaaaaab">
@hachibeeDI
hachibeeDI / go_wait.go
Created October 19, 2013 13:54
pattern of wait for goroutine finished
func routine(quit chan int) {
// do stuff
quit <- 1
}
func main() {
routineQuit := make(chan int)
go routine(routineQuit)
<-routineQuit // blocks until quit is written to
@hachibeeDI
hachibeeDI / client.go
Created September 24, 2013 14:16
echo server written by golang
package main
import (
"net"
"os"
)
const (
RECV_BUF_LEN = 1024
)
@hachibeeDI
hachibeeDI / Sample.scala
Created August 2, 2013 06:09
とりあえずleapのsampleの単純な置き換えのおいとく
import java.io.IOException
import com.leapmotion.leap._
import com.leapmotion.leap.Vector
import com.leapmotion.leap.Frame
;
import com.leapmotion.leap.Gesture.State
;