我有一系列的短语.我想在一个循环中从数组中随机选择短语.我不想在循环中再次选择相同的短语.我以为我可以随机选择短语,然后在下一个循环之前将其删除.
<?php
for ($i=0; $i<16; $i++) {
$phrases = array(
'Hello Sailor', 'Acid Test', 'Bear Garden', 'Botch A Job',
'Dark Horse', 'In The Red', 'Man Up', 'Pan Out',
'Quid Pro Quo', 'Rub It In', 'Turncoat', 'Yes Man',
'All Wet', 'Bag Lady', 'Bean Feast', 'Big Wig',
);
$ran_Num = array_rand($phrases);
$ran_Phrase = $phrases[$ran_Num];
unset($phrases[$ran_Phrase]);
echo $ran_Phrase . "\r\n";
echo count($phrases) . "\r\n";
}
Run Code Online (Sandbox Code Playgroud)
是否有可能在每个循环中从数组中随机选择一个不同的短语?
我在网上找到了这个Angular Directive来添加一个twitter分享按钮.这一切似乎都是明星前进,但我无法弄清楚attrs.$observe实际上在做什么.
我查看了文档,但无法$observe在任何地方看到引用.
该指令似乎只是添加了href来自控制器的指令,所以任何人都可以解释其余代码在做什么?
module.directive('shareTwitter', ['$window', function($window) {
return {
restrict: 'A',
link: function($scope, element, attrs) {
$scope.share = function() {
var href = 'https://twitter.com/share';
$scope.url = attrs.shareUrl || $window.location.href;
$scope.text = attrs.shareText || false;
href += '?url=' + encodeURIComponent($scope.url);
if($scope.text) {
href += '&text=' + encodeURIComponent($scope.text);
}
element.attr('href', href);
}
$scope.share();
attrs.$observe('shareUrl', function() {
$scope.share();
});
attrs.$observe('shareText', function() {
$scope.share();
});
}
}
}]);
<a href="" target="_blank" share-twitter share-url="[[shareTwitterUrl]]" share-text="[[shareTwitterText]]">Twitter</a>
Run Code Online (Sandbox Code Playgroud) 我正在尝试快速htaccess来阻止除了我的ip之外的所有内容.
我有这个
order deny, allow
deny from all
allow from "MY IP"
Run Code Online (Sandbox Code Playgroud)
"我的IP"是我的IP
我无法看到是否来自我的ip - 这是正确的方法吗?
在工作中我有一个代理,在家里我没有代理
在工作中我设置代理如:
git config - -global http.proxy http://proxy.theaddress.co.uk:8080
git config - -global https.proxy https://proxy.theaddress.co.uk:8080
Run Code Online (Sandbox Code Playgroud)
在家里我删除了代理
git config --global --unset http.proxy
git config --global --unset https.proxy
Run Code Online (Sandbox Code Playgroud)
我正试着用我的git repo推送一些东西
git push -u origin master
Run Code Online (Sandbox Code Playgroud)
我明白了
Could not resolve proxy: proxy.theaddress.co.uk
Run Code Online (Sandbox Code Playgroud)
.gitconfig文件如下所示.
[user]
name = first last
email = first.last@sitname.co.uk
[http]
[https]
[push]
default = current
[http]
[core]
excludesfile = /Users/first.last/.gitignore_global
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
trustExitCode = …Run Code Online (Sandbox Code Playgroud) 我这里有一个jsfiddle - http://jsfiddle.net/gh4Lur4b/8/
这是一个全宽度的自举旋转木马.
我想改变高度,仍然保持全宽.
高度是由图像高度决定的.
如何调整转盘的高度并保持100%的宽度.
.carousel-inner{
// height: 300px;
}
.item, img{
height: 100% !important;
width: 100% !important;
border: 1px solid red;
}
Run Code Online (Sandbox Code Playgroud) 我这里有一个jsfiddle - http://jsfiddle.net/w23v50h5/1/
div {
position: absolute;
left: 315px;
top: 143px;
width: 50px;
height: 50px;
background: red;
-webkit-animation: myOrbit 6s linear infinite;
-moz-animation: myOrbit 6s linear infinite;
-o-animation: myOrbit 6s linear infinite;
animation: myOrbit 6s linear infinite;
}
@-webkit-keyframes myOrbit {
from { -webkit-transform: rotate(0deg) translateX(5px) translateY(120px) rotate(0deg);}
to { -webkit-transform: rotate(360deg) translateX(5px) translateY(120px) rotate(-360deg); }
}
@-moz-keyframes myOrbit {
from { -moz-transform: rotate(0deg) translateX(100px) rotate(0deg); }
to { -moz-transform: rotate(360deg) translateX(100px) rotate(-360deg); }
}
@-o-keyframes myOrbit {
from { …Run Code Online (Sandbox Code Playgroud) 我这里有一个jsfiddle - http://jsfiddle.net/apbuc773/
我想用svg创建一个明星.
我想打动明星的外面.在我的例子中,笔划在每条线上,解剖内部形状.
也可以半满星形.
我想用它来获得星级评分,但我需要一半,也许四分之一的填充.
<svg height="210" width="500">
<polygon points="100,10 40,198 190,78 10,78 160,198" style="fill:red;stroke:blue;"/>
</svg>
Run Code Online (Sandbox Code Playgroud) 我这里有一个演示
我正在尝试使用 *ngIf 添加到 DOM 后获取元素的高度
我试图通过在@ViewChild 上使用 setter 来做到这一点,该 setter 应该被称为 *ngIf 变为 true 的一个。
在我的示例中,它似乎仅在添加元素然后删除元素时才起作用(单击按钮两次)。
当元素显示时,我怎样才能让它工作。
我知道我可以用 [hidden] 而不是 *ngIf 来做到这一点,但我的实际代码有很多我不想一次放入 DOM 的元素
import { Component, Input, ElementRef, ViewChild } from '@angular/core';
@Component({
selector: 'child-comp',
templateUrl: './child.component.html'
})
export class ChildComponent{
@Input() parent: ElementRef;
private blockThree: ElementRef;
@ViewChild('blockThree') set content(content: ElementRef) {
this.blockThree = content;
}
showThree: boolean = false
blockHeightThree: number
constructor(){ }
showBlockThree(){
this.showThree = !this.showThree
this.blockHeightThree = this.blockThree.nativeElement.clientHeight;
console.log('element height '+this.blockHeightThree);
}
}
Run Code Online (Sandbox Code Playgroud) 我在这里有一个jsfiddle:http://jsfiddle.net/nH5WP/
这是一个使用Bootstrap 3的超简单3 x 3网格
我想在每个块的右边和底部添加边距.
每行中的最后一个块都在下降,我通常会删除每行中最后一个块的右边距
.box:last-child{
background: yellow;
margin: 0 0 10px 0;
}
Run Code Online (Sandbox Code Playgroud)
但这似乎不起作用.
如何在此网格中的每个块之间添加边距?
<div class="container">
<div class="row">
<div class="col-xs-4 box">
<p>One</p>
</div>
<div class="col-xs-4 box">
<p>Two</p>
</div>
<div class="col-xs-4 box">
<p>Three</p>
</div>
</div>
<div class="row">
<div class="col-xs-4 box">
<p>Four</p>
</div>
<div class="col-xs-4 box">
<p>Five</p>
</div>
<div class="col-xs-4 box">
<p>Six</p>
</div>
</div>
<div class="row">
<div class="col-xs-4 box">
<p>Seven</p>
</div>
<div class="col-xs-4 box">
<p>Eight</p>
</div>
<div class="col-xs-4 box">
<p>Nine</p>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud) 我在这里有一个Bootply:http://www.bootply.com/XLGE6Vpjov
我需要在容器中居中的3个圆圈,然后我需要里面的文本水平和垂直居中.
如何将文本垂直居中?
我知道border-radius在IE8中不起作用,但我不介意它在那里是一个正方形.
<div class="container">
<div class="row">
<div class="col-md-4 block text-center">
<p class="circle">Some Text here Some text here Some text here Some text here</p>
</div>
<div class="col-md-4 block">
<p class="circle">Some Text here</p>
</div>
<div class="col-md-4 block">
<p class="circle">Some More Text here</p>
</div>
</div>
</div>
.block{
border: 1px solid red;
text-align: center;
vertical-align: middle;
}
.circle{
background: red;
border-radius: 200px;
color: white;
height: 200px;
font-weight: bold;
width: 200px;
}
Run Code Online (Sandbox Code Playgroud)