问题列表 - 第33370页

HTML5 Canvas与SVG + Raphael.js的优点和缺点是什么?

我刚刚使用Canvas开始了一个项目.但我需要的一件事就是跟踪可移动的,可点击的盒子,如下例所示:http://raphaeljs.com/graffle.html所以我想知道Raphael-js + SVG会不会更好.

你会用哪个?为什么?

javascript svg raphael html5-animation

12
推荐指数
2
解决办法
1万
查看次数

什么是F#报价?

F#中的"引用"是什么,它们用于什么?

f# quotations

6
推荐指数
2
解决办法
430
查看次数

如何使用C#在数据库中保存图像

我想将用户图像保存到C#中的数据库中.我怎么做?

c# sql asp.net-mvc ado.net

28
推荐指数
4
解决办法
12万
查看次数

如何以编程方式创建ProgressBar?

我的应用程序需要以ProgressBar编程方式创建一个小的. ProgressBar没有设置样式的方法(我想要一个小的progressBar).构造函数可以采用a ProgressBar,但它是一个接口,并要求我实现一组函数.有没有办法设置AttributeSet小风格?(我不能用xml来创建 ProgressBar)

android android-progressbar

72
推荐指数
2
解决办法
9万
查看次数

使用grep进行负匹配(匹配不包含foo的行)

我一直在试图找出这个命令的语法:

grep ! error_log | find /home/foo/public_html/ -mmin -60
Run Code Online (Sandbox Code Playgroud)

要么

grep '[^error_log]' | find /home/baumerf/public_html/ -mmin -60
Run Code Online (Sandbox Code Playgroud)

我需要查看所有已修改的文件,除了那些已命名的文件error_log.

我在这里读过它,但只发现了一个not-regex模式.

grep

912
推荐指数
3
解决办法
77万
查看次数

从Internet下载文件,同时可以随时中止下载

我想从专门用于下载的单独线程中下载Delphi程序中的文件.

问题是主程序可以随时关闭(因此下载线程也可以随时终止).因此,即使没有连接或服务器滞后宝贵的秒钟,我需要一种方法在一两秒内终止下载线程.

你们建议使用什么功能?

我已经尝试过InterOpenURL/InternetReadFile但它没有超时参数.它有一个异步版本,但我找不到任何有用的Delphi示例,我不确定异步版本是否会保护我免受挂起...

以前建议使用套接字,但TClientSocket似乎也没有超时功能.

我需要做好充分准备,如果用户在他/她的计算机上遇到Internet连接问题或者网络服务器一直滞后我的应用程序在关闭之前就不会挂起.

在回答我不想使用任何第三方组件和Indy时请记住.非常感谢任何示例代码.

谢谢!

delphi multithreading wininet download delphi-7

7
推荐指数
2
解决办法
2595
查看次数

如何检测facebook的FB.init何时完成

旧的JS SDK有一个名为FB.ensureInit的函数.新的SDK似乎没有这样的功能......我怎样才能确保在完全启动之前我不进行api调用?

我把它包含在每个页面的顶部:

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId  : '<?php echo $conf['fb']['appid']; ?>',
      status : true, // check login status
      cookie : true, // enable cookies to allow the server to access the session
      xfbml  : true  // parse XFBML
    });
    FB.Canvas.setAutoResize();
  };

  (function() {
    var e = document.createElement('script');
    e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
  }());
</script>
Run Code Online (Sandbox Code Playgroud)

javascript facebook

114
推荐指数
5
解决办法
12万
查看次数

使用Python下载,提取和读取gzip文件

我想在Python中下载,提取和迭代文本文件,而不必创建临时文件.

基本上,这个管道,但在python中

curl ftp://ftp.theseed.org/genomes/SEED/SEED.fasta.gz | gunzip | processing step
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

def main():
    import urllib
    import gzip

    # Download SEED database
    print 'Downloading SEED Database'
    handle = urllib.urlopen('ftp://ftp.theseed.org/genomes/SEED/SEED.fasta.gz')


    with open('SEED.fasta.gz', 'wb') as out:
        while True:
            data = handle.read(1024)
            if len(data) == 0: break
            out.write(data)

    # Extract SEED database
    handle = gzip.open('SEED.fasta.gz')
    with open('SEED.fasta', 'w') as out:
        for line in handle:
            out.write(line)

    # Filter SEED database
    pass
Run Code Online (Sandbox Code Playgroud)

我不想使用process.Popen()或任何东西,因为我希望这个脚本与平台无关.

问题是Gzip库只接受文件名作为参数而不是句柄."管道"的原因是下载步骤仅占用了大约5%的CPU,并且同时运行提取和处理会更快.


编辑:这不起作用,因为

"由于gzip压缩的工作方式,GzipFile需要保存其位置并在压缩文件中向前和向后移动.当"文件"是来自远程服务器的字节流时,这不起作用;所有你能做的与它一起检索一个字节,而不是在数据流中来回移动." - 潜入python

这就是我收到错误的原因

AttributeError: addinfourl instance has no attribute 'tell' …
Run Code Online (Sandbox Code Playgroud)

python

6
推荐指数
1
解决办法
1万
查看次数

进行两用查询,还是两个单独的查询?

这是一个人为的例子,但考虑一个场景,员工有工作地点,员工也有经理,他们也有工作地点:

create table WorkingLocation (
    ID int not null primary key identity(1,1), 
    Name varchar(50)
)

create table Employee (
    ID int not null primary key identity(1,1), 
    Name varchar(50), 
    WorkingLocationID int null,
    ManagerID int null,
    constraint FK_Employee_WorkingLocation foreign key (WorkingLocationID) references WorkingLocation (ID),
    constraint FK_Employee_Manager foreign key (ManagerID) references Employee (ID)
)
Run Code Online (Sandbox Code Playgroud)

现在考虑一个想要雇员的商业规则WorkingLocation,但是WorkingLocation如果他没有经理人的话,他会满足于他的经理人.此时您有两个选择:

1:有一个获取两者的查询,让业务规则决定使用哪个:

select 
    e.*,
    emp_location.*,
    mgr_location.*
from Employee e
    left join WorkingLocation emp_location on e.WorkingLocationID = emp_location.ID
    left join Employee mgr on e.ManagerID = mgr.ID …
Run Code Online (Sandbox Code Playgroud)

sql performance

3
推荐指数
1
解决办法
182
查看次数

WPF DataGrid控件模板

我正在尝试自定义WPF 4.0 DataGrid并需要其控件模板的列表(也是嵌套DataGridColumnHeadersPresenter的控件模板 - PART_ColumnHeadersPresenter).我发现链接提供了许多控件模板,但列表中缺少DataGrid!是否有发布最新WPF 4.0 DataGrid的控件模板的地方.我尝试使用以下代码获取它,但它没有给我嵌套模板:

// Create an XmlWriter
StringBuilder sb = new StringBuilder();
XmlWriterSettings xmlSettings = new XmlWriterSettings
    { Indent = true, IndentChars = "    ", NewLineOnAttributes = true };
XmlWriter writer = XmlWriter.Create(sb, xmlSettings);

// Write the control template
ControlTemplate template = controlToExtract.Template;
XamlWriter.Save(template, writer);

// Write results to display
controlTemplate.AppendText(sb.ToString());
Run Code Online (Sandbox Code Playgroud)

wpf datagrid controltemplate

7
推荐指数
1
解决办法
6078
查看次数