Skip to content

Instantly share code, notes, and snippets.

@t-miya
t-miya / Amazonlinux.docker
Created October 3, 2017 08:35
AWS Lambda 用に pip でモジュールを用意するための Dockerfile
FROM amazonlinux:2017.03
RUN true\
&& yum -q -e 0 -y update || true\
&& yum -q -e 0 -y install gcc python27-devel python27-pip || true\
&& pip install --upgrade pip || true\
&& pip install wheel || true\
&& yum -q -e 0 -y clean all
CMD [""]
@t-miya
t-miya / convertMapToStr.go
Created September 4, 2017 13:31
Json データ を interface{} でパース後, 再び文字列に戻す際のパーサー
import (
"log"
"reflect"
"strconv"
)
func convertMapToStr(jsonData interface{}) string {
l := []string{}
for key, val := range jsonData.(map[interface{}]interface{}) {
switch reflect.ValueOf(val).Kind() {
@t-miya
t-miya / revser_list.py
Created May 22, 2013 05:46
ループなしのリスト逆順化 再帰的に左右のペアとなるインデックス同士を入れ替える。 奇数長の場合は入れ替え先と元のインデックスが同値、 偶数長の場合はインデックスがリスト長の半分を超えた時点で終了 pythonの場合はスライスを使った方がスマートかもしれない
def rev(l, index=0):
dest = len(l)-index-1
if dest == index or index+1 > len(l)/2:
return l
tmp = l[index]
l[index] = l[dest]
l[dest] = tmp
return rev(l, index+1)
@t-miya
t-miya / calc_fib.py
Last active December 17, 2015 14:38
フィボナッチ数の求め方メモ fib1の方は二重再帰で効率が悪いので末尾再帰になっているfib2の方が良い
def fib1(n):
if n<3:
return 1
else:
return fib1(n-1) + fib1(n-2)
def fib2(n, fn1=1, fn=0):
if n<1:
return fn1
else:
@t-miya
t-miya / .vimrc
Created July 20, 2012 01:08
vimrc settings
set modeline
set nobackup
set incsearch
set smartcase
set showmatch
set encoding=utf-8
set fileencoding=utf-8
"----------------------------------------------------------
@t-miya
t-miya / QuickSortTest.java
Created April 1, 2012 15:13
クイックソートの勉強に組んでみました
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* クイックソートサンプル
*/
public class QuickSortTest
{
public static void main(String[] args)