この本を読んで気になったサイトのメモです。
さかぽん先生.tv(小中学生向け)
eboard [いーぼーど] (小学校~高校生向け)
マナビー(高校生向け)
カーンアカデミー(日本語吹き替え)(小学生~大人向け)
schoo(大人向け)
JMOOC(大人向け)
config.log_tags = [ :uuid, :remote_ip ]
config.log_tags = [ :uuid, :remote_ip, :user_agent ]
class A MOGE="momomo" end p A::MOGE -> "momomo" muga = A::MOGE A.send :remove_const, :MOGE A::MOGE = "mimimi" p A::MOGE -> "mimimi" A.send :remove_const, :MOGE A::MOGE = muga p A::MOGE -> "momomo"
HOGE = "hohoho" p HOGE -> hohoho" fuga = HOGE Object.send :remove_const, :HOGE HOGE="hihihi" p HOGE -> "hihihi" Object.send :remove_const, :HOGE HOGE = fuga p HOGE -> "hohoho"
----------------------------------- /var/lib/mysql/mysql-audit.json { daily rotate 30 missingok compress delaycompress sharedscripts postrotate if test -x /usr/bin/mysqladmin && \ /usr/bin/mysqladmin ping &>/dev/null then /usr/bin/mysql --defaults-extra-file=/root/.my.cnf -e "set global audit_json_file_flush=ON" fi endscript } -----------------------------------
C POSIX
10646-1:1993, 10646-1:1993/UCS4, ANSI_X3.4-1968, ANSI_X3.4-1986, ANSI_X3.4, ASCII, CP367, CSASCII, CSUCS4, IBM367, ISO-10646, ISO-10646/UCS2, ISO-10646/UCS4, ISO-10646/UTF-8, ISO-10646/UTF8, ISO-IR-6, ISO-IR-193, ISO646-US, ISO_646.IRV:1991, OSF00010020, OSF00010100, OSF00010101, OSF00010102, OSF00010104, OSF00010105, OSF00010106, OSF05010001, UCS-2, UCS-2BE, UCS-2LE, UCS-4, UCS-4BE, UCS-4LE, UCS2, UCS4, UNICODEBIG, UNICODELITTLE, US-ASCII, US, UTF-8, UTF8, WCHAR_T
FROM centos:latest | |
MAINTAINER vivahiraj | |
RUN yum -y install vi | |
RUN echo 'ZONE="Asia/Tokyo"' > /etc/sysconfig/clock | |
RUN cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime | |
RUN yum groupinstall -y japanese-support | |
RUN echo 'LANG="ja_JP.UTF-8"' > /etc/sysconfig/i18n | |
RUN echo 'LC_CTYPE="ja_JP.utf8"' >> /etc/sysconfig/i18n | |
RUN yum reinstall -y glibc-common | |
RUN yum reinstall -y glibc | |
ENV LANG ja_JP.utf8 |
FROM centos:latest | |
MAINTAINER vivahiraj | |
ENV ADD_USER tomato | |
ENV USER_PWD tomato | |
RUN yum update -y | |
RUN yum -y install openssh-server | |
RUN sed -ri 's/required pam_loginuid.so/optional pam_loginuid.so/g' /etc/pam.d/sshd | |
RUN /etc/init.d/sshd start | |
RUN /etc/init.d/sshd stop | |
RUN useradd -m $ADD_USER | |
RUN echo $ADD_USER:$USER_PWD | chpasswd | |
EXPOSE 22 | |
CMD ["/usr/sbin/sshd", "-D"] |
require 'opencv' require 'fluent-logger' require 'base64' log = Fluent::Logger::FluentLogger.new(nil, :host=>'fluentdが起動しているホスト', :port=>24224) cap = OpenCV::CvCapture.open loop do #撮影間隔を以下のsleepで調整 sleep 1 img = cap.query #おくる画像のサイズを指定する場合は、以下のコメントをとる #img = img.resize OpenCV::CvSize.new 640, 360 mat = img.to_CvMat data = Base64.encode64(mat.encode('.jpg').pack('C*')) unless log.post("exec_test.image", {"sender"=>"raspberry pi","image_data"=>data}) p log.last_error # You can get last error object via last_error method end end
open("/var/td-agent/data/test/hoge.txt", "w") {|f| f.write ARGV f.write File.new(ARGV[0]).read }
require 'json' require 'base64' inf = open(ARGV[0]) inf.each do |l| data = JSON.parse l file_name=data['got_at'] + ".jpg" File.open("/var/td-agent/data/test/#{file_name}", 'wb') {|f| f.write Base64.decode64(data["image_data"]) } end
require 'fluent-logger' require 'base64' filename='aaa.jpg' image=File.new(filename).read image_data=Base64.encode64(image) log = Fluent::Logger::FluentLogger.new(nil, :host=>'localhost', :port=>24224) unless log.post("exec_test.image", {"file_name"=>filename,"image_data"=>image_data}) p log.last_error # You can get last error object via last_error method end
require 'fluent-logger' log = Fluent::Logger::FluentLogger.new(nil, :host=>'localhost', :port=>24224) unless log.post("debug.aaaa", {"agent"=>"foo","bbbb"=>"cccc"}) p log.last_error # You can get last error object via last_error method end
require 'opencv' | |
capture = OpenCV::CvCapture.open | |
mat = capture.query.to_CvMat | |
mat.save('output.jpg') |
require 'opencv' | |
require 'em-websocket' | |
require 'base64' | |
EM::run do | |
cap = OpenCV::CvCapture.open | |
det_file = "/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_default.xml" | |
det = OpenCV::CvHaarClassifierCascade::load det_file | |
connections = Array.new | |
EM::WebSocket.start(:host => '0.0.0.0', :port => 51234) do |ws| | |
ws.onopen do |handshake| | |
puts 'connected' | |
connections.push(ws) | |
end | |
ws.onclose do |handshake| | |
puts 'closed' | |
connections.delete(ws) | |
end | |
end | |
EM::defer do | |
loop do | |
sleep 0.1 | |
next if connections.size == 0 | |
img = cap.query | |
img = img.resize OpenCV::CvSize.new 640, 360 | |
det.detect_objects(img).each do |rect| | |
puts "detect!! : #{rect.top_left}, #{rect.top_right}, #{rect.bottom_left}, #{rect.bottom_right}" | |
img.rectangle! rect.top_left, rect.bottom_right, :color => OpenCV::CvColor::Red | |
end | |
mat = img.to_CvMat | |
data = Base64.encode64(mat.encode('.jpg').pack('C*')) | |
connections.each do |con| | |
con.send(data); | |
end | |
end | |
end | |
end |
<!doctype html> | |
<html lang="ja"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>WebCam</title> | |
</head> | |
<body> | |
<div id="capture-area"> | |
</div> | |
<script src="http://codeorigin.jquery.com/jquery-2.0.3.min.js"></script> | |
<script> | |
$(function() { | |
var ws = new WebSocket('ws://raspberrypi.local:51234'); | |
ws.onopen = function() { | |
$('#capture-area').append($('<img>').attr('id', 'capture')); | |
$('#capture').css("width","800px"); | |
}; | |
ws.onclose = function() { | |
}; | |
ws.onmessage = function(evt) { | |
var src = 'data:image/jpeg;base64,' + evt.data; | |
$('#capture').attr('src', src); | |
}; | |
}); | |
</script> | |
</body> | |
</html> |
aaa: 2014-01-25 22:57:09と書いていたところが、おかしかったようです。
[1] pry(main)> a = "aaa: 2014-01-25 22:57:09" => "aaa: 2014-01-25 22:57:09" [2] pry(main)> YAML.load(a) => {"aaa"=>"2014-01-25 22:57:09"} [3] pry(main)> YAML.load(a)["aaa"].class => String
[1] pry(main)> a = "aaa: 2014-01-25 22:57:09" => "aaa: 2014-01-25 22:57:09" [2] pry(main)> YAML.load(a) => {"aaa"=>2014-01-26 07:57:09 +0900} [3] pry(main)> YAML.load(a)["aaa"].class => Time
[1] pry(main)> YAML.method(:load) => #<Method: Syck.load>
[1] pry(main)> YAML.method(:load) => #<Method: Psych.load>
[1] pry(main)> YAML::ENGINE.yamler = 'psych' => "psych" [2] pry(main)> a = "aaa: 2014-01-25 22:57:09" => "aaa: 2014-01-25 22:57:09" [3] pry(main)> YAML.load(a) => {"aaa"=>2014-01-26 07:57:09 +0900} [4] pry(main)> YAML.load(a)["aaa"].class => Time
aaa: 2014-01-25 22:57:09 +09:00
=> "aaa: 2014-01-25 22:57:09 +09:00" [2] pry(main)> YAML.load(a) => {"aaa"=>2014-01-25 22:57:09 +0900} [3] pry(main)> YAML.load(a)["aaa"].class => Time
CONNECTION RETRY: ActiveRecord::ConnectionAdapters::SQLServerAdapter retry #0. TinyTds::Error: DBPROCESS is dead or not enabled: EXEC sp_executesql N'*******; SELECT @@ROWCOUNT AS AffectedRows'
Error 20004 (severity 9): Read from the server failed OS error 104, "接続が相手からリセットされました"
(util.c:156):Changed query state from READING to DEAD (util.c:331):tdserror(0x1585150, 0x15853b0, 20004, 104) (util.c:361):tdserror: client library returned TDS_INT_CANCEL(2) (util.c:384):tdserror: returning TDS_INT_CANCEL(2) (token.c:555):processing result tokens. marker is 0() (token.c:122):tds_process_default_tokens() marker is 0() (token.c:125):leaving tds_process_default_tokens() connection dead
len = 1; setsockopt(tds->s, SOL_SOCKET, SO_KEEPALIVE, (const void *) &len, sizeof(len)); len = 30; setsockopt(tds->s, IPPROTO_TCP, TCP_KEEPIDLE, (const void *) &len, sizeof(len)); len = 1; setsockopt(tds->s, IPPROTO_TCP, TCP_KEEPINTVL, (const void *) &len, sizeof(len)); len = 10; setsockopt(tds->s, IPPROTO_TCP, TCP_KEEPCNT, (const void *) &len, sizeof(len));
twitter-bootstrap-rails
を使ってみました。
developmentでは何の問題もなく使えていたのですが、
productionでは、
ActionView::Template::Error (undefined local variable or method ` bootstrap_flash' for #<#<Class:0x00000004abf460>:0x000000051a9690>):
みたいなエラーが出て使えなかったのです。
調べてみると
helperにbootstrap_flashを追加すればよいみたいな感じなのですが
今回使っている
twitter-bootstrap-rails
twitter-bootstrap-rails-2.2.8/app/helpers/flash_block_helper.rb
にhelperがちゃんと用意されていました。
これをapp/helperにコピーすれば動くのですが、
それでは、いまいちです。
エラーが出た原因ですが、
Gemfileの書き方がいけませんでした。
最初は、
group :assets do gem "twitter-bootstrap-rails" end
とassetsグループの中に入れていたのですが、これがダメでした。
groupにいれずに普通に
gem "twitter-bootstrap-rails"
と書いておけばOKでした。
やれやれです。
incompatible character encodings: ASCII-8BIT and UTF-8 (RuntimeError)
みたいなエラーが出てマジックコメント書いてささっと解決さと思ったのにすでにマジックコメントが書いてあってどういうことだろう・・・と思ったわけです。
こんなエラーが出ていますが、ただ単に利用するテーブルに権限がないだけで、権限を振ればOKだったりすることがあります。
私の場合既存システムのDBのデータをselectしたいなぁと思ったときに、そのテーブルへのselect権を付け忘れていてエラーが出たのでした。
紛らわしいエラーですね。
Bundler::GemHelper.install_tasks #以下を追加 t = Rake.application.lookup('release') t.clear t.instance_variable_set('@full_comment', nil) desc 'Please keep this for internal use only.' task :release do puts "Please keep this for internal use only." end
# -*- coding: utf-8 | |
require 'rubygems' | |
require 'tesseract-ocr' | |
engine = Tesseract::Engine.new{ |engine| | |
engine.language = :jpn | |
} | |
puts "==== 画像全体から文字を取得します" | |
puts engine.text_for(ARGV[0]) | |
puts "" | |
#以下のようにすると画像の一部だけで認識できる | |
#test_for(file_name,認識させたい左上のx,認識させたい左上のxy,認識させたい幅,認識させたい高さ) | |
puts "==== 画像のメイリオの部分のみ" | |
puts engine.text_for(ARGV[0],0,0,200,100) | |
puts "" | |
puts "==== 画像のゴシックの部分のみ" | |
puts engine.text_for(ARGV[0],370,70,540-370,130-70) | |
puts "" | |
puts "==== 画像の明朝の部分のみ" | |
puts engine.text_for(ARGV[0],100,120,230-100,180-120) | |
puts "" | |
puts "==== 画像の赤いメイリオの部分のみ" | |
puts engine.text_for(ARGV[0],280,180,420-280,250-180) | |
puts "" | |
puts "==== 画像の縦書きメイリオの部分のみ" | |
puts engine.text_for(ARGV[0],490,160,570-490,290-160) | |
puts "" | |
puts "==== 画像の富士山の上のメイリオの部分のみ" | |
puts engine.text_for(ARGV[0],50,270,580-50,460-270) | |
puts "" | |
puts "==== 認識した一文字ずつの情報" | |
engine.symbols_for(ARGV[0]).each_with_index{ |val, i| | |
text = val.text | |
b = val.bounding_box | |
printf("%d | text=%s pos=(x:%d y:%d w:%d h:%d)\n", | |
i, text, b.x, b.y, b.width, b.height) | |
} | |
puts "" | |
puts "==== 認識した文字ブロックの情報" | |
engine.blocks_for(ARGV[0]).each_with_index{ |val, i| | |
text = val.text | |
b = val.bounding_box | |
printf("%d | text=%s pos=(x:%d y:%d w:%d h:%d)\n", | |
i, text, b.x, b.y, b.width, b.height) | |
} | |
puts "" | |
puts "==== 認識した文字段落(ブロックとの違いがよくわからない)の情報" | |
engine.paragraphs_for(ARGV[0]).each_with_index{ |val, i| | |
text = val.text | |
b = val.bounding_box | |
printf("%d | text=%s pos=(x:%d y:%d w:%d h:%d)\n", | |
i, text, b.x, b.y, b.width, b.height) | |
} | |
puts "" | |
puts "==== 認識した文字の行ごとの情報" | |
engine.lines_for(ARGV[0]).each_with_index{ |val, i| | |
text = val.text | |
b = val.bounding_box | |
printf("%d | text=%s pos=(x:%d y:%d w:%d h:%d)\n", | |
i, text, b.x, b.y, b.width, b.height) | |
} | |
puts "" | |
puts "==== 認識した単語のごとの情報" | |
engine.words_for(ARGV[0]).each_with_index{ |val, i| | |
text = val.text | |
b = val.bounding_box | |
printf("%d | text=%s pos=(x:%d y:%d w:%d h:%d)\n", | |
i, text, b.x, b.y, b.width, b.height) | |
} | |
puts "" |
==== 画像全体から文字を取得します 加順ス 卜ですー メイリ赫すー ーF^ゴシックを 使ってみました〝 ーF“明朝で†〟 ヒロシで†〟 メ 赤し丶字での 古 琶 メイリ祀す〟 茗 で 麦 ==== 画像のメイリオの部分のみ 伽R折ス 卜です〟 メイリ祀す〟 ==== 画像のゴシックの部分のみ ーP^ゴシツクを 使ってみましナこ〝 ==== 画像の明朝の部分のみ ーPA明朝です〟 ヒロシです〟 ==== 画像の赤いメイリオの部分のみ 赤し`字での メイリ祀す〟 ==== 画像の縦書きメイリオの部分のみ メ縦 ィ管 リ實 オで で 麦 ==== 画像の富士山の上のメイリオの部分のみ \ ` '/ f ~ j での 丿 イリ村す~ / ==== 認識した一文字ずつの情報 0 | text=加 pos=(x:28 y:44 w:23 h:12) 1 | text=順 pos=(x:52 y:44 w:42 h:13) 2 | text=ス pos=(x:94 y:44 w:16 h:13) 3 | text=卜 pos=(x:115 y:43 w:11 h:14) 4 | text=で pos=(x:126 y:45 w:16 h:12) 5 | text=す pos=(x:143 y:43 w:15 h:14) 6 | text=ー pos=(x:159 y:53 w:5 h:4) 7 | text=メ pos=(x:29 y:76 w:14 h:13) 8 | text=イ pos=(x:45 y:75 w:14 h:14) 9 | text=リ pos=(x:63 y:75 w:11 h:14) 10 | text=赫 pos=(x:76 y:75 w:32 h:14) 11 | text=す pos=(x:109 y:75 w:15 h:14) 12 | text=ー pos=(x:125 y:85 w:5 h:4) 13 | text=ー pos=(x:385 y:84 w:6 h:11) 14 | text=F pos=(x:393 y:84 w:7 h:11) 15 | text=^ pos=(x:400 y:84 w:8 h:11) 16 | text=ゴ pos=(x:410 y:83 w:14 h:13) 17 | text=シ pos=(x:426 y:84 w:13 h:12) 18 | text=ッ pos=(x:443 y:87 w:10 h:9) 19 | text=ク pos=(x:458 y:84 w:12 h:13) 20 | text=を pos=(x:474 y:83 w:13 h:14) 21 | text=使 pos=(x:384 y:106 w:16 h:14) 22 | text=っ pos=(x:402 y:111 w:12 h:8) 23 | text=て pos=(x:417 y:108 w:14 h:11) 24 | text=み pos=(x:433 y:107 w:15 h:13) 25 | text=ま pos=(x:450 y:106 w:12 h:13) 26 | text=し pos=(x:468 y:107 w:10 h:13) 27 | text=た pos=(x:481 y:106 w:14 h:13) 28 | text=〝 pos=(x:496 y:116 w:6 h:4) 29 | text=ー pos=(x:122 y:137 w:4 h:11) 30 | text=F pos=(x:128 y:137 w:8 h:11) 31 | text=“ pos=(x:136 y:137 w:8 h:11) 32 | text=明 pos=(x:145 y:136 w:14 h:14) 33 | text=朝 pos=(x:160 y:136 w:16 h:14) 34 | text=で pos=(x:177 y:137 w:15 h:12) 35 | text=† pos=(x:193 y:136 w:15 h:14) 36 | text=〟 pos=(x:208 y:146 w:5 h:4) 37 | text=ヒ pos=(x:122 y:161 w:12 h:12) 38 | text=ロ pos=(x:138 y:162 w:12 h:10) 39 | text=シ pos=(x:154 y:161 w:13 h:12) 40 | text=で pos=(x:169 y:161 w:15 h:12) 41 | text=† pos=(x:185 y:160 w:15 h:14) 42 | text=〟 pos=(x:200 y:170 w:5 h:4) 43 | text=メ pos=(x:506 y:170 w:13 h:14) 44 | text=赤 pos=(x:301 y:189 w:15 h:15) 45 | text=し pos=(x:318 y:192 w:7 h:11) 46 | text=丶 pos=(x:328 y:192 w:4 h:9) 47 | text=字 pos=(x:333 y:189 w:15 h:15) 48 | text=で pos=(x:349 y:192 w:15 h:12) 49 | text=の pos=(x:365 y:192 w:15 h:12) 50 | text=古 pos=(x:506 y:185 w:14 h:31) 51 | text=琶 pos=(x:537 y:169 w:16 h:46) 52 | text=メ pos=(x:302 y:223 w:13 h:13) 53 | text=イ pos=(x:318 y:222 w:14 h:14) 54 | text=リ pos=(x:336 y:222 w:10 h:14) 55 | text=祀 pos=(x:349 y:222 w:31 h:14) 56 | text=す pos=(x:382 y:222 w:14 h:14) 57 | text=〟 pos=(x:398 y:232 w:5 h:4) 58 | text=茗 pos=(x:506 y:217 w:14 h:31) 59 | text=で pos=(x:538 y:219 w:14 h:13) 60 | text=麦 pos=(x:506 y:249 w:14 h:22) ==== 認識した文字ブロックの情報 0 | text=加順ス 卜ですー メイリ赫すー ーF^ゴシックを 使ってみました〝 ーF“明朝で†〟 ヒロシで†〟 メ 赤し丶字での 古 琶 メイリ祀す〟 茗 で 麦 pos=(x:0 y:0 w:607 h:476) ==== 認識した文字段落(ブロックとの違いがよくわからない)の情報 0 | text=加順ス 卜ですー メイリ赫すー ーF^ゴシックを 使ってみました〝 ーF“明朝で†〟 ヒロシで†〟 メ 赤し丶字での 古 琶 メイリ祀す〟 茗 で 麦 pos=(x:28 y:43 w:525 h:228) ==== 認識した文字の行ごとの情報 0 | text=加順ス 卜ですー pos=(x:28 y:43 w:136 h:14) 1 | text=メイリ赫すー ーF^ゴシックを pos=(x:29 y:75 w:458 h:22) 2 | text=使ってみました〝 pos=(x:384 y:106 w:118 h:14) 3 | text=ーF“明朝で†〟 pos=(x:122 y:136 w:91 h:14) 4 | text=ヒロシで†〟 メ pos=(x:122 y:160 w:397 h:24) 5 | text=赤し丶字での 古 琶 pos=(x:301 y:169 w:252 h:47) 6 | text=メイリ祀す〟 茗 で pos=(x:302 y:217 w:250 h:31) 7 | text=麦 pos=(x:506 y:249 w:14 h:22) ==== 認識した単語のごとの情報 0 | text=加順ス pos=(x:28 y:44 w:82 h:13) 1 | text=卜ですー pos=(x:115 y:43 w:49 h:14) 2 | text=メイリ赫すー pos=(x:29 y:75 w:101 h:14) 3 | text=ーF^ゴシックを pos=(x:385 y:83 w:102 h:14) 4 | text=使ってみました〝 pos=(x:384 y:106 w:118 h:14) 5 | text=ーF“明朝で†〟 pos=(x:122 y:136 w:91 h:14) 6 | text=ヒロシで†〟 pos=(x:122 y:160 w:83 h:14) 7 | text=メ pos=(x:506 y:170 w:13 h:14) 8 | text=赤し丶字での pos=(x:301 y:189 w:79 h:15) 9 | text=古 pos=(x:506 y:185 w:14 h:31) 10 | text=琶 pos=(x:537 y:169 w:16 h:46) 11 | text=メイリ祀す〟 pos=(x:302 y:222 w:101 h:14) 12 | text=茗 pos=(x:506 y:217 w:14 h:31) 13 | text=で pos=(x:538 y:219 w:14 h:13) 14 | text=麦 pos=(x:506 y:249 w:14 h:22)