攻殻程序隊 〜Wizard in the Market〜
デバッグ時に特定のメソッドが呼び出された時のそのメソッドの場所を調べる。
module function Kernel.#set_trace_func
は超便利。
http://doc.okkez.net/static/187/method/Kernel/m/set_trace_func.html
最近の記事の手抜きぶりが半端ないです。申し訳ないです。。
- Comments: 0
- Trackbacks: 0
NeedleをRuby1.9で使とうとしてる。
とりあえずエラー表示の削除はこれ。
http://stackoverflow.com/questions/8890891/needle-definition-context-rb36-warning-undefining-initialize-may-cause-seri
class DefinitionContext
( private_instance_methods +
protected_instance_methods +
public_instance_methods -
[ :instance_eval,
bject_id, :__id__, :__send__, :initialize,
:remove_const, :method_missing, :method, :class, :inspect, :to_s,
:instance_variables, :block_given? ]
).
each { |m| undef_method m }
c:/Ruby192/lib/ruby/gems/1.9.1/gems/needle-1.3.0/lib/needle/thread.rb
Thread.criticalが非推奨になったからなんとかしなきゃいけない。
while (Thread.critical = true; @locked)
whileの中が面白い。@lockedの値だけでループの継続処理の判断を行う。
Thread.criticalはイテレータの繰り返し判断の前に毎度繰り返し処理される。
うーん。
とりあえず暫定処置として、@m = Mutex.new をinitialize に加えて、
thread.critical = trueの部分を @m.lock
thread.critical = falseの部分を @m.unlock に変えたけど、これで正しいかどうかは超不安・・・
これで進めます。
[追記]
thread.rb 全然ダメだったから結構書きなおした。
これで正しいかは不明・・・。
てか、なんでオリジナルのQueryableMutexなんて使おうとしてるのかが分からない。
#–
# =============================================================================
# Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
# All rights reserved.
#
# This source file is distributed as part of the Needle dependency injection
# library for Ruby. This file (and the library as a whole) may be used only as
# allowed by either the BSD license, or the Ruby license (or, by association
# with the Ruby license, the GPL). See the “doc” subdirectory of the Needle
# distribution for the texts of these licenses.
# —————————————————————————–
# needle website : http://needle.rubyforge.org
# project website: http://rubyforge.org/projects/needle
# =============================================================================
#++
require ‘thread’
module Needle
# A subclass of Mutex that allows clients to discover which thread has the
# mutex locked. This is necessary for (among other things) discovering
# cycles in the dependency graph of services.
class QueryableMutex < Mutex
# Create a new unlocked QueryableMutex.
def initialize
super
@@m = Mutex.new #kireek
@@locking_thread = nil
end
# Checks to see if the current thread has the mutex locked, and if it
# does, raises an exception. Otherwise, locks the mutex and sets the
# locking thread to Thread.current.
def lock
return if @@locking_thread == Thread.current
#if @@m.locked?
# raise ThreadError,
# “an attempt was made to reacquire an existing lock ” +
# “(this could happen if you have a circular dependency on a service)”
#end
#while (Thread.critical = true; @locked)
# @waiting.push Thread.current
# Thread.stop
#end
@@m.lock
#if @@m.locked? then
# @@m.lock
#else
# @waiting.push Thread.current
# Thread.stop
#end
@@locking_thread = Thread.current
#Thread.critical = false
self
end
# Attempts to acquire the lock. Returns +true+ if the lock was acquired,
# and +false+ if the mutex was already locked.
def try_lock
result = false
Thread.critical = true
unless @locked
@locked = true
result = true
@@locking_thread = Thread.current
end
#Thread.critical = false
result
end
# Unlocks the mutex and sets the locking thread to +nil+.
def unlock
return unless @@m.locked?
#Thread.critical = true
#begin
# t = @waiting.shift
# t.wakeup if t
#rescue ThreadError
# retry
#end
@@locking_thread = nil
@@m.unlock
#Thread.critical = false
#begin
# t.run if t
#rescue ThreadError
#end
self
end
# Return +true+ if the current thread has locked this mutex.
def self_locked?
@@locking_thread == Thread.current
end
end
end
- Comments: 0
- Trackbacks: 0
Rails3での add_to_base Active Reacord
use model_instance.errors[:base] << “Msg” instead of depracated model_instance.errors.add_to_base(“Msg”) for Rails 3
だそうで、.add_to_baseはdepracatedなので、[:base] << “msg”を使いましょう。
- Comments: 0
- Trackbacks: 0
スワップをイスラミックを使って儲けようと考えている方へ。
- 2012-02-13 (月)
- FX
今気づいたけど、為替ブログ語りながらFXタグがなかった・・・。
話は代わり、本題。
さっき見つけたんですが、これは読んでおいたほうがいいです。
23 : Trader@Live! : 2011/09/14(水) 09:27:08.60 ID:FVApWilu [1/1回発言]
ノーリスクスワップ取りを3年前からやっている者です。やっていたか。Crown Forexの倒産で200万失い。
MarketivaはE-Goldのごたごたに巻き込まれるは、スワップ有になるわ。
各業者のノースワップ口座を開こうと思ったらムスリム証明を求められるわ、
日本人は駄目だと断られ。
やっと、ノースワップの業者を開設したら、ネガティブスワップばかり取っていると判断され
口座を凍結され。
標準でノースワップの業者からは
ACCOUNT FREEZE NOTICEという怖い題で、
I would like to bring to your attention that under our regulatory contract we are obliged to contact our clients and verify their identity,
thus securing our clients safety and preventing cases of fraud,
credit theft and money laundering.
The Finance department would have no other choice but to freeze your account .
と何故かマネロンを理由に口座を凍結され(ノД`)
数々のユダヤ系業者に騙され、俺はもう身も心もお金もぼろぼろ。
400万位何だかんだで消えたかも。FxClearingもカナダに会社があるのに、カナダ人は受け入れておらず、
理由はライセンスを取らなくて済むためと公言している会社…。恐ろしいです…。
- Comments: 0
- Trackbacks: 0
Sakura VPS に Ruby on Rails3 を入れる。
またやることになったのでまとめておく。
ruby-1.9.2-p290.tar.gz をDL&解凍
解凍したディレクトリで
./configure
sudo make
sudo make install
一応、SQLiteも入れる
sqlite-autoconf-3071000.tar.gzをDL&解凍
解凍したディレクトリで
./configure
sudo make
sudo make install
sudo apt-cache search ^build-essential$
sudo apt-get install build-essential
sudo ldconfig
sudo gem i sqlite3
sudo gem i mysql2
sudo gem i rails
- Comments: 0
- Trackbacks: 0
複数ドメインを同一IPアドレスでapache上で管理する
http://sakaguch.com/pastbbs/0033/B0016691.html
www.を外した時と付けた時でリダイレクト先が変わったので困った。
ServerName homeserver-streaming.com
ServerAlias homeserver-streaming.com *.homeserver-streaming.com
のように、ServerNameだけじゃなくてAliasも必要
これで予期せぬリダイレクトは解消した。
- Comments: 0
- Trackbacks: 0
validateをDBにTableがないときに使いたければ、ActiveFormを使う。
gem install rails3-active_form
Gemfileにも
gem “rails3-active_form”, “~> 2.0.0″
modelフォルダ下に新しくmodelファイルの作成
request.rbとかそんな感じ。
request.rbの中身
require “active_form”
class Request < ActiveForm
attr_accessor :name, :mladdr, :phone, :subject, :body
end
本来テーブルから取得するはずの変数をattr_accessorで定義してあげれば、
controllerでModel名でnewしてあげれば、form_forメソッドが使えました。
日本語化のために・・・。
ActiveFormの子クラスに下記を追加
#バリデーションエラーメッセージ内のプロパティ名を日本語にマッピングします。
class << self
HUMANIZED_ATTRIBUTE_KEY_NAMES = {
"name" => “お名前”,
:name => “お名前”
}def human_attribute_name(attribute_key_name, options = {})
HUMANIZED_ATTRIBUTE_KEY_NAMES[attribute_key_name] || super
end
end
ネット上のソースだと、human_attribute_nameがrails3.*よりエラーになるからoption={}が必要だったり、
“name”と:nameの両方を反映させなきゃいけなかったりと超手間取ったけどなんとか解決。
:nameがエラーメッセージ側、”name”がラベル側に反映する。
- Comments: 0
- Trackbacks: 0
ActionView::Template::Error (application.css isn’t precompiled):
productionで起動するとキャッシュの作成がまったく行われないから、
手動でやってやる必要があるということだけ。
rake assets:precompile
ってすればおk!
- Comments: 0
- Trackbacks: 0
[作業メモ] Sakura VPS Serverにsqlite3の最新版を入れる際に。
www.sqlite.org
からソースファイルダウンロードして解答
解答したディレクトリで
./configure
sudo make
sudo make install
sqlite3 -version
ってすると、
SQLite header and source version mismatch
勘弁して欲しかったけど、
sudo apt-cache search ^build-essential$
sudo apt-get install build-essential
sudo ldconfig
ってやれば解決した。
- Comments: 0
- Trackbacks: 0
[ただのメモ]Mysqlの外部からの接続
- 2012-02-08 (水)
- プログラミング
mysqlは、ポート開放、ユーザ権限の拡張以外に、skip-networking, bind-addressを無効にしてないと、外部から接続できない。
- Comments: 0
- Trackbacks: 0

