instruction
stringlengths
0
30k
@Juan Manuel Did you ever work in classic ASP? When you had to program all of your own events and "viewstatish" items (like a dropdown recalling its selected value after form submission)? If so, then ASP.NET MVC will not feel that awkward off the bat. I would check out Rob Conery's Awesome Series "[MVC Storefront][1...
Honestly I think it depends on the discipline of the developers. I use Subversion for my personal work and I've used it at a few jobs. What I like about Subversion is I don't have to hunt someone down and ask them why they're working on something and if it would be OK for me to do some work. The problem comes when...
I know almost nothing about linq. I'm doing this: var apps = from app in Process.GetProcesses() where app.ProcessName.Contains( "MyAppName" ) && app.MainWindowHandle != IntPtr.Zero select app; Which gets me all the running processes which match that criteria. But I don't know how to get t...
One useful strategy to keep in mind might be the [composite pattern][1]. At a low level, it might allow you to treat all GUI objects (and collections of objects) more easily once built. But I have no idea what's involved in GUI framework design, so one place to find general inspiration is in the source code of an exist...
Assuming that in your first example apps is an IEnumerable<Process> you could make use of the .Count and .FirstOrDefault properties to get the single item that you want to pass to SetForegroundWindow. var apps = from app in Process.GetProcesses() where app.ProcessName.Contains( "MyAppName" ) && app.MainWind...
I found Ted Jensen's "Tutorial on Pointers and Arrays in C" an excellent resource for learning about pointers. It is divided into 10 lessons, beginning with an explanation of what pointers are (and what they're for) and finishing with function pointers. <http://home.netcom.com/~tjensen/ptr/cpoint.htm> Moving on from...
I think looking at the way other GUI toolkits have done it would be an excellent place to start. For C++ examples, I hear lots of good things about [Qt][1]. I haven't used it personally though. And of course WxWidgets as Nick mentioned. [1]:http://trolltech.com/products/qt/
@FryHard FirstOrDefault will work but remember that it returns null if none are found. This code isn't tested but should be close to what you want: var app = Process.GetProcesses().FirstOrDefault(p => p.ProcessName.Contains("MyAppName") && p.MainWindowHandle != IntPtr.Zero); if (app == null) return; Se...
Well, you can already lock up a browser and *seriously* slow down a system with badly-behaved JS. Enlightened browsers have implemented checks for this sort of thing, and will stop it before it gets out of hand. I would tend to assume that threads would be dealt with in a similar manner.
Well, you can already lock up a browser and *seriously* slow down a system with badly-behaved JS. Enlightened browsers have implemented checks for this sort of thing, and will stop it before it gets out of hand. I would tend to assume that threads would be dealt with in a similar manner. --- Perhaps you could ...
I would probably use struct as the type, and then throw an exception if it isn't an Enum type. I don't see how your (Type, string) option is any safer than using object or struct.
**Install the ASP.NET AJAX Control Toolkit** Download the ZIP file AjaxControlToolkit-Framework3.5SP1-DllOnly.zip from the ASP.NET AJAX Control Toolkit Releases page of the CodePlex web site. Copy the contents of this zip file directly into the bin directory of your web site. http://www.codeplex.com/AjaxContro...
**Install the ASP.NET AJAX Control Toolkit** 1. Download the ZIP file AjaxControlToolkit-Framework3.5SP1-DllOnly.zip from the [ASP.NET AJAX Control Toolkit Releases][1] page of the CodePlex web site. 2. Copy the contents of this zip file directly into the bin directory of your ...
Here's my html-light version: <script type="text/javascript"> function switchTo(index) { $('#switches li').css('font-weight', 'normal'); $('#switches li').eq(index).css('font-weight', 'bold'); $('#slides div').css('display', 'none'); $('#slides div').eq(index).css('displa...
Here's my html-light version: <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> function switchTo(index) { $('#switches li').css('font-weight', 'normal'); $('#switches li').eq(index).css('font-weight', 'bold'); $('#slides div').css('di...
Here's my html-light version: <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> function switchTo(index) { $('#switches li').css('font-weight', 'normal'); $('#switches li').eq(index).css('font-weight', 'bold'); $('#slides div').css('di...
- I would use a minor variation in the second union: where (ISNULL(feed_tbl.name, 'NONAME') <> ISNULL(data_tbl.name, 'NONAME')) OR (ISNULL(data_tbl.status, 'NOSTATUS') <> ISNULL(feed_tbl.status, 'NOSTATUS')) OR (ISNULL(data_tbl.update, '12/31/2039') <> ISNULL(feed_tbl.update, '12/31/2039')) For...
Agree with Frank here, there's not a problem with static (global) functions (of course providing they are organised).. The problems only start to really creep in when people think "oh I will just make the scope on this bit of data a little wider".. Slippery slope :)
Agree with Frank here, there's not a problem with static (global) functions (of course providing they are organised).. The problems only start to really creep in when people think "oh I will just make the scope on this bit of data a little wider".. Slippery slope :) To put it really into perspective.. [Functional Pr...
Visual Assist X. Spell checks your comments and a whole lot more. [http://www.wholetomato.com/][1] [1]: http://www.wholetomato.com/
Regex (C#): Replace \n with \r\n
|c#|regex|
How can I replace lone instances of \n with \r\n (LF alone with CRLF) using a regular expression in C#? Sorry if it's a stupid question, I'm new to Regex. I know to do it by: myStr.Replace("\n", "\r\n"); myStr.Replace("\r\r\n", "\r\n"); But this is inelegant, and would destroy any "\r+\r\n" alre...
For more of this kind of silliness see this nice article pertaining to Windows calculator. [When you change the insides, nobody notices](http://blogs.msdn.com/oldnewthing/archive/2004/05/25/141253.aspx)
For more of this kind of silliness see this nice article pertaining to Windows calculator. [When you change the insides, nobody notices](http://blogs.msdn.com/oldnewthing/archive/2004/05/25/141253.aspx) > The innards of Calc - the arithmetic > engine - was completely thrown away > and rewritten from scratch. Th...
Setting up replicated repositories in Plastic SCM
|plasticscm|repository|version-control|distributed|
So we're trying to set up replicated repositories using PlasticSCM, one in the US, and one in Australia and running into a bit of a snag. The US configuration is Active Directory, the AU configuration is User/Password. This in itself is not a big deal, I've already set up the SID translation table. The problem...
I often use this little snippet I've written long time ago. It's short and easy to add anywhere when debugging etc... #include <ctype.h> #include <stdio.h> void hexdump(void *ptr, int buflen) { unsigned char *buf = (unsigned char*)ptr; int i, j; for (i=0; i<buflen; i+=16) { ...
You'll need to instance a [`ResourceManager`](http://msdn.microsoft.com/en-us/library/aa984408%28VS.71%29.aspx) for the `Login.resx`: var resman = new System.Resources.ResourceManager( "RootNamespace.Login", System.Reflection.Assembly.GetExecutingAssembly() ) var text = resman.GetStri...
I've worked with Word documents in SVN. With [TortoiseSVN](http://tortoisesvn.tigris.org/), you can easily diff Word documents (between working copy and repository, or between two repository revisions). It's really slick and definitely recommended. The other thing to do if you're using Word documents in SVN is to ad...
How to bring in a web app
|web-applications|beta|launching|
I run a game and the running is done by hand, I have a few scripts that help me but essentially it's me doing the work. I am at the moment working on web app that will allow the users to input directly some of their game actions and thus save me a lot of work. The problem is that I'm one man working on a moderately ...
> Thinstall is great for single apps, but not an entire stack.... I didn't try it yet, but with the new version of thinstall you are able to let different thinstalled application communicate. But I guess you're right a vm-ware image would be easier
We're talking about C++ right? Why on earth are we still using macros!? C++ inline functions give you the same speed as a macro, with the added benefit of type-safety and parameter evaluation (which avoids the issue that Rodney and dwj mentioned. inline const char * const BoolToString(bool b) { re...
Here's my light-markup jQuery version: <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> function switchTo(i) { $('#switches li').css('font-weight','normal').eq(i).css('font-weight','bold'); $('#slides div').css('display','none').eq(i).css('display',...
I know this is going to be heresy for a cygwin user, but you could just use [PuTTY][1] instead. [1]: http://www.chiark.greenend.org.uk/~sgtatham/putty/
Always use nvarchar. You may never need the double-byte characters for most applications. However, if you need to support double-byte languages and you only have single-byte support in your database schema it's really expensive to go back and modify throughout your application. The cost of migrating one appli...
As far as I know this is not possible. You **might** be able to do it if you use uncompressed wave files already encoded in DTS or something and put a surround receiver in between. This will however stop you from doing anything with the sound before outputting it, not even changing the volume. And I guess that's no...
The question is ill-posed in the standard [ZFC][1] (Zermelo-Fraenkel + axiom of Choice) set theory because the object thus defined is not a set. Since (again, assuming standard ZFC) your _class_ {x : x\not\in x} is not a set, the answer becomes no, it's not an element of itself (even as a class) since only sets can ...
How can I change the way my Drupal theme displays the front page
|css|drupal|themes|
Here are the rules for the types that can be included as Attribute parameters: <http://tinyurl.com/59blgw>
Best way to pass a large number of arguments into a configuration dialog
|c#|
I've got a situation where I have a main form that pops up an advanced configuration form that just has half a dozen matched check boxes and combo boxes to select some advanced options (the check boxes to enable/disable, the combo to select a media if enabled). If I just pass the individual settings for the check an...
You really need to use a memory profiler that tracks allocations. Take a look at [JProfiler][1] - their "heap walker" feature is great, and they have integration with all of the major Java IDEs. It's not free, but it isn't that expensive either ($499 for a single license) - you will burn $500 worth of time pretty quick...
Check out this LGPL project. I know it can set foreground for a window. Otherwise aku is correct. It'll require most likely some pinvoke calls. http://mwinapi.sourceforge.net/ If you need information on pinvoke use: http://www.pinvoke.net/
I'm a bit confused, I'm not being flippant -- you say you want to return exceptions serialised as XML on the one hand and that the user will never see the exceptions on the other hand. Who will be seeing these exceptions? Normally I'd say to use WCF fault contracts.
It turns out that the answer was easier than I expected. There is a `--batch` parameter missing, gpg tries to read from /dev/tty that doesn't exist for cron jobs. To debug that I have used `--exit-on-status-write-error` param. But to use that I was inspired by exit status 2, reported by echoing `$?` as Cd-Man suggested...
I personally would create a carrier object to store the values. You then get the nice intellisense for it, and changes to it would be quite straightforward. It would also be faster than dictionary lookups for parameter values. And of course, you get type safety. :)
Personally, I use a set of methods I have developed for bridging the server-side ASP.NET "magic" (I have yet to use the MS MVC stuff yet) and my client-side code because of the munging of the IDs that happens. Here is just one that may or may not prove useful: public void RegisterControlClientID(Control contro...
From some of the initial research it doesn't appear to be a super simple solution. It appears that doing this involves having Visual Studio 2008 actually installed on the continuous integration server, which could be a deal breaker. Then configure the MSTest.exe to run in the tasks list, but first you'll have to...
You should be able to check out the current version of the code and then create a git repository around it. Updating that and committing it to your local git repository should be painless. As should cloning it. The only catch is that you need to have them both ignore each other (I've done something similar with SVN)...
A short form is convenient and helps avoid spelling mistakes. Localize as applicable, but be sure to display the expected format (do not leave the user blind). Provide a date-picker control as an *optional* aide to filling in the field. As an extra, on-the-fly parsing and display of the date in long form might help ...
Well... KernelTrap has [something on this][1]. Looks like you can use [vss2svn][2] to pipe the Source Safe repo into a Subversion repository, then use the very nice git-svn to pull into a local git repo. I would assume the commits back to VSS would not be a smooth, automatic process using this method. [1]: http:...
While I would still like an answer to why my JS wasn't being recognized, the solution I found in the meantime (and should have done in the first place) is to use an Asp:CompareValidator instead of an Asp:CustomValidator.
While you cannot prevent usage of those inherited members to my knowledge, you should be able to hide them from IntelliSense using the [EditorBrowsableAttribute][1]: Using System.ComponentModel; [EditorBrowsable(EditorBrowsableState.Never)] private string MyHiddenString = "Muahahahahahahahaha"; ...
I think you're best least hackish way is to consider composition as opposed to inheritance. Or, you could create an interface that has the members you want, have your derived class implement that interface, and program against the interface.
Reducing duplicate error handling code in C#?
|c#|exception|error-handling|
I've never been completely happy with the way exception handling works, there's a lot exceptions and try/catch brings to the table (stack unwinding, etc.), but it seems to break a lot of the OO model in the process. Anyway, here's the problem: Let's say you have some class which wraps or includes networked file I...
I've used [JMeter](http://jakarta.apache.org/jmeter/). Besides testing the web server you can also test your database backend, messaging services and email servers.
My opinion is if you are depending on a minimum/maximum/specific size **don't** just assume that (say) an `unsigned int` is 32 bytes - use `uint32_t` instead (assuming your compiler supports C99).
There have already been a bunch of great answers, but for an absolute beginner, I would wholeheartedly recommend [Hackety Hack][1]. It was created by the unreasonably prolific [why_the_lucky_stiff][2] specifically to provide a BASIC/LOGO/Pascal-like environment for new programmers to experiment in. It's essentially a s...
And some more links, just in case the above didn't suffice: [Windows Presentation Foundation - Data Binding How-to Topics](http://msdn.microsoft.com/en-us/library/ms752039.aspx) (approx 30 'How To' articles from MSDN) "The topics in this section describe how to use data binding to bind elements to data fr...
And some more links, just in case the above didn't suffice: [Windows Presentation Foundation - Data Binding How-to Topics](http://msdn.microsoft.com/en-us/library/ms752039.aspx) - Approx 30 'How To' articles from MSDN. "The topics in this section describe how to use data binding to bind elements to data...
We use the [Web Service Software Factory][1], and we really like it because it makes it easier for developers to follow standards and appropriate patterns. The learning curve for us wasn't bad - a few hours per developer at most. Other than that, there aren't any other pros & cons worth mentioning. [1]: http:...
Facebook does it, when you write on people's walls, but only resizes vertically. Horizontal resize strikes me as being a terrible mess, due to word-wrap, long lines, and so on, but vertical resize would be pretty safe and nice Facebook is inhabited by every idiot on the planet, and none of the facebook-using-idi...
I am trying to build an website for my college's magazine. I used the "views" module to show a block of static content I created on the front page. My question is: how can I edit the theme's css so it changes the way that block of static content is displayed? For reference, <a href="http://www.historia.uff.br/aro...
Best practices for signing .NET assemblies?
|.net|assembly|signing|
I have a solution consisting of 5 projects, each of which compile to separate assemblies. Right now I'm code-signing them, but I'm pretty sure I'm doing it wrong. What's the best practice here? - Sign each with a different key; make sure the passwords are different - Sign each with a different key; use the same p...
Since your application is small, there is essentially no appreciable cost increase to using nvarchar over varchar, and you save yourself potential headaches down the road if you have a need to store unicode data.
A better solution is to store the MD5 in the configuration file. But instead of the MD5 being just of the configuration file, also include some "key" value, like a fixed guid, in the MD5. write(MD5(FixedGUID + ConfigFileText)); Then you simply remove that MD5 and rehash it with your secret key. If the MD5's...
A better solution is to store the MD5 in the configuration file. But instead of the MD5 being just of the configuration file, also include some secret "key" value, like a fixed guid, in the MD5. write(MD5(SecretKey + ConfigFileText)); Then you simply remove that MD5 and rehash the file (including your secret...
If you use Active Directory you could have each app use AD for authentication, login could then be seamless. Otherwise, if the applications can talk to each other behind the scenes, you could use sessionids and have one app handling id generation serving all of your other applications.
Assuming you meant "How do I test against things that are hard/impossible to mock": If you have a class that "goes out and gets the Win32_LogicalDisk object for a server" AND does something else (consumes the 'Win32_LogicalDisk' object in some way), assuming you want to test the pieces of the class that consume this...
WPF - Load Font from Stream?
|wpf|fonts|stream|
I have a MemoryStream with the contents of a Font File (.ttf) and I would like to be able to create a FontFamily WPF object from that stream **WITHOUT** writing the contents of the stream to disk. I know this is possible with a System.Drawing.FontFamily but I cannot find out how to do it with System.Windows.Media.FontF...
|wpf|fonts|stream|
XML is often used for configuration, and in this case there are some other simple storage formats that are often used (less document oriented): 1. [.property files][1] 2. [INI files][2] There's various ways for reading and writing both, depending on platform and language. [1]: http://en.wikipedia.org/wiki...
Depending on what you are encoding (size, framerate, hardware, etc) real-time encoding may not even be possible. Video encoding is VERY CPU intensive.
I'm looking for "unbreakable" watermarks, so data stored in exif or image metadata are out. I have found some interesting stuff on the web while waiting for replies here: http://www.cosy.sbg.ac.at/~pmeerw/Watermarking/ There is a master thesis that's fairly exhaustive about algorithms and their caracteristics (w...
We're talking about C++ right? Why on earth are we still using macros!? C++ inline functions give you the same speed as a macro, with the added benefit of type-safety and parameter evaluation (which avoids the issue that Rodney and dwj mentioned. inline const char * const BoolToString(bool b) { re...
Assuming that this will work in PERL as it does in languages that claim to use PERL-compatible syntax: `/<\/?[^p][^>]*>/`
Assuming that this will work in PERL as it does in languages that claim to use PERL-compatible syntax: `/<\/?[^p][^>]*>/` EDIT: But that won't match a `<pre>` or `<param>` tag, unfortunately. This, perhaps? /<\/?(?!p>|p )[^>]+>/ That should cover `<p>` tags that have attributes, too.
How to keep the browser history in sync when using Ajax?
|asp.net|web|ajax|
I'm writing a simple photo album app using ASP.NET Ajax. The app uses async Ajax calls to pre-load the next photo in the album, without changing the URL in the browser. The problem is that when the user clicks the **back** button in the browser, the app doesn't go back to the previous photo, instead, it navigates...
Since HTML is not a regular language I would not expect a regular expression to do a very good job at matching it. They might be up to this task (though I'm not convinced), but I would consider looking elsewhere; I'm sure perl must have some off-the-shelf libraries for manipulating HTML. Anyway, I would think that w...
There are tools that should help you find your leak, like JProbe, YourKit, AD4J or JRockit Mission Control. The last is the one that I personally know best. Any good tool should let you drill down to a level where you can easily identify what leaks, and where the leaking objects are allocated. Using HashTables, Has...
Something like this should be good: MyConfigurationDialog dialog = new MyConfigurationDialog(); //Copy the dictionary so that the dialog can't mess with our settings dialog.Settings = new Dictionary(existingSettings); if(DialogResult.OK == dialog.Show()) { //grab the settings th...
Well, why not just throw the standard SOAPExceptions? The problem with error codes and serialized XML is that they both require additional logic to recognize that an error did in fact happen. Such an approach is only useful if you have specialized logging or logic that needs to happen on the other side of the web se...
Update in Linq
|c#|linq|
How can i update an entity that is disconnected from database? Code below does not run correctly and throws InvalidOperationExcepiton. public void Foo() { DataContext context = new DataContext(); LinqEntity item = new LinqEntity(){ Id = 1, Name = "John", Surname = "Doe"} ; context.Linq...
I think that [mod_filter_ext][1] is the module you are looking for. You can write a short Perl script for example to insert the JS code in the pages and register it to process HTML pages: while (<>) { s/<html>/\Q<script>....\E/; print $_; } You could even use something like `sed` to per...