Skip to content

Instantly share code, notes, and snippets.

@colrichie
colrichie / getsunrise.sh
Last active April 25, 2020 15:08
郵便番号に基づき、WebAPI叩いて、日の出・日の入時刻を返すコマンド
#! /bin/sh
#######################################################################
#
# 日の出・日の入時刻検索コマンド GETSUNRISE.SH
#
# [概要]
# ・第1引数に郵便番号(必須,7桁)、第2引数に日付(任意,8桁)を与えると
# WebAPIを叩きに行って、その地域、その日の日の出&日の入り時刻を返すよ。
#
@colrichie
colrichie / sessionf
Last active August 29, 2015 13:56
SESSIONF - Session File Manager (useful for CGI scripts)
#! /bin/sh
######################################################################
#
# SESSIONF - Session File Manager (useful for CGI scripts)
#
# USAGE: sessionf <subcommand> [argument] ...
#
# * List of Subcommands:
# create ..... $0 create at=<template_path>
@colrichie
colrichie / mkcookie
Last active August 29, 2015 13:56
MKCOOKIE - HTTP Cookie String Generator
#! /bin/sh
######################################################################
#
# MKCOOKIE - HTTP Cookie String Generator
#
# USAGE: mkcookie [options] [<name>=<value>]
#
# * <name>=<value> : Cookie varriable name and value
# * OPTIONS:
@colrichie
colrichie / utconv
Last active August 29, 2015 13:55
UTCONV - UNIX time and Real DateTime Converter
#! /bin/sh
######################################################################
#
# UTCONV - UNIX time and Real DateTime Converter
#
# USAGE: utconv [datetime_text_or_file] # for Real-datetime -> Unixtime
# utconv -r [unixtime_text_or_file] # for Unixtime -> Real-datetime
#
# * utconv reads stdin when <datetime_text_or_file> is not given.
@colrichie
colrichie / exflock
Last active February 20, 2022 01:46
EXFLOCK - A file lock command that you can use like flock(2)
#! /bin/sh
######################################################################
#
# EXFLOCK : A file lock command that you can use like flock(2)
#
# Usage : exflock <seconds> <file> [maxlifetime]
# <seconds> ...... maximum waiting time to succeed locking
# <file> ......... the path of the file you want to lock
# [maxlifetime] .. the maximum life of the locking process (sec)
@colrichie
colrichie / gzpipe
Last active December 28, 2015 01:09
GZPIPE - Making a named pipe behave as a gzipping filter
#! /bin/sh
######################################################################
#
# GZPIPE - Making a named pipe behave as a gzipping filter
#
# USAGE: gzpipe [-t timeout] <named_pipe_to_use> [output_file]
#
# 1) create the named pipe <named_pipe_to_use> when unexists
# 2) read stream data from the named pipe
@colrichie
colrichie / mkstemp
Last active December 27, 2015 20:19
MKSTEMP - A wrapper of mktemp(1) to behave as a equivalent of mkstemp(1)
#! /bin/sh
######################################################################
#
# MKSTEMP : A wrapper of mktemp(1) to behave as a equivalent of mkstemp(1)
#
# Written by Rich Mikan (richmikan[at]richlab.org) at 2013/11/09
#
# Usage : mkstemp [mktemp(1)options] <template>
#
@colrichie
colrichie / apalognorm
Last active February 23, 2020 01:56
APALOGNORM is a normalizer for logs of the Apache combined format.For example, the following command give you the referer field.$ apalognorm http-access.log | awk '{print $8}'
#! /bin/sh
######################################################################
#
# APALOGNORM : a normalizer for logs of the Apache combined format
#
# Written by Rich Mikan (richmikan[at]richlab.org) at 2014/01/04
#
# Usage : apalognorm [-s string] <logfile>
# <logfile> should be written with Apache combine format.
@colrichie
colrichie / fsed
Last active May 19, 2021 17:41
FSED : flexible sed (looks like the fgrep)
#! /bin/sh
######################################################################
#
# FSED : flexible sed (looks like the fgrep)
#
# Written by Rich Mikan (richmikan[at]richlab.org) at 2014/04/08
#
# Usage : fsed <pattern_str> <substitute_str> <file>
#
@colrichie
colrichie / yamanote_quine.rb.sh
Created August 25, 2012 10:55
Yamanote Quine
#! /bin/sh
# This source code should be viewed and run with
# more than 58 chars width and more than 100 lines height.
# 10 20 30 40 50
# -------+---------+---------+---------+---------+-------|
#
# The original code is exposed at
# http://www.slideshare.net/mametter/ruby-2012