内置的VIM :sort命令可对文本行进行排序.我想在一行中对单词进行排序,例如变换行
b a d c e f
Run Code Online (Sandbox Code Playgroud)
至
a b c d e f
Run Code Online (Sandbox Code Playgroud)
目前我通过选择线然后使用来实现这一点:!tr ' ' '\n' | sort | tr '\n' ' ',但我确信有更好,更简单,更快捷的方式.在那儿?
请注意,我使用bash,所以如果有一个更短更优雅的bash命令来执行此操作,那也没关系.
编辑:我的用例是我有一行说SOME_VARIABLE="one two three four etc",我想要对该变量中的单词进行排序,即我想要SOME_VARIABLE="etc four one three two".
最终结果应该优选地可以映射到快捷键,因为这是我经常需要的东西.
我打开一个zip文件时遇到问题.我使用此代码压缩文件:
public static string Zip_File(string soruce , string target)
{
try
{
byte[] bufferWrite;
using (FileStream fsSource = new FileStream(soruce, FileMode.Open, FileAccess.Read, FileShare.Read))
{
bufferWrite = new byte[fsSource.Length];
fsSource.Read(bufferWrite, 0, bufferWrite.Length);
using (FileStream fsDest = new FileStream(target, FileMode.OpenOrCreate, FileAccess.Write))
{
using (GZipStream gzCompressed = new GZipStream(fsDest, CompressionMode.Compress, true))
{
gzCompressed.Write(bufferWrite, 0, bufferWrite.Length);
bufferWrite = null;
fsSource.Close();
gzCompressed.Close();
fsDest.Close();
}
}
}
return "success";
}
catch (Exception ex)
{
return ex.Message;
}
}
Run Code Online (Sandbox Code Playgroud)
当我调用此函数时收到"成功"消息,但我无法打开zip文件.
ZipFiles.Zip_File(@"C:\Documents and Settings\ccspl\Desktop\IntegrityDVR.mdb", @"C:\Documents and Settings\ccspl\Desktop\a.zip")
Run Code Online (Sandbox Code Playgroud)
这是我的函数调用代码: …
我有c ++代码需要在编译之前完成它的sed.我该如何插入Makefile.am?
我尝试了典型的makefile设置,目标似乎不存在:
gentest.cc:
$(SED) -i "s|FIND|REPLACE|" gentest.cc
如果你对我为什么要这样做感兴趣,那是因为我slider3.py在python中编写了我的程序(),而我的伙伴用c ++(gentest.cc)写了他的,并且他需要调用我的.我正在通过编辑argv然后使用来完成此操作execv().
... {
char **argv2 = new char*[argc];
memset(argv2,0,sizeof(argv2));
argv2[0] = "__PREFIX__/bin/slider3.py";
memcpy(argv2 + 1, argv + 2, sizeof(char *) * (argc - 2));
int oranges = execv(argv2[0], argv2);
printf("%s\n", strerror(oranges));
return oranges;
} ...
我已经处理了#!添加到slider3.py并chmod +x使用不起作用的方法gentest.cc.我还处理了添加slider3.py到已安装的文件列表.
EXTRA_DIST=testite.sh slider3_base.py
bin_SCRIPTS = slider3.py
CLEANFILES = $(bin_SCRIPTS)
slider3.py: slider3_base.py
rm -f slider3.py
echo …
我使用jQuery UI中的UI DatePicker作为独立选择器.我有这个代码:
<div id="datepicker"></div>
Run Code Online (Sandbox Code Playgroud)
以下JS:
$('#datepicker').datepicker();
Run Code Online (Sandbox Code Playgroud)
当我尝试使用此代码返回值时:
var date = $('#datepicker').datepicker('getDate');
Run Code Online (Sandbox Code Playgroud)
我退回了这个:
Tue Aug 25 2009 00:00:00 GMT+0100 (BST)
Run Code Online (Sandbox Code Playgroud)
这是完全错误的格式.有没有办法让我以格式返回DD-MM-YYYY?
我有一个脚本需要向国际观众显示日期数据 - 例如
"2009年8月25日星期二提交"
是否有一种更简单/更清洁的方式将其转换为法语(等)"Mar 25Aoû09",而不是:
设置常量LANG和$LANGUAGES包含文件数组&:
if(LANG != 'EN')
{
include $LANGUAGES['LANG'];
}
Run Code Online (Sandbox Code Playgroud)
然后,包含的文件会映射日期和月份并替换适当的区域设置?
谢谢
大卫
有没有办法递归自动记录包含其中的类和函数的模块或包?
我认为为每个函数添加autofunctionor automodule指令是愚蠢的; 必须有一种方法来自动化该过程,否则我根本没有看到使用Sphinx的重点.
澄清: 而不是:
.. automodule:: segments.segments
.. autoclass:: segments.segments.Seg
.. automethod:: Seg.method_1
.. automethod:: Seg.method_2
.. automethod:: Seg.method_3
.......
.. automethod:: Seg.method_n
Run Code Online (Sandbox Code Playgroud)
这需要我手动剪切并粘贴所有方法名称并相应地更新文档,我想要一个如下命令:
.. automodule:: segments.segments
.. autoclass:: segments.segments.Seg
.. MAGIC COMMAND: Automatically print the docstrings and signatures
of all Seg() methods.
Run Code Online (Sandbox Code Playgroud) SELECT A.PD_END_DT Recent_PD_END_DT,
B.PD_END_DT Last_PD_END_DT,
A.NRX_CNT - B.NRX_CNT DELTA
FROM wkly_lnd.lnd_wkly_plan_rx_summary A,
wkly_lnd.lnd_wkly_plan_rx_summary B
WHERE a.MKT_I D =b.MKT_ID;
Run Code Online (Sandbox Code Playgroud) 我有一个类,它有许多模块,它们根据一些运行时标准与它混合在一起.
我希望能够获得已经混合到这个类中的模块的列表.你怎么能这样做?
UPDATE
所以,当我说类我的意思是对象,因为它是在运行时使用以下方式扩展的对象:
obj.extend(MyModule)
Run Code Online (Sandbox Code Playgroud)
obj.included_modules和obj.ancestors不存在,因此您无法从那里获取已混入的模块.
我有两个数组:
string[] Group = { "A", null, "B", null, "C", null };
string[] combination = { "C#", "Java", null, "C++", null };
Run Code Online (Sandbox Code Playgroud)
我希望返回所有可能的组合,例如:
{ {"A","C#"} , {"A","Java"} , {"A","C++"},{"B","C#"},............ }
Run Code Online (Sandbox Code Playgroud)
应该忽略null.