Skip to content

Instantly share code, notes, and snippets.

View pistatium's full-sized avatar
🚲
Cycling

kimihiro_n pistatium

🚲
Cycling
View GitHub Profile
@pistatium
pistatium / exercise-equivalent-binary-tree.go
Last active January 28, 2016 02:53
Exercise: Equivalent Binary Trees
package main
import (
"fmt"
"golang.org/x/tour/tree"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
@pistatium
pistatium / layout.css
Created October 22, 2015 06:44
responsive image
.box1 {
width: 100px;
height: 200px;
}
.box2 {
width: 300px;
height: 500px;
}
div {
position: relative;
@pistatium
pistatium / request_checker.py
Last active September 29, 2015 03:04
リクエストされたHeaderとBodyを標準出力とレスポンスに書き出すスクリプト
# coding: utf-8
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def post(self):
print("Header---------")
print(self.request.headers)
@pistatium
pistatium / doze_memo.md
Created June 29, 2015 12:51
まったりAndroid Framework Code Reading #1 Memo

Android Doze

Dozeとは

センサーを利用して、ユーザーが端末を使っていない時にバッテリーの消費を抑える機能…らしい。

使い方

http://androidlover.net/android-os/android-m/android-m-how-to-use-doze-mode.html

  • アプリごとにDozeモードの有効・無効が切り替えられる
  • 有効なアプリに対しては通信やWifiスキャン等が抑えられる
  • デフォルトではGooglePlay開発者サービス等一部アプリ(サービス)をのぞいたすべてに対して有効になっている
@pistatium
pistatium / redis_cache_decorator.py
Created June 19, 2015 09:52
関数をRedisでキャッシュするためのデコレータ
# coding: utf-8
from __future__ import absolute_import, division, print_function
import pickle
import functools
import redis
@pistatium
pistatium / PolyArea.java
Last active August 29, 2015 14:11
多角形の面積を計算する的な
/**
* Copyright (c) 2014 pistatium
*
* This software is released under the MIT License.
*
* http://opensource.org/licenses/mit-license.php
*/
import java.util.*;
import java.lang.Math;
@pistatium
pistatium / MovableFooter.swift
Last active August 29, 2015 14:10
スクロールで浮き沈みする奴 Swift版
/**
* Copyright (c) 2014 pistatium
*
* This software is released under the MIT License.
*
* http://opensource.org/licenses/mit-license.php
*/
/*
* cf.
@pistatium
pistatium / file0.txt
Created September 24, 2014 10:47
サブクラスの要素だけを一覧で取得する ref: http://qiita.com/kimihiro_n/items/752be1203a3938f73316
class Base(object):
def getAttributeKeys(self):
""" Baseを継承したクラスで定義された
要素(メソッドやプロパティ)のキーだけを取得したい
"""
class Child(Base):
@pistatium
pistatium / default_eyecatch.php
Created September 18, 2014 03:00
[WP]アイキャッチの設定とデフォルト画像の登録
<?php
// アイキャッチの設定とデフォルト画像の登録
add_action('init', function() {
add_theme_support('post-thumbnails');
$filename = dirname(__FILE__) . "/img/no_image.png";
if (file_exists($filename)) {
$wp_upload_dir = wp_upload_dir();
$upload_path = $wp_upload_dir['path'];
@pistatium
pistatium / wt_form_bootstrap.html
Created August 20, 2014 09:29
WTForm with bootstrap
{% for field in form %}
<div class="form-group {{funcs["yesno"](field.errors,"has-error")}}">
<label for="{{field.label.field_id}}" class="col-sm-2 control-label">{{field.label.text}}</label>
<div class="col-sm-10">
{% raw field(class_="form-control") %}
{% if field.description %}
<span class="help-block">{{ field.description}}</span>
{% end %}
{% if field.errors %}
<span class="help-block">