2014年12月30日火曜日

Python: Use MySQL

mysql.connector

↓mysql.connector
http://dev.mysql.com/downloads/connector/python/

$ python
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysql.connector
c>>> cnx = mysql.connector.connect(user='☆☆☆' , password='☆☆☆', host='☆☆☆', database='☆☆☆' )
>>> cnx.close()



Python: Import to Rails DB.

wrote by python.

 81 d = datetime.datetime.today()
 82
 83 i = 0
 84 for data in line:
 85      if gi.record_by_name(data["IPADDRESS"]) != None:
 86         i = i+1
 87         ipaddress = data["IPADDRESS"]
 88         latitude = gi.record_by_name(data["IPADDRESS"])["latitude"]
 89         longitude =  gi.record_by_name(data["IPADDRESS"])["longitude"]
 90
 91         add_RemoteData = ( "INSERT INTO geoips "
 92                 "(created_at,updated_at,ipaddress,latitude,longitude) "
 93                 "VALUES(%s,%s,%s,%s,%s)")
 94         data_RemoteData = ( d, d, ipaddress, latitude, longitude )
 95         cursor.execute(add_RemoteData,data_RemoteData)

Tor Exit Node

Tor Exit Node .




https://hhoshina.info/map/index

Rails: Passenger ver.4.0.56

When running Passenger under Ruby 2.2, the following error occurs:
   passenger_native_support.so: undefined symbol: rb_thread_blocking_region
There have probably been large changes with regard to thread handling. 

https://github.com/phusion/passenger/issues/1314  

2014年12月28日日曜日

Ruby: version 2.2.0 Released !

 Ruby ver 2.2.0 installed.

$ sudo ☆☆☆ install libffi-devel
$ gem source --add https://tokyo-m.rubygems.org/

$ git clone https://github.com/rubygems/rubygems
$ cd rubygems
$ sudo ruby setup.rb
$ gem -v
2.4.5

$ cd /****/rbenv/plugins/ruby-build
$ git pull origin master

$ rbenv install --list
...
2.2.0
...
$ sudo  CONFIGURE_OPTS="--disable-install-rdoc --enable-shared" rbenv install 2.2.0
$ rbenv versions
$ sudo rbenv global 2.2.0
$ ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005)

$ sudo gem install bundler







2014年12月23日火曜日

Rails: rails_admin

rails_admin installed.





$ vim Gemfile
---
gem 'rails_admin'
---

$ bundle install
$ rails g rails_admin:install
$ rake db:migrate
$ vim config/routes.rb
 ----
  2   devise_for :admin_users
  3   mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
 ---

Japanese
https://gist.github.com/mshibuya/1662352#file-rails_admin-ja-yml

2014年12月21日日曜日

Rails: UpGrade

Ruby on Rails Upgrade.


$ gem install rails --no-ri --no-rdoc                                    

$ vim Gemfile

$ bundle update

$ bundle install

$ bundle exec rake rails:update

     overwrite...
   routes.rb [no]
      application.rb [no]
      secrets.yml [no]
      production.rb [no]
      bin/rails [Yes]
      bin/rake [Yes]

$bundle exec rspec spec/

Rails: ver.4.2.0 release

development server

$ rails s -b 0.0.0.0

2014年12月13日土曜日

2014年12月6日土曜日

Ruby On Rails: Basic Auth

    def basic_auth
             authenticate_or_request_with_http_basic do |user,pass|
                  user = "☆☆" && pass == "☆☆"
              end
     end


2014年12月2日火曜日

Ruby On Rails: API Create

API Created.

$ cat app/controllers/application_controller.rb
......
protect_from_forgery with: : null_session
......

$ cat  ☆☆_controller.rb
...... 
  def ☆☆_params
   #params.require(:☆☆).permit(:☆☆, :☆☆)
   params.permit(:☆☆, :☆☆)
  end
...... 



fd-find

 $ sudo apt install fd-find $ fdfind 石