Skip to content

Instantly share code, notes, and snippets.

View komasaru's full-sized avatar

mk-mode komasaru

View GitHub Profile
@komasaru
komasaru / test_nokogiri_xml.rb
Created August 28, 2015 06:11
Ruby script to verify the speed of xml parsing by Nokogiri.
#! /usr/local/bin/ruby
# coding: utf-8
#
# Ruby script to verify the speed of xml parsing by Nokogiri.
#
# Copyright(C) 2015 mk-mode.com All Rights Reserved.
#---------------------------------------------------------------------------------
#++
require 'benchmark'
require 'nokogiri'
@komasaru
komasaru / iso_3166_2_jp.csv
Created March 2, 2014 07:10
CSV file of ISO 3166-2:JP.
3166-2 code Subdivision name Language code
JP-01 Hokkaido en
JP-01 Hokkaidô ja
JP-02 Aomori ja
JP-03 Iwate ja
JP-04 Miyagi ja
JP-05 Akita ja
JP-06 Yamagata ja
JP-07 Fukushima en
JP-07 Hukusima ja
@komasaru
komasaru / read_excel.rb
Created March 9, 2014 07:35
Ruby script to read a Excel workbook by 'spreadsheet'.
require 'spreadsheet'
XLS = "./test.xls"
class ReadExcel
# 読み込み
def read
begin
# Excelファイルを読み込み
wb = Spreadsheet.open(XLS, 'r')
@komasaru
komasaru / noaa_stations.rb
Created March 17, 2014 10:43
Ruby script to calculate a summary of the list of NOAA's weather stations.
# ***************************************
# Ruby script to calculate a summary of
# the list of NOAA's weather stations.
# ***************************************
require 'open-uri'
class NoaaStations
FILE = "http://www.aviationweather.gov/static/adds/metars/stations.txt"
def initialize
@komasaru
komasaru / noaa_weather_station.sh
Last active August 29, 2015 13:57
Bash script to search NOAA weather stations by a ICAO code.
#!/bin/bash
# 引数(ICAO コード)不正なら終了
if [[ ! "$1" =~ [0-9A-Z]{4} ]]; then
echo "Wrong argument! - $1"
exit
fi
# 定数定義
URL="http://www.aviationweather.gov/static/adds/metars/stations.txt"
@komasaru
komasaru / test_maptools.R
Last active August 29, 2015 14:04
R script to generate a map by maptools.
# ライブラリの読み込み
library(maptools)
library(RColorBrewer)
# Shape ファイルのフルパス
shp <- '/path/to/shapefile.shp'
# Shape ファイルの読み込み
# map <- readShapePoly(shp) # これでもよい
map <- readShapeSpatial(shp)
@komasaru
komasaru / test_maptools_ksj.R
Last active August 29, 2015 14:04
R script to generate a map of KSJ by maptools.
# ライブラリの読み込み
library(gpclib)
library(ggplot2)
library(maptools)
# gpclib ライセンス警告表示の抑止
gpclibPermit()
# Shape ファイルのフルパス
shp_file <- '/path/to/N03-140401_32_GML/N03-14_32_140401.shp'
@komasaru
komasaru / earthquake.R
Created July 27, 2014 01:29
R script to plot earthquake infos on a map.
# 国土地理院・地球地図日本に地震情報をプロット
# ライブラリの読み込み
library(gpclib)
library(ggplot2)
library(maptools)
# gpclib ライセンス警告表示の抑止
gpclibPermit()
@komasaru
komasaru / SjistToUtf8.cpp
Created August 6, 2014 04:54
Gist - C++ source code to convert ShiftJIS to UTR-8.
/***********************************************************
* 文字コード変換 (ShiftJIS -> UTF-8)
**********************************************************/
#include <fstream>
#include <iostream> // for cout, endl
#include <stdio.h> // for fopen
#include <string.h> // for strlen
#include <iconv.h> // for iconv
#define ENC_SRC "Shift_JIS" // Encoding ( Src )
@komasaru
komasaru / GetHtml.cpp
Created August 6, 2014 04:44
C++ source code to get HTML.
/***********************************************************
* HTML 取得(テキストファイル保存)
**********************************************************/
#include <fstream> // for ofstream
#include <iostream> // for cout, endl
#include <stdio.h> // for fopen
#include <string.h> // for strlen
#include <curl/curl.h> // Require `libcurl4-openssl-dev`
#include <list> // list