我在〜/ .bashrc中定义了一些别名和函数.
我使用终端窗口启动emacs emacs -nw
当我执行时M-x shell-command,〜/ .bashrc中的别名和函数不可用,但是给出"找不到命令".
我用谷歌搜索了一下,但是我遇到的所有帖子都说,如果我理解正确的话,〜/ .bashrc就是这个应该工作的地方(而不是〜/ .profile或〜/ .bash_profile).
我错过了什么?
在我的演示者中,我有这个属性:
public List<string> PropertyNames { get; set; }
Run Code Online (Sandbox Code Playgroud)
我想用ItemsControl/DataTemplate列出名称,如下所示:
<ItemsControl ItemsSource="{Binding PropertyNames}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Value}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Run Code Online (Sandbox Code Playgroud)
由于通用列表没有命名属性,如何在Binding语句中引用该值?
我的问题针对setjmp/longjmp关于局部变量的行为.
示例代码:
jmp_buf env;
void abc()
{
int error;
...
if(error)
longjmp(env);
}
void xyz() {
int v1; // non-volatile; changed between setjmp and longjmp
int v2; // non-volatile; not changed between setjmp and longjmp
volatile int v3; // volatile; changed between setjmp and longjmp
volatile int v4; // volatile; not changed between setjmp and longjmp
...
if(setjmp(env)) {
// error handling
...
return;
}
v1++; // change v1
v3++; // change v3
abc();
}
int main(...) {
xyz();
} …Run Code Online (Sandbox Code Playgroud) 我有这种模式,我需要从列表中选择任何随机元素,而不是当前的元素(作为参数传递).我想出了这个方法:
public Element GetAnyoneElseFromTheList(Element el)
{
Element returnElement = el;
Random rndElement = new Random();
if (this.ElementList.Count>2)
{
while (returnElement == el)
{
returnElement = this.ElementList[rndElement.Next(0,this.ElementList.Count)];
}
return returnElement;
}
else return null;
}
Run Code Online (Sandbox Code Playgroud)
但是,虽然循环一直困扰着我几天,但我需要睡一会儿.还有其他好办法吗?即.以固定数量的步骤返回的东西?
编辑:在我的情况下,列表保证包含要避免的"el"元素,并且列表不包含重复项,但是看到一些更一般的情况也很有趣.
我试图弄清楚如何使用辅助线程更新UI中的不确定NSProgressIndicator,而主线程做了一些繁重的工作,就像几十个应用程序一样.这个片段基于Apple的"Trivial Threads"示例使用分布式对象(DO的):
// In the main (client) thread...
- (void)doSomethingSlow:(id)sender
{
[transferServer showProgress:self];
int ctr;
for (ctr=0; ctr <= 100; ctr++)
{
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
NSLog(@"running long task...");
}
}
// In the secondary (server) thread...
- (oneway void)showProgress:(Controller*)controller
{
[controller resetProgressBar];
float ticks;
for (ticks=0; ticks <= 100; ticks++)
{
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
[controller updateProgress:ticks];
NSLog(@"updating progress in UI...");
}
}
Run Code Online (Sandbox Code Playgroud)
然而不幸的是,有没有办法,我可以得到两个线程来运行并发.辅助线程将运行,主线程将等待,直到它完成或主线程运行,然后是辅助线程 - 但不能同时运行.
即使我将指针传递给服务器线程并要求它直接更新进度条(不调用主线程)也没有区别.似乎一旦主线程进入这样的循环,它就会忽略发送给它的所有对象.我仍然是Obj-C的新手,我真的很感激任何帮助.
几乎有这个工作,但......
javascript调用django像这样:
.sortable({
connectWith: '.object',
update: function() {
var order = $(this).sortable('serialize');
$.ajax({
type: "POST",
data: order,
url: "/focus_upd/"
});
....
Run Code Online (Sandbox Code Playgroud)
并且在focus_upd函数中,数据到达正常
POST:<QueryDict: {u'task[]': [u'29', u'20', u'29', u'28']}>,
Run Code Online (Sandbox Code Playgroud)
但如果我参考request.POST ['task []']我得到28
为什么会发生这种情况?如何获得整个列表?
我在执行JUnit测试时收到此错误消息:
java.lang.OutOfMemoryError: GC overhead limit exceeded
Run Code Online (Sandbox Code Playgroud)
我知道它OutOfMemoryError是什么,但GC开销限制意味着什么?我怎么解决这个问题?
我有遗留系统的一些数据文件,我想用Awk处理.每个文件都包含一个记录列表.有几种不同的记录类型,每种记录类型都有一组不同的固定宽度字段(没有字段分隔符).记录的前两个字符表示类型,然后您可以知道应该遵循哪些字段.文件可能如下所示:
AAField1Field2LongerField3
BBField4Field5Field6VeryVeryLongField7Field8
CCField99
Run Code Online (Sandbox Code Playgroud)
使用Gawk我可以设置FIELDWIDTHS,但这适用于整个文件(除非我在某个记录的基础上缺少某种方式设置它),或者我可以将FS设置为""并处理文件中的一个字符一段时间,但这有点麻烦.
有没有一种使用Awk从这样的文件中提取字段的好方法?
编辑:是的,我可以使用Perl(或其他).我仍然很想知道是否有一种合理的方法可以用Awk做到这一点.
我是ctags的忠实粉丝所以我想知道我是否有cscope,我会在两个程序中受益更多.似乎后者具有与ctags相同的特征,即便于找到符号.
有哪些功能范围可以通过VIM进一步提高我的工作效率?
谢谢
我正在从表值函数中选择一些行,但是通过将SELECT TOP放在查询中,发现了一个莫名其妙的巨大性能差异.
SELECT col1, col2, col3 etc
FROM dbo.some_table_function
WHERE col1 = @parameter
--ORDER BY col1
Run Code Online (Sandbox Code Playgroud)
需要花费5到6分钟才能完成.
然而
SELECT TOP 6000 col1, col2, col3 etc
FROM dbo.some_table_function
WHERE col1 = @parameter
--ORDER BY col1
Run Code Online (Sandbox Code Playgroud)
在大约4或5秒内完成.
如果返回的数据集很大,这不会让我感到惊讶,但涉及的特定查询返回 200,000中的~5000行.
因此,在这两种情况下,整个表都被处理,因为SQL Server一直在搜索6000行,它将永远不会到达.为什么那么巨大的差异呢?这是否与SQL Server在预期结果集大小时分配空间的方式有关(TOP 6000因此给它一个较低的要求,更容易在内存中分配)?有没有其他人目睹过这样的事情?
谢谢