instruction
stringlengths
0
30k
I have the following HTML (note the CSS making the background black and text white) <select id="opts" style="background-color: black; color: white;"> <option>first</option> <option>second</option> </select> Safari is smart enough to make the small triangle that appears to the right of the text the same color as the foreground text. Other browsers basically ignore the CSS, so they're fine too. Firefox 3 however applies the background color but leaves the triangle black, so you can't see it, like this ![example](http://farm4.static.flickr.com/3248/2800878559_40a573cf1d.jpg?v=0) I can't find out how to fix this - can anyone help? Is there a `-moz-select-triangle-color` or something obscure like that? Thanks
I have the following HTML (note the CSS making the background black and text white) <html> <select id="opts" style="background-color: black; color: white;"> <option>first</option> <option>second</option> </select> </html> Safari is smart enough to make the small triangle that appears to the right of the text the same color as the foreground text. Other browsers basically ignore the CSS, so they're fine too. Firefox 3 however applies the background color but leaves the triangle black, so you can't see it, like this ![example](http://farm4.static.flickr.com/3248/2800878559_40a573cf1d.jpg?v=0) I can't find out how to fix this - can anyone help? Is there a `-moz-select-triangle-color` or something obscure like that? Thanks
We keep the binary files and images in revision control, using Perforce. It's great! We keep a lot of art assets, and it scales well for lots of large files. It recognizes binary files, the ones that can't be diffed, and stores them as full file copies in the back end. It has P4V (cross-platform visual browser), and a thumbnail system so image files can be seen in the browser.
> I dropped that code into a file and pushed it to ff3 and I don't see what you see...the arrow is default color with gray background and black arrow. > Are you styling scrollbars too? I've updated the post, the HTML in there is now literally *all* the html that is being loaded, no other CSS/JS or anything, and it still looks exactly as posted in the pic. Note I'm on vista. It may do different things on XP, I haven't checked
There is an option in the Print Dialog to do the same (in VS 2005 and 2008 atleast)!
Just as you're doing for Subject, does t.Element("body").Value not give you what you need?
Is it possible to use the System.Xml namespace objects to get the job done here instead of using LINQ? As you already mentioned, XmlNode.InnerXml is exactly what you need.
At a company where I used to work we stored 155 million images in an Oracle 8i (then 9i) database. 7.5TB worth.
For something like a webserver, dividing up the tasks of handling each connection is (relatively) easy. I say it's safe to say that web servers is one of the most common (and ironed out) uses of parallel code. And since you are able to split up much of the processing into multiple discrete threads, more cores actually does benefit you. This is one of the big reasons why shared hosting is even possible. If server software like IIS and Apache couldn't run requests in parallel it would mean that every page request would have to be dished out in a queue fashion...likely making load times unbearably slow. This also why high end server Operating Systems like Windows 2008 Server Enterprise support something like 64 cores and 2TB of RAM. These are applications that can actually take advantage of that many cores. Also, since each request is likely has low CPU load, you can probably (for some applications) get away with more slower cores. But obviously having each core faster can mean being able to get each task done quicker and, in theory, handle more tasks and more server requests.
Mark Harrison said: > I don't have much experience with IIS, but I imagine the same scenario applies with its thread pool. Indeed - more cores = more threads running concurrently. IIS is inherently multithreaded, and takes easy advantage of this.
I'm not sure if I can solve this in one go, but we can go back and forth as necessary. First, I want to repeat what I think you are saying and make sure I'm clear. You want to disallow requests to servlet1 and servlet2 is the request doesn't have the proper referer and it **does** have a query string? I'm not sure I understand (servlet1|servlet2)/.+\?.+ because it looks like you are requiring a file under servlet1 and 2. I think maybe you are combining PATH_INFO (before the "?") with a GET query string (after the "?"). It appears that the PATH_INFO part will work but the GET query test will not. I made a quick test on my server using script1.cgi and script2.cgi and the following rules worked to accomplish what you are asking for. They are obviously edited a little to match my environment: RewriteCond %{HTTP_REFERER} !^http://(www.)?example.(com|org) [NC] RewriteCond %{QUERY_STRING} ^.+$ RewriteRule ^(script1|script2)\.cgi - [F] The above caught all wrong-referer requests to script1.cgi and script2.cgi that tried to submit data using a query string. However, you can also submit data using a path_info and by posting data. I used this form to protect against any of the three methods being used with incorrect referer: RewriteCond %{HTTP_REFERER} !^http://(www.)?example.(com|org) [NC] RewriteCond %{QUERY_STRING} ^.+$ [OR] RewriteCond %{REQUEST_METHOD} ^POST$ [OR] RewriteCond %{PATH_INFO} ^.+$ RewriteRule ^(script1|script2)\.cgi - [F] Based on the example you were trying to get working, I think this is what you want: RewriteCond %{HTTP_REFERER} !^http://mywebaddress(.cl)?/.* [NC] RewriteCond %{QUERY_STRING} ^.+$ [OR] RewriteCond %{REQUEST_METHOD} ^POST$ [OR] RewriteCond %{PATH_INFO} ^.+$ RewriteRule (servlet1|servlet2)\b - [F] Hopefully this at least gets you closer to your goal. Please let us know how it works, I'm interested in your problem. (BTW, I agree that referer blocking is poor security, but I also understand that relaity forces imperfect and partial solutions sometimes, which you seem to already acknowledge.)
@Mark Biek > Is MySQL replication an option? You could even turn it on and off if you didn't want it constantly replicating. Thanks for the suggestion, but I cannot enable replication on the server. It is a shared server with very little room for maneuver. I've updated the question to note this.
What's a good design pattern for web method return values?
|web-services|wsdl|soap|
When coding web services, how do you structure your return values? How do you handle error conditions (expected ones and unexpected ones)? If you are returning something simple like an int, do you just return it, or embed it in a more complex object? Do all of the web methods within one service return an instance of a single class, or do you create a custom return value class for each method?
|web-services|wsdl|soap|bestpractices|
|web-services|soap|wsdl|
I use transactions on every write operation to the database. So there are quite a few small "transactions" wrapped in a larger transaction and basically there is an outstanding transaction count in the nesting code. If there are any outstanding children when you end the parent, its all rolled back. I prefer client-side transaction handling where available. If you are relegated to doing sps or other server side logical units of work, server side transactions are fine.
I don't know how to share the session cookies, but you can easily share the same login. i.e. People will need to log separately into both sites, but will be able to use the same username and password. In the mediawiki file "LocalSettings.PHP", you can tell it to use a different (wordpress) database for authentication: e.g. require_once('includes/AuthPlugin.php'); require_once('extensions/AuthPress.php'); $wgAuth = new AuthPress(); $wgAuth->setAuthPressTablePrefix('evo_'); # Only include the following if you aren't using the same db as MediaWiki $wgAuth->setAuthPressDBServer ('localhost'); $wgAuth->setAuthPressDBName('yourWordPressDB'); $wgAuth->setAuthPressUser('mySQL user for same'); $wgAuth->setAuthPressPassword('The password'); See http://bbpress.org/forums/topic/mediawiki-bbpress-and-wordpress-integration
Have Matlab with Simulink? There are PLL demo files available at Matlab Central [here][1]. Matlab's code generation capabilities might get you from there to a PLL written in C. [1]: http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=14868&objectType=FILE#
With so much untapped power I cannot see how it would go unused for too long. The question is, though, how the GPU will be used for this. CUDA seems to be a good guess for now but other techologies are emerging on the horizon which might make it more approachable by the average developer. Apple have recently announced OpenCL which they claim is much more than CUDA, yet quite simple. I'm not sure what exactly to make of that but the khronos group (The guys working on the OpenGL standard) are working on the OpenCL standard, and is trying to make it highly interoperable with OpenGL. This might lead to a technology which is better suited for normal software development. It's an interesting subject and, incidentally, I'm about to start my master thesis on the subject of how best to make the GPU power available to the average developers (if possible) with CUDA as the main focus.
a defaul constraint only works on inserts, for an update use a trigger
To execute a file in the current directory, the syntax to use is: `./foo` As mentioned by allain, `./a.exe` is the correct way to execute a.exe in the working directory using Cygwin. Note: You may wish to use the `-o` parameter to `cc` to specify your own output filename. An example of this would be: `cc helloworld.c -o helloworld.exe`.
My suggestion would be to create a stored procedure which defaults the lastUpdate to getdate(). I've tried to avoid triggers in the past because pre-SQL2005 locating and editing them was a pain in the rump. Especially for developers who are new to your project. Also add that as the default value for your column definition.
Thomas wrote: > Apparently, gcc doesn't behave like the one described in The C Programming language It does in general. For your program to run on Windows it needs to end in .exe, "the C Programming language" was not written with Windows programmers in mind. As you've seen, cygwin emulates many, but not all, features of a POSIX environment.
You've asked for the canonical reason why Boost::MultiIndex was made: list insertion order with fast lookup by key. [Boost MultiIndex tutorial: list fast lookup][1] [1]: http://www.boost.org/doc/libs/1_36_0/libs/multi_index/doc/tutorial/basics.html#list_fast_lookup
If your goal is to have user-friendly URLs throughout your application, use the following approach: 1) Create a routing rule for your module/action in the application's routing.yml file. The following example is a routing rule for an action that shows the most recent questions in an application, defaulting to page 1 (using a pager): recent_questions: url: questions/recent/:page param: { module: questions, action: recent, page: 1 } 2) Once the routing rule is set, use the `url_for()` helper in your template to format outgoing URLs. <a href="<?php echo url_for('questions/recent?page=1') ?>">Recent Questions</a> In this example, the following URL will be constructed: `http://myapp/questions/recent/1.html`. 3) Incoming URLs (requests) will be analyzed by the routing system, and if a pattern match is found in the routing rule configuration, the named wildcards (ie. the `:/page` portion of the URL) will become request parameters. You can also use the `link_to()` helper to output a URL without using the HTML `<a>` tag.
>Apparently, gcc doesn't behave like the one described in The C Programming language, where it says that the command cc helloworld.c produces a file called a.out which can be run by typing a.out on the prompt. A Unix hasn't behaved in that way by default (so you can just write the executable name without ./ at the front) in a long time. It's called a.exe, because else Windows won't execute it, as it gets file types from the extension.
> dF: that's pretty cool... I didn't > know that I could access the fields in > a class using dict. > > Mark: the situations that I wish I had > this are precisely when I want a tuple > but nothing as "heavy" as a > dictionary. You can access the fields of a class using a dictionary because the fields of a class, its methods and all its properties are stored internally using dicts (at least in Cython). ...Which leads us to your second comment. Believing that Python dicts are "heavy" is an extremely non-pythonistic concept. And reading such comments kills my Python Zen. That's not good. You see, when you declare a class you are actually creating a pretty complex wrapper around a dictionary - so, if anything, you are adding more overhead than by using a simple dictionary. An overhead which, by the way, is meaningless in any case. If you are working on performance critical applications, use C or something.
also, this is pretty trivial and obvious, but be sure to [session_destroy][1] after every use. [1]: http://www.php.net/session_destroy
This is pretty trivial and obvious, but be sure to [session_destroy][1] after every use. This can be difficult to implement if the user does not log out explicitly, so a timer can be set to do this. Here is a good [tutorial][2] on setTimer() and clearTimer(). [1]: http://www.php.net/session_destroy [2]: http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/
XML Processing in Python
|python|xml|
I'm about to build a piece of a project that will need to build and post an xml document to a web service, and I'd like to do it in Python as a means to expand my skills there. Unfortunately, while I know the XML model fairly well in .Net, I'm uncertain what the pros and cons are of the XML models in Python. Anyone have experience doing XML processing in Python? Where would you suggest I start. The XML files I'll be building will be fairly simple. Thanks, Eric Sipple
I was glad to find [a good conversation][1] on this subject, as I hadn't really given it much thought before. In summary, signed is a good general choice - even when you're dead sure all the numbers are positive - if you're going to do arithmetic on the variable (like in a typical for loop case). If you're going to do bitwise things like masks, unsigned starts to make more sense. Or, if you're desperate to get that extra positive range by taking advantage of the sign bit. Personally, I like signed because I don't trust myself to stay consistent and avoid mixing the two types (like the article warns against). [1]: http://coding.derkeiler.com/Archive/C_CPP/comp.lang.c/2004-02/1382.html
Personally, I've played with several of the built-in options on an XML-heavy project and have settled on [pulldom][1] as the best choice for less complex documents. Especially for small simple stuff, I like the event-driven theory of parsing rather than setting up a whole slew of callbacks for a relatively simple structure. [Here is a good quick discussion of how to use the API][2]. What I like: you can handle the parsing in a `for` loop rather than using callbacks. You also delay full parsing (the "pull" part) and only get additional detail when you call `expandNode()`. This satisfies my general requirement for "responsible" efficiency without sacrificing ease of use and simplicity. [1]: http://docs.python.org/lib/module-xml.dom.pulldom.html [2]: http://www.prescod.net/python/pulldom.html
You might be able to use IronRuby for that. Otherwise I'd suggest you have a directory where you place precompiled assemblies. Then you could have a reference in the DB to the assembly and class, and use reflection to load the proper assemblies at runtime.
You might be able to use IronRuby for that. Otherwise I'd suggest you have a directory where you place precompiled assemblies. Then you could have a reference in the DB to the assembly and class, and use reflection to load the proper assemblies at runtime. If you really want to compile at run-time you could use the CodeDOM, then you could use reflection to load the dynamic assembly. [MSDN article which might help][1]. [1]: http://msdn.microsoft.com/en-us/library/microsoft.csharp.csharpcodeprovider.aspx
Powershell scripts might be useful too and surely more flexible than *xcopy* and other DOS commands. You can easily recurse through sub-directories, filter your files by name or extensions, treat especially some particular files based on the criteria of your choice, etc. The [Powershell community web site][1] is a good starting point. [1]: http://www.powershellcommunity.org
Small static images (not more than a couple of megs) that are not frequently edited, should be stored in the database. This method has several benefits including easier portability (images are transferred with the database), easier backup/restore (images are backed up with the database) and better scalability (a file system folder with thousands of little thumbnail files sounds like a scalability nightmare to me). Serving up images from a database is easy, just implement an http handler that serves the byte array returned from the DB server as a binary stream.
Are there any built-in audit packages? Oracle has a nice package, which will even send audit changes off to a separate server outside the access of any bad guy who is modifying the SQL. Their example is awesome... it shows how to alert on anybody modifying the audit tables.
If there isn't a sort that makes sense to order them you desire, don't union the results together - just return 3 separate recordsets, and deal with them accordingly in your data tier.
You web-server (I'm assuming you are using one) is designed to handle images while a database is not. Thus I would vote heavily on the nay side. Store just the path (and maybe file info too) in the database.
Your web-server (I'm assuming you are using one) is designed to handle images while a database is not. Thus I would vote heavily on the nay side. Store just the path (and maybe file info too) in the database.
Add an additional column with hard-coded values that you will use to sort the overall resultset, like so: SELECT A,B,C,1 as [order] FROM table WHERE field LIKE 'query%' UNION SELECT A,B,C,2 as [order] FROM table WHERE field LIKE '%query' UNION SELECT A,B,C,3 as [order] FROM table WHERE field LIKE '%query%' GROUP BY B ORDER BY [order] ASC, B ASC LIMIT 5
If Session("whatever") IsNot Nothing Then
The best I could come up with is to produce a matrix of sums of each pair, and then merge the rows together, a-la merge sort. I feel like I'm missing some simple insight that will reveal a much more efficient solution. My algorithm, in Haskell: matrixOfSums list = [[a+b | b <- list, b >= a] | a <- list] sortedSums = foldl merge [] matrixOfSums --A normal merge, save that we remove duplicates merge xs [] = xs merge [] ys = ys merge (x:xs) (y:ys) = case compare x y of LT -> x:(merge xs (y:ys)) EQ -> x:(merge xs (dropWhile (==x) ys)) GT -> y:(merge (x:xs) ys) I found a minor improvement, one that's more amenable to lazy stream-based coding. Instead of merging the columns pair-wise, merge all of them at once. In practice, this seemed to use less memory. -- wide-merge does a standard merge (ala merge-sort) across an arbitrary number of lists -- wideNubMerge does this while eliminating duplicates wideNubMerge :: Ord a => [[a]] -> [a] wideNubMerge ls = wideNubMerge1 $ filter (/= []) ls wideNubMerge1 [] = [] wideNubMerge1 ls = mini:(wideNubMerge rest) where mini = minimum $ map head ls rest = map (dropWhile (== mini)) ls betterSortedSums = wideNubMerge matrixOfSums
It appears that a popular solution will not work in all containers... http://www.theserverside.com/discussions/thread.tss?thread_id=30190
It's trying to bring in some Ruby Goodness :) **Concept:** This is some sample Ruby Code that prints out each element of the array rubyArray = [1,2,3,4,5,6,7,8,9,10] rubyArray.each{|x| puts x # do whatever with x } The Array's each method implementation **yields** control over to the caller (the 'puts x') with **each** element of the array neatly presented as x. The caller can then do whatever it needs to do with x. However **.Net** doesn't go all the way here.. C# seems to have coupled yield with IEnumerable, in a way forcing you to write a foreach loop in the caller as seen in Mendelt's response. Little less elegant. //calling code foreach(int i in obCustomClass.Each()) { Console.WriteLine(i.ToString()); } // CustomClass implementation private int[] data = {1,2,3,4,5,6,7,8,9,10}; public IEnumerable<int> Each() { for(int iLooper=0; iLooper<data.Length; ++iLooper) yield return data[iLooper]; }
Regular expression to match (C) function calls
|regular-expression|
Does anyone have a regular expression for matching function calls in C programs ?
|regex|
Having tried to do this some years ago I remember it not being very easy. The way I did it was to create totally new table to user/pass and then replace these columns in the respective software with foreign keys to your new table - this required **a lot** of custom tweaking of core files in each application - mainly making sure all SQL requests to this data have the extra join needed for your new table. If I find the time I will maybe try and provide a step by step of the changes needed. There are some **pretty big drawbacks** to this approach though. The main one being from now on your gonna have to hand update any patches If you have no content or users yet look at http://bbpress.org/documentation/integration-with-wordpress/ which will make things a lot simpler for you. I can't quite remember but I believe that I big problem I had was that MediaWiki requires usernames formatted a certain that conflicted with phpBB. ---------- Of course, a totally different approach would be to mod each piece of software to use OpenID _ I believe plugins/extensions are readily available for all the applications you mentioned.
+1 for Ben's answer. In addition, I suggest considering that the generic response allow for multiple error/warning items, to allow the reply to be as comprehensive and actionable as possible. (Would you want to use a compiler that stopped after the first error message, or one that told you as much as possible?)
Recursion means a function calling itself. For example: <pre> (define (un-ended name) (un-ended 'me) (print "How can I get here?")) </pre> Tail-Recursion means the recursion that conclude the function: <pre> (define (un-ended name) (print "hello") (un-ended 'me)) </pre> See, the last thing un-ended function (procedure, in Scheme jargon) does is to call itself. Another (more useful) example is: <pre> (define (map lst op) (define (helper done left) (if (nil? left) done (helper (cons (op (car left)) done) (cdr left)))) (reverse (helper '() lst))) </pre> In the helper procedure, the LAST thing it does if left is not nil is to call itself (AFTER cons something and cdr something). This is basically how you map a list. The tail-recursion has a great advantage that the interperter (or compiler, dependent on the language and vendor) can optimize it, and transform it into something equivalent to a while loop. As matter of fact, in Scheme tradition, most "for" and "while" loop is done in tail-recursion manner (there is no for and while, as far as I know).
you could write an excel spreadsheet that loads a given excel spreadsheet and saves it as csv (rather than doing it manually). then you could automate that from c#. and once its in csv, the c# program can grok that. (also, if someone asks you to program in excel, it's best to pretend you don't know how) (edit: ah yes, rob and ryan are both right)
I know that people have been making an Excel "extension" for this purpose. You more or less make a button in Excel that says "Export to Program X", and then export and send off the data in a format the program can read. <http://msdn.microsoft.com/en-us/library/ms186213.aspx> should be a good place to start. Good luck
Forgive me if I am off-base here, but isn't this what the [Office PIA's](http://www.microsoft.com/downloads/details.aspx?FamilyId=C41BD61E-3060-4F71-A6B4-01FEBA508E52&displaylang=en) are for?
Not free, but with the latest Office there's a *very* nice automation .Net API. (there has been an API for a long while but was nasty COM) You can do everything you want / need in code all while the Office app remains a hidden background process.
Yes, but only very slightly. A much bigger performance improvement can be achieved by using better algorithms (for example keeping the list sorted and doing a binary search). In general optimizing a given algorithm only gets you so far. Choosing a better algorithm (even if it's not completely optimized) can give you a considerable (order of magnitude) performance improvement.
I think, it will not make much of a difference. The compiler will already optimize it in that direction. Besides, the variable i does not have much impact, word stays constant throughout the function and the rest is too large to fit in any register. It is only a matter how large the cache is and if the whole array might fit in there. String comparisons are rather expensive computationally. Can you perhaps use some kind of hashing for the array before searching?
Refactoring away labeled loops.
|java|refactoring|label|
After I was convinced that labeled breaks/continues are a total "nono" over [here][1], I need help to remove the label out of my code. I have a square matrix and a vector that has the same length. The vector has already some values in it an depending on the values in the matrix the vector is changed in the loop. I hope, the code-fragment is basically understandable vectorLoop: for( int idx = 0; idx < vectorLength; idx++) { if( conditionAtVectorPosition( v, idx ) ) continue vectorLoop; matrixLoop: for( rowIdx = 0; rowIdx < n; rowIdx++ ) { if( anotherConditionAtVector( v, rowIdx ) ) continue matrixLoop; if( conditionAtMatrixRowCol( m, rowIdx, idx ) ) continue vectorLoop; } setValueInVector( v, idx ); } please convince me, that there is a more readable/better version without the labels. [1]: http://stackoverflow.com/questions/15481/java-coding-standard-best-practices-labeled-brakecontinue#15501
[This guy](http://www.mojoportal.com/mojoportal-gets-advanced-google-analytics-integration.aspx) has had some success with at least some light Analytics integration. Now I realize this isn't exactly what you're looking for, but he does mention a book and perhaps you can get in touch with him.
Templates spread across multiple files
|c++|templates|
C++ seems to be rather grouchy when declaring templates across multiple files. More specifically, when working with templated classes, the linker expect all method definitions for the class in a single compiler object file. When you take into account headers, other declarations, inheritance, etc., things get really messy. Are there any general advice or workarounds for organizing or redistributing templated member definitions across multiple files?
Across how many files? If you just want to separate class definitions from implementation then try [this article][1] in the C++ faqs. That's about the only way I know of that works at the moment, but some IDEs (Eclipse CDT for example) won't link this method properly and you may get a lot of errors. However writing your own makefiles or using Visual C++ this has always worked for me :-) [1]: http://www.parashift.com/c++-faq-lite/templates.html#faq-35.12 "Separating Template Files"
I would echo David's suggestion. You'd probably want to examine how the RDBMS is executing your query (e.g., via table scans or using indexes). One quick check would be to time just the part of the query involving the text search. Something like this: SELECT ca.Line1, ca.CityName, ca.PostalCode FROM CustomerAddress as ca WHERE ca.CustomerId = <some id number> AND (ca.Line1 LIKE '%ae%' OR ca.CityName LIKE '%ab%' OR ca.PostalCode LIKE '%10%'); If that takes a long time, then the `LIKE`s are the issue (remove one expression at a time from the `OR`ed line to see if just one of those columns is causing the slowdown). If it's quick, then the joins are suspect. You could write a similar query for the CustomerAccount table as well.
Regardless of whether the assembly has been compiled as a release build the exception should certainly 'bubble' up to the caller, there's no reason an assembly not being compiled in debug mode should have any affect on that. I'd agree with Daniel is suggesting that perhaps the exception is occurring on a separate thread - try hooking the thread exception event in Application.ThreadException. This should be raised when any unhandled thread exception occurs. You could adapt your code thus:- using System.Threading; ... void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { throw new ParserException(e.Exception.Message, e.Exception); } ... var exceptionHandler = new ThreadExceptionEventHandler(Application_ThreadException); Application.ThreadException += exceptionHandler; try { // Execution stopped at parser.prog() TimeDefParser.prog_return prog_ret = parser.prog(); return prog_ret == null ? null : prog_ret.value; } catch (Exception ex) { throw new ParserException(ex.Message, ex); } finally { Application.ThreadException -= exceptionHandler; }
Is it possible that the exception is being thrown in another thread? Obviously your calling code is single threaded, but maybe the library you are consuming is doing some multithreaded operations under the covers.
Is it possible that the exception is being thrown in another thread? Obviously your calling code is single threaded, but maybe the library you are consuming is doing some multithreaded operations under the covers.
Have you made a support request to the vendor? Perhaps there's something about the MacBook Pro hardware that prevents the product from working.
If you're looking for a "higher-level" explanation of this stuff (as in, not code), [Applied Cryptography](http://www.schneier.com/book-applied.html) has quite a few relevant examples (and I believe a section on "secure elections" that covers some voting strategies).
SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7, tokens 9.5.0.DEF.2, SOFTWARE\IBM\DB2\InstalledCopies
|.net|db2|vista64|
I am trying to get the DB2 data provider from a 32-bit .Net application to connect to DB2 running as a 32-bit application on Vista 64 (is that confusing enough yet)? Unfortunately, I am getting the following error: > SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7, tokens 9.5.0.DEF.2, SOFTWARE\IBM\DB2\InstalledCopies There are several [IBM forum posts][1] mentioning it, but little useful guidance. Has anyone experienced this before? Or do you have better ideas for fixing it? [1]: http://www-128.ibm.com/developerworks/forums/thread.jspa?threadID=207638&tstart=45
Longhorn213 almost has the right answer, but as as Sean Chambers says should use is insead of ==. The most import thing to note is that **you have to use recursion** as longhorn213 points out or you may miss some of the controls on the page. HOWEVER, I too would love to see if there more succinct way to do this with LINQ.
Longhorn213 almost has the right answer, but as as Sean Chambers says should use ctrl is IInterfaceToFind instead of ctrl.GetType() == aTypeVariable The most import thing to note is that **you have to use recursion** as longhorn213 points out or you may miss some of the controls on the page. HOWEVER, I too would love to see if there more succinct way to do this with LINQ.
Longhorn213 almost has the right answer, but as as Sean Chambers and bdukes say, you should use ctrl is IInterfaceToFind instead of ctrl.GetType() == aTypeVariable The reason why is that if you use .GetType(), you will get the true type of an object, not necesarily what it can also be cast to in its inheritance/Interface implimentation chain. The most import thing to note is that **you have to use recursion** as longhorn213 points out or you may miss some of the controls on the page. HOWEVER, I too would love to see if there more succinct way to do this with LINQ.
Longhorn213 almost has the right answer, but as as Sean Chambers and bdukes say, you should use ctrl is IInterfaceToFind instead of ctrl.GetType() == aTypeVariable The reason why is that if you use .GetType(), you will get the true type of an object, not necessarily what it can also be cast to in its inheritance/Interface implementation chain. The most import thing to note is that **you have to use recursion** as longhorn213 points out or you may miss some of the controls on the page. HOWEVER, I too would love to see if there more succinct way to do this with LINQ.
In your example above, when 'i' will always be positive and a higher range would be beneficial, unsigned would be useful. Like if you're using 'declare' statements, such as: #declare BIT1 (unsigned int 1) #declare BIT32 (unsigned int reallybignumber) Especially when these values will never change. However, if you're doing an accounting program where the people are irresponsible with their money and are constantly in the red, you will most definitely want to use 'signed'. I do agree with saint though that a good rule of thumb is to use signed, which C actually defaults to, so you're covered.
size_t is often a good choice for this, or size_type if you're using an STL class.
You could use any of the DLR languages, which provide a way to really easily host your own scripting platform. However, you don't have to use a scripting language for this. You could use C# and compile it with the C# code provider. As long as you load it in its own AppDomain, you can load and unload it to your heart's content.
There's a PHP5 "database migration framework" called Ruckusing. I haven't used it, but the [examples][1] show the idea, if you use the language to create the database as and when needed, you only have to track source files. [1]: http://code.google.com/p/ruckusing/wiki/CompleteExamples
I just whipped this up quick in Ruby: def perms(x, y, possible_characters) all = [""] current_array = all.clone 1.upto(y) { |iteration| next_array = [] current_array.each { |string| possible_characters.each { |c| value = string + c next_array.insert next_array.length, value all.insert all.length, value } } current_array = next_array } all.delete_if { |string| string.length < x } end You might look into language API for built in permutation type functions, and you might be able to write more optimized code, but if the numbers are all that high, I'm not sure there is much of a way around having a lot of results. Anyways, the idea behind the code is start with string of length 0, then keep track of all the strings of length Z where Z is the current size in the iteration. Then, go through each string and append each character onto each string. Finally at the end, remove any that were below the x threshold and return the result. I didn't test it with potentially meaningless input (null character list, weird values of x and y, etc).
You can tell your users to add your From address to their contacts when they complete their order, which, if they do so, will help a lot. Otherwise, I would try to get a log from some of your users. Sometimes they have details about why it was flagged as spam in the headers of the message, which you could use to tweak the text. Other things you can try: - Put your site name or address in the subject - Keep all links in the message pointing to your domain (and not <your domain>email.com) - Put an address or other contact information in the email
This warning is there because Java is not actually storing type information at runtime in an object that uses generics. Thus, if 'object' is actually a List&lt;String&gt;, there will be no ClassCastException at runtime except until an item is accessed from the list that doesn't match the generic type defined in the variable. This can cause further complications if items are added to the list with this incorrect generic type information. Any code still holding a reference to the list but with the correct generic type information will now have an inconsistent list. To remove the warning, try: List<?> list = (List<?>) object; However, note that you will not be able to use certain methods such as add because the compiler doesn't know if you are trying to add an object of incorrect type. The above will work in a lot of situations, but if you have to use add or some similarly restricted method, you will just have to suffer the yellow underline in Eclipse (or a SuppressWarning annotation).
I'm not sure if I'm being unclear, but if so, I'm seeing the debugger halt execution with an "Unhandled Exception" of type NoViableAltException. Initially, I didn't know anything about this Debug->Exceptions menu item because MS expects you, at VS install time, to commit to a profile when you have no idea how they are different. Apparently, [I was not on the C# dev profile and was missing this option][1]. After finally debugging all thrown CLR exceptions, I was unfortunately unable to discover any new behavior leading to the reason for this unhandled exception issue. All the exceptions thrown were expected and supposedly handled in a try/catch block. I reviewed the external assembly and there is no evidence of multithreading. By that, I mean no reference exists to System.Threading and no delegates were used whatsoever. I'm familiar with that constitutes instantiating a thread. I verify this by observing the Threads toolbox at the time of the unhandled exception to view there is only one running thread. I have an open issue with the ANTLR folks so perhaps they've been able to tackle this issue before. I've been able to replicate it in a simple console app project using .NET 2.0 and 3.5 under VS 2008 and VS 2005. It's just a pain point because it forces my code to only work with known valid parser input. Using an `IsValid()` method would be risky if it threw an unhandled exception based on user input. I'll keep this question up to date when more is learned of this issue. [1]: http://blogs.vertigo.com/personal/keithc/Blog/archive/2007/07/20/missing-menu-options-in-visual-studio-2005.aspx
Validate a UK phone number
|c#|regex|regular-expression|
How do I validate a UK phone number in C# using a regex?
|c#|regex|regular-expression|language-agnostic|
|c#|language-agnostic|regex|
Getting parts of a URL (Regex)
|url|regex|regular-expression|
Given the URL (single line): http://test.example.com/dir/subdir/file.html How can I extract the following parts using regular expressions: - The Subdomain (test) - The Domain (example.com) - The path without the file (/dir/subdir/) - The file (file.html) - The path with the file (/dir/subdir/file.html) - The URL without the path (http://test.example.com) - (add any other that you think would be useful) The regex should work correctly even if I enter the following URL: http://example.example.com/example/example/example.html Thank you.
|url|regex|regular-expression|language-agnostic|