Eclipse有一个很棒的功能,允许您将所有'字段列'对齐,这意味着它将转向:
int myVar = 2334;
int asdf = 34;
String s = "hello";
Run Code Online (Sandbox Code Playgroud)
成
int myVar = 2334;
int asdf = 34;
String s = "Hello";
Run Code Online (Sandbox Code Playgroud)
这使代码更具可读性,我喜欢它.但是我似乎无法找到类似的设置来使它对常规局部变量这样做.有人知道是否有办法?如果没有人,那将是一种耻辱.
谢谢
我有一个使用netbeans编写的GUI,其中包含一些简单的组件.我希望能够在JFrame内部绘制GUI组件的同时绘制图像(任何文件类型,最简单).
不必调整它们的大小,只需按原样绘制它们,在我选择的x和y位置.每次更新时都会绘制几张图像,一些图像将被隐藏,另一些图像将被显示.更新只会每5秒左右发生一次,因此速度快并不是真正的问题.
如果可以将事件附加到被点击的图像上,那将是很好的,但不是必需的.
这是一个非常简单的任务,我还没有得到一个简单的答案.
我该怎么做呢?
谢谢
package Pokertable;
Run Code Online (Sandbox Code Playgroud)
/**要更改此模板,请选择"工具"| 模板*并在编辑器中打开模板.*/
/**ClientWindow.java**创建于2009年9月12日,下午9:10:48*/
/****@author Robert*/public class ClientWindow扩展javax.swing.JFrame {
/** Creates new form ClientWindow */
public ClientWindow() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jTextField1 = new javax.swing.JTextField(); …Run Code Online (Sandbox Code Playgroud) 我说"实时代码"因为我的意思不是来自文本源文件或源字符串,而是来自partialFunctions/lambdas.(我知道Ruby1.8的parseTree和C#linq可以做到)
考虑一个partialFunction f:
val f = (i: Int, j: Int) => (i + j) * 2
Run Code Online (Sandbox Code Playgroud)
我希望有一些工具像这样:
getBodyAstFrom(f) //=> (Infix('*'), (Infix('+'), Id('i'), Id('j')), Val('2'))
Run Code Online (Sandbox Code Playgroud)
我不关心语义事物(上下文解析和implicits太复杂,对我来说是不必要的),我只需要实时代码的语法树,是否可能?
检查其他人的代码可能存在问题,但我自己的代码呢?以下事情可能吗?
val f = AstFunction(i: Int, j: Int){(i + j) * 2}
f(5, 6) //=> 22
f.ast //=> (Infix('*'), (Infix('+'), Id('i'), Id('j')), Val('2'))
Run Code Online (Sandbox Code Playgroud)
它似乎需要一些黑客入侵编译器,嗯......
我是GPU编程的新手,我使用brook +语言在ATI流处理器上进行暴力破解RAR密码恢复,但我发现用brook +语言编写的内核不允许任何调用普通函数(内核函数除外),我的问题是:
1)如何在这种情况下使用unrar.dll(到unrar归档文件)API?这是编程RAR密码恢复的唯一方法吗?
2)使用GPU的破解和ElcomSoft软件怎么样?
3)该程序中GPU(ATI Stream处理器或CUDA)内部功能的确切作用是什么?
4)nVidia/CUDA技术比ATI/brook +语言更容易/更灵活吗?
我使用WINFORMS而不是WPF.
我只知道基本的c#.net gui编程.我不想要传统的窗户外观.我希望拥有自己的自定义外观(例如gtalk,防病毒软件,媒体播放器,谷歌浏览器).
实际上我受谷歌PICASA软件的启发.这很棒.我想做那样的事情.我怎么能这样做?如果有什么我应该学习的请指出我.
此外,我可能必须编写自己的自定义控件(如修改过的树视图等).我想.请提供一些好的学习资源.
我遇到过一些情况,我想要绘制比我真正应该得到的更多的点数 - 主要是因为当我与人分享我的情节或将它们嵌入文件时,它们占据了太多的空间.在数据帧中随机抽样行非常简单.
如果我想要一个真正的随机样本的点图,很容易说:
ggplot(x,y,data=myDf[sample(1:nrow(myDf),1000),])
Run Code Online (Sandbox Code Playgroud)
但是,我想知道是否有更有效(理想的罐装)方式来指定绘图点的数量,以便您的实际数据准确地反映在绘图中.所以这是一个例子.假设我正在绘制类似于重尾分布的CCDF之类的东西,例如
ccdf <- function(myList,density=FALSE)
{
# generates the CCDF of a list or vector
freqs = table(myList)
X = rev(as.numeric(names(freqs)))
Y =cumsum(rev(as.list(freqs)));
data.frame(x=X,count=Y)
}
qplot(x,count,data=ccdf(rlnorm(10000,3,2.4)),log='xy')
Run Code Online (Sandbox Code Playgroud)
这将产生x和y轴变得越来越密集的图.在这里,为较大的x或y值绘制较少的样本是理想的.
有没有人对处理类似问题有任何提示或建议?
谢谢,-e
我的C++应用程序中有一个缓冲类,如下所示:
class Buffer
{
public:
Buffer(size_t res): _rpos(0), _wpos(0)
{
_storage.reserve(res);
}
protected:
size_t _rpos, _wpos;
std::vector<uint8> _storage;
}
Run Code Online (Sandbox Code Playgroud)
有时使用构造函数失败,因为它无法分配所需的内存空间.例如,一次调用构造函数res = 37导致了一个段错误,其中包含我从其核心转储获得的以下堆栈跟踪:
#0 0x00007f916a176ed5 in raise () from /lib/libc.so.6
No symbol table info available.
#1 0x00007f916a1783f3 in abort () from /lib/libc.so.6
No symbol table info available.
#2 0x00007f916a1b33a8 in ?? () from /lib/libc.so.6
No symbol table info available.
#3 0x00007f916a1b8948 in ?? () from /lib/libc.so.6
No symbol table info available.
#4 0x00007f916a1bb17c in ?? () from /lib/libc.so.6
No …Run Code Online (Sandbox Code Playgroud) 我想根据第二列中的值仅选择NumPy数组中的某些行.例如,此测试数组在第二列中具有从1到10的整数.
>>> test = numpy.array([numpy.arange(100), numpy.random.randint(1, 11, 100)]).transpose()
>>> test[:10, :]
array([[ 0, 6],
[ 1, 7],
[ 2, 10],
[ 3, 4],
[ 4, 1],
[ 5, 10],
[ 6, 6],
[ 7, 4],
[ 8, 6],
[ 9, 7]])
Run Code Online (Sandbox Code Playgroud)
如果我只想要第二个值为4的行,那么很容易:
>>> test[test[:, 1] == 4]
array([[ 3, 4],
[ 7, 4],
[16, 4],
...
[81, 4],
[83, 4],
[88, 4]])
Run Code Online (Sandbox Code Playgroud)
但是当有多个想要的值时,我如何获得相同的结果呢?
通缉名单可以是任意长度.例如,我可能想要第二列为2,4或6的所有行:
>>> wanted = [2, 4, 6]
Run Code Online (Sandbox Code Playgroud)
我提出的唯一方法是使用列表推导,然后将其转换回数组并且看起来太复杂,尽管它有效:
>>> test[numpy.array([test[x, 1] in wanted for x …Run Code Online (Sandbox Code Playgroud) class a:
def b():
...
Run Code Online (Sandbox Code Playgroud)
b的意义是什么?
谢谢
class a:
@staticmethod
def b():
return 1
def c(self):
b()
print a.b()
print a().b()
print a().c()#error
Run Code Online (Sandbox Code Playgroud)
和
class a:
@staticmethod
def b():
return 1
def c(self):
return self.b()
print a.b()
print a().b()
print a().c()
#1
#1
#1
Run Code Online (Sandbox Code Playgroud) 我正在编写一个Perl脚本,它将编写一些输入并将这些输入发送到外部程序.这个程序有一个很小但非零的机会,我想把它计时:
my $pid = fork;
if ($pid > 0){
eval{
local $SIG{ALRM} = sub { die "TIMEOUT!"};
alarm $num_secs_to_timeout;
waitpid($pid, 0);
alarm 0;
};
}
elsif ($pid == 0){
exec('echo blahblah | program_of_interest');
exit(0);
}
Run Code Online (Sandbox Code Playgroud)
现在,在$ num_secs_to_timeout之后,program_of_interest仍然存在.我试图在匿名子程序中杀死它,$SIG{ALRM}如下所示:
local $SIG{ALRM} = sub{kill 9, $pid; die "TIMEOUT!"}
Run Code Online (Sandbox Code Playgroud)
但这没有做任何事情.program_of_interest仍然存在.我如何杀死这个过程?