我知道这个方法可以获得特定日期的季度开始和结束:
@date.beginning_of_quarter
@date.end_of_quarter
Run Code Online (Sandbox Code Playgroud)
但是我怎样才能得到例如开头的结局.2012年第4季度?无需通过2012年第4季度中期的日期到end_of_quarter?谢谢
让我们说我有一个User有很多的现代Posts.
所以现在例如我选择Users谁是男性:
User.where(gender: male)
Run Code Online (Sandbox Code Playgroud)
如何扩展我的搜索查询并仅选择具有Post标记的男性用户[sport,holiday]?
如果我只需要使用Posts我只需要打电话:
Post.where(tag: [sport,holiday])
Run Code Online (Sandbox Code Playgroud)
如何连接这两个查询?
至于Auth Challenge我的用户池,我定义了一个 Lambda 函数。此函数向 Authy 发送请求以要求一键式身份验证。
我希望通过此设置将 Authy Multi-Factor Authentication 添加到 Cognito 登录过程。
但是,当我进行身份验证时,使用用户名和密码登录 Cognito 用户时,不会触发此 lambda 函数!
我怎么了?Lambda 触发器是否仅用于为注册过程定义?谢谢
- - - - - - - - - - -更新: - - - - - - - - - - - - - - ---------------------
我的登录代码,需要用户名和密码:
authenticate(userName, userPassword) {
var userData = {Username: userName, Pool : CognitoUserPool}
var cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser(userData);
var authenticationData = {Username : userName, Password : userPassword};
var authenticationDetails = new AWSCognito.CognitoIdentityServiceProvider.AuthenticationDetails(authenticationData);
cognitoUser.authenticateUser(authenticationDetails, …Run Code Online (Sandbox Code Playgroud) authentication lambda triggers amazon-web-services amazon-cognito
我有一个100%宽度的容器,我想填充8个相同大小的输入.100/8 = 12.5
html:
<div id="container">
<input class="form" />
<input class="form" />
....
</div>
Run Code Online (Sandbox Code Playgroud)
我的css:
#container{
width: 100%;
background-color:red;
margin:0;
}
.form{
width:12.5%;
margin:0;
}
Run Code Online (Sandbox Code Playgroud)
正如你在这个小提琴中看到的那样:https://jsfiddle.net/7z7e63cb/
最后一个输入显示在另一行中.为什么?我该如何解决?谢谢
我使用数组map()方法检查数组中的每个元素,如果 if 子句中的条件为真,我将调用另一个函数。
$.map(data['icd'], function (field, i) {
if(field.nummer == search){
Diagnose.single(field.id);
};
});
Run Code Online (Sandbox Code Playgroud)
现在我的问题是,map如果元素满足 if 条件,我想停止该方法。因为我注意到当我有例如 6 个元素满足条件时,该函数Diagnose.single(field.id);被调用 6 次而不是一次!
我试过:
$.map(data['icd'], function (field, i) {
if(field.nummer == search){
Diagnose.single(field.id);
return true;
};
});
Run Code Online (Sandbox Code Playgroud)
但这没有用!我可以做什么?谢谢
我需要检查数组中是否包含某些特定值.我可以这样:
if($.inArray('Z', arr) != -1){
..
}else if($.inArray('A', arr) != -1){
..
}else if($.inArray('G', arr) != -1){
..
}else if($.inArray('T', arr) != -1){
......
Run Code Online (Sandbox Code Playgroud)
或者更短:
if($.inArray('Z', arr) != -1) || ($.inArray('A', arr) != -1) || ($.inArray('G', arr) != -1) ||($.inArray('T', arr) != -1) ... {
Run Code Online (Sandbox Code Playgroud)
但是我的代码有更短的版本吗?谢谢
我有一张叫做的桌子products.它存储产品名称及其价格.价格以整数的格式存储为美分.
当我选择我的数据时:
SELECT name, price
FROM products
Run Code Online (Sandbox Code Playgroud)
我得到这样的数据:
Name Price
Car 3032
Banana 178
Run Code Online (Sandbox Code Playgroud)
但我希望数据格式如下:
Name Price
Car 30,32
Banan 1,78
Run Code Online (Sandbox Code Playgroud)
这可能吗?我现在的功能就像sum,count.. etc
我有一个像这样的课:
class House
def bricks
Brick.for(@house_plan).where(size: 5)
end
def wood
Wood.for(@house_plan).where(size: 5)
end
end
Run Code Online (Sandbox Code Playgroud)
我的目标是提取电话 for(self).where(size: 5):
我首先尝试的是:
class House
def bricks
Brick.match_material
end
def wood
Wood.match_material
end
def match_material
for(@house_plan).where(size: 5)
end
end
Run Code Online (Sandbox Code Playgroud)
但后来我收到了这个错误:
syntax error, unexpected '\n', expecting :: or '[' or '.'
Run Code Online (Sandbox Code Playgroud)
然后我将我的代码更改为:
def match_material
.for(@house_plan).where(size: 5)
end
Run Code Online (Sandbox Code Playgroud)
现在我做的时候:
house = House.new(HousePlan.new)
house.bricks
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
formal argument cannot be an instance variable
Run Code Online (Sandbox Code Playgroud)
在这一行: for(@house_plan).where(size: 5)
我想在文档中找到日期。
并以数组形式返回此Date。
假设我有这段文字:
On the 03/09/2015 I am swiming in a pool, that was build on the 27-03-1994
Run Code Online (Sandbox Code Playgroud)
现在我的代码应该返回['03/09/2015','27-03-1994']一个数组中的两个Date对象。
我的想法是使用正则表达式解决此问题,但该方法search()仅返回一个结果,并且test()只能测试字符串!
您将如何解决?特别是当您不知道日期的确切格式时?谢谢
我想创建一个接受方法名称并打印出来的对象.我应该可以调用任何方法.例如,
obj.hello("was")
# => called hello with argument 'was'
obj.ok(["df", 1])
# => called ok with argument ["df", 1]
Run Code Online (Sandbox Code Playgroud)
我不想定义hello或ok提前.
那可能吗?