在javascript/jQuery中,有没有办法识别文本块/段落中的单词?例如,假设我有以下段落:
Lorem ipsum dolor坐下来,精致的adipistur elit.Mauris suscipit interdum fermentum.Aenean fermentum imperdiet augue,et venenatis lectus semper vel.在quam egestas eleifend中的Phasellus faucibus nulla.Cras tristique augue eget libero tristique condimentum.Mauris eget diam eget risus feugiat rutrum.Duis placerat lorem quis augue semper porttitor.Nullam iaculis dui feugiat erat condimentum rutrum.在累积直径的Sed.Maecenas ut urna id velit posuere auctor in vel dui.Aeoan consectetur dui在leo faucibus sed feugiat dui blandit.在accumsan diam vitae erat volutpat volutpat aliquam nunc euismod.Vivamus viverra lorem nulla.Quisque justo quam,adipiscing坐在amet auctor non,laoreet sit amet nisl.Donec euismod lorem ac …
我只想要一个bash脚本在调用后5分钟运行.我究竟做错了什么?
我有命令:
/path/to/my/script | at now + 5 min
Run Code Online (Sandbox Code Playgroud)
然而,剧本每次都会立即运行.
我试图通过ajax(jQuery)发送200万字符大的非数据字符(非二进制字符串)的POST数据,它总是在PHP端显示为空白.这是我的代码:
var string = "<data string that is 2M chars long>";
$.ajax({
cache: false,
type: 'POST',
url: 'data.php',
data: {'data_string': string}
});
Run Code Online (Sandbox Code Playgroud)
在PHP方面,我收到以下错误消息(当尝试从中检索数据时$_POST['data_string']):
Notice: Undefined index: data_string in data.php on line ...
Run Code Online (Sandbox Code Playgroud)
我已经检查了post_max_sizephp.ini,它设置为256M应该绰绰有余?我很难过,不知道我做错了什么......
编辑:如果我制作"string"少量数据(例如var string = 'test')然后按预期$_POST["data_string"]返回test.所以我想知道我是否会在Apache2,PHP或浏览器中达到某种数据限制?我使用的是Google Chrome 17.0.963.79
EDIT2:memory_limit = 256M在php.ini中
EDIT3:max_input_time = -1在php.ini中
EDIT4:var_dump($ _ POST)返回数组(0)
EDIT5:在debian squeeze上运行PHP5的最新稳定版本:PHP 5.3.3-7 + squeeze8与Suhosin-Patch(cli)(内置:2012年2月10日14:12:26)
有没有办法在Internet Explorer中执行以下解决方案?(IE7及以上)
link:使用jQuery.ajax发送multipart/formdata
解决方案代码在IE的每个浏览器中都很有用.
我是git的新手,我希望能够在推送到origin/master之后捕获提交消息,并根据字符串包含的内容运行bash脚本(在服务器上).
例如,如果我的git commit消息说: [email] my commit message
如果提交消息包含[email]然后执行指定的操作,否则不要这样做.
这是我想在post-receive钩子中使用的示例bash脚本:
#!/bin/bash
MESSAGE= #commit message variable?
if [[ "$MESSAGE" == *[email]* ]]; then
echo "do action here"
else
echo "do nothing"
fi
Run Code Online (Sandbox Code Playgroud)
基本上我需要知道的是提交消息的变量名是什么,在上面的bash脚本中使用?另外,我不确定这是否是正确的钩子.
如何每X个字符分解一个字符串?例如,我想每1000个字符分解一个非常长的字符串,每次字符串都可以完全随机.
var string = <my text string that is thousands of characters long>
有没有办法像使用HTML5/CSS/JavaScript一样更改Flash/ActionScript中的图像颜色?
以下是Flash中的一个示例:http ://www.kirupa.com/developer/actionscript/color.htm 编辑:这是我希望复制的过程.
我正在尝试完成这样的事情(颜色变化方面,保留光照和阴影):http: //www.acura.com/ExteriorColor.aspx ? model = TL无需每次加载和替换新图像; 我希望能够简单地改变色调(即做一个纯HTML5/CSS/JS方法).编辑:这是我希望实现的结果,而不是过程.
基本上我想改变图像的调色板/色调,同时保留图像的其他方面(例如渐变,光照等).我已经接近了,但还不够近; 我已经达到了在原始图像上使用图像蒙版和复合的程度(有点像透明图像叠加).下面是一些示例代码(请注意这只是一个片段,所以它可能会或可能不会工作;我只显示示例代码,以便您了解我正在尝试做什么):
<div id='mask'>
<canvas id='canvas' width='100' height='100'></canvas>
</div>
<button data-rgba='255,0,0,0.5'>red</button>
<button data-rgba='0,255,0,0.5'>green</button>
<script>
foo = {};
foo.ctx = jQuery('#canvas')[0];
foo.ctx_context = foo.ctx.getContext('2d');
foo.mask = jQuery('#mask')[0];
foo.img = new Image();
foo.img_path = '/path/to/image_mask.png'; // 100px x 100px image
foo.changeColor = function(rgba){
foo.ctx_context.clearRect(0, 0, 100, 100);
foo.ctx_context.fillStyle = 'rgba(' + rgba + ')';
foo.ctx_context.fillRect(0, 0, 100, 100);
foo.ctx_context.globalCompositeOperation = 'destination-atop';
foo.ctx_context.drawImage(foo.img, 0, 0);
foo.ctx_context.css({'background-image': "url(" + …Run Code Online (Sandbox Code Playgroud) 有没有办法编写一个BASH脚本,将一个字符串附加到目录中的每个文件?
例如,我想将字符串"test"附加到我当前工作目录中的每个.html文件中; 就像是:
echo "test" >> *.html
Run Code Online (Sandbox Code Playgroud)
但当然这不起作用.
我正在尝试将<P>文档中的所有标记更改为<DIV>.这就是我想出来的,但它似乎不起作用:
$dom = new DOMDocument;
$dom->loadHTML($htmlfile_data);
foreach( $dom->getElementsByTagName("p") as $pnode ) {
$divnode->createElement("div");
$divnode->nodeValue = $pnode->nodeValue;
$pnode->appendChild($divnode);
$pnode->parentNode->removeChild($pnode);
}
Run Code Online (Sandbox Code Playgroud)
这是我想要的结果:
之前:
<p>Some text here</p>
Run Code Online (Sandbox Code Playgroud)
后:
<div>Some text here</div>
Run Code Online (Sandbox Code Playgroud) 这是以下的一种变体,但有一点不同:如何获得固定位置div以与内容水平滚动?使用jQuery
这是我的变化:http://jsfiddle.net/Bdwc4/
基本上,我希望能够在div的最右边看到"x",为了做到这一点,div必须是绝对的.但与此同时,我需要在垂直滚动时修复div.换句话说,在垂直或水平滚动时,您应始终能够在该固定位置看到"x".它有点像我想要它做的,但只有当你在窗口的顶部.无论你在哪里垂直滚动,我都希望能够水平滚动.
如果你选择不使用上面的jsfiddle,这里是我正在使用的代码:
<style>
.scroll_fixed {
left:500px;
position:absolute
}
.scroll_fixed.fixed {
position:fixed
}
.x { float:right }
.foo { background-color: red; width: 150px; height:150px; left:500px }
body { width: 500px }
.header { margin-top: 100px }
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script>
$(window).scroll(function(event) {
var x = 0 - $(this).scrollLeft();
var y = $(this).scrollTop();
// whether that's below the form
if (y) {
// if so, ad the fixed class
$('.scroll_fixed').addClass('fixed');
} else {
// otherwise remove …Run Code Online (Sandbox Code Playgroud)