~/techlog/ -3ページ目

オブジェクトリテラル変数の作成


●オブジェクトリテラルの呼ばれる側
var msgobj = {
msg1: "アサヒ",
msg2: "キリン",
msg3: "グリコ",
msg4: "ドコモ",
msg5: "ロッテ",
msg6: "カゴメ",
msg7: example = {
aa1: "あ",
aa2: "い",
aa3: "う",
},
msg8: "や",
};

●呼び出す側
function checkData () {
var i, d;
for(i=0; i<5; i++){
d = msgobj;
alert( eval("d.msg" + [i+1]) );
}
alert( msgobj.msg7.aa1 );
alert( msgobj.msg7.aa3 );
alert( msgobj.msg8 );
}



かなり無理やりなことやってるけど。


ServarmansVPS導入

DTIのServermansVPSの490円のプランに契約した。

たまたま最初に契約したプロバイダがDTIでそれ以来の付き合いなので

初期申し込みから5分かからず専用サーバが導入完了!(笑)



いちばんシンプルで何も入ってないサーバプランを契約

で、色々見てみた・・・・・




ほんと何も入ってない(笑)

yum groupinstall とか使って

CentOSのパッケージをインストールしないとだめですね。



でもお手軽でサーバ開設できたのでワクワクです。

これからサーバ構築してWebサイト開設して

Webサービスを何か始めます(笑)。


Rubyの変数・定数の種類いろいろ

●Rubyの変数いろいろ

・変数の宣言は必要ない(らしい。たぶん・・・)

■ 小文字aからz か、_ で始まる → ローカル変数
(例)var1
最初に宣言されたブロック内だけ有効。
ブロックとはなんだろう?

■ @から始まる → インスタンス変数
(例)@var1

■ @@から始まる → クラス変数
(例)@@var1

■ $から始まる → グローバル変数
(例)$var1
どこでも使える変数

■ 大文字AからZで始まる → 定数
(例)Var1
初期化した後にも代入できるが初期化の後の代入はWarningが出る(らしい)

rakeのコマンド一覧

rakeのコマンド一覧を確認したい時

rake --task
って打つと一覧が表示される。こんな感じで・・・

バージョンによっても細かく違いがあるからこれが全てと信じないように。
rake db:abort_if_pending_migrations # Raises an error if there are pending migrations
rake db:charset # Retrieves the charset for the current environment's database
rake db:collation # Retrieves the collation for the current environment's database
rake db:create # Create the database defined in config/database.yml for the current RAILS_ENV
rake db:create:all # Create all the local databases defined in config/database.yml
rake db:drop # Drops the database for the current RAILS_ENV
rake db:drop:all # Drops all the local databases defined in config/database.yml
rake db:fixtures:identify # Search for a fixture given a LABEL or ID.
rake db:fixtures:load # Load fixtures into the current environment's database.
rake db:migrate # Migrate the database through scripts in db/migrate and update db/schema.rb by invoking db:schema:dump. Target specific version with VERSION=x. Turn off output with VERBOSE=false.
rake db:migrate:down # Runs the "down" for a given migration VERSION.
rake db:migrate:redo # Rollbacks the database one migration and re migrate up.
rake db:migrate:reset # Resets your database using your migrations for the current environment
rake db:migrate:up # Runs the "up" for a given migration VERSION.
rake db:reset # Drops and recreates the database from db/schema.rb for the current environment and loads the seeds.
rake db:rollback # Rolls the schema back to the previous version.
rake db:schema:dump # Create a db/schema.rb file that can be portably used against any DB supported by AR
rake db:schema:load # Load a schema.rb file into the database
rake db:seed # Load the seed data from db/seeds.rb
rake db:sessions:clear # Clear the sessions table
rake db:sessions:create # Creates a sessions migration for use with ActiveRecord::SessionStore
rake db:setup # Create the database, load the schema, and initialize with the seed data
rake db:structure:dump # Dump the database structure to a SQL file
rake db:test:clone # Recreate the test database from the current environment's database schema
rake db:test:clone_structure # Recreate the test databases from the development structure
rake db:test:load # Recreate the test database from the current schema.rb
rake db:test:prepare # Check for pending migrations and load the test schema
rake db:test:purge # Empty the test database
rake db:version # Retrieves the current schema version number
rake doc:app # Build the RDOC HTML Files
rake doc:clobber_app # Remove rdoc products
rake doc:clobber_plugins # Remove plugin documentation
rake doc:clobber_rails # Remove rdoc products
rake doc:guides # Generate Rails guides
rake doc:plugins # Generate documentation for all installed plugins
rake doc:rails # Build the RDOC HTML Files
rake doc:reapp # Force a rebuild of the RDOC files
rake doc:rerails # Force a rebuild of the RDOC files
rake gems # List the gems that this rails application depends on
rake gems:build # Build any native extensions for unpacked gems
rake gems:build:force # Force the build of all gems
rake gems:install # Installs all required gems.
rake gems:refresh_specs # Regenerate gem specifications in correct format.
rake gems:unpack # Unpacks all required gems into vendor/gems.
rake gems:unpack:dependencies # Unpacks all required gems and their dependencies into vendor/gems.
rake log:clear # Truncates all *.log files in log/ to zero bytes
rake middleware # Prints out your Rack middleware stack
rake notes # Enumerate all annotations
rake notes:custom # Enumerate a custom annotation, specify with ANNOTATION=WTFHAX
rake notes:fixme # Enumerate all FIXME annotations
rake notes:optimize # Enumerate all OPTIMIZE annotations
rake notes:todo # Enumerate all TODO annotations
rake rails:freeze:edge # Lock to latest Edge Rails, for a specific release use RELEASE=1.2.0
rake rails:freeze:gems # Lock this application to the current gems (by unpacking them into vendor/rails)
rake rails:template # Applies the template supplied by LOCATION=/path/to/template
rake rails:unfreeze # Unlock this application from freeze of gems or edge and return to a fluid use of system gems
rake rails:update # Update both configs, scripts and public/javascripts from Rails
rake rails:update:application_controller # Rename application.rb to application_controller.rb
rake rails:update:configs # Update config/boot.rb from your current rails install
rake rails:update:generate_dispatchers # Generate dispatcher files in RAILS_ROOT/public
rake rails:update:javascripts # Update your javascripts from your current rails install
rake rails:update:scripts # Add new scripts to the application script/ directory
rake routes # Print out all defined routes in match order, with names.
rake secret # Generate a crytographically secure secret key.
rake stats # Report code statistics (KLOCs, etc) from the application
rake test # Run all unit, functional and integration tests
rake test:benchmark # Run tests for benchmarkdb:test:prepare / Benchmark the performance tests

gem の状況確認

Rubyとはお題が違ってるかもしれませんが…

gem でのインストール済みライブラリを確認しようと思ってたら

gem
server
でwebサーバが起動出来て、

http://(起動ホスト名):8808/
にアクセスすると、いろんなことが確認できちゃう。

すげー。