小编use*_*287的帖子

如何在div #content加载时显示div #loading

我想要实施一个解决方案,其中:

  1. 而div #content中的内容正在加载,
  2. 隐藏div #content,
  3. show div #loading,
  4. 然后当div #content加载时,
  5. hide div #loading,
  6. 淡出div #content

我试过了:

HTML:

<div id="content">
<!--this stuff takes a long time to load-->
<img src="http://lorempixel.com/1920/1920/">
</div>
<div id="loading">
<!-- this is the loading gif -->
<img src="http://lorempixel.com/400/200/">
</div>
Run Code Online (Sandbox Code Playgroud)

JS:

// when user browses to page
$('#content').hide();
$('#loading').show();

// then when div #content has loaded, hide div #loading and fade in div #content
$('#content').bind('load', function() {
$('#loading').hide();
$('#content').fadeIn('slow');
});
Run Code Online (Sandbox Code Playgroud)

这是我正在研究的jsfiddle:

http://jsfiddle.net/rwone/Y9CQ4/

谢谢.

html jquery loading

5
推荐指数
1
解决办法
3万
查看次数

如何在MySQL中撤消对新用户的*。*访问权限?

在mysql 5.6命令行客户端(以root用户身份登录时),我创建了一个用户:

CREATE USER 'admin'@'localhost' IDENTIFIED BY 'password';
Run Code Online (Sandbox Code Playgroud)

然后通过以下方式授予特权:

GRANT ALL PRIVILEGES ON databasename.* TO 'admin'@'localhost';
Run Code Online (Sandbox Code Playgroud)

使用以下命令检查特权时:

SHOW GRANTS FOR 'admin'@'localhost';
Run Code Online (Sandbox Code Playgroud)

显示了上面分配的数据库的特权以及以下特权:

GRANT USAGE ON *.* TO 'admin'@'localhost' IDENTIFIED BY PASSWORD...
Run Code Online (Sandbox Code Playgroud)

我试图通过以下方式撤销特权:

REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'admin'@'localhost';
Run Code Online (Sandbox Code Playgroud)

但这并不会删除 *.*

我如何撤消*.*mysql中新用户的访问权限?

mysql privileges grant

5
推荐指数
1
解决办法
1万
查看次数

.NET框架来自哪里?Visual Studio还是Windows?

我正在学习C#并在运行Windows 7的PC上安装了Visual Studio 2012.

我现在可以浏览到该C:\Windows\Microsoft.NET目录.

我的第一个问题是:

Visual Studio是附带.NET目录,还是Visual Studio只访问运行Windows 7的计算机上已存在的目录?

我的第二个相关问题是:

该位置编号最大的文件夹C:\Windows\Microsoft.NET\Framework\v4.0.30319.这让我感到困惑,因为https://en.wikipedia.org/wiki/.NET_Framework#History表中与Visual Studio 2012相关的版本号是4.5.50709.17929.

那么,如果几周前安装Visual Studio,为什么我没有更高版本号的文件夹呢?

.net c# visual-studio-2012

5
推荐指数
1
解决办法
2914
查看次数

让Ace编辑器在Bottle环境中工作所需的最小文件是什么?它们需要放在哪里?

这是Ace编辑器的GitHub仓库:

https://github.com/ajaxorg/ace

我猜测所需的文件是:

JS

https://github.com/ajaxorg/ace-builds/blob/master/src-noconflict/ace.js

一个主题

https://github.com/ajaxorg/ace-builds/blob/master/src-noconflict/theme-tomorrow.js

一种模式

https://github.com/ajaxorg/ace-builds/blob/master/src-noconflict/mode-javascript.js

一位工人

https://raw.github.com/ajaxorg/ace-builds/master/src-noconflict/worker-javascript.js

实施是:

HTML

<script src="/static/js/ace/ace.js"></script>

<div class="my_ace_editor">function foo(items) {
var x = "All this is syntax highlighted";
return x;
}
</div>
Run Code Online (Sandbox Code Playgroud)

CSS

#my_ace_editor {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
Run Code Online (Sandbox Code Playgroud)

jQuery的

$(document).ready(function() {
var editor = ace.edit("my_ace_editor");
editor.setTheme("ace/theme/tomorrow");
editor.getSession().setMode("ace/mode/javascript");
});
Run Code Online (Sandbox Code Playgroud)

瓶路线

@route('/static/js/ace/<filename>')
def server_static_js(filename):
    return static_file(filename, root='/static/js/ace')
Run Code Online (Sandbox Code Playgroud)

我没有收到任何Firebug错误,但Ace编辑器没有显示.

让Ace编辑器在Bottle环境中工作所需的最小文件是什么?它们需要放在哪里?

编辑: 在上面添加CSS规则后显示Ace编辑器.

bottle python-2.7 ace-editor

5
推荐指数
1
解决办法
1155
查看次数

如何通过文件元数据从GridFS中删除图像文件?

我有一个包含以下元数据的图像:

> db.fs.files.find().pretty()
{
    "_id" : ObjectId("4576874577342672346"),
    "chunkSize" : 262144,
    "user_name" : "my name",
    "filename" : "image.jpg",
    "length" : 7103,
    "uploadDate" : ISODate("2014-01-23T13:31:48.155Z"),
    "user_email" : "email@email.com",
    "md5" : "1234567890"
}
>
Run Code Online (Sandbox Code Playgroud)

我想从 Python (PyMongo) 中删除图像。

上的文档delete()似乎规定该delete()函数中唯一接受的参数是file_id

http://api.mongodb.org/python/current/api/gridfs/#gridfs.GridFS.delete

以编程方式,我有以下可以在文件元数据中匹配的值:

  • 用户名
  • 文档名称
  • 用户邮箱

我该如何:

  • 获取file_id(必要时通过使用上述值)或
  • 删除基于元数据字段以外的文件file_id

此外,我目前仅使用单个块文件进行测试,如果将来与更大的文件交互是否会删除file_id或其他元数据也会删除所有关联的块?

python mongodb pymongo gridfs

5
推荐指数
1
解决办法
6215
查看次数

Node.js将文件发送到客户端

您好,我一直在尝试从node.js向客户端发送文件.我的代码可以工作,但是当客户端转到指定的url(/helloworld/hello.js/test)时,它会传输文件.从谷歌浏览器访问它使文件(.mp3)在播放器中播放.

我的目标是让客户端的浏览器下载文件并询问客户端他想要存储它的位置,而不是在网站上传输它.

http.createServer(function(req, res) {
    switch (req.url) {
        case '/helloworld/hello.js/test':

            var filePath = path.join(__dirname, '/files/output.mp3');
            var stat = fileSystem.statSync(filePath);

            res.writeHead(200, {
                'Content-Type': 'audio/mpeg',
                'Content-Length': stat.size
            });

            var readStream = fileSystem.createReadStream(filePath);
            // We replaced all the event handlers with a simple call to readStream.pipe()
            readStream.on('open', function() {
                // This just pipes the read stream to the response object (which goes to the client)
                readStream.pipe(res);
            });

            readStream.on('error', function(err) {
                res.end(err);
            });
    }
});
Run Code Online (Sandbox Code Playgroud)

html javascript node.js

5
推荐指数
2
解决办法
3万
查看次数

updateMany()之后如何获取所有更新文档的值?

期望的行为

更新多个文档中的属性值后,访问每个已更新文档的已更新属性的值。

(对于上下文,我增加多个用户的通知计数,然后将每个更新的值发送回相应的用户(如果他们已登录socket.io

我尝试过的

let collection = mongo_client.db("users").collection("users"); 
let filter = { "user_email": { $in: users_to_notify } };
let update = { $inc: { "new_notifications": 1 } };
let result = await collection.updateMany(filter, update);

// get the `new_notifications` value for all updated documents here

Run Code Online (Sandbox Code Playgroud)

似乎没有适用于该方法的returnOriginal类型。 optionupdateMany()

https://docs.mongodb.com/manual/reference/method/db.collection.updateMany

http://mongodb.github.io/node-mongodb-native/3.2/api/Collection.html#updateMany

这是可以理解的,因为returnOriginal似乎只有在更新一个文档时才有意义,例如在findOneAndUpdate()方法的选项中。

问题

如果上述所有假设均成立,那么在方法完成 new_notifications后获取所有更新文档的值的最佳方法是什么?updateMany()

是否只是进行另一个数据库调用来获取更新的值?


例如 - 这有效:

let collection = mongo_client.db("users").collection("users"); 
let filter = { "user_email": { $in: users_to_notify } …
Run Code Online (Sandbox Code Playgroud)

mongodb node.js socket.io

5
推荐指数
1
解决办法
2509
查看次数

如何在javascript中连接多行字符串?

对于附加的正确语法有很多结果<li>,但我试图找到一个解决方案,其中+this['name']+值包含在<li>'s中.firebug正在显示'SyntaxError: unterminated string literal',jslint正在显示'Unclosed string'.我已尝试过逗号的多个不同版本,但我无法让它工作.

 $.each(data.result, function() {
     $("ul").append("<li>Name: "+this['name']+"</li>
                     <li>Age: "+this['age']+"</li>
                     <li>Company: "+this['company']+"</li>
                     <br />");
 });
Run Code Online (Sandbox Code Playgroud)

谢谢.

javascript append

4
推荐指数
1
解决办法
9946
查看次数

在2012年11月,通过json和php获取youtube数据的正确语法是什么?

我很难通过json和php获取youtube视频数据.

我花了整整一个晚上和早上尝试从网络上的代码片段和堆栈溢出.

他们没有工作的事实告诉我,我没有使用最新的语法.

我认为提出这个问题的最明确的方法是询问以下属性是否正确,如2012年11月.

所以这是我的初始变量声明:

$json = file_get_contents("http://gdata.youtube.com/feeds/api/videos/{$random_text}?v=2&alt=json");
$json_data = json_decode($json);
Run Code Online (Sandbox Code Playgroud)

任何人都可以告诉我,如果以下是正确的:

1.  $video_title = $json_data->{'entry'}->{'title'};
2.  $video_date = $json_data->{'entry'}->{'published'};
3.  $video_duration = $json_data->{'entry'}->{'media:group'}->{'yt$duration'};
4.  $video_views = $json_data->{'entry'}->{'yt$statistics'}->{'viewCount'};
5.  $video_description = $json_data->{'entry'}->{'content'};
Run Code Online (Sandbox Code Playgroud)

我不想通过提供太多其他代码和信息来淡化问题,但我得到的错误之一是:

Catchable fatal error: Object of class stdClass could not be converted to string
Run Code Online (Sandbox Code Playgroud)

所以我知道其中一个属性是不正确的.

谢谢你的帮助,我要去喝咖啡然后回来吧!

研究

这些资源是我想要获得的属性的直接api引用,应该可以工作,但它们似乎不是:(.

饲料和进入结构:

https://developers.google.com/youtube/2.0/developers_guide_protocol_understanding_video_feeds#Understanding_Video_Entries

条目的内容:

https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_entry

标题标签:

https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_title

发布标签:

https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_published

yt:持续时间标签:

https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_yt:duration

yt:statistics> viewCount标签:

https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_yt:statistics

内容标签(视频说明):

https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_content

代码示例(根据要求)

所以我在做的是:

  • 我有一张表格
  • 提交后,它由php文件(insert.php)处理
  • 这会对数据进行一些更改,然后提交到数据库
  • 我在$ final_li_code开头的行中得到错误消息(但是如果没有包含json变量,则代码有效,所以问题在于json变量)
  • (我被告知这种形式很容易被sql注入,但它不是一个面向公众的形式,即它是受htaccess/htpasswd保护的).

这是insert.php的相关代码:

// basic form information
$field1 …
Run Code Online (Sandbox Code Playgroud)

php syntax json youtube-api

4
推荐指数
1
解决办法
1259
查看次数

如何将数千个分隔符添加到已在python中转换为字符串的数字?

在我的场景(python 2.7)中,我有:

str(var)

其中var是一个变量,有时需要数千个分隔符,例如1,500,但正如您所看到的那样,已转换为字符串(用于连接目的).

我希望能够将该变量打印为具有数千个分隔符的字符串.

我已经阅读了为数字添加格式的解决方案,例如:

>>> '{:20,.2}'.format(f)
'18,446,744,073,709,551,616.00'
Run Code Online (Sandbox Code Playgroud)

来自/sf/answers/127623261/

但这似乎仅适用于数字,而不适用于已转换为字符串的数字.

谢谢.

编辑: 对于更具体的上下文,这是我的实现场景:

print 'the cost = $' + str(var1) + '\n'
print 'the cost = $' + str(var2) + '\n'
Run Code Online (Sandbox Code Playgroud)

我有几个'vars'.

python formatting python-2.7

4
推荐指数
1
解决办法
691
查看次数