instruction
stringlengths
0
30k
I think you might want to be a bit more specific, when you say data structures my mind goes in a few directions... Arrays - They are certainly well documented and available in. (http://us.php.net/manual/en/book.array.php) SQL Data - Depends on the database you are using, but most are available. (http://us.php.net...
I was able to do this about a year ago, but I no longer remember all of the details. Basically, you can use IntPtr.Size to determine which DLL to load, then perform the actual LoadLibrary through p/Invoke. At that point, you've got the module in memory and you ought to be able to just p/Invoke functions from inside o...
You can try to develop some sort of a generic component that accepts a [SynchronizationContext][1] as input and uses it to invoke the events. [1]: http://msdn.microsoft.com/en-us/library/system.threading.synchronizationcontext.aspx
Of course PHP has data structures. The array in php is incredibly flexible. Some examples: $foo = array( 'bar' => array(1,'two',3), 'baz' => explode(" ", "Some nice words") ); Then you have an absolute plethora of array functions available to map/filter/walk/etc the structures, or convert, ...
Are you wanting to change the location of the files on the workstation? If so, here's how I do it: Open Visual Studio Open the Source Control Explorer window. From the Workspace dropdown select "Workspaces..." The Manage Workspaces dialog should show up. Select the workspace you want to modify, and clic...
You don't need to *compile* python for Mac/Windows/Linux. It is an interpreted language, so you simply need to have the Python interpreter installed on the system of your choice (it is available for all three platforms). As for a GUI library that works cross platform, Python's [Tk/Tcl][1] widget library works very ...
Possible to "spin off" several GUI threads? (Not halting the system at Application.Run)
|winforms|c#|.net|
|c#|.net|winforms|
**My Goal** I would like to have a main processing thread (non GUI), and be able to spin off GUIs in their own background threads as needed, and having my main non GUI thread keep working. Put another way, I want my main non GUI-thread to be the owner of the GUI-thread and not vice versa. I'm not sure this is even p...
**My Goal** I would like to have a main processing thread (non GUI), and be able to spin off GUIs in their own background threads as needed, and having my main non GUI thread keep working. Put another way, I want my main non GUI-thread to be the owner of the GUI-thread and not vice versa. I'm not sure this is even p...
LSP in OO programming?
|oop|
Am I right in thinking the full name of the LSP is the Liskoff Substitution Principle? I'm having trouble finding an [online] source to cite for any information on this... it seems to be a cornerstone of OOP, and yet I'm having trouble finding definitions.
If you assume each user has one or more addresses, a telephone number, etc., you could have a 'Users' table, an 'Addresses Table' (containing a primary key and then non-unique reference to Users), the same for phone numbers - allowing multiple rows with the same UserID foreign key, which would make querying 'all addres...
Yes, you are right. It's spelled Liskov which is probably why you can't find a citation. Here's the [link.][1] One of the better resources regarding this is Robert C. Martin's Agile Software Development Principles Patterns and practices book. [1]: http://en.wikipedia.org/wiki/Liskov_substitution_principle
Your SelectedValue should be a unique id of some sort, that doesn't change. The Text value that gets displayed to the user is something seperate, and can change if necessary without affecting your application, because you associate the id with your Order, not the displayed string value.
It depends on what you're testing. If you're testing a business logic component -- then its immaterial where the data is coming from and you'd probably use a mock or a hand rolled stub class that simulates the data access routine the component would have called in the wild. The only time I mess with the data access i...
@Matt Hamilton It does. "c" works for whatever the CurrentCultureInfo is, the question becomes if all the users of the web application have the same currency as the server, otherwise, they will need to get the cultureinfo clientside and use the currency gleaned from there.
It sounds like you might be testing message based systems, or systems with highly parameterised interfaces, where there are large numbers of permutations of input data. In general all the rules of standard unti testing still hold: * Try to make the units being tested as small and discrete as possible. * Try to...
take a look [here][1] [1]: http://asp.dotnetheaven.com/aspnet/doc/caching/fragment.aspx you use VaryByParam and VaryByControl in the output cache.
This is NOT a good idea [This article talks about ruby's timeout library.](http://blog.headius.com/2008/02/rubys-threadraise-threadkill-timeoutrb.html) which throws exceptions across threads. It explains how doing such a thing is fundamentally broken. It's not just broken in ruby, it's broken anywhere that throws...
This is NOT a good idea [This article talks about ruby's timeout library.](http://blog.headius.com/2008/02/rubys-threadraise-threadkill-timeoutrb.html) which throws exceptions across threads. It explains how doing such a thing is fundamentally broken. It's not just broken in ruby, it's broken anywhere that throws...
We use a commit hook script to trigger our release robot. Writing new release information to a file named changes.txt in our different products will trigger the creation of a tag and the relevant artifacts.
I think you can specify OutputCache in the control's markup file like you'd do on an ASPX page. And it'd get properly cached automatically. Just read up on OutputCache page directive on MSDN and get the parameters right and it should do what you want it to. It's been a long time since I write classic ASP.NET but ...
Boolean Field in Oracle
|oracle-database|
Yesterday I wanted to add a boolean field to an Oracle table. However, there isn't actually a boolean data type in Oracle. Does anyone here know the best way to simulate a boolean? Googling the subject discovered several approaches 1. Use an integer and just don't bother assigning anything other than 0 or 1 to it...
There's no standard engine. However, the POSIX Extended Regular Expression format is a valid subset of most engines and is probably as close as you'll get to a standardised subset.
Server Core won't be very useful (to me at least, and I think many others as well) until they get a version of .Net framework on it. Maybe a specialized subset like they have in the Compact Framework on smart phones.
Towers of Hannoi is great for practice on recursion.
Towers of Hannoi is great for practice on recursion. I'd also do a search on sample programming interview questions.
When the HTML is parsed, what JQuery sees in the DOM is a UPWARDS DOUBLE ARROW ("⇑"), not the entity reference. Thus, in your Javascript code you should test for "⇑" or "\u21d1".
When the HTML is parsed, what JQuery sees in the DOM is a `UPWARDS DOUBLE ARROW` ("⇑"), not the entity reference. Thus, in your Javascript code you should test for `"⇑"` or `"\u21d1"`. Also, you need to switch what you're switching to: if(arrow == "\u21d1") { $("#"+id+" span").html("\u21d3"); ...
When the HTML is parsed, what JQuery sees in the DOM is a `UPWARDS DOUBLE ARROW` ("⇑"), not the entity reference. Thus, in your Javascript code you should test for `"⇑"` or `"\u21d1"`. Also, you need to change what you're switching to: function expandCollapse(id) { var arrow = $("#"+id+" span").html(); ...
Most regular expression tools/languages support these [basic capabilities](http://www.regular-expressions.info/reference.html): 1. Character Classes/Sets - [] 2. Anchors - ^$ 3. Alternation - | 4. Quantifiers - ?+*{n,m} 5. Metacharacters - \w, \s, \d, ... 6. Backreferences - \1, \2, ... 7. Dot - . 8. Simple m...
Most regular expression tools/languages support these [basic capabilities](http://www.regular-expressions.info/reference.html): 1. Character Classes/Sets and their Negation - [] 2. Anchors - ^$ 3. Alternation - | 4. Quantifiers - ?+*{n,m} 5. Metacharacters - \w, \s, \d, ... 6. Backreferences - \1, \2, ... 7. D...
Are you wanting to change the location of the files on the workstation? If so, here's how I do it: <ol> <li>Open Visual Studio</li> <li>Open the Source Control Explorer window.</li> <li>From the Workspace dropdown select "Workspaces..."</li> <li>The Manage Workspaces dialog should show up.</li> <li>Select the ...
You can use fseek() to clear the eof condition on the stream. Essentially, read to the end of the file, sleep foir a file, fseek() (without changing your position) to clear eof, the read to end of file again. wash, rinse, repeat. man fseek(3) for details.
You can use fseek() to clear the eof condition on the stream. Essentially, read to the end of the file, sleep for a while, fseek() (without changing your position) to clear eof, the read to end of file again. wash, rinse, repeat. man fseek(3) for details.
You can use fseek() to clear the eof condition on the stream. Essentially, read to the end of the file, sleep for a while, fseek() (without changing your position) to clear eof, the read to end of file again. wash, rinse, repeat. man fseek(3) for details. Here's what it looks like in perl. perl's seek() is essen...
The associative array can be used for most basic data structures hashtable, queue, stack. But if you want something like a tree or heap I don't think they exist by default but I'm sure there are free libraries anywhere. To have an array emulate a stack use `array_push()` to add and `array_pop()` to take off To h...
I would probably leave it up to your application to perform the scoring. Check out [Maybe Normalizing Isn't Normal][1] by Jeff Atwood. [1]: http://www.codinghorror.com/blog/archives/001152.html
Sending a mail as both HTML and Plain Text in .net
|c#|.net|
I'm sending mail from my C# Application, using the SmtpClient. Works great, but I have to decide if I want to send the mail as Plain Text or HTML. I wonder, is there a way to send both? I think that's called multipart. I googled a bit, but most examples essentially did not use SmtpClient but composed the whole SMTP-...
What's the best way to implement a SQL script that will grant select, references, insert, update, and delete permissions to a database role on all the user tables in a database?
|sql|sql-server|t-sql|permissions|
Ideally, this script could be run multiple times, as new tables were added to the database. SQL Server Management Studio generates scripts for individual database objects, but I'm looking for more of a "fire-and-forget" script.
myList = ['a','b','c','d'] myString = ",".join(myList ) I'm pretty sure that doesn't work if the list contains numbers.
**Foreach uses Duck Typing** Paraphrasing, or shamelessly stealing from [Krzysztof Cwalinas blog][1] on this. More interesting trivia than anything. For your object to support foreach, you *don't* have to implement *IEnumerable*. I.e. this is not a constraint and it isn't checked by the compiler. What's checked i...
What you want to do is use the AlternateViews property on the MailMessage [http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.alternateviews.aspx][1] [1]: http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.alternateviews.aspx
@Andrew - I'm exactly in your situation. I use a MBP while my company work is purely Microsoft based: i.e., .NET, COM etc. While nothing can beat running Vista natively in Boot Camp (I've never seen Vista run so fast), the niceties of having your Mac OS be the "main" OS, for internet, mail etc. has gotten to the follow...
Mocking Frameworks enable you to test your business objects. Data Driven tests often end up becoming more of a intergration test than a unit test, they also carry with them the burden of managing the state of a data store pre and post execution of the test and the time taken in connecting and executing queries. In...
Another online book that I pick up whenever I need to get back into C++ is "C++ In Action" by Bartosz Milewski. Its [online][1] at his site. [1]: http://www.relisoft.com/book/index.htm
Combining Structures
|matlab|
I want to know the best way to combine two structures with differing fields names. For example, starting with A.field1 = 1; A.field2 = 'a'; B.field3 = 2; B.field4 = 'b'; I would like to have C.field1 = 1; C.field2 = 'a'; C.field3 = 2; C.field4 = 'b'; Is there...
Looking at the amount of sense people are demonstrating in other answers here, I'd say that using a regex probably isn't the best idea for your situation. Go for something tried and tested, and treat my previous answer as a demonstration that regexes need not be *that* scary.
Linq to Entities vs ESQL
|entity-framework|linq-to-entities|esql|
**When using the Entity Framework, does ESQL perform better than Linq to Entities?** I'd prefer to use Linq to Entities (mainly because of the strong-type checking), but some of my other team members are citing performance as a reason to use ESQL. I would like to get a full idea of the pro's/con's of using either m...
I have to second the comment by @Phil Bennett as I try to approach these integration tests with a rollback solution. I have a very detailed post about integration testing your data access layer [here][1] I show not only the sample data access class, base class, and sample DB transaction fixture class, but a full ...
I have to second the comment by @Phil Bennett as I try to approach these integration tests with a rollback solution. I have a very detailed post about integration testing your data access layer [here][1] I show not only the sample data access class, base class, and sample DB transaction fixture class, but a full ...
Indexing Service + MODI = Full-text over OCR? You wish!
|ocr|dep|cisvc|indexingservice|modi|
Scenario: You have configured Indexing Service to index your files, which also include scanned images saved as hi-res TIFF files. You also have installed MS Office 2003+ and configured MS Office Document Imaging (MODI) correctly so you can perform OCR on your images and even embed the OCR'd text into TIFFs. Awesomen...
It's not that difficult to switch between version control systems. As others have mentioned the important thing is to start using anything as soon as possible. The benefits of using source control over not using source control vastly outweigh the differential benefits between different types of source control. Remem...
I'm sure this is possible if you hack at it hard enough, but I'd suggest it is not a good idea. 'Windows' (that you see on the screen) are highly coupled to processes. That is, each process which displays any GUI is expected to have a Message Loop, which processes all of the messages which are involved with creating...
I really like regular expressions. As long as the command strings are fairly simple, you can write a few regexes that could take a few pages of code to manually parse. I would suggest you check out http://www.regular-expressions.info/ for a good intro to regexes, as well as specific examples for Java.
A simple string tokenizer on spaces should work, but there are really many ways you could do this. Here is an example using a tokenizer: String command = "kick person"; StringTokenizer tokens = new StringTokenizer(command); String action = null; if (tokens.hasMoreTokens()) { action =...
The architecture you are talking about could become very cumbersome in the long run, and if you need to change the questions it means more changes to the UDF you are using. I would think you could probably do your analysis in code without necessarily de-normalizing your database. De-normalization could also lend to...
What this probably means is that your Apache is only using 1 child process. Therefore: The 1 child process is handling a request (in this case sleeping but it could be doing real work, Apache can't tell the difference), so when a new request comes it, it will have to wait until the first process is done. The ...
No way, you definitely want to keep it normalized. It's not even that hard of a query. Basically, you want to left join the students correct answers with the total answers for that question, and do a count. This will give you the percent correct. Do that for each student, and put the minimum percent correct in a whe...
Denormalization is generally considered a last resort. The problem seems very similar to survey applications, which are very common. Without seeing your data model, it's difficult to propose a solution, but I will say that it is definitely possible. I'm wondering why you need 20 parameters to that function? A rel...
Adding Inline Search function to web page
|javascript|html|
Is it possible to embed an inline search box into a web page which provides similar functionality to the [IE7Pro Inline Search][1] or similar plugins for Firefox/Safari? [1]: http://www.ie7pro.com/inline-search.html
The tail program is open source, so you could reference that. I wondered the same thing and looked at the code a while back, thinking it would be pretty simple, but I was surprised at how complex it was. There are lots of gotchas that have to be taken into account.
Search strategies in ORMs
|search|orm|engine|doctrine|propel|
I am looking for information on handling search in different ORMs. Currently I am redeveloping some old application in PHP and one of requirements is: make everything or almost everything searchable, so user just types "punkrock live" and the app finds videos clips, music tracks, reviews, upcoming events or even use...
@Andrew - I'm exactly in your situation. I use a MBP while my company work is purely Microsoft based: i.e., .NET, COM etc. While nothing can beat running Vista natively in Boot Camp (I've never seen Vista run so fast), the niceties of having your Mac OS be the "main" OS, for internet, mail etc. has gotten me to the fol...
There should be a vmware.log file or something similar in the directory that contains your vm. After you start the vm, are there any new errors in it? Also, is the network adapter enabled?
If you have a `std::list` of plain old data (what .NET would call 'value types'), then returning a const reference to that list will be fine (ignoring evil things like `const_cast`) If you have a `std::list` of pointers (or `boost::shared_ptr`'s) then that will only stop you modifying the collection, not the items *...
How do you get the current image name from an ASP.Net website?
|c#|asp.net|
Scenario: You have an ASP.Net webpage that should display the next image in a series of images. If 1.jpg is currently loaded, the refresh should load 2.jpg. Assuming I would use this code, where do you get the current images name. <code> string currImage = MainPic.ImageUrl.Replace(".jpg", ""); currImage = c...
Use of const reference or shared pointer will only help if the contents of underlying collection do not change over time. Consider your design. Does the caller really need to see the internal array? Can you restructure the code so that the caller tells object what to do with the array? E.g., if the caller intends to...
Remember that the MAX aggregate function will work on text as well as numbers. This query will only require the table to be scanned once. SELECT Action, MAX( CASE data WHEN 'View' THEN data ELSE '' END ) ViewCol, MAX( CASE data WHEN 'Edit' THEN data ELSE '' END ) EditCol FROM t ...
Alas, this won't solve the re-importing problem, but check out [http://wejn.org/stuff/moz-export.html][1] They have a single html page with a small javascript section that exports your passwords. Save the html to your desktop, read through to make sure it's not evil, open the page in FF, save the results. Maybe I...
You can use the [Foxmarks][1] plugin. This exports to XML or CSV format. I used it a week ago and it works really fine. [1]: https://addons.mozilla.org/en-US/firefox/addon/2410
df -i should tell you the number of inodes used and free on the filesystem
Good overview of different algorithms: - [Computing pi][1]; - [Gauss-Legendre-Salamin][2]. I'm not sure about the complexity claimed for the Gauss-Legendre-Salamin algorithm in the first link (I'd say O(N log^2(N) log(log(N)))). I do encourage you to try it, though, the convergence is *really* fast. Als...
Good overview of different algorithms: - [Computing pi][1]; - [Gauss-Legendre-Salamin][2]. I'm not sure about the complexity claimed for the Gauss-Legendre-Salamin algorithm in the first link (I'd say O(N log^2(N) log(log(N)))). I do encourage you to try it, though, the convergence is *really* fast. Als...
[MultiSelectTreeView][1]: > Why doesn't .NET have a multiselect treeview? There are so many uses for one and turning on checkboxes in the treeview is a pretty lousy alternative. [1]: http://www.codeproject.com/KB/tree/Multiselect_Treeview.aspx
i would start to look at SQL Server Compact Edition for this! It helps with all of your issues. [Data Storage Architecture with SQL Server 2005 Compact Edition][1] It specifically designed for > Field force applications (FFAs). FFAs > usually share one or more of the > following attributes > > ...
XHTML is easy, use [lxml](http://codespeak.net/lxml/validation.html). HTML is harder, since there's traditionally not been as much interest in validation among the HTML crowd (run StackOverflow itself through a validator, yikes). The easiest solution would be to execute external applications such as [nsgmls](http://...
I had good luck in the past with InstantRails, but I'm not sure how up-to-date it is now, as the project has changed hands several times. You might also try [ruby stack][1] or [flash rails][2], though I've not used either personally. [1]: http://bitnami.org/stack/rubystack [2]: http://rubyforge.org/projec...
I didn't know JRun was even still in existence since 1999 or something like that. Anyway, [Tomcat][1] or [Jetty][2] would be my easy replacements. Tomcat for its scriptability from ANT etc and Jetty for its pure simplicity (start an instance in 5 lines of code!). [Glassfish][3] is a huge system with many components,...