on-internet

Are there known false positives issues with Valgrind?

Are there any known false positives with Valgrind? I get a 'Conditional jump or move depends on uninitialised value(s)' with the fmemopen function, writing in C and compiling with GCC. Can I be sure it's real? EDIT: Are there known issues that are not in the suppression files? Are there some things one can do in a program, that are not really errors but Valgrind will say they are? If there are known issues, a list would be nice.

Join the discussion →

News clustering

How does Google News and Techmeme cluster news items that are similar? Are there any well know algorithm that is used to achieve this? Appreciate your help. Thanks in advance.

Join the discussion →

Vendor Branches in Git

A Git project has within it a second project whose content is being worked on independently. Submodules cannot be used for the smaller, as even the subproject must be included when users attempt to clone or download the 'parent'. Subtree-merging cannot be used, as the subproject is being actively developed, and subtree merging makes it very difficult to merge those updates back into the original project. I have been informed that the solution is known in the SVN world as "Vendor Branches", and that it is so simply done in Git so as to not even need addressing. Half-baked tutorials abound on th

Join the discussion →

A minimal hash function for C?

I can't use boost:hash because I have to stick with C and can't use C++. But, I need to hash a large number (10K to 100k) of tokens strings (5 to 40 bytes length) so that search within those are fastest. MD5, SHA1 or any long hash function seems too heavy for a simple task, I am not doing cryptography. Plus there is the storage and computing cost. Therefore my question: What might be the simplest hash algorithm that will ensure collision prevention in most practical cases. How many bit to use for the hash value? I am developing for 32 bit systems. Does hash algorithm in Perl/Python use 32 bit

Join the discussion →

JS delete operator and garbage collection

I'm a bit confused with JavaScript's delete operator. Take the following piece of code: var obj = { helloText: "Hello World!" }; var foo = obj; delete obj; After this piece of code has been executed, obj is null, but foo still refers to an object exactly like obj. I'm guessing this object is the same object that foo pointed to. This confuses me, because I expected that writing delete obj deleted the object that obj was pointing to in memory—not just the variable obj. Is this because JavaScript's Garbage Collector is working on a retain/release basis, so that if I didn't have any other variable

Join the discussion →

Generating PDF files with JavaScript [closed]

I’m trying to convert XML data into PDF files from a web page and I was hoping I could do this entirely within JavaScript. I need to be able to draw text, images and simple shapes. I would love to be able to do this entirely in the browser.

Join the discussion →

low level programming: How does the OS start a new thread/process?

Whenever the bootloader loads the operating system there is presumably only ONE program flow active, right? This would mean, one processor holds the instruction pointer and executes the commands it founds at the position the EIP register points to. At which point and how does the system start to exploit more processes and/or threads (no userland threads, but cpu threads)?

Join the discussion →

Truncate file at front

A problem I was working on recently got me to wishing that I could lop off the front of a file. Kind of like a “truncate at front,” if you will. Truncating a file at the back end is a common operation–something we do without even thinking much about it. But lopping off the front of a file? Sounds ridiculous at first, but only because we’ve been trained to think that it’s impossible. But a lop operation could be useful in some situations. A simple example (certainly not the only or necessarily the best example) is a FIFO queue. You’re adding new items to the end of the file and pulling items ou

Join the discussion →

How does a CPU implement an instruction like MUL/MULT?

In different assembly languages MUL (x86) or MULT (mips) refer to multiplication. It is a black box to the programmer. I am interested in how actually a CPU accomplishes a multiplication regardless of the architecture. Let's say I am the CPU and I have two 16-bit values in my registers. So now I have to implement MUL using some of my bit-fiddling instructions (and, or, xor, not, shl, shr, etc). What shall I do?

Join the discussion →

How CPUs implement Instructions like MUL/MULT?

In different assembly languages MUL (x86)/MULT (mips) refer to multiplication. It is a black box for the programmer. I am interested in how actually a CPU accomplishes a multiplication regardless of the architecture. Lets say I have two 16-bit values in my registers and I am the cpu, so I have to implement MUL using the other bit-fiddling instructions I have (and,or,xor,not,shl,shr,etc). What shall I do?

Join the discussion →

grouping predicates in find

This part \( -name *txt -o -name *html \) confuses me in the code: find $HOME \( -name \*txt -o -name \*html \) -print0 | xargs -0 grep -li vpn Can someone explain the the brackets and -o? Is -o a command or a parameter? I know the brackets are escaped by \, but why are they for?

Join the discussion →

JavaScript equivalent to printf/String.Format

I'm looking for a good JavaScript equivalent of the C/PHP printf() or for C#/Java programmers, String.Format() (IFormatProvider for .NET). My basic requirement is a thousand separator format for numbers for now, but something that handles lots of combinations (including dates) would be good. I realize Microsoft's Ajax library provides a version of String.Format(), but we don't want the entire overhead of that framework.

Join the discussion →

SELECT DISTINCT in DataView's RowFilter

I'm trying to narrow down the rows that are in my DataView based on a relation with another table, and the RowFilter I'm using is as follows; dv = new DataView(myDS.myTable, "id IN (SELECT DISTINCT parentID FROM myOtherTable)", "name asc", DataViewRowState.CurrentRows); "myTable" and "myOther" table are related via myTable.ID and myOtherTable.parentID, and so the idea is that the DataView should only contain rows from "myTable" which have corresponding child rows in "myOtherTable". Unfortunately, I'm getting this error; Syntax error: Missing operand after 'DISTINCT' operator. The SQL is fine a

Join the discussion →

Where does 'Hello world' come from?

'hello, world' is usually the first example for any programming language. I've always wondered where this sentence came from and where was it first used. I've once been told that it was the first sentence ever to be displayed on a computer screen, but I've not been able to find any reference to this. So my question is: Where does the practice to use 'hello, world' as the first example for computer languages originate from? Where was it first used? Update Although the answers are quite interesting, I should have noted that I had read the Wikipedia article. It does answer the question about the

Join the discussion →

Set up a scheduled job?

I've been working on a web app using Django, and I'm curious if there is a way to schedule a job to run periodically. Basically I just want to run through the database and make some calculations/updates on an automatic, regular basis, but I can't seem to find any documentation on doing this. Does anyone know how to set this up? To clarify: I know I can set up a cron job to do this, but I'm curious if there is some feature in Django that provides this functionality. I'd like people to be able to deploy this app themselves without having to do much config (preferably zero). I've considered trigg

Join the discussion →

How are variables on the stack accessed?

Suppose we have these local variables: int a = 0; int b = 1; int c = 2; int d = 3; As far as I know, these will be allocated on the system stack, like this: | | | 3 | d | 2 | c | 1 | b |_0_| a Does this mean that in order to get the value of a, the values of d, c and b must first be popped out of the stack? If so, where do these values go? Does this mean that accessing more recently declared variables will be faster? Or am I missing something (which I suspect is the case), and the whole thing works in some other way?

Join the discussion →

What certificate(s) do I need for a website connected to an executable via WCF?

I'm developing software which will be deployed using clickonce (on the website foo.com), and which will then connect to my server using WCF with an encrypted transport So I need an SSL certificate which will: Identify my foo.com website has really being my website Identify the exe I deploy using clickonce as being genuine Identify my application server has really being my application server. I also want my SSL certificate to be signed by an authority known to the public (ie, firefox or windows won't ask the user to install the authority's certificate first !) What SSL certificate should I get?

Join the discussion →

Best tool for Code-Analyzement or Code-Review

Which code-Analyzer or Code-Review tool do you suggest , For Analyzing DotNet 2.0 & 3.5 code and getting All classes , Methods , Properties , Instances , Definition , Databases & and their relation to code , I want to get print-ready Information about codes & projects , ( here I dont mean a tool for testing the code & structures ) Is there anyone with similar specifications ?

Join the discussion →

"Absolute" string metric

I have a huge (but finite) set of natural language strings. I need a way to convert each string to a numeric value. For any given string the value must be the same every time. The more "different" two given strings are, the more different two corresponding values should be. The more "similar" they are, the less different values should be. I do not know yet what exact definition of difference between strings I need. No natural language parsing anyway. It should probably be something Levenstein-like (but Levenstein is relative and I need absolute metric). Lets start with something simple. Update

Join the discussion →

How to redirect to a different admin page in WordPress without "headers already sent" error?

I am writing a WordPress plugin. I want to perform a redirect (after creating database records from POST data) to another admin page. Neither header("Location: ...") nor wp_redirect() work; I receive: Warning: Cannot modify header information - headers already sent by ... How do I properly perform a redirect inside the WordPress admin?

Join the discussion →

How do I convert a git repository to mercurial?

I've been developing a java application using git as source code repository. I'd like to share the project with other java developers and hg seems to be most used by them. My question is how do I convert a git repository to hg? If I tried googling "convert git to hg" and every search hit is about converting from hg to git. I'm also using TortoiseHg.

Join the discussion →

How to generate XML file dynamically using PHP?

I have to generate a xml file dynamically at runtime. Please help me in generating the below XML file dynamically using PHP. <?xml version="1.0" encoding="UTF-8"?> <xml> <track> <path>song1.mp3</path> <title>Track 1 - Track Title</title> </track> <track> <path>song2.mp3</path> <title>Track 2 - Track Title</title> </track> <track> <path>song3.mp3</path> <title>Track 3 - Track Title</title> </track> <track> <path>song4.mp3</path> <title>Track 4 - Track Title</title> </track> <track> <path>song5.mp3</path> <title>Track 5 - Track Title</title> </track> <track> <path>song6.mp3</path> <title>Track 6

Join the discussion →

Safer Alternatives to the C Standard Library [closed]

The C standard library is notoriously poor when it comes to I/O safety. Many functions have buffer overflows (gets, scanf), or can clobber memory if not given proper arguments (scanf), and so on. Every once in a while, I come across an enterprising hacker who has written his own library that lacks these flaws. What are the best of these libraries you have seen? Have you used them in production code, and if so, which held up as more than hobby projects?

Join the discussion →

How do I efficiently determine if a polygon is convex, non-convex or complex?

From the man page for XFillPolygon: If shape is Complex, the path may self-intersect. Note that contiguous coincident points in the path are not treated as self-intersection. If shape is Convex, for every pair of points inside the polygon, the line segment connecting them does not intersect the path. If known by the client, specifying Convex can improve performance. If you specify Convex for a path that is not convex, the graphics results are undefined. If shape is Nonconvex, the path does not self-intersect, but the shape is not wholly convex. If known by the client, specifying Nonconvex inst

Join the discussion →
Older stories