Zeus gem https://github.com/burke/zeus在MacOSX上按预期工作,但是,在Linux机器上它显示了所描述的问题(和未解决的):https://github.com/burke/zeus/issues/237
使用:
终端:"zeus start"短暂地给出"退出状态1",然后彩色终端界面向下移动一行并且它挂起,所有行"等待"(黄色).
终奌站:
sudo apt-get install golang
Run Code Online (Sandbox Code Playgroud)
(在MacOSX上它是"brew install go")
gem install zeus -v 0.13.3.rc2 --pre
Run Code Online (Sandbox Code Playgroud)
(还尝试了"gem install zeus -v 0.13.3.rc2"和"gem install zeus",每次都使用gem卸载和重新创建初始化文件zeus.json和custom_plan.rb)
gem list
Run Code Online (Sandbox Code Playgroud)
(已安装Zeus的一个版本)
bundle show
Run Code Online (Sandbox Code Playgroud)
(Zeus没有按预期捆绑)
zeus init
Run Code Online (Sandbox Code Playgroud)
(也尝试过删除zeus.json和custom_plan.rb)
也不能在同事的机器上使用MacOSX:
> sudo brew install go
Warning: go-1.0.3 already installed
> gem list
*** LOCAL GEMS ***
method_source (0.8.1)
zeus (0.13.3)
> rbenv version
1.9.3-p327-perf
Run Code Online (Sandbox Code Playgroud)
好吧,我有ssh访问Linux盒子(Ubuntu),这使得Zeus使用相同的代码库进行处理.我可以使用什么诊断来确定/比较它与本地机器有什么不同?我现在正在研究dpkg --get-selections
gem list …Run Code Online (Sandbox Code Playgroud) 不幸的是,出于测试目的,我需要使用Internet Explorer 9,我已经按照MS Answers超级有用的故障排除指南,并搜索了谷歌,仍然无法安装它.
还尝试了IETester,Utilu IE Collection,Triple Booting试用版的windows.
所有论坛,最终终止于"格式化磁盘,重新安装Windows"解决方案或没有回复.重新安装Windows不是一个可行的选择!
我使用的是Windows 7 Professional x64 Service Pack 1(双启动).
Windows更新失败:
"WindowsUpdate_80092004" "WindowsUpdate_dt000"
Run Code Online (Sandbox Code Playgroud)
:根据"获取此错误的帮助".但是,如果查看事件日志,它会说:
0x80070643
Run Code Online (Sandbox Code Playgroud)
:这是令人困惑的,因为它不是同一个错误.为什么,窗户,为什么?
有一个微软修复它你可以下载,在更新失败后清理(为什么这不是由Windows更新自动完成?)和运行后,在网络安全模式下重启,并直接从独立安装程序安装,ie9 "安装",但如果你运行它并单击"帮助>关于"它说它的IE8,然后在计算机获得BSOD(蓝屏死机)之后的某个时刻,当它重新启动时,噗!它的IE8再次出现.
那么,如何安装ie9?
一些 Vim 函数在一定范围内工作:
:'<,'>TOhtml
Run Code Online (Sandbox Code Playgroud)
第一个命令取一个范围,后面的命令通过管道传输结果,其语法是什么?
在wiki的评论中,它建议使用一个插件来允许所有命令在该范围内运行;但在这里我只需要第一个参数来处理范围。
# These are the commands I am attempting to chain
:'<,'>TOhtml
:w! ~/mylink
:q!
# The last two can chain or be one command
:w! ~/mylink | q!
:wq! ~/mylink
# But these fail
:'<,'>TOhtml | wq! ~/mylink
:execute "'<,'>TOhtml" | "wq! ~/mylink"
Run Code Online (Sandbox Code Playgroud) 我经常遇到一堆复杂的if语句,Ruby 的清理方法是什么?
(在这个服务对象示例中,一个 foo 有很多条。这是为了将一个 bar 转移到不同的 foo。)
class BarManager
include FancyErrorLogger
def self.transfer(bar, new_foo)
# Is a move needed? Is this line superfluous and a premature optimisation?
return true if bar.foo_id == new_foo.id
# Checks that bar can be moved to new_foo. Many more elsifs in practice, needs refactoring. These examples demonstrate the potential complexity of each step, preventing the use of overly simplistic solutions such as seen here http://codereview.stackexchange.com/questions/14080/avoiding-a-lot-of-ifs-in-ruby
if bar.dependency == :do_not_move_me or bar.some_condition == …Run Code Online (Sandbox Code Playgroud) rustc 在使用println!.
代码:
fn main() {
println!("Hello, world!");
}
Run Code Online (Sandbox Code Playgroud)
运行它:
me@mclaptop:~
> rustc helloworld.rs
me@mclaptop:~
>
Run Code Online (Sandbox Code Playgroud)
为什么它不打印任何东西?
让我们说:
a = { b:1 , c: { d:2, e:3 } }
address = [:c, :e]
Run Code Online (Sandbox Code Playgroud)
我可以访问3与
a[ address[0] ][ address[1] ]
Run Code Online (Sandbox Code Playgroud)
但这不灵活,我希望能够采用任意地址数组并通过哈希来完成它.
是否有一种优雅的方式来做或者我需要编写一个递归方法?RubyDoc的Fetch如果它接受了一个数组就会很棒.
最好用代码解释....
>> String.ancestors
=> [String, Comparable, Object, Kernel, BasicObject]
>> Comparable.ancestors
=> [Comparable]
>> Object.ancestors
=> [Object, Kernel, BasicObject]
>> Kernel.ancestors
=> [Kernel]
>> BasicObject.ancestors
=> [BasicObject]
Run Code Online (Sandbox Code Playgroud)
所以我怀疑继承链是String <Object <BasicObject ...而Comparable和Kernel是mixins ...
是否有一个函数'foobar'可以显示继承:
>> String.foobar
=> [Object, BasicObject]
Run Code Online (Sandbox Code Playgroud)
如果可能的话,还包括存储单例方法的隐藏元类?
红宝石如何强制整数除以实数?
# integer division with integers - no problem
>> [ 7/2 , 7%2 ]
=> [3, 1]
# integer division with floats - '%' gives the remainder just fine...
# ...but for the quotient it used real division
>> [ 7.0/2 , 7.0%2 ]
=> [3.5, 1.0]
# This is what happens with non integer-y floats
>> [ 7.1/2 , 7.1%2 ]
=> [3.55, 1.0999999999999996]
Run Code Online (Sandbox Code Playgroud)
我想要[ 3.0, 1.1 ].假设这不能在香草红宝石中完成并且需要使用宝石?
我从SQL导出表和查询,其中一些字段是多行的.
Ruby(1.9+)读取CSV的方式似乎是:
require 'csv'
CSV.foreach("exported_mysql_table.csv", {:headers=>true}) do |row|
puts row
end
Run Code Online (Sandbox Code Playgroud)
如果我的数据是这样的,那么效果很好:
"id","name","email","potato"
1,"Bob","bob@bob.bob","omnomnom"
2,"Charlie","char@char.com","andcheese"
4,"Doug","diggyd@diglet.com","usemeltattack"
Run Code Online (Sandbox Code Playgroud)
(第一行是标题/属性)
但如果我有:
"id","name","address","email","potato"
1,"Bob","---
- 101 Cottage row
- Lovely Village
- \"\"
","bob@bob.bob","omnomnom"
2,"Charlie","---
- 102 Flame Street
- \"\"
- \"\"
","char@char.com","andcheese"
4,"Doug","---
- 103 Dark Cave
- Next to some geo dude
- So many bats
","diggyd@diglet.com","usemeltattack"
Run Code Online (Sandbox Code Playgroud)
然后我得到错误:
.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/csv.rb:1894:in `block (2 levels) in shift': Missing or stray quote in line 2 (CSV::MalformedCSVError)
Run Code Online (Sandbox Code Playgroud)
这似乎是因为该行的末尾没有近距离引用,因为它跨越了几行.
(我试过'FasterCSV',因为ruby 1.9,宝石变成了'csv')
特定
class Foo
has_many :bar
end
class Bar
belongs_to :foo
end
Run Code Online (Sandbox Code Playgroud)
我想要:
=> #<ActiveRecord::Relation [#<Foo id: 11, qux: 'hi', bar_id: 1, bar_name: 'blah', bar_something: 'blahblah' >, #<Foo id: 23, qux: 'hi', bar_id: 2, bar_name: 'lorem', bar_something: 'ipsum' >]>
Run Code Online (Sandbox Code Playgroud)
我可以做这个:
> Foo.where(qux: 'hi').includes(:bar)
=> #<ActiveRecord::Relation [#<Foo id: 11, qux: 'hi', bar_id: 1 >, #<Foo id: 23, qux: 'hi', bar_id: 2 >]>
Run Code Online (Sandbox Code Playgroud)
但它不会加载子记录.似乎只是在需要的时候坚持下去.
必须有比这更优雅的东西吗?
Foo.where(qux: 'hi').includes(:bar).to_a.map do | f |
f.keys.each { |k| f[ k.to_s ] = f.delete(k) if k.class == :symbol …Run Code Online (Sandbox Code Playgroud) 如何使用 AWS Cloudwatch Log Insights 的替换功能?
该文档没有给出工作示例。
给定包含路径的日志,例如/api/lumberjack/123/axe/456/fashion
我在尝试:
fields message
| parse message "path=* " as path
| fields replace(path, /[0123456789]+/, 'ID') as uniqpath
| stats count(*) by uniqpath
Run Code Online (Sandbox Code Playgroud)
我期望的结果如下:
uniqpath | count
/api/lumberjack/ID/axe/ID/fashion | 12
/api/lumberjack/ID/beardedness | 44
Run Code Online (Sandbox Code Playgroud)
但它却抱怨“无效的参数,收到:(路径)但预期:(str:字符串,searchValue:字符串,replaceValue:字符串)”
ruby ×6
activerecord ×1
aws-cloudwatch-log-insights ×1
bsod ×1
csv ×1
fastercsv ×1
hash ×1
inheritance ×1
math ×1
mysql ×1
refactoring ×1
rust ×1
ubuntu ×1
vim ×1
zeus ×1