PostgreSQL syntax check without running the query

I want to verify the syntax of files containing sql queries before they can be committed in my CVS project. In order to do that, I have a commitinfo script, but I have trouble finding out if the sql commands are valid. psql does not seem to have a dryrun mode, and constructing my own … Read more

How to extract top-level domain name (TLD) from URL

how would you extract the domain name from a URL, excluding any subdomains? My initial simplistic attempt was: ‘.’.join(urlparse.urlparse(url).netloc.split(‘.’)[-2:]) This works for, but not Is there a way to do this properly without using special knowledge about valid TLDs (Top Level Domains) or country codes (because they change). thanks Answer Here’s a great … Read more

How do I convert String to Number according to locale (opposite of .toLocaleString)?

If I do: var number = 3500; alert(number.toLocaleString(“hi-IN”)); I will get ३,५०० in Hindi. But how can I convert it back to 3500. I want something like: var str=’३,५००’; alert(str.toLocaleNumber(“en-US”)); So, that it can give 3500. Is it possible by javascript, jquery or any other free library? Answer I think you are looking for something … Read more

Examples of LL(1), LR(1), LR(0), LALR(1) grammars?

Is there a good resource online with a collection of grammars for some of the major parsing algorithms (LL(1), LR(1), LR(0), LALR(1))? I’ve found many individual grammars that fall into these families, but I know of no good resource where someone has written up a large set of example grammars. Does anyone know of such … Read more

How can I parse a String to BigDecimal? [duplicate]

This question already has answers here: Safe String to BigDecimal conversion (9 answers) Closed 8 years ago. I have this String: 10,692,467,440,017.120 (it’s an amount). I want to parse it to a BigDecimal. The problem is that I have tried both DecimalFormat and NumbeFormat in vain. Answer Try this // Create a DecimalFormat that fits … Read more