binary-data

Full-text search on MongoDB GridFS?

我只是一个虾纸丫 提交于 2019-12-05 05:29:51
Say, if I want to store PDFs or ePub files using MongoDB's GridFS, is it possible to perform full-text searching on the data files? You can't currently do real full text search within mongo: http://www.mongodb.org/display/DOCS/Full+Text+Search+in+Mongo Feel free to vote for it here: https://jira.mongodb.org/browse/SERVER-380 Mongo is more of a general purpose scalable data store, and as of yet it doesn't have any full text search support. Depending on your use case, you could use the standard b-tree indexes with an array of all of the words in the text, but it won't do stemming or fuzzy

General question about Binary files

北城以北 提交于 2019-12-05 04:40:29
I am a beginner and I am having trouble in grasping binary files. When I write to a file in binary mode (in python), I just write normal text. There is nothing binary about it. I know every file on my computer is a binary file but I am having trouble distinguishing between files written in binary mode by me and files like audio, video etc files that show up as gibberish if I open them in a text editor. How are files that show up as gibberish created? Can you please give an example of a small file that is created like this, preferably in python? I have a feeling I am asking a really stupid

how to parse binary files in Clojure

ⅰ亾dé卋堺 提交于 2019-12-05 02:44:14
What is the cleanest way to parse binary data in clojure? I need to be able to read/write equally cleanly to a file or a socket. something like: (read-data source-of-data) => { :index 42 , :block-size 4 , data-size: 31415, :data (1 2 3 4 ...)} and the reverse for putting data back. It would be really great to somehow define the structure once and have the read and write functions use the same definition. Gloss makes it easy to define binary formats at the byte level for both reading and writing. (defcodec example-codec [:id :uint32 :msg-type (enum :byte {:a \A, :b \B}) :status (string :ascii

Output binary data from CGI in Python 3

此生再无相见时 提交于 2019-12-05 01:15:28
问题 This question is related to this one. I was having no problems while printing raw binary data from a CGI script in Python 2, for example: #!/usr/bin/env python2 import os if __name__ == '__main__': with open(os.path.abspath('test.png'), 'rb') as f: print "Content-Type: image/png\n" print f.read() Here are the relevant response headers: > GET /cgi-bin/plot_string2.py HTTP/1.1 > User-Agent: curl/7.32.0 > Host: 0.0.0.0:8888 > Accept: */* > * HTTP 1.0, assume close after body < HTTP/1.0 200

Accessing binary data from Javascript, Ajax, IE: can responseBody be read from Javascript (not VB)?

匆匆过客 提交于 2019-12-05 00:54:45
First of all, I am aware of this question: How do I load binary image data using Javascript and XMLHttpRequest? and specifically best answer therein, http://emilsblog.lerch.org/2009/07/javascript-hacks-using-xhr-to-load.html . So accessing binary data from Javascript using Firefox (and later versions of Chrome which actually seem to work too; don't know about Opera). So far so good. But I am still hoping to find a way to access binary data with a modern IE (ideally IE 6, but at least IE 7+), without using VB. It has been mentioned that XHR.messageBody would not work (if it contains zero bytes)

There are a “binary dump” or “get binary representation” function in LibXML2?

情到浓时终转凉″ 提交于 2019-12-04 17:15:39
I need to access the internal binary representation of a loaded XML DOM... There are some dump functions , but I not see something like "binary buffer" (there are only "XML buffers"). My last objective is to compare byte-by-byte, the same document , before and after some black-box procedure , directly with their binary (current and cached) representations, without convertion (to XML-text representation)... So, the question, There are a binary representation (in-memory structures) in LibXML2, to compare dump with current representations? I need only to check if current and dumped DOMs are

Java: read from binary file, send bytes over socket

假如想象 提交于 2019-12-04 16:24:44
This should be easy, but I can't get my head around it right now. I wanna send some bytes over a socket, like Socket s = new Socket("localhost", TCP_SERVER_PORT); DataInputStream is = new DataInputStream(new BufferedInputStream(s.getInputStream())); DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(s.getOutputStream())); for (int j=0; j<40; j++) { dos.writeByte(0); } That works, but now I dont want to writeByte to the Outputstream, but read from a binary file, then write it out. I know(?) I need a FileInputStream to read from, I just can't figure out hot to construct the

OpenCV binary adaptive threshold OCR

感情迁移 提交于 2019-12-04 15:43:10
问题 I need to convert some images to binary for OCR. Here are the functions I am using: Mat binarize(Mat & Img, Mat& res, float blocksize, bool inverse) { Img.convertTo(Img,CV_32FC1,1.0/255.0); CalcBlockMeanVariance(Img,res, blocksize, inverse); res=1.0-res; res=Img+res; if (inverse) { cv::threshold(res,res,0.85,1,cv::THRESH_BINARY_INV); } else { cv::threshold(res,res,0.85,1,cv::THRESH_BINARY); } cv::resize(res,res,cv::Size(res.cols/2,res.rows/2)); return res; } Where CalcBlockMeanVariance : void

Python binary data reading

送分小仙女□ 提交于 2019-12-04 14:12:25
问题 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

Convert an image to binary data (0s and 1s) in java

一个人想着一个人 提交于 2019-12-04 12:56:32
I want to read an image from a url and convert it into binary data. Please help me.. byte[] data = null; ByteArrayOutputStream bas = null; try { URL u = new URL( "http://www.eso.org/public/archives/images/screen/eso0844a.jpg"); HttpURLConnection con1 = (HttpURLConnection) u.openConnection(); con1.setAllowUserInteraction(true); con1.setRequestMethod("GET"); con1.connect(); InputStream is = con1.getInputStream(); BufferedImage imgToServe = null; if (is != null) { imgToServe = ImageIO.read(is); } bas = new ByteArrayOutputStream(); ImageIO.write(imgToServe, "jpg", bas); File f = new File("C:\\img