我有一个类(Foo)延迟加载一个名为(Bar)的属性.您的首选方法是防止未初始化后备区域的错误使用(由于智能或缺乏经验的员工)?
我可以想到3个选项:
class Foo {
// option 1 - Easy to use this.bar by mistake.
string bar;
string Bar {
get {
// logic to lazy load bar
return bar;
}
}
// option 2 - Harder to use this._bar by mistake. It is more obscure.
string _bar2;
string Bar2 {
get {
// logic to lazy load bar2
return _bar2;
}
}
//option 3 - Very hard to use the backing field by mistake.
class BackingFields {
public string …Run Code Online (Sandbox Code Playgroud) 我在源文件中有2个方法:
def Foo
puts "hello"
puts "bar"
end
def Bar
puts "hello"
puts "bar"
end
Run Code Online (Sandbox Code Playgroud)
我想交换方法的顺序,所以Bar是第一个.
假设光标在d in上def Foo,简单的方法是:
shift v -> jjjj -> d -> jjj -> p -> O -> esc
但是这种感觉有点长,并且不适合任意长的方法:
在Vim中最有效的方法是什么?击键明智?
编辑 请记住,我希望解决方案能够解决方法在大类环境中的情况,因此G最好避免使用
我使用宝石思考狮身人面像:
sudo gem install freelancing-god-thinking-sphinx \
--source http://gems.github.com
Run Code Online (Sandbox Code Playgroud)
所以:
require 'vendor/plugins/thinking-sphinx/recipes/thinking_sphinx'
Run Code Online (Sandbox Code Playgroud)
这是规定的网站上不起作用.
在使用gem时,如何在deploy.rb文件中包含capistrano思考sphinx任务?
编辑
添加: require 'thinking_sphinx/deploy/capistrano'
给我:
/usr/lib/ruby/gems/1.8/gems/freelancing-god-thinking-sphinx-1.1.12/lib/thinking_sphinx/deploy/capistrano.rb:1: undefined method `namespace' for main:Object (NoMethodError)
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /usr/lib/ruby/gems/1.8/gems/capistrano-2.5.8/lib/capistrano/configuration/loading.rb:152:in `require'
是否有.NET 4.0版本的mdbg托管调试器源?
我需要移植我的CPU分析器,并且ICorDebug在.NET 4.0中有所改变.
它应该在这个链接:
http://www.microsoft.com/downloads/en/details.aspx?familyid=E59C3964-672D-4511-BB3E-2D5E1DB91038&displaylang=en
"假定"是一个有效的词!
有任何想法吗?
微软是删除它还是意外破坏了链接?
我正在尝试使用以下命令安装 gem dm-mysql-adapter:
gem install dm-mysql-adapter -- --with-mysql-config=/usr/bin/mysql
--with-mysql-lib=/usr/lib/mysql
Run Code Online (Sandbox Code Playgroud)
并得到了这个结果:
构建原生扩展。这可能需要一段时间...
错误:安装 dm-mysql-adapter 时出错:
错误:无法构建 gem 本机扩展。
/usr/local/bin/ruby extconf.rb --with-mysql-config=/usr/bin/mysql
--with-mysql-lib=/usr/lib/mysql
*** extconf.rb 失败 ***
由于某种原因无法创建 Makefile,可能缺少
必要的库和/或头文件。检查 mkmf.log 文件以获取更多信息
细节。您可能需要配置选项。
提供的配置选项:
--with-opt-dir
--没有选择目录
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/bin/ruby
--with-mysql-config
extconf.rb:43:in `': nil:NilClass 的未定义方法 `split'
(无方法错误)
Gem 文件将保持安装在
/usr/local/lib/ruby/gems/1.9.1/gems/do_mysql-0.10.2 用于检查。
结果记录到
/usr/local/lib/ruby/gems/1.9.1/gems/do_mysql-0.10.2/ext/do_mysql/gem_make.out
有没有人遇到同样的问题?我该怎么做才能解决这个问题?谢谢!
我很想知道 C# .net 中何时使用 STA/MTA?
using (ManualResetEventSlim mre = new ManualResetEventSlim(false))
{
Thread _STAThread = new Thread(new ThreadStart(() =>
{
globalComObject = new ComClass();
mre.Set();
try
{
Thread.CurrentThread.Join();
}
catch (ThreadAbortException)
{ }
}));
_STAThread.SetApartmentState(ApartmentState.STA);
_STAThread.IsBackground = true;
_STAThread.Start();
mre.Wait();
}
Run Code Online (Sandbox Code Playgroud) 我今天有一种情况,我希望在迁移中向表中添加部分postgres索引.当然,这种东西在轨道使用中是不可能的add_index(它将来一段时间)
所以,我被迫execute在我的迁移中使用语句.
现在,schema.rb在顶部有这个评论:
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
Run Code Online (Sandbox Code Playgroud)
不幸的是,如果我有任何自定义DML,这个execute声明schema.rb …
我正在尝试为textarea设置自定义工具栏,我有以下内容
HTML:
<div id="main">
<div id="toolbar"></div>
<textarea></textarea>
</div>
Run Code Online (Sandbox Code Playgroud)
css:
#main {
background-color: #ddd;
height: 400px;
width: 400px;
position: relative;
}
#toolbar {
background-color: #444;
height: 40px;
color: white;
}
textarea {
outline: none;
border: none;
border-left: 1px solid #777;
border-right: 1px solid #777;
border-bottom: 1px solid #777;
margin: 0;
position: absolute;
top: 40px;
bottom: 0;
left: 0;
right: 0;
}
Run Code Online (Sandbox Code Playgroud)
它的工作方式与我在Chrome中的预期完全相同,但在firefox中,即文本区域不占用div中的所有可用空间.
如何设置它以使工具栏在div的顶部占用40px,并且textarea消耗所有其余高度.
我正在动态调整这个东西,所以不能使用textrea的"px"高度或宽度.
Codepen:http://codepen.io/anon/pen/pDgvq