This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN { | |
FS="|" | |
} | |
{ | |
for( i=1; i<=NF; i++ ) { | |
printf( "\"" $i "\"" ",") | |
} | |
printf("\n") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Crypto do | |
def md5(s) do | |
list_to_binary(Enum.map(bitstring_to_list(:crypto.md5(s)), fn(x) -> integer_to_binary(x, 16) end)) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Crypto do | |
def gethash(typ, s) do | |
list_to_binary(Enum.map(bitstring_to_list(:crypto.hash(typ, s)), fn(x) -> integer_to_binary(x, 16) end)) | |
end | |
def sha1(s), do: gethash(:sha, s) | |
def md5(s), do: gethash(:md5, s) | |
def sha256(s), do: gethash(:sha256, s) | |
def sha512(s), do: gethash(:sha512, s) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
QUALITY=50 | |
SIZE=120 | |
OUTPUT='thumbnail/'${1%.*}'thumb.jpg' | |
convert -define jpeg:size=${SIZE} -quality ${QUALITY} -thumbnail ${SIZE} ${1} ${OUTPUT} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _justify_list(list1, list2): | |
"""短いほうのリストに空要素を追加して、リストの長さをそろえる""" | |
short_list = min(list1, list2, key=len) | |
c = max(len(list1), len(list2)) - len(short_list) | |
for i in range(0, c): | |
short_list.append('') | |
return list1, list2 | |
def _join_str_list(parent_list, child_list, margin): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eto = ['申', '酉', '戌', '亥', '子', '丑', '寅', '卯', '辰', '巳', '午', '未'] | |
print('年を入力') | |
y = int(input()) | |
print('干支は{eto}'.format(eto[y%len(eto)])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_digest(s): | |
import hashlib | |
m = hashlib.md5() | |
m.update(s.encode()) | |
return m.hexdigest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_timestamp(): | |
from datetime import datetime | |
return datetime.now().strftime('%Y-%m-%d %H:%M') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*-coding:utf-8-*- | |
from datetime import datetime as dt | |
def make_time_table(raw_time_table): | |
"""入力された文字から、時間のリストを使って返します""" | |
ret = list() | |
# 1文字目は無意味なので読み捨てます | |
lst = raw_time_table.split(' ')[1:] | |
# 2要素ずつ取り出して、時間データとして確保します |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Convert DM->second | |
(defun dm-to-sec (x) | |
(* (/ x 100.0) 60.0)) | |
;; Convert DM->minutes | |
(defun dm-to-min (x) | |
(/ x 100.0)) | |
;; Convert second->minutes | |
(defun sec-to-min (x) | |
(/ x 60.0)) | |
;; second->minutes convert with m:s.# style format |
OlderNewer