binary-data

Prune binary data from a git repository after the fact

Deadly 提交于 2019-12-02 17:28:48
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 old commits... an answer that uses this method would also be pretty generally useful to others, since I

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

隐身守侯 提交于 2019-12-02 17:02:55
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. 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 smaller. In order for a file of size X to be mapped to some smaller size Y, some file of size Y or smaller must be mapped to a file of size X or larger. The only way lossless compression can work is if some possible files can be identified as being more probable than others; in that scenario,

How to insert images in mongoDB using java?

懵懂的女人 提交于 2019-12-02 17:01:19
I want to store image documents in MongoDB. I am using java. Any links or suggestions would be appreciated. Edward83 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(String filePath) throws Exception { File file = new File(filePath); int size = (int)file.length();

Calculating Binary Data Similarity

廉价感情. 提交于 2019-12-02 14:03:30
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 of two files' binary data . To give a little more detail for you to work with, even though this is

Applying cumsum to binary vector

自闭症网瘾萝莉.ら 提交于 2019-12-02 12:27:30
I have a simple binary vector a which I try to translate into vector b using the R function cumsum . However, cumsum does not exactly return vector b . Here is an example: a <- c(1,0,0,0,1,1,1,1,0,0,1,0,0,0,1,1) b <- c(1,2,2,2,3,4,5,6,7,7,8,9,9,9,10,11) > cumsum(a) [1] 1 1 1 1 2 3 4 5 5 5 6 6 6 6 7 8 The problem is that whenever a 0 appears in vector a then the previous number should be increased by 1 but only for the first 0. The remaining ones are given the same value. Any advise would be great! :-) The trick is to use diff to mark the transitions: cumsum(as.logical(a+c(0,abs(diff(a))))) [1]

How to loop over a binary file in Python in chunks

廉价感情. 提交于 2019-12-02 11:16:09
问题 I'm trying to use Python to loop over a long binary file filled with 8-byte records. Each record has the format [ uint16 | uint16 | uint32 ] (which is "HHI" in struct-formatting) Apparently each 8-byte block is getting treated as an int , instead of an array of 8-bytes, then causing the struct.unpack call to fail with open(fname, "rb") as f: sz=struct.calcsize("HHI") print(sz) # This shows 8, as expected for raw in f.read(sz): # Expect this should read 8 bytes into raw print(type(raw)) # This

Displaying Raw Data From Image File Using TextBox or RichTextBox?

强颜欢笑 提交于 2019-12-02 06:17:55
问题 My program reads a DDS image file and stores it as a byte array. I want to be able to show the users the raw data in a TextBox form so at first I convert the byte array to a string using the following code: string data = System.Text.Encoding.ASCII.GetString(bytes); I then set the TextBox text: textBox.Text = data; The problem I am having is the text box is not showing all the data. Here is a screenshot of how it looks: As you can see only the first few characters are displayed. I am assuming

Getting Binary Data from StandardOutput

给你一囗甜甜゛ 提交于 2019-12-02 05:43:42
问题 I'm starting a process with code similar to that below: // some of the flags are not needed process.StartInfo.CreateNoWindow = true; process.StartInfo.ErrorDialog = false; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardError = true; process.StartInfo.RedirectStandardOutput = true; process.EnableRaisingEvents = true; process.OutputDataReceived += process_OutputDataReceived; process.ErrorDataReceived += process_OutputDataReceived; process.Start(); process

Outputting a Binary String to a Binary File in C++

那年仲夏 提交于 2019-12-02 05:09:26
Let's say I have a string that contains a binary like this one "0110110101011110110010010000010". Is there a easy way to output that string into a binary file so that the file contains 0110110101011110110010010000010? I understand that the computer writes one byte at a time but I am having trouble coming up with a way to write the contents of the string as a binary to a binary file. Use a bitset: //Added extra leading zero to make 32-bit. std::bitset<32> b("00110110101011110110010010000010"); auto ull = b.to_ullong(); std::ofstream f; f.open("test_file.dat", std::ios_base::out | std::ios_base:

Render blob image with Angular 4

喜欢而已 提交于 2019-12-02 03:53:14
问题 I'm trying to render an user image that comes from soap server response, it not should be difficult but i dont know how start to do. This is the code of the request way: this.http.post(wsurl, xml, {withCredentials: true, headers: headers}) .toPromise() .then((response) =>.... This is the response: ------=_Part_18_19650293.1510067330953 Content-Type: text/xml; charset=UTF-8 Content-Transfer-Encoding: binary Content-Id: <94A7DA36FAAE3F537AD3295BF2DFF5AD> <?xml version="1.0" encoding="UTF-8"?>