instruction
stringlengths
0
30k
I have a script that checks responses from HTTP servers using the PEAR HTTP classes. However, I've recently found that the script fails on FTP servers (and probably anything that's not HTTP or HTTPS). I tried Google, but didn't see any scripts or code that returned the server status code from servers other than HTTP se...
|php|http|ftp|pear|server-response|
I have a script that checks responses from HTTP servers using the PEAR HTTP classes. However, I've recently found that the script fails on FTP servers (and probably anything that's not HTTP or HTTPS). I tried Google, but didn't see any scripts or code that returned the server status code from servers other than HTTP se...
|php|https|ftp|pear|server-response|
|php|http|ftp|pear|server-response|
Tools like [doxygen][1] (used with the graphviz options) can generate dependency graphs for include files... I don't know if they'd provide enough overview for what you're trying to do, but it could be worth trying. [1]: http://www.doxygen.org
When you state "back up source code", I hope you include in your meaning the backing up of your version control system too. Backing your current source code (to multiple places) is definitely critical, but backing up your history of changes as preseved by your VCS is paramount in my opinion. It may seem trivial espe...
If you use the runtime solution scaryjeff posted (I've done that a lot), be sure to force two garbage collections first if you want fairly accurate/consistent results, otherwise it's going to be all over the place.
If you looking specifically for in JVM memory: Runtime runtime = Runtime.getRuntime(); NumberFormat format = NumberFormat.getInstance(); StringBuilder sb = new StringBuilder(); long maxMemory = runtime.maxMemory(); long allocatedMemory = runtime.totalMemory(); ...
Better hope that this._data is not null if it's also a reference type. public bool Equals( MyClass obj ) { if (obj == null) { return false; } else { return (this._data != null && this._data.Equals( obj._data )) || obj._data == null; } ...
I'm guessing that watching the database for changes would be the best way to do it. That way, you could post any changes you saw happen in the FogBugz database through other Biztalk adapters. Please keep us updated with what you decide to do - I'd be interested to hear about it.
I've been using [Delicious][1] quite a bit over the past 2 years and it's been a great help. [1]: http://delicious.com
As far as I know that isn't possible Gustavo - it's up to each application to put its notifyicon in the systray, and ensure it's kept in the right state. You'll notice sometimes when explorer.exe crashes that certain icons don't reappear - this isn't because their process has crashed, simply that their application ...
It's not possible without modifying the compiler. This is because Handle is an abstract data type, not a typeclass.
For all those who refer to the question as the homework question: I have to say, most of you provided a homework answer. You don't do division/modulus to get the digits in production code, firstly because it's suboptimal (your CPU is designed for binary arithmetics not decimal) and secondly because it's unintuitiv...
Turbulent Intellect has the exactly right answer. I just want to advise that you can strip some of the nulls and exceptions out of the types you are using to make it friendlier to use them. public class IngredientBag { private Dictionary<string, string> _ingredients = new Diction...
One of the way I do it is by creating a 'Global' class with the constant values and do a static import in the classes that need access to the constant.
The way I do it is simply: - on every AddRef() record call-stack, - matching Release() removes it. This way at the end of the program I'm left with AddRefs() without maching Releases. No need to match pairs,
Two things to consider are: - You must be able to guarantee that the object is fully created and initialised before it is made available to other threads. - There must be some mechanism by which the main (GUI) thread detects that the data has been loaded and all is well. To be thread safe this will inevitably i...
I (as a developer, not designer, soo not designer) tried to start learning WPF through Blend. While I could get stuff working, looking back at what I produced makes me shiver. Now that I know my way around WPF pretty good, I still use Blend and Design every now and then, but my work is based in XAML (not designer vi...
You don't. standard C++ doesn't expose to concept of a directory. specifically it doesn't give any way to list all the files in a directory. A horrible hack would be to use system() calls and to parse the results. The most reasonable solution would be to use some kind of cross platform library such as QT or even pos...
Actually, I've resolved this by removing bean from session, so it has to be generated again when jsf page is called. Then I pick up get parameters from a request in constructor.
How to get parametrized Class instance
|java|generics|
Since generics were introduced, Class is parametrized, so that List.class produces Class&lt;List>. This is clear. What I am not able to figure out is how to get a instance of Class of type which is parametrized itself, i.e. Class&lt;List&lt;String>>. Like in this snippet: public class GenTest { stati...
If you are looking for a book, [O'Reilly][1] has a few [XML book][2]s. Since I had picked up XML on the job, I just went with [XML in a Nutshell][3] for use as a reference. You might be able to use them to find a good tutorial book on XML for a beginner like [Learning XML][4], if that's what you are looking for. ...
How would it know that the public methods are unused? By marking a method as public it can be accessed by any application which references your library.
http://vyaskn.tripod.com/oracle_sql_server_differences_equivalents.htm is a good resource
Even though there are plenty of tutorials about XML , I agree with Galwegian . I learned XML from [W3Schools][1]. [1]: http://www.w3schools.com/xml/default.asp
This depends on the feature set of the performance tools you have. But if you just need to log the processing time then you could follow this approach. 1. Log the starting time in the [HttpApplication.BeginRequest][1] event. 2. Log the elapsed time in the [HttpApplication.PreSendRequestContent][2] event. If you ...
What is the bes guide to learn XML
|xml|
I'm learning XML, currently of Wikibooks, but that is kinda huge and not oversee-able... anybody know a better place?
I think that FF autofills fields based on the "name" attribute of the field so that if the password box has the name="password" and the change password box has the same it will fill in the same password in both places. Try changing the name attribute of one of the boxes.
It's always best to keep acquisition/release of any resource as balanced as possible. BYTE * pBytes = new BYTE [sizeof(STRUCT) + nPaddingSize]; STRUCT* pStruct = reinterpret_cast< STRUCT* > ( pBytes ) ; // do stuff with pStruct delete [] pBytes ;
It's always best to keep acquisition/release of any resource as balanced as possible. Although leaking or not is hard to say in this case. It depends on the compiler's implementation of the vector (de)allocation. BYTE * pBytes = new BYTE [sizeof(STRUCT) + nPaddingSize]; STRUCT* pStruct = reinterp...
Brennon Williams new book should also be good!!! ![alt text][1] [1]: http://images.pearsoned-ema.com/jpeg/large/9780672329319.jpg
Please see my article on this "Java is Pass-By-Value, Dammit!" http://javadude.com/articles/passbyvalue.htm erlando paraphrased this article in his response (I would have appreciated attribution... it's not cool to copy someone else's work and present it as your own, dude...)
Hey there -- just noticed you referenced my article ;)
Hey there -- just noticed you referenced my article ;) (http://javadude.com/articles/passbyvalue.htm) The Java Spec says that everything in java is pass-by-value. There is no such thing as "pass-by-reference" in java. The key to understanding this is that something like Dog myDog; is _not_ a Dog; it'...
I'm not sure I understand what you mean here. Do you want to know if the object is of **any generic type** or do you want to test if it is a **specific generic type**? Or do you just want to know if is enumerable? I don't think the first is possible. The second is definitely possible, just treat it as any other type...
I would do a quick fix on this to add the style: border-left:2px solid #BDBDBD; to the .buffer class .buffer {style.css (line 328) background-color:#FFFFFF; border-left:2px solid #BDBDBD; /* Grey border */ float:left; height:20px; margin:0px; padding:0px; width:160px; }
Well, you don't want to use the resx style resources: you just stick the ico file in your project in a folder (lets say "ArtWork") and in the properties, set the Build Action to "Resources" ... Then you can reference it in XAML using PACK URIs ... "pack://application:,,,/Artwork/PoshConsoleWindow.ico" See here: [...
Well, you don't want to use the resx style resources: you just stick the ico file in your project in a folder (lets say "ArtWork") and in the properties, set the Build Action to "Resources" ... Then you can reference it in XAML using PACK URIs ... "pack://application:,,,/Artwork/Notify.ico" See here: [http://msdn...
System.Windows.Forms.NotifyIcon icon = new System.Windows.Forms.NotifyIcon(); Stream iconStream = Application.GetResourceStream( new Uri( "pack://application:,,,/YourReferencedAssembly;component/YourPossibleSubFolder/YourResourceFile.ico" )).Stream; icon.Icon = new System.Drawing.Icon( iconStream );
Your icon file should be added to one of your project assemblies and its Build Action should be set to Resource. After adding a reference to the assembly, you can create a NotifyIcon like this: System.Windows.Forms.NotifyIcon icon = new System.Windows.Forms.NotifyIcon(); Stream iconStream = Application.GetR...
How to replace a character for a newline in vim?
|vim|replace|
I'm trying :%s/,/\n/g but it inserts what looks like a ^@ instead of an actual newline, the file is not on DOS mode or anything. What should I do?
I'm trying :%s/,/\n/g but it inserts what looks like a ^@ instead of an actual newline, the file is not on DOS mode or anything. What should I do? EDIT: If you are curious, like me, check [this other question][1] as well. [1]: http://stackoverflow.com/questions/71417/why-is-r-a-newline-for-vim
I assume you've already tried EnumDisplayMonitors() and it didn't work. So if that returns a single HMONITOR for each set of cloned displays, you could compare this set of results to the result of EnumDisplayDevices(). Devices returned by EnumDisplayDevices() that *are* attached to the desktop but *aren't* returned by ...
Implementation of "Remember me" in a Rails application.
|rubyonrails|ruby-on-rails|ruby|
My Rails-app has a sign in box with a "remember me" checkbox. Users who check that box should remain logged in even after closing their browser. I'm keeping track of whether users are logged in by storing their id in the user's session. But sessions are implemented in Rails as session cookies, which are not persist...
|rubyonrails|ruby-on-rails|ruby|http|
My Rails-app has a sign in box with a "remember me" checkbox. Users who check that box should remain logged in even after closing their browser. I'm keeping track of whether users are logged in by storing their id in the user's session. But sessions are implemented in Rails as session cookies, which are not persist...
|ruby|ruby-on-rails|http|
|ruby|ruby-on-rails|https|
The whole point of unit testing is to make testing easy. It's automated. "make test" and you're done. If one of the problems you face is difficult to test code, that's the best reason of all to use unit testing.
C++ web service framework
|c++|xml|web-services|frameworks|xsd|
We are looking for a C++ web services framework, preferably open source. Any recommendations?
We are looking for a C++ Soap web services framework that support RPC, preferably open source. Any recommendations?
Why don't you create a quick comparison? Take a task like "find all divs or tables which contain images of class foo and attach a click event to each of them which makes them expand 50%." Or something more relevant to what you're doing. Then code that with jQuery, Prototype, etc, and compare. Which is shorter? E...
Best way to convince... find a bug, write a unit test for it, fix the bug. That particular bug is unlikely to ever appear again, and you can prove it with your test. If you do this enough, others will catch on quickly.
Actually, your files, while stored in a source repository (big word for another place on your hard drive, or a hard drive somewhere else), you can also have a copy on your local machine, too, just where they exist now. So, all files that aren't checked out would be marked as "read only", if you are using VSS (not su...
Actually, your files, while stored in a source repository (big word for another place on your hard drive, or a hard drive somewhere else), can also exist on your local machine, too, just where they exist now. So, all files that aren't checked out would be marked as "read only", if you are using VSS (not sure about S...
You don't. The c++ standard has no concept of directories. It is up to the implementation to turn a string into a file handle. The contents of that string and what it maps to is OS dependent. Keep in mind that C++ can be used to write that OS, so it gets used at a level where asking how to iterate through a directory i...
Take a look at [SHDoneButton][1] API. [1]: http://msdn.microsoft.com/en-us/library/aa453682.aspx
If you're primarily interested in blogs, what I think we need is a way to prioritize the information that we, **personally**, are interested in. There used to be an RSS reader called wTicker (now demised) that used Bayesian filtering to rate articles for you. Another product under development, [Particls][1], would simi...
I wouldn't call throwing an OutOfMemoryError or StackOverflowError a crash. These are just normal exceptions. To really crash a VM there are 3 ways: 1. Use JNI and crash in the native code. 2. If no security manager is installed you can use reflection to crash the VM. This is VM specific, but normally a VM stores...
Include following code with yours to refresh System Tray. public const int WM_PAINT = 0xF; [DllImport("USER32.DLL")] public static extern int SendMessage(IntPtr hwnd, int msg, int character, IntPtr lpsText); Send WM_PAINT Message to paint System Tray which will refresh it. SendMessage(traynotifywnd,WM_PAINT,...
Which to use, eruby or erb?
|ruby|eruby|erb|
What's the difference between eruby and erb? What considerations would drive me to choose one or the other? My application is generating config files for network devices (routers, load balancers, firewalls, etc.). My plan is to template the config files, using embedded ruby (via either eruby or erb) within the sou...
That 'junk' looks a lot like someone interpreted UTF-8 data as ISO 8859-1 or Windows-1252, probably repeatedly. ’ is the sequence C3 A2, E2 82 AC, E2 84 A2. - UTF-8 C3 A2 = U+00E2 = â - UTF-8 E2 82 AC = U+20AC = € - UTF-8 E2 84 A2 = U+2122 = ™ We then do it again: in Windows 1252 this sequence i...
I've tried Fitnesse and its really awful (particularly integration with SVN). And our company develop similar open-source tool with fit engine: [FitPro][1] Another brilliant tool I've used is [Concordion][2]. It has the only disadvantage - requrements in html format [1]: http://sourceforge.net/projects/fitp...
If you are using SCRUM, this has Sprint reports and Product Burndown reports: [http://www.scrumforteamsystem.com/en/default.aspx][1] [1]: http://www.scrumforteamsystem.com/en/default.aspx
How do we create an installer than doesn't require administrator permissions?
|windows-vista|installation|windows-xp|administrator|
When creating a setup/MSI with Visual Studio is it possible to make a setup for a simple application that doesn't require administrator permissions to install? If its not possible under Windows XP is it possible under Vista? For example a simple image maniputlation application that allows you to paste photos on top...
I'm not sure if java supports automatic xinclude. But you will have to use namespaces to make it work. So don't use `<xinclude ....>`, but use: <xi:xinclude xmlns:xi="http://www.w3.org/2001/XInclude" href="example/File2.xml" /> Normally the included file should still contain the xml header as well. There is ...
I prefer writing the times down using pen and paper. That way you can more fairly weigh things that would have been miscalculated if you were recording them with a stopwatch or timer. If you start on something and have to get up for a few minutes, a timer may count that toward your working time had you neglected to...
2TB is chump change nowadays. Look into hard-drive based hot-swappable backup machines, and rent a box at your local bank: <http://www.high-rely.com/> (there are many more products such as this, but my Google-time is limited).
I second Keith; if you're calling a stored procedure 30,000 times, you have far bigger problems than connection pooling.
[Amazon S3][1] might fit your budget better. I don't know if there is software available to automate the backup process but it's rather easy to write your own code to handle this. Here's their [pricing calculator][2]. According to my estimates you're going to be well under the $1000/mo range. [1]: http://www....
It could be a solution, as it would not erode the interface. I guess you could have a class like this: public class BusinessObjectRecord : BusinessObject { }
[Jungle Disk][1] is one such piece of software that can automate the backup process to Amazon S3. I use it for backup at home, but I guess it could work just as well from a server. Also, there are probably other backup tools that make use of S3 for offsite storage. [1]: http://www.jungledisk.com/index.aspx
I always create a separate assembly that contains: * A lot of small Interfaces (think ICreateRepository, IReadRepository, IReadListRepsitory.. the list goes on and most of them relies heavily on generics) * A lot of concrete Interfaces, like an IPersonRepository<Person,PersonKey,PersonParameters>, that inherits...
I always create a separate assembly that contains: * A lot of small Interfaces (think ICreateRepository, IReadRepository, IReadListRepsitory.. the list goes on and most of them relies heavily on generics) * A lot of concrete Interfaces, like an IPersonRepository<Person,PersonKey,PersonParameters>, that inherits...
What is the best guide to learn XML
There are a couple things PGO can work toward: - Deciding which functions should be inlined or not depending on how often they are called. - Deciding how to place hints about which branch of an "if" statement. - Deciding how to optimize loops based on how many iterations get taken each time that loop is call...
It works by placing extra code to count the number of times each codepath is taken. When you compile a second time the compiler uses the knowledge gained about execution of your program that it could only guess at before. There are a couple things PGO can work toward: - Deciding which functions should be inlined o...
I recommend reading this [OpenGL font tutorial][1]. It's for the D programming language but it's a nice introduction to various issues involved in implementing a glyph caching system for rendering text with OpenGL. The tutorial covers Unicode compliance, antialiasing, and kerning techniques. D is pretty comprehensi...
It depends on a lot of things: - If there is little change in the data (think backend with "publish" button or daily batches), then I would definitely use static files (updated via push from the backend). We used this solution on a couple of large sites and worked really well. - If the data is small enough, mem...
Strawberry Perl is just getting better and better. One problem I've repeatedly had with ActiveState is that my modules sometimes fail to install because I need an upgrade to a core module, but they won't allow that. Thus, everybody who *doesn't* use Windows can use my code, but they can't do that with ActiveState's P...
Windows IDE / editor for a beginner
|editor|ide|windows|
I'm teaching (or trying to teach) computer programming to a grad-student. Her previous experience amounts to little more than writing spreadsheet formulae. Which IDE or text editor should I recommend? Please bear in mind that: * I only meet my student about once a week. * She uses Windows and I use Linux. * S...
I'm teaching (or trying to teach) computer programming to a grad-student. Her previous experience amounts to little more than writing spreadsheet formulae. Which IDE or text editor should I recommend? Please bear in mind that: * I only meet my student about once a week. * She uses Windows and I use Linux. * S...