instruction
stringlengths
0
30k
Does [Uri.IsWellFormedUriString][1] work for you? [1]: http://msdn.microsoft.com/en-us/library/system.uri.iswellformeduristring.aspx
Do look at Linq to entities though. I have a datareader populate a collection of objects that are mapped to the oracle table. I can use linq to query that collection in very powerful, simple, and easy ways. I love it. Highly recommend.
The VisualSVN manual says it works with all editions of Visual Studio - though I have not personally tried it. I know that none of Microsoft's Team Foundation Server stuff will work with Express.
Short answer: No. The Express editions support neither the Add-Ins nor Source Control providers (SCC plug-ins). While there are ways to make this work, they are undocumented, violate the license and [have caused legal trouble before…][1] [1]: http://weblogs.asp.net/nunitaddin/archive/2007/05/31/microsoft-vs-testdriven-net-31-may-2007.aspx
SELECT a,b,a+b FROM test_table INTO OUTFILE '/tmp/result.txt' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' (the docs show INTO OUTFILE up in the SELECT .. portion which may work as well, but I've never tried it that way) http://dev.mysql.com/doc/refman/5.0/en/select.html INTO OUTFILE creates a file on the server; if you are on a client and want it there, do: mysql -u you -p -e "SELECT ..." > file_name
I think you could compile api.dll as a resource into wrapper.dll. Then manually access that Resource out of api.dll and manually load it. I have manually loaded assemblies from disk, so loading one from a Stream should not be any different. I would try including the dll in your project as a file, similar to including a text or xml file (in addition to its project reference for compilation). Then I would set the build action to "Embedded Resource." Within wrapper.dll, I would use the Assembly object to access api.dll just like any other embedded resource. You will then also want to load the assembly using Assembly.Load http://msdn.microsoft.com/en-us/library/system.reflection.assembly.load.aspx
First port of call would be to fire up [Fiddler][1] and analyze the data going to and from the browser. Take a look at the headers, the url actually being called and the params (if any) being passed to the AJAX method and see if it all looks good before getting to the server. If that all looks ok, is there any way you can verify it's actually hitting the server via logging, or tracing in the AJAX method? ed: another thing I would try is rig up a test page to call the AJAX method on the server using a non-ajax based call and analyze the traffic in fiddler and compare the two. [1]: http://www.fiddlertool.com/fiddler/
Any reason not to start using the HTML 5 doctype?
|doctype|html|
<!DOCTYPE html> It is supposed to be backwards compatible with HTML4 and XHTML. [John Resig posted about some of the benefits][1]. [1]: http://ejohn.org/blog/html5-doctype/ As long as we don't use any of the new and not supported yet features, would there be any downside to start building sites with this doctype?
Comments at the top of the page before <html> will throw IE into quirks mode, which could explain why the page breaks, if that's where your comment appears. For more information, check out the "Triggering different rendering modes" on [this wikipedia page](http://en.wikipedia.org/wiki/Quirks_mode)
I'd say use it and test extensively. Then let us know if it blew your house up or something. :')
I've heard good things about Mosso . <http://www.mosso.com/>
I found a fairly elegant solution with [Telerik's RadAjaxManager][1]. It works quite nicely, essentially you register each control which might invoke a postback, and then register each control which should be re-drawn after that postback is performed asynchronously. The RadAjaxManager will update the DOM after the async postback and rewrite the ViewState and all affected controls. After taking a peek in Reflector, it looks a little kludgy under the hood, but it suits my purposes. [1]: http://www.telerik.com/demos/aspnet/prometheus/Ajax/Examples/Common/ViewState/DefaultCS.aspx
Other than the ToList difference, #2 is a lot more readable and natural IMO
C# syntax is so close to Java (and better in some ways) that you might as well learn C# instead of J#. And since C# is more widely used, you can easily find Java --> C# tutorials on google or check out [http://www.asp.net/learn][1] and watch some videos. [1]: http://www.asp.net/learn
There is also "sparklines" - they are available in lots of flavours (very simple charts though).
My question to you would be why use it if you don't use any of the new/unsupported features. I'm not saying you couldn't play around with it, but why start building sites with a doctype that offers no benefits and could be supplemented by XHTML5.
>Also, on the Intel Macs, can I use generic x86 asm? or is there a modified instruction set? Any information about post Intel Mac assembly helps. It's the same instruction set; it's the same chips.
I am now using Linq to Sql. This solves the problem entirely. However if you do not have that option (or some similar ORM tool), I don't see any reason to separate Read/Write methods. It just adds more classes and complicates data access. I have always designed it as follows: 1. Component/Business Object: Car 2. Data Access, containing static Read and Write methods: CarDB Example Usage: Car car = new Car(); car.Manufacturer = "Toyota" car.Model = "Camry" car.Year = 2006; car.CarID = CarDB.InsertCar(car) car.OwnerID = 2; CarDB.UpdateCar(car); This also makes sense for data access where both Reads and Write need to be performed as part of the same transaction. If you split up the classes, where would that go?
void shl12(uint8_t *v, size_t length) { if (length == 0) { return; // nothing to do } if (length > 1) { uint8_t last_byte, next_byte; next_byte = *(v + 1); for (uint8_t *end = &v[length]; *(v + 2) < *end; v++) { last_byte = next_byte; next_byte = *(v + 2); *v = ((last_byte & 0x0f) << 4) | ((next_byte) & 0xf0) >> 4); } // the next-to-last byte is half-empty *(v++) = (next_byte & 0x0f) << 4; } // the last byte is always empty *v = 0; }
There are a couple of edge-cases which make this a neat problem: * the input array might be empty * the last and next-to-last bits need to be treated specially, because they have zero bits shifted into them Here's a simple solution which loops over the array copying the low-order nibble of the next byte into its high-order nibble, and the high-order nibble of the next-next (+2) byte into its low-order nibble. To save dereferencing the look-ahead pointer twice, it maintains a two-element buffer with the "last" and "next" bytes: void shl12(uint8_t *v, size_t length) { if (length == 0) { return; // nothing to do } if (length > 1) { uint8_t last_byte, next_byte; next_byte = *(v + 1); for (size_t i = 0; i + 2 < length; i++, v++) { last_byte = next_byte; next_byte = *(v + 2); *v = ((last_byte & 0x0f) << 4) | ((next_byte) & 0xf0) >> 4); } // the next-to-last byte is half-empty *(v++) = (next_byte & 0x0f) << 4; } // the last byte is always empty *v = 0; }
There are a couple of edge-cases which make this a neat problem: * the input array might be empty * the last and next-to-last bits need to be treated specially, because they have zero bits shifted into them Here's a simple solution which loops over the array copying the low-order nibble of the next byte into its high-order nibble, and the high-order nibble of the next-next (+2) byte into its low-order nibble. To save dereferencing the look-ahead pointer twice, it maintains a two-element buffer with the "last" and "next" bytes: void shl12(uint8_t *v, size_t length) { if (length == 0) { return; // nothing to do } if (length > 1) { uint8_t last_byte, next_byte; next_byte = *(v + 1); for (size_t i = 0; i + 2 < length; i++, v++) { last_byte = next_byte; next_byte = *(v + 2); *v = ((last_byte & 0x0f) << 4) | ((next_byte) & 0xf0) >> 4); } // the next-to-last byte is half-empty *(v++) = (next_byte & 0x0f) << 4; } // the last byte is always empty *v = 0; } Consider the boundary cases, which activate successively more parts of the function: * When `length` is zero, we bail out without touching memory. * When `length` is one, we set the one and only element to zero. * When `length` is two, we set the high-order nibble of the first byte to low-order nibble of the second byte (that is, bits 12-16), and the second byte to zero. We don't activate the loop. * When `length` is greater than two we hit the loop, shuffling the bytes across the two-element buffer. If efficiency is your goal, the answer probably depends largely on your machine's architecture. Typically you should maintain the two-element buffer, but handle a machine word (32/64 bit unsigned integer) at a time. If you're shifting a lot of data it will be worthwhile treating the first few bytes as a special case so that you can get your machine word pointers word-aligned. Most CPUs access memory more efficiently if the accesses fall on machine word boundaries. Of course, the trailing bytes probably have to be handled specially too so you don't touch memory past the end of the array.
Right, a tag is just a copy: svn copy trunk tags/BLAH When people say SVN doesn't really copy anything, they mean that the repository doesn't need to duplicate the data. It uses something akin to symbolic links to keep track of the copies.
Git does have pre-commit and post-commit hooks, they are located inside each .git/hooks directory. Just modify the files and chmod them to make them executable.
A tag is a reference to the set of revision numbers at the time the tag was taken- it's the same thing as a branch or a copy, internally.
If you have an unsorted vector, then you can simply swap with the last vector element then resize(). With an ordered container, you'll be best off with std::vector::erase(). Note that there is a std::remove() defined in &lt;algorithm&gt;, but that doesn't actually do the erasing. (Read the documentation carefully).
From the VEMap.GetCenter Method documentation: > This method returns null when the map > style is set to VEMapStyle.Birdseye or > VEMapStyle.BirdseyeHybrid. Here is what I've found, though: var northWestLL = (new _xy1).Decode(map.GetMapView().TopLeftLatLong); var southEastLL = (new _xy1).Decode(map.GetMapView().BottomRightLatLong); The (new _xy1) seems to work the same as the old undocumented VEDecoder object.
**Coupling** * Loose: You and the guy at the convenience store. You communicate through a well-defined protocol to achieve your respective goals - you pay money, he lets you walk out with the bag of Cheetos. Either one of you can be replaced without disrupting the system. * Tight: You and your wife. **Cohesion** * Low: The convenience store. You go there for everything from gas to milk to ATM banking. Products and services have little in common, and the convenience of having them all in one place may not be enough to offset the resulting increase in cost and decrease in quality. * High: The cheese store. They sell cheese. Nothing else. Can't beat 'em when it comes to cheese though.
You should take a look at [ICProject][1], especially the getOutputEntries and getAllSourceRoots operations. [This tutorial][2] has some brief examples too. I work with JDT so thats pretty much what I can do. Hope it helps :) [1]: http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.cdt.doc.isv/reference/api/org/eclipse/cdt/core/model/ICProject.html [2]: http://dev.eclipse.org/viewcvs/index.cgi/cdt-core-home/docs/qnx/cpathentry.html?root=Tools_Project&revision=1.11
The Subversion book is online in a complete and free form: <http://svnbook.red-bean.com/en/1.4/svn-book.html#svn.branchmerge.tags> And yes, you basically do an svn copy. Subversion is smart enough to do a copy-on-write style mechanism to save space and minimize transfer time.
Even if you mark a class as public, members are still private by default. In other words, the class is pretty much useless. I think making it public by default instead may go too far, though. Try using 'internal' some. It should provide enough access for _most_ purposes.
Even if you mark a class as public, members are still private by default. In other words, the class is pretty much useless outside the same namespace. I think making it public by default instead may go too far, though. Try using 'internal' some. It should provide enough access for _most_ purposes.
Lucene is a great, powerful search engine. There is also a .Net clone [lucene.Net][1] If you want to abstract your search from your application and be able to query it in a language neutral way with XML/HTTP and JSON APIs, have a look at [solr][2]. Solr runs lucene in the background, but adds a nice web interface to it. [1]: http://incubator.apache.org/lucene.net/ [2]: http://lucene.apache.org/solr/
It depends on how comprehensive your web site is and how much you want to do yourself. If you are running a a **small website** without further possibilities to add a custom search, let google do the work (maybe add a [sitemap][1]) and use the [google custom search][2] If you run a **medium site** with an sql engine use the search features of your sql engine. If you run some **heavier software stack** like J2EE or .Net use [Lucene][3], a great, powerful search engine or its .Net clone [lucene.Net][4] If you want to **abstract your search from your application** and be able to query it in a language neutral way with XML/HTTP and JSON APIs, have a look at [solr][5]. Solr runs lucene in the background, but adds a nice web interface to it. [1]: https://www.google.com/webmasters/tools/docs/en/protocol.html [2]: http://www.google.com/coop/cse/ [3]: http://lucene.apache.org/java/docs/ [4]: http://incubator.apache.org/lucene.net/ [5]: http://lucene.apache.org/solr/
It depends on how comprehensive your web site is and how much you want to do yourself. If you are running a a **small website** without further possibilities to add a custom search, let google do the work (maybe add a [sitemap][1]) and use the [google custom search][2]. If you run a **medium site** with an sql engine use the search features of your sql engine. If you run some **heavier software stack** like J2EE or .Net use [Lucene][3], a great, powerful search engine or its .Net clone [lucene.Net][4] If you want to **abstract your search from your application** and be able to query it in a language neutral way with XML/HTTP and JSON APIs, have a look at [solr][5]. Solr runs lucene in the background, but adds a nice web interface to it. [1]: https://www.google.com/webmasters/tools/docs/en/protocol.html [2]: http://www.google.com/coop/cse/ [3]: http://lucene.apache.org/java/docs/ [4]: http://incubator.apache.org/lucene.net/ [5]: http://lucene.apache.org/solr/
foreach(string key in hashTable.Keys) { Console.WriteLine(String.Format("{0}: {1}", key, hashTable[key])); }
Hm thats really too bad. I suppose there are sometimes reasons why apps don't exist yet. Basically what I'm trying to do is simplify the process of sending image links to people using various apps (mainly web browser text forms, but also anytime I'm editing in a terminal window) by hooking the process of pasting an image in a text context, uploading the image in the background, and pasting a url to where the image was uploaded all with a single action.
Hm thats really too bad. I suppose there are sometimes reasons why apps don't exist yet. Basically what I'm trying to do is simplify the process of sending image links to people using various apps (mainly web browser text forms, but also anytime I'm editing in a terminal window) by hooking the process of pasting an image in a text context, uploading the image in the background, and pasting a url to where the image was uploaded all with a single action. Edit: I suppose the easier solution to this is to just create a new keyboard combo that is hooked by my app before it gets to any other app. There's no reason in particular that I need to tie it to copy/paste functionality.
Rolling back bad changes with svn in Eclipse
|svn|eclipse|subclipse|subversive|
Could do a messaging solution in Java Servlets using the application context. Objects stored as attributes in the application context are visible from anywhere in your webapp.
Could do a messaging solution in Java Servlets using the application context. Objects stored as attributes in the application context are visible from anywhere in your webapp. Update: Chat like functionality... I guess that would be AJAX polling your message structure stored in the app context unless you want to use something like applets.
You probably don't want to use sessions for things like chat messages but you probably could use some type of implementation of queueing using [MSMQ][1]. The approach to chat could be done in many different ways, this is just a suggesting off the top of my head. [1]: http://msdn.microsoft.com/en-us/library/ms711472.aspx
It's also worth noting that you can use * and ** when calling functions as well. This is a shortcut that allows you to pass multiple arguments to a function directly using either a list of a dictionary. For example, if you have the following function: def foo(x,y,z): print "x=" + str(x) print "y=" + str(y) print "z=" + str(z) You can do things like: >>> mylist = [1,2,3] >>> foo(*mylist) x=1 y=2 z=3 >>> mydict = {'x':4,'y':5,'z':6} >>> foo(**mydict) x=4 y=5 z=6
Gathering stats should be done whenever there has been large changes to the data content, for example a large number of deletes or inserts. If the table structure has changed you should gather stats also. It is advisable to use the 'ESTIMATE' option. Do this as an automated process out of business hours if possible, or if you have to do it during business hours then choose a time when there is minimum access to the tables you wish to gather stats for.
You can technically "branch" as little as a single file if you'd like... you can use 'svn switch' on any level directory or file. SVN tracks resources on a per-file basis just as CVS does, so it can do 'sticky' to the same effect. Committing a working copy containing mixed paths has very different effects though. See: - [http://svnbook.red-bean.com/en/1.0/re27.html][1] - [http://svn.haxx.se/dev/archive-2002-11/0336.shtml][2] [1]: http://svnbook.red-bean.com/en/1.0/re27.html [2]: http://svn.haxx.se/dev/archive-2002-11/0336.shtml
Don't know if it's any good, but there's a chat servlet [here][1] that might be useful to use or learn from if you decide to go the Java route... [1]: http://coldjava.hypermart.net/servlets/chatfaq.htm
Jeff posted a good "getting started" article for Windows, including how to setup **svnserve**: [Setting up Subversion on Windows][1] [1]: http://www.codinghorror.com/blog/archives/001093.html
I don't think you need to set up Java just to use a servlet for this. I would use AJAX and the database. I don't know ASP.NET but I PHP is similar in this case, being also basically "stateless". If you want to display some kind of asynchronous communication between two different users, say, from two different sessions, without a lot of refreshing (like chat), you can have the AJAX page constantly poll the database for new messages, and display them when they come in. You can also use AJAX to insert the new messages, giving the user read/write access to this messages data structure. Since the "other" user is doing the same thing, user A should see new messages pop up when user B types them in. Is that what you mean?
There are a couple of edge-cases which make this a neat problem: * the input array might be empty * the last and next-to-last bits need to be treated specially, because they have zero bits shifted into them Here's a simple solution which loops over the array copying the low-order nibble of the next byte into its high-order nibble, and the high-order nibble of the next-next (+2) byte into its low-order nibble. To save dereferencing the look-ahead pointer twice, it maintains a two-element buffer with the "last" and "next" bytes: void shl12(uint8_t *v, size_t length) { if (length == 0) { return; // nothing to do } if (length > 1) { uint8_t last_byte, next_byte; next_byte = *(v + 1); for (size_t i = 0; i + 2 < length; i++, v++) { last_byte = next_byte; next_byte = *(v + 2); *v = ((last_byte & 0x0f) << 4) | (((next_byte) & 0xf0) >> 4); } // the next-to-last byte is half-empty *(v++) = (next_byte & 0x0f) << 4; } // the last byte is always empty *v = 0; } Consider the boundary cases, which activate successively more parts of the function: * When `length` is zero, we bail out without touching memory. * When `length` is one, we set the one and only element to zero. * When `length` is two, we set the high-order nibble of the first byte to low-order nibble of the second byte (that is, bits 12-16), and the second byte to zero. We don't activate the loop. * When `length` is greater than two we hit the loop, shuffling the bytes across the two-element buffer. If efficiency is your goal, the answer probably depends largely on your machine's architecture. Typically you should maintain the two-element buffer, but handle a machine word (32/64 bit unsigned integer) at a time. If you're shifting a lot of data it will be worthwhile treating the first few bytes as a special case so that you can get your machine word pointers word-aligned. Most CPUs access memory more efficiently if the accesses fall on machine word boundaries. Of course, the trailing bytes have to be handled specially too so you don't touch memory past the end of the array.
In theory it's possible. Now how difficult in practice it might be depends on whether Java serialization format is documented or not. I guess, it's not. **edit:** [oops, I was wrong, thanks Charles][1]. **Anyway, this is what I suggest you to do** 1. capture from log4j & deserialize Java object in your own little Java program. 2. now when you have the object again, serialize it using your own custom formatter. ***Tip:** Maybe you don't even have to write your own custom formatter. for example, [JSON (scroll down for libs)][2] has libraries for Python and Java, so you could in theory use Java library to serialize your objects and Python equivalent library to deserialize it* 3. send output stream to your python application and deserialize it [1]: http://java.sun.com/j2se/1.4/pdf/serial-spec.pdf [2]: http://www.json.org/
In theory it's possible. Now how difficult in practice it might be depends on whether Java serialization format is documented or not. I guess, it's not. **edit:** [oops, I was wrong, thanks Charles][1]. **Anyway, this is what I suggest you to do** 1. capture from log4j & deserialize Java object in your own little Java program. 2. now when you have the object again, serialize it using your own custom formatter. ***Tip:** Maybe you don't even have to write your own custom formatter. for example, [JSON (scroll down for libs)][2] has libraries for Python and Java, so you could in theory use Java library to serialize your objects and Python equivalent library to deserialize it* 3. send output stream to your python application and deserialize it > **Charles wrote:** > > the problem is that for this > to work, your "little java program" > needs to load the same versions of all > the same classes that it might > deserialize. Which is tricky if you're > receiving log messages from one app, > and really tricky if you're > multiplexing more than one log stream. > Either way, it's not going to be a > little program any more. Can't you just simply reference Java log4j libraries in your own java process? I'm just giving general advice here that is applicable to any pair of languages (name of the question is pretty language agnostic so I just provided one of the generic solutions). Anyway, I'm not familiar with log4j and don't know whether you can "inject" your own serializer into it. If you can, then of course your suggestion is much better and cleaner. [1]: http://java.sun.com/j2se/1.4/pdf/serial-spec.pdf [2]: http://www.json.org/
Any good Subversion 1.5 virtual appliance recommendations?
|version-control|svn|
I'm looking for a quick-and-dirty solution to this, I have to set up a Subversion server really quickly, like by the end of the day tomorrow. My initial thought was to just download a virtual appliance that we could load onto our host machine. The problem I am having however is that all the appliances I have found so far are stuck in svn version 1.4 or lower. Does anybody know of an appliance that has svn 1.5 running? I don't need any of the other bits like issue tracking, WebSVN or any of that stuff. Thanks, Wally
|svn|version-control|
I'm looking for a quick-and-dirty solution to this, I have to set up a Subversion server really quickly, like by the end of the day tomorrow. My initial thought was to just download a virtual appliance that we could load onto our host machine. The problem I am having however is that all the appliances I have found so far are stuck in svn version 1.4 or lower. Does anybody know of an appliance that has svn 1.5 running? I don't need any of the other bits like issue tracking, WebSVN or any of that stuff. Thanks, Wally ***EDIT: To answer some of the questions, I would prefer for the host OS to be some flavour of Linux so that I can avoid having to purchase an additional Windows license.***
Should I use Google Web Toolkit for my new webapp?
|ruby|google-web-toolkit|javascript|
I would like to create a database backed interactive AJAX webapp which has a custom (specific kind of events, editing) calendaring system. This would involve quite a lot of JavaScript and AJAX, and I thought about Google Web Toolkit for the interface and Ruby on Rails for server side. Is Google Web Toolkit reliable and good? What hidden risks might be if I choose Google Web Toolkit? Can one easily combine it with Ruby on Rails on server side? Or should I try to use directly a JavaScript library like jQuery? I have no experience in web development except some HTML, but I am an experienced programmer (c++, java, c#), and I would like to use only free tools for this project.
|javascript|ruby|gwt|
Are there some specific URIs you care about or are you trying to find a single regex that validates [STD66](http://rfc.net/std0066.html)? I was going to point you to [this regex](http://www.unix.com.ua/rfc/std0066.html#p50) for parsing a URI but I think [bdukes](http://stackoverflow.com/questions/30847#30858) answer is better.
Are there some specific URIs you care about or are you trying to find a single regex that validates [STD66](http://rfc.net/std0066.html)? I was going to point you to [this regex](http://www.unix.com.ua/rfc/std0066.html#p50) for parsing a URI. You could then, in theory, check to see if all of the elements you care about are there. But I think [bdukes](http://stackoverflow.com/questions/30847#30858) answer is better.
Is there a graceful way to handle passing a list of ids as a parameter to a stored procedure. For instance, I want departments 1, 2, 5, 7, 20 returned by my stored procedure. In the past, I have passed in a comma delimited list of ids, like the below code, but feel really dirty doing it. SQL Server 2005 is my only applicable limitation I think. create procedure getDepartments @DepartmentIds varchar(max) as declare @Sql varchar(max) select @Sql = 'select [Name] from Department where DepartmentId in (' + @DepartmentIds + ')' exec(@Sql)
|sql-server|t-sql|stored-procedures|
Truncate (not round) decimal places in SQL Server
|t-sql|sql-server|
I'm trying to determine the best way to truncate or drop extra decimal places in SQL without rounding. For example: declare @value decimal(18,2) set @value = 123.456 This will auto round @Value to be 123.46....which in most cases is good. However, for this project I don't need that. Is there a simple way to truncate the decimals I don't need? I know I can use the left() function and convert back to a decimal...any other ways?
|sql-server|t-sql|
I suppose this might partially be because Subversion has the idea of a central server along with an absolute time line of revisions. Mercurial is truly distributed and has no such reference to an absolute time line. This does allow Mercurial projects to form more complicated hierarchies of branches for adding features and testing cycles by sub project however teams now need to much more actively keep on top of merges to stay current as they can't just hit update and be done with it.
In Subversion (and CVS), the repository is first and foremost. In git and mercurial there is not really the concept of a repository in the same way; here _changes_ are the central theme. I've not thought much about how you'd implement either but my impression (based on bitter experience and lots of reading) is that this difference is what makes merging and branching so much easier in non-repository based systems.
VSS is horrible. I may be channelling Spolsky (not sure if he's said this), but using VSS is actually worse than not using source control at all. Despite its name, it *isn't* safe. It creates the illusion of safety without providing it. Without VSS, you'd probably be making regular backups of your code. With VSS, you'll think, "Mehh, it's already under source control. Why bother backing up?" Great until it [corrupts your entire codebase][1] and you lose everything. (This, incidentally, happened at a company I worked at.) Get rid of VSS as soon as you can and switch to a real source control solution. [1]: http://www.highprogrammer.com/alan/windev/sourcesafe.html
Crop MP3 to first 30 seconds (PHP or Linux)
|php|linux|mp3|id3|
I want to be able to generate a new (fully valid) MP3 file from an existing MP3 file to be used as a preview -- try-before-you-buy style. The new file should only contain the first *n* seconds of the track. I need to write this in PHP, but it would be ok to shell out to a linux executable. There is a good library [getid3][1] for PHP, but at first glance, it appears to only have the ability to manipulate the tags. I could be wrong; documentation is somewhat lacking for this lib. Now, I know I could just "chop the stream" at *n* seconds (calculating from the bitrate and header size) when delivering the file, but this is a bit dirty and a real PITA on a VBR track. I'd like to be able to generate a proper MP3 file. Anyone any ideas? [1]: http://getid3.sourceforge.net/
First, I'd create a simple DependencyObject class to hold your collection: class YourCollectionType : DependencyObject { [PROPERTY DEPENDENCY OF ObservableCollection<YourType> NAMED: BoundList] } Then, on your ValidationRule-derived class, create a property: YourCollectionType ListToCheck { get; set; } Then, in the XAML, do this: <Binding.ValidationRules> <YourValidationRule> <YourValidationRule.ListToCheck> <YourCollectionType BoundList="{Binding Path=TheCollectionYouWantToCheck}" /> </YourValidationRule.ListToCheck> </YourValidationRule> </Binding.ValidationRules> Then in your validation, look at ListToCheck's BoundList property's collection for the item that you're validating against. If it's in there, obviously return a false validation result. If it's not, return true.
<pre><code> public static void PrintKeysAndValues( Hashtable myList ) { IDictionaryEnumerator myEnumerator = myList.GetEnumerator(); Console.WriteLine( "\t-KEY-\t-VALUE-" ); while ( myEnumerator.MoveNext() ) Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value); Console.WriteLine(); } </code></pre> from: <http://msdn.microsoft.com/en-us/library/system.collections.hashtable(VS.71).aspx>
You could just use a static int class variable that gets incremented each time your doIt method is called.
First add all directories to CVS find . -type d -print0| xargs -0 cvs add Then add all the files in the directories to CVS find . -type f -print0| xargs -0 cvs add
This should work for pretty much every version of the framework... foreach (string HashKey in TargetHash.Keys) { Console.WriteLine("Key: " + HashKey + " Value: " + TargetHash[HashKey]); } The trick is that you can get a list/collection of the keys (or the values) of a given hash to iterate through. EDIT: Wow, you try to pretty your code a little and next thing ya know there 5 answers... 8^D
I recommend [TortoiseSVN](http://tortoisesvn.tigris.org/). It adds SVN capabilities into Windows Explorer. In addition TortoiseSVN check to see if the IDE you are using has support for SVN.
I find that cleaning it immediately has two advantages. One, you can validate against it and provide feedback to the user. Two, you do not have to worry about consuming the data in other places.
I like to sanitize it as early as possible, which means the sanitizing happens when the user tries to enter in invalid data. If there's a TextBox for their age, and they type in anything other that a number, I don't let the keypress for the letter go through. Then, whatever is reading the data (often a server) I do a sanity check when I read in the data, just to make sure that nothing slips in due to a more determined user (such as hand-editing files, or even modifying packets!) Edit: Overall, sanitize early and sanitize any time you've lost sight of the data for even a second (e.g. File Save -> File Open)
User input should always be treated as malicious before making it down into lower layers of your application. Always handle sanitizing input as soon as possible and should not for any reason be stored in your database before checking for malicious intent.
Split data access class into reader and writer or combine them?
|oop|reader|writer|classdesign|
This might be on the "discussy" side, but I would really like to hear your view on this. Previously I have often written data access classes that handled both reading and writing, which often led to poor naming, like FooIoHandler etc. The rule of thumb that classes that are hard to name probably are poorly designed suggests that this is not a good solution. So, I have recently started splitting the data access into FooWriter and FooReader, which leads to nicer names and gives some additional flexibility, but at the same time I kind of like keeping it together, if the classes are not to big. Is a reader/writer separation a better design, or should I combine them? If I should combine them, what the heck should I name the class? Thanks /Erik
|architecture|oop|data-access|
Well I am not Python expert so I can't comment on how to solve your problem but if you have program in .NET you may use IKVM.NET to deserialize Java objects easily. I have experimented this by creating .NET Client for Log4J log messages written to Socket appender and it worked really well. I am sorry, if this answer does not make sense here.
There definitely isn't a Box Plot built into SSRS 2005, though it's possible that 2008 has one. SSRS 2005 does have a robust extension model. If you can implement a chart in System.Drawing/GDI+, you can make it into a [custom report item][1] for SSRS. There are a few third-party vendors with fairly feature-rich products, but the only one I've ever evaluated was [Dundas Chart][2], which isn't cheap, but gives you about 100x more charting capability than SSRS 2005 built in (for SSRS 2008, Microsoft incorporated a great deal of Dundas's charting technology). I can't say from experience that I know Dundas Chart supports the Box Plot, but this [support forum post][3] says so. [1]: http://msdn.microsoft.com/en-us/magazine/cc188686.aspx [2]: http://www.dundas.com/Products/Chart/RS/index.aspx [3]: http://support.dundas.com/forum/printable.aspx?m=3579
This is a really vague question. We'd need a concrete example to get a better idea of the problem.
because in most cases you've got to sort your results first. For example, when you search on Google, [you can view only up to 100 pages of results][1]. They don't bother sorting by page-rank beyond 1000 websites for given keyword (or combination of keywords). **Pagination is fast. Sorting is slow.** [1]: http://www.google.com.au/search?hl=en&safe=off&q=google&start=1000&sa=N
Because in most cases you've got to sort your results first. For example, when you search on Google, [you can view only up to 100 pages of results][1]. They don't bother sorting by page-rank beyond 1000 websites for given keyword (or combination of keywords). **Pagination is fast. Sorting is slow.** [1]: http://www.google.com.au/search?hl=en&safe=off&q=google&start=1000&sa=N
Coupling and cohesion
|oop|
I'm trying to boil down the concepts of coupling and cohesion to a concise definition. Can someone give me a short and understandable explanation (shorter than the definitions on Wikipedia [here][1] and [here][2])? [1]: http://en.wikipedia.org/wiki/Coupling_(computer_science) [2]: http://en.wikipedia.org/wiki/Cohesion_(computer_science) Thanks.
|oop|architecture|theory|
I'm trying to boil down the concepts of coupling and cohesion to a concise definition. Can someone give me a short and understandable explanation (shorter than the definitions on Wikipedia [here][1] and [here][2])? How do they interact? Thanks. [1]: http://en.wikipedia.org/wiki/Coupling_(computer_science) [2]: http://en.wikipedia.org/wiki/Cohesion_(computer_science)
I'm trying to boil down the concepts of coupling and cohesion to a concise definition. Can someone give me a short and understandable explanation (shorter than the definitions on Wikipedia [here][1] and [here][2])? How do they interact? Thanks. [1]: http://en.wikipedia.org/wiki/Coupling_(computer_science) [2]: http://en.wikipedia.org/wiki/Cohesion_(computer_science) Anybody have a good, short example?