我是一个明确的新手,所以为垃圾编码道歉!我为自己设定的练习项目编写了以下Jquery:
单击div时,它会添加"in_answerbox1"类,并在answerbox中创建克隆的div,并添加"answerbox_letter1"类.
最终网格中会有很多div(或表格中的单元格),当您点击某个特定的网格时,它会淡出并似乎出现在答案框中.然后,当您单击答案框中的内容时,网格中的相关div将重新出现,克隆将从答案框中删除.
但是,我现在只想添加类,如果我点击的东西不在答案框中:即,如果原始或克隆有一个包含"answerbox"的类.
我写了下面的内容,知道它不起作用,但它可以解释我想要的更好.
var n = 0;
$('#box').click(function(){
if(!$(this).hasClass('*[class^="answerbox"]')) {
$(this).addClass('in_answerbox' + (n+ 1) );
$(this).clone().appendTo('#answerbox').addClass('answerbox_letter' + (n + 1));
n = (n + 1);
}
});
Run Code Online (Sandbox Code Playgroud)
有什么建议?
我的问题是关于与PM2一起运行HTTP服务器.
我面临的问题是:
所以我尝试了以下(请注意应该将参数传递给HTTP服务器脚本的双破折号:
/node_modules/http-server/lib$ pm2 start http-server.js -- /home/unixuser/websiteroot -p8686
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
我也尝试过:
http-server /home/unixuser/websiteroot -p8686
Run Code Online (Sandbox Code Playgroud)
哪个有效,但没有pm2的大力支持?
任何建议都会很棒,谢谢!
我工作的公司目前使用一些基本功能来抽象OCI库作为数据库连接的手段.我们正在考虑切换到PHP的PDO对象,但从一些快速搜索来看,看起来Oracle驱动程序比其他PDO驱动程序稍微不成熟.对于在生产环境中使用PDO/oci8的人,我将不胜感激.
谢谢!
我正在尝试使用Rails创建一个按钮,使用Rails上传图片.我试过这个:
<input class="tiny round disabled button" name="picture[picture]" type="file">
Run Code Online (Sandbox Code Playgroud)
不幸的是,它没有工作,并创建了两个不同的按钮,让您选择一张图片.我需要专门为文件字段做些什么吗?
一位朋友问我这个问题,我给了事实上两个选择.
第一种方法,测试文件权限:
//adapted from https://stackoverflow.com/questions/11775884/nodejs-file-permissions#answer-11781404
var fs = require('fs')
function canWrite(directory) {
var stat = fs.statSync(directory)
// 2 is the octal value for chmod -w-
return !!( 2 & (stat.mode & parseInt('777', 8)).toString(8)[0] ) //first char is the owner
}
Run Code Online (Sandbox Code Playgroud)
如果user(process.uid)不是文件系统所有者(stat.uid)也不在它的group(process.gid vs stat.gid)中怎么办?它仍然会获得644权限并且无法写入.
我们怎样才能真正知道(使用nodejs)当前用户属于文件系统组(stat.gid)?容易在bash中,但可移植它会是与一个的NodeJS乱七八糟.
第二种方式,懒惰:
var fs = require('fs')
var canWrite = true
try {
fs.writeFileSync('./test')
fs.unlinkSync('./test')
} catch(e) {
canWrite = false
}
if(canWrite) {
//go …Run Code Online (Sandbox Code Playgroud) 首先,我已经阅读了这个相关问题和另一种方法(博客文章).
这是我的behat.yml:
default:
suites:
users:
contexts:
- DoctrineFixturesContext
- FeatureContext
- Behat\MinkExtension\Context\MinkContext
- Sanpi\Behatch\Context\RestContext
- Sanpi\Behatch\Context\JsonContext
paths: [%paths.base%/features/users]
extensions:
Behat\Symfony2Extension:
kernel:
env: "test"
debug: "true"
Behat\MinkExtension:
base_url: ''
sessions:
default:
symfony2: ~
Sanpi\Behatch\Extension: ~
Run Code Online (Sandbox Code Playgroud)
现在我想要的是重现用户的行为,即:
Authorization带令牌的标头我发现最简单的方法是简单地模仿用户行为:
class FeatureContext implements Context, SnippetAcceptingContext
{
private $request;
public function __construct(Request $request)
{
$this->request = $request;
}
/**
* @BeforeScenario @Login
*/
public function login()
{
$d = $this->request->send('POST', '/login_check', ['_username' => 'test', …Run Code Online (Sandbox Code Playgroud) 这就是我在完美世界中所做的事情:
fs.open('somepath', 'r+', function(err, fd) {
fs.write(fd, 'somedata', function(err, written, string) {
fs.rewind(fd, 0) //this doesn't exist
})
})
Run Code Online (Sandbox Code Playgroud)
这是我目前的实施:
return async.waterfall([
function(next) {
//opening a file descriptor to write some data
return fs.open('somepath', 'w+', next)
},
function(fd, next) {
//writing the data
return fs.write(fd, 'somedata', function(err, written, string) {
return next(null, fd)
})
},
function(fd, next) {
//closing the file descriptor
return fs.close(fd, next)
},
function(next) {
//open again to reset cursor position
return fs.open('somepath', 'r', next)
}
], …Run Code Online (Sandbox Code Playgroud) HTML
<p style="font-size:24px;">Inline Test</p>
<p class="1head">TEST</p>
<p class="1body">TEST</p>
Run Code Online (Sandbox Code Playgroud)
CSS
@font-face {
font-family: SegoeUI;
src: url(segoeui.ttf);/*Yes it is licensed*/
}
body {
padding:0px;
font-family:SegoeUi;
margin:0px;
font-weight: 400;
}
.1head {
font-size:24px;
color:#2c3e50;
padding-bottom:10px;
}
.1body {
font-size:16px;
color:#2c3e50;
}
Run Code Online (Sandbox Code Playgroud)
P元素似乎不接受类或ID.当我使用我的网络浏览器工具查看CSS是否正常通过时,它根本不会出现.其他CSS元素,如div等...接受来自相同样式表的CSS.我迷路了,我真的找不到问题.