我正在写一个Greasemonkey用户脚本,并希望在页面完全加载时执行特定代码,因为它返回了我想要显示的div计数.
问题是,这个特定的页面有时需要一些加载.
我试过,文件$(function() { });和$(window).load(function(){ });包装.但是,似乎没有一个对我有用,尽管我可能会错误地应用它们.
我能做的最好是使用一个setTimeout(function() { }, 600);有效的,虽然它并不总是可靠的.
在Greasemonkey中使用哪种最好的技术来确保在页面加载完成后执行特定的代码?
我正在尝试为sailsjs v1模型创建蓝图查询.
该模型是一个BlogPost,有2个"选项".一个是目标,另一个是状态.
如果目标是Site并且状态为Published,则应返回查询,否则为nope.我正在使用Sails提供的默认REST路由(蓝图),如果我试图找到所有这些路由,一切正常.但是,如果我试图通过ID找到一个...我甚至无法找回状态为"未发布"的那些.
这是我的代码blueprint.js parseBlueprintOptions- >
parseBlueprintOptions: function (req) {
var queryOptions = req._sails.hooks.blueprints.parseBlueprintOptions(req);
if (queryOptions.using === 'blogpost') {
if (req.options.blueprintAction === 'create') {
queryOptions.newRecord.user_id = req.session.user.id;
return queryOptions;
} else if (req.options.blueprintAction === 'update') {
queryOptions.criteria.where.user_id = req.session.user.id;
queryOptions.valuesToSet.user_id = req.session.user.id;
return queryOptions;
} else {
if (req.session.administrator) {
return queryOptions;
} else {
queryOptions.criteria.where.blogpost_target = 'Site';
queryOptions.criteria.where.blogpost_status = 'Published';
console.log(queryOptions);
return queryOptions;
}
}
}
}
};
Run Code Online (Sandbox Code Playgroud)
有关为什么不触发查询的提示findOne?正如我所说,无论状态/目标如何,它都会返回.
我正在尝试创建单元测试.我有班级用户:
public class User
{
public int UsersCount
{
get
{
using (MainContext context = new MainContext())
{
return context.Users.Count();
}
}
}
public Guid Id { get; set; } = Guid.NewGuid();
public string UserName { get; set; }
public string Password { get; set; }
public Contact UserContact { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我的第一个测试是UsersCount_Test测试,它测试UsersCount属性:
[TestMethod]
public void UsersCount_Test()
{
var user = new User();
var context = new MainContext();
int usersCount = context.Users.Count();
context.Users.Add(new User());
context.SaveChanges();
Assert.AreEqual(usersCount + 1, …Run Code Online (Sandbox Code Playgroud) 基本上,我正在开发一个视频编辑应用程序,让用户可以选择他们的一些图像,并创建一个带有音乐的视频幻灯片.
我正在使用FFMPEG从图像生成视频幻灯片放映,但问题是我只能在执行FFMPEG命令后显示视频的预览.
用Google搜索了这么多博客,我知道有一种可能的方式来显示输出的预览.
从参考应用程序检查下图.我正在开发类似于这个应用程序的东西.可以选择替换视频中的图像.一旦我更改图像,此应用程序将显示即时预览.
如果有人想检查,这是参考应用程序的链接:
单击"导出"按钮,此应用程序可让您生成视频输出.我可以这样做,因为我知道FFMPEG以及如何使用FFMPEG生成OUTPUT FILE,但我不知道如何在生成实际视频文件之前显示OUTPUT VIDEO的快速预览.
在我的UBUNTU设备上,我可以使用FFPLAY工具查看FFMPEG命令的输出,但如何在Android设备上执行相同操作.
一些有用的链接:http: //androidwarzone.blogspot.com/2011/12/ffmpeg4android.html
如何将数组转换为 angular 6 中的 observable 数组。我试图在拥有数组的同时返回一个 observable。我这样做是为了代替 HTTP 请求,我可以返回硬编码数据。
我有以下界面:
export interface IProduct {
productId: number;
productName: string;
productCode: string;
releaseDate: string;
description: string;
price: number;
starRating: number;
imageUrl: string;
}
Run Code Online (Sandbox Code Playgroud)
然后我有这个服务:
export class ProductService {
products: IProduct[];
getProducts(): Observable<IProduct[]> {
this.products = [
{
'productId': 2,
'productName': 'Black cat',
'productCode': 'GDN-001',
'releaseDate': 'March 18, 2018',
'description': 'Can punch peoples faces.',
'price': 32.00,
'starRating': 5,
'imageUrl': 'https://placekitten.com/400/420'
},
{
'productId': 3,
'productName': 'T Cat',
'productCode': 'GDN-002',
'releaseDate': 'March 18, 2018', …Run Code Online (Sandbox Code Playgroud) javascript ×2
android ×1
angular ×1
angular6 ×1
arrays ×1
c# ×1
ffmpeg ×1
greasemonkey ×1
jquery ×1
node.js ×1
observable ×1
performance ×1
sails.js ×1
tampermonkey ×1
unit-testing ×1
video ×1