instruction
stringlengths
0
30k
Given the code bellow, how do I style the radio buttons to be next to the labels and style the label of the selected radio button differently than the other labels? <div class="input radio"> <fieldset> <legend>What color is the sky?</legend> <input type="hidden" name="color" value="" id="SubmitQuestion" /> <input type="radio" name="color" id="SubmitQuestion1" value="1" /> <label for="SubmitQuestion1">A strange radient green.</label> <input type="radio" name="color" id="SubmitQuestion2" value="2" /> <label for="SubmitQuestion2">A dark gloomy orange</label> <input type="radio" name="color" id="SubmitQuestion3" value="3" /> <label for="SubmitQuestion3">A perfect glittering blue</label> </fieldset> </div> Also let me state that I use the yui css styles as base. If you are not familir with them, they can be found here: * [reset-fonts-grids.css][1] * [base-min.css][2] Documentation for them both here : [Yahoo! UI Library][3] [1]: http://yui.yahooapis.com/2.5.2/build/reset-fonts-grids/reset-fonts-grids.css [2]: http://yui.yahooapis.com/2.5.2/build/base/base-min.css [3]: http://developer.yahoo.com/yui/reset/
> but have you tried setting the > compatibilty mode for the database to > sql server 2000. I just checked the 2005 database, I selected the database, and clicked Properties->Options, and it says the db is already in 2000 compatibility mode.
This is a pain. What we really need is for Microsoft to allow us to hook into a Post-Solution Build event. You can do this via macros but that's too complicated. I'm assuming this is a C++ project because I don't have this problem with C#. This is my solution, it's not elegant but it works: - Create a new project whose only purpose is to run the post-build script. Mark it as dependent on every other project in the solution. - Add a dummy file to that project called dummy.h or whatever. - Right click on dummy.h in Solution Explorer and select Properties. - Select 'Custom Build Step'. - For the command line type 'echo' and for Outputs just type 'dummy' or something else that will never exist. This project, and therefore the post-build script, will now be run on every build. John.
Here are some 3rd-party diagramming tools: - <http://www.nevron.com/Products.DiagramFor.NET.Overview.aspx> - <http://www.nwoods.com/GO/dotnet.htm> - <http://www.syncfusion.com/products/diagram/web/default.aspx>
var fileName = string.Format("{0}\\fileNameHere", Directory.GetCurrentDirectory()); var connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; data source={0}; Extended Properties=Excel 8.0;", fileName); var adapter = new OleDbDataAdapter("SELECT * FROM [workSheetNameHere$]", connectionString); var ds = new DataSet(); adapter.Fill(ds, "anyNameHere"); DataTable data = ds.Tables["anyNameHere"]; This is what I usually use. It is a little different because I usually stick a AsEnumerable() at the edit of the tables: var data = ds.Tables["anyNameHere"].AsEnumerable(); as this lets me use LINQ to search and build structs from the fields. var query = data.Where(x => x.Field<string>("phoneNumber") != string.Empty).Select(x => new MyContact { firstName= x.Field<string>("First Name"), lastName = x.Field<string>("Last Name"), phoneNumber =x.Field<string>("Phone Number"), });
The Java runtime library supports validation. Last time I checked this was the Apache Xerces parser under the covers. You should probably use a [javax.xml.validation.Validator][1]. import java.io.File; import java.net.URL; import javax.xml.XMLConstants; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; import javax.xml.validation.Validator; import org.xml.sax.SAXException; public class XmlValidator { private static Validator createValidator( URL schemaFile) throws SAXException, ParserConfigurationException { SchemaFactory schemaFactory = SchemaFactory .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = schemaFactory .newSchema(schemaFile); return schema.newValidator(); } public static void main( String[] args) throws Exception { URL schemaFile = new URL( "http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"); Source xmlFile = new StreamSource( new File("web.xml")); Validator validator = createValidator(schemaFile); try { validator.validate(xmlFile); System.out.println(xmlFile .getSystemId() + " is valid"); } catch (SAXException e) { System.out.println(xmlFile .getSystemId() + " is NOT valid"); System.out .println("Reason: " + e .getLocalizedMessage()); } } } The schema factory constant is the string http://www.w3.org/2001/XMLSchema which defines XSDs. The above code validates a WAR deployment descriptor against the URL http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd but you could just as easily validate against a local file. You should not use the DOMParser to validate a document (unless your goal is to create a document object model anyway). This will start creating DOM objects as it parses the document - wasteful if you aren't going to use them. [1]: http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/validation/Validator.html
The low cost solution is to switch to using ClickOnce, which you can automate using MSBuild. But if you still need to create a Windows Installer package, you will need to convert your project to WiX (pretty straight foward) and build that with your solution. This will get you started: [Automate Releases With MSBuild And Windows Installer XML][1] [1]: http://msdn.microsoft.com/en-us/magazine/cc163456.aspx
@Mike: While I agree that validity is not needed to make a page render (after all, we have to keep IE6 compatibility in...), creating valid XHTML that IS compatible AND valid is not a problem. The problems start when people are used to HTML 4 and using the depreciated tags and attributes. Just because the Web is a pile of crap does not mean that every new page needs to be a pile of crap as well. Most Validation errors on SO are so trivial, it shouldn't take too long to fix, like missing quotes on attributes. But it may still be kind of pointless, given the fact that the W3C does not have any idea where they want to be going anyway (see HTML 5) and a certain big Browser company that also makes operating systems does not care as well, so a site could as well send out it's doctype as HTML 1337 Sucks and browsers will still try to render it.
[nProf][1] is a free .Net profiler ([ref][2]). [1]: http://nprof.sourceforge.net/Site/Description.html [2]: http://stackoverflow.com/questions/3927/what-are-some-good-net-profilers#3935
[nProf][1] is a good, free tool for .Net Profiling. [1]: http://nprof.sourceforge.net/Site/Description.html
Using IP address isn't really the best idea in my experience. For example; my office has two IP addresses that get used depending on load and we constantly run into issues using IP addresses. Instead, I've opted for storing the sessions in a separate database for the domains on my servers. This way no one on the file system has access to that session info. This was really helpful with phpBB before 3.0 (they've since fixed this) but it's still a good idea I think.
Ajaxian actually had a [post on inserting / retrieving html from an iframe](http://ajaxian.com/archives/introducing-html-into-an-iframe-and-getting-it-back) today. You can probably use the js snippet they have posted there. As for handling whether browser / tab, you can attach to the onbeforeunload (<http://msdn.microsoft.com/en-us/library/ms536907(VS.85).aspx>) event
Ajaxian actually had a [post on inserting / retrieving html from an iframe](http://ajaxian.com/archives/introducing-html-into-an-iframe-and-getting-it-back) today. You can probably use the js snippet they have posted there. As for handling closing of a browser / tab, you can attach to the onbeforeunload (<http://msdn.microsoft.com/en-us/library/ms536907(VS.85).aspx>) event and do whatever you need to do.
Keep in mind that the money data type can have up to 4 digits past the decimal. Values with more than two digits might not work as expected for either your original solution or the x100 trick.
I used to use NUnit, but I switched to MbUnit since it has more features. I love RowTest. It lets you parametrize your tests. NUnit does have a litter bit better tool support though. I am using ReSharper to run MbUnit Tests. I've had problems with TestDriven.NET running my SetUp methods for MbUnit.
Expanding on [Nathans][1] post. The following will do the job lot in one batch file. @echo off if %1.==Sub. goto %2 for %%f in (*.in) do call %0 Sub action %%~nf goto end :action echo The file is %3 copy %3.in %3.out ren %3.out monkeys_are_cool.txt :end [1]: http://stackoverflow.com/users/4142/nathan-fritz
Perhaps the most common SVN property, 'svn:ignore' is done through the .gitignore file, rather than metadata. I'm afraid I don't have anything more helpful for the other kinds of metadata.
Database exception handling best practices
|database|architecture|exception|
How do you handle database exceptions in your application? Are you trying to validate data prior passing it to DB or just relying on DB schema validation logic? Do you try to recover from some kind of DB errors (e.g. timeouts)? Here are some approaches: - Validate data prior passing it to DB - Left validation to DB and handle DB exceptions properly - Validate on both sides - Validate some obvious constraints in business logic and left complex validation to DB What approach do you use? Why?
How do you handle database exceptions in your application? Are you trying to validate data prior passing it to DB or just relying on DB schema validation logic? Do you try to recover from some kind of DB errors (e.g. timeouts)? Here are some approaches: 1. Validate data prior passing it to DB 2. Left validation to DB and handle DB exceptions properly 3. Validate on both sides 4. Validate some obvious constraints in business logic and left complex validation to DB What approach do you use? Why? **Updates:** Regarding approach #3: Having multiple same validation in multiple places breaks DRY principle i.e. leads to logic duplication. Do you think it's a necessary evil?
How do you handle database exceptions in your application? Are you trying to validate data prior passing it to DB or just relying on DB schema validation logic? Do you try to recover from some kind of DB errors (e.g. timeouts)? Here are some approaches: 1. Validate data prior passing it to DB 2. Left validation to DB and handle DB exceptions properly 3. Validate on both sides 4. Validate some obvious constraints in business logic and left complex validation to DB What approach do you use? Why? **Updates:** Regarding approach #3: Having same validations in multiple places breaks DRY principle i.e. leads to logic duplication. Do you think it's a necessary evil?
|database|architecture|exception|
|database|exception|architecture|
How do you handle database exceptions in your application? Are you trying to validate data prior passing it to DB or just relying on DB schema validation logic? Do you try to recover from some kind of DB errors (e.g. timeouts)? Here are some approaches: 1. Validate data prior passing it to DB 2. Left validation to DB and handle DB exceptions properly 3. Validate on both sides 4. Validate some obvious constraints in business logic and left complex validation to DB What approach do you use? Why? **Updates:** Regarding approach #3: Having same validations in multiple places breaks DRY principle i.e. leads to logic duplication. Do you think it's a necessary evil? I'm glad to see growing discussion. Let’s try to sum up community answers. Suggestion: - Validate on both sides - Check business logic constraint on client side, let DB do integrity checks - Check early to avoid bothering DB - Check early to improve user experience - Keep DB interacting code in place to simplify development - Object-relational mapping (NHibernate, Linq, etc.) can help you to deal with constrains Do you have anything else to say?
I write a SOAP server that receives XML requests, and creates XML responses. (Unfortunately, it's not my project, so it's closed source, but that's another problem). It turned out for me that creating (SOAP) XML documents is fairly simple, if you have a data structure that "fits" the schema. I keep the envelope, since the response envelope is (almost) the same as the request envelope. Then, since my data structure is a (possibly nested) dictionary, I create a string that turns this dictionary into &lt;key>value&lt;/key> items. This is a task that recursion makes simple, and I end up with the right structure. This is all done in python code, and is currently fast enough for production use. You can also (relatively) easily build lists as well, although depending upon your client, you may hit problems unless you give length hints. For me, this was much simpler, since a dictionary is a much easier way of working than some custom class. For the books, generating XML is much easier than parsing!
I've always used the SharpZip Library (found [here][1]) [1]: http://sharpdevelop.net/OpenSource/SharpZipLib/Download.aspx
I've always used the SharpZip Library (found [here][1]) edit: hyperlink wont work, here's the url: http://sharpdevelop.net/OpenSource/SharpZipLib/Download.aspx [1]: http://sharpdevelop.net/OpenSource/SharpZipLib/Download.aspx
I've always used the SharpZip Library <http://sharpdevelop.net/OpenSource/SharpZipLib/Download.aspx>
Swap unique indexed column values in database.
|sql|database|
I have a database table and one of the fields (not primary key) is having unique index on it. Now I want to swap values under this column for two rows. How could this be done? Two hack I know are: 1. Delete both rows and re-insert them 2. Update rows with some other value and swap and then update to actual value. But I don't want to go for these as they do not seem to be the appropriate solution to the problem. Could anyone help me out?
Automatically update version number
|c#|.net|visual-studio|
I would like the version property of my application to be incremented for each build but I'm not sure on how to enable this functionality in Visual Studio (2005/2008). I have tried to specify the AssemblyVersion as 1.0.* but it doesn't get me exactly what I want. I'm also using a settings file and in earlier attempts when the assembly version changed my settings got reset to the default since the application looked for the settings file in another directory. I would like to be able to display a version number in the form of 1.1.38 so when a user finds a problem I can log the version they are using as well as tell them to upgrade if they have an old release.
I would like the version property of my application to be incremented for each build but I'm not sure on how to enable this functionality in Visual Studio (2005/2008). I have tried to specify the AssemblyVersion as 1.0.* but it doesn't get me exactly what I want. I'm also using a settings file and in earlier attempts when the assembly version changed my settings got reset to the default since the application looked for the settings file in another directory. I would like to be able to display a version number in the form of 1.1.38 so when a user finds a problem I can log the version they are using as well as tell them to upgrade if they have an old release. A short explanation of how the versioning works would also be appreciated. When does the build and revision number get incremented?
<blockquote><blockquote>Some come with a performance penalty of running the same test twice, which may not always be trivial. The alternative to that is storing and passing round booleans, which gets ugly.</blockquote> The performance penalty is minor. However I agree that running a test twice is not a nice solution.</blockquote> I believe the question was how to remove the labels, not how to optimize the algorithm. It appeared to me that the original poster was unaware of how to use 'continue' and 'break' keywords without labels, but of course, my assumptions may be wrong. When it comes to performance, the post does not give any information about the implementation of the other functions, so for all I know they might as well be downloading the results via FTP as consisting of simple calculations inlined by the compiler. That being said, doing the same test twice is not optimal&mdash;in theory.
<blockquote><blockquote>Some come with a performance penalty of running the same test twice, which may not always be trivial. The alternative to that is storing and passing round booleans, which gets ugly.</blockquote> The performance penalty is minor. However I agree that running a test twice is not a nice solution.</blockquote> I believe the question was how to remove the labels, not how to optimize the algorithm. It appeared to me that the original poster was unaware of how to use 'continue' and 'break' keywords without labels, but of course, my assumptions may be wrong. When it comes to performance, the post does not give any information about the implementation of the other functions, so for all I know they might as well be downloading the results via FTP as consisting of simple calculations inlined by the compiler. That being said, doing the same test twice is not optimal&mdash;in theory. EDIT: On a second thought, the example is actually not a horrible use of labels. I agree that <a href="http://en.wikipedia.org/wiki/Goto#Criticism_of_goto_usage">"goto is a no-no"</a>, but not because of code like this. The use of labels here does not actually affect the readability of the code in a significant way. Of course, they are not required and can easily be omitted, but not using them simply because "using labels is bad" is not a good argument in this case. After all, removing the labels does not make the code much easier to read, as others have already commented.
<p>I've had a similar problem before when using ODBC linked tables to connect to an Sql Server. The solution was to relink the tables and specify the primary key to the table. If Access doesn't know the primary key it cannot perform inserts or updates.</p> I haven't any experience with ADPs but it could be a similar thing, theres a knowledge base article about it here http://support.microsoft.com/?scid=kb%3Ben-us%3B235267&x=15&y=13
Maybe this is not the best way, but it works. // Here is your path String p = photosLocation + "whatever.jpg"; // Here is the page address String pa = Page.Request.Url.AbsoluteUri; // Take the page name String pn = Page.Request.Url.LocalPath; // Here is the server address String sa = pa.Replace(pn, ""); // Take the physical location of the page String pl = Page.Request.PhysicalPath; // Replace the backslash with slash in your path pl = pl.Replace("\\", "/"); p = p.Replace("\\", "/"); // Root path String rp = pl.Replace(pn, ""); // Take out same path String final = p.Replace(rp, ""); // So your picture's address is String path = sa + final;
|html|css|styles|radio-button|
Given the code bellow, how do I style the radio buttons to be next to the labels and style the label of the selected radio button differently than the other labels? <div class="input radio"> <fieldset> <legend>What color is the sky?</legend> <input type="hidden" name="color" value="" id="SubmitQuestion" /> <input type="radio" name="color" id="SubmitQuestion1" value="1" /> <label for="SubmitQuestion1">A strange radient green.</label> <input type="radio" name="color" id="SubmitQuestion2" value="2" /> <label for="SubmitQuestion2">A dark gloomy orange</label> <input type="radio" name="color" id="SubmitQuestion3" value="3" /> <label for="SubmitQuestion3">A perfect glittering blue</label> </fieldset> </div> Also let me state that I use the yui css styles as base. If you are not familir with them, they can be found here: * [reset-fonts-grids.css][1] * [base-min.css][2] Documentation for them both here : [Yahoo! UI Library][3] @pkaeding: Thanks. I tried some floating both thing that just looked messed up. The styling active radio button seemed to be doable with some input[type=radio]:active nomination on a google search, but I didnt get it to work properly. So the question I guess is more: Is this possible on all of todays modern browsers, and if not, what is the minimal JS needed? [1]: http://yui.yahooapis.com/2.5.2/build/reset-fonts-grids/reset-fonts-grids.css [2]: http://yui.yahooapis.com/2.5.2/build/base/base-min.css [3]: http://developer.yahoo.com/yui/reset/
Have you considered using conditional compilation to control what happens during debug/deployment? e.g. DateTime date; #if DEBUG date = new DateTime(2008, 09, 04); #else date = DateTime.Now; #endif Failing that, you want to expose the property so you can manipulate it, this is all part of the challenge of writing _testable_ code, which is something I am currently wrestling myself :D
Have you considered using conditional compilation to control what happens during debug/deployment? e.g. DateTime date; #if DEBUG date = new DateTime(2008, 09, 04); #else date = DateTime.Now; #endif Failing that, you want to expose the property so you can manipulate it, this is all part of the challenge of writing _testable_ code, which is something I am currently wrestling myself :D ###Edit A big part of me would preference [Blair's approach][1]. This allows you to "hot plug" parts of the code to aid in testing. It all follows the design principle _encapsulate what varies_ test code is no different to production code, its just no one ever sees it externally. Creating and interface may seem like a lot of work for this example though (which is why I opted for conditional compilation). [1]: http://stackoverflow.com/questions/43711/whats-a-good-way-to-overwrite-datetimenow-during-testing#43720
Thanks so far. I've successfully tried Andrew Connel's solution: [http://www.andrewconnell.com/blog/articles/UsingCodeBehindFilesInSharePointSites.aspx][1] Wrapping it into a solution is part of that, but the main problem was how to get the code into that, and it's more leaning towards Option 2 without having to create the controls in code. What I was missing: In the .cs File, it is required to manually add the "protected Button Trigger;" stuff, because there is no automatically generated .designer.cs file when using a class library. [1]: http://www.andrewconnell.com/blog/articles/UsingCodeBehindFilesInSharePointSites.aspx
Maybe this is not the best way, but it works. // Here is your path String p = photosLocation + "whatever.jpg"; // Here is the page address String pa = Page.Request.Url.AbsoluteUri; // Take the page name String pn = Page.Request.Url.LocalPath; // Here is the server address String sa = pa.Replace(pn, ""); // Take the physical location of the page String pl = Page.Request.PhysicalPath; // Replace the backslash with slash in your path pl = pl.Replace("\\", "/"); p = p.Replace("\\", "/"); // Root path String rp = pl.Replace(pn, ""); // Take out same path String final = p.Replace(rp, ""); // So your picture's address is String path = sa + final; Edit: Ok, somebody marked as not helpful. Some explanation: take the physical path of the current page, split it into two parts: server and directory (like c:\inetpub\whatever.com\whatever) and page name (like /Whatever.aspx). The image's physical path should contain the server's path, so "substract" them, leaving only the image's path relative to the server's (like: \design\picture.jpg). Replace the backslashes with slashes and append it to the server's url.
The IInterceptor is the recommended way to modify any data in nhibernate in a non-invasive fashion. It's also useful for decryption / encryption of data without your application code needing to know. Triggers on the database are moving the responsibility of logging (an application concern) in to the DBMS layer which effectively ties your logging solution to your database platform. By encapsulating the auditing mechanics in the persistance layer you retain platform independance and code transportability. I use Interceptors in production code to provide auditing in a few large systems.
One repository per project. Steven Murawski's comment about CC.NET is an interesting one. I would be interested to hear how it works if you need to specify several source control repositories.
Simply delete the .suo file. It contains the list of open files.
Evidence Base Scheduling Tool
|evidence-based-scheduling|
Are there any free tools that implement evidence based scheduling that [joel talks about][1]? There lies fogbugz of course but I am looking for a simple and free tool that can apply ebs on some tasks that I give estimates (and actual times which are complete) for. [1]: http://www.joelonsoftware.com/items/2007/10/26.html
|fogbugz|evidence-based-scheduling|
Evidence Based Scheduling Tool
Not sure if this is what you are after but you can [search source code on Google][1]. Follow the link for a search on ['function:reduce() lang:python'][2] on Google Code search At first glance the following projects use <code>reduce()</code> <ul> <li>MoinMoin</li> <li>Zope</li> <li>Numeric</li> <li>ScientificPython</li> </ul> etc. etc... [1]: http://www.google.com/codesearch/ [2]: http://www.google.com/codesearch?q=function%3Areduce()+lang%3Apython&hl=en&btnG=Search+Code
I would have to say that this is pretty bad practice. Whilst some people might be happy to say that looping through the collection is less efficient to throwing an exception, there is an overhead to throwing an exception. I would also question why you are using a collection to access an item by key when you would be better suited to using a dictionary or hashtable. My main problem with this code however, is that regardless of the type of exception thrown, you are always going to be left with the same result. For example, an exception could be thrown because the object doesn't exist in the collection, or because the collection itself is null or because you can't cast myCollect[myObject] to aObject. All of these exceptions will get handled in the same way, which may not be your intention. These are a couple of nice articles on when and where it is usally considered acceptable to throw exceptions: * [Foundations of Programming][1] * [Throwing exceptions in c#][2] I particularly like this quote from the second article: > It is important that exceptions are > thrown only when an unexpected or > invalid activity occurs that prevents > a method from completing its normal > function. Exception handling > introduces a small overhead and lowers > performance so should not be used for > normal program flow instead of > conditional processing. It can also be > difficult to maintain code that > misuses exception handling in this > way. [1]: http://codebetter.com/blogs/karlseguin/archive/2008/05/29/foundations-of-programming-pt-8-back-to-basics-exceptions.aspx [2]: http://www.blackwasp.co.uk/CSharpThrowingExceptions.aspx
In IE. Select View -> Script Debugger -> Open. That should do it.
I like break my classes down into packages that are related to each other. For example: **Model** For database related calls **View** Classes that deal with what you see **Control** Core functionality classes **Util** Any misc. classes that are used (typically static functions) etc.
TechRepublic has a good walk through - [http://blogs.techrepublic.com.com/programming-and-development/?p=672][1] [1]: http://blogs.techrepublic.com.com/programming-and-development/?p=672
Firebug lite doesn't work too well for me. The Developer Toolbar just isn't good enough. There really is no great solution.
Exceptions should be exceptional. Something like 'The collection is missing because the database has fallen out from underneath it' is exceptional Something like 'the key is not present' is normal behaviour for a dictionary. For your specific example of a winforms Control collection, the `Controls` property has a `ContainsKey` method, which is what you're supposed to use. There's no `ContainsValue` because when dealing with dictionaries/hashtables, there's no fast way short of iterating through the entire collection, of checking if something is present, so you're really discouraged from doing that. As for WHY Exceptions should be exceptional, it's about 2 things 1. Indicating what your code is trying to do. You want to have your code match what it is trying to achieve, as closely as possible, so it is readable and maintainable. Exception handling adds a bunch of extra cruft which gets in the way of this purpose 2. Brevity of code. You want your code to do what it's doing in the most direct way, so it is readable and maintainable. Again, the cruft added by exception handling gets in the way of this.
I think the best thing to do here would be one/both of two things: 1. Rethink the design, if its too complex, find a less-complex way. 2. Stop trying to visualise it.. :P Just store the dimensions in question that you need to sum, then do them one at a time. Once you have the base code, then look at improving the efficiency of your algorithm.
These are standard library references. Make sure that all libraries (including the standard library) are using the *same* linkage. E.g. you can't link statically while linking the standard lib dynamically. The same goes for the threading model used. Take special care that you and the 3rd party library use the same linkage options. This can be a real pain in the *ss.
SICP is a great book, but it is difficult when you don't know the Lagrange (as I recall). This is probably my bias, but I thought ocaml was pretty easy to get into. You have the option of programming in a few different styles. Along those lines, I'd recommend python as well. Though, ocaml will get you closer to the syntax of Haskell. I [posted a bunch of links][1] to Haskell and Ocaml references that _are_ books, with examples et cetera that seem right up your alley. If you prefer Lisp, you can try to power through the [99-problems in Lisp][2](which you can do in any language, really), or you can watch the [lectures][3] from the people who wrote SICP. [1]: http://stackoverflow.com/questions/22873/language-referencestutorials-for-popular-languages#22940 [2]: http://www.ic.unicamp.br/~meidanis/courses/mc336/2006s2/funcional/L-99_Ninety-Nine_Lisp_Problems.html [3]: http://video.google.com/videoplay?docid=5546836985338782440
SICP is a great book, but it is difficult when you don't know the Lagrange (as I recall). This is probably my bias, but I thought ocaml was pretty easy to get into. You have the option of programming in a few different styles. Along those lines, I'd recommend python as well. Though, ocaml will get you closer to the syntax of Haskell. F# is another option, I've looked at the code and I can never tell if it is ocaml or not --the comments are a dead giveaway, if present. I [posted a bunch of links][1] to Haskell and Ocaml references that _are_ books, with examples et cetera that seem right up your alley. If you prefer Lisp, you can try to power through the [99-problems in Lisp][2](which you can do in any language, really), or you can watch the [lectures][3] from the people who wrote SICP. Further down the road, get a hold of "[Purely Functional Data Structures][4]", as it'll get into the hard-core deep design and considerations you have to take into account in functional languages --it uses ML (which ocaml derived from). [1]: http://stackoverflow.com/questions/22873/language-referencestutorials-for-popular-languages#22940 [2]: http://www.ic.unicamp.br/~meidanis/courses/mc336/2006s2/funcional/L-99_Ninety-Nine_Lisp_Problems.html [3]: http://video.google.com/videoplay?docid=5546836985338782440 [4]: http://books.google.com/books?id=SxPzSTcTalAC&dq=purely+functional+data+structures
SICP is a great book, but it is difficult when you don't know the Lagrange (as I recall). This is probably my bias, but I thought ocaml was pretty easy to get into. You have the option of programming in a few different styles until you're completely comfortable. Along those lines, I'd recommend python as well. Though, ocaml will get you closer to the syntax of Haskell, and similar functional languages. F# is another option, I've looked at the code and I can never tell if it is ocaml or not --the comments are a dead giveaway, if present. I [posted a bunch of links][1] to Haskell and Ocaml references that _are_ books, with examples et cetera that seem right up your alley. If you prefer Lisp, you can try to power through the [99-problems in Lisp][2](which you can do in any language, really), or you can watch the [lectures][3] from the people who wrote SICP. Further down the road, get a hold of "[Purely Functional Data Structures][4]", as it'll get into the hard-core deep design and considerations you have to take into account in functional languages --it uses ML (which ocaml derived from). [1]: http://stackoverflow.com/questions/22873/language-referencestutorials-for-popular-languages#22940 [2]: http://www.ic.unicamp.br/~meidanis/courses/mc336/2006s2/funcional/L-99_Ninety-Nine_Lisp_Problems.html [3]: http://video.google.com/videoplay?docid=5546836985338782440 [4]: http://books.google.com/books?id=SxPzSTcTalAC&dq=purely+functional+data+structures
>3) Do not match if in the middle of a string (thanks nohat). You can perhaps write a reg ex to check ".\*Boolean.\*". But what if you have quote(") inside the string? So, you have more work to not exclude (\") pattern. >4) Do not match if in a comment. (// or /\* \*/) For '//', you can have a regex to exclude //.* But, better could be to first put a regex to compare the whole line for the // comments ((.\*)(//.\*)) and then apply replacement only on $1 (first matching pattern). For /\* \*/, it is more complex as this is multiline pattern. One approach can be to first run whole of you code to match multiline comments and then take out only the parts not matching ... something like ... (.*)(/\*.\*\*/)(.\*). But, the actual regex would be even more complex as you would have not one but more of multi-line comments. Now, what if you have /\* or \*/ inside // block? (I dont know why would you have it.. but Murphy's law says that you can have it). There is obviously some way out but my idea is to emphasize how bad-looking the regex will become. My suggestion here would be to use some lexical tool for C++ and replace the token Boolean with bool. Your thoughts?
I totally agree with Dallas. Use a case statement - it makes your intent clearer. The synthesis tool will build it as a look-up table (if it's parallel) and will optimise whatever it can. Also, I wouldn't worry so much about keeping your RTL code short. I'd shoot for clarity first. Synthesis tools are cleverer than you think...
Ayende Rahien [uses][1] a static method that is rather simple... public static class SystemTime { public static Func<DateTime> Now = () => DateTime.Now; } [1]: http://www.ayende.com/Blog/archive/2008/07/07/Dealing-with-time-in-tests.aspx
The brand-new version of ASP.NET ([3.5 SP1][1]) has a nifty feature called [CompositeScript][2]. This allows you to use a [ScriptManager][3] to reference lots of tiny little .js files server-side and have them delivered as a single .js file to the client. Good for the client since it only has to download one file. Good for you since you can maintain the files however you want on the server side. <asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="True" runat="server"> <Scripts> <asp:ScriptReference Assembly="SampleControl" Name="SampleControl.UpdatePanelAnimation.js" /> </Scripts> </asp:ScriptManager> [1]: http://msdn.microsoft.com/en-us/vstudio/products/cc533447.aspx [2]: http://msdn.microsoft.com/en-us/library/system.web.ui.compositescriptreference.aspx [3]: http://msdn.microsoft.com/en-us/library/system.web.ui.scriptreference.aspx
To reference something on the stage, you need to give the stage instance a name - not give the symbol in the library a class name. Click on the item on the stage and look at the properties panel. There should be a text entry box just above the entry boxes for the item's dimensions. Enter a name there. Elsewhere in your code, you can then refer to that item on stage by it's instance name.
Building a custom Linux Live CD
|linux|
Can anyone point me to a good tutorial on creating a bootable Linux CD from scratch? I need help with a fairly specialized problem: my firm sells an expansion card that requires custom firmware. Currently we use an extremely old live CD image of RH7.2 that we update with current firmware. Manufacturing puts the cards in a machine, boots off the CD, the CD writes the firmware, they power off and pull the cards. Because of this cycle, it's essential that the CD boot and shut down as quickly as possible. The problem is that with the next generation of cards, I have to update the CD to a 2.6 kernel. It's easy enough to acquire a pre-existing live CD - but those all are designed for showing off Linux on the desktop - which means they take forever to boot. Can anyone fix me up with a current How-To?
How do you handle database exceptions in your application? Are you trying to validate data prior passing it to DB or just relying on DB schema validation logic? Do you try to recover from some kind of DB errors (e.g. timeouts)? Here are some approaches: 1. Validate data prior passing it to DB 2. Left validation to DB and handle DB exceptions properly 3. Validate on both sides 4. Validate some obvious constraints in business logic and left complex validation to DB What approach do you use? Why? **Updates:** I'm glad to see growing discussion. Let’s try to sum up community answers. Suggestion: - Validate on both sides - Check business logic constraint on client side, let DB do integrity checks [from hamishmcn][2] - Check early to avoid bothering DB [from ajmastrean][3] - Check early to improve user experience [from Will][1] - Keep DB interacting code in place to simplify development [from hamishmcn][2] - Object-relational mapping (NHibernate, Linq, etc.) can help you to deal with constrains [from ajmastrean][3] - Client side validation is necessary for security reasons [from Seb Nilsson][4] Do you have anything else to say? [1]: http://stackoverflow.com/questions/39371/database-exception-handling-best-practices#39428 [2]: http://stackoverflow.com/questions/39371/database-exception-handling-best-practices#39406 [3]: http://stackoverflow.com/questions/39371/database-exception-handling-best-practices#39461 [4]: http://stackoverflow.com/questions/39371/database-exception-handling-best-practices#39487
How do you handle database exceptions in your application? Are you trying to validate data prior passing it to DB or just relying on DB schema validation logic? Do you try to recover from some kind of DB errors (e.g. timeouts)? Here are some approaches: 1. Validate data prior passing it to DB 2. Left validation to DB and handle DB exceptions properly 3. Validate on both sides 4. Validate some obvious constraints in business logic and left complex validation to DB What approach do you use? Why? **Updates:** I'm glad to see growing discussion. Let’s try to sum up community answers. Suggestions: - Validate on both sides - Check business logic constraints on client side, let DB do integrity checks [from hamishmcn][2] - Check early to avoid bothering DB [from ajmastrean][3] - Check early to improve user experience [from Will][1] - Keep DB interacting code in place to simplify development [from hamishmcn][2] - Object-relational mapping (NHibernate, Linq, etc.) can help you to deal with constrains [from ajmastrean][3] - Client side validation is necessary for security reasons [from Seb Nilsson][4] Do you have anything else to say? [1]: http://stackoverflow.com/questions/39371/database-exception-handling-best-practices#39428 [2]: http://stackoverflow.com/questions/39371/database-exception-handling-best-practices#39406 [3]: http://stackoverflow.com/questions/39371/database-exception-handling-best-practices#39461 [4]: http://stackoverflow.com/questions/39371/database-exception-handling-best-practices#39487
class A: def _ _init_ _(self): self.name = 'A' a = A() Creates an attribute on the object instance a of type A and it can therefore be found in: `a.__dict__` class B: name = 'B' b = B() Creates an attribute on the class B and the attribute can be found in `B.__dict__` alternatively if you have an instance b of type B you can see the class level attributes in `b.__class__.__dict__`
With the "Built in" stuff, you can't, as using 1.0.* or 1.0.0.* will replace the revision and build numbers with a coded date/timestamp, which is usually also a good way. For more info, see the [Assembly Linker][1] Dicumentation in the /v tag. As for automatically incrementing numbers, use the AssemblyInfo Task: [http://code.msdn.microsoft.com/AssemblyInfoTaskvers][2] This can be configured to automatically increment the build number. There are 2 Gotchas: 1. Each of the 4 numbers in the Version string is limited to 65535. This is a Windows Limitation and unlikely to get fixed. * [http://blogs.msdn.com/msbuild/archive/2007/01/03/why-are-build-numbers-limited-to-65535.aspx][3] 2. Using with with Subversion requires a small change: * [http://www.andrewconnell.com/blog/archive/2006/08/29/4078.aspx][4] Retreiving the Version number is then quite easy: Version v = Assembly.GetExecutingAssembly().GetName().Version; string About = string.Format(CultureInfo.InvariantCulture, @"YourApp Version {0}.{1}.{2} (r{3})", v.Major, v.Minor, v.Build, v.Revision); [1]: http://msdn2.microsoft.com/en-us/library/c405shex(vs.80).aspx [2]: http://code.msdn.microsoft.com/AssemblyInfoTaskvers [3]: http://blogs.msdn.com/msbuild/archive/2007/01/03/why-are-build-numbers-limited-to-65535.aspx [4]: http://www.andrewconnell.com/blog/archive/2006/08/29/4078.aspx
Second the Buildbot - Trac integration. You can find more information about the integration on the <a href="http://buildbot.net/trac/wiki/BuildbotAndTrac">Buildbot website</a>. At my previous job, we wrote and used the plugin they mention (tracbb). What the plugin does is rewriting all of the Buildbot urls so you can use Buildbot from within Trac. (http://example.com/tracbb). The really nice thing about Buildbot is that the configuration is written in Python. You can integrate your own Python code directly to the configuration. It's also very easy to write your own BuildSteps to execute specific tasks. We used BuildSteps to get the source from SVN, pull the dependencies, publish test results to WebDAV, etcetera. I wrote an X10 interface so we could send signals with build results. When the build failed, we switched on a red lava lamp. When the build succeeded, a green lava lamp switched on. Good times :-)
I think you should go for solution 2. There is no 'swap' function in any SQL variant I know of. If you need to do this regularly, I suggest solution 1, depending on how other parts of the software are using this data. You can have locking issues if you're not careful. But in short: there is no other solution than the ones you provided.
It depends on what kind of application you are building. Create a representative test scenario, and start hammering away. Then you will know the definitive answer. Besides your use case, it also depends on CPU, memory, front-side bus, operating system, cache settings, etcetera. Seriously, just test your own scenario. If you need some numbers (that actually may mean nothing in your scenario): - <a href="http://www.oracle.com/technology/products/berkeley-db/pdf/berkeley-db-perf.pdf">Oracle Berkeley DB: Performance Metrics and Benchmarks</a> - <a href="http://staff.rcost.unisannio.it/visaggio/berkleyDB.pdf">Performance Metrics & Benchmarks: Berkeley DB</a>
Encrypting Passwords
Your best researching the most common type of queries that happen on your database and creating indexes based on that research. For example, if there is a table which stores website hits, which is written to very very often but hardly even read from. Then don't index the table in away. If how ever you have a list of users which is access more often than is written to, then I would firstly create a clustered index on the column that is access the most, usually the primary key. I would then create an index on commonly search columns, and those which are use in order by clauses.
The advice you got is right. Try them all, one by one. There is NO substitute for testing when it comes to performance. Unless you prove it, you haven't done anything.
How do I configure a Vista Ultimate (64bit) account so it can access a SMB share on OSX?
|macos|windows-vista|smb|
I have Windows File sharing enabled on an OS X 10.4 computer. It's accessible via \\rudy\myshare for all the Windows users on the network, except for one guy running Vista Ultimate 64-bit edition. All the other users are running Vista or XP, all 32-bit. All the workgroup information is the same, all login with the same username/password. The Vista 64 guy can see the Mac on the network, but his login is rejected every time. Now, I imagine that Vista Ultimate is has something configured differently to the Business version and XP but I don't really know where to look. Any ideas?
It all depends on the problem you're trying to solve. Obviously you can solve any problem in either style (procedural or OO), but you usually can figure out in the planning stages before you start writing code which style suits you better. Some people like to write up use cases and if they see a lot of the same nouns showing up over and over again (e.g., a person withdraws money from the bank), then they go the OO route and use the nouns as their objects. Conversely, if you don't see a lot of nouns and there's really more verbs going on, then procedural or functional may be the way to go. Steve Yegge has a [great but long post][1] as usual that touches on this from a different perspective that you may find helpful as well. [1]: http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html
The word on the street is that unless you are a database vendor trying to prove that your database can do it (like, let's say Microsoft boasting about Terraserver storing a bajillion images in SQL Server) it's not a very good idea. When the alternative - storing images on file servers and paths in the database is so much easier, why bother? Blob fields are kind of like the off-road capabilities of SUVs - most people don't use them, those who do usually get in trouble, and then there are those who do, but only for the fun of it.
The restful_authentication plugin has a good implementation of this: <http://agilewebdevelopment.com/plugins/restful_authentication>
In my opinion, it is better to make the version number part of the file itself. e.g. myscript.1.2.3.js You can set your webserver to cache this file forever, and just add a new js file when you have a new version.
It's an often-asked question. There's an [ASPN Cookbook][1] entry on it that has served me in the past. And there is an [extensive page of requirements one person would like to see from a module doing this.][2] [1]: http://code.activestate.com/recipes/113799/ [2]: http://wiki.python.org/moin/BitManipulation
Another option would be to infer the time zone from the user agent's country preference. This is a somewhat crude method (won't work for en-US), but makes a good approximation.
If you happen to be using ([OpenID][1]) for authentication, [Simple Registration Extension][2] would solve the problem for authenticated users (You'll need to convert from tz to numeric). Another option would be to infer the time zone from the user agent's country preference. This is a somewhat crude method (won't work for en-US), but makes a good approximation. [1]: http://openid.net/ [2]: http://openid.net/specs/openid-simple-registration-extension-1_0.html
If you happen to be using [OpenID][1] for authentication, [Simple Registration Extension][2] would solve the problem for authenticated users (You'll need to convert from tz to numeric). Another option would be to infer the time zone from the user agent's country preference. This is a somewhat crude method (won't work for en-US), but makes a good approximation. [1]: http://openid.net/ [2]: http://openid.net/specs/openid-simple-registration-extension-1_0.html
According to the [TortoiseHg FAQ][1] the context menus will work in 64-bit Vista if you use a third-party 32-bit file manager, like [FreeCommander][2] or [TotalCommander][3]. There's no mention of a workaround to get them to work with Windows Explorer though. [1]: http://tortoisehg.wiki.sourceforge.net/FAQ [2]: http://www.freecommander.com [3]: http://www.ghisler.com/
<section name="AppNameConfiguration" type="AppName.SystemBase.AppNameConfiguration, SystemBase"/> The custom section is supposed to have a class that defines how the various configuration data can be managed, (This is in the Type section). Is this class not available for you to examine? MSDN has a decent explanation of how to create custom configuration sections in VB that may be helpful to you: http://msdn.microsoft.com/en-us/library/2tw134k3.aspx
Does git have anything like `svn propset`?
|version-control|git|svn|
Browsing through the git documentation, I can't see anything analogous to SVN's commit hooks or the "propset" features that can, say, update a version number or copyright notice within a file whenever it is committed to the repository. Are git users expected to write external scripts for this sort of functionality (which doesn't seem out of the question) or have I just missed something obvious?