magic-numbers

Does anyone know a list with magic numbers of file systems and archive/compression formats?

时光总嘲笑我的痴心妄想 提交于 2019-12-08 02:14:54
问题 I'm looking for a list that has the magic numbers of the most important of the following file systems and archive/compression formats: http://en.wikipedia.org/wiki/List_of_file_systems http://en.wikipedia.org/wiki/List_of_archive_formats For example something like: -filesystem- -magic_number- -cramfs- -45 3d cd 28 00- -archive/compression- -magic_number- -gz- -1f 8b- I found some on google but no complete list or technical docs, so I ask you guys as experts. 回答1: You could try this list: File

Refactor CSS to eliminate “magic numbers”

て烟熏妆下的殇ゞ 提交于 2019-12-07 04:58:58
问题 I know magic numbers are bad, but I still come across times when they seem unavoidable. I've created an example that I'd love for someone to show me how to refactor and eliminate the magic number. Hopefully, this will help me think differently about eliminating them in the future. My example on CodePen: http://codepen.io/kevinsperrine/pen/LiGlb Edit: Line 51 of the css file contains the "magic number". top: -42px; Edit 2: In an attempt to clarify what I'm asking: WordPress's Style Guide

What's the significance of -532459699?

↘锁芯ラ 提交于 2019-12-06 20:17:33
问题 This is a number that's returned as an exit code in many .NET exceptions (particularly COM exceptions, I think). In this question someone used Reflector to find out that this value was initialized to a private variable in nearly every Exception constructor. My question is, why? What significance does this number have? It's hard to believe that it was chosen arbitrarily. I don't even see any numeric significance (e.g., in its binary or hex representation). 回答1: Did you pay attention to its hex

non-NULL reserved pointer value

烈酒焚心 提交于 2019-12-06 11:43:53
How can I create a reserved pointer value? The context is this: I have been thinking of how to implement a data structure for a dynamic scripting language (I am not planning on implementing this - just wondering how it would be done). Strings may contain arbitrary bytes, including NUL. Thus, it is necessary to store the value separately. This requires a pointer (to point to the array) and a number. The first trick is that if the pointer is NULL, it cannot possibly be a valid string, so the number can be used for an actual integer. If a second reserved pointer value could be created, this could

Avoiding magic strings and numbers

陌路散爱 提交于 2019-12-06 07:11:57
问题 I am working on an application that has been edited by various programmers over the past few years and I have stumbled across a problem with using String Literals to access MenuItems. For Example: in many places there is code like mainMenu.MenuItems[1].MenuItems[0].Visible=true; or mainMenu.MenuItems["View"].MenuItems["FullScreen"].Visible=true; how do I change the Strings used to identify the MenuItem and catch all of the places that it is being used for access? The menus and menuitems are

How to identify the file type even though the file-extension has been changed?

大城市里の小女人 提交于 2019-12-06 05:08:12
This question was migrated from Information Security Stack Exchange because it can be answered on Stack Overflow. Migrated 6 years ago . Files are categorized by file-extension. So my question is, how to identify the file type even the file extension has been changed. For example, i have a video file with name myVideo.mp4 , i have changed it to myVideo.txt . So if i double-click it, the preferred text editor will open the file, and won't open the exact content. But, if i play myVideo.txt in a video player, the video will be played without any problem. I was just thinking of developing an

How can I say a file is SVG without using a magic number?

女生的网名这么多〃 提交于 2019-12-05 19:00:15
问题 An SVG file is basically an XML file so I could use the string <?xml (or the hex representation: '3c 3f 78 6d 6c' ) as a magic number but there are a few opposing reason not to do that if for example there are extra white-spaces it could break this check. The other images I need/expect to check are all binaries and have magic numbers. How can I fast check if the file is an SVG format without using the extension eventually using Python? 回答1: XML is not required to start with the <?xml preamble

What's the significance of -532459699?

冷暖自知 提交于 2019-12-05 01:24:10
This is a number that's returned as an exit code in many .NET exceptions (particularly COM exceptions, I think). In this question someone used Reflector to find out that this value was initialized to a private variable in nearly every Exception constructor. My question is, why? What significance does this number have? It's hard to believe that it was chosen arbitrarily. I don't even see any numeric significance (e.g., in its binary or hex representation). Did you pay attention to its hex representation, E0434F4D ? Here's a brief synopsis: E0 - represents E 43 - ASCII for C 4F - ASCII for O 4D

Is 23,148,855,308,184,500 a magic number, or sheer chance?

巧了我就是萌 提交于 2019-12-04 07:17:19
问题 Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. News reports such as this one indicate that the above number may have arisen as a programming bug. A man in the United States popped out to his local petrol station to buy a pack of cigarettes - only to find his card charged $23,148,855,308,184,500. That is $23 quadrillion (£14 quadrillion) - many times the US national

How can I say a file is SVG without using a magic number?

旧街凉风 提交于 2019-12-04 02:59:27
An SVG file is basically an XML file so I could use the string <?xml (or the hex representation: '3c 3f 78 6d 6c' ) as a magic number but there are a few opposing reason not to do that if for example there are extra white-spaces it could break this check. The other images I need/expect to check are all binaries and have magic numbers. How can I fast check if the file is an SVG format without using the extension eventually using Python? XML is not required to start with the <?xml preamble, so testing for that prefix is not a good detection technique — not to mention that it would identify every