我想要的是:

我在一个远程站点上有一个clojure程序,让我们称它为mccarthy。 我想做的是从我的笔记本电脑连接到nrepl-ritz,最好使用nrepl-ritz-jack-in。插孔在本地程序中工作良好,但似乎不能连接到远程程序。

尝试1

C-x C-f on /mccarthy:code/program/project.clj

(需要的nrepl-ritz)

m x nrepl-ritz-jack-in

结果

Emacs似乎挂起了。如果我去到*nrepl-server*缓冲区,我看到:

Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.flatland.drip.Main.invoke(Main.java:117)
    at org.flatland.drip.Main.start(Main.java:88)
    at org.flatland.drip.Main.main(Main.java:64)
Caused by: java.lang.AssertionError: Assert failed: project
    at leiningen.ritz_nrepl$start_jpda_server.invoke(ritz_nrepl.clj:23)
    at leiningen.ritz_nrepl$ritz_nrepl.doInvoke(ritz_nrepl.clj:95)

(还有很多其他的台词……)

我在我的笔记本电脑上使用了drip,而不是在mccarthy上,所以nrepl-ritz-jack-in显然没有检测到它是一个远程文件。然而,在这种情况下,常规的旧nrepl-jack-in将按预期工作。

尝试2

我还试着用莱茵写麦卡锡,开始写nrepl-ritz:

mattox@mccarthy$ lein ritz-nrepl
nREPL server started on port 42874

从我的笔记本电脑,我转发一个端口,使本地42874连接到麦卡锡的42874:

ssh -L 42874:localhost:42874 -N mccarthy

然后,从我本地的Emacs:

(require 'nrepl-ritz)

m x nrepl

主持人:127.0.0.1

端口:42874

这给了我一个联系:

; nREPL 0.1.7-preview
user> 

为了验证,我跑了

m x nrepl-ritz-threads

它给了我一个很好的线程表。

m x nrepl-ritz-break-on-exception

user> (/ 1 0)

结果

这会挂起,但有时会显示一个隐藏的调试缓冲区,其中有一些重启可用。如果我告诉它将异常传递回程序,它永远不会将控制权交还给REPL。

我已经做了大量的搜索,但没有能够得到任何更具体的比“确保lein在你的路径上”(我确实这样做了,在两台机器上…)

在阅读一些SQL调优相关文档时,我发现了这个:

选择计数(*):

计算行数。 通常不恰当地用于验证记录的存在。

SELECT COUNT(*)真的那么糟糕吗?

验证记录存在的正确方法是什么?

如何在c#中做“内联函数”?我想我不明白这个概念。它们像匿名方法吗?比如函数?

注意:答案几乎完全涉及内联函数的能力,即。用被调用者的主体替换函数调用站点的手册或编译器优化。如果你对匿名(又名lambda)函数感兴趣,请参阅@jalf的回答或每个人都在谈论的“lambda”是什么?

我正在查看这里的strlen代码,我想知道在代码中使用的优化是否真的需要?例如,为什么像下面这样的工作不一样好或更好?

unsigned long strlen(char s[]) {
    unsigned long i;
    for (i = 0; s[i] != '\0'; i++)
        continue;
    return i;
}

更简单的代码是不是更好和/或更容易编译器优化?

strlen在链接后面的页面上的代码是这样的:

/* Copyright (C) 1991, 1993, 1997, 2000, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Torbjorn Granlund (tege@sics.se), with help from Dan Sahlin (dan@sics.se); commentary by Jim Blandy (jimb@ai.mit.edu). The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include <string.h> #include <stdlib.h> #undef strlen /* Return the length of the null-terminated string STR. Scan for the null terminator quickly by testing four bytes at a time. */ size_t strlen (str) const char *str; { const char *char_ptr; const unsigned long int *longword_ptr; unsigned long int longword, magic_bits, himagic, lomagic; /* Handle the first few characters by reading one character at a time. Do this until CHAR_PTR is aligned on a longword boundary. */ for (char_ptr = str; ((unsigned long int) char_ptr & (sizeof (longword) - 1)) != 0; ++char_ptr) if (*char_ptr == '\0') return char_ptr - str; /* All these elucidatory comments refer to 4-byte longwords, but the theory applies equally well to 8-byte longwords. */ longword_ptr = (unsigned long int *) char_ptr; /* Bits 31, 24, 16, and 8 of this number are zero. Call these bits the "holes." Note that there is a hole just to the left of each byte, with an extra at the end: bits: 01111110 11111110 11111110 11111111 bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD The 1-bits make sure that carries propagate to the next 0-bit. The 0-bits provide holes for carries to fall into. */ magic_bits = 0x7efefeffL; himagic = 0x80808080L; lomagic = 0x01010101L; if (sizeof (longword) > 4) { /* 64-bit version of the magic. */ /* Do the shift in two steps to avoid a warning if long has 32 bits. */ magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; himagic = ((himagic << 16) << 16) | himagic; lomagic = ((lomagic << 16) << 16) | lomagic; } if (sizeof (longword) > 8) abort (); /* Instead of the traditional loop which tests each character, we will test a longword at a time. The tricky part is testing if *any of the four* bytes in the longword in question are zero. */ for (;;) { /* We tentatively exit the loop if adding MAGIC_BITS to LONGWORD fails to change any of the hole bits of LONGWORD. 1) Is this safe? Will it catch all the zero bytes? Suppose there is a byte with all zeros. Any carry bits propagating from its left will fall into the hole at its least significant bit and stop. Since there will be no carry from its most significant bit, the LSB of the byte to the left will be unchanged, and the zero will be detected. 2) Is this worthwhile? Will it ignore everything except zero bytes? Suppose every byte of LONGWORD has a bit set somewhere. There will be a carry into bit 8. If bit 8 is set, this will carry into bit 16. If bit 8 is clear, one of bits 9-15 must be set, so there will be a carry into bit 16. Similarly, there will be a carry into bit 24. If one of bits 24-30 is set, there will be a carry into bit 31, so all of the hole bits will be changed. The one misfire occurs when bits 24-30 are clear and bit 31 is set; in this case, the hole at bit 31 is not changed. If we had access to the processor carry flag, we could close this loophole by putting the fourth hole at bit 32! So it ignores everything except 128's, when they're aligned properly. */ longword = *longword_ptr++; if ( #if 0 /* Add MAGIC_BITS to LONGWORD. */ (((longword + magic_bits) /* Set those bits that were unchanged by the addition. */ ^ ~longword) /* Look at only the hole bits. If any of the hole bits are unchanged, most likely one of the bytes was a zero. */ & ~magic_bits) #else ((longword - lomagic) & himagic) #endif != 0) { /* Which of the bytes was the zero? If none of them were, it was a misfire; continue the search. */ const char *cp = (const char *) (longword_ptr - 1); if (cp[0] == 0) return cp - str; if (cp[1] == 0) return cp - str + 1; if (cp[2] == 0) return cp - str + 2; if (cp[3] == 0) return cp - str + 3; if (sizeof (longword) > 4) { if (cp[4] == 0) return cp - str + 4; if (cp[5] == 0) return cp - str + 5; if (cp[6] == 0) return cp - str + 6; if (cp[7] == 0) return cp - str + 7; } } } } libc_hidden_builtin_def (strlen)

为什么这个版本运行得很快?

它是不是做了很多不必要的工作?

我正在实现以下模型存储用户相关的数据在我的表-我有2列- uid(主键)和一个元列,其中存储关于JSON格式的用户的其他数据。

 uid   | meta
--------------------------------------------------
 1     | {name:['foo'], 
       |  emailid:['foo@bar.com','bar@foo.com']}
--------------------------------------------------
 2     | {name:['sann'], 
       |  emailid:['sann@bar.com','sann@foo.com']}
--------------------------------------------------

这种方法(在性能和设计方面)是否比每个属性一列模型更好?在每个属性一列模型中,表将有许多列,如uid、name、emailid。

我喜欢第一个模型的地方是,你可以添加尽可能多的字段,没有限制。

另外,我想知道,既然我已经实现了第一个模型。我如何对它执行查询,比如,我想获取所有名称为'foo'的用户?

问:在数据库中存储用户相关数据(请记住,字段的数量是不固定的),使用JSON还是每个字段列?另外,如果实现了第一个模型,如何查询上述数据库?我应该使用这两个模型,通过存储所有的数据,可以在一个单独的行和JSON(是不同的行)的数据查询搜索?


更新

由于没有太多需要执行搜索的列,使用这两种模型是否明智?每列键的数据,我需要搜索和JSON为其他人(在同一个MySQL数据库)?

我目前有一个密钥存储库,其中有一个只有我应该知道的特定密码。我现在需要将对密钥库的访问权授予其他人,因此我希望:

1)修改密码,这样我就可以和其他人分享,让他们签名 2)创建一个不同的密码,并允许他们使用该密码签名。

这可能吗?如果是,怎么做?

我试图找到.keystore文件和.jks文件之间的区别,但我找不到它。我知道jks代表“Java密钥存储库”,两者都是存储密钥/值对的方法。

两者之间有什么区别或偏好吗?

我有一个网站(Flash)本地化成十几种语言,我想根据用户的浏览器设置自动定义一个默认值,以尽量减少访问内容的步骤。

仅供参考,由于代理限制,我不能使用服务器脚本,所以我猜JavaScript或ActionScript将适合解决这个问题。

问题:

“猜测”用户语言环境的最佳方法是什么? 是否有任何现有的简单类/函数可以帮助我(没有复杂的本地化包)?特别是以一种聪明的方式将所有可能的语言减少到更小的数量(我有的翻译)。 在什么情况下我可以相信这样的解决方案? 还有其他的解决方法或建议吗?

我是rails编程的初学者,试图在一个页面上显示许多图像。有些图像是放在其他图像之上的。简单地说,假设我想要一个蓝色正方形,在蓝色正方形的右上角有一个红色正方形(但在角落里不紧)。我试图避免合成(与ImageMagick和类似)由于性能问题。

我只是想让重叠的图像彼此相对。

作为一个更困难的例子,想象一个里程表放在一个更大的图像中。对于六位数字,我需要合成一百万个不同的图像,或者在飞行中完成,其中所需要的只是将六张图像放在另一张图像的顶部。