我找到了这个CSP片段,但我不知道将它放在HTML中的哪个位置.
Content-Security-Policy: script-src 'self' https://apis.google.com
Run Code Online (Sandbox Code Playgroud)
解?
var policy = "default-src 'self'";
http.createServer(function (req, res) {
res.writeHead(200, {
'Content-Security-Policy': policy
});
});
Run Code Online (Sandbox Code Playgroud) 我正在研究这段代码,我不明白这行是做什么的: [(y << 3) + x]
for (int y = 0; y <= 7; ++y) {
for (int x = 0; x <= 7; ++x) {
final String pieceCode = pieceCodes[(y << 3) + x];
if (pieceCode.length() != 2) throw new IllegalArgumentException();
if (!pieceCode.equals("--")) {
pieces[((7 - y) << 3) + x] = CheckersPiece.valueOf(pieceCode.charAt(0), pieceCode.charAt(1));
}
}
}
Run Code Online (Sandbox Code Playgroud) Base 64采用3 Byte(24位)并通过4*6位表示这些.如果数据不能除以3,则额外的字节被视为一种填充?这个填充是否负责base64表示大于二进制编码?
或者为什么base64更大?
我想开始一个CSS转换,background-color如果单击一个按钮,它会改变和维度.但是代码中有一个错误:
jQuery的
$(function() {
$('#change').click(function() {
$('#box').addClass('change');
});
});
Run Code Online (Sandbox Code Playgroud)
HTML
<div id="box" class="start"></div>
<div id="button">click</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.start{
height:100px;
width:100px;
background: black;
transition: all 2.0s linear;
-webkit-transition: all 0.8s linear;
-moz-transition: all 0.8s linear;
-ms-transition: all 0.8s linear;
-o-transition: all 0.8s linear;
}
.change{
width: 200px;
height: 200px;
background:yellow;
}
#button{
width: 80px;
height: 20px;
padding: 4px;
margin: 5px;
border:solid 1px black;
background: grey;
cursor: pointer;
color: white;
}
Run Code Online (Sandbox Code Playgroud) 我找到了nodeJS服务器的示例代码.我不明白这行代码的作用是什么,它的真实含义是:
var urlParts = url.parse(req.url, true)
Run Code Online (Sandbox Code Playgroud)
以下几行对我来说也不清楚.为什么写data.txt是必要的?
fs.writeFileSync("data.txt", data);
Run Code Online (Sandbox Code Playgroud)
服务器
server = http.createServer(function(req, res) {
res.writeHead(200, {
'Content-Type': 'text/plain',
'Access-Control-Allow-Origin': 'http://localhost'
});
var urlParts = url.parse(req.url, true),
data = urlParts.query.data;
fs.writeFileSync("data.txt", data);
res.end("OK");
});
Run Code Online (Sandbox Code Playgroud)