Skip to content

Instantly share code, notes, and snippets.

View tagomoris's full-sized avatar

Satoshi Tagomori tagomoris

View GitHub Profile
@tagomoris
tagomoris / parser_bench.js
Created October 16, 2012 03:45
node.js html parser (jquery style) benchmark
var fs = require('fs'),
async = require('async');
var try_series = function(func_name, func, data, times, cb){
var start = new Date();
var tries = new Array(times);
for(var i = 0 ; i < times ; i++) {
tries[i] = function(callback){func(data, callback);};
}
async.series(tries, function(err,result){
@tagomoris
tagomoris / namespace.md
Created September 26, 2023 11:19
Namespace on read

"Namespace on read"とは

これは、Rubyに仮想的なトップレベル名前空間を導入するためのNamespaceを提案します。NamespaceはRubyスクリプトかネイティブ拡張ライブラリかを問わず、ライブラリをグローバル名前空間から独立した形でrequire/loadします。

動機

"Namespace on read"は次の2つの問題を解決し、また1つの問題について解決の道筋を提供します。

  • ライブラリ(等)間での名前の衝突を避ける
  • グローバルに共有されたライブラリ/オブジェクトの意図しない変更を避ける
@tagomoris
tagomoris / md_sync_call.sh
Created April 20, 2011 06:33
Run "check" about specified md device if it's status is "idle"
#!/bin/sh
TARGET_MD=$1
### call md verifying when idle.
######
# HOW TO USE
### md_sync_call.sh md0
error_exit() {
@tagomoris
tagomoris / github_org_clone_all.rb
Last active March 27, 2020 03:23
Script to clone all repositories of specified organization
#!/usr/bin/env ruby
# gem i github_api
## Setting -> Applications -> Personal Access Tokens -> Generate new token
# Selected scopes:
# * repo
# * public_repo
# * repo:status
# * read:org
require 'socket'
PORT = 8088
server = TCPServer.open(PORT)
children = []
puts "server.0 starting children"
9.times do |i|
num = i + 1 # 0 is for main
children << Thread.start(server) do |s|
require 'msgpack'
# x = "\x82\xA9condition\xA2OR\xA6groups\x92\x82\xA9condition\xA2or\xA7filters\x91\x83\xA3col\xAAbirth_date\x
# A3ope\xA5month\xA3val\xA12\x82\xA9condition\xA2or\xA7filters\x91\x83\xA3col\xADshare_capital\xA3ope\xB3greater_or_equal_
# th\xDD\x98[)\x8DL\f\v\x8C\f"
# MessagePack.unpack x
x2 = "\x82\xA9condition\xA2OR\xA6groups\x92\x82\xA9condition\xA2or\xA7filters\x91\x83\xA3col\xAAbirth_date\xA3ope\xA5month\xA3val\xA12\x82\xA9condition\xA2or\xA7filters\x91\x83\xA3col\xADshare_capital\xA3ope\xB3greater_or_equal_th\xDD\x98[)\x8DL\f\v\x8C\f"
[
{"name": "Amina Frost", "country": "US", "city": "Hammond", "amount": 30},
{"name": "Mehak Flowers", "country": "US", "city": "Kansas City", "amount": 41},
{"name": "Angharad Davie", "country": "AU", "city": "Queenstown", "amount": 31},
{"name": "Hannah Robins", "country": "UK", "city": "Langport", "amount": 1},
{"name": "Romilly Lowe", "country": "US", "city": "Kansas City", "amount": 10},
{"name": "Komal Donaldson", "country": "UK", "city": "Langport", "amount": 19},
{"name": "Florence Andrew", "country": "US", "city": "Kansas City", "amount": 7}
]

多くのWebサービス・インターネットサービスでは、今やデータの収集・処理・分析といったタスクが非常に重要なものになっていることは多くの方に賛同をいただけるものと思います。近年ではIoTというキーワードもよく話題になります。増え続けるデータの処理をどのようにするか、といった点に悩んでいるサービス事業者の方は多いのではないでしょうか。

この種のデータ処理・分析をどこでどうやって行うか、という問題は通常のWebサービスの開発とはかなり異なる知識と経験を要求されます。特にHadoopを中心とした分散処理基盤のデプロイとメンテナンスはこれまで多くの開発者を悩ませてきました。

一方、近年ではデータ処理・データ分析に特化したサービスもいくつも出てきました。自分でHadoopクラスタのセットアップ・運用をしなくても利用可能なこれらのサービスは特に開発者の少ないスタートアップで広く利用されるようになり、耳にされることも多いかもしれません。

このエントリでは、継続的に増え続けるデータ処理・分析の基盤にどのようなものがあり、どのようなケースで有効に利用できるか、自分の考えをまとめておこうと思います。これからのデータ処理基盤を考えている方には参考になるかもしれません。

@tagomoris
tagomoris / fiber.rb
Created May 31, 2018 08:05
fiber hack
class Foo
def initialize
@closed = false
end
def close
@closed = true
end
def closed?
access-log: /dev/null
hosts:
"localhost":
listen: 8384
paths:
"/t":
mruby.handler: |
class Foo
def initialize(ch, a)
@ch = ch