我正在开发一个项目来创建我当前目录中的文件的数据库.我想要的关于我的文件的一个细节是在ubuntu中使用chmod设置的文件权限.(只是一个注释:我也需要组和所有者信息 - 就像chown-如果你能告诉我,如果提升可以检索所有权信息,那就太棒了.)
我正在使用boost文件系统库,我已多次检查文档,但无法找到如何获取权限.
在此页面中,它显示有enum perms文件权限字符串,这些字符串不会显示在我自己的filesystem.hpp上.(我已经检查过我有1.49版本,也是从源代码构建的,以确保).同样在这里它显示它可以获得如下权限:
perms permissions() const noexcept;
//Returns: The value of
//permissions() specified by the postconditions of the most recent call
//to a constructor, operator=, or permissions(perms) function.
Run Code Online (Sandbox Code Playgroud)
我无法找到权限函数,也无法找到存储perms列表的位置.
这是我到目前为止的代码(实际上是来自boost教程,但我将其修改为递归),如果你能告诉我如何获得文件权限/所有权或建议另一个库而不是提升我会很感激.
编辑:我已添加s.permissions()为ethan_liou建议,但输出不是预期的.这是更新的代码和输出.
// filesystem tut4.cpp ---------------------------------------------------------------//
// Copyright Beman Dawes 2009
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// Library home page: http://www.boost.org/libs/filesystem
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <boost/filesystem.hpp>
#include <stdio.h>
using namespace std; …Run Code Online (Sandbox Code Playgroud) 我有一个 PHP 类,用于读取我正在转换为 NodeJS 的二进制数据或在 NodeJS 中找到等效的几个函数。我对这个 BinaryReader 类感兴趣的函数是ReadULong和ReadUShort。我相信这些意味着读取无符号长整数(4 个字节)和无符号短整数(2 个字节)。当我试图在 NodeJS 中找到这些的等价物时,我对在这些之间使用哪个函数感到困惑:
buf.readUInt16LE(offset, [noAssert])
buf.readUInt16BE(offset, [noAssert])
buf.readUInt32LE(offset, [noAssert])
buf.readUInt32BE(offset, [noAssert])
Run Code Online (Sandbox Code Playgroud)
在这种情况下会LE或BE代表什么?
另外,我在 PHP 类上发现了一个常量,上面写着const DEFAULT_BYTE_ORDER = 'L';. 这是L相同L的readUInt32LE?这是关于字节顺序的全部内容吗?
到目前为止,我已经阅读了这些文章:
如果我能得到更多关于二进制阅读的参考资料,我将不胜感激!
我需要帮助理解剪切路径CSS 属性,以便使我的剪切圆版本如下......
更像设计版本:
如果您可以在灰色背景上看到,我的圆圈在被剪裁后显得更大且更圆。
我该怎么做才能使圆圈更圆?我的想法是:
:after元素或带半径的右边框最好,我想避免使用背景图像。但是,我需要牢记响应能力,因为当我们调整窗口大小时,圆圈无法大幅改变形状。
剪辑路径是正确的方法吗?有人可以用另一种使用 CSS 的方式提出一个更简单、更优雅的解决方案吗?
提前谢谢您,这是我写的一个片段,说明了我如何剪切“绿色/蓝色”背景:
.page-banner {
background: grey;
width: 100%;
height: 300px;
background-position: top;
overflow: hidden;
}
.page-banner-text {
position: absolute;
background: #00525d8a;
padding-left: 100px;
width: 60%;
/* adjustments to snippet */
top: 10px;
left: 10px;
height: 300px;
/* this is the code for circle */
clip-path: circle(560px at left);
padding-right: 250px;
}Run Code Online (Sandbox Code Playgroud)
<div class="page-banner">
<div class="container">
<div class="page-banner-text">
<h1 class="block-title">Programs For Adults</h1>
<p>Programs to …Run Code Online (Sandbox Code Playgroud)我一直在玩jsdom,这是node.js的一个模块.底部的以下代码来自其文档页面.我的问题是如何从异步函数返回一些东西.
我知道这个问题很多,可能也是我的问题.我也知道,当涉及到这类问题时,回调是一个好朋友.我的目标是在PHP中找到一个可能像cookie或Session变量一样的解决方法,以便在异步函数之外将这一小部分数据传输到外部作用域.然后,一旦从外部范围设置数据,就应该可以访问它.
我想知道的第一件事是:
save(data)在B点到内存,从Cretrieve(data)点到内存; 这会有用吗?老实说,我不喜欢编写临时文件来解决异步函数.我一直在寻找一种简单而有效的方法来传递数据,但是我需要像你这样有经验的程序员的一些指导来超越这个问题的不必要的方法.
如果你能为我提出一些想法,说明哪些可行,哪些可能无效,我会很感激.
这是示例代码:
// Print all of the news items on hackernews
var jsdom = require("jsdom");
// var result;
// A) Outer Scope: Since the function is async in done, storing the result here and echoing in point C is pointless.
jsdom.env({
html: "http://news.ycombinator.com/",
scripts: ["http://code.jquery.com/jquery.js"],
done: function (errors, window) {
var $ = window.$; …Run Code Online (Sandbox Code Playgroud) [user]
name = Alvin J. Alexander
email = [omitted]
[merge]
tool = vimdiff
Run Code Online (Sandbox Code Playgroud)
这是~/.gitconfig文件的样子.我以前从未遇到过这样的数据对象.这种格式是否有像json文件这样的名称?或者这是一种自定义格式?
我的目标是从此文件中提取数据以填写package.json模板.我想研究这种格式,以便更好地理解如何解析它.解析函数是否已存在?
这是一个解析它的模板:
(需要iniparser安装模块)
var iniparser = require('iniparser');
var fs = require('fs');
var home_dir = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
console.log (home_dir);
var config_file = home_dir+'/.gitconfig';
var exists = fs.existsSync(config_file);
if (exists) {
console.log("Getting some information from the git configuration...");
var config = iniparser.parseSync(config_file);
console.log(config);
return config;
}
else {
console.log("Git configuration file does not exist...");
return {};
};
Run Code Online (Sandbox Code Playgroud) 我查看了文档:
我使用以下命令创建了一个项目:
npm install --save neo4j-driver
nano index.js
Run Code Online (Sandbox Code Playgroud)
并写下了这段代码:
var neo4j = require('neo4j-driver').v1;
// Create a driver instance, for the user neo4j with password neo4j.
// It should be enough to have a single driver per database per application.
var driver = neo4j.driver("bolt://localhost:7687", neo4j.auth.basic("neo4j", "123456"));
// Register a callback to know if driver creation was successful:
driver.onCompleted = function() {
// proceed with using the driver, it was successfully instantiated
console.log('successfully connected');
};
// Register …Run Code Online (Sandbox Code Playgroud) 使用我正在制作的脚本,jquery 从 url 参数获取变量。它获取的值是一个 url,所以如果它是这样的
http://localhost/index.html?url=http://www.example.com/index.php?something=some
上面写着:
url = http://www.example.com/index.php?something
Run Code Online (Sandbox Code Playgroud)
如果它像
http://localhost/index.html?url=http://www.example.com/index.php?something%3Dsome
上面写着:
url = http://www.example.com/index.php?something%3Dsome
这将注册为有效的网址。我的问题是如何搜索变量=中的符号并将其替换为jquery 或 javascript 的url十六进制?%3D
我有一个处理mongodb数据库的开源项目.我正在尝试创建一个查询数据库以检查条目是否存在的函数.
问题是当if_exists()返回true或false时它返回undefined,因为mongodb驱动程序函数是异步的.该文件是Query.js,我在这里尝试了解决问题的方法在Node.js中进行同步MongoDB查询的正确方法是什么?但是我仍然使用get方法得到一个未定义的结果.
使这项工作的最佳方法是什么?
单元测试的输出如下:
running unit tests...
add query test
exists tests:
get: undefined
{}
should be true: undefined
get: undefined
{}
should be false:undefined
Captains Logs listening on port 3000
Captains_Logs v0.5.0-21
[ { name: 'rhcp', _id: 50cbdcbe9c3cf97203000002 } ]
[ { name: 'os', _id: 50cbdcbe9c3cf97203000001 } ]
Run Code Online (Sandbox Code Playgroud)
您可以在WeaponXI/cplog中浏览整个代码
或者快速查看query.js代码是:
var DB = require('../../lib/db.js').DB;
function methods() {
//query object
var Q = {};
//will act as our private variables to workaround …Run Code Online (Sandbox Code Playgroud) 我在coffeescript中使用while循环时遇到了一些麻烦.
原始功能如下,来源是这个答案:
// Return all pattern matches with captured groups
RegExp.prototype.execAll = function(string) {
var match = null;
var matches = new Array();
while (match = this.exec(string)) {
var matchArray = [];
for (i in match) {
if (parseInt(i) == i) {
matchArray.push(match[i]);
}
}
matches.push(matchArray);
}
return matches;
}
Run Code Online (Sandbox Code Playgroud)
它按预期工作.我通过js2coffee转换它,咖啡脚本是:
# Return all pattern matches with captured groups
RegExp::execAll = (string) ->
matches = new Array()
match = null
while match = @exec(string)
matchArray = …Run Code Online (Sandbox Code Playgroud) 我在我的节点app.coffee文件上有这个咖啡脚本代码来处理上传:
app.post "/import", (req, res) ->
console.log req.files
fs.readFile req.files.displayImage.path, (err, data) ->
newPath = __dirname + "/uploads/" + req.files.displayImage.name
fs.writeFile newPath, data, (err) ->
throw err if err
res.redirect "/"
Run Code Online (Sandbox Code Playgroud)
在JavaScript转换中,它看起来像这样:
app.post("/import", function(req, res) {
console.log(req.files);
return fs.readFile(req.files.displayImage.path, function(err, data) {
var newPath;
newPath = __dirname + "/uploads/" + req.files.displayImage.name;
return fs.writeFile(newPath, data, function(err) {
if (err) {
throw err;
}
return res.redirect("/");
});
});
});
Run Code Online (Sandbox Code Playgroud)
form(action="", method="post", enctype="multipart/form-data")
input(type="file", name="displayImage")
input(type="submit", name="Upload")
Run Code Online (Sandbox Code Playgroud)
文件数据如下所示:
{ displayImage: …Run Code Online (Sandbox Code Playgroud) node.js ×7
javascript ×5
asynchronous ×1
binaryreader ×1
boost ×1
buffer ×1
c++ ×1
clip-path ×1
coffeescript ×1
config ×1
css ×1
file-type ×1
file-upload ×1
git-config ×1
ini ×1
jquery ×1
json ×1
mongodb ×1
neo4j ×1
regex ×1
scope ×1
ubuntu ×1