跟进https://serverfault.com/questions/191331/should-servers-have-their-timezone-set-to-gmt-utc的问题
MySQL时区应该设置为UTC还是应该设置为与服务器或PHP设置相同的时区?(如果不是UTC)
优缺点都有什么?
在SQLite中,如何选择some_column为空的记录?
空计为NULL和"".
如何在youtube iframe嵌入视频上叠加半透明不透明度的div?
<iframe class="youtube-player" type="text/html" width="520" height="330" src="http://www.youtube.com/embed/NWHfY_lvKIQ" frameborder="0"></iframe>
<div id="overlay"></div>
Run Code Online (Sandbox Code Playgroud)
CSS
#overlay {
position:fixed;
top:0;
left:0;
width:100%;
height:100%;
background:#000;
opacity:0.8;
/*background:rgba(255,255,255,0.8); or just this*/
z-index:50;
color:#fff;
}
Run Code Online (Sandbox Code Playgroud)
编辑(添加更多说明):
HTML5正在逼近我们,越来越多的设备使用它而不是闪存,这使得youtube视频的嵌入变得复杂,幸好youtube提供了一个特殊的可嵌入iFrame,可以处理所有视频嵌入兼容性问题,但是现在以前使用半透明div覆盖视频对象的方法不再有效,我现在无法添加<param name="wmode" value="transparent">
到对象,因为它现在是iFrame,所以如何在顶部添加不透明的div iframe嵌入式视频?
作为一般的经验法则,如果将gif交错,png交错和jpeg渐进是合适的吗?
特别是在网络上发布图像时.
我已经在互联网和stackoverflow上搜索了很长时间来回答这个问题,我发现链接表明你不应该把meta标签放在正文中:
schema.org网站清楚地显示了元标记直接嵌套在主体http://schema.org/AggregateRating中
只需看看那里发布的示例
Customer reviews:
<div itemprop="reviews" itemscope itemtype="http://schema.org/Review">
<span itemprop="name">Not a happy camper</span> -
by <span itemprop="author">Ellie</span>,
<meta itemprop="datePublished" content="2011-04-01">April 1, 2011
<div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
<meta itemprop="worstRating" content = "1">
<span itemprop="ratingValue">1</span>/
<span itemprop="bestRating">5</span>stars
</div>
<span itemprop="description">The lamp burned out and now I have to replace
it. </span>
</div>
<div itemprop="reviews" itemscope itemtype="http://schema.org/Review">
<span itemprop="name">Value purchase</span> -
by <span itemprop="author">Lucas</span>,
<meta itemprop="datePublished" content="2011-03-25">March 25, 2011
<div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
<meta itemprop="worstRating" content …
Run Code Online (Sandbox Code Playgroud) 有没有办法从javascript文件中的字符串添加CSS到javascript文档的头部?
假设我们有一个网页,它有一个灯箱脚本,这个脚本需要一个css文件来运行.
现在添加此css文件<link>
将使css文件下载,即使对于没有启用js的人也是如此.
我知道我可以使用脚本动态加载css文件,但这也意味着将有2个http请求,并且在文件中几乎没有css的情况下,我发现这个效率低下.
所以我想,如果你可以将css文件中的css放入脚本中,让脚本解析css并将其添加到头部,或者更好的是让脚本直接添加css在<head>
该文件中.
但是我没有在网上发现这表明这是可能的,所以有可能用js将css添加到头部吗?
我编辑了roryf的跨浏览器工作的答案(IE5除外)
使用Javascript:
function addcss(css){
var head = document.getElementsByTagName('head')[0];
var s = document.createElement('style');
s.setAttribute('type', 'text/css');
if (s.styleSheet) { // IE
s.styleSheet.cssText = css;
} else { // the world
s.appendChild(document.createTextNode(css));
}
head.appendChild(s);
}
Run Code Online (Sandbox Code Playgroud) 在php中有一种方法可以从字符串中提供唯一的哈希值,但哈希值只是由数字组成的?
例:
return md5(234); // returns 098f6bcd4621d373cade4e832627b4f6
Run Code Online (Sandbox Code Playgroud)
但是我需要
return numhash(234); // returns 00978902923102372190
(20 numbers only)
Run Code Online (Sandbox Code Playgroud)
这里的问题是我希望哈希很短.
编辑: 好的,让我来解释这里的背景故事.我有一个网站,每个注册人都有一个ID,我也需要一个ID供该人使用和交换(因此不能太长),到目前为止ID编号为00001,00002,00003等. ..
要修复第1点和第2点,我需要"隐藏"数字,同时保持其唯一性.
数字哈希函数基于/sf/answers/1657590931/的代码
/**
* Return a number only hash
* https://stackoverflow.com/a/23679870/175071
* @param $str
* @param null $len
* @return number
*/
public function numHash($str, $len=null)
{
$binhash = md5($str, true);
$numhash = unpack('N2', $binhash);
$hash = $numhash[1] . $numhash[2];
if($len && is_int($len)) {
$hash = substr($hash, 0, $len);
}
return $hash;
}
// Usage …
Run Code Online (Sandbox Code Playgroud) 在URL查询字符串中使用多维数组合成器实际上是安全/有效的吗?
http://example.com?abc[]=123&abc[]=456
Run Code Online (Sandbox Code Playgroud)
它似乎适用于每个浏览器,我一直认为它可以使用,但在本文中评论它不是:http://www.456bereastreet.com/archive/201008/what_characters_are_allowed_unencoded_in_query_strings/#comment4
我想听听第二个意见.
你如何在php中检查字符串是否是sql语句的有效兼容列名?只是一个字符串匹配.
如何只使用一个SQL查询获取mysql中的maxmum日期和最小日期?