binary-data

Python binary data reading

情到浓时终转凉″ 提交于 2019-12-03 08:45:26
A urllib2 request receives binary response as below: 00 00 00 01 00 04 41 4D 54 44 00 00 00 00 02 41 97 33 33 41 99 5C 29 41 90 3D 71 41 91 D7 0A 47 0F C6 14 00 00 01 16 6A E0 68 80 41 93 B4 05 41 97 1E B8 41 90 7A E1 41 96 8F 57 46 E6 2E 80 00 00 01 16 7A 53 7C 80 FF FF Its structure is: DATA, TYPE, DESCRIPTION 00 00 00 01, 4 bytes, Symbol Count =1 00 04, 2 bytes, Symbol Length = 4 41 4D 54 44, 6 bytes, Symbol = AMTD 00, 1 byte, Error code = 0 (OK) 00 00 00 02, 4 bytes, Bar Count = 2 FIRST BAR 41 97 33 33, 4 bytes, Close = 18.90 41 99 5C 29, 4 bytes, High = 19.17 41 90 3D 71, 4 bytes, Low =

Read binary data from an image and save it with JavaScript

ぃ、小莉子 提交于 2019-12-03 08:22:06
I want to read the binary data of an image and then save it again to my local disk with JavaScript. I wrote a small demo that shows this use-case. To read the file I use readAsBinaryString from the File Reader API (HTML5) to get the binary data. I write the binary string into a textfield from which I then read the data again to write it to a file. If I save the file my images (I tested several JPEGs) are broken so you cannot see anything useful. Can it be that "readAsBinaryString" makes a conversion which makes the binary data incorrect? To have a look at my demo application I made a fiddle .

Finding a number of maximally different binary vectors from a set

折月煮酒 提交于 2019-12-03 05:17:47
Consider the set, S , of all binary vectors of length n where each contains exactly m ones; so there are n-m zeros in each vector. My goal is to construct a number, k , of vectors from S such that these vectors are as different as possible from each other. As a simple example, take n =4, m =2 and k =2, then a possible solution is: [1,1,0,0] and [0,0,1,1]. It seems that this is an open problem in the coding theory literature (?). Is there any way (i.e. algorithm) to find a suboptimal yet good solution ? Is Hamming distance the right performance measure to use in this case ? Some thoughts: In

Storing PDF files as binary objects in SQL Server, yes or no?

江枫思渺然 提交于 2019-12-03 04:46:27
I have to find a design decision for the following task: I have a SQL Server database and it contains a table of orders. PDF documents will be uploaded by users through a simple file upload from a web page and assigned to an order. There is not more than one document per order (perhaps no document, never more than one). For this purpose a user opens a web page, enters an order number, gets the order displayed and clicks on an upload button. So I know to which order the uploaded document belongs to. Now I am considering two options to store the documents on the web server: 1) Extend my table of

Prune binary data from a git repository after the fact

半腔热情 提交于 2019-12-03 04:09:56
问题 I accidentally committed some large binary data into some commits. Since then I've updated my .gitignore, and those files are no longer being committed. But I'd like to go back into the older commits and selectively prune out this data from the repository, removing a couple directories that should have been in .gitignore. I don't want to remove the commits themselves. How would I go about accomplishing this? My preferred method would be some way to retroactively apply the .gitignore rules to

How to insert images in mongoDB using java?

五迷三道 提交于 2019-12-03 03:31:06
问题 I want to store image documents in MongoDB. I am using java. Any links or suggestions would be appreciated. 回答1: For storing binary data like images you can use GridFS or implement your own realization; Download the driver and look at src/test/com/mongodb/gridfs/GridFSTest.java ;) Edit: you are lucky today! I made complete code for you;) Enjoy! package mongodb.testing.java; import com.mongodb.*; import com.mongodb.gridfs.*; import java.io.*; public class Main { public static byte[] LoadImage

Persisting Blob Streams with NHibernate

主宰稳场 提交于 2019-12-03 03:07:43
If I have a class declared as: public class MyPersistentClass { public int ID { get; set; } public Stream MyData {get;set; } } How can I use NHibernate's mappings to persist the MyData property to and from the database? Sebastian Markbåge You could use a Stream using a custom type and map it according to your storage needs. But there are some issues with using the Stream object as I mention in my blog series about lazy streaming of BLOBs and CLOBs with NHibernate . What you really need is a Blob object that in turn can create a Stream to read data from. Since Stream contains information about

What is the best file compression of random binary data that you can achieve? [closed]

那年仲夏 提交于 2019-12-03 03:02:56
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Specifically, what programs are out there and what has the highest compression ratio? I tried Googling it, but it seems experience would trump search results, so I ask. 回答1: If file sizes could be specified accurate to the bit, for any file size N, there would be precisely 2^(N+1)-1 possible files of N bits or

Calculating Binary Data Similarity

耗尽温柔 提交于 2019-12-03 00:23:52
问题 I've seen a few questions here related to determining the similarity of files, but they are all linked to a particular domain (images, sounds, text, etc). The techniques offered as solutions require knowledge of the underlying file format of the files being compared. What I am looking for is a method without this requirement, where arbitrary binary files could be compared without needing to understand what type of data they contain. That is, I am looking to determine the similarity percentage

Looking at binary output from fortran on gnuplot

血红的双手。 提交于 2019-12-02 19:49:01
So, I created a binary file with fortran, using something similar to this: open (3,file=filename,form="unformatted",access="sequential") write(3) matrix(i,:) The way I understand it, fortran pads the file with 4 bytes on either end of the file, and the rest is just the data that I want (in this case, a list of 1000 doubles). I want to read this in with gnuplot, however, I don't know how to get gnuplot to skip the first and last 4 bytes, and read the rest in as doubles. The documentation isn't very helpful in this regard. Thanks Testing with gnuplot 5.0, the following fortran unformatted data