Skip to content

Instantly share code, notes, and snippets.

View kosho's full-sized avatar

Kosho Owa kosho

View GitHub Profile
@kosho
kosho / decode_rails_cookie.rb
Created May 7, 2015 00:43
Decode cookie generated by Ruby on Rails
@kosho
kosho / delete_picasa_albums.sh
Created May 7, 2015 00:47
Delete all Picasa albums created by the user
# Delete all Picasa albums created by the user
# Note: Autogenerated albums such as Auto Backup and Instant Upload can not be deleted
# Your Google Account to manage
GOOGLE_ACCOUNT=<REPLACE_WITH_YOURS>
# Your Gooel Developer API Credentials
# Go to https://console.developers.google.com to register your project
CLIENT_ID=<REPLACE_WITH_YOURS>
CLIENT_SECRET=<REPLACE_WITH_YOURS>
@kosho
kosho / Makefile
Last active August 29, 2015 14:22
Makefile to generate a beamer styled PDF file from a markdown written in Japanse on Mac OS.
SRC =
OPTS = --latex-engine=lualatex -t beamer -V fontsize:10pt -V colortheme:beaver -H h-luatexja.tex
all: $(SRC:.md=.pdf)
$(SRC:.md=.pdf): $(SRC)
iconv -f UTF-8-MAC -t UTF-8 $(@:.pdf=.md) | pandoc -o $@ $(OPTS)
open $@
clean:

Set of Emacs init.el Configurations

  • auto-complete-blackets.el: Auto complete corresponding blackets
  • use-source-han-code-jp.el: Use Source Han Code JP font
@kosho
kosho / filebeat.yml
Last active April 10, 2024 13:37
Structured logging example configurations
# Apache httpd
- input_type: log
paths:
- /var/log/httpd/access_log.js
document_type: apache
json.keys_under_root: true
json.add_error_key: true
# Squid
- input_type: log
@kosho
kosho / remove_code_blocks.sh
Last active January 30, 2017 05:17
Remove code blocks from asciidoc
flag="0"
while read x
do
if [[ $x == "-----"* ]]; then
if [ $flag == "0" ]
then flag="1"
else flag="0"
fi
else
if [ $flag == "0" ]
# -*- coding: utf-8 -*-
import sys
import codecs
import csv
import json
# Modify the `fieldnames` with the column names of the CSV input
fieldnames = tuple(range(200))
csvfile = open(sys.argv[1], 'rU')
tail -n +2 %1 | awk 'BEGIN{FS = ","}{print "{\"index\": { }}\n{ \"@timestamp\" : \""$1"\", \"field2\": \""$2"\", \"field3\":" $3 "}" }' > %2
T="T"
for d in `seq -f "%02g" 1 30`; do
for m in `seq -f "%02g" 0 23`; do
for h in `seq -f "%02g" 0 59`; do
echo "{\"index\" : {} }"
echo "{\"@timestamp\": \"2016-04-$d$T$m:$h:00Z\", \"status\": 100}"
done
done
done
# -*- coding: utf-8 -*-
import sys
import codecs
import csv
import json
csvfile = open(sys.argv[1], 'rU')
header_reader = csv.reader(csvfile)
header = next(header_reader)
reader = csv.DictReader(csvfile, header)