Skip to content

Instantly share code, notes, and snippets.

@kimoto
kimoto / hoge.pl
Created Mar 8, 2017
perlのsortないで関数呼び出しをすると意図する回数より多く関数呼出しされてしまうかもの件 (n^2)
View hoge.pl
(Hoge->new(3), Hoge->new(2), Hoge->new(1)) 並び順のデータのソートだと、4回関数が呼ばれる
(Hoge->new(1), Hoge->new(2), Hoge->new(3)) だと、上記例(result.txt)のように6回関数が呼ばれる
なので事前にすべて計算をしておいてその値でソートをするか、いわゆるmemo化のように関数内でキャッシュを作成しておかないとダメかもしれない
@kimoto
kimoto / syouhyou_yomi.rb
Created Aug 18, 2015
商標検索をもとに読みを取得する
View syouhyou_yomi.rb
#!/bin/env ruby
# encoding: utf-8
require 'mechanize'
def syouhyou_yomi(*keywords)
keywords.flatten!
wait_time = 0.2
agent = Mechanize.new
agent.user_agent_alias = 'Mac Mozilla'
@kimoto
kimoto / fashion_press.rb
Created Aug 18, 2015
fashion press cralwer
View fashion_press.rb
#!/bin/env ruby
# encoding: utf-8
require 'net/http'
require 'nokogiri'
uri = URI("http://www.fashion-press.net/brands/en")
doc = Nokogiri::HTML(Net::HTTP.get(uri))
results = []
View elasticsearch14.rb
class Elasticsearch14 < Formula
homepage "https://www.elastic.co/products/elasticsearch"
url "https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.4.4.tar.gz"
sha256 "a3158d474e68520664debaea304be22327fc7ee1f410e0bfd940747b413e8586"
bottle do
cellar :any
sha256 "d2a1df0938267bcff1cfae6341392ec2d4869809e7adf868e8b3d54eb0908481" => :yosemite
sha256 "1d18d3bf86a1b6e17a9612d0178e12f70a68fffd0eddd0c956964226d48ef3b0" => :mavericks
sha256 "f3bb1bfc49b1a56ddfa485c8c032d3b39beb70cf0ed9df20c69d3dbff8a2abd2" => :mountain_lion
@kimoto
kimoto / elasticsearch144.rb
Created Aug 13, 2015
elasticsearch144.rb
View elasticsearch144.rb
class Elasticsearch14 < Formula
homepage "https://www.elastic.co/products/elasticsearch"
url "https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.4.4.tar.gz"
sha256 "a3158d474e68520664debaea304be22327fc7ee1f410e0bfd940747b413e8586"
bottle do
cellar :any
sha256 "d2a1df0938267bcff1cfae6341392ec2d4869809e7adf868e8b3d54eb0908481" => :yosemite
sha256 "1d18d3bf86a1b6e17a9612d0178e12f70a68fffd0eddd0c956964226d48ef3b0" => :mavericks
sha256 "f3bb1bfc49b1a56ddfa485c8c032d3b39beb70cf0ed9df20c69d3dbff8a2abd2" => :mountain_lion
View csresulter2csv.rb
#!/bin/env ruby
# encoding: utf-8
require 'nokogiri'
require 'net/http'
MEMBER_KEY="メンバー"
DAY_KEY="日付"
def crawl(url)
doc = Nokogiri::HTML(Net::HTTP.get(URI(url)))
@kimoto
kimoto / normalize_neologd.rb
Last active Aug 29, 2015
Normalizer for mecab-neologd
View normalize_neologd.rb
require 'moji'
def normalize_neologd(norm)
norm.tr!("0-9A-Za-z", "0-9A-Za-z")
norm = Moji.han_to_zen(norm, Moji::HAN_KATA)
hypon_reg = /(?:˗|֊|‐|‑|‒|–|⁃|⁻|₋|−)/
norm.gsub!(hypon_reg, "-")
choon_reg = /(?:﹣|-|ー|—|―|─|━)/
norm.gsub!(choon_reg, "")
chil_reg = /(?:~|∼|∾|〜|〰|~)/
@kimoto
kimoto / find_focusyarou.m
Created Jul 17, 2014
会社のiMacでフォーカス奪う悪質な犯人探しのためのコード
View find_focusyarou.m
# How to use:
# gcc ./find_focusyarou.m -framework AppKit
# ./a.out
#import <Cocoa/Cocoa.h>
int main(){
while(1){
NSString *appName = [[[NSWorkspace sharedWorkspace] activeApplication] objectForKey:@"NSApplicationName"];
NSLog(@"%@\n", appName);
sleep(1);
@kimoto
kimoto / apache_modcache_vulun.txt
Last active Aug 29, 2015
Apache + mod_cache の Rangeリクエスト を使った脆弱性について
View apache_modcache_vulun.txt
概要
・Apache/mod_cacheで、初回リクエストがHTTP Rangeリクエストだったときにコンテンツ断片をキャッシュしてしまう問題
発生条件
・Apacheが対象バージョンであること
・proxy先のコンテンツがHTTP Range Request (Partial Content)に対応している
・proxy先のコンテンツがcache-controlとexpiresヘッダーを出力しない
・mod_cache + mod_rewrite + mod_proxy使ってること
対象バージョン
@kimoto
kimoto / mvm_sundown_a3.pop
Created Jun 17, 2013
Fixed Bug: mvm_sundown_a3.pop
View mvm_sundown_a3.pop
#base robot_giant.pop
#base robot_standard.pop
#base sundown_templates.pop
WaveSchedule
{
StartingCurrency 600
RespawnWaveTime 5
CanBotsAttackWhileInSpawnRoom no
You can’t perform that action at this time.