Skip to content

Instantly share code, notes, and snippets.

View tkfm-yamaguchi's full-sized avatar

Takafumi Yamaguchi tkfm-yamaguchi

View GitHub Profile
@tkfm-yamaguchi
tkfm-yamaguchi / launch-nonblocking-httpserver-in-ruby.rb
Created February 23, 2018 10:05
Launch webrick as non-blocking http server
require 'webrick'
require 'open3'
server = WEBrick::HTTPServer.new(:DocumentRoot => './', Port: 9999, ServerType: Thread)
server.start
sleep 3
result = Open3.capture2e('curl http://localhost:9999/index.html')
p result
@tkfm-yamaguchi
tkfm-yamaguchi / main.rb
Created February 21, 2018 14:49
download, unzip and process on memory with Ruby
# HTTP 上の zip ファイルをオンメモリで DL/加工 した結果をファイルに保存.
# 行単位での読み出し/加工/書き出しを意識した実装.
if __FILE__ == $0
url = "http://localhost:8000/1020201008_00.csv.zip"
require "open-uri"
require "zip"
File.open('conved.csv', 'w') do |output|
OpenURI.open_uri(url) do |payload_io|
@tkfm-yamaguchi
tkfm-yamaguchi / geojson_simplifier.rb
Created February 20, 2018 01:26
minify geojson with reducing the precision of coordinates
#!/usr/bin/env ruby
# coding: utf-8
require "json"
def reduce_precision_recursively(coordinates, precision: 6)
if coordinates.first.is_a?(Array)
coordinates.each do |coords|
round_coordinates(coords, precision: precision)
@tkfm-yamaguchi
tkfm-yamaguchi / shape_to_geojson.txt
Created February 19, 2018 16:26 — forked from rob-murray/shape_to_geojson.txt
GDAL shape 2 geoJSON with generalisation and reduced precision
/Library/Frameworks/GDAL.framework/Versions/1.9/Programs/ogr2ogr -f GeoJSON -simplify 100 -lco COORDINATE_PRECISION=2 ~/Downloads/mbtiles/nat_park_region_100x.json ~/Downloads/mbtiles/nat_park_region.shp
@tkfm-yamaguchi
tkfm-yamaguchi / justify-idiot-microsoft-word-for-mac-shortcuts.md
Last active February 19, 2018 11:09
Justify Idiot Keyboard Shortcuts of Microsoft Word For Mac 2016.

Word for Mac の頭の悪いショートカットを修正する

  • 16.10 (180210) で確認.
  • dotm のフォーマットがバージョンアップで予告もなしに変更されて, 設定ファイルをおじゃんにされることがあるので要注意.
  • バージョンアップでキーが登録されている名称(NavPaneSearch)とかがコロコロ変わる. ひどい時は日本語→英語(というかメソッド名っぽいもの)に変更されたりする(当然予告なんぞない).

キーボードショートカットの再設定

@tkfm-yamaguchi
tkfm-yamaguchi / index.html
Last active February 19, 2018 05:39
scroll to the specific element programatically
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>すくろーる♡</title>
<style type="text/css">
#outer {
border: 1px solid #000;
height: 400px;
overflow-y: scroll;
@tkfm-yamaguchi
tkfm-yamaguchi / commit-message-prefix.md
Created February 1, 2018 09:57
The prefixes for a commit message (by angular)
@tkfm-yamaguchi
tkfm-yamaguchi / React-Directory-Layout.md
Created January 29, 2018 07:19 — forked from koistya/React-Directory-Layout.md
File and folder naming convention for React.js components

File and folder naming convention for React.js components

Directory Layout #1

/actions/...
/components/common/Link.js
/components/common/...
/components/forms/TextBox.js
/components/forms/TextBox.res/style.css
@tkfm-yamaguchi
tkfm-yamaguchi / sum_of_digits.rb
Created January 29, 2018 01:19
measure the time to get the sum of digits
require "benchmark"
# Sum of digits
TARGET = 123456789
def sum_by_s
TARGET.to_s.chars.map(&:to_i).sum
end
@tkfm-yamaguchi
tkfm-yamaguchi / MS_OFFICE_BUGS.md
Last active December 20, 2017 06:42
Bugs: Microsoft Office 2016 for Mac
  • Word
    • Can't save a file as PDF.
  • Can't input the equations with the keyboard shortcuts.