我正在从书中学习SQL,我正在尝试编写存储过程,但我不相信我正确地做了.以下方式在Microsoft SQL中无效吗?如果没有,什么时候有效,如果有的话?
create procedure dept_count(in dept_name varchar(20), out d_count integer)
begin
select count(*) into d_count
from instructor
where instructor.dept_name=dept_count.dept_name
end
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
消息156,级别15,状态1,过程wine_change,第1行关键字'in'附近的语法不正确.
我一直在玩Firebase,在阅读完文档(以及其他SO问题)之后,我仍然对某些API密钥感到困惑.我正在使用Firebase for Analytics,Crashlytics和Performance.但它也与Google Play和AdMob相关联.
当我第一次设置它时,在开发者控制台中创建了3个API密钥.
我尝试阅读文档,找到它描述如何使用这些键,但我无法找到它.通过查看Firebase应用程序,它看起来像是Android Key用作的Web API Key,并且Server Key用作Cloud Message Legacy Server Key(尽管我不使用云消息传递).我不确定Firebase是如何使用的Browser Key.
我正在尝试做的是尽可能地限制这些密钥,以防止任何恶意使用它们.
我添加了以下API限制
我不完全确定这些限制是否适用于我使用它们的内容,但它至少对我而言是有用Android Key的Server Key,至少就我所知.但是,Browser Key由于Firebase Browser Key在重新部署应用程序时正在创建新的限制,因此这些限制似乎不起作用.
总结一下我的问题,我可以看到Firebase正在为我自动创建API密钥,但我找不到任何文档来讨论这些密钥如何用于我正在使用的Firebase的基本功能.我也不完全确定如何限制这些键,尤其是Browser Key.
这是我试图自己解决的一个问题,在递归(而不是家庭作业)上要好一点.我相信我找到了一个解决方案,但我不确定时间复杂度(我知道DP会给我更好的结果).
找到你可以上n阶梯的所有方法,如果你可以一次采取k步,使k <= n
例如,如果我的步长是[1,2,3]并且楼梯的大小是10,我可以采取10步1的大小[1,1,1,1,1,1,1,1, 1,1] = 10或者我可以采取3步和3步1尺寸[3,3,3,1] = 10
这是我的解决方案:
static List<List<Integer>> problem1Ans = new ArrayList<List<Integer>>();
public static void problem1(int numSteps){
int [] steps = {1,2,3};
problem1_rec(new ArrayList<Integer>(), numSteps, steps);
}
public static void problem1_rec(List<Integer> sequence, int numSteps, int [] steps){
if(problem1_sum_seq(sequence) > numSteps){
return;
}
if(problem1_sum_seq(sequence) == numSteps){
problem1Ans.add(new ArrayList<Integer>(sequence));
return;
}
for(int stepSize : steps){
sequence.add(stepSize);
problem1_rec(sequence, numSteps, steps);
sequence.remove(sequence.size()-1);
}
}
public static int problem1_sum_seq(List<Integer> sequence){
int sum = 0;
for(int i : sequence){
sum += …Run Code Online (Sandbox Code Playgroud) 可能会发布busboy错误并进行处理吗?
例:
busboy.on('file', function(fieldname, file, filename, encoding, mimetype) {
if(mimetype !== 'application/pdf') {
this.emit('error',new Error('Wrong file type'));
return;
}
}
busboy.on('error', function(err) {
console.log('An error has occured: \n' + err);
});
Run Code Online (Sandbox Code Playgroud)
如果这样做,则会出现以下错误:
events.js:141
throw er; // Unhandled 'error' event
^
Error: Wrong file type
at Busboy.<anonymous> (/home/ubuntu/workspace/suploadtest/app.js:44:31)
at emitMany (events.js:108:13)
at Busboy.emit (events.js:182:7)
at Busboy.emit (/home/ubuntu/workspace/uploadtest/node_modules/busboy/lib/main.js:31:35)
at PartStream.<anonymous> (/home/ubuntu/workspace/uploadtest/node_modules/busboy/lib/types/multipart.js:213:13)
at emitOne (events.js:77:13)
at PartStream.emit (events.js:169:7)
at HeaderParser.<anonymous> (/home/ubuntu/workspace/uploadtest/node_modules/busboy/node_modules/dicer/lib/Dicer.js:51:16)
at emitOne (events.js:77:13)
at HeaderParser.emit (events.js:169:7)
Run Code Online (Sandbox Code Playgroud)
我希望能够通过消息发出自己的错误,然后在错误事件中删除上传的文件。
我正在用node.js 构建一个应用程序,允许用户使用express 和busboy 上传文档。用户可以一次上传多个文档,但文件总大小限制为 20mb。
是否可以阻止用户在给定时间内发出多个上传请求?我担心的是,有人可以轻松编写一个脚本来上传 20mb(每次上传的限制),并每分钟重复 100 次或相当大的数量。理想情况下,用户只能每 30 秒或每分钟上传一次。
我正在尝试使用 gitfilter-branch功能删除最近更新和提交的文件。我尝试运行以下命令:
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch myfile' --prune-empty --tag-name-filter cat -- 6f7fda9..HEAD
Run Code Online (Sandbox Code Playgroud)
但是,这只会从主分支中删除文件,我希望将其从所有分支中删除。
与承诺开始6f7fda9向HEAD我要删除的文件。我运行的命令是错误的吗?
我第一次为我的应用设置 Firebase。我按照说明操作,注意到在开发者控制台中创建了 3 个 API 密钥和 1 个 OAuth 2.0 客户端 ID。
API 密钥:
OAuth 2.0 客户端 ID
我想重命名这些以便我知道它们是什么。所以我进入 Firebase 并找出它们的使用位置并将它们重命名为以下内容:
但是,当我重命名它们并重新部署我的应用程序时,Firebase 会重新创建新密钥。
现在我有以下 Api 密钥:
android google-play firebase google-play-services google-developers-console
我在我的单元测试中抛出一个Exception,但是在抛出之后,我仍然希望能够继续测试
doThrow(new Exception()).when(myMock).myMethod();
myMock.myMethod();
System.out.println("Here"); // this is never called
// Do verify and asserts
Run Code Online (Sandbox Code Playgroud)
是否有可能做到这一点?
假设我有一个User包含Organization字段的域对象。我可以使用外键映射它,并让 hibernate 处理其余的事情,如下所示:
class User {
String id
String firstName
Organization organization
static mapping = {
table 'user'
id column: "user_id", generator:'assigned'
organization column: 'organization_Id'
}
}
class Organization {
String id
String name
String address
static mapping = {
table 'organization'
id column: "organization_id", generator:'assigned'
}
}
Run Code Online (Sandbox Code Playgroud)
这工作正常,但是当我想查询组织中的所有用户时,我可能必须这样做
String orgId = "some id"
Organization org = Organization.findById(orgId)
List<User> users = User.findAllByOrganization(org)
Run Code Online (Sandbox Code Playgroud)
不必传递Organization域对象而只需传递 Organization.Id(表上的外键)会很方便User。
我希望我的代码如下所示:
String orgId = "some id"
List<User> users …Run Code Online (Sandbox Code Playgroud) 我正在尝试制作一个简单的程序来检查麦克风是否静音。Line这是我用来确定哪个麦克风的代码。
private Line getMic() throws LineUnavailableException {
Mixer.Info[] mixerInfos = AudioSystem.getMixerInfo();
for (int i = 0; i < mixerInfos.length; i++) {
Mixer mixer = AudioSystem.getMixer(mixerInfos[i]);
int maxLines = mixer.getMaxLines(Port.Info.MICROPHONE);
Port lineIn = null;
if (maxLines > 0) {
lineIn = (Port) mixer.getLine(Port.Info.MICROPHONE);
return lineIn;
}
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
然后从那里我调用以下内容:
BooleanControl muteControl = (BooleanControl)mic.getControl(BooleanControl.Type.MUTE);
System.out.println(muteControl.getValue());
Run Code Online (Sandbox Code Playgroud)
但是,我收到错误:
Unsupported control type: Mute
Run Code Online (Sandbox Code Playgroud)
我继续查看Controls可以使用Line以下内容:
for(Control c : mic.getControls()){
System.out.println(c.getType());
}
Run Code Online (Sandbox Code Playgroud)
只有一个Control,那就是Master Volume. 我不确定为什么 …
我看了几个其他线程,但似乎无法弄清楚如何删除2d数组.
这是我如何初始化数组.num_items并且capacity是预定的变量:
int **P = new int *[num_items];
for (x = 0; x <= num_items; x++)
P[x] = new int[capacity];
Run Code Online (Sandbox Code Playgroud)
以下是我认为我想删除它的方式,然而,它崩溃了:
for(x = 0; x <= num_items; x++)
delete [] P[x];
delete [] P;
Run Code Online (Sandbox Code Playgroud)
为了澄清,我希望数组P保留1个额外的num_items.因此,如果num_items = 7,那么我希望数组大小为8,以便P [7]有效.
java ×3
android ×2
busboy ×2
firebase ×2
javascript ×2
node.js ×2
algorithm ×1
arrays ×1
audio ×1
c++ ×1
exception ×1
express ×1
git ×1
github ×1
google-play ×1
grails ×1
grails-orm ×1
http ×1
javasound ×1
microphone ×1
mockito ×1
sql-server ×1
t-sql ×1