Entries from 2013-01-01 to 1 year

Sinatra and async_sinatra EventMachine WebSockets

http://jordanhollinger.com/2011/07/09/writing-an-ajax-long-polling-server-in-ruby-part-2

Bundler

http://qiita.com/sumyapp/items/6843ceebbbfc09a2b6ac http://qiita.com/u1_fukui/items/b86b21f6ed39f4c10d5d http://www.rubylife.jp/rails/ini/index2.html http://shokai.org/blog/archives/7262

Default to only serving localhost in development mode. (Postmodern)

WEBrick/shotgun/Sinatraがデフォルトでは外部から繋がらない

http://qiita.com/u1_fukui/items/b86b21f6ed39f4c10d5d http://ruby.about.com/od/sinatra/a/sinatra5.htmver1.4から「only serving localhost in development mode」だそうです。 = 1.4.0 / 2013-03-15対応方法最初に見たドキュメントの通り、environment…

Block Proc yeild async_sinatra

http://d.hatena.ne.jp/yoshidaa/20090511/1241967137 http://blog.livedoor.jp/sasata299/archives/51488276.htmlhttp://jordanhollinger.com/2011/05/15/writing-an-ajax-long-polling-server-in-ruby-part-1

httpについて 

http://www.studyinghttp.net/method http://yohei-y.blogspot.hk/2005/04/rest-5-get-post-put-delete.html

inject

http://ruby-doc.org/core-2.0/Enumerable.html#method-i-inject[1, 2, 3, 4].inject(0) { |result, element| result + element } # => 10ary = %w(1 2 2 3 3 3 4 4 4 4) ary.inject(Hash.new(0)){|hash, a| hash[a] += 1; hash} #=> {"1"=>1, "2"=>2, "3"=>…

mechanize "OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed"

原因:OpenSSLの証明書が間違っているもしくは古くなった。HTTPSの意味はなくなるが、簡単に動く様になる方法。 a.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE ※特定のサイトで相手を完全に信用している場合は、これで良い。http://limi.co.uk/post…

ubuntu NetworkManagerにrouteを新たに加える, 2 NICs, 2 routers, port forwarding from 2nd router, VPN routing

2つのルーターが別々のネットワークに繋がっていて場合、1台のPCに2枚のネットワークカードをインストールしそれぞれのネットワークにつなげると、デフォルト・ネットワークでしかポートフォワードが設定できない。原因=>PCにデフォルト・ルートがNetworkM…

Finding/Configuring your network interface. IP

https://help.ubuntu.com/community/NetworkConfigurationCommandLine/Automatic ip: policy routing http://www.softpanorama.net/Net/Internet_layer/Routing/policy_routing.shtml

NetworkManagerでデフォルトの設定がおかしくなったとき

The way to use network manager for default network assignment is by checking the 'Use this connection only for resources on its network' option in editing IPv4 routes on all connections you do NOT want to be the default.To do this without …

vino設定

vino-preferences

sshd ポートの設定

【sshd】ポートの設定 pオプション 接続を受け付けるポートの指定(デフォルト=22番). 以下のように複数のポートを受け付けることが可能(sshd の設定ファイルは /etc/ssh/sshd_config). Port 22 #デフォルト Port 10000 #追加分 変更後,sshd を再起…

`require': cannot load such file -- openssl (LoadError)

sudo apt-get install libssl-dev rvm remove 2.0.0 # get rid of unsuccessful installation rvm get head --autolibs=3 # get the latest RVM and build required libs rvm requirements # just in case, install all other required stuff rvm reinstall …

remote lubuntu LXDE session tightvnc vncclient vino

https://help.ubuntu.com/community/VNC/ServersLXDE session automatically after tightvncserver starts to make me able see desktop when connecting to the host via vncclient? http://askubuntu.com/questions/178962/how-to-start-lxde-session-auto…

例外の発生した場所/行番号をメッセージで出力してみる

組み込み変数の$@を使う。begin open("notfound.txt", "r") do |file| puts file.readlines end rescue puts $@ end ファイル名、行数、メソッド名が出力される。morningcoffee.rb:2:in `initialize'

sftp ruby command line

Net::SFTP.start('host', 'username', :password => 'password') do |sftp| # upload a file or directory to the remote host sftp.upload!("/path/to/local", "/path/to/remote") # download a file or directory from the remote host sftp.download!("/p…

stop apport , error with apport-gpu-error-intel.py

Re: Internal error with apport-gpu-error-intel.py If you have no problems with your system then you can disable apport's reports . For one session only sudo service apport stop Permanent gksudo gedit /etc/default/approt and change the enab…

Nokogiri contains

require 'nokogiri'html = ' foo bar 'doc = Nokogiri::HTML(html) doc.at('p:contains("bar")').text.strip => "bar"

ppp pptp /etc/ppp/options DNS設定

/etc/ppp/options に以下を設定しておけば、PPP,PPTP接続時のDNSを設定してくれるms-dns 8.8.8.8 ms-dns 8.8.4.4

Nokogiri/Mechanize エンコード問題で上手くform,field等が見つからないとき

thePage=a.get(href).body.toutf8 dom=Nokogiri::HTML( thePage ) print dom.at('p[property="main_title"]').inner_text print dom.at('input[name="comment"]')['value'] form=dom.at('form[id="toukou"]') Mechanize::Form.new(form,a,a.page){|f| f['dat…

kikenn

sTime = Time.now until chkip=`curl -ss checkip.dyndns.com`.match(/Current\sIP\sAddress:\s(#{IP_Regex})/) or (Time.now-sTime)>3*60 do sleep 1 end

Ethernet 圧着 自作

http://www.geekpage.jp/practical/utp/index.php

Block site host squid

http://askubuntu.com/questions/180941/blocking-multiple-sites-with-etc-hosts http://jaxov.com/2009/09/how-to-block-websites-in-ubuntu-linux/ hosts example127.0.0.1 localhost 192.168.1.199 UbuntuServer 0.0.0.0 r.twimg.com 0.0.0.0 p.twitter.…

ruby gem command

http://docs.rubygems.org/read/chapter/16 http://docs.rubygems.org/read/chapter/2 http://docs.rubygems.org/read/chapter/10

Ubuntu VPN PPTP Client setting

http://www.ubuntugeek.com/howto-configure-pptp-vpn-in-ubuntu-intrepid-and-jaunty.htmlirst you need to install the following packages sudo apt-get install pptp-linux ppp pptpdConfigurationFirst you need to edit /etc/ppp/chap-secrets file su…

Nokogiri/Mechanize Can't find libxml/parser.h

apt-get update sudo apt-get install build-essential sudo apt-get install libxslt-dev libxml2-dev

NX Gnome3 Ubuntu Server 12.04

Ubuntu server 12.10 より上のバージョンだとNXのリドローが上手く行かず、再コネクトするとテキストが見えなくなる。(以下を参照)http://askubuntu.com/questions/198790/nomachine-nx-text-missing-on-all-gtk-interface-unity-and-gnome-classicそこで…

selenium

http://anahorny.blogspot.hk/2011/08/selenium-webdriver-ruby-tutorial.html http://qiita.com/items/9cb81d7a98150ff22f53

“Open As Root” ,“Open terminal here” to Nautilus' Gnome

sudo apt-get install nautilus-open-terminal$ sudo add-apt-repository ppa:nae-team/ppa $ sudo apt-get update && sudo apt-get install nautilus-open-as-root