我正在尝试在Mavericks上安装以下gem版本
显然,therubyracer宝石取决于libv8.
什么是libv8?我的一些研究似乎表明它是Google Chrome使用的某种javascript库?
我在安装它时遇到了麻烦,但是这个很棒的帖子既有我的错误,也有关于如何绕过它的解释清楚的答案.
所以我安装libv8
了
gem install libv8 -- --with-system-v8
Run Code Online (Sandbox Code Playgroud)
这是我的理解,这安装了gem,但使用我的本地系统安装v8库而不是... gem附带的版本?无论哪种方式,它都是成功的.
在下一步中,我在安装therubyracer
gem时遇到了麻烦.我不太确定这个gem是做什么的,只是因为它是我正在尝试的rails项目的依赖项bundle install
.
它给了我以下错误:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/jeeves.butler/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for main() in -lpthread... yes
checking for main() in -lobjc... yes
checking for v8.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. …
Run Code Online (Sandbox Code Playgroud) 我正在使用 Jest 编写一些规范,并使用 ESLint 来整理样式。
对于我的foo.spec.js
测试,eslint 不断抛出以下错误。它似乎认为jest
,beforeEach
,afterEach
,等...没有在该文件中定义。
11:1 error 'beforeEach' is not defined no-undef
12:3 error 'jest' is not defined no-undef
14:13 error 'jest' is not defined no-undef
18:1 error 'afterEach' is not defined no-undef
20:1 error 'describe' is not defined no-undef
21:3 error 'it' is not defined no-undef
25:5 error 'expect' is not defined no-undef
28:5 error 'expect' is not defined no-undef
31:5 error 'expect' is not defined no-undef
34:3 error …
Run Code Online (Sandbox Code Playgroud) 我有一个字符串数组,我想排除以foo_
OR 开头的值超过7个字符.
我可以循环遍历每个元素,运行if
语句,并将其添加到路径中的切片.但我很好奇是否有一种惯用的或更像golang的方式来完成它.
例如,同样的事情可能在Ruby中完成
my_array.select! { |val| val !~ /^foo_/ && val.length <= 7 }
Run Code Online (Sandbox Code Playgroud) 刚刚安装了Ubuntu 13.10(Saucy)和我尝试安装的任何东西sudo apt-get install
都失败并抛出了一系列404
错误.
示例 - 安装 tmux
[jeeves@HAL] hadoop > sudo apt-get install tmux
[sudo] password for jeeves:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
tmux
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 247 kB of archives.
After this operation, 577 kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated! …
Run Code Online (Sandbox Code Playgroud) 我使用Chrome DevTools将视口大小调整为480px宽,如下所示.
我正在使用bootstrap的网格布局,所以我有一个div.container
我正在使用的,如左下角所示.当我将鼠标悬停在它上面时,我看到chrome有特别div
标记为宽度750px
(整体body
都是980px
),即使我清楚地将屏幕设置为较小的分辨率.即使顶部的标尺也显示宽度为480px.
为了进一步确认,您可以看到媒体查询说750px的宽度应该只设置在更高的分辨率(最小768px),因此视口假设它的宽度比它高.
我是否误解了如何使用响应功能?
谢谢!
ActionJob
在Rails中连接的常见模式是使用一个perform()
方法设置一个Job,该方法通过perform_now
或者异步调用perform_later
在邮件程序的特殊情况下,可以直接打电话deliver_now
或deliver_later
因为ActionJob
是很好的集成ActionMailer
.
该轨道文档有以下评论-
# If you want to send the email now use #deliver_now
UserMailer.welcome(@user).deliver_now
# If you want to send the email through Active Job use #deliver_later
UserMailer.welcome(@user).deliver_later
Run Code Online (Sandbox Code Playgroud)
措辞使得它看起来像deliver_now
会不会使用ActiveJob
发送邮件.那是正确的,如果有啥之间真正的差异deliver_now
和deliver_later
?一个不是异步的吗?
同样,同样的差异适用于perform_now
和perform_later
?
谢谢!
每次我推送到Github,它似乎触发两个 Travis CI构建 - 一个用于PR,一个用于Push本身.从链接来看,它们似乎也是单独的构建.
这两者之间的确切区别是什么?我如何启用它以便只运行一个?
假设我正在git
使用我的Rails
应用程序,我有两个分支,每个分支都有自己的迁移.
1)branch001
创建一个名为tableA
via migration 的表20160101000000_create_table_A
2)branch002
创建一个名为tableB
via migration 的表20160101000001_create_table_B
显然,第二次迁移的时间戳是在第一次迁移之后创建的.
但是,让我说我首先合并branch002
,master
因为它已经准备好了.我的架构文件变成 -
ActiveRecord::Schema.define(version: 20160101000001) do
....
end
Run Code Online (Sandbox Code Playgroud)
模式版本告诉activerecord它已经修补到比我的第一个分支更大的级别/版本.
当我终于合并我的第一个分支时会发生什么?
20160101000000
吗?谢谢!
编辑 -
真的想知道当我合并第二个分支时我应该怎么做才能解决合并冲突master
.我应该将其作为较晚的时间戳保留还是将其退回到较早的时间戳?
<<<<<<< HEAD (master)
ActiveRecord::Schema.define(version: 20160101000001) do
=======
ActiveRecord::Schema.define(version: 20160101000000) do
>>>>>>> 282cda7... Adding Table B
Run Code Online (Sandbox Code Playgroud) 根据这里和这里的Rails文档,使用update_all
不执行以下操作 -
updated_at
字段:limit
和:order
方法我正在尝试通过我的代码库并删除实例update_all
,特别是因为第一点.
有没有办法仍然有方便update_all
并仍然运行验证?我知道我可以遍历每条记录并保存它,但这不仅在视觉上更混乱,而且效率更低,因为它执行N个SQL语句而不是1
# before
User.where(status: "active").update_all(status: "inactive")
# after
User.where(status: "active").each { |u| u.update(status: "inactive") }
Run Code Online (Sandbox Code Playgroud)
谢谢!
编辑:我正在使用Rails 4.2
我正在尝试使用Python客户端库以编程方式访问我自己的个人Google帐户中的联系人列表
这是一个将在没有用户输入的情况下在服务器上运行的脚本,因此我将其设置为使用我设置的服务帐户中的凭据.我的Google API控制台设置如下所示.
我正在使用以下基本脚本,从API文档中提供的示例中提取 -
import json
from httplib2 import Http
from oauth2client.service_account import ServiceAccountCredentials
from apiclient.discovery import build
# Only need read-only access
scopes = ['https://www.googleapis.com/auth/contacts.readonly']
# JSON file downloaded from Google API Console when creating the service account
credentials = ServiceAccountCredentials.from_json_keyfile_name(
'keep-in-touch-5d3ebc885d4c.json', scopes)
# Build the API Service
service = build('people', 'v1', credentials=credentials)
# Query for the results
results = service.people().connections().list(resourceName='people/me').execute()
# The result set is a dictionary and should contain the key 'connections'
connections = results.get('connections', []) …
Run Code Online (Sandbox Code Playgroud) activerecord ×2
apt-get ×1
aptitude ×1
arrays ×1
css ×1
eslint ×1
gcc ×1
git ×1
github ×1
go ×1
javascript ×1
jestjs ×1
jobs ×1
libv8 ×1
python ×1
ruby ×1
slice ×1
therubyracer ×1
travis-ci ×1
ubuntu ×1
unit-testing ×1
validation ×1