identification

Django content type of an image file

泪湿孤枕 提交于 2019-12-11 03:43:45
问题 I want to check a file type before uploading it by: content = self.cleaned_data['picture'] content_type = content.content_type.split('/')[0] When I upload the picture I get an error: 'NoneType' object has no attribute 'content_type' What can be wrong here? 回答1: imghdr.what will return image format as string (gif, png etc.) if the image is valid, or None otherwise. Usage: import imghdr imghdr.what(value) In the above example value can be either a file(-like) object or a filename. 来源: https:/

Identifying CDs

江枫思渺然 提交于 2019-12-09 00:38:11
问题 I'd like to be able to determine what music album CD is in a CD drive. For example, if someone claims that the CD in their drive is Eminem - The Eminem Show, I would like to be able to verify that the CD is indeed The Eminem Show. Any ideas? I've applied for a Gracenote developer license, but they won't get back to me for five days. Also, how does this work? Is there some GUID or other unique identifier that music discs are encoded with? Lastly, might this be possible with data CDs, like, say

How can I know if a TIFF image is in the format CCITT T.6(Group 4)?

二次信任 提交于 2019-12-08 17:36:21
问题 How can I know if a TIFF image is in the format CCITT T.6(Group 4)? 回答1: You can use this (C#) code example. It returns a value indicating the compression type: 1: no compression 2: CCITT Group 3 3: Facsimile-compatible CCITT Group 3 4: CCITT Group 4 (T.6) 5: LZW public static int GetCompressionType(Image image) { int compressionTagIndex = Array.IndexOf(image.PropertyIdList, 0x103); PropertyItem compressionTag = image.PropertyItems[compressionTagIndex]; return BitConverter.ToInt16

How to identify a zip file in java?

亡梦爱人 提交于 2019-12-05 08:41:28
I want to identify my archive whether it is zip or rar . But the problem I get runtime error before I can validate my file. I want to create custom notification: public class ZipValidator { public void validate(Path pathToFile) throws IOException { try { ZipFile zipFile = new ZipFile(pathToFile.toFile()); String zipname = zipFile.getName(); } catch (InvalidZipException e) { throw new InvalidZipException("Not a zip file"); } } } At the moment I have runtime error: java.util.zip.ZipException: error in opening zip file I'd suggest to open a plain InputStream an reading the first few bytes (magic

Why is stanford corenlp gender identification nondeterministic?

我只是一个虾纸丫 提交于 2019-12-04 14:45:54
I have the following results and as you can see the name edward has different results (null and male). This has happened with several names. edward, Gender: null james, Gender: MALE karla, Gender: null edward, Gender: MALE Additionally, how can I customize the gender dictionaries? I want to add Spanish and Chinese names. You have raised a lot of issues! 1.) Karla is not in the default gender mappings file, so that is why that's getting null 2.) If you want to make your own custom file, it should be in this format: JOHN\tMALE There should be one NAME\tGENDER entry per line The GenderAnnotator

Can you find out which compiler was used to compile a program?

笑着哭i 提交于 2019-12-04 09:17:51
问题 Given an executable that is compiled from C to run on Solaris, is it possible to determine which compiler was used to compile the associated incomplete executable? I can't see anything when using either the strings or the file command, and magic doesn't seem to contain anything specific. Do compilers generally put a fingerprint in their executable output files? cheers, 回答1: If the executable isn't stripped, try /usr/ccs/bin mcs-p This will usually show the compiler, linker and all the header

How to get specific ID for a JButton?

◇◆丶佛笑我妖孽 提交于 2019-12-04 06:24:38
问题 I'm trying to build a program that utilizes a 3x3 grid of buttons (using Java Swing), so I initialize it with a GridLayout and a loop to create the buttons: panel.setBorder(BorderFactory.createEmptyBorder(3,3,5,5)) panel.setLayout(new GridLayout(3,3,10,10)); String[] buttons = {"Top Left", "Top Middle", "Top Right", "Middle Left", "Middle", "Middle Right", "Bottom Left", "Bottom Middle", "Bottom Right"}; for(int i = 0; i < buttons.length; i++) { buttray[i] = new JButton(buttons[i]); panel.add

How can I uniquely identify a machine in C?

混江龙づ霸主 提交于 2019-12-03 11:31:20
I want to uniquely identify a machine in C. The following are sources which have serial numbers, but they aren't guaranteed to be unique, or present (like a removable HDD or network card). CPU: I'm using the cpuid instruction, however, serial number is not implemented for any processor except Pentium 3, i.e. not relevant. I can use the processor signature, but this won't be unique for every processor. HDD: ? BIOS: ? motherboard: ? MAC address: via system function calls. For all the question marks, how would I get the serial numbers in C? If you answer with a system dependent solution, please

Can you find out which compiler was used to compile a program?

被刻印的时光 ゝ 提交于 2019-12-03 01:41:29
Given an executable that is compiled from C to run on Solaris, is it possible to determine which compiler was used to compile the associated incomplete executable? I can't see anything when using either the strings or the file command, and magic doesn't seem to contain anything specific. Do compilers generally put a fingerprint in their executable output files? cheers, If the executable isn't stripped, try /usr/ccs/bin mcs-p This will usually show the compiler, linker and all the header files used Yes IDA is great for this. It uses a technology called FLIRT . PEID will do the trick. It

How to get specific ID for a JButton?

丶灬走出姿态 提交于 2019-12-02 12:19:19
I'm trying to build a program that utilizes a 3x3 grid of buttons (using Java Swing), so I initialize it with a GridLayout and a loop to create the buttons: panel.setBorder(BorderFactory.createEmptyBorder(3,3,5,5)) panel.setLayout(new GridLayout(3,3,10,10)); String[] buttons = {"Top Left", "Top Middle", "Top Right", "Middle Left", "Middle", "Middle Right", "Bottom Left", "Bottom Middle", "Bottom Right"}; for(int i = 0; i < buttons.length; i++) { buttray[i] = new JButton(buttons[i]); panel.add(buttray[i]); buttray[i].addActionListener(this); } The buttons load just fine, but I do not understand