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... |
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... |
> 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, th... |
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 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 : Collect... |
|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 E... |
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, s... |
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 a... |
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*
*Ther... |
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 A... |
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 ... |
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 .NE... |
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/m... |
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 ... |
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 A... |
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 A... |
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
--... |
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 A... |
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, th... |
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 t... |
|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... |
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 c... |
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 ... |
@[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 ... |
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 yo... |
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 ... |
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 ... |
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... |
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 g... |
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 w... |
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.99... |
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.99... |
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; 67... |
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 ... |
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... |
> 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. ... |
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 standa... |
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... |
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 partit... |
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) f... |
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... |
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 le... |
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 ... |
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 ... |
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 ... |
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 va... |
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 t... |