language-agnostic

Why do garbage collectors freeze execution?

I was thinking about garbage collection on the way home, and I began wondering, why does the garbage collector totally freeze execution of a program? Personally I would have designed it to block any threads which try to allocate a new object, but threads which were running would be left alone. I can't imagine any situation where this wou...

Regex help: capture an entire line if it starts with a 1. or 2. ...

I'm awful at regexes, but would love some help defining a rule that would take this text: Il Cuccio, via Ronchi 43/b, 14047 Mombercelli, Asti. Tel: 380 7277050 Fax: 0141 959282 E-mail: [email protected] www.ilcuccio.it Accommodation in communal room or tent. French and English spoken. Contact: Cristina Belotti. Apicoltura Leida Bar...

Should References in Object-Oriented Programming Languages be Non-Nullable by Default?

Null pointers have been described as the "billion dollar mistake". Some languages have reference types which can't be assigned the null value. I wonder if in designing a new object-oriented language whether the default behavior should be for references to prevent being assigned null. A special version of the could then be used to overr...

RSS items order, does it matter?

Hi, I created RSS feed with Java Rome lib. The project is near the end. But I found some strange behavior of RSS clients. I think it's more RSS clients problem, but i wont to make sure. Rome holds items in List, so latest items are in the end of the list. I opened my feed I rss clients (Firefox and RSS Bandit) and I found there are in ...

To change a language automatically, should you use the Keyboard Language or the Location value?

To change a language automatically, should you use the Keyboard Language or the Location value? ...

PHP: Make Site Unicode Compatible

Hello, How can i make my site unicode compatible to support more languages other than english. Thanks ...

Programmer Puzzle: Encoding a chess board state throughout a game.

Not strictly a question, more of a puzzle... Over the years, I've been involved in a few technical interviews of new employees. Other than asking the standard "do you know X technology" questions, I've also tried to get a feel for how they approach problems. Typically, I'd send them the question by email the day before the interview, an...

Code Golf - Tetris Fitting

Time for NP-Complete code golf! Given a rectangular board, and a set of tetrominoes, can the tetrominoes be fit into the board such that all pieces are used, no space is left over, and the pieces don't overlap? See Wikipedia if you've been living under a rock and don't know what Tetrominoes are - they're just the pieces from Tetris. Inp...

The right time to handle all exceptions

I've done a few projects so far, and i've noticed that every single one i've written entirely without any exception handling, then at the end I do a lot of tests and handle them all. is it right? i get thousands of exceptions while testing (which I fix right away) that if i've handled it i wouldn't see exactly where it is(when not usi...

Algorithm for a planning tool

I'm writing a small software application that needs to serve as a simple planning tool for a local school. The 'problem' it needs to solve is fairly basic. Namely, the teachers need to talk with the parents of all children. However, some children have, of course, brothers and sisters in different groups, so these talks need to be schedul...

Can this Roman Number to Integer converter code be shorter?

95 bytes currently in python I,V,X,L,C,D,M,R,r=1,5,10,50,100,500,1000,vars(),lambda x:reduce(lambda T,x:T+R[x]-T%R[x]*2,x,0) Here is the few test results, it should work for 1 to 3999 (assume input is valid char only) >>> r("I") 1 >>> r("MCXI") 1111 >>> r("MMCCXXII") 2222 >>> r("MMMCCCXXXIII") 3333 >>> r("MMMDCCCLXXXVIII") 3888 >>> r...

Code Golf: Diamond Blackjack

The challenge The shortest code by character count to output a best-case blackjack hand from the list of number-cards given. Input is a list of numbers from 1 to 10 (inclusive) separated by space. Output will be the best blackjack hand formed from that list of cards - the closest available combo to reach 21 by the sum of all card valu...

What's the most elegant 10-20 line function you've seen/written?

In the vein of What is the coolest thing you can do in <10 lines of simple code? Help me inspire beginners!, but for non-beginners: Tell us about some of your fast solutions to complex problems, or ingenious uses of little-known language features. Two examples I (and I'm sure everyone else) have seen are Quake's Inverse Square Root and ...

Maintaining network integrity in peer-to-peer network

I am looking for information on techniques, algorithms, etc. on how to maintain network integrity in a dynamic peer-to-peer network. Both practical implementations, academic papers and anything else in that category are welcome. Imagine a network that is solely peer-to-peer based where each node is only connect to x other nodes. Without...

Nice screencast tutorials for programming

hello, i am looking for a website that provides nice screencasts and tutorials about programming and webdesign. Currently i am using http://net.tutsplus.com. I think this one is pretty nice. Anyone know of any good alternatives? ...

Bug Hunting Strategies?

Let's say you have a bug that was found in functional testing of a fairly complex part of the software. It could stem from bad/unexpected data in the database, middle-tier code, or something in the front-end. Fine. We've all been there. You have unit tests to write & run, debugging/logging statements to insert, sql statements to write...

Is this method of checking a "gift code" secure?

I have a backend that generates gift codes, each with a certain number of uses. Give these to a blogger or whatever, and their readership can redeem the code for a promotional item. I'm working on the best way to check a codes validity without having collisions/dupes, or anything like that. I need to 1) validate the code 2) collect ship...

Transferring data between Remote Desktop and Client

Hello. I have an application that people use through Remote Desktop/Terminal Server. The application supports digital signatures. Well, the digital signature pad is on the client, but the program runs on the server. The signature pad also does not support being shared as a device through Remote Desktop(not listed with "Supported Plug And...

RESTful services and

Hello. I have just read Resource-Oriented Architecture: The Rest of REST. The reasoning behind content negotiation is compelling, but there's one thing I sometimes need, which seems to be impossible in this schema. Let assume I've got a web service to deliver some graphs. I want users to choose between different styles of these graphs ...

Runtime bugs due to case-sensitivity in (variable) names.

We recenly had a problem (http://stackoverflow.com/questions/1845817/antlr-cannot-launch-the-debugger-time-out-waiting-to-connect-to-the-remote-pars/1848755#1848755) where there was a runtime bug which could have been due to case-sensitivity in (variable) names and was OS-dependent. This was in ANTLR but I am wondering more generally whe...