binary

How do you express binary literals in Python?

How do you express an integer as a binary number with Python literals? I was easily able to find the answer for hex: >>> 0x12AF 4783 >>> 0x100 256 and, octal: >>> 01267 695 >>> 0100 64 How do you use literals to express binary in Python? Summary of Answers Python 2.5 and earlier: can express bi...

Binary file layout reference

Where are good sources of information on binary file layout structures? If I wanted to pull in a BTrieve index file, parse MP3 headers, etc... where does one get reliable information?...

Binary buffer in Python

In Python you can use StringIO for a file-like buffer for character data. Memory-mapped file basically does similar thing for binary data, but it requires a file that is used as the basis. Does Python have a file object that is intended for binary data and is memory only, equivalent to Java's ByteArrayOutputStream? The use-case I have i...

SharePoint stream file for preview

I am looking to stream a file housed in a SharePoint 2003 document library down to the browser. Basically the idea is to open the file as a stream and then to "write" the file stream to the reponse, specifying the content type and content disposition headers. Content disposition is used to preserve the file name, content type of course...

How would you explain binary to your grandmother?

I recently bought a shirt with this great quote on "There are 10 types of people in the world, those who can read binary, and those who can't." Now I find myself having to explain it to everybody! How would you explain this shirt to your grandmother, mother, kid, etc... ...

Self validating binaries?

My question is pretty straightforward: You are an executable file that outputs "Access granted" or "Access denied" and evil persons try to understand your algorithm or patch your innards in order to make you say "Access granted" all the time. After this introduction, you might be heavily wondering what I am doing. Is he going to crack...

How many bits are there in a nibble?

binary question :) ...

How do you write a binary literal in ruby?

Most languages (Ruby included) allow number literals to be written in at least three bases: decimal, octal and hexadecimal. Numbers in decimal base is the usual thing and are written as (most) people naturally write numbers, 96 is written as 96. Numbers prefixed by a zero are usually interpreted as octal based: 96 would be written as 014...

How would you go about reverse engineering a set of binary data pulled from a device?

A friend of mine brought up this questiont he other day, he's recently bought a garmin heart rate moniter device which keeps track of his heart rate and allows him to upload his heart rate stats for a day to his computer. The only problem is there are no linux drivers for the garmin USB device, he's managed to interpret some of the data...

Converting string of 1s and 0s into binary value

I'm trying to convert an incoming sting of 1s and 0s from stdin into their respective binary values (where a string such as "11110111" would be converted to 0xF7). This seems pretty trivial but I don't want to reinvent the wheel so I'm wondering if there's anything in the C/C++ standard libs that can already perform such an operation? ...

Locking binary files using git version control system

For one and a half years, I have been keeping my eyes on the git community in hopes of making the switch away from SVN. One particular issue holding me back is the inability to lock binary files. Throughout the past year I have yet to see developments on this issue. I understand that locking files goes against the fundamental principle...

Find matching sequences in two binary files

Let me start off with a bit of background. This morning one of our users reported that Testuff's setup file has been reported as infected with a virus by the CA antivirus. Confident that this was a false positive, I looked on the web and found that users of another program (SpyBot) have reported the same problem. A now, for the actual ...

C# file read/write fileshare doesn't appear to work

Hi, My question is based off of inheriting a great deal of legacy code that I can't do very much about. Basically, I have a device that will produce a block of data. A library which will call the device to create that block of data, for some reason I don't entirely understand and cannot change even if I wanted to, writes that block of...

How to check my byte flag?

I use a byte to store some flag like : 10101010 and I would like to know how to verify that a specific bit is at 1 or 0. ...

How to package a Linux binary for my Open Source application?

I have an Open Source app and I currently only post the binary for the Windows build. At this point Linux users have to get the source and compile it. Is there a standard way for posting a Linux binary? My app is in c / c++ and compiled with gcc, the only external Linux code I use is X Windows and CUPS. ...

Is there a standard encoding for NEEDED entries in ELF?

I'm trying to make some of my code a bit more friendly to non-pure-ascii systems and was wondering if there was a particular character encoding used for NEEDED entries in ELF binaries, or is it rather unstandard and based on the creating system's filesystem encoding (or even just directly the bytes that were passed to whatever created th...

How can I read binary data from wfstream?

Hello world! I have a slight problem reading data from file. I want to be able to read wstring's, aswell as a chunk of raw data of arbitrary size (size is in bytes). std::wfstream stream(file.c_str()); std::wstring comType; stream >> comType; int comSize; stream >> comSize; char *comData = new char[comSize]; memset(comData, 0, comS...

How do I compile to x64 binary from a x86 platform running VS2008 Pro?

I am trying to compile my apps (which uses 3rd party libraries) for the x64 platform. However selecting x64 from Build Configuration Manager from my VS2008 Pro doesn't seem to work. The binary does get created but my client wasn't able to get it to run on x64. I wonder if the 3rd party DLLs could be the cause. Anyone has any idea on th...

How to append binary values in VBScript

If I have two variables containing binary values, how do I append them together as one binary value? For example, if I used WMI to read the registry of two REG_BINARY value, I then want to be able to concatenate the values. VBScript complains of a type mismatch when you try to join with the '&' operator. ...

Base-2 (Binary) Representation Using Python

Building on How Do You Express Binary Literals in Python, I was thinking about sensible, intuitive ways to do that Programming 101 chestnut of displaying integers in base-2 form. This is the best I came up with, but I'd like to replace it with a better algorithm, or at least one that should have screaming-fast performance. def num_bi...