instruction stringlengths 0 30k ⌀ |
|---|
While this question has already been answered, I think there are some other points to mention:
- If you want lazy-instantiation of the singleton while using a pointer to a dynamically allocated instance, you'll have to make sure you clean it up at the right point.
- You could use Matt's solution, but you'd need to use a proper mutex/critical section for locking, and by checking "pObj == NULL" both before and after the lock. Of course, **pObj** would also have to be *static* ;)
.
A mutex would be unnecessarily heavy in this case, you'd be better going with a critical section.
But as already stated, you can't guarantee threadsafe lazy-initialisation without using at least one synchronisation primitive.
Edit: Yup Derek, you're right. My bad. :) |
Mark's answer is the simpler, more elegant solution. Why build a complex program with inter-thread communication if it's not necessary? Spawn 4 threads. Each thread calculates size-of-file/4 to determine it's start point (and stop point). Each thread can then work entirely independently.
The *only* reason to add a special thread to handle reading is if you expect some lines to take a very long time to process *and* you expect that these lines are clustered in a single part of the file. Adding inter-thread communication when you don't need it is a *very bad idea*. You greatly increase the chance of introducing an unexpected bottleneck and/or synchronization bugs. |
> You could use Matt's solution, but you'd need to use a proper mutex/critical section for locking, and by checking "pObj == NULL" both before and after the lock. Of course, pObj would also have to be static ;) . A mutex would be unnecessarily heavy in this case, you'd be better going with a critical section.
OJ, that doesn't work. As Chris pointed out, that's double-check locking, which is not guaranteed to work in the current C++ standard. See: [C++ and the Perils of Double-Checked Locking](http://www.ddj.com/184405726) |
When you say that you have no data, how are you even using asp.net or c#. What functionality does that provide you over plain HTML? Also, if you do plan on caching, it's probably best to cache to a file, and then when a request is made, stream out the file. The OS will take care of keeping the file in memory so that you won't have to read it off the disk all the time. |
You may want to build in a cache updating mechanism if you want to do this, just to make sure you can clear the cache if you need to do a code update. Other than that, there aren't any problems that I can think of. |
PHP Variables passed by value or by reference? |
|php|variables|byreference|byvalue| |
I had a Java developer new to PHP ask me this question the other day, so I thought I'd document the answer here.
Question: are PHP variables passed by value or by reference? |
|php|variables|by-reference|by-value| |
List<BusinessObject> or BusinessObjectCollection? |
|c#|collections|generics| |
Prior to C# generics, everyone would code collections for their business objects by creating a collection base that implemented IEnumerable
IE:
public class CollectionBase : IEnumerable
and then would derive their Business Object collections from that.
public class BusinessObjectCollection : CollectionBase
Now with the generic list class, does anyone just use that instead? I've found that I use a compromise of the two techniques:
public class BusinessObjectCollection : List<BusinessObject>
I do this because I like to have strongly typed names instead of just passing Lists around.
What is **your** approach? |
|c#|.net|generics|collections|classdesign| |
|c#|.net|generics|collections|class-design| |
Should DB layer members be static or instance? |
|classdesign| |
I've seen projects where the classes in the DB layer have just static functions in them and other projects where those classes need to be instantiated to get access to the member functions.
Which is "better" and why? |
|classdesign|database| |
|database|orm|classdesign| |
|database|orm|class-design| |
What Content Management does your workplace use? |
|oracle|contentmanagement|ucm| |
I noticed a lack of Content Management tags all up in the pool.<br>
So here is a quick and dirty survey to get things started.
1) What UCM solution is your company using? <br>
2) How big is your company?<br>
3) Are you happy with the implementation?<br>
<br><br>
ME:<br>
1) The company I work for uses Oracle ECM (formerly Stellent UCM).<br>
2) We have somewhere over 10,000 employees across Australia, New Zealand and Indonesia.<br>
3) It works! Having worked with the system for a while now. I can see where the initial implementation went wrong. Its 3 years later and it is *Rewrite Time!* (Three year itch?)
|
I've done this in the past.
Either do it manually, (build a nice gui that helps the user do it quickly) or have it automated and check against a recent address database (you have to buy that) and manually handle errors.
Manual handling will take about 10 seconds each, meaning you can do 3600/10 = 360 per hour, so 4000 should take you approximately 11-12 hours. This will give you a high rate of accuracy.
For automation, you _need_ a recent US address database, and tweak your rules against that. I suggest not going fancy on the regex (hard to maintain long-term, so many exceptions). Go for 90% match against the database, do the rest manually.
Do get a copy of Postal Addressing Standards (USPS) at [http://pe.usps.gov/cpim/ftp/pubs/Pub28/pub28.pdf][1] and notice it is 130+ pages long. Regexes to implement that would be nuts.
[1]: http://pe.usps.gov/cpim/ftp/pubs/Pub28/pub28.pdf
For international addresses, all bets are off. US-based workers would not be able to validate.
Alternatively, use a data service. I have, however, no recommendations.
Furthermore: when you do send out the stuff in the mail (that's what it's for, right?) make sure you put "address correction requested" on the envelope (in the right place) and _update_ the database. (We made a simple gui for the front desk person to do that; the person who actually sorts through the mail)
Finally, when you have scrubbed data, look for duplicates.
|
Well you can extend what has been done [here](http://diditwith.net/PermaLink,guid,aacdb8ae-7baa-4423-a953-c18c1c7940ab.aspx) to make delegates safer to use (no memory leaks) |
How do you express binary literals in python? |
|python|syntax|binary| |
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?** |
|python|syntax|binary|literals| |
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?**
---
*Edit*
*It appears as though there is **no** way to express binary in python as a literal. The only way to do it is with the <code>int()</code> function demonstrated below by lbrandy.* |
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?**
---
*Edit*
*There **is no way** to express it as a literal, but lbrandy's method is the closest thing to working.* |
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: there is no way to express binary literals.
* Python 2.6 beta and above: You can do like so: `0b1100111` or `0B1100111` |
I would store the referring URL using the [ViewState][1]. Storing this outside the scope of the page (i.e. in the Session state or cookie) may cause problems if more than one browser window is open.
The example below validates that the page was called internally (i.e. not requested directly) and bounces back to the referring page after the user submits their response.
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.UrlReferrer == null)
{
//Handle the case where the page is requested directly
throw new Exception("This page has been called without a referring page");
}
if (!IsPostBack)
{
ReturnUrl = Request.UrlReferrer.PathAndQuery;
}
}
public string ReturnUrl
{
get { return ViewState["returnUrl"].ToString(); }
set { ViewState["returnUrl"] = value; }
}
protected void btn_Click(object sender, EventArgs e)
{
//Do what you need to do to save the page
//...
//Go back to calling page
Response.Redirect(ReturnUrl, true);
}
}
[1]: http://msdn.microsoft.com/en-us/library/system.web.ui.control.viewstate.aspx |
Native Delphi enumerations are already type-safe. Java enumerations were an innovation for that language, because before it didn't have enumerations at all. However, perhaps you mean a different feature - enumeration values prefixed by their type name.
Upcoming Delphi 2009, and the last version of the Delphi for .NET product, support a new directive called scoped enums. It looks like this:
{$APPTYPE CONSOLE}
{$SCOPEDENUMS ON}
type
TFoo = (One, Two, Three);
{$SCOPEDENUMS OFF}
var
x: TFoo;
begin
x := TFoo.One;
if not (x in [TFoo.Two, TFoo.Three]) then
Writeln('OK');
end.
|
I agree with MartinNH.
Many of these problems root from the fact that you develop while logged in as an administrator in Visual Studio (so the program has all the permissions for execution set properly) but you deploy as a user with lesser privileges.
Try setting the priveleges of the task scheduler user higher. |
> It works. I have no idea why, but it does.
For future reference:
It works because Apache processes alias directives in order, and uses the first match. It was always hitting `Alias /`, which will match anything, before `WSGIScriptAlias`.
From the [`mod_alias` documentation](http://httpd.apache.org/docs/2.2/mod/mod_alias.html):
> First, all Redirects are processed before Aliases are processed, and therefore a request that matches a `Redirect` or `RedirectMatch` will never have Aliases applied. Second, the Aliases and Redirects are processed in the order they appear in the configuration files, with the first match taking precedence. |
You do not have to register a dialog box.
Dialog boxes are predefined so (as you noted) there is no reference to a window class when you create a dialog. If you want more control of a dialog (like you get when you create your own window class) you would subclass the dialog which is a method by which you replace the dialogs window procedure with your own. When your procedure is called you modify the behavior (example: how the dialog's background is drawn) of the dialog window; you then might or might not call the original window procedure depending upon what you're trying to do. |
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 binary using `int('01010101111',2)` but not with a literal.
* Python 2.5 and earlier: there is no way to express binary literals.
* Python 2.6 beta and above: You can do like so: `0b1100111` or `0B1100111` .
* Python 2.6 beta and above: will also allow `0o27` or `0O27` (second character is the letter O) to represent an octal.
* Python 3.0 beta and above: will no longer allow the older `027` syntax for octals. |
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 binary using `int('01010101111',2)` but not with a literal.
* Python 2.5 and earlier: there is *no way* to express binary literals.
* Python 2.6 beta: You can do like so: `0b1100111` or `0B1100111` .
* Python 2.6 beta: will also allow `0o27` or `0O27` (second character is the letter O) to represent an octal.
* Python 3.0 beta: Same as 2.6, but will no longer allow the older `027` syntax for octals. |
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?**
TESTING ROLLBACK
---
***Summary of Answers***
* Python 2.5 and earlier: can express binary using `int('01010101111',2)` but not with a literal.
* Python 2.5 and earlier: there is *no way* to express binary literals.
* Python 2.6 beta: You can do like so: `0b1100111` or `0B1100111` .
* Python 2.6 beta: will also allow `0o27` or `0O27` (second character is the letter O) to represent an octal.
* Python 3.0 beta: Same as 2.6, but will no longer allow the older `027` syntax for octals. |
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 binary using `int('01010101111',2)` but not with a literal.
* Python 2.5 and earlier: there is *no way* to express binary literals.
* Python 2.6 beta: You can do like so: `0b1100111` or `0B1100111` .
* Python 2.6 beta: will also allow `0o27` or `0O27` (second character is the letter O) to represent an octal.
* Python 3.0 beta: Same as 2.6, but will no longer allow the older `027` syntax for octals. |
Image size for BannerBitmap property in Windows Installer |
|windows-installer| |
> You could use Matt's solution, but you'd need to use a proper mutex/critical section for locking, and by checking "pObj == NULL" both before and after the lock. Of course, pObj would also have to be static ;) . A mutex would be unnecessarily heavy in this case, you'd be better going with a critical section.
OJ, that doesn't work. As Chris pointed out, that's double-check locking, which is not guaranteed to work in the current C++ standard. See: [C++ and the Perils of Double-Checked Locking](http://www.ddj.com/184405726)
Edit: No problem, OJ. It's really nice in languages where it does work. I expect it will work in C++0x (though I'm not certain), because it's such a convenient idiom. |
I believe [Zenity](http://live.gnome.org/Zenity) will do what you want. It's specifically designed for displaying GTK dialogs from the command line, and it's available as an [Ubuntu package](http://packages.ubuntu.com/hardy/zenity). |
The architects of the DSL Tools team wrote a book, [Domain-Specific Development with Visual Studio DSL Tools.][1] The book's [website][2] has some other links and resources.
[1]: http://tinyurl.com/573bok "Domain Specific Development with Visual Studio DSL Tools."
[2]: http://www.domainspecificdevelopment.com/ |
Domain Specific Language resources |
|ms|dsl|t4|vsx| |
I was just listening to some older .Net Rocks! episodes, and I found #329 on DSLs to be interesting. My problem is that I can't find any good online resources for people trying to learn this technology. I get the basics of the creating new designers, but the MS docs on the T4 engine used by the DSL tools and then how to integrate the templates with the DSL models are lacking.
Does anyone know of some good introductory resources for the MS DSL tools?
Thanks. |
|dsl|t4|vsx| |
|dsl|vsx|t4| |
I was just listening to some older .Net Rocks! episodes, and I [found #329 on DSLs](http://www.microsoft.com/downloads/details.aspx?FamilyID=D91887EA-5128-4BB1-B861-1DC1F9564941&displaylang=en) to be interesting. My problem is that I can't find any good online resources for people trying to learn this technology. I get the basics of the creating new designers, but the MS docs on the T4 engine used by the DSL tools and then how to integrate the templates with the DSL models are lacking.
Does anyone know of some good introductory resources for the MS DSL tools?
Thanks. |
Is the PC likely to have Acrobat installed? I think Acrobat installs a shell extension so previews of the first page of a PDF document appear in Windows Explorer's thumbnail view. You can get thumbnails yourself via the IExtractImage COM API, which you'll need to wrap. [VBAccelerator has an example in C#][1] that you could port to Python.
[1]: http://www.vbaccelerator.com/home/net/code/libraries/shell_projects/Thumbnail_Extraction/article.asp |
In C# what is the difference between String and string |
You do not have to register a dialog box.
Dialog boxes are predefined so (as you noted) there is no reference to a window class when you create a dialog. If you want more control of a dialog (like you get when you create your own window class) you would subclass the dialog which is a method by which you replace the dialogs window procedure with your own. When your procedure is called you modify the behavior of the dialog window; you then might or might not call the original window procedure depending upon what you're trying to do. |
@[Staale](http://stackoverflow.com/questions/37041/exposing-a-remote-interface-or-object-model#37175)
It is certainly possibly, but as you note, that would make it blocking (at home for something like 10 seconds due to sleeping disks), meaning I can't use it to update the UI directly.
I could use the iterator to create a copy of the result in a separate thread and then send that to the UI, but while the iterator solution by itself is rather elegant, it won't fit in very well. In the end, something implementing [IStructuredContentProvider](http://help.eclipse.org/stable/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/jface/viewers/IStructuredContentProvider.html) needs to return an array of all the objects in order to display it in a [TableViewer](http://help.eclipse.org/stable/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/jface/viewers/TableViewer.html), so if I can get away with getting something like that out of a callback... :)
I'll give it some more thought. I might just be able to work out something. It does give the code a nice look. |
We use CruiseControl.NET with both NAnt and MsBuild for our build server. We configured it so that it would have builds everytime we check code in, as well as nightly builds. |
How do you remove a specific revision in the git history? |
|git| |
Suppose you git history looks like this:
1
2
3
4
5
Where 1-5 are separate revisions. You need to remove 3 while still keeping 1, 2, 4 and 5. How to do it?
Is there an efficient method when there are hundreds of revisions after the one to be deleted? |
Suppose you git history looks like this:
1
2
3
4
5
Where 1-5 are separate revisions. You need to remove 3 while still keeping 1, 2, 4 and 5. How to do it?
Is there an efficient method when there are hundreds of revisions after the one to be deleted?
[edit] @shrughes: Suppose I wanted to do either. Do you have any better suggestions to make other than "read the documentation"? Obviously I already did that. Without an advanced degree in neuroscience and possibly a direct feed into Linus brain, it is probably impossible to get any useful information out of it. |
var ipuint32 = BitConvertor.ToUInt32(IPAddress.Parse"some.ip.address.ipv4").GetAddressBytes());`
|
> <i>These users do want to be distracted when a new message arrives.</i>
It sounds like you're writing an app for an internal company project.
You might want to investigate writing a small windows app in .net which adds a notify icon and can then do fancy popups or balloon popups or whatever, when they get new messages.
This isn't overly hard and I'm sure if you ask SO 'how do I show a tray icon' and 'how do I do pop up notifications' you'll get some great answers :-)
For the record, I'm pretty sure that (other than using an alert/prompt dialog box) you can't flash the taskbar in JS, as this is heavily windows specific, and JS really doesn't work like that. You may be able to use some IE-specific windows activex controls, but then you inflict IE upon your poor users. Don't do that :-( |
If you are looking for a truly language agnostic solution then you will be sorely disappointed in my opinion because you'll be stuck with a for loop and some conditionals. However if you opened it up to functional languages or functional language features (I'm looking at you LINQ) then my colleagues here can fill this page with elegant examples in Ruby, Lisp, Erlang, and others. |
Looks like a web service is going to be the answer for me. On a production box I'd rather not have to go through compiling and maintaining my own special installation of PHP since ODBC support needs to be compiled in, according to the PHP documentation.
Thanks for the suggestion! |
If you expect infrequent collisions, [Optimistic Concurrency][1] is probably your best bet.
Scott Mitchell wrote a comprehensive tutorial on implementing that pattern: [http://www.asp.net/Learn/data-access/tutorial-21-cs.aspx][2]
[1]: http://msdn.microsoft.com/en-us/library/aa0416cz.aspx
[2]: http://www.asp.net/Learn/data-access/tutorial-21-cs.aspx |
I'm guessing that because you want to set it for all users, that you're on some kind of shared computer, which is probably running under a domain?
**HERE BE DRAGONS**
Let's say Joe and Jane regularly log onto the computer, then they will each have 'registries'.
You'll then install your app, which will employ giant hacks and disgusting things to set items under HKCU for them.
THEN, bob will come along and log on (he, and 500 other people have accounts in the domain and so can do this). He's never used this computer before, so he has no registry. The first time he logs in, windows creates him one, but he won't have your setting.
Your app then falls over or behaves incorrectly, and bob complains loudly about those crappy products from raynixon incorporated.
The correct answer is to just have some default settings in your app, which can write them to the registry if it doesn't find them. It's general good practice that your app should never depend on the registry, and should create things as needed, for any registry entry, not just HKCU, anyway |
I'm guessing that because you want to set it for all users, that you're on some kind of shared computer, which is probably running under a domain?
**HERE BE DRAGONS**
Let's say Joe and Jane regularly log onto the computer, then they will each have 'registries'.
You'll then install your app, and the installer will employ giant hacks and disgusting things to set items under HKCU for them.
THEN, bob will come along and log on (he, and 500 other people have accounts in the domain and so can do this). He's never used this computer before, so he has no registry. The first time he logs in, windows creates him one, but he won't have your setting.
Your app then falls over or behaves incorrectly, and bob complains loudly about those crappy products from raynixon incorporated.
The correct answer is to just have some default settings in your app, which can write them to the registry if it doesn't find them. It's general good practice that your app should never depend on the registry, and should create things as needed, for any registry entry, not just HKCU, anyway |
Efficiently get sorted sums of a sorted list |
|algorithm|language-agnostic| |
Are people still writing [SOAP services][1] or is it a technology that has passed its [architectural shelf life][2]? Are people returning to binary formats?
[1]: http://zeroc.com/blogs/michi/
[2]: http://www.addsimplicity.com/ |
Oddball examples? What about using the gamma function!
![gamma n equals factorial n minus one][1]
## OCaml: Using Gamma ##
let rec gamma z =
let pi = 4.0 *. atan 1.0 in
if z < 0.5 then
pi /. ((sin (pi*.z)) *. (gamma (1.0 -. z)))
else
let consts = [| 0.99999999999980993; 676.5203681218851; -1259.1392167224028;
771.32342877765313; -176.61502916214059; 12.507343278686905;
-0.13857109526572012; 9.9843695780195716e-6; 1.5056327351493116e-7;
|]
in
let z = z -. 1.0 in
let results = Array.fold_right
(Array.mapi
(fun i x -> if i = 0 then x else x /. (z+.(float i)))
consts)
0.0
in
let x = z +. (float (Array.length consts)) -. 1.5 in
let final = (sqrt (2.0*.pi)) *.
(x ** (z+.0.5)) *.
(exp (-.x)) *. result
in
final
let factorial_gamma n = int_of_float (gamma (float (n+1)))
[1]: http://www.codecogs.com/eq.latex?\Gamma%20n%20=%20(n-1)! |
Oddball examples? What about using the gamma function!
![gamma_n_equals_factorial_n_minus_one][1]
## OCaml: Using Gamma ##
let rec gamma z =
let pi = 4.0 *. atan 1.0 in
if z < 0.5 then
pi /. ((sin (pi*.z)) *. (gamma (1.0 -. z)))
else
let consts = [| 0.99999999999980993; 676.5203681218851; -1259.1392167224028;
771.32342877765313; -176.61502916214059; 12.507343278686905;
-0.13857109526572012; 9.9843695780195716e-6; 1.5056327351493116e-7;
|]
in
let z = z -. 1.0 in
let results = Array.fold_right
(fun x y -> x +. y)
(Array.mapi
(fun i x -> if i = 0 then x else x /. (z+.(float i)))
consts
)
0.0
in
let x = z +. (float (Array.length consts)) -. 1.5 in
let final = (sqrt (2.0*.pi)) *.
(x ** (z+.0.5)) *.
(exp (-.x)) *. result
in
final
let factorial_gamma n = int_of_float (gamma (float (n+1)))
[1]: http://www.codecogs.com/eq.latex?%5CGamma%20n%20%3D%20(n-1)! |
Oddball examples? What about using the gamma function! Since, `Gamma n = (n-1)!`.
## OCaml: Using Gamma ##
let rec gamma z =
let pi = 4.0 *. atan 1.0 in
if z < 0.5 then
pi /. ((sin (pi*.z)) *. (gamma (1.0 -. z)))
else
let consts = [| 0.99999999999980993; 676.5203681218851; -1259.1392167224028;
771.32342877765313; -176.61502916214059; 12.507343278686905;
-0.13857109526572012; 9.9843695780195716e-6; 1.5056327351493116e-7;
|]
in
let z = z -. 1.0 in
let results = Array.fold_right
(fun x y -> x +. y)
(Array.mapi
(fun i x -> if i = 0 then x else x /. (z+.(float i)))
consts
)
0.0
in
let x = z +. (float (Array.length consts)) -. 1.5 in
let final = (sqrt (2.0*.pi)) *.
(x ** (z+.0.5)) *.
(exp (-.x)) *. result
in
final
let factorial_gamma n = int_of_float (gamma (float (n+1))) |
I'm working on a quick setup program in VS2005 and wanted to change the banner bitmap. Anyone know off-hand what the ideal (or req'ed) dimensions are for the new banner image? Thanks. |
Damn if I didn't just find it on MSDN. The answer is:
http://msdn.microsoft.com/en-us/library/3kbk77sf(VS.80).aspx
"For best results, you should use a bitmap with dimensions of 500 pixels wide by 70 pixels high." |
You can of course use SIFR http://www.mikeindustries.com/blog/sifr/
This degrades gracefully in browsers that do not support it and is accessible.
It's not really suitable for using on loads of text but for headings and highlight text it's perfect.
Of course this is a work around to an intrinsic limitation of browsers and the web at this time, but when was this not the case for the majority of web technologies and techniques. |
If it's human entered data, then you'll spend too much time trying to code around the exceptions.
Try:
1. Regular expression to extract the zip code
2. Zip code lookup (via appropriate government DB) to get the correct address
3. Get an intern to manually verify the new data matches the old
|
I think another "overlooked" feature of java is the JVM itself. It is probably the best VM available. And it supports lots of interesting and useful languages (Jython, JRuby, Scala, Groovy). All those languages can easily and seamlessly cooperate.
If you design a new language (like in the scala-case) you immediately have all the existing libraries available and your language is therefore "useful" from the very beginning.
All those languages make use of the HotSpot optimizations. The VM is very well monitor and debuggable. |
> This won't solve your problem, but if
> you only needed lat/long data for
> these addresses, the Google Maps API
> will parse non-formatted addresses
> pretty well.
Good suggestion, alternatively you can execute a CURL request for each address to Google Maps and it will return the properly formatted address. From that, you can regex to your heart's content. |
This is a timely thread; we switched to Arial because Calibri is WAY small compared to all the other fallback fonts! It pained me greatly to switch to (gag) Arial because it's a crap copy of Helvetica:
http://www.ms-studio.com/articles.html
The sizing difficulties (too big if you go with a "c" font as your standard; too small if you go with something normal) are described in detail here:
http://neosmart.net/blog/2006/css-vistas-new-fonts/
I will miss Calibri's beautiful hand-tuned RGB aliasing a lot, but it was just impossible to deliver a good experience for most users without demanding Calibri be installed. It's reasonably common, as it comes with Office 2007 (Win/Mac) and of course Vista.. but it's far from universal, so it's a little irresponsible to rely heavily on it for a global web audience. |
I'd implement some sort of custom "text serialization" and transmit plain text. As you say, you can rebuild the information doing the reversed process. |
I use Emacs on Windows.
Installing and configuring it to work with rails is a pain though. |
The alternative to SOAP is not binary formats.
I think you're seeing a surge in the desire to leave the complexities of WS-* behind in favor of REST and JSON, because they're much simpler to use and don't require frameworks to be used successfully. The problems that WS-* ostensibly tries to solve aren't problems for most users, but they have to pay for the complexity any way. |
OK this is an attempt to finish the proof of correctness. By analogy to the Reverse-delete algorithm, we know that enough edges will be removed. What remains is to show that there will not be to many edges removed.
Removing to many edges can be described as removing all the edges between the side of a binary partition of the graph nodes. However only edges in a cycle are ever removed, therefor, for all edge between partitions to be removed, there needs to be a return path to complete the cycle. If we only consider edges between the partitions then the algorithm can at most remove the larger of each pair of edges, this can never remove the smallest bridging edge. Therefor for any arbitrary binary partitioning, the algorithm can't sever all links between the side.
What remains is to show that this extends to >2 way partitions. |
In the distant past (before I started working for CodeGear) I gave up on the odd Delphi-ized IDL language that the IDE presented, and wrote my own IDL and compiled it using MS midl. This largely worked; the only catch, IIRC, was making sure dispids (id attribute) were correct on automation interfaces (dispinterfaces) for property getters & setters - there was some invariant that tlibimp expected but midl didn't guarantee.
However, now that Delphi 2009 uses a safe subset of midl syntax, and includes a compiler for this midl in the box and integrated into the IDE, these problems should be a thing of the past. |
Why would complete normalization "be a mess"? this is exactly the kind of thing that normalization makes less messy. |
Why would complete normalization "be a mess"? This is exactly the kind of thing that normalization makes less messy. |
I have about 50 web sites running perl/apache/mysql and about 10 running C#/ASP.Net/SQL Server (Lite) and other (large) applications running on SQL Server (Heavy). I never have problems with SQL Server - it just works. I often have problems with MySQL.
My advice would be to go for the SQL Server based option even if you had to pay for it. |
Looks like a basic parsing task. Generally the approach you are going to want to take is to create a recursive function with the following general algorithm
base case (input doesn't begin with '[') return the input
recursive case:
split the input on ',' (you will need to find commas only at this level)
for each sub string call this method again with the sub string
return array containing the results from this recursive method
The only slighlty tricky part here is splitting the input on a single ','. You could write a separate function for this that would scan through the string and keep a count of the openbrackets - closedbrakets seen so far. Then only split on commas when the count is equal to zero.
|
Cool, thank you Mark, I had forgotten that CreateFile opens things too. I was looking at the volume management API and not seeing how to open things. |
The features available to use are dependent on your processor. Apple uses the same Intel stuff as everybody else. So yes, generic x86 should be fine (assuming you're not on a PPC :D).
As far as tools go, I think your best bet is a good text editor that 'understands' assembly. |
I recommend a sieve, either the [Sieve of Eratosthenes][2] or the [Sieve of Atkin.][1]
The sieve or Eratosthenes is probably the most intuitive method of finding a list of primes. Basically you:
1. write down a list of numbers from 2 to whatever limit you want, let's say 1000.
2. Take the first number that isn't crossed off (for the first iteration this is 2) and cross off all multiples of that number from the list.
3. Repeat step 2 until you reach the end of the list. All the numbers that aren't crossed off are prime.
Obviously there are quite a few optimizations that can be done to make this algorithm work faster, but this is the basic idea.
The sieve of Atkin uses a similiar approach, but unfortunately I don't know enough about it to explain it to you. But I do know that the algorithm I linked takes 8 seconds to figure out all the primes up to 1000000000 on an ancient Pentium II-350
[1]: http://cr.yp.to/primegen.html
[2]: http://primes.utm.edu/links/programs/sieves/Eratosthenes/C_source_code/ |
I recommend a sieve, either the [Sieve of Eratosthenes](http://primes.utm.edu/links/programs/sieves/Eratosthenes/C_source_code/) or the [Sieve of Atkin.](http://cr.yp.to/primegen.html)
The sieve or Eratosthenes is probably the most intuitive method of finding a list of primes. Basically you:
1. write down a list of numbers from 2 to whatever limit you want, let's say 1000.
2. Take the first number that isn't crossed off (for the first iteration this is 2) and cross off all multiples of that number from the list.
3. Repeat step 2 until you reach the end of the list. All the numbers that aren't crossed off are prime.
Obviously there are quite a few optimizations that can be done to make this algorithm work faster, but this is the basic idea.
The sieve of Atkin uses a similiar approach, but unfortunately I don't know enough about it to explain it to you. But I do know that the algorithm I linked takes 8 seconds to figure out all the primes up to 1000000000 on an ancient Pentium II-350
Sieve of Eratosthenes Source Code: <http://primes.utm.edu/links/programs/sieves/Eratosthenes/C_source_code/>
Sieve of Atkin Source Code: <http://cr.yp.to/primegen.html> |
I recommend a sieve, either the [Sieve of Eratosthenes](http://primes.utm.edu/links/programs/sieves/Eratosthenes/C_source_code/) or the [Sieve of Atkin.](http://cr.yp.to/primegen.html)
The sieve or Eratosthenes is probably the most intuitive method of finding a list of primes. Basically you:
1. Write down a list of numbers from 2 to whatever limit you want, let's say 1000.
2. Take the first number that isn't crossed off (for the first iteration this is 2) and cross off all multiples of that number from the list.
3. Repeat step 2 until you reach the end of the list. All the numbers that aren't crossed off are prime.
Obviously there are quite a few optimizations that can be done to make this algorithm work faster, but this is the basic idea.
The sieve of Atkin uses a similiar approach, but unfortunately I don't know enough about it to explain it to you. But I do know that the algorithm I linked takes 8 seconds to figure out all the primes up to 1000000000 on an ancient Pentium II-350
Sieve of Eratosthenes Source Code: <http://primes.utm.edu/links/programs/sieves/Eratosthenes/C_source_code/>
Sieve of Atkin Source Code: <http://cr.yp.to/primegen.html> |
By default, tnsnames.ora is located in the $ORACLE_HOME/network/admin directory on UNIX operating systems and in the ORACLE_HOME\network\admin directory on Windows operating systems. tnsnames.ora can also be stored the following locations:
The directory specified by the TNS_ADMIN environment variable (or registry value)
On UNIX operating systems, the global configuration directory. For example, on the Solaris Operating System, this directory is /var/opt/oracle
If you have multiple ORACLE_HOMES, be aware of which one you are using, as the location of the tnsnames.ora file can vary from one ORACLE_HOME to the next.
For the person who mentioned the TWO_TASK environment variable, that is used to set a default database service name to connect to (which could be a database on another server). The service name you set TWO_TASK to is then looked up in the tnsnames.ora file when you connect.
|
IE6 cannot handle PNG's correctly, be warned. |
Script from the FTP server, and just call the stored proc. |
My docs would probably best be handled by accessing:
System.getProperty("user.home");
Look up the docs on [System.getProperty][1].
[1]: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html |
I suggest http://www.canonware.com/Parsing/, since it is pure python and you don't need to learn a grammar, but it isn't widely used, and has comparatively little documentation. The heavyweight is ANTLR and PyParsing. ANTLR can generate java and C++ parsers too, and AST walkers but you will have to learn what amounts to a new language. |