instruction
stringlengths
0
30k
I had an idea I was mulling over with some colleagues. None of us knew whether or not it exists currently.<br><br> The Basic Premise is to have a system that has 100% uptime but can become more efficient dynamically.<br><br><br> Here is the scenario:<br><br> * So we hash out a system quickly to a specified set of in...
I had an idea I was mulling over with some colleagues. None of us knew whether or not it exists currently.<br><br> The Basic Premise is to have a system that has 100% uptime but can become more efficient dynamically.<br><br><br> Here is the scenario:<br><br> * So we hash out a system quickly to a specified set of in...
If you're scripting in BASH, actually, you can just issue: <pre> cat - yourfile <<<"text" > /tmp/out && mv /tmp/out yourfile </pre> That's actually in the <a href="http://www.linuxtopia.org/online_books/advanced_bash_scripting_guide/x13320.html" target="new">Complex Example</a> you yourself posted in your own que...
The reason was to have same codebase in WinMo and Symbian. My personal preference would be to have native solution on both. But that would mean, developing & maintaining two set of code bases. And the management does not prefer that for some reason ;)
Best practices to parse xml files with C#?
|c#|xml|
The default methods for dealing with xml in c# seem incredibly crude to me, leading me to suspect that I must be missing something in my searches. What is considered the standard best practices to parse xml files in c#?
I'd use [LINQ to XML][1] if you're in .NET 3.5. [1]: http://msdn.microsoft.com/en-us/library/bb308960.aspx#xlinqoverview_topic3
You can bind to an element using ElementName, so if you wanted to bind the selected tree item to the ItemsSource of a ListBox: ItemsSource="{Binding SelectedItem, ElementName=treeView1}"
[Litmus][1] is another web-based alternative. [1]: http://litmusapp.com/ "Litmus"
Look at [37signals][1] and how nice their web UIs are (mostly HTML + AJAX). It's a good example of web applications that work. One of the things to remember are to make sure you don't break the web paradigm. If users want to see two things side by side, they should be able to duplicate the window and let the web bro...
What's wrong with [XmlTextReader][1], [XmlReader][2], [XmlNodeReader][3] and the [System.Xml.XPath][4] namespace? ([XPathNavigator][5], [XPathDocument][6], [XPathExpression][7], [XPathnodeIterator][8])? Usually [XPath][9] makes reading XML easier, which is what you might be looking for. [1]: http://msdn.micr...
What is the best way to do per-user database connections in Rails? I realize this is a poor Rails design practice, but we're gradually replacing an existing web application that uses one database per user. A complete redesign/rewrite is not feasible.
Open source PDF library for C/C++ application?
|c|c++|pdf|
I want to be able to generate PDF ouput from my (native) C++ Windows application. Are there any free/open source libraries available to do this? I looked at the answers to [this question](http://stackoverflow.com/questions/177/how-do-i-programmatically-create-a-pdf-in-my-net-application), but they mostly relate to ....
|c++|c|open-source|pdf|
No. But why don't you just use your webserver's logs? The value of GA is not in the data they collect, but the aggregation/analysis. That's why it's not called Google Raw Data.
In Vim, what is the best way to select, delete, or comment out large portions of multi-screen text?
|perl|vim|vi|
Selecting a large amount of text that extends over many screens in an IDE like Eclipse is fairly easy since you can use the mouse, but what is the best way to e.g. select and delete multiscreen blocks of text or write e.g. three large methods out to another file and then delete them for testing purposes in Vim when usi...
|vim|vi|
You don't want to encode all HTML, you only want to HTML-encode any user input that you're outputting. For PHP: [htmlentities][1] [1]: http://us.php.net/htmlentities
You don't want to encode all HTML, you only want to HTML-encode any user input that you're outputting. For PHP: [htmlentities][1] and [htmlspecialchars][2] [1]: http://us.php.net/htmlentities [2]: http://us.php.net/manual/en/function.htmlspecialchars.php
I've used the code from the codeproject [article][1] and it works pretty well. It's a nice wrapper around the IMAPI2, so as longs as IMAPI2 supports what you need to do, the .NET wrapper will do it. [1]: http://www.codeproject.com/KB/miscctrl/imapi2.aspx
Or, if you want to go the hard way, add a reference to your project for Microsoft.VisualBasic and then use the following: Microsoft.VisualBasic.FileIO.FileSystem.CopyDirectory(fromDirectory, toDirectory); However, using one of the recursive functions is a better way to go since it won't have to load the VB dl...
As long as the client initiates the connection (to get passed firewall and NAT problems) either way is fine. If there are several different type of data you need to send, you might want to have the client specify which type he wants, but this is only needed once per connection. Then you can have the server continue...
When you say the DB field has a length of 4, that means 4 bytes, which is equivalent to an Int32 (4 bytes = 32 bits). That's why your column is being returned as an int32. There are different [integer datatypes][1] in SQL Server -- if you are sure the number won't get higher than 6, you should declare the column in...
You're not saving much if anything by using an Int16 on the ASP side. It still has to load it into a 32-bit register eventually.
FYI, the CLR maps int to Int32 internally anyways.
"Data Remanence" There's a pretty good set of references regarding possible attacks and their actual feasibility on [Wikipedia.][1] There are DoD and NIST standards and recommendations cited there too. Bottom line, it's possible but becoming ever-harder to recover overwritten data from magnetic media. Nonetheless, ...
Use whatever your Sql Server stored proc has defined. If it's an int in Sql Server, then use Int32 in .NET. smallint in Sql is int16. Otherwise, Sql Server will just upconvert it automatically, or throw an error if it needs to be downconverted.
In some SQL databases, VARCHAR will be padded out to its maximum size in order to optimize the offsets, This is to speed up full table scans and indexes. Because of this, you do not have any space savings by using a VARCHAR(200) compared to a CHAR(200)
Well I found the "Server Logs" mentioned in the error above. You need to turn on tracing in the web.config file by adding the following tags: <system.diagnostics> <sources> <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing" > <listeners> <add name=...
Why not attach both to Northwind and see which fits best for you and your situation?
Well, I presume you mean unit testing your code that hits the database, in which case, there is [NDbUnit][1], which appears to be a DbUnit clone for .NET. I've never used it, but I have used DbUnit, and it is quite useful. Edit: I assumed you were using .NET because you mentioned MSSQL. If however you are actually...
If you need cross-platform, look at Boost's Program Options library (boost.org).
If you need a cross-platform solution, try Boost's [Program Options][1] library. [1]: http://www.boost.org/doc/libs/1_36_0/doc/html/program_options.html
It sounds like what you want may be a longest substring match. That is, in your example, two files like trash..thash..song_name_mp3.mp3 and garbage..spotch..song_name_mp3.mp3 would end up looking the same. You'd need some heuristics there, of course. One thing you might try is putting the string through a so...
C#3 - This returns false as soon as a char counted from the beginning fails to match its equivalent at the end: static bool IsPalindrome(this string input) { char[] letters = input.ToUpper().ToCharArray(); for (int i = 0; i < letters.Length / 2; i++) if( letters[i] != letter...
C#3 - This returns false as soon as a char counted from the beginning fails to match its equivalent at the end: static bool IsPalindrome(this string input) { char[] letters = input.ToUpper().ToCharArray(); int i = 0; while( i < letters.Length / 2 ) if( letters[i] !=...
Unit-testing servlets
|unit-testing|eclipse|tomcat|servlets|junit|
I have a bunch of servlets running under the Tomcat servlet container. I would like to separate test code from production code, so I considered using a test framework. JUnit is nicely integrated into Eclipse, but I failed to make it run servlets using a running Tomcat server. Could you please recommend a unit testing ...
Is there a reliable way to prevent cheating in a web based contest where anonymous users can vote?
|asp.net|silverlight|
I'm working on a web-based contest which is supposed to allow anonymous users to vote, but we want to prevent them from voting more than once. IP based limits can be bypassed with anonymous proxies, users can clear cookies, etc. It's possible to use a Silverlight application, which would have access to isolated storage...
If you're .NET 2.0, try XmlReader and it's subclasses XmlTextReader, XmlValidatingReader provide a fast, lightweight (memory usage etc), forward only way to parse an XML file. If you need XPath capabilities try the XPathNavigator. If you need the entire document in memory try XmlDocument.
I did the italics-as-bold trick on Consolas back in July 2007 and posted a [screenshot of it on my blog][1]. I use FontLab which does a great job for this but a custom tool to copy and set the header would be the best bet as you can't modify and redistribute Consolas. [)amien [1]: http://damieng.com/blog/2...
I did the italics-as-bold trick on Consolas back in July 2007 and posted a [screenshot of it on my blog][1]. I used FontLab which does a great job but a custom tool to copy and set the header would be the best bet as you can't modify and redistribute Consolas and FontLab costs $699. If you want to go down the Fon...
it's very simple, I know this is standard methods but you can create your own library to deal with that much better. Here is some examples: XmlDocument xmlDoc= new XmlDocument(); //* create an xml document object. xmlDoc.Load("yourXMLFile.xml"); //* load the XML document from the specified file. ...
I had an idea I was mulling over with some colleagues. None of us knew whether or not it exists currently.<br><br> The Basic Premise is to have a system that has 100% uptime but can become more efficient dynamically.<br><br><br> Here is the scenario:<br><br> * So we hash out a system quickly to a specified set of in...
I had an idea I was mulling over with some colleagues. None of us knew whether or not it exists currently.<br><br> The Basic Premise is to have a system that has 100% uptime but can become more efficient dynamically.<br><br> > **Here is the scenario:**<br><br> * So we hash out a system quickly to a > specified s...
Call gcc same way as you call it for your source file but with a header file. e.g. g++ $(CPPFLAGS) test.h this generates a file called test.h.gch Every time gcc searches for test.h it look first for test.h.gch and if it finds it it uses it automatically. More information can be found under [GCC Preco...
|openid|.net|authentication|
I'm looking at using OpenID for my authentication scheme and wanted to know what the best .NET library is to use for MVC specific applications? thx
|.net|asp.net-mvc|authentication|openid|
It is a static function on the MessageBox class, the simple way to do this is using MessageBox.Show("my message"); in the System.Windows.Forms class. You can find more on the msdn page for this [here][1] . Among other things you can control the message box text, title, default button, and icons. Since you ...
MessageBox.Show also returns a DialogResult, which if you put some buttons on there, means you can have it returned what the user clicked. Most of the time I write something like if (MessageBox.Show("Do you want to continue?", "Question", DialogBoxButtons.YesNo) == DialogResult.Yes) { //some interestin...
You could just rename the project (.Xproj file and project folder) in TFS, delete the local folder structure and all of its contents, then do a get latest for the project. All of this depends the notion of your source repository is completely up to date and compilable.
[py2exe][1] is probably what you want, but it only works on Windows. [PyInstaller][2] works on Windows and Linux. [Py2app][3] works on the Mac. [1]: http://www.py2exe.org/ [2]: http://pyinstaller.python-hosting.com/ [3]: http://pypi.python.org/pypi/py2app/
Importing JavaScript in JSP tags
|java|jsp|jsp-tags|
I have a .tag file that requires a javascript library (as in a .js file). Currently I am just remembering to import the .js file in every JSP that uses the tag but this is a bit cumbersome and prone to error. Is there a way to do the importing of the .js inside the JSP tag? *(for caching reasons I would want t...
How to read bound hover callback functions in jquery
|javascript|jquery|callback|
I used jquery to set hover callbacks for elements on my page. I'm now writing a module which needs to temporarily set new hover behavior for some elements. The new module has no access to the original code for the hover functions. I want to store the old hover functions before I set new ones so I can restore them wh...
Since you are working with tabular data, I'd recommend using the GridView control. Then you'll be able to access individual cells. Otherwise, you can set the td's for Field1 and Field4 to `runat="server"` and give them ID's. Then in the codebehind, access the `InnerText` property for each td.
If I have a small problem that I'd like to solve quickly, I tend to use a scripting language. The code tax is smaller, and, for me at least, the result comes faster.
If you can write it quicker in Java, then go for it. Just try and be aware of what the various scripting languages can do. e.g. Don't make a full blown Java app when you can do the same with a bash one-liner.
How to get a list of current open windows/process with Java?
|java|process|list|
Does any one know how do I get the current open windows or process of a local machine using Java? What I'm trying to do is: list the current open task, windows or process open, like in Windows Taskmanager, but using a multi-platform approach - using only Java if it's possible. Thanks!
|java|processes|list|
Fast Disk Cloning
|dd|linux|hdd|
Is there a way to have Linux read ahead when cloning a disk? I use the program named "dd" to clone disks. The last time I did this it seemed as though the OS was reading then writing but never at the same time. Ideally, the destination disk would be constantly writing without waiting that's of course if the source d...
Is there a way to have Linux read ahead when cloning a disk? I use the program named "dd" to clone disks. The last time I did this it seemed as though the OS was reading then writing but never at the same time. Ideally, the destination disk would be constantly writing without waiting that's of course if the source d...
|linux|hdd|dds|
The [Google V8 JavaScript Engine][1] is written in C++ and uses [SCons][2], so I guess that's one vote for it. [1]: http://code.google.com/p/v8/ [2]: http://www.scons.org/
If you can afford a smidge more overhead in the generation, go for DataList and use the DataKeys property, which will save the data fields you need. You could also use labels in each of your table cells and be able to reference items with e.Item.FindControl("LabelID").
Weigh the importance of the tool against popping open a text editor for a quick edit vs. opening IDE, recompiling, redeploying, etc.
It is not the validation part I want to change. The problem is in the initial handshake, the server transmits the message informing the client that client authentication is required (that is the CertificateRequest message). As part of this message, the server sends the names of CAs that it will accept as issuers of the...
You will need to copy the [Process](http://java.sun.com/javase/6/docs/api/java/lang/Process.html) out, err, and input streams to the System versions. The easiest way to do that is using the [IOUtils](http://commons.apache.org/io/api-release/org/apache/commons/io/IOUtils.html) class from the Commons IO package. The [c...
Realising this is a bit off-topic to the question, but if you are using a lot of stored procedures, make sure there is a consistent way to put them under some sort of source control (e.g., subversion or git) and be able to migrate updates from your development system to the test system to the production system. When...
The key advantage is that you have decoupled the definition from the implementation and so you can vary one against the other. Version 2 of the library might want a very different implementation and so they can easily modify the CatImpl wihtout having to change the signature of the exposed Cat class. This means the...
Placing the call to the impl->Purr inside the cpp file means that in the future you could do something completely different without having to change the header file. Maybe next year they discover a helper method they could have called instead and so they can change the code to call that directly and not use impl->Purr ...
Look at the inner exception that you are getting. It will tell you which field/property it is having trouble serializing. You can exclude fields/properties from xml serialization by decorating them with the [XmlIgnore()] attribute. I don't think that XmlSerializer uses the [Serializable] attribute, so I doub...
The font is fixed width and height, so making a background bitmap dynamically isn't difficult, and is probably the quickest and easiest solution. In fact, if you size it correctly there will only be one stretched pixel per character. -Adam
What do you have on the client's side? Many firewalls allow outgoing requests but block incoming requests. In other words, pull may be your only option if you are crossing the Internet unless you are sending out e-mails.
There's `Kernel::local_variables`, but I'm not sure that this will work for a method's local vars, and I don't know that you can manipulate it in such a way as to do what you wish to acheive.
I don't know if it is possible in XAML-only but try the following: Give your ComboBox a name so you can access it in the codebehind: "typesComboBox1" Now try the following typesComboBox1.ItemsSource = Enum.GetValues(typeof(ExampleEnum));
Take a look at <a href="http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001397">ActiveRecord::Base.establish_connection</a>. That's how you connect to a different database server. I can't be of much more help since I don't know how you recognize the user or map it to it's database, but I suppose a master dat...
SDK for writing DVD's
|.net|sdk|image-capture|dvd-burning|
I need to add DVD writing functionality to an application I'm working on. However it needs to be able to write out files that are being grabbed "live" from a camera, over a long period of time. I can't wait until all the files are captured before I start writing them to the DVD, I need to write them out in chunks as I ...
I believe what you want is a flag type enum. You need to add the Flags attribute to the top of the enum, and then you can combine enums with the 'Or' keyword. Like this: <Flags()> _ Enum CombinationEnums As Integer HasButton = 1 TitleBar = 2 ReadOnly = 4 ETC = 8 End En...
I believe what you want is a flag type enum. You need to add the Flags attribute to the top of the enum, and then you can combine enums with the 'Or' keyword. Like this: <Flags()> _ Enum CombinationEnums As Integer HasButton = 1 TitleBar = 2 ReadOnly = 4 ETC = 8 End En...
I prefer the following: if a == []: print "The list is empty." Readable and you don't have to worry about calling a function like `len()` to iterate through the variable. Although I'm not entirely sure what the BigO notation of something like this is... but Python's so blazingly fast I doubt it'd matt...
Okay. Ignoring the 'tomcat' bit and coding to the servlet, your best bet is to create mocks for the response and request objects, and then tell it what you expect out of it. So for a standard empty doPost, and using [EasyMock][1], you'll have public void testPost() { mockRequest = createMock(Http...