kaku's blog
RSS Feed

Articles

  • database commond

    PostgreSQL

    create user

    CREATE USER davide WITH PASSWORD 'jw8s0F4';

    Read More »

  • ssh公開鍵権限設定

    client

    cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
    chmod 700 ~/.ssh
    chmod 600 ~/.ssh/authorized_keys

    Read More »

  • Linux 環境変数メモ

    bash

    .bash_profileは、ログイン時だけに実行される設定ファイルだ。ここでは、環境変数の設定などが行われる(内容はディストリビューションによって異なる)。

    Read More »

  • rspec rails

    $ echo 'gem "rspec-rails", :group => [:development, :test]' >> Gemfile
    $ rails generate rspec:install
    //test
    $ rake spec
    $ rails generate scaffold Widgets name:string
          invoke    rspec
          create      spec/models/widget_spec.rb
          invoke    rspec
          create      spec/controllers/widgets_controller_spec.rb
          create      spec/views/widgets/edit.html.erb_spec.rb
          create      spec/views/widgets/index.html.erb_spec.rb
          create      spec/views/widgets/new.html.erb_spec.rb
          create      spec/views/widgets/show.html.erb_spec.rb
          create      spec/routing/widgets_routing_spec.rb
          invoke      rspec
          create        spec/requests/widgets_spec.rb
          invoke      rspec
          create        spec/helpers/widgets_helper_spec.rb
    $ rails g model widge
          invoke    rspec
          create      spec/models/widge_spec.rb
          create      app/assets/stylesheets/mycontroller.css.scss
    $ rails g controller widget
          invoke  rspec
          create    spec/controllers/widget_controller_spec.rb
          invoke    rspec
          create      spec/helpers/widget_helper_spec.rb
    $ rails g integration_test widget
          invoke  rspec
          create    spec/requests/widgets_spec.rb
    $ rails generate scaffold_controller Foos
          invoke  rspec
          create    spec/controllers/foos_controller_spec.rb
          create    spec/views/foos/edit.html.erb_spec.rb
          create    spec/views/foos/index.html.erb_spec.rb
          create    spec/views/foos/new.html.erb_spec.rb
          create    spec/views/foos/show.html.erb_spec.rb
          create    spec/routing/foos_routing_spec.rb
          invoke    rspec
          create      spec/requests/foos_spec.rb
          invoke  helper
          create    app/helpers/foos_helper.rb
          invoke    rspec
          create      spec/helpers/foos_helper_spec.rb

    Read More »

  • Metaprogramming Ruby

    第一章,object model

    class与module

    1. class是object,class name是定数。object的instance value住在object里面,object的method住在class里面。
    2. class只是一个拥有allocate, new, superclass这三个函数的module。那么什么时候用class,什么时候用module呢?一般当要被include的时候用module(或者当作namespace使用的时候),要生成或者继承的时候使用class。
    String.instance_methods == 'abc'.methods # => true
    Class.instance_methods(false)            # => [:allocate, :new, :superclass]
    # class
    'hello'.class # => String
    String.class  # => Class
    Class.class   #=> Class
    # superclass
    Myclass.superclass        # => Object
    String.superclass         # => Object
    Class.superclass          # => Module
    Module.superclass         # => Object
    Object.superclass         # => BasicObject
    BasicObject.superclass    # => nil

    Read More »