如果我将脚本保存在与被操作的图像相同的目录中,则此方法有效.结果图像"foo.jpg"也在同一位置生成.
<?php
$im = new imagick('image.jpg');
$im->thumbnailImage( 200, 0);
$im->writeImage("foo.jpg");
?>
Run Code Online (Sandbox Code Playgroud)
但是,如果脚本位于一个位置并且我希望使用的图像位于另一个位置并且我希望将缩略图保存到的位置在其他位置,如何指定这些路径呢?
做这样的事情不起作用:
$im = new imagick('path/to/image.jpg');
Run Code Online (Sandbox Code Playgroud) 我试图理解这个查询的确切作用:
SELECT DISTINCT `state`, `state_name` FROM `geo` ORDER BY `state_name` ASC
Run Code Online (Sandbox Code Playgroud)
我要做的就是选择2列(state和state_name),我只想要唯一的行,这些行没有州字段的重复值.我不在乎state_name字段中是否有重复的值.
我的查询是检查两列的唯一性还是只是状态?
我有一个数组已按字母顺序包含所有值:
Alligator
Alpha
Bear
Bees
Banana
Cat
Cougar
Run Code Online (Sandbox Code Playgroud)
现在我只想列出每个以上面开头的第一个字母,如下所示:
A
---
Alligator
Alpha
B
---
Bear
Bees
Banana
C
---
Cat
Cougar
etc...
Run Code Online (Sandbox Code Playgroud)
如何才能做到这一点?
就像MySQL Optimizer如何将查询转换为更有效的查询一样,是否有类似的优化过程在PHP幕后进行?PHP在哪里获取代码,在执行代码之前对其进行分析并将其转换为更高效的代码?
这对我不起作用:
var foo = "Collection%3A 9 Bad Interviews With Former GOP Presidential Candidates";
console.log(decodeURI(foo));
Run Code Online (Sandbox Code Playgroud)
它输出:
Collection%3A 9 Bad Interviews With Former GOP Presidential Candidates
Run Code Online (Sandbox Code Playgroud)
这是不正确的,如果你在这样的网站上输入foo字符串:
http://meyerweb.com/eric/tools/dencoder/
它显示正确的输出,即:
Collection: 9 Bad Interviews With Former GOP Presidential Candidates
Run Code Online (Sandbox Code Playgroud)
如何正确解码字符串?
我不想使用Express默认提供的Jade模板引擎.我试图遵循本指南,但它失败了:
http://blog.luksidadi.com/expressjs-underscore-template/
有问题的错误是:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: callback function required
at Function.engine (/home/me/blog/node_modules/express/lib/application.js:173:38)
at Object.<anonymous> (/home/tk/blog/app.js:28:5)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Array.0 (module.js:470:10)
at EventEmitter._tickCallback (node.js:192:40)
Run Code Online (Sandbox Code Playgroud)
当我尝试使用以下命令启动服务器时,我得到了这个:
node app.js
Run Code Online (Sandbox Code Playgroud)
怎么解决这个?
app.js:
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, user = require('./routes/user')
, http = require('http')
, path = require('path');
var app = express();
app.configure(function(){
app.set('port', …Run Code Online (Sandbox Code Playgroud) 我找到了一个处理HTML5文件阅读器API的JavaScript.它是用纯JavaScript编写的,我正在将它转换为jQuery脚本.但是我在这一点上陷入困境.
这有效:
document.getElementById('drop-area').addEventListener('drop', function(e) {
e.preventDefault();
e.stopPropagation();
console.log(e.dataTransfer.files); // outputs the right stuff
}, false);
Run Code Online (Sandbox Code Playgroud)
这失败了:
$('#drop-area').on('drop', function(e) {
e.preventDefault();
e.stopPropagation();
console.log(e.dataTransfer.files); // ERROR: e.dataTransfer is undefined
});
Run Code Online (Sandbox Code Playgroud)
这个问题有什么解决方案?
在users表格中,我有一个字段dob,用于以这种格式存储用户的出生日期:
1959-04-02
Run Code Online (Sandbox Code Playgroud)
无论如何,我想选择所有18岁和19岁的用户.这是我的查询:
SELECT *
FROM `users`
WHERE dob BETWEEN '1993-10-30' AND '1994-10-30'
Run Code Online (Sandbox Code Playgroud)
但它似乎只选择了大多数18岁的孩子和一些(但不是全部)19岁的孩子.我在数据库中有一堆测试用户,18和19岁的人数相等.然而,这个问题产生了大约90%的18岁儿童和大约10%的19岁儿童.为什么?
我知道在其他帖子中已经提到过这个问题,但这些答案并不适合我的情况.如果你从这里嵌入twitter关注按钮:
https://twitter.com/about/resources/buttons
<a href="https://twitter.com/share" class="twitter-share-button">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
Run Code Online (Sandbox Code Playgroud)
JS用iframe替换了链接:
<iframe scrolling="no" frameborder="0" allowtransparency="true" src="http://platform.twitter.com/widgets/tweet_button.1360366574.html#_=1360791644346&count=horizontal&id=twitter-widget-0&lang=en&original_referer=http%3A%2F%2Fwww.foo.com%2Fsearch%2Fcats&size=m&text=Search%20Results%20for%20%22cats%22%20on%20Foo&url=http%3A%2F%2Fwww.foo.com%2Fsearch%2Fcats" class="twitter-share-button twitter-count-horizontal" style="width: 109px; height: 20px;" title="Twitter Tweet Button" data-twttr-rendered="true"></iframe>
Run Code Online (Sandbox Code Playgroud)
如您所见,宽度设置为内联样式.我知道我可以用以下内容覆盖这个:
.twitter-share-button { width: 80px !important; }
Run Code Online (Sandbox Code Playgroud)
例如,但我不想这样做,因为如果共享计数增加到特定内容页面上的非常大的数字,该怎么办?然后,共享计数将被最小宽度遮挡.
有没有办法告诉twitter根据内部的共享数量来确定返回的iframe的大小,以便它不大于它需要的最小所需宽度?
我知道Facebook通过data-width我认为的数据属性接受所需的宽度,这可以设置为auto来获取我上面要求的行为类型.twitter是否为他们的分享按钮提供类似的东西?
javascript ×4
php ×3
jquery ×2
mysql ×2
css ×1
express ×1
filereader ×1
html ×1
html5 ×1
imagemagick ×1
imagick ×1
node.js ×1
pug ×1
sql ×1
twitter ×1