Skip to content

Instantly share code, notes, and snippets.

Avatar
😇

Yuichi Goto yasaichi

😇
  • Tokyo, Japan
View GitHub Profile
@yasaichi
yasaichi / x_means.py
Last active Mar 2, 2022
Implementation of X-means clustering in Python
View x_means.py
"""
以下の論文で提案された改良x-means法の実装
クラスター数を自動決定するk-meansアルゴリズムの拡張について
http://www.rd.dnc.ac.jp/~tunenori/doc/xmeans_euc.pdf
"""
import numpy as np
from scipy import stats
from sklearn.cluster import KMeans
@yasaichi
yasaichi / config.ru
Created Apr 5, 2015
パーフェクト Ruby on Rails 10章
View config.ru
require './basic_auth'
App = lambda do |env|
[200, { "Content-Type" => "text/html" }, ["Hello, Rack world!"]]
end
use BasicAuth, user_name: 'test:user', password: 'pass'
run App
@yasaichi
yasaichi / basic_auth.rb
Created Apr 5, 2015
パーフェクト Ruby on Rails 10章
View basic_auth.rb
require 'base64'
class BasicAuth
def initialize(app, user_name:, password:)
@app = app
@user_name = user_name
@password = password
end
def call(env)
@yasaichi
yasaichi / keys.rb
Created Mar 13, 2015
rails/rails/blob/4-2-stable/activesupport/lib/active_support/core_ext/hash/keys.rb
View keys.rb
class Hash
def transform_keys
return enum_for(:transform_keys) unless block_given?
result = self.class.new
each_key do |key|
result[yield(key)] = self[key]
end
result
end
@yasaichi
yasaichi / camelize_keys.rb
Last active Aug 29, 2015
Hash#camelize_keys
View camelize_keys.rb
require 'active_support/core_ext'
class Hash
unless method_defined?(:camelize_keys)
def camelize_keys(first_letter = :upper)
transform_keys { |key| key.camelize(first_letter) rescue key }
end
end
unless method_defined?(:camelize_keys!)