(query-replace-regexp "from" "to")在文本文件中进行大量更改时,我会定期使用表达式.
我想要一个正则表达式,如果存在,用于删除所有不匹配的行.例如,在用于构建RPM的RedHat SPEC文件中,我想只留下以其开头的行/^Patch/(并删除所有不匹配的行).很容易grep -E '^Patch'但在Emacs中有没有办法?
我试过了:
(query-replace-regexp "^\\(?!Patch\\)[^\r\n]*$" "")
Run Code Online (Sandbox Code Playgroud)
无济于事(负面预测似乎不受支持).
有任何想法吗?
我想在SQL Server 2005中的一行上执行多个语句.如何在一行中执行以下操作:
use master
go
sp_spaceused mytable
Run Code Online (Sandbox Code Playgroud)
当我尝试use master; go; sp_spaceused mytable我得到Incorrect syntax near 'go'.
当我尝试use master go sp_spaceused mytable我得到Incorrect syntax near 'go'.
I want to do something like the following:
delay( 2500 )
.then( function () { console.log( "Step 1 done" ) } )
.then( delay( 7500 ) )
.then( function () { console.log( "Step 2 done" ) } );
Run Code Online (Sandbox Code Playgroud)
So implementation of delay has been demonstrated many times before:
function delay( ms ) {
var deferred = Q.defer();
setTimeout( deferred.resolve, ms );
return deferred.promise;
}
Run Code Online (Sandbox Code Playgroud)
But if I run the above in node.js I get:
... delay of 2500ms
Step 1 …Run Code Online (Sandbox Code Playgroud) Apache Pig v0.7可以读取gzip文件而不需要额外的努力,例如:
MyData = LOAD '/tmp/data.csv.gz' USING PigStorage(',') AS (timestamp, user, url);
Run Code Online (Sandbox Code Playgroud)
我可以处理该数据并将其输出到磁盘上:
PerUser = GROUP MyData BY user;
UserCount = FOREACH PerUser GENERATE group AS user, COUNT(MyData) AS count;
STORE UserCount INTO '/tmp/usercount' USING PigStorage(',');
Run Code Online (Sandbox Code Playgroud)
但输出文件未压缩:
/tmp/usercount/part-r-00000
Run Code Online (Sandbox Code Playgroud)
有没有办法告诉STORE命令以gzip格式输出内容?请注意,理想情况下我想要一个适用于Pig 0.6的答案,因为我希望使用Amazon Elastic MapReduce; 但如果有任何版本的猪的解决方案,我想听听它.
我在表中有一个varchar(100)列,它包含整数(作为字符串)和非整数字符串的混合.例如
| dimension varchar(100) |
| '5' |
| '17' |
| '3' |
| 'Pyramids' |
| 'Western Bypass' |
| '15' |
Run Code Online (Sandbox Code Playgroud)
如何编写表达式,例如总结所有有效整数的值?如果我尝试:
-- should return 5 + 17 + 3 + 15 = 40
SELECT
SUM( CONVERT( INT, dimension ) )
FROM
mytable
Run Code Online (Sandbox Code Playgroud)
我会收到一个Conversion failed when converting the varchar value 'Pyramids' to data type int.错误.
是否有我可以在我的表达式中使用的测试,就像ISNULL()函数一样,如果字段不是数字,我可以指定一个默认值?
假设我有一个餐厅评论数据集:
User,City,Restaurant,Rating
Jim,New York,Mecurials,3
Jim,New York,Whapme,4.5
Jim,London,Pint Size,2
Lisa,London,Pint Size,4
Lisa,London,Rabbit Whole,3.5
Run Code Online (Sandbox Code Playgroud)
我想根据用户和城市的平均评论生成一个列表.即输出:
User,City,AverageRating
Jim,New York,3.75
Jim,London,2
Lisa,London,3.75
Run Code Online (Sandbox Code Playgroud)
我可以编写一个Pig脚本,如下所示:
Data = LOAD 'data.txt' USING PigStorage(',') AS (
user:chararray, city:chararray, restaurant:charray, rating:float
);
PerUserCity = GROUP Data BY (user, city);
ResultSet = FOREACH PerUserCity {
GENERATE group.user, group.city, AVG(Data.rating);
}
Run Code Online (Sandbox Code Playgroud)
但是我很好奇我是否可以先对更高级别的组(用户)进行分组,然后再对下一级(城市)进行分组:即
PerUser = GROUP Data BY user;
Intermediate = FOREACH PerUser {
B = GROUP Data BY city;
GENERATE group AS user, B;
}
Run Code Online (Sandbox Code Playgroud)
我明白了:
Error during parsing.
Invalid alias: GROUP …Run Code Online (Sandbox Code Playgroud) 我正在使用一个名为的javascript文件 pull.js.它用于Ipad中的下拉刷新,但是,当我使用其他jquery和javascript停止工作?它给出了以下未捕获的异常错误:
"错误:未捕获的异常:
[异常... "没有足够的参数" nsresult: "0x80570001(NS_ERROR_XPC_NOT_ENOUGH_ARGS)" 位置: "JS帧:: pull.js ::匿名::线26" 的数据:无]"
我正在传递此js文件的内容:
var PULL = function() {
var content,
pullToRefresh,
refreshing,
contentStartY,
success,
start,
cancel,
startY,
track = false,
refresh = false;
var removeTransition = function() {
//content.style['-webkit-transition-duration'] = 0;
};
return {
init: function(o) {
content = document.getElementById('content');
pullToRefresh = document.getElementById('pull_to_refresh');
refreshing = document.getElementById('refreshing');
success = o.success;
start = o.start;
cancel = o.cancel;
document.body.addEventListener('touchstart', function(e) {
e.preventDefault();
contentStartY = parseInt(content.style.top);
startY = e.touches[0].screenY;
});
document.body.addEventListener('touchend', function(e) { …Run Code Online (Sandbox Code Playgroud) 我有一些非常长的行作为Apache Pig(拉丁语)表达式.有没有办法将它们分成多行?
一旦按下enter(不完整)命令执行,我就尝试了一个尾随反斜杠无效
假设我有以下代码:
my $compiled = eval 'sub { print( "Hello World\n" ); }';
Run Code Online (Sandbox Code Playgroud)
我可以这样写:
$compiled->();
Run Code Online (Sandbox Code Playgroud)
到现在为止还挺好.现在假设我创建了10个函数:
my @fns = ();
for ( my $i = 0; $i < 10; $i++ ) {
push( @fns, eval "sub { print( 'I am function $i\n' ); }" );
}
Run Code Online (Sandbox Code Playgroud)
我可以按如下方式调用这10个函数:
foreach ( @fns ) {
$_->();
}
Run Code Online (Sandbox Code Playgroud)
现在,我想创建一个动态函数,它可以显式调用我的10个函数中的每一个:
my $evalcode = "sub {";
foreach ( @fns ) {
# if I print $_ it shows something like
# "CODE(0x94084f8)", but trying to
# call …Run Code Online (Sandbox Code Playgroud) apache-pig ×3
javascript ×2
perl ×2
compare ×1
emacs ×1
eval ×1
ios ×1
jquery ×1
pack ×1
q ×1
regex ×1
sql ×1
sql-server ×1