Skip to content

Instantly share code, notes, and snippets.

@tmtysk
tmtysk / file0.txt
Created April 17, 2015 02:27
AWS S3にアップロードしたファイルのContent-Typeを一括で書き換えるワンライナー ref: http://qiita.com/tmtysk/items/f85e7d03132e999c94a1
$ aws s3 ls --recursive s3://<bucket_name>/<somewhere> | grep -e '.jpg$' | awk '{ print "s3://<bucket_name>/"$4 }' | while read origname; do aws s3 mv ${origname} ${origname}.bak; aws s3 mv ${origname}.bak ${origname} --metadata-directive REPLACE --content-type "image/jpeg"; done
@tmtysk
tmtysk / blog_category.json
Last active August 29, 2015 14:19
Jubatusでテキストに含まれる特徴語の傾向を学習し、入力テキストをカテゴライズする ref: http://qiita.com/tmtysk/items/4d177ba27c8d2484b206
{
"method": "NHERD",
"parameter": {
"regularization_weight": 0.001
},
"converter": {
"num_filter_types": {
},
"num_filter_rules": [
],
@tmtysk
tmtysk / ha_mroonga.cpp.20120605.diff
Created June 5, 2012 22:47
forcible patch to enable utf8mb4 encoding on mroonga
--- ha_mroonga.cpp.orig 2012-04-29 09:51:15.000000000 +0900
+++ ha_mroonga.cpp 2012-06-05 17:33:45.000000000 +0900
@@ -117,6 +117,7 @@
static grn_hash *mrn_hash;
static CHARSET_INFO *mrn_charset_utf8 = NULL;
+static CHARSET_INFO *mrn_charset_utf8mb4 = NULL;
static CHARSET_INFO *mrn_charset_binary = NULL;
static CHARSET_INFO *mrn_charset_ascii = NULL;
static CHARSET_INFO *mrn_charset_latin1_1 = NULL;
@tmtysk
tmtysk / gist:1902193
Created February 24, 2012 17:22
山手線駅のリスト(コピペ用)
# vim: set fileencoding=utf-8 filetype=ruby ts=4 :
stations = %w(東京 有楽町 新橋 浜松町 田町 品川 大崎 五反田 目黒 恵比寿 渋谷 原宿 代々木 新宿 新大久保 高田馬場 目白 池袋 大塚 巣鴨 駒込 田端 西日暮里 日暮里 鶯谷 上野 御徒町 秋葉原 神田)
@tmtysk
tmtysk / swf_tags_scraper.rb
Created August 26, 2010 04:04
外部サイトをスクレイピングしてSWFタグ番号からタグ名のHashをつくる
# vim: set fileencoding=utf-8 filetype=ruby ts=2 :
# making Hash object of SwfTagType(code) to SwfTagName by scraping on external url.
require 'nokogiri'
require 'open-uri'
require 'pp'
TARGET_URI = "http://example.com/swf_tags"
doc = Nokogiri::HTML(open(TARGET_URI))
swfs = Hash.new
@tmtysk
tmtysk / gist:263992
Created December 26, 2009 17:41
emoji4unicode のデータと Unicode::Emoji::E4U を使って、SoftBank の SJIS-Unicode 変換テーブル(jpmobileフォーマット)を作成する
use Unicode::Emoji::E4U;
binmode(STDOUT, ":utf8");
my $e4u = Unicode::Emoji::E4U->new;
# fetch data files from Google Code (default)
$e4u->datadir('http://emoji4unicode.googlecode.com/svn/trunk/data/');
my $softbank = $e4u->softbank; # Unicode::Emoji::Google instance
print "Jpmobile::Emoticon::SOFTBANK_SJIS_TO_UNICODE = {\n";
@tmtysk
tmtysk / mediarssgen.rb
Created October 15, 2009 08:37
Creating simple "Media RSS (http://video.search.yahoo.com/mrss)" from jpegs in specified directories and uri.
# mediarssgen.rb
# Creating simple "Media RSS (http://video.search.yahoo.com/mrss)"
# from jpegs in specified directories and uri.
#
# Usage: $ ruby mediarssgen.rb <thumbnail_dir> <image_dir> <uri_root>
require 'rubygems'
require 'libxml'
include LibXML
@tmtysk
tmtysk / xpathtest.rb
Created May 29, 2009 18:19
rexml v.s. libxml (searching by XPath expr)
require 'rubygems'
require 'rexml/document'
require 'libxml'
RUBY_VERSION # => "1.8.6"
REXML::Version # => "3.1.7.2"
LibXML::XML::LIBXML_VERSION # => "2.6.30"
xml = '<hoge><foo><foo/><bar/></foo></hoge>'