Skip to content

Instantly share code, notes, and snippets.

@colrichie
colrichie / parsrc.sh
Last active September 14, 2017 09:00
[MOVED] CSV & JSON & XML file scraping tools
#! /bin/sh
#
# parsrc.sh
# CSV(Excel形式(RFC 4180):ダブルクォーテーションのエスケープは"")から
# 行番号列番号インデックス付き値(line field indexed value)テキストへの正規化
# (例)
# aaa,"b""bb","c
# cc",d d
# "f,f"
# ↓
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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>