码:
public class SlowDictionary {
private final Map<String,String> dict = new HashMap<String,String>();
public synchronized String translate (String word)
throws IllegalArgumentException {
if (!dict.containsKey(word)) {
throw new IllegalArgumentException(word + " not found.");
}
return dict.get(word);
}
public synchronized void addToDictionary (String word, String translation)
throws IllegalArgumentException {
if (dict.containsKey(word)) {
throw new IllegalArgumentException(word + " already exists.");
}
dict.put(word,translation);
}
public synchronized Set<String> getAllWords () {
return dict.keySet();
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个关于Git的基本问题:
假设有子域git.mysite.com,其中安装了git.我的实际网站是在mysite.com上.我如何告诉Git"发布"对mysite.com的特定或最新提交?
我使用MediaTemple(gs)进行托管.网站位于/domains/mysite.com/html,Git位于/domains/git.mysite.com/html/mysite.git.
谢谢!
当我生成单元测试时,Visual studio添加了一些模拟我的类的虚构类并添加了"阴影"属性.它有什么作用?
我有一个应用程序,它使用SQL Enterprise将所有数据存储在4个不同的数据库中.我需要建立为我的用户"离线"工作的能力.我完成了这个Merge Replication到SQL Express每个人的本地安装.这个"作品"但感觉就像大锤的方法.
例如,当任何单个用户只能与100个左右进行交互时,我正在将所有14000个人复制到每个数据库.这甚至没有计算出它们在与中央数据库的连接之间永远不会与5个以上的交互.
我正在寻找的是提示,指针,也许是一个关于Sync Framework 2(带数据库)的精彩教程.第一手资料说明了什么对你有用,为什么也会受到欢迎.我还没有找到一个清晰简洁的(更不用说当前的)教程Sync Framework.
我的具体是MS SQL Server 2005或2008年,任何版本.任何.Net版本(3.5或4).当前数据层都是LinqToSQL.目前没有任何Sprocs使用.
到目前为止,我的想法是仅同步每个工作人员分配的案例量和相关数据.理想情况下,我们会直接选择"签入/签出"格式,选择他们计划访问的成员,然后同步必要的数据.
作为奖励,有人可以告诉我这被称为什么?我偶尔会遇到"偶尔连接",但这似乎不准确.把它们称为"偶尔DIS连接"会更准确吗?
.net sql-server occasionallyconnected disconnected microsoft-sync-framework
当我按下结束键时,我希望它能将我带到行尾.同样,当我按下Home键时,我希望它能将我带到行的开头.但是在Xcode中,这些导航到页面的顶部和底部.怎么能改变?
我有一个页面(page1.php),我使用一个选择框将另一个页面(page2.php)加载到DIV中.在page2.php里面有一个UL,它将数据从数据库(通过PHP)加载到LI中,并且是可排序的.
我的问题是,当我自己加载page2.php时,它序列化很好.但是,当page2.php通过.load()加载到page1.php时,它根本没有序列化,我得到了未定义.
这是重要的代码,这本身也可以正常工作,但是当通过.load()函数加载这个页面时却不行
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
<style>
#thelist { list-style-type: none; margin: 0; padding: 0; width:700px; }
#thelist li { margin: 3px 3px 3px 0; padding: 1px; float: left; width: 200px; height: 150px; }
</style>
<ul id="thelist">
<li style="margin-bottom:5px;" name='listItem_1' id='listItem_1'>
test1
</li>
<li style="margin-bottom:5px;" name='listItem_2' id='listItem_2'>
test2
</li>
<script type="text/javascript">
$(function() {
$("#thelist").sortable({
update : function () {
var order = $('#thelist').sortable('serialize');
alert(order); // This alerts "undefined" when page2.php is loaded into page1.php via .load();
$("#info").load("reorder_slides.php?"+order); …Run Code Online (Sandbox Code Playgroud) 出了点问题,非常令人沮丧.我在velocity的主页上看到,当我运行webapp时,应该设置一些属性.而且我已经做到了,但无论我做什么,我都会遇到同样的错误.
这是我设置道具和使用速度的地方
public class ConfirmationMailGenerator implements MailGenerator {
private BasicUser user;
private String htmlTemplate = "HTMLConfirmationMailTemplate.vsl";
private String plainTemplate = "PlainConfirmationMailTemplate.vsl";
public ConfirmationMailGenerator(BasicUser user) {
this.user = user;
}
public StringWriter generateHTML() throws Exception {
Properties props = new Properties();
props.setProperty("resource.loader", "wepapp");
props.setProperty("webapp.resource.loader.class", "org.apache.velocity.tools.view.WebappResourceLoader");
props.setProperty("webapp.resource.loader.path", "/WEB-INF/mailtemplates/");
VelocityEngine engine = new VelocityEngine(props);
VelocityContext context = new VelocityContext();
engine.init();
Map map = createDataModel();
context.put("user", map);
Template template = engine.getTemplate(htmlTemplate);
StringWriter writer = new StringWriter();
template.merge(context, writer);
return writer;
}
...
}
Run Code Online (Sandbox Code Playgroud)
这些文件当然保存在/ …
是否有可能以及如何在iphone/ipad上实现forbiden退出应用程序?
我们有一个必须永久在ipad设备上工作的应用程序.用户不应该有任何退出应用程序的方法.你能建议如何实现这个功能吗?
在使用ElementTree的Python 2.6中,在特定元素中获取XML(作为字符串)的好方法是什么,比如你在HTML和javascript中可以做什么innerHTML?
这是我开始使用的XML节点的简化示例:
<label attr="foo" attr2="bar">This is some text <a href="foo.htm">and a link</a> in embedded HTML</label>
Run Code Online (Sandbox Code Playgroud)
我想最终得到这个字符串:
This is some text <a href="foo.htm">and a link</a> in embedded HTML
Run Code Online (Sandbox Code Playgroud)
我已经尝试迭代父节点并连接子节点tostring(),但这只给了我子节点:
# returns only subnodes (e.g. <a href="foo.htm">and a link</a>)
''.join([et.tostring(sub, encoding="utf-8") for sub in node])
Run Code Online (Sandbox Code Playgroud)
我可以使用正则表达式破解解决方案,但是希望有一些不那么讨厌的东西:
re.sub("</\w+?>\s*?$", "", re.sub("^\s*?<\w*?>", "", et.tostring(node, encoding="utf-8")))
Run Code Online (Sandbox Code Playgroud) java ×2
.net ×1
c# ×1
collections ×1
concurrency ×1
disconnected ×1
elementtree ×1
exit ×1
git ×1
ipad ×1
iphone ×1
jquery ×1
jquery-ui ×1
mediatemple ×1
performance ×1
php ×1
python ×1
sql-server ×1
unit-testing ×1
velocity ×1
xcode ×1
xml ×1