# Daily Archives

• ### Need a php based filemanager with support for extracting RAR/ZIP?

##### - by Johnes thomas
Is there any php based filemanager with RAR support that I can host on my server?

• ### Prove this Tautology (No Truth Tables)

##### - by FSM
This is for homework for my Discrete Math class. I understand how to prove tautologies with a truth table. I'm having trouble figuring out how to do it without though. I found this example in our text, but the solution is not provided. I was hoping someone could answer it as best they could so I could apply it to my other questions. Thanks! ! = not/invert ^ = and V = or - = if then [!P ^ (P V Q) ] - Q I also am completely lost for this question (I fear I'll be tested on something of this difficulty) [ (P - Q) ^ (Q - R) ] - (P - R) Thanks for the help all!

##### - by mewrei
Is there any way to chase down lockups and runaway load averages? Every so often (pretty randomly) I'll get my load average spike up over 5 usually to around 10-15 and sometimes as high as 75 (dual core machine), and cause my system to lock for an indeterminate amount of time. The only thing I can possibly chase it to is using nVidia fakeraid (RAID-1) with JFS on top of that for my /home partition. Also I noticed that when my load averages spike, the power management system doesn't step up my processor speed from 1.6 to its maximum 2.13Ghz clock speed (not sure if this makes a huge difference with this problem). Any ideas?

• ### Using .NET's HttpWebRequest to download a multitude of files in a row

##### - by Cornelius
I have an application that needs to download several files in a row in succession (sometimes a few thousand). However, what ends up happening when several files need to be downloaded is I get an exception with an inner exception of type SocketException and the error code 10048 (WSAEADDRINUSE). I did some digging and basically it's because the server has run out of sockets (and they are all waiting for 240s or so before they become available again) - not coincidentally it starts happening around the 1024 file range. I would expect that the HttpWebRequest/ServicePointManager would be reusing my connection, but apparently it is not (and the files are https, so that may be part of it). I never saw this problem in the C++ code that this was ported from (but that doesn't mean it didn't ever happen - I'd be surprised if it was, though). I am properly closing the WebRequest object and the HttpWebRequest object has KeepAlive set to true by default. Next my intent is to fiddle around with ServicePointManager.SetTcpKeepAlive(). However, I can't see how more people haven't run into this problem. Has anyone else run into the problem, and if so, what did you do to get around it? Currently I have a retry scheme that detects this error and waits it out, but that doesn't seem like the right thing to do. Here's some basic code to verify what I'm doing (just in case I'm missing closing something): WebRequest webRequest = WebRequest.Create(uri); webRequest.Method = "GET"; webRequest.Credentials = new NetworkCredential(username, password); WebResponse webResponse = webRequest.GetResponse(); try { using(Stream stream = webResponse.GetResponseStream()) { // read the stream } } finally { webResponse.Close() }

• ### .NET How can i set field value on value type using reflection

##### - by soccerazy
.NET I want to clone a value type's fields. How can i set a field value on a value type using reflection (or something else dynamically)? This works for reference types but not for value types. I understand why but I don't know an alternative. shared function clone(of t)(original as t) as t dim cloned as t 'if class then execute parameterless constructor if getType(t).isClass then cloned = reflector.construct(of t)() dim public_fields = original.getType.getFields() for each field in public_fields dim original_value = field.getValue(original) 'this won't work for value type, but it does work for reference type ??? field.setValue(cloned, original_value) next return cloned end function

• ### How to insert inline content from one FlowDocument into another?

##### - by Robert Rossney
I'm building an application that needs to allow a user to insert text from one RichTextBox at the current caret position in another one. I spent a lot of time screwing around with the FlowDocument's object model before running across this technique - source and target are both FlowDocuments: using (MemoryStream ms = new MemoryStream()) { TextRange tr = new TextRange(source.ContentStart, source.ContentEnd); tr.Save(ms, DataFormats.Xaml); ms.Seek(0, SeekOrigin.Begin); tr = new TextRange(target.CaretPosition, target.CaretPosition); tr.Load(ms, DataFormats.Xaml); } This works remarkably well. The only problem I'm having with it now is that it always inserts the source as a new paragraph. It breaks the current run (or whatever) at the caret, inserts the source, and ends the paragraph. That's appropriate if the source actually is a paragraph (or more than one paragraph), but not if it's just (say) a line of text. I think it's likely that the answer to this is going to end up being checking the target to see if it consists entirely of a single block, and if it does, setting the TextRange to point at the beginning and end of the block's content before saving it to the stream. The entire world of the FlowDocument is a roiling sea of dark mysteries to me. I can become an expert at it if I have to (per Dostoevsky: "Man is the animal who can get used to anything."), but if someone has already figured this out and can tell me how to do this it would make my life far easier.

• ### Extracting pair member in lambda expressions and template typedef idiom

##### - by Nazgob
Hi, I have some complex types here so I decided to use nifty trick to have typedef on templated types. Then I have a class some_container that has a container as a member. Container is a vector of pairs composed of element and vector. I want to write std::find_if algorithm with lambda expression to find element that have certain value. To get the value I have to call first on pair and then get value from element. Below my std::find_if there is normal loop that does the trick. My lambda fails to compile. How to access value inside element which is inside pair? I use g++ 4.4+ and VS 2010 and I want to stick to boost lambda for now. #include <vector> #include <algorithm> #include <boost\lambda\lambda.hpp> #include <boost\lambda\bind.hpp> template<typename T> class element { public: T value; }; template<typename T> class element_vector_pair // idiom to have templated typedef { public: typedef std::pair<element<T>, std::vector<T> > type; }; template<typename T> class vector_containter // idiom to have templated typedef { public: typedef std::vector<typename element_vector_pair<T>::type > type; }; template<typename T> bool operator==(const typename element_vector_pair<T>::type & lhs, const typename element_vector_pair<T>::type & rhs) { return lhs.first.value == rhs.first.value; } template<typename T> class some_container { public: element<T> get_element(const T& value) const { std::find_if(container.begin(), container.end(), bind(&typename vector_containter<T>::type::value_type::first::value, boost::lambda::_1) == value); /*for(size_t i = 0; i < container.size(); ++i) { if(container.at(i).first.value == value) { return container.at(i); } }*/ return element<T>(); //whatever } protected: typename vector_containter<T>::type container; }; int main() { some_container<int> s; s.get_element(5); return 0; }

• ### .NET: How Do I Create File Icon Overlays

##### - by Maxim Z.
I'm trying to add different icon overlays over the icons of various files (note: not all the files of a certain type, just certain files). If you don't get what I mean, I'm referring to what programs like TortoiseSVN, TortoiseHG, Dropbox, etc. do. Can this be done in .NET? If so, how? I'm hoping there's a library out there for this. I found this CodeProject article about something like this, but it's not .NET. Thanks in advance.

• ### Revisiting .NET, but what should I focus on?

##### - by Wayne M
After about a two-year hiatus, I'm brushing up on my .NET skills to find a .NET job (my previous two positions have very little development, or development using legacy technologies, so apart from a few very minor apps I have not touched .NET in close to two years). I'm aware of things like ASP.NET MVC, and I have previously read on things like NHibernate and DI/IOC, albeit I have yet to use them apart from very trivial "Hello World" type applications. I have a subscription to Rob Conery's Tekpub website and occasionally watch these videos when I have free time. My concern is this: I don't live in a very technical area. I would be surprised if any but the most tech-savvy companies have heard of, let alone use, ASP.NET MVC, NHibernate (or even LINQ/EF), or know about IoC. I would be willing to bet a large sum of money that 95% of the possible jobs I could obtain will use the following: Visual Source Safe, if any VCS at all ASP.NET 2.0 Webforms (3.5 if lucky) Raw ADO.NET on top of a very thin implementation of the Gateway pattern Stored Procedures in the database for most CRUD operations Gratuitous use of code-behind, with a Service layer if I'm lucky If I were extremely lucky, I might find a shop that has heard of ORMs and either uses one, or has wrote their own data abstraction. Also if I were lucky, the company would be using Model-View-Presenter. In light of this I'm not sure what I should focus on learning. Personally, I would prefer to be using the latest stuff - ASP.NET MVC, NHibernate, jQuery, WCF etc. Reality says I should go back to the basics, since it looks like most potential opportunities aren't going to be anywhere near the cutting edge, or anywhere close to it. And, as much as I would like to find a position and start to show the other developers the benefits, in my past experience this has usually resulted in my being fired for "not being a team player" and doing things the bad old way. So, I am curious how you would approach a situation like this? What should I focus on, in order to A) Reaquaint myself with .NET, and B) Prepare myself to obtain a .NET job again that is more than likely going to use techniques that I and most other knowledgeable developers will scoff at?

• ### YUI Menu rendering below "fold" on first open

##### - by Flash84x
I have a YUI menu on the bottom navigation of the screen which creates a large white space beneath it where the action list would be rendered if visible... On the first click the menu will render in that white space which requires the user to scroll to see it... on the second click however it will draw upward (ideally) so that the user does not have to scroll to see the menu... the second click also kills that block of white space... i found adding a style of display:none to the div kills the white space... but then YUI doesn't set the display to block, which from what I understood it should... so I wrote another method that would do that manually... but the same behavior happens, the menu first renders below the fold requiring the user to scroll.... 2nd time its works fine... some reason the top/left positions are not being calculated properly on the first click and i cannot seem to figure out why

• ### memory not freed in matlab?

##### - by noam
I am running a script that animates a plot (simulation of a water flow). After a while, I kill the loop by doing ctrl-c. After doing this several times I get the error: ??? Error: Out of memory. And after I start receiving that error, every call to my script will generate it. Now, it happens before anything inside the function that I am calling is executed, i.e even if I add the line a=1 as the first line of the function I am calling, I still get the error and no printout, so the code inside the function doesn't even get executed. What could be causing this?

• ### How do I verifying if site has javascript enabled and if user's browser is IE 8

##### - by WingMan20-10
I was using .net 4.0 with visual studio 2010

• ### "Presenter First" vs "Passive View" MVP?

##### - by Bermo
Is the "Presenter First" MVP pattern the same as the "Passive View"? If not, how do they differ?

• ### Is there any way to connect the Database server from Selenium RC?

##### - by Vijay Prasath
Does anyone know how to connect DB from Selenium RC? I need to run a lot of user IDs and passwords with different role access. Currently I am using this as data suite with an HTML file.

• ### not so obvious pointers

##### - by mike_hornbeck
I have a class : class X{ public : void f ( int ) ; int a ; } ; And the task is "Inside the code provide declarations for : pointer to int variable of class X pointer to function void(int) defined inside class X pointer to double variable of class X" Ok so pointer to int a will be just int *x = &a, right ? If there is no double in X can I already create pointer to double inside this class ? And the biggest problem is the second task. How one declares pointer to function ?