instruction
stringlengths
0
30k
In .NET 2.0 you have to code this yourself. It involves researching daylight savings time laws in various regions and building that into your own data structures. The problem is somewhat simplified if you only care about a subset of time zones, for example just in the USA, but if you need all global time zones, you have a lot of work to do, and then the code has to be updated every few years when the laws change. Even the new time zone objects in the latest version of .NET will require windows updates to keep them correct as laws change. Look [here][1], [here][2], and [here][3] for more info. [1]: http://aa.usno.navy.mil/faq/docs/daylight_time.php [2]: http://en.wikipedia.org/wiki/Daylight_saving_time [3]: http://www.timeanddate.com/time/aboutdst.html
It looks like this has been reported as a [Java bug](http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6442982). It appears to be caused by using annotations from a 3rd party library (like JUnit) and not including the jar with that annotation in the javadoc invocation. If that is the case, just use the -classpath option on javadoc and include the extra jar files.
Try the [Web Developer Plugin](https://addons.mozilla.org/en-US/firefox/addon/60) for Firefox. Specifically, the **Information -> Display Block Size** and **Outline -> Outline Block Level Elements** options. This will allow to see the borders of your elements, and their size as Firefox sees them.
I'm getting a java.lang.ClassCastException when generating javadocs. Any ideas?
|java|javadoc|ant|
I'm using ant to generate the javadocs, but it gets this exception over and over. Any help would be appreciated. [javadoc] java.lang.ClassCastException: com.sun.tools.javadoc.ClassDocImpl cannot be cast to com.sun.javadoc.AnnotationTypeDoc [javadoc] at com.sun.tools.javadoc.AnnotationDescImpl.annotationType(AnnotationDescImpl.java:46) [javadoc] at com.sun.tools.doclets.formats.html.HtmlDocletWriter.getAnnotations(HtmlDocletWriter.java:1739) [javadoc] at com.sun.tools.doclets.formats.html.HtmlDocletWriter.writeAnnotationInfo(HtmlDocletWriter.java:1713) [javadoc] at com.sun.tools.doclets.formats.html.HtmlDocletWriter.writeAnnotationInfo(HtmlDocletWriter.java:1702) [javadoc] at com.sun.tools.doclets.formats.html.HtmlDocletWriter.writeAnnotationInfo(HtmlDocletWriter.java:1681) [javadoc] at com.sun.tools.doclets.formats.html.FieldWriterImpl.writeSignature(FieldWriterImpl.java:130) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.FieldBuilder.buildSignature(FieldBuilder.java:184) [javadoc] at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source) [javadoc] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [javadoc] at java.lang.reflect.Method.invoke(Method.java:597) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.FieldBuilder.invokeMethod(FieldBuilder.java:114) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:90) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.AbstractMemberBuilder.build(AbstractMemberBuilder.java:56) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.FieldBuilder.buildFieldDoc(FieldBuilder.java:158) [javadoc] at sun.reflect.GeneratedMethodAccessor51.invoke(Unknown Source) [javadoc] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [javadoc] at java.lang.reflect.Method.invoke(Method.java:597) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.FieldBuilder.invokeMethod(FieldBuilder.java:114) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:90) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.AbstractMemberBuilder.build(AbstractMemberBuilder.java:56) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.buildFieldDetails(ClassBuilder.java:301) [javadoc] at sun.reflect.GeneratedMethodAccessor43.invoke(Unknown Source) [javadoc] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [javadoc] at java.lang.reflect.Method.invoke(Method.java:597) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.invokeMethod(ClassBuilder.java:101) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:90) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.buildClassDoc(ClassBuilder.java:124) [javadoc] at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source) [javadoc] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [javadoc] at java.lang.reflect.Method.invoke(Method.java:597) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.invokeMethod(ClassBuilder.java:101) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:90) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.build(ClassBuilder.java:108) [javadoc] at com.sun.tools.doclets.formats.html.HtmlDoclet.generateClassFiles(HtmlDoclet.java:155) [javadoc] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.generateClassFiles(AbstractDoclet.java:164) [javadoc] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:106) [javadoc] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.start(AbstractDoclet.java:64) [javadoc] at com.sun.tools.doclets.formats.html.HtmlDoclet.start(HtmlDoclet.java:42) [javadoc] at com.sun.tools.doclets.standard.Standard.start(Standard.java:23) [javadoc] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [javadoc] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [javadoc] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [javadoc] at java.lang.reflect.Method.invoke(Method.java:597) [javadoc] at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:215) [javadoc] at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:91) [javadoc] at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:340) [javadoc] at com.sun.tools.javadoc.Start.begin(Start.java:128) [javadoc] at com.sun.tools.javadoc.Main.execute(Main.java:41) [javadoc] at com.sun.tools.javadoc.Main.main(Main.java:31)
|java|ant|javadoc|
I'm using ant to generate the javadocs, but it gets this exception over and over. Any help would be appreciated. Jdk 1.6.0_06 [javadoc] java.lang.ClassCastException: com.sun.tools.javadoc.ClassDocImpl cannot be cast to com.sun.javadoc.AnnotationTypeDoc [javadoc] at com.sun.tools.javadoc.AnnotationDescImpl.annotationType(AnnotationDescImpl.java:46) [javadoc] at com.sun.tools.doclets.formats.html.HtmlDocletWriter.getAnnotations(HtmlDocletWriter.java:1739) [javadoc] at com.sun.tools.doclets.formats.html.HtmlDocletWriter.writeAnnotationInfo(HtmlDocletWriter.java:1713) [javadoc] at com.sun.tools.doclets.formats.html.HtmlDocletWriter.writeAnnotationInfo(HtmlDocletWriter.java:1702) [javadoc] at com.sun.tools.doclets.formats.html.HtmlDocletWriter.writeAnnotationInfo(HtmlDocletWriter.java:1681) [javadoc] at com.sun.tools.doclets.formats.html.FieldWriterImpl.writeSignature(FieldWriterImpl.java:130) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.FieldBuilder.buildSignature(FieldBuilder.java:184) [javadoc] at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source) [javadoc] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [javadoc] at java.lang.reflect.Method.invoke(Method.java:597) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.FieldBuilder.invokeMethod(FieldBuilder.java:114) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:90) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.AbstractMemberBuilder.build(AbstractMemberBuilder.java:56) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.FieldBuilder.buildFieldDoc(FieldBuilder.java:158) [javadoc] at sun.reflect.GeneratedMethodAccessor51.invoke(Unknown Source) [javadoc] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [javadoc] at java.lang.reflect.Method.invoke(Method.java:597) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.FieldBuilder.invokeMethod(FieldBuilder.java:114) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:90) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.AbstractMemberBuilder.build(AbstractMemberBuilder.java:56) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.buildFieldDetails(ClassBuilder.java:301) [javadoc] at sun.reflect.GeneratedMethodAccessor43.invoke(Unknown Source) [javadoc] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [javadoc] at java.lang.reflect.Method.invoke(Method.java:597) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.invokeMethod(ClassBuilder.java:101) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:90) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.buildClassDoc(ClassBuilder.java:124) [javadoc] at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source) [javadoc] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [javadoc] at java.lang.reflect.Method.invoke(Method.java:597) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.invokeMethod(ClassBuilder.java:101) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:90) [javadoc] at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.build(ClassBuilder.java:108) [javadoc] at com.sun.tools.doclets.formats.html.HtmlDoclet.generateClassFiles(HtmlDoclet.java:155) [javadoc] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.generateClassFiles(AbstractDoclet.java:164) [javadoc] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:106) [javadoc] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.start(AbstractDoclet.java:64) [javadoc] at com.sun.tools.doclets.formats.html.HtmlDoclet.start(HtmlDoclet.java:42) [javadoc] at com.sun.tools.doclets.standard.Standard.start(Standard.java:23) [javadoc] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [javadoc] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [javadoc] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [javadoc] at java.lang.reflect.Method.invoke(Method.java:597) [javadoc] at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:215) [javadoc] at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:91) [javadoc] at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:340) [javadoc] at com.sun.tools.javadoc.Start.begin(Start.java:128) [javadoc] at com.sun.tools.javadoc.Main.execute(Main.java:41) [javadoc] at com.sun.tools.javadoc.Main.main(Main.java:31)
Unless I'm missing something, `','.join(foo)` should do what you're asking for. >>> ','.join(['']) '' >>> ','.join(['s']) 's' >>> ','.join(['a','b','c']) 'a,b,c'
Unless I'm missing something, `','.join(foo)` should do what you're asking for. >>> ','.join(['']) '' >>> ','.join(['s']) 's' >>> ','.join(['a','b','c']) 'a,b,c' (edit: and as jmanning2k points out, ','.join([str(x) for x in foo]) is safer and quite Pythonic, though the resulting string will be difficult to parse if the elements can contain commas -- at that point, you need the full power of the `csv` module, as Douglas points out in his answer.)
I'd rather tab indentation not work than breaking tabbing between form items. If you want to indent to put in code in the Markdown box, use Ctrl+K (or ⌘K on a Mac). In terms of actually stopping the action, jQuery (which Stack Overflow uses) will stop an event from bubbling when you return false from an event callback. This makes life easier for working with multiple browsers.
I would advise against changing the default behaviour of a key. I do as much as possible without touching a mouse, so if you make my tab key not move to the next field on a form I will be very aggravated. A shortcut key could be useful however, especially with large code blocks and nesting. Shift-TAB is a bad option because that normally takes me to the previous field on a form. Maybe a new button on the WMD editor to insert a code-TAB, with a shortcut key, would be possible?
You don't have to get out of Ruby to do this, can use the Base64 module in Ruby to encode the document like this: irb(main):005:0> require 'base64' => true irb(main):007:0> Base64.encode64("Hello World") => "SGVsbG8gV29ybGQ=\n" irb(main):008:0> Base64.decode64("SGVsbG8gV29ybGQ=\n") => "Hello World" And you can call gzip/gunzip using Kernel#system: system("gzip foo.something") system("gunzip foo.something.gz")
MAC addresses in JavaScript
|javascript|
I know that we can get the MAC address of a user via IE (ActiveX objects). Is there a way to do the same thing in all browsers? (Especially since FF is gaining browser share everyday!)
I guess it depends what database you're using, but Red Gate ([www.red-gate.com][1]) make a tool called SQL Data Generator. This can be configured to fill your database with sensible looking test data. You can also tell it to always use the same seed in its random number generator so your 'random' data is the same every time. You can then write your unit tests to make use of this reliable, repeatable data. As for testing the web side of things, I'm currently looking into Selenium ([selenium.openqa.org][2]). This appears to be a cross-browser capable test suite which will help you test functionality. However, as with all of these web site test tools, there's no real way to test how well these things *look* in all of the browsers without casting a human eye over them! [1]: www.red-gate.com [2]: selenium.openqa.org
The quick and simple answer is No. Javascript is quite a high level language and does not have access to this sort of information.
If this is for an intranet application and all of the clients use DHCP, you can query the DHCP server for the MAC address for a given IP address.
IE 8 is supposed to have better tools, but the IE Developer Toolbar is pretty good: <http://www.microsoft.com/downloads/details.aspx?FamilyId=E59C3964-672D-4511-BB3E-2D5E1DB91038&displaylang=en>
You might find [Firebug Lite][1] useful for that. Its bookmarklet should be especially useful when debugging on a user's machine. [1]: http://getfirebug.com/lite.html
Try it using SQL. - [CREATE FULLTEXT CATALOG][1] - [ALTER FULLTEXT CATALOG][2] Here's an example from Microsoft. --Change to accent insensitive USE AdventureWorks; GO ALTER FULLTEXT CATALOG ftCatalog REBUILD WITH ACCENT_SENSITIVITY=OFF; GO -- Check Accentsensitivity SELECT FULLTEXTCATALOGPROPERTY('ftCatalog', 'accentsensitivity'); GO --Returned 0, which means the catalog is not accent sensitive. [1]: http://msdn.microsoft.com/en-us/library/ms189520%28SQL.90%29.aspx [2]: http://msdn.microsoft.com/en-us/library/ms176095%28SQL.90%29.aspx
Can UDP data be delivered corrupted?
|c++|networking|udp|
Is it possible for UDP data to come to you corrupted? I know it is possible for it to be lost.
GODI installation issue
|linux|ocaml|godi|
I'm trying to install [GODI][1] on linux (Ubuntu). It's a library management tool for the ocaml language. I've actually installed this before --twice, but awhile ago-- with no issues --that I can remember-- but this time I just can't figure out what I'm missing. $ ./bootstrap --prefix <<path>>/godi $ ./bootstrap_stage2 .: 1: godi_confdir: not found Error: Command fails with code 2: /bin/sh Failure! I had added the proper directories to the path, and they show up with a quick `echo $path`, and `godi_confdir` reported as being: $ godi_confdir <<path>>/godi/etc (...and the directory exists, with the godi.conf file present). So, I can't figure out why `./bootstrap_stage2` isn't working. [1]: http://godi.camlcity.org/godi/index.html
I'm trying to install [GODI][1] on linux (Ubuntu). It's a library management tool for the ocaml language. I've actually installed this before --twice, but awhile ago-- with no issues --that I can remember-- but this time I just can't figure out what I'm missing. $ ./bootstrap --prefix /home/nlucaroni/godi $ ./bootstrap_stage2 .: 1: godi_confdir: not found Error: Command fails with code 2: /bin/sh Failure! I had added the proper directories to the path, and they show up with a quick `echo $path`, and `godi_confdir` reported as being: /home/nlucaroni/godi/etc (...and the directory exists, with the godi.conf file present). So, I can't figure out why `./bootstrap_stage2` isn't working. [1]: http://godi.camlcity.org/godi/index.html
UDP is slightly quicker in my experience, but not by much. The choice shouldn't be made on performance but on the message content and compression techniques. If it's a protocol with message *exchange*, I'd suggest that the very slight performance hit you take with TCP is more than worth it. You're given a connection between two end points that will give you everything you need. Don't try and manufacture your own reliable two-way protocol on top of UDP unless you're really, really confident in what you're undertaking.
Each TCP connection requires an initial handshake before data is transmitted. Also, the TCP header contains a lot of overhead intended for different signals and message delivery detection. For a message exchange, UDP will probably suffice if a small chance of failure is acceptable. If receipt must be verified, TCP is your best option.
I'm the lead developer on an enterprise document management system in which some customers store hundreds of gigabytes of documents. Terabytes in the not too distant future. We use the **file system** approach for many of the reasons mentioned on this page plus another: archiving. Many of our customers must conform to industry specific archival rules, such as storage to optical disk or storage in a non-proprietary format. Plus, you have the flexibility of simply adding more disks to a NAS device. If you have your files stored in your database, even with SQL Server 2008's file stream data type, your archival options just became a whole lot narrower.
G'day, As a quick answer I would say to come up with a series of categories and have switchable logging levels, e.g. info, warning, error, critical, etc. Then make it easy to set the logging level to tune the level of detail that you need. Typically, set the logging level in a config file and stop and restart the app. I would also pulicise to the dvelopers what the meaning is for each of the levels. edit: I would also set up a system to rotate out, compress and archive log files on a regular basis, maybe nightly. cheers, Rob
I'm afraid there is no way you can do it without PInvoke. To give focus to some window you should call SetForegroundWindow function, see [this][1] article for details. [1]: http://www.codeproject.com/KB/cs/windowhider.aspx
For *persistence.xml*, specifically, you can put a persistence unit in a separate JAR, which you can deploy separately from your web application WAR, or both together in an EAR archive, depending on what your application server supports. For example, the JBoss manual describes this as [Deploy EAR with EJB3 JAR][1]. For *struts-config.xml* I expect that you are going to have to override the Struts code that loads it, if you want to use a non-standard location. I don't know about the Velocity templates. In general, web applications only load resources from within the WAR, for security reasons. There are other techniques you can use, but you may find it easier to try [weblets][2], which seems to be a framework designed to let you load resources from a separate JAR. [1]: http://www.jboss.org/file-access/default/members/jbossas/freezone/docs/Server_Configuration_Guide/beta422/html/ch01s04s02.html [2]: https://weblets.dev.java.net/
Embed audio object in infopath
|infopath|moss|sharepoint|
Is it possible to embed an audio object (mp3, wma, whatever) in a web-enabled infopath form? If it is, how do you do it?
|infopath|moss|sharepoint|audio|
Can an audio object be embedded in an InfoPath form ?
|sharepoint|audio|moss|infopath|
Is it possible to embed an audio object (mp3, wma, whatever) in a web-enabled InfoPath form ? If it is, how do you do it ?
Comparison of Lat, Long Coordinates
I used the draggable search in Spy++ (installed with VS) to look at the split open button on the file-open dialog of VS. This revealed that it's an ordinary windows button with a style which includes BS_DEFSPLITBUTTON. That's a magic keyword which gets you to some interesting places, including http://www.codeplex.com/windowsformsaero/SourceControl/FileView.aspx?itemId=212902&changeSetId=9930 and here http://msdn.microsoft.com/en-us/library/bb775949.aspx#using_splits Hope this helps you. EDIT: I've actually just tried that code from CodePlex and it does create a split button - but you do have to make sure you've set the button's FlatStyle to 'System' rather than 'Standard' which is the default. I've not bothered to hook-up the event handling stuff for the drop-down, but that's covered in the MSDN link, I think. Of course, this is Vista-only (but doesn't need Aero enabled, despite the name on codeplex) - if you need earlier OS support, you'll be back to drawing it yourself.
I usually create a repository and use that to save my entity, then retrieve a fresh one. Then I assert that the retrieved is equal to the saved.
What kind of scrpt generation are you talking about now?, generating create scripts from the objects in the database is way faster in SSMS compared to EM. But if you are running an select or something that gives you lots of rows in the grid, it is crazy slow.. like scripts generating inserts statements of all rows in an table, if you got lots of data, it is almost not doable.
> Don't tell me -- the functions don't > have any naming convention that tells > you which include file has their > implementation... That brings back > memories (shudder)... How did you guess? ;) > I hope you have weighed the upgrade > you are doing against just rewriting > from scratch -- as long as you are not > intending to extend the app too much > and you are not primarily responsible > for maintaining the app, upgrading a > complex workflow-based app like you > are doing may be cheaper and a better > choice than rewriting it from scratch. > ASP.NET should give you better > opportunities to improve performance > and scalability, at least, than > Classic ASP. From your question I > imagine that it is too late in the > process for that discussion anyway. This was something we talked about. Based on timing (trying to beat a competitor's site to launch) and resources (basically two developers) it made sense to not nuke the site from orbit. Things have actually gone much better than I expected. We were aware even from the planning stages that this code was going to give us the most problems. You should see the revision history of the classic ASP pages involved, it's a bloodbath. > For larger files, I'd try to get a > higher level view first. For example, > one thing I've noticed is that Classic > ASP was horrible about function calls. > You'd be reading through some code and > find a call to a function with no clue > as to where it might be implemented. > As a result, Classic ASP code tended > to have long functions and scripts to > avoid those nasty jumps. I remember > seeing a function that printed out to > 40 pages! Parsing straight through > that much code is no fun. I've actually had this displeasure of working with the legacy code quite a bit so I have a decent high level understanding of the system. You're right about the function length, there are some routines (most I've refactored down into much smaller ones) that are 3-4x as long as any of the aspx pages/helper classes/ORMs on the new site.
If you are not doing a merge in SQL 2008 you must change it to: if @@rowcount = 0 and @@error=0 otherwise if the update fails for some reason then it will try and to an insert afterwards because the rowcount on a failed statement is 0
Try this: var distinctFooBars = (from foo in foos select foo.Bar).Distinct().ToArray();
Take a look at HttpWebRequest. You should be able to construct a request to the URL in question using HttpWebRequest.Method = "POST".
Is Java pass by reference?
|java|programming-languages|reference|
I always thought Java was pass by reference, however I've seen a couple of blog posts that claim it's not. I don't think I understand the distinction they're making. Could someone explain it please? e.g. [This blog][1] [1]: http://javadude.com/articles/passbyvalue.htm
Look into using a [numbers table][1]. While it can be hackish, it's the best method I've come by to quickly query missing data, or show all dates, or anything where you want to examine values within a range, regardless of whether all values in that range are used. [1]: http://andre-silva-cardoso.blogspot.com/2007/11/sql-trickspatterns-1-numbers-table.html
Based on the info [here][1], I'd recommend going with HashMap. I think the biggest advantage is that Java will prevent you from modifying it while you are iterating over it, unless you do it through the iterator. [1]: http://www.jguru.com/faq/view.jsp?EID=430247
Optimizing Conway's 'Game of Life'
|language-agnostic|performance|algorithm|
To experiment, I've (long ago) implemented Conway's [Game of Life][1] (and I'm aware of [this][2] related question!). My implementation worked by keeping 2 arrays of booleans, representing the 'last state', and the 'state being updated' (the 2 arrays being swapped at each iteration). While this is reasonably fast, I've often wondered about how to optimize this. One idea, for example, would be to precompute at iteration N the zones that *could* be modified at iteration (N+1) (so that if a cell does not belong to such a zone, it won't even be considered for modification at iteration (N+1)). I'm aware that this is very vague, and I never took time to go into the details... Do you have any ideas (or experience!) of how to go about optimizing (for speed) Game of Life iterations? [1]: http://en.wikipedia.org/wiki/Conway's_Game_of_Life [2]: http://stackoverflow.com/questions/1823/writing-a-conways-game-of-life-program
Have you tried the WebClient class? An example might look like: WebClient client = new WebClient(); NameValueCollection data = new NameValueCollection(); data["var1"] = "var1"; client.UploadValues("http://somewhere.com/api", "POST", data);
If a process "doesn't come back", I recommend [strace][1] to analyze how a process is interacting with the operating system. In case of <tt>ls</tt>: $strace ls you would have seen that it reads all directory entries ([getdents(2)][2]) before it actually outputs anything. (sorting… as it was already mentioned here) [1]: http://linux.die.net/man/1/strace [2]: http://linux.die.net/man/2/getdents
How do you OCR an tiff file using Tesseract's interface in c#? Currently I only know how to do it using the executable.
Yes it's possible. In the project properties you can target different versions of the .Net Framework going back to .NET 2.0. Upgrading to VS 2008 will upgrade your Solution file and you won't be able to go back to VS 2005 unless you have backed up your solution
You could also use [Outlook Redemption][1], which is supported from managed code; I'm not immediately sure if it has a simple MAPISendDocuments replacement, but Dmitry's helpful if you have questions. As for "crashes and burns", here's another quote from an MS support guy, [here][2] > It's the sort of thing that'll mostly work. It'll work while you're writing it. Then it'll work while you're testing it. It'll work while your customer is evaluating it. Then as soon as the customer deploys it - BAM! That's when it'll decide to start having problems. And Microsoft ain't gonna help you with it, since we told you not to do it in the first place. :) [1]: http://www.dimastr.com/redemption/ [2]: http://groups.google.com/group/microsoft.public.win32.programmer.messaging/msg/20149ae3de2f4920?hl=en&
Actually, VB6 implements [RAII](http://en.wikipedia.org/wiki/RAII) just like C++ meaning that locally declared references automatically get set to `Nothing` at the end of a block. Similarly, it *should* automatically reset member class variables after executing `Class_Terminate`. However, there have been several reports that this is not done reliably. I don't remember any rigorous test but it has always been best practice to reset member variables manually.
Moving from Visual Studio 2005 to 2008 and .NET 2.0
|c#|visual-studio|.net|
I'm currently using VS2005 Profesional and .NET 2.0, and since our project is rather large (25 projects in the solution), I'd like to try VS 2008, since its theoretically faster with larger projects. Before doing such thing, i'd like to know if what I've read is true: can I use VS2008 in ".net 2.0" mode? I don't want my customers to install .net 3.0 or .3.5, I just want to install VS2008, open my solution and start working from there. Is this possible? P.D.: the solution is a c# Window Forms project.
|c#|.net|visual-studio|.net-3.5|.net-2.0|
I would take a look at Main Concept's Reference SDK: http://www.mainconcept.com/site/developer-products-6/pc-based-sdks-20974/reference-sdk-21221/information-21243.html It is built for transcoding and, since it is a licensed SDK it doesn't have any of the legal issues surrounding ffmpeg/libavcodec.
Yes, the feature that enables this is Visual Studio 2008 is called multi-targeting. See [this link][1] for more information. To use it you simply open the Properties for your Project, and select the Target Framework you want from the drop-down list on that page. [1]: http://weblogs.asp.net/scottgu/archive/2007/06/20/vs-2008-multi-targeting-support.aspx
JQuery has animation, but I don't know what it is like on a Mac (I don't have a mac). If things are going slow, then you are probably making the animations too complicated. Remember, JavaScript is a slow language, and DOM is not designed for animation, so try to limit yourself with respect to the number of animations at the same time. Always ask if the animation is really necessary.
Well, for starters you could use CSS Transformations if the application is Safari-specific. Otherwise JQuery got some built in animations and a big community behind it (and thus, a large plugin repository).
How to profile a rails controller action
|ruby|ruby-on-rails|
What is the best way to profile a controller action in Ruby on Rails. Currently I am using the brute-force method of throwing in "puts Time.now" calls between what I think will be a bottleneck. But that feels really, really dirty. There has got to be a better way.
SSIS: Adding a constant column value when doing a CSV to SQL conversion
|sql-server|csv|ssis|
I am reading in CSV file and translating it to a SQl Table. The kicker is that one of the columns in the table is a type ID that needs to be set to a constant (in this case 2). I am not sure how to do this.
If you call volume to the service gets up too high, you should definitely consider getting your own set of postal data. In most cases, that will provide all of the information that you need, and there are plenty of db tools for indexing location data (i.e. PostGIS for PostgreSQL).
Essentially, yes. I was not sure you could do it like that (current version does not do it like that). When using the python install script, however, there is no option (that I can find) to specify where to put directories and files (eg --prefix). I was hoping to match the current layout of python related files so as to avoid 'polluting' my machine with redundant files.
This is a [Lisp FAQ][1] (slightly adapted): > **\*\*\* How do I make an executable from my programme?** > This depends on your implementation; you will need to consult your vendor's documentation. > - With ECL and GCL, the standard compilation process will produce a native executable. > - With LispWorks, see the *Delivery User's Guide* section of the documentation. > - With Allegro Common Lisp, see the *Delivery* section of the manual. > - etc... > However, the classical way of interacting with Common Lisp programs does not involve standalone executables. Let's consider this during two phases of the development process: programming and delivery. > *Programming phase*: Common Lisp development has more of an incremental feel than is common in batch-oriented languages, where an edit-compile-link cycle is common. A CL developer will run simple tests and transient interactions with the environment at the REPL (or Read-Eval-Print-Loop, also known as the *listener*). Source code is saved in files, and the build/load dependencies between source files are recorded in a system-description facility such as ASDF (which plays a similar role to *make* in edit-compile-link systems). The system-description facility provides commands for building a system (and only recompiling files whose dependencies have changed since the last build), and for loading a system into memory. > Most Common Lisp implementations also provide a "save-world" mechanism that makes it possible to save a snapshot of the current lisp image, in a form which can later be restarted. A Common Lisp environment generally consists of a relatively small executable runtime, and a larger image file that contains the state of the lisp world. A common use of this facility is to dump a customized image containing all the build tools and libraries that are used on a given project, in order to reduce startup time. For instance, this facility is available under the name EXT:SAVE-LISP in CMUCL, SB-EXT:SAVE-LISP-AND-DIE in SBCL, EXT:SAVEINITMEM in CLISP, and CCL:SAVE-APPLICATION in OpenMCL. Most of these implementations can prepend the runtime to the image, thereby making it executable. > *Application delivery*: rather than generating a single executable file for an application, Lisp developers generally save an image containing their application, and deliver it to clients together with the runtime and possibly a shell-script wrapper that invokes the runtime with the application image. On Windows platforms this can be hidden from the user by using a click-o-matic InstallShield type tool. [1]: http://code.google.com/p/lispfaq/
Well, MSBuild is built in, so if you are doing something simple, then yes, it is recommended. But for something like nightly builds, I would suggest [FinalBuilder][1]. See this [question on Build/Configuration Management Tools.][2] [1]: http://finalbuilder.com [2]: http://stackoverflow.com/questions/672/which-build-configuration-management-tool#830
You can override the path by setting the environmental variable LD_LIBRARY_PATH. However I would suggest changing the system paths as well so you don't have to change the library path for all users. This can be done using crel. crel -l -c /var/ld/ld.config -l /usr/lib:/usr/local/lib:/opt/gnu/lib For the includes just add -I/opt/gnu/include to your CFLAGS variable.
I believe you need to add the following to the Makefile: CFLAGS += -I/opt/gnu/include LDFLAGS += -L/opt/gnu/lib -R/opt/gnu/lib The -I argument tell gcc where to find the include files. The -L flag tells ld where to find the libraries while linking. The -R flag writes /opt/gnu/lib into the library search path in the quadrupel binary, so it can find its libraries when it starts.
I don't know about the SEO aspect of this (because I never can tell the mambo jambo from the real deal). But as Douglas Crockford pointed out in one of his javascript webcasts the browser always stops for parsing the script, at each <script> element. So, if possible, I'd rather deliver the whole document and enhance the page as late as possible with scripts anyway. Something like <pre> &lt;head> --stylesheets-- &lt;/head> &lt;body> Lorem ipsum dolor ... ... &lt;script src="theFancyStuff.js">&lt;/script> &lt;/body></pre>
UDP used a 16 bit checksum. It is not impossible for it to have corruption, but it's pretty unlikely. In any case it is not more susceptible for corruption than TCP.
I use two search engines: [IconFinder][1] and [IconLook][2]. If you can't find what you want, this [blog post][3] has a list of great resources. [1]: http://www.iconfinder.net/index.php?q=file [2]: http://www.iconlook.com/search.icon?q=file&s12=on&s16=on&s22=on&s32=on&s48=on&s64=on&s128=on [3]: http://speckyboy.com/2008/03/04/top-40-free-icon-resources-for-web-designers-updated-speckyboy/
It is worth noting that sometimes you do want non-configurable "hard-coded" numbers in your code. There are a number of [famous ones][1] including 0x5F3759DF which is used in the optimized inverse square root algorithm. In the rare cases where I find the need to use such Magic Numbers, I set them as a const in my code, and document why they are used, how they work, and where they came from. [1]: http://en.wikipedia.org/wiki/Magic_number_(programming)
The way the FogBugz screenshot setup tool does this is that it appends a 256 byte block at the end of the setup program at the moment it is downloaded. In other words, the download script spits out all the bytes from setup.exe and then an extra 256 with the url for the FogBugz server, plus any padding. Windows ignores these extra bytes when the .exe is run (provided you turned off the CRC check for your setup installer - we're using [InnoSetup][1]). After installation, we run the Screenshot program with a command line switch that tells it where the setup installer is. It looks at the end of the setup.exe and finds it's info, and then writes that to the registry so the user doesn't have to know it. [1]: http://www.innosetup.com
The latest iPhone OS Programming Guide has a full section on this, with sample code. I am sure this is a recent addition, so maybe you missed it. It explains all the conditions you have to comply with; basically... - set the Info.plist properties (this changes the position of the status bar, but not the view) - rotate your view manually around its center, on either your UIViewController viewDidLoad: method or your applicationDidFinishLaunching: method or implement auto rotation ("Autoresizing behaviors", page 124) Look for "Launching in Landscape Mode", page 102.
The MSDN Documentation seems to miss one thing though, I had to set the content type manually, but otherwise, it works like a charm :-) MailMessage msg = new MailMessage(username, nu.email, subject, body); msg.BodyEncoding = Encoding.UTF8; msg.SubjectEncoding = Encoding.UTF8; AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlContent); htmlView.ContentType = new System.Net.Mime.ContentType("text/html"); msg.AlternateViews.Add(htmlView);
@jmanning2k using a list comprehension has the downside of creating a new temporary list. The better solution would be using itertools.imap which returns an iterator from itertools import imap l = [1, "foo", 4 ,"bar"] ",".join(imap(str, l))
Really you're only doing four calculations, so ***readability seems way more important*** here than efficiency. My approach to make something like this more readable is to 1. Extract common code to a function 2. Put similar calculations together to make the patterns more obvious 3. Get rid of the intermediate variable print_zeroes and be explicit about the cases in which you output bytes even if they're zero (i.e. the preceding byte was non-zero) I've changed the random code block into a function and changed a few variables (underscores are giving me trouble in the markdown preview screen). I've also assumed that *bytes* is being passed in, and that whoever is passing it in will pass us a pointer so we can modify it. Here's the code: /* append byte b to stream, increment index */ /* really needs to check length of stream before appending */ void output( int i, unsigned char b, char stream[], int *index ) { printf("", i, b); stream[(*index)++] = b; } void answer( char bytestream[], unsigned int *bytes, unsigned int n) { /* mask out four bytes from word n */ first = (n & 0xFF000000) >> 24; second = (n & 0x00FF0000) >> 16; third = (n & 0x0000FF00) >> 8; fourth = (n & 0x000000FF) >> 0; /* conditionally output each byte starting with the */ /* first non-zero byte */ if (first) output( 1, first, bytestream, bytes); if (first || second) output( 2, second, bytestream, bytes); if (first || second || third) output( 3, third, bytestream, bytes); if (first || second || third || fourth) output( 4, fourth, bytestream, bytes); } Ever so slightly more efficient, and ***maybe*** easier to understand would be this modification to the last four if statements: if (n>0x00FFFFFF) output( 1, first, bytestream, bytes); if (n>0x0000FFFF) output( 2, second, bytestream, bytes); if (n>0x000000FF) output( 3, third, bytestream, bytes); if (1) output( 4, fourth, bytestream, bytes); I agree, however, that compressing this field makes the receiving state machine overly complicated. But if you can't change the protocol, this code is much easier to read.
|sorting|comparison|
I have a list of more than 15 thousand latitude and longitude coordinates. Given any X,Y coordinates, what is the fastest way to find the closest coordinates on the list?
Working, usable and stable. It's well tested since quite a lot of mono's own low-level functionality has to be marshaled through it to the underlying operating system. There are some <a href="http://www.mono-project.com/Interop_with_Native_Libraries">P/Invoke extensions</a> when compared to Microsoft .Net implementation (after all they deal with a single OS family and three architectures at most). Most notable of those would be that library mappings transform the library name to OS-specific variants (e.g. `mylib.dll` searches for `mylib.so` on Linux, `mylib.dylib` on OS X and so on) and take into account various other system specific conventions. There is also a <a href="http://www.mono-project.com/Config_DllMap">DLLMap</a> configuration extension which can be used if the default name translations are not enough. Usually it's convenient to have the same API of the binary lib exposed on different OSes, so that migrating between platforms only requires changes in the C code, not the .Net part.
For a typical desktop app, I'd store everything on the current session, and maybe store info messages for the past n sessions or up to x in size. I'm assuming that your messages are organized. We use 4 categories; errors, warnings, info, and trace. We're still figuring out what goes at which level. As I'm getting used to parsing log files, I generally say "log more". Don't sweat readability, you're probably gonna have to process the log file a bit before you can use it. In the end, find a good logging framework that allows you to control your spool usage on lifetime and storage space, and a proper api that minimizes the effect on your code. Ideally you just type <code>info("waaah")</code> or <code>warning("waah")</code> and the API does all the fancy tagging for you.
**Ruby** - The [Free Ruby on Rails Training Online Course by Sang Shin][1] Isn't too bad. It also has a decent amount of further reading links on each subject in the course [1]: http://www.javapassion.com/rubyonrails/
1. Go to menu View 2. Click on Design Tasks 3. Select Controls in the 'Design Tasks' Task pane 4. Click on the 'add or remove custom controls' button to install your custom control 5. Click on the Add button and select ActiveX Control 6. Select the Windows Media Player control 7. Select the necessary properties for databinding and finish the wizard. After you have added the control, you can drag and drop the control on your screen. Right-Click on the control and select the 'Windows Media Player properties' Fill in the URL to automatically embed the file to play.
Edit: My apologies, I missed that the question was about Web forms - for which the below does not work. Must learn to read the question fully! 1. Go to menu View 2. Click on Design Tasks 3. Select Controls in the 'Design Tasks' Task pane 4. Click on the 'add or remove custom controls' button to install your custom control 5. Click on the Add button and select ActiveX Control 6. Select the Windows Media Player control 7. Select the necessary properties for databinding and finish the wizard. After you have added the control, you can drag and drop the control on your screen. Right-Click on the control and select the 'Windows Media Player properties' Fill in the URL to automatically embed the file to play.