Magic numbers are unexplained values that often should be replaced with a named constant.
Questions tagged [magic-numbers]
193 questions
0
votes
0 answers
File Mime Type Detection
There is a necessity to identify the mime type of the file. The file is uploaded through the browser and is read by the server in chunks asynchronously. Is it possible to detect file mime type using Apache Tika with few initial chunks rather than…

user3753682
- 187
- 4
- 13
0
votes
0 answers
file signature with C
I am working in a project to process images, and I need to check the contents of the images, to make sure that the format is valid (eg: png, jpg, etc). So, I know that I can use the magic numbers or file signature. I have tried to use the…

Gabriela Cavalcante
- 85
- 2
- 11
0
votes
2 answers
Finding out file type based on character inside a file
I want to find out file type of .properties file which is basically a text file. Using Apache tika and other mime type detectors prints out a .properties file as "text/plain" file as the magic number used for text file and .properties would be…
user4277706
0
votes
1 answer
Writing Java.class file in NodeJs (preserving magic number)
I have server that replaces some strings in a file. It looks like this:
var stringToBeReplacedWith = "Cool text";
var data = fs.readFileSync(file, 'utf-8');
var RegExp = new RegExp("Stringtobereplaced", 'g'); // global search
data =…

Mdlc
- 7,128
- 12
- 55
- 98
0
votes
1 answer
Flex SDK 3.5 - Check file magic number
Related to:
Flex SDK 3.5 - Check file mimetype
Is there a way to get a file's magic number in Flex SDK 3.5 in order to get the file type?

Fernando Briano
- 7,699
- 13
- 58
- 75
0
votes
1 answer
Is there a way to avoid "Magic Number" issues when I know the destination plateform?
I built a tool in python 2.7.5 and I compiled it with python -m compileall
When I tried to use it on the destination plateforme (python 2.6.6) I got that annoying "Magic Number" error.
I already read a bunch of things about that error and I think I…

Patrick Ferreira
- 1,983
- 1
- 15
- 31
0
votes
4 answers
Mapping magic numbers to enum values, and vice-versa
In the database I'm using this with there are magic numbers which I want to map to the State enum, and vice-versa. I'm intrigued by the static declaration of undefined.code = 0. What does this declaration, if that's what it is, actually…

Thufir
- 8,216
- 28
- 125
- 273
0
votes
3 answers
Magic numbers for parameters or method overloading?
I need to implement an interface for a class in C++ where I need to ask for events occured related with two kinds of sets, let's say here persons and actions. I need to ask for person identifier and action identifier in all possible combinations…

chorch
- 163
- 1
- 7
0
votes
1 answer
setbounds values are magic numbers
im getting setbounds values as magic numbers. Is there a way to assign all values to a variable rather than assigning a variable to each value?
setBounds(10,0,30,200);
thanks in advance.

Hash
- 7,726
- 9
- 34
- 53
0
votes
2 answers
jpanel background magic numbers
I don't want to use magic numbers. I'm setting a color to a jpanel background, Is there a possible way to use a color instead of
panel.setBackground(new color (255,255,255));
Thanks

Hash
- 7,726
- 9
- 34
- 53
0
votes
2 answers
Should screen dimension constants that hold magic numbers be refactored?
I have a few specific places in my code where I use specific pixel dimensions to blit certain things to the screen. Obviously these are placed in well named constants, but I'm worried that it's still kind of vague.
Example: This is in a small…

Anonymous
- 4,167
- 11
- 47
- 52
0
votes
1 answer
Is there a tool for the conversion of duplicate literals into final Strings/magic numbers in Java?
I have some Java files that use the same String values up to 20 times each, and I want a tool that replaces those Strings with a private static final String STRING_TO_CAPS_AS_CONSTANT or something along those lines. If it can also convert numbers…

NobleUplift
- 5,631
- 8
- 45
- 87
0
votes
6 answers
c# switch statement question
I'll cut to the chase. I have two questions about switch that are simple, but I can't figure them out.
First:
in c# switch statements, do case statements have to be consecutive (with ints)?
For example:
switch(someInt)
{
case 1
// some…

Alex
- 64,178
- 48
- 151
- 180
0
votes
1 answer
How to prepend a “magic number” to a core data persistent store?
Is is possible to prepend some “magic number” data to a core data persistent store?
I have an older application which uses a custom binary file format. Each file starts with a 5-byte magic number (let's say 0A 0B 0C 0D 0E) and a 1-byte format…

Rinzwind
- 1,173
- 11
- 23
0
votes
1 answer
Passing Array List Object between activities using parcelable
I'll first start this off saying i have seen all the other posts that deal with this and have tried all of them.
I'm trying to do the same thing asked in the other posts, which is to pass the values of a ArrayList from one activity to another using…

kbarnes
- 11
- 1
- 4