Skip to content

Instantly share code, notes, and snippets.

@okisanjp
okisanjp / fibonacci_lrucache.py
Last active October 19, 2018 04:13
Python3.2 or higher lru_cacheで再帰をキャッシュ
# -*- coding: utf-8 -*-
#
# フィボナッチ数列 第30項を計算する関数に
# lru_cacheを使って関数の呼び出し回数を比較
#
from functools import lru_cache
exec_counter = 0
@okisanjp
okisanjp / awsbliing.py
Created December 5, 2017 08:20
python boto3で~/.aws/credentialsのprofileごとに請求額を取る
# coding:utf-8
from boto3.session import Session
import datetime
profiles = ['profile1', 'profile2']
for profile in profiles:
session = Session(profile_name=profile)
#!/bin/bash -u
echo "=============================================="
echo "Started : Create AMI for production Deploy"
echo "=============================================="
TAG_NAME='EC2_TAG_NAME_OF_INSTANCE'
echo "Target Instance : ${TAG_NAME}"
@okisanjp
okisanjp / gist:ed2fddcab43bc09041ef28a862979416
Created April 5, 2017 11:33
chatworkにリンクを共有するためのブックマークレット
javascript:(function() {var t = document.title;var l = location.href;prompt('chatwork link' ,'[info][title]' + t + '[/title]' + l + '[/info]');})();
@okisanjp
okisanjp / docker-compose.yml
Last active June 5, 2018 01:52
zabbix3.2 on docker memo : https://gist.github.com/take4/3ee5413649f193938c738d02cc6448eb#file-zabbix-docker-compose-yaml こちら参考にデータ永続化部分の汎用性を高めるためにボリュームを追加
version: '2'
services:
zabbix_db:
container_name: zabbix_db
image: mysql:5.7
command: mysqld --character-set-server=utf8 --collation-server=utf8_unicode_ci
volumes:
- zabbix_storage_db:/var/lib/mysql
- /etc/localtime:/etc/localtime:ro
ports:
@okisanjp
okisanjp / feedly_api_test.rb
Last active February 13, 2017 01:27
feedly apiにfeedlrでアクセスする例
# -*- coding: utf-8 -*-
require 'feedlr'
Feedlr.configure do |config|
config.oauth_access_token = 'TOKEN'
end
client = Feedlr::Client.new
# p client.methods.sort - Object.methods
@okisanjp
okisanjp / new_gist_file.js
Last active December 14, 2016 03:38
js.fizzbuzz.practice
console.clear();
for(var i = 1; i <= 100; i++){
console.log(
// confusing use of '!'
!(i % 15) && 'FizzBuzz' ||
!(i % 5) && 'Buzz' ||
!(i % 3) && 'Fizz' ||
i
);
}
@okisanjp
okisanjp / 0_reuse_code.js
Created December 13, 2016 07:51
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@okisanjp
okisanjp / gist:158bc0498f751259ecd1
Last active March 6, 2017 14:24
awscli + jqで開発マシンの/etc/hosts用出力
### プライベートIPの場合
$ aws ec2 describe-instances | jq -r '.Reservations[].Instances[] | .PrivateIpAddress + "\t" + .Tags[].Value'
192.0.2.1 aws1.example
192.0.2.2 aws2.example
192.0.2.3 aws3.example
192.0.2.4 aws4.example
192.0.2.5 aws5.example
192.0.2.6 aws6.example
192.0.2.7 aws7.example
@okisanjp
okisanjp / file0.txt
Created May 29, 2015 06:39
readで入力待ちの時、whileと組み合わせて想定文字以外のときにエラーを表示する ref: http://qiita.com/okisanjp/items/47698db1de28b5836ca5
echo -n "Are you sure you want to exit the server? [y/n] > "
while :
do
read INPUT
case "$INPUT" in
"y" ) kill $SERVER_PID
echo "Stopped WEBRick"
break ;;
"n" ) echo "Canceled."
break ;;