我在一个主题分支上开始做一些工作
•-•-• < topic
/
•-• < master
Run Code Online (Sandbox Code Playgroud)
我推动主题分支
$ git push origin topic
Run Code Online (Sandbox Code Playgroud)
其他人将更改推送到主人
•-•-• < origin/topic
/
•-•-•—• < origin/master
Run Code Online (Sandbox Code Playgroud)
历史应该是这样的
•-•-• < topic
/
•-•-•—• < master
Run Code Online (Sandbox Code Playgroud)
; update master
$ git checkout master
$ git fetch origin
$ git merge --ff-only origin/master
; rebase topic
$ git checkout topic
$ git rebase master
Run Code Online (Sandbox Code Playgroud)
我的所有提交topic都被认为是未提交的.所以,当我尝试时git push origin topic,我得到了
! [rejected] topic -> topic (non-fast-forward)
error: failed to push some refs …Run Code Online (Sandbox Code Playgroud) 我想这与数组填充类似,但我想知道它是否可以简化.
var arr = [1,2,3],
x = 5;
for (var i=0; i<x; i++) {
arr.push(x);
}
console.log(arr);
//=> [1, 2, 3, 5, 5, 5, 5, 5]
Run Code Online (Sandbox Code Playgroud)
有没有办法在不使用for循环的情况下执行此操作?
更新
即使有移动器聪明的解决方案,for循环似乎是最高性能的
我试过这个,它运行正常
<p alt="world">hello</p>
Run Code Online (Sandbox Code Playgroud)
用CSS
p::after {
content: attr(alt);
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试时它不起作用
<img src="http://placehold.it/300x300" alt="my image caption">
Run Code Online (Sandbox Code Playgroud)
用CSS
img::after {
content: attr(alt);
}
Run Code Online (Sandbox Code Playgroud)
是否可以为img使用CSS 输出替代文字?
请指出浏览器与您提供的任何解决方案兼容.
试图使用TypeScript弄湿我的脚,但我一直遇到麻烦。今天,一个旧功能浮出水面,并且作为练习,我很好奇是否可以将其转换为TypeScript。到目前为止,颈部已经完全疼痛。
declare type Ord = number | string;
// type signature for f sucks really bad
// (f: Ord => Ord => boolean) would be really nice, if possible
// but instead I have to give names (_) for the parameters? dumb
const arrayCompare = (f: (_: Ord) => (_: Ord) => boolean) => ([x,...xs]: Ord[]) => ([y,...ys]: Ord[]): boolean => {
if (x === undefined && y === undefined)
return true;
else if …Run Code Online (Sandbox Code Playgroud) PHP人民,我已经厌倦了这样做
$value = isset($arr[$key]) ? $arr[$key] : null;
Run Code Online (Sandbox Code Playgroud)
或这个
$value = array_key_exists($key, $arr) ? $arr[$key] : null;
Run Code Online (Sandbox Code Playgroud)
不要没有人告诉我这样做
$arr = array(1);
$key = 5;
$value = $arr[$key];
// Notice: Undefined offset: 5
Run Code Online (Sandbox Code Playgroud)
我得了支气管炎.不是没有人有时间f'dat.
我想能做出一个功能......
function array_get(Array $arr, $key, $default=null) {
return array_key_exists($key, $arr)
? $arr[$key]
: $default
;
}
Run Code Online (Sandbox Code Playgroud)
但这是最好的(最惯用的)方式吗?
我有两个对象:
1)
{A: 10, B: 20, C: 30}
Run Code Online (Sandbox Code Playgroud)
2)
{A: 10, B: 22, C: 30}
Run Code Online (Sandbox Code Playgroud)
你可以看到:除了一件事之外,几乎是平等的:关键B值是不同的.
我怎样才能进入我的someNewArr关键价值差异?
像someNewArr:( {B: 22}我从第二个对象获取值)
我正在使用角度,我的意思是这样的:
var compareTwoObjects = function(initialObj, editedObj) {
var resultArr = [];
angular.forEach(initialObj, function(firstObjEl, firstObjInd) {
angular.forEach(editedObj, function(secondObjEl, secondObjInd) {
if (firstObjEl.key === secondObjEl.key && firstObjEl.value !== secondObjEl.value){
resultArr.push({firstObjEl.key: secondObjEl.value});
}
})
});
});
Run Code Online (Sandbox Code Playgroud) 在Firefox 43上使用以下代码打开名为index.html的文件会出现以下错误:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script>
"use strict";
class RangeIterator {}
</script>
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我在控制台中看到以下错误:
SyntaxError: class is a reserved identifier
Run Code Online (Sandbox Code Playgroud)
知道我为什么会收到这个错误吗?
我在项目中做了一些按位操作,我想知道内置的类型数组是否会让我有些头疼,甚至可能会给我带来一点性能提升.
let bytes = [128, 129, 130, 131]
let uint32 = (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3]
//=> -2138996093
Run Code Online (Sandbox Code Playgroud)
我可以使用类型化数组来获得相同的答案吗?
// not actually working !
let uint8bytes = Uint8Array.from(bytes)
let uint32 = Uint32Array.from(uint8bytes)[0]
//=> ideally i'd get the same value as above: -2138996093
Run Code Online (Sandbox Code Playgroud)
问题:
我发现奇怪的是uint32上面的内容是否定的 - 显然不是很......没有签名,因为var的名字暗示......
如果我将二进制八位字节混合并解析它,我会得到免费的肯定答案
// 128 129 130 131
let bin = '10000000' + '10000001' + '10000010' + '10000011'
let uint32 = Number.parseInt(bin,2)
console.log(uint32)
// …Run Code Online (Sandbox Code Playgroud)我试图通过减少这个函数来包围Cont和callCC:
s0 = (flip runContT) return $ do
(k, n) <- callCC $ \k -> let f x = k (f, x)
in return (f, 0)
lift $ print n
if n < 3
then k (n+1) >> return ()
else return ()
Run Code Online (Sandbox Code Playgroud)
我设法达到了这一点:
s21 = runContT (let f x = ContT $ \_ -> cc (f, x) in ContT ($(f,0))) cc where
cc = (\(k,n) -> let
iff = if n < 3 then k (n+1) else ContT ($()) …Run Code Online (Sandbox Code Playgroud) 脚本文件
$filename = realpath(sprintf("%s/%s", getcwd(), $argv[1]));
var_dump($filename);
Run Code Online (Sandbox Code Playgroud)
让我们尝试一些事情
[/foo/bar/bof] $ php script.php ../foo.txt
string(16) "/foo/bar/foo.txt"
[/foo/bar/bof] $ php script.php ../nonexistent.txt
bool(false)
Run Code Online (Sandbox Code Playgroud)
该死!realpath返回 false 因为文件不存在。
我想看到的../nonexistent.txt是
string(24) "/foo/bar/nonexistent.txt"
Run Code Online (Sandbox Code Playgroud)
如何获取 PHP 中任何相对路径的规范化路径?
注意:我看到了一些有关解析符号链接路径的问题。这些问题的答案不适用于我的问题。
javascript ×4
arrays ×3
php ×2
angularjs ×1
concat ×1
css ×1
ecmascript-6 ×1
git ×1
git-rebase ×1
haskell ×1
html ×1
html5 ×1
idioms ×1
monads ×1
pad ×1
path ×1
realpath ×1
typed-arrays ×1
typescript ×1