guid

Convert .NET Guid to MongoDB ObjectID

让人想犯罪 __ 提交于 2019-12-03 10:48:23
问题 How can I convert a .NET GUID to a MongoDB ObjectID (in C#). Also, can I convert it back again to the same GUID from the ObjectID? 回答1: You can't convert ObjectId into GUID and vice versa, because they are two different things(different sizes, algoritms). You can use any type for mongoDb _id including GUID . For example in official c# driver you should specify attribute [BsonId] : [BsonId] public Guid Id {get;set;} [BsonId] public int Id {get;set;} ObjectId: A BSON ObjectID is a 12-byte value

Generating unique and opaque user IDs in Google App Engine

时光怂恿深爱的人放手 提交于 2019-12-03 10:30:37
问题 I'm working on an application that lets registered users create or upload content, and allows anonymous users to view that content and browse registered users' pages to find that content - this is very similar to how a site like Flickr, for example, allows people to browse its users' pages. To do this, I need a way to identify the user in the anonymous HTTP GET request. A user should be able to type http://myapplication.com/browse/<userid>/<contentid> and get to the right page - should be

Exception in Glass mapper for Sitecore in PageEditor mode

匿名 (未验证) 提交于 2019-12-03 10:10:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: For the code: strMenuText . Append ( RenderLink ( mainlinkitem , x => x . NavigationItem . Url . StringToLink (), isEditable : true , contents : mainlinkitem . NavigationTitle )); Here mainlinkitem is Navigation object for interface created for data template. I am using interfaces in this case and castle windsor creates dynamic proxy objects for this. Things work ok until I try to use Page editor mode and below error shows up from glass mapper api. Expression doesn't evaluate to a member x.NavigationItem.Url.StringToLink() at Glass

Convert byte[] or object to GUID

我是研究僧i 提交于 2019-12-03 10:06:10
I assigned some value to object data type like, object objData =dc.GetDirectoryEntry().Properties["objectGUID"].Value; this object retun the value like {byte[16]} [0]: 145 [1]: 104 [2]: 117 [3]: 139 [4]: 124 [5]: 15 [6]: 255 [7]: 68 [8]: 142 [9]: 159 [10]: 208 [11]: 102 [12]: 148 [13]: 157 [14]: 179 [15]: 75 Then i casting this object to byte[], like byte[] binaryData = objData as byte[]; It will also return like, {byte[16]} [0]: 145 [1]: 104 [2]: 117 [3]: 139 [4]: 124 [5]: 15 [6]: 255 [7]: 68 [8]: 142 [9]: 159 [10]: 208 [11]: 102 [12]: 148 [13]: 157 [14]: 179 [15]: 75 Then i convert the hex

guid/uuid in Typescript Node.js app

妖精的绣舞 提交于 2019-12-03 09:25:51
I try to make a uuid (v 3.0.1) package work in Node/Typescript app, but I'm not sure what should I import and how to use it. This is index.d.ts (from @types/uuid v 2.0.29): declare namespace uuid { interface V1Options { node?: number[]; clockseq?: number; msecs?: number | Date; nsecs?: number; } type V4Options = { random: number[] } | { rng: () => number[]; } interface UuidStatic { (options?: V4Options): string; (options: V4Options | null, buffer: number[], offset?: number): number[]; (options: V4Options | null, buffer: Buffer, offset?: number): Buffer; v1(options?: V1Options): string; v1

How deterministic Are .Net GUIDs?

霸气de小男生 提交于 2019-12-03 09:11:10
问题 Yesterday I asked Are GUIDs generated on Windows 2003 safe to use as session IDs? and the answer combined with combined with this article GUIDs are globally unique, but substrings of GUIDs aren't prompted me to think about replacing my current mechanism of using GUIDs as session ID's in cookies. Because it's a bit of work to make that change I decided to run a quick GUID test on my Vista PC to see if a sequence of GUIDs was obviously deterministic (what I'm worried about is if an attacker was

What is the fastest way to look for duplicate uniqueidentifier in Sql Server?

匿名 (未验证) 提交于 2019-12-03 09:06:55
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: We use uniqueidentifier for every record within a very large database. For business reasons we need to ensure that the uniqueidentifier is never used more than once, but for performance reasons we have a bigint as the primary key . What is the fastest way to test the existence of a uniqueidentifer in a Sql server table? 回答1: ** < 0.05ms to validate a uniqueidentifier from 100,000,000 rows on a single Standard S0 Sql Azure instance. ** DISCLAIMER: The following aproach may require tweaking to your business requirements, and currently has only

GUID vs INT IDENTITY [duplicate]

匿名 (未验证) 提交于 2019-12-03 08:59:04
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Possible Duplicate: How do you like your primary keys? I'm aware of the benefits of using a GUID, as well as the benefits of using and INT as a PK in a database. Considering that a GUID is in essence a 128 bit INT and a normal INT is 32 bit, the INT is a space saver (though this point is generally moot in most modern systems). In the end, in what circumstances would you see yourself using an INT as a PK versus a GUID? 回答1: Kimberley Tripp (SQLSkills.com) has an article on using GUID's as primary keys. She advices against it because of the

Scrapy image download how to use custom filename

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: For my scrapy project I'm currently using the ImagesPipeline . The downloaded images are stored with a SHA1 hash of their URLs as the file names. How can I store the files using my own custom file names instead? What if my custom file name needs to contain another scraped field from the same item? e.g. use the item['desc'] and the filename for the image with item['image_url'] . If I understand correctly, that would involve somehow accessing the other item fields from the Image Pipeline. Any help will be appreciated. 回答1: This was the way I

GUID / UUID type in typescript

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have this function: function getProduct(id: string){ //return some product } where id is actually GUID. Typescript doesn't have guid type. Is it possible create type GUID manually? function getProduct(id: GUID){ //return some product } so if instead 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' will be some 'notGuidbutJustString' then I will see typescript compilation error. Update: as David Sherret said: there is no way to ensure a string value based on regex or some other function at compile time but it is possible do all the checks in one