我已经回顾了Jasmine的toHaveBeenCalledWith匹配器的文档,以便了解是否可以为参数传递正则表达式,如果该参数应该是一个字符串.不幸的是,这是不受支持的功能.还有一个问题在github上打开请求此功能.
我已经挖了一些代码库,我看到如何在现有的匹配器中实现它.我认为将它作为一个单独的匹配器实现更合适,这样就可以单独捕获抽象.
与此同时,什么可能是一个好的解决方法?
React中的CSS属性不会自动添加其供应商前缀.
例如,用:
<div style={{
transform: 'rotate(90deg)'
}}>Hello World</div>
Run Code Online (Sandbox Code Playgroud)
在Safari中,不会应用旋转.
我如何实现这一目标?
在深入研究这个问题之后,我在理解文档和结果之间陷入了僵局.
根据https://www.relishapp.com/rspec/rspec-rails/v/2-8/docs/routing-specs/route-to-matcher,我们应该能够编写以下内容:
#rspec-rails (2.8.1)
#rspec (>= 1.3.1)
#rspec-core (~> 2.8.0)
# routing spec
require "spec_helper"
describe BusinessUsersController do
describe "routing" do
it "routes to some external url" do
get("/business_users/7/external_url").should route_to("http://www.google.com")
end
end
end
# routes.rb
BizeebeeBilling::Application.routes.draw do
resources :business_users do
member do
get "external_url" => redirect("http://www.google.com")
end
end
end
Run Code Online (Sandbox Code Playgroud)
运行此规范会产生以下结果:失败:
1) BusinessUsersController routing routes to some external url
Failure/Error: assert_routing "/business_users/7/external_url", "http://www.google.com"
ActionController::RoutingError:
No route matches "/business_users/7/external_url"
# ./spec/routing/business_users_routing_spec.rb:19:in `block (3 levels) in <top (required)>'
Run Code Online (Sandbox Code Playgroud)
我无法在任何地方找到报告此特定问题的人.
添加细节:手动测试时,路线得到很好的解决.
使用AWS CLI从命令行解密密文时,密文会被解密而不会出现问题:
$ aws kms decrypt --ciphertext-blob fileb://encrypted-secrets --output text --query Plaintext --region us-east-1 | base64 --decode > decryped-secrets
Run Code Online (Sandbox Code Playgroud)
当尝试从js脚本执行此操作时,此解密操作也在本地工作:
#!/usr/local/bin/node
const fs = require('fs');
const AWS = require('aws-sdk');
const kms = new AWS.KMS({region:'us-east-1'});
const secretPath = './encrypted-secrets';
const encryptedSecret = fs.readFileSync(secretPath);
const params = {
CiphertextBlob: encryptedSecret
};
kms.decrypt(params, function(err, data) {
if (err) {
console.log(err, err.stack);
} else {
const decryptedScret = data['Plaintext'].toString();
console.log('decrypted secret', decryptedScret);
}
});
Run Code Online (Sandbox Code Playgroud)
但是,当在AWS Lambda函数的上下文中尝试使用与上述几乎完全相同的代码时,调用该函数会导致超时:
'use strict';
const zlib = require('zlib');
const mysql …Run Code Online (Sandbox Code Playgroud) amazon-web-services aws-sdk aws-lambda aws-kms aws-sdk-nodejs
看起来好像yarn没有将node-gyp标志传递给本机包npm.
例如,当尝试使用以下命令安装sqlite3@3.1.6时:
npm install sqlite3@3.1.6 \
--build-from-source \
--sqlite_libname=sqlcipher \
--sqlite=`brew --prefix` \
--verbose
Run Code Online (Sandbox Code Playgroud)
我们成功安装了带有sqlcipher扩展的sqlite3,由于传递--sqlite_libname而且--sqlite是在sqlite3 中指定的binding.gyp.
但是,当试图使用yarn并运行我认为是等效的命令时,看起来标志不符合:
yarn add sqlite3@3.1.6 \
--force \
--build-from-source \
--sqlite_libname=sqlcipher \
--sqlite=`brew --prefix` \
--verbose
Run Code Online (Sandbox Code Playgroud)
使用npm无法识别的命令行参数将转换为gyp标志.
有了yarn这似乎并没有工作.
有没有办法获得此功能yarn?
有可能在不久的将来将LDAP身份验证集成到Meteor.js中吗?
关于如何让它今天起作用的任何提示?
在测试LinkedIn API并尝试构建Meteor JS智能包以对LinkedIn的OAuth提供商进行身份验证时,我遇到了一个完全障碍.
在遵循这些指示的过程中,我能够成功生成一个oauth_token用于授权请求的形式,其形式为:
https://www.linkedin.com/uas/oauth/authorize?oauth_token={oauth_token}
Run Code Online (Sandbox Code Playgroud)
当使用由如下所示的ruby脚本生成的令牌将其放入浏览器时:
require 'oauth'
api_key = '{linkedin api key}'
api_secret = '{linkedin api secret}'
configuration = { :site => 'https://api.linkedin.com',
:authorize_path => '/uas/oauth/authenticate',
:request_token_path => '/uas/oauth/requestToken',
:access_token_path => '/uas/oauth/accessToken' }
consumer = OAuth::Consumer.new(api_key, api_secret, configuration)
request_token = consumer.get_request_token
puts request_token.params[:oauth_token]
Run Code Online (Sandbox Code Playgroud)
然后,我可以使用上面的URI轻松地将令牌转储为浏览器中的查询字符串参数,并查看LinkedIn权限对话框.
使用有效令牌显示的LinkedIn auth窗口:

不幸的是,当尝试在命令行中编写curl请求时,oauth_token生成的请求在同一个url中使用时会失败.实际上,它导致linkedin以500错误响应,并且浏览器显示标准500错误窗口.响应没有附加细节:

这里的代码类似于我在我的curl请求中实现的新代码oauth_token:
alex@alex-mac accounts-linkedin (fixes_for_meteor_0_5_4)* $ cat linkedin_oauth_gen.sh
curl -X POST https://api.linkedin.com/uas/oauth/requestToken --verbose --header 'Authorization: OAuth oauth_nonce="0d9a3e40660811e2bcfd0800200c9a66",oauth_timestamp="1359019570",oauth_version="1.0",oauth_signature_method="HMAC-SHA1",oauth_consumer_key="{oauth_consumer_key}",oauth_signature="{oauth_signature}"'
Run Code Online (Sandbox Code Playgroud)
值得注意的是,我使用了LinkedIn的OAuth测试控制台来生成Authorization标头.
这很重要,因为我在尝试在Meteor JS智能包中实现类似功能时会遇到同样的问题.
然而,我的主要问题是为什么在世界上我可以用上面的ruby代码来做,但是当使用简单的curl shell命令时,令牌似乎没有有效生成(或者LinkedIn根本不想尊重它) ...
我知道这里有一个类似的问题,但是由于我的情况有点不同,我仍然无法完成这项工作.我想通过使用google-drive-ruby gem在google驱动器中创建一个文件夹.
据谷歌(https://developers.google.com/drive/folder)使用"驱动器" API,您可以通过插入用的MIME类型"application/vnd.google-apps.folder"文件中创建一个文件夹时,
例如
POST https://www.googleapis.com/drive/v2/files
Authorization: Bearer {ACCESS_TOKEN}
Content-Type: application/json
...
{
"title": "pets",
"parents": [{"id":"0ADK06pfg"}]
"mimeType": "application/vnd.google-apps.folder"
}
Run Code Online (Sandbox Code Playgroud)
在我的情况下,我希望能够做同样的事情,但在使用google_drive API时.它有一个接受的mime-type选项的upload_from_file选项,但是这仍然不为我工作,我走到这一步,执行以下代码时是最好的结果是从谷歌此错误消息.
session.upload_from_file("test.zip","test",:content_type =>"application/vnd.google-apps.folder")
"Mime-type application/vnd.google-apps.folder无效.无法使用Google mime-types创建文件.
如果你能给我任何建议,我将不胜感激.
在昨天教我的JavaScript课程时,我和我的学生遇到了一些有趣的功能,我认为这些功能值得在一个问题和我得到的答案中捕获.
Array.length在chrome中输入JS控制台返回1.
同样,Function.length回报1.这很重要,因为:
JavaScript中的每个函数实际上都是一个Function对象.(MDN JS参考:功能)
因此,Object.length可能所有其他本机对象将1作为length属性的值返回.
那么,最后为什么会发生这种行为呢?
在 Mac 上,docker 使用 HyperKit 来创建 LinuxKit VM。这意味着,除其他外,我看不到在诸如 之类的地方为给定容器下拉的任何图像层/var/lib/docker,因为虚拟机控制着所有这些。
有没有办法真正在该虚拟机上获得一个 shell,以便能够进行这种内省?
为什么当尝试在 的实例上调用delete_allor并传递条件时,会抛出错误,而不会?destroy_allActiveRecord::Associations::CollectionProxyArgumentError: Valid values are :nullify or :delete_allActiveRecord::Relation#delete_all
例如,当尝试给定一种关系(例如和 之间delete_all可能存在)时,就会出现这种情况。在这种情况下,给定一个实例,人们可能想做类似的事情:MoviesActorsMovie
movie.actors.delete_all(id: [2,3,4])
上面的方法不起作用,抛出错误。
他们的对手也是如此#destroy_all。
我大致有以下源数据,我试图通过vim的regexp搜索和替换来执行全局替换:
"text": [{
"uid": "...",
"left": 50,
"top": 715,
"minSize": 60,
"maxSize": 70,
"width": "345px",
"align": "center",
"font": "...",
"forbidden": "",
"border": true,
"printType": 0
}
Run Code Online (Sandbox Code Playgroud)
我的搜索/替换字符串如下所示:
:%s/"left": \(\d\+\)/"left": \=submatch(1)*0.66/g
实际上,我试图"left"在所有情况下将财产减少到其当前价值的66%.
不幸的是,结果字符串变为:
"text": [{
"uid": "...",
"left": =submatch(1)*0.66,
"top": 715,
"minSize": 60,
"maxSize": 70,
"width": "345px",
"align": "center",
"font": "...",
"forbidden": "",
"border": true,
"printType"
Run Code Online (Sandbox Code Playgroud)
所以,而不是让"left": 33我得到"left": =submatch(1)*0.66.
起初,我认为这是因为我正在使用=submatch(0).但是,切换到=submatch(0)没有修复问题,只是=submatch(0)在替换后的字符串中返回.
是否会出现无法正确评估表达式的情况?
关闭-webkit-filterchrome 似乎存在问题.
在使用非浏览器特定的filtercss属性时,在firefox 34.0.5或firefox 35中,我似乎也没怎么想.
显然,根据caniuse,该物业应该是可用的.
给出以下代码段:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
#outer {
background: blue;
-webkit-filter: grayscale(100%);
}
#outer #inner {
background: green;
-webkit-filter: none;
}
</style>
</head>
<body>
<div id="outer">
outer
<div id="inner">inner</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
最重要的是,为什么没有div#inner关闭其过滤器?