2015年12月31日木曜日

DeepLearning: TensorFlow

$ sudo apt-get install python-dev
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.6.0-cp27-none-linux_x86_64.whl
$ cd
$ git clone --recurse-submodules https://github.com/tensorflow/tensorflow
$ cd tensorflow/tensorflow/examples/tutorials/mnist/
$ python fully_connected_feed.py

$ tensorboard --port=6879 --logdir=data




2015年12月26日土曜日

Ruby : ver.2.3.0 released

$ cd /****/rbenv/plugins/ruby-build
$ sudo git pull origin master
$ rbenv install --list
$ sudo CONFIGURE_OPTS="--disable-install-rdoc --enable-shared" rbenv install 2.3.0
$ rbenv versions
* 2.2.3 (set by /***/rbenv/version)

  2.3.0
$ sudo rbenv global 2.3.0
$ ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]

2015年7月14日火曜日

Deep Learning: Test of "Deep Dream"

Success !

Test of "Deep Dream"

$ sudo yum install nginx
$ git clone https://github.com/VISIONAI/clouddream.git
$ sudo systemctl stop httpd
$ cd clouddream
$ sudo ./start.sh
$ sudo ./stop.sh
$ sudo ./enter.sh

root@429d26ef5fb0:/# cd /opt/deepdream
root@429d26ef5fb0:/# python deepdream.py
.....
.....
3 2 inception_4c/output (300, 400, 3)
3 3 inception_4c/output (300, 400, 3)
3 4 inception_4c/output (300, 400, 3)
3 5 inception_4c/output (300, 400, 3)
3 6 inception_4c/output (300, 400, 3)
3 7 inception_4c/output (300, 400, 3)
root@429d26ef5fb0:/# exit
$ sudo ./start.sh

show http://hhoshina.info/

before

after


2015年7月12日日曜日

Docker : Docker for mac

*** init
$ boot2docker delete
$ boot2docker init
$ boot2docker up
$ boot2docker ssh

*** docker
$ sudo docker pull cordea/pycaffe
$ docker images
$ docker run -it cordea/pycaffe:latest bash
ubuntu#
ctrl+p ctrl+q

docker@...$ docker ps
CONTAINER ID        IMAGE                   COMMAND             CREATED             STATUS              PORTS               NAMES

c003803c258f        cordea/pycaffe:latest   "bash"              6 minutes ago       Up 6 minutes  

docker@...$ docker attach c003803c258f

*** docker exit and restart
ubuntu# exit
docker@...$ exit
docker@...$ docker ps -a
CONTAINER ID        IMAGE                   COMMAND             CREATED             STATUS                     PORTS               NAMES               SIZE
f650703ece0b        cordea/pycaffe          "bash"              2 hours ago         Exited (0) 5 seconds ago                       hungry_darwin       37.7 MB (virtual 3.159 GB)

c003803c258f        cordea/pycaffe:latest   "bash"              2 hours ago         Exited (0) 2 hours ago                         hungry_mestorf      374 B (virtual 3.122 GB)

docker@...$ docker commit -m "hhoshina-pyaffe" f650703ece0b hhoshina-pycaffe 1.1

$ boot2docker ssh
$ docker images

Deep Learning : caffe

Test of Deep Learning Software .

$ sudo docker pull cordea/pycaffe
$ sudo docker images
$ sudo docker run -it cordea/pycaffe:latest bash

# cd /home/pycaffe/caffe
# make runtest
# make distribute
# pip install -r /home/pycaffe/caffe/distribute/python/requirements.txt
# su pycaffe
pycaffe@f650703ece0b:~/caffe$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe
libdc1394 error: Failed to initialize libdc1394




2015年5月13日水曜日

An Open Intelligent Personal Assistant

Sirius implements the core functionalities of an IPA including speech recognition, image matching, natural language processing and a question-and-answer system. 

http://sirius.clarity-lab.org/

Sirius has been tested on Ubuntu 12.04 and 14.04. 

2015年5月10日日曜日

ruby: ver.2.2.2 update

$ sudo rbenv global 2.2.2
$ sudo gem install bundler
$ sudo rbenv rehash
$ sudo gem install passenger
$ sudo passenger-install-apache2-module
$ bundle update
$ bundle install
$ bundle exec rake rails:update
$ bundle exec rspec

2015年3月23日月曜日

sh: search ipadresses

$ for((i=1;i<255;i++))
> do
> ping -c 1 -W 1 ☆.☆.☆.$i | grep '64 bytes'
> done

Python: tips

>>> 'abcdefg'[0]
'a'
>>> 'abcdefg'[-1]
'g'
>>> 'abcdefg'[0:3]
'abc'
>>> 'abcdefg'[3:-1]
'def'
>>> 'abcdefg'[3:]
'defg'
>>> 'abcdefg'[:3]
'abc'
>>> 'abcdefg'[1::2]
'bdf'
>>> 'abcdefg'[::-1]
'gfedcba'


>>> '83 69 67 79 78'.split()
['83', '69', '67', '79', '78']
>>> '53:45:43:43:4f:4e'.split(':')
['53', '45', '43', '43', '4f', '4e']


>>> ' '.join(['83', '69', '67', '79', '78'])
'83 69 67 79 78'
>>> ':'.join(['53', '45', '43', '43', '4f', '4e'])
'53:45:43:43:4f:4e'


>>> import hashlib
>>> hashlib.md5('abc').hexdigest()
'900150983cd24fb0d6963f7d28e17f72'
>>> hashlib.sha1('abc').hexdigest()
'a9993e364706816aba3e25717850c26c9cd0d89d'
>>> hashlib.sha256('abc').hexdigest()
'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad'
>>> hashlib.sha512('abc').hexdigest()
'ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f'




2015年3月8日日曜日

MongoDB: Python: find by descending

import pymongo

 conn = pymongo.Connection()
 db = conn["apache"]
 coll = db["access"]

for data in coll.find().sort([('time',pymongo.DESCENDING)]):



2015年3月7日土曜日

fluentd: Install for getting httpd access log

(1) MongoDB Install

(2) fluentd install

 30 $ sudo vim /etc/☆/td-agent.conf
 32   <source>
 33     type tail
 34     format apache
 35     path /☆/httpd/access_log
 36     pos_file /☆/apache2.access_log.pos
 37     tag mongo.apache.access
 38   </source>
 39
 40   <match mongo.*.*>
 41   # plugin type
 42   type mongo
 43   # mongodb db + collection
 44   database apache
 45   collection access
 46   # mongodb host + port
 47   host localhost
 48   port ☆
 49   # interval
 50   flush_interval 10s
 51   # make sure to include the time key
 52   include_time_key true
 53   </match>


2015年3月4日水曜日

Mobile-Tools

https://hhoshina.info/p/Mobile-Tools.html

Ruby: 2.2.1 Released !

  $ cd /****/rbenv/plugins/ruby-build                                        
  $ git pull origin master
 
  $ rbenv install --list
  ...
  2.2.1
  ...
  $ sudo  CONFIGURE_OPTS="--disable-install-rdoc --enable-shared" rbenv instal    l 2.2.1
  $ rbenv versions
 $ sudo rbenv global 2.2.1
 $ ruby -v
 ruby 2.2.1p85 (2015-02-26 revision 49769)

 $ sudo gem install bundler

 $ sudo gem install passenger

 $ sudo passenger-install-apache2-module

 $ cd /☆☆/rails_application

$ bundle update

2015年2月25日水曜日

Rails: Twitter Auth by 0Auth (detail)

$ vim Gemfile
 10
 11 gem 'omniauth'
 12 gem 'omniauth-twitter'
 13 gem 'twitter'
 14

$ vim config/initializers/omniauth.rb
 17 
 18 Rails.application.config.middleware.use OmniAuth::Builder do
 19   provider :twitter, 'TWITTER_CONSUMER_KEY', 'TWITTER_CONSUMER_SECURET',
 20         :request_path => 'sign_in', :callback_path => 'sign_in/callback'
 21 end
 22 

$ vim config/routes.rb
 25 
 26 get '/auth/:provider/callback'=>'sessions#create'
 27 

$ rails g controller sessions

$ vim sessions_controller.rb 
 32 
 33 class SessionsController < ApplicationController                            
 34   def create
 35    raise request.env["omniauth.auth"].to_yaml
 36   end
 37 end
 38 

$ rails g model usertwitter provider:string uid:string name:string
  
$ vim controller/usertwitter.rb
 50   class SessionsController < ApplicationController                                
 51       def create
 52           auth = request.env["omniauth.auth"]
 53           user = Usertwitter.find_by_provider_and_uid(auth["provider"], au    th["uid"]) 
 54           || Usertwitter.create_with_omniauth(auth)
 55           session[:user_id] = user.id
 56   
 57          redirect_to '/' , :notice => "Signed in!"
 58       end
 59   end

$ vim model/usertwitter.rb
 63     def self.create_with_omniauth(auth)
 64      create!do |usertwitter|
 65        usertwitter.provider = auth["provider"]
 66        usertwitter.uid = auth["uid"]
 67        usertwitter.name = auth["name"]
 68      end
 69    end

$ vim controllers/twines.rb
 80     before_filter :authenticate
 81 
 82       def authenticate
 83          auth = request.env["omniauth.auth"]
 84           redirect_to '/' unless current_user
 85      end

 ***Twitter Service Setting
 42 https://dev.twitter.com/
 43 Product → Login with Twitter
 44 Manage Your Apps






2015年2月22日日曜日

Rails: Twitter Auth

Twitter Auth by 0Auth





File..

Gemfile
config/initializes/omniauth.rb
config/routes.rb
controllers/session_controller.rb
controllers/user.rb

2015年2月11日水曜日

Rails: layouts/application rendering

$ vim environments/production.rb

 33   config.assets.compress = true
 34   config.assets.debug = false

$ rake assets:clean RAILS_ENV=production
$ rake assets:precompile RAILS_ENV=production





Rails: add_index(DB)

$ rails g migration add_index_geoips
$ vim 20150211110932_add_index_geoips.rb

  1 class AddIndexGeoips < ActiveRecord::Migration                            
  2   def change
  3     add_index :geoips,[:id , :ipaddress , :latitude , :longitude]
  4   end
  5 end

$ rake db:migrate



2015年2月10日火曜日

Rails: CanCan::AccessDenied

$ vim controllers/application_controller.rb 

  1 class ApplicationController < ActionController::Base                   
  5 
  6   rescue_from CanCan::AccessDenied do |exception|
  7     redirect_to '/' , :alert => exception.message
  8   end
  9 
 10 end

2015年2月9日月曜日

Rails: devise install on rails_admin

■ devise user add

$ rails g devise:install
$ vim ../config/environments/development.rb
   config.action_mailer.default_url_options = { host: 'hhoshina.info', port: 3000 }  ← add
   end

$ rails g devise user
$ rake db:migrate

■new user add ( on rails_admin website )




■  add admin column to user

  $ rails g migration AddAdminToUser user
  $ vim 20150209134227_add_admin_to_user.rb
   -----
  1 class AddAdminToUser < ActiveRecord::Migration
  2   def change
  3     add_column :users, :admin, :boolean      <--- Change                                  
  4   end
  5 end
  -----

■ admin flag add ( on rails_admin website)

■ cancan config
 $ rails g cancan:ability
 $ vim model/ability.rb
  --------
  1 class Ability                                                                
  2     include CanCan::Ability
  3
  4     def initialize(user)
  5         if user && user.admin?
  6             can :access, :rails_admin
  7             can :manage, :all
  8         end
  9     end
 10 end
 --------

■rails_admin config
 $ vim initializers/rails_admin.rb

 12 ## == Devise ==
 13    config.authenticate_with do |controller|
 14     warden.authenticate! scope: :user
 15    end
 16    config.current_user_method(&:current_user)
 17 
 18   ## == Cancan ==
 19    config.authorize_with :cancan






Rails: devise destory

$ rails destroy devise:install
      remove  config/initializers/devise.rb
      remove  config/locales/devise.en.yml

$ rails destroy devise User
      invoke  active_record
      remove    db/migrate/20150207125104_devise_create_users.rb
      remove    app/models/user.rb
      invoke    rspec
      remove      spec/models/user_spec.rb
       route  devise_for :users

$ rake db:migrate


2015年2月8日日曜日

Rails: Passenger debug



if show error message , you check ↓

$ tail error_log
-------
[ 2015-02-07 23:43:10.2449 1276/7f1a10a6b700 Pool2/Implementation.cpp:287 ]: Could not spawn process for application /var
/: An error occured while starting up the preloader.
  Error ID: 9a4609eb
  Error details saved to: /tmp/passenger-error-mWzkyA.html
-------
$ view passenger-error-mWzkyA.html

in `method_missing'
  /app/models/user.rb:4:in `<class:User>'
  /app/models/user.rb:1:in `<top (required)>'  ← code check !





2015年2月1日日曜日

Rails: Gemfile , gem delete

exec.

$ vim Gemfile
---
gem 'paperclip'
---

$ sudo gem uninstall paperclip

$ vim Gemfile
---
gem 'paperclip' <---delete
---


2015年1月5日月曜日

Ruby: rubygems-update

$ sudo gem update

$ sudo gem install rubygems-update
    Fetching: rubygems-update-2.4.5.gem (100%)
    Successfully installed rubygems-update-2.4.5
    Parsing documentation for rubygems-update-2.4.5
    Installing ri documentation for rubygems-update-2.4.5
    Done installing documentation for rubygems-update after 1 seconds
    1 gem installed

$ sudo update_rubygems
    RubyGems 2.4.5 installed
    Parsing documentation for rubygems-2.4.5
    Installing ri documentation for rubygems-2.4.5

$ sudo gem update

2015年1月3日土曜日

Rails: Passenger ver.4.0.57 Released

Passenger ver .4.0.56 on ruby 2.2.0 , don't work , because of BUG.
Passenger ver.4.0.57 on ruby 2.2.0 , can WORK. Success.

$ sudo rbenv global 2.2.0

$ sudo gem install passenger
   Fetching: passenger-4.0.57.gem (100%)
   Building native extensions.  This could take a while...
   Successfully installed passenger-4.0.57
   Parsing documentation for passenger-4.0.57
   Installing ri documentation for passenger-4.0.57
   Done installing documentation for passenger after 10 seconds
   1 gem installed

$ sudo passenger-install-apache2-module

$ cd /☆☆/rails_application
$ bundle update







2015年1月1日木曜日

GoLang: Use Mysql

  1 package main                                                                                      
  2
 21 import "fmt"
 22 import "log"
 23 import _ "github.com/go-sql-driver/mysql"
 24 import "database/sql"
 25
 26
 29 func main() {
 30     db, _ := sql.Open("mysql", "☆☆:☆☆☆@/☆☆☆☆")
 31
 32     var name string
 33
 34     if err := db.QueryRow("SELECT ipaddress FROM geoips WHERE id = ☆☆").Scan(&name); err != nil {
 35         log.Fatal(err)
 36     }
 37
 38     fmt.Println(name)
 39 } 

fd-find

 $ sudo apt install fd-find $ fdfind 石