走过海棠暮

文章 评论 浏览 25

走过海棠暮 2024-08-26 05:45:08

我不会使用程序集作为许可证文件 - 正如其他人指出的那样,破坏它相对微不足道。
我会使用一个文件(xml 或其他文件),然后将其锁定到用户计算机。这可以通过多种方式实现:
1)使用 System.Cryptography.ProtectedData - 这只是包装 Windows DPAPI 并使用 Windows 密钥存储(每个用户或每个本地计算机)。这是一种简单的方法,但您必须使用 Encoding.UTF8.GetString (或任何您的编码)从字节数组转换回来。这很简单,但不是工业强度,因为有人仍然可以挖出密钥库等。
2) 使用机器唯一 ID(例如具有对称算法(例如 Rijndael 或 Blowfish)的 SID,并提供未加密许可证文件的 SHA-256 哈希值作为 IV。这实现起来有点复杂,因为您需要使用 WMI 来查找 SID,然后使用 System.Security.Cryptography.RijndaelManaged 等来进行加密/解密。

I wouldn't go with using an assembly as a license file - as others have pointed out it's relatively trivial to break.
I would use a file ( xml or whatever ) then lock it to the users machine. This can be achieved in several ways :
1) Use System.Cryptography.ProtectedData - this just wraps the Windows DPAPI and uses the windows key store ( either per user or per local machine ). This a simple(ish) approach but you will have to using Encoding.UTF8.GetString ( or whatever your encoding is ) to convert back from a byte array. This is simple but not industrial strength as someone could still dig out the key store etc.
2) Use a machine unique ID such as the SID with a symmetric algorithm such as Rijndael or Blowfish and provide the SHA-256 hash of the unencrypted license file as the IV. This is a bit more complex to implement as you'd need to use WMI to find the SID and then use System.Security.Cryptography.RijndaelManaged etc to do the encryption/decryption.

使用程序集作为许可证文件的优点/缺点?

走过海棠暮 2024-08-26 02:46:55

多对多根据结构的不同设置不同的方式。如果类 A 具有 B 实体的集合,您可以将其直接绑定到 DataSource 属性,如下所示:

<asp:Repeater ... DataSource="<% Eval("Bs") %>">

因此,这取决于对象模型中实体的引用方式,这又取决于多对多设置。看看这个:http://thedatafarm.com/blog/data-access/inserting-many-to-many-relationships-in-ef-with-or-without-a-join-entity/

Many to many is setup different ways depending on structure. If class A has a collection of B entities, you can bind it directly to the DataSource property as in:

<asp:Repeater ... DataSource="<% Eval("Bs") %>">

So it depends on how the entities are referenced in your object model, which again varies depending on the many to many setup. Check this out: http://thedatafarm.com/blog/data-access/inserting-many-to-many-relationships-in-ef-with-or-without-a-join-entity/

使用来自 2 个实体框架查询的数据加载嵌套转发器

走过海棠暮 2024-08-26 01:42:34

为了让客户端排序工作,我需要在加载网格后调用 reloadGrid

loadComplete: function() {
    jQuery("#myGridID").trigger("reloadGrid"); // Call to fix client-side sorting
}

我不必在应用程序中的另一个网格上执行此操作,因为它被配置为使用通过另一个网格检索的数据AJAX 调用,而不是直接由网格检索数据:

editurl: "clientArray"
datatype: "local"

To get client-side sorting to work, I needed to call reloadGrid after the grid was loaded:

loadComplete: function() {
    jQuery("#myGridID").trigger("reloadGrid"); // Call to fix client-side sorting
}

I did not have to do this on another grid in my application because it was configured to use data retrieved via another AJAX call, instead of data retrieved directly by the grid:

editurl: "clientArray"
datatype: "local"

jqGrid客户端排序

走过海棠暮 2024-08-26 01:30:15

对于这种情况,一种更简单、更方便的解决方案是将包含 .h 文件的目录(在本例中为 /lib/irrlicht-1.6/include)拖到项目文件中,而不是显式地将包含路径添加到项目设置中窗格。当然,这会将标头添加到您的项目中,并且可以轻松浏览它们并搜索符号等,并且还将目录路径添加到 gcc 编译中,以便您不必显式管理包含路径。

Rather than explicitly adding include paths to your project settings, an easier and more convenient solution for this kind of situation is to just drag the directory containing your .h files (/lib/irrlicht-1.6/include in this case) into the project files pane. This adds the headers to your project of course, and makes it easy to browse them and search for symbols, etc, and it also adds the directory path to gcc compiles, so that you don't have to manage include paths explicitly.

Xcode 找不到#Include<>标头

走过海棠暮 2024-08-25 20:05:38

您也可以将这一解决方案用于 WebView。调用 findAllAsync

webview.findAllAsync(((EditText) findViewById(R.id.edit)).getText().toString());

并将 FindListener 添加到 WebView

    webview.setFindListener(new FindListener() {

        @Override
        public void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches, boolean isDoneCounting) {
            Toast.makeText(getApplicationContext(), "Matches: " + numberOfMatches, Toast.LENGTH_LONG).show();
        }
    });

使用 webview.findNext(false); 迭代结果,其中 false/true显示方向。

但这个解决方案是在 API level 16 中添加的!!!您可以设置 JavaScript 来进行高亮显示 - http://www.nsftools.com/misc/SearchAndHighlight。嗯

As well you could use this one solution for WebView. Call findAllAsync

webview.findAllAsync(((EditText) findViewById(R.id.edit)).getText().toString());

than add FindListener to WebView

    webview.setFindListener(new FindListener() {

        @Override
        public void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches, boolean isDoneCounting) {
            Toast.makeText(getApplicationContext(), "Matches: " + numberOfMatches, Toast.LENGTH_LONG).show();
        }
    });

Iterate in result with webview.findNext(false); where false/true shows the direction.

But this solution was added in API level 16!!! Instead of you can setup JavaScript for higlihting - http://www.nsftools.com/misc/SearchAndHighlight.htm

在 TextView 或 WebView 中突出显示文本

走过海棠暮 2024-08-25 13:07:43

听起来您实际上还没有分配数组。通常,您会在初始化程序中执行此操作。 (也不要忘记将 release 添加到您的 dealloc 方法中。)@synthesize 创建 getter 和 setter,但您仍然拥有自己处理对象的分配/解除分配。

It sounds like you haven't actually allocated array. Generally, you would do this in your initializer. (Don't forget to add a release to your dealloc method, too.) @synthesize creates the getter and setter, but you still have to handle allocating/deallocating the object yourself.

与 NSString 相关的问题

走过海棠暮 2024-08-25 10:30:25

您是否将其回显到 HTML 页面中?因为代码会被解析成实际的链接。

查看输出页面的来源。

Are you echoing it into an HTML page? Because the code will be parsed into an actual link.

View the source of your output page.

通过 Form 将 Textarea 中的 HTML 代码发送到 PHP

走过海棠暮 2024-08-25 09:49:54

插入->节目列表功能效果很好。我只是想补充一点,如果你在Mac上,并尝试直接使用命令+V或右键单击+粘贴将一段代码粘贴到程序列表中,空格将不会被保留,你必须手动通过键入制表符、回车符等插入空格。

解决此问题的一个非常简单的方法是使用 shift+command+V 进行粘贴。这会保留原始源代码的所有空白。

The insert->Program Listing feature works great. I just want to add that if you are on Mac, and try to directly paste, using command+V or right-click+paste, a block of code into the program listing, the whitespace will not be preserved, and you have to manually insert the whitespace by typing tabs, returns, etc.

A very easy way to get around this is is to paste using shift+command+V. This preserves all the whitespace of your original source code.

在 Lyx 文档中插入编程代码

走过海棠暮 2024-08-25 09:09:49

任何有兴趣将 Preon 移植到 .NET 的人,请随时与我联系。我是 Java Preon 的开发者:flotsam dot nl 的 wilfred

Anyone interested in porting Preon to .NET, feel free to to contact me. I'm the developer of Java Preon: wilfred at flotsam dot nl

.NET 的二进制文件解析库

走过海棠暮 2024-08-25 06:06:39

最简单的是

std::wstring w( s.begin(), s.end() );

......但要保留口音,您需要 codecvt 但是,这个示例可能有用。

The simplest would be

std::wstring w( s.begin(), s.end() );

... but to preserve accents you'd need codecvt however, this example might be useful.

OS X 上的字符串到 wstring 转换

走过海棠暮 2024-08-25 04:32:53

我不确定我是否理解您的问题,但是可以使用类 java/awt/geom/Area.

I'm not sure I understand your question but composite shapes can be created with the class java/awt/geom/Area.

在 Java 2D 中创建复合形状

走过海棠暮 2024-08-25 03:00:48

我就是这样做的。

我认为这已经是合理范围内尽可能有效的了。它优化了单字符大小写,并避免为每个删除的子序列创建多个子字符串。

请注意,处理了将空字符串传递给修剪的极端情况(其他一些答案将进入无限循环)。

/** Trim all occurrences of the string <code>rmvval</code> from the left and right of <code>src</code>.  Note that <code>rmvval</code> constitutes an entire string which must match using <code>String.startsWith</code> and <code>String.endsWith</code>. */
static public String trim(String src, String rmvval) {
    return trim(src,rmvval,rmvval,true);
    }

/** Trim all occurrences of the string <code>lftval</code> from the left and <code>rgtval</code> from the right of <code>src</code>.  Note that the values to remove constitute strings which must match using <code>String.startsWith</code> and <code>String.endsWith</code>. */
static public String trim(String src, String lftval, String rgtval, boolean igncas) {
    int                                 str=0,end=src.length();

    if(lftval.length()==1) {                                                    // optimize for common use - trimming a single character from left
        char chr=lftval.charAt(0);
        while(str<end && src.charAt(str)==chr) { str++; }
        }
    else if(lftval.length()>1) {                                                // handle repeated removal of a specific character sequence from left
        int vallen=lftval.length(),newstr;
        while((newstr=(str+vallen))<=end && src.regionMatches(igncas,str,lftval,0,vallen)) { str=newstr; }
        }

    if(rgtval.length()==1) {                                                    // optimize for common use - trimming a single character from right
        char chr=rgtval.charAt(0);
        while(str<end && src.charAt(end-1)==chr) { end--; }
        }
    else if(rgtval.length()>1) {                                                // handle repeated removal of a specific character sequence from right
        int vallen=rgtval.length(),newend;
        while(str<=(newend=(end-vallen)) && src.regionMatches(igncas,newend,rgtval,0,vallen)) { end=newend; }
        }

    if(str!=0 || end!=src.length()) {
        if(str<end) { src=src.substring(str,end); }                            // str is inclusive, end is exclusive
        else        { src="";                     }
        }

    return src;
    }

Here's how I would do it.

I think it's about as efficient as it reasonably can be. It optimizes the single character case and avoids creating multiple substrings for each subsequence removed.

Note that the corner case of passing an empty string to trim is handled (some of the other answers would go into an infinite loop).

/** Trim all occurrences of the string <code>rmvval</code> from the left and right of <code>src</code>.  Note that <code>rmvval</code> constitutes an entire string which must match using <code>String.startsWith</code> and <code>String.endsWith</code>. */
static public String trim(String src, String rmvval) {
    return trim(src,rmvval,rmvval,true);
    }

/** Trim all occurrences of the string <code>lftval</code> from the left and <code>rgtval</code> from the right of <code>src</code>.  Note that the values to remove constitute strings which must match using <code>String.startsWith</code> and <code>String.endsWith</code>. */
static public String trim(String src, String lftval, String rgtval, boolean igncas) {
    int                                 str=0,end=src.length();

    if(lftval.length()==1) {                                                    // optimize for common use - trimming a single character from left
        char chr=lftval.charAt(0);
        while(str<end && src.charAt(str)==chr) { str++; }
        }
    else if(lftval.length()>1) {                                                // handle repeated removal of a specific character sequence from left
        int vallen=lftval.length(),newstr;
        while((newstr=(str+vallen))<=end && src.regionMatches(igncas,str,lftval,0,vallen)) { str=newstr; }
        }

    if(rgtval.length()==1) {                                                    // optimize for common use - trimming a single character from right
        char chr=rgtval.charAt(0);
        while(str<end && src.charAt(end-1)==chr) { end--; }
        }
    else if(rgtval.length()>1) {                                                // handle repeated removal of a specific character sequence from right
        int vallen=rgtval.length(),newend;
        while(str<=(newend=(end-vallen)) && src.regionMatches(igncas,newend,rgtval,0,vallen)) { end=newend; }
        }

    if(str!=0 || end!=src.length()) {
        if(str<end) { src=src.substring(str,end); }                            // str is inclusive, end is exclusive
        else        { src="";                     }
        }

    return src;
    }

Java 中的修剪字符

走过海棠暮 2024-08-24 22:44:56

也许 jvmtop 值得一看。
它是一个命令行工具,可为多个指标提供实时视图

您可以使用其 STDOUT 作为进一步处理的输入。

输出示例:

 JvmTop 0.4.1  amd64  8 cpus, Linux 2.6.32-27, load avg 0.12
 http://code.google.com/p/jvmtop

  PID MAIN-CLASS      HPCUR HPMAX NHCUR NHMAX    CPU     GC    VM USERNAME   #T DL
 3370 rapperSimpleApp  165m  455m  109m  176m  0.12%  0.00% S6U37 web        21
11272 ver.resin.Resin [ERROR: Could not attach to VM]
27338 WatchdogManager   11m   28m   23m  130m  0.00%  0.00% S6U37 web        31
19187 m.jvmtop.JvmTop   20m 3544m   13m  130m  0.93%  0.47% S6U37 web        20
16733 artup.Bootstrap  159m  455m  166m  304m  0.12%  0.00% S6U37 web        46

Maybe jvmtop is worth a look.
It's a command-line tool which provides a live-view for several metrics.

You can use its STDOUT as an input for further processing.

Example output:

 JvmTop 0.4.1  amd64  8 cpus, Linux 2.6.32-27, load avg 0.12
 http://code.google.com/p/jvmtop

  PID MAIN-CLASS      HPCUR HPMAX NHCUR NHMAX    CPU     GC    VM USERNAME   #T DL
 3370 rapperSimpleApp  165m  455m  109m  176m  0.12%  0.00% S6U37 web        21
11272 ver.resin.Resin [ERROR: Could not attach to VM]
27338 WatchdogManager   11m   28m   23m  130m  0.00%  0.00% S6U37 web        31
19187 m.jvmtop.JvmTop   20m 3544m   13m  130m  0.93%  0.47% S6U37 web        20
16733 artup.Bootstrap  159m  455m  166m  304m  0.12%  0.00% S6U37 web        46

如何获取用于在 Jconsole 中创建图表的 csv 数据

走过海棠暮 2024-08-24 20:25:34

嗯,基于网格的答案很好,但有时您无论如何都需要对接近的点进行分组,即使它们不在同一个网格单元中。我的方法是通过分组来实现这一点:如果两个点靠近或者有一系列靠近点连接它们,则它们位于同一组中。此语义无法使用适当的 IEqualityComparer 来完成,因为它需要在生成组之前提前了解所有项目。所以我做了一个简单的LINQ风格的运算符GroupByCluster,它基本上实现了这一点。

代码位于:http://ideone.com/8l0LH。它可以在我的 VS 2010 上编译,但无法在 Mono 上编译,因为 HashSet<> 无法隐式转换为 IEnumerable<>(为什么?)。

该方法是通用的,因此效率不高:它是输入大小的二次方。对于具体类型,它可以变得更高效:例如,对于 T = double,我们只需对输入数组进行排序即可获得 O(n log n) 性能。类似但更复杂的技巧也适用于 2D 点。


注意:您最初的主张不可能用 IEqualityComparer 实现,因为您的“近似相等”不是传递性的(但 IEqualityComparer 中的相等必须如此)。

Well, the answer based on grids is good, but sometimes you need to group the close points anyway, even if they are not in the same grid cell. My approach is to implement this with a grouping: two points are in the same group if either they are close or there is a sequence of close points connecting them. This semantics cannot be done with a proper IEqualityComparer, because it needs to know all the items in advance before producing the groups. So I've done a simple LINQ-style operator GroupByCluster, which basically achieves this.

The code is here: http://ideone.com/8l0LH. It compiles on my VS 2010, but fails to compile on Mono because HashSet<> cannot be implicitly converted to IEnumerable<> (why?).

The approach is generic and thus not very efficient: it's quadratic on input size. For the concrete types it can be made more efficient: for example, for T = double we can just sort the input array and have O(n log n) performance. The analogous though more complicated trick is applicable for 2D points as well.


Note aside: your initial proposition is impossible to implement with IEqualityComparer, since your "approximate equality" is not transitive (but the equality in IEqualityComparer has to be so).

如何实现 IEqualityComparer有公差

走过海棠暮 2024-08-24 12:49:06

您可以从 中的 $_SERVER 全局变量找出所有内容>genimg.php,就像普通脚本一样。

例如,使用 $_SERVER['REMOTE_HOST'] 确定用户查看当前页面的主机名(在您的情况下,加载图像)。请参阅手册中的更多详细信息。

You can figure out everything from $_SERVER global variable in your genimg.php, just as a normal script would.

For example, use $_SERVER['REMOTE_HOST'] to determine the host name from which the user is viewing the current page (in your case, loading the image). See more details in the manual.

从 php 生成的链接图像中检索反向链接信息

更多

推荐作者

寻梦旅人

文章 0 评论 0

冰美式不加糖

文章 0 评论 0

m0_51416705

文章 0 评论 0

123456wqwqwq

文章 0 评论 0

qq_R47skh

文章 0 评论 0

hs1283

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文