instruction
stringlengths
0
30k
What's the best (cross browser) way of restricting the maximum number of characters that can be entered into an html textarea?
You have two choices to do this. The Quick and Dirty is selecting your files (using ctrl) in Project Explorer view, right-click them, choose `Replace with...` and then you choose the best option for you, from `Latest from Repository`, or some `Branch` version. After getting those files you modify them (with a space,...
How is [this][1] for starters. [1]: http://railsforum.com/viewtopic.php?id=17785 # The submit button in your child window's view: <%= button_to_function 'Save', "$('my_form').submit(); window.opener.location.reload(); window.close();" %>
I agree with the others -- set a default value of GetDate() on the LastUpdate column and then use a trigger to handle any updates. Just something simple like this: CREATE TRIGGER KeepUpdated on Profiles FOR UPDATE, INSERT AS UPDATE dbo.Profiles SET LastUpdate = GetDate() WHERE Username I...
I've tried JVoiceXML in the past and had some luck with it. [http://jvoicexml.sourceforge.net/][1] It's java of course, but that wasn't a problem for my situation. [1]: http://jvoicexml.sourceforge.net/
Are you using .Net 1.0 or 1.1? If so then catch(Exception ex) won't catch exceptions from unmanaged code. You'll need to use catch {} instead. See this article for further details: http://www.netfxharmonics.com/2005/10/net-20-trycatch-and-trycatchexception/
> "Also, you can put some code in to > catch all unhandled exceptions. Read > the link for more info, but the basics > are these two lines." This is false. This used to catch all unhandled exceptions in .NET 1.0/1.1 but it was a bug and it wasn't supposed to and it was fixed in .NET 2.0. AppDomain.Current...
As I mentioned [before](http://stackoverflow.com/questions/10961/have-you-used-a-wiki-in-your-project-or-group#10977), a Wiki is very unorganized. However, if that is the only argument from your developers, then invest some effort to create a simple index page and keep it updated (either do it yourself or ask people...
Find "sticky" items (sub-3 pg. docs / diagrams / etc) something that the team seems to be creating again and again & post it on the wiki. Make sure everyone has access to the wiki and knows its there - set up a notification mechanism if possible. With some luck, the next time they have to access, rather than dig it out...
You can't force developers to do something they do not have an incentive of using for; unfortunately wikis, like documentation (well, in fact wikis *are* documentation) rarely have any "cool" value for developers. Besides, they're already deep into dev work -- could you really bother them with a wiki? That being sai...
ASP.NET AJAX allows you to register web services with the ScriptManager which will create JavaScript proxies for you to call. See <http://msdn.microsoft.com/en-us/library/bb515101.aspx>.
I have done some selling and even run some training sessions. I think some people are turned off by the lack of WYSIWYG editing and ability to paste formatted text from Word or Outlook. I know there are some tools to work around these, but they are still barriers. There are some areas where the wiki is being used to...
[SnippetsEmu][1] is a useful snippets plugin. [1]: http://slipperysnippets.blogspot.com/
We've been using a wiki in some form or another for a while now, but it does take a while for people to get on board. You might find that you will be the only one writing articles for some time, but bear with it, other people will come on board eventually. If someone sends an email around that contains information ...
You can use panels with automatic layout such as [FlowLayoutPanel][1] and [TableLayoutPanel][2]. Unfortunately there are only 2 panels with automatic layout out of box but you can create custom layout panel. [1]: http://msdn.microsoft.com/en-us/library/system.windows.forms.flowlayoutpanel.asp [2]: http:/...
You can use panels with automatic layout such as [FlowLayoutPanel][1] and [TableLayoutPanel][2]. Unfortunately there are only 2 panels with automatic layout out of box but you can create custom layout panel. I would recommend you to read following articles: [How to: Create a Resizable Windows Form for Data...
You can use panels with automatic layout such as [FlowLayoutPanel][1] and [TableLayoutPanel][2]. Unfortunately there are only 2 panels with automatic layout out of box but you can create custom layout panel. I would recommend you to read following articles: [How to: Create a Resizable Windows Form for Data...
How are partial methods used in C# 3.0?
|c#|partial-methods|
I have read about partial methods in the latest [C# language specification][1], so I understand the principles, but I'm wondering how people are actually using them. Is there a particular design pattern that benefits from partial methods? [1]: http://msdn.microsoft.com/en-us/vcsharp/aa336809.aspx
|c#|design-patterns|partial-methods|
|c#|design-patterns|.net-3.5|partial-methods|
The TEXTAREA tag does not have a MAXLENGTH attribute the way that an INPUT tag does, at least not in most standard browsers. A very simple and effective way to limit the number of characters that can be *typed* into a TEXTAREA tag is: <textarea onKeyPress="return ( this.value.length < 50 );"></textarea> ...
|c++|string|boolean|
Maybe this is a dumb question, but is there any way to convert a boolean value to a string such that 1 turns to "true" and 0 turns to "false"? I could just use an if statement, but it would be nice to know if there is a way to do that with the language or standard libraries. Plus, I'm a pedant. :)
Impersonation worked well for me in this scenario. We had a wizard that uploaded a zip file through the website, but we load balanced the site. Therefore needed to setup a way to save the file on all the machines. Let me know and I can answer further questions on getting it setup.
Impersonation worked well for me in this scenario. We had a wizard that uploaded a zip file through the website, but we load balanced the site. Therefore needed to setup a way to save the file on all the machines. There are many different ways to do it. We decided to make all requests to run under the user we set...
Although that code looks quite secure, I've always held the opinion that any sufficiently motivated person could break it given adequate time. I do think it will take quite a bit of determination to get through that, but I'm relatively sure it could be done.
Disregarding the theoretical implications, it seems to be "Any language that has a keyword called 'class'" :-P
I agree that a macro might be the best fit. I just whipped up a test case (believe me I'm no good with C/C++ but this sounded fun): #include <stdio.h> #include <stdarg.h> #define BOOL_STR(b) (b?"true":"false") int main (int argc, char const *argv[]) { bool alpha = true; pr...
The unix tool `xxd` is distributed as part of [`vim`](http://www.vim.org/download.php), and according to <http://www.vmunix.com/vim/util.html#xxd>, the source for xxd is <ftp://ftp.uni-erlangen.de:21/pub/utilities/etc/xxd-1.10.tar.gz>. It was written in C and is about 721 lines. The only licensing information given for...
Try this Macro. Anywhere you want the "true" or false to show up just replace it with PRINTBOOL(var) where var is the bool you want the text for. #define PRINTBOOL(x) x?"true":"false"
To further what aib said, I would say that a language isn't really object oriented unless the standard libraries that are available are object oriented. The biggest example of this is PHP. Although it supports all the standard object oriented concepts, the fact that such a large percentage of the standard libraries a...
I think most of the answers so far are spot on - the more you plug away at it yourself, the larger the body of useful information will become, so slowly but surely people will naturally start to use it. The other approach you could use is this: Suggest that every time someone asks another team member a question abo...
In addition to @Fredrik's tip about setting project items to "Copy to Output Directory", you can also specify a post-build action in the project's properties in the Build tab and include CMD commands like copy.exe and move.exe.
If you open the .MSG file in a text editor, i believe you will find that the information you are after is stored as plain text inside the file. (It is on all the messages i have checked at least) It would be pretty easy to write some code to parse the file looking for lines beginning with "From:" or "To:" etc. and t...
The convention I've most seen is simply camel case, like a method name... myLabel: but I've also seen labels prefixed with an underscore _myLabel: or with lab... labSomething: You can probably sense though from the other answers that you'll be hard-pushed to find a coding standard that say...
What appears to be the matter with the code? OK, the question should be... what should the code do that it doesn't already. When I run the code, I see 2 red 'spikes' am I not ment to? You appear to draw the first spike within the clipped rectangle region verified by adding the the following code at the beginni...
What appears to be the matter with the code? OK, the question should be... what should the code do that it doesn't already. When I run the code, I see 2 red 'spikes' am I not ment to? You appear to draw the first spike within the clipped rectangle region verified by adding the the following after the declarati...
I have a couple that I really like: [GlyFx][1] and [Liquidicity Vector Icons][2]. Those from Liquidicity are specially useful for WPF or Silverlight, you can make an interface that even zoomed looks great. [1]: http://glyfx.com/products/free.html [2]: http://www.gosquared.com/liquidicity/archives/122
You didn't mention for what OS, but the [WMI Redistributable Components version 1.0][1] definitely exist. [1]: http://www.microsoft.com/downloads/details.aspx?familyid=013BB284-3946-44A9-AC3C-BF2A569EAA72&displaylang=en "Microsoft Download Center"
You didn't mention for what OS, but the [WMI Redistributable Components version 1.0][1] definitely exists. [1]: http://www.microsoft.com/downloads/details.aspx?familyid=013BB284-3946-44A9-AC3C-BF2A569EAA72&displaylang=en "Microsoft Download Center"
You didn't mention for what OS, but the [WMI Redistributable Components version 1.0][1] definitely exists. For Windows Server 2003, the WMI SDK and redistributables are part of the [Server SDK][2] *I believe* that the same is true for the [Server 2008 SDK][3] [1]: http://www.microsoft.com/downloads/details...
I usually take that approach, but if I feel like it's going to cause confusion, I'll use ellipses like: `myFunction(...)` I guess if I were good, I would use those *any* time I was omitting parameters from a function in text.
Try this: var request = new XMLHttpRequest(); request.overrideMimeType( 'text/xml' ); request.onreadystatechange = process; request.open ( 'GET', url ); request.send( null ); function process() { if ( request.readyState == 4 && request.status...
Try this: var request = new XMLHttpRequest(); request.overrideMimeType( 'text/xml' ); request.onreadystatechange = process; request.open ( 'GET', url ); request.send( null ); function process() { if ( request.readyState == 4 && request.status == 200 ) { ...
I recommend Git. If you're working by yourself SVN or CVS are hated by many people but they're solid options.
Version Control is essential to development, even if you're working by yourself because it protects you from yourself. If you make a mistake, it's a simple matter to rollback to a previous version of your code that you know works. This also frees you to explore and experiment with your code because you're free of havin...
> "Also, you can put some code in to > catch all unhandled exceptions. Read > the link for more info, but the basics > are these two lines." This is false. This used to catch all unhandled exceptions in .NET 1.0/1.1 but it was a bug and it wasn't supposed to and it was fixed in .NET 2.0. AppDomain.Current...
I don't get it...your catch block just throws a new exception (with the same message). Meaning that your statement of: > The problem is that in some cases (not all) that my try/catch block won't catch it and instead stops execution as an unhandled exception. is exactly what is *expected* to happen.
@dmckee: I think the suggested solution is good, but for simple data (e.g. if only the name is needed) it could be augmented with auto-generated code. While there are lots of ways to auto-generate code, for something as simple as this I believe you could write a simple XSLT that takes in an XML representation of the en...
I tried it and it looked promising at first but quickly had issues actually deploying it to a Medium Trust host.
PHP mail using Gmail
|php|email|gmail|
In my PHP webapp, I want to be notified via email whenever certain errors occur. I'd like to use my Gmail account for sending these. How could this be done?
> Are there any general advice or workarounds for organizing or redistributing templated member definitions across multiple files? Yes; don't. The C++ spec permits a compiler to be able to "see" the entire template (declaration _and_ definition) at the point of instantiation, and (due to the complexities of any i...
It's probably a bit late to be looking tonight at code trends for an interview tomorrow. Microsoft is currently busy doing what it has always done: me-too functionality, only better. New dynamically typed languages with a new language runtime and MVC are looking really promising. With WPF and Expression they're c...
It's probably a bit late to be looking tonight at code trends for an interview tomorrow. Microsoft is currently busy doing what it has always done: me-too functionality, only better. New dynamically typed languages with a new language runtime and MVC are looking really promising. With WPF and Expression they're c...
In my biased opinion, C is the best point to start. The language is small, it's high level features are ubiquitous and the low level features let you learn the machine. I found the [C Primer Plus, 5th Edition][1] very helpful as a beginning programmer with almost no programming experience. It assumes no prior progra...
insert/replace XML tag in XmlDocument
|java|xml|xquery|
I have a XmlDocument in java, created with the Weblogic XmlDocument parser. I want to replace the content of a tag in this xmldocument with my own data, or insert the tag if it isnt there. <customdata> <tag1 /> <tag2>mfkdslmlfkm</tag2> <location /> <tag3 /> </customdata> ...
|regex|lisp|emacs|regular-expression|
|regex|emacs|lisp|
For context, I am something of an emacs newbie. I haven't used it for very long, but have been using it more and more (I like it a lot). Also I'm comfortable with lisp, but not super familiar with elisp. What I need to do is bind a regular expression to a keyboard combination because I use this particular regex so...
For context, I am something of an emacs newbie. I haven't used it for very long, but have been using it more and more (I like it a lot). Also I'm comfortable with lisp, but not super familiar with elisp. What I need to do is bind a regular expression to a keyboard combination because I use this particular regex so...
For context, I am something of an emacs newbie. I haven't used it for very long, but have been using it more and more (I like it a lot). Also I'm comfortable with lisp, but not super familiar with elisp. What I need to do is bind a regular expression to a keyboard combination because I use this particular regex so...
Have you tried reinstalling RubyGems? I had a pretty similar error message until I reuninstalled and for some reason, it installed into a different directory and then the problem went away.
I believe that physical security is more important for voting booth system rather than you know, code security. These machine by their very nature shouldn't be connected to any kind of public networks, especially not the the internet. But having a good physical security to prevent any sort of physical tempering is v...
Just finally found [answer][1]... I was missing a gem, and thrown off by bad error message from Rails... [1]: http://www.shorepound.net/wpblog/?p=65
That's probably about the best you can do. Just be aware that anybody with enough dedication, can probably de-obfuscate your program. Just make sure you're comfortable with that before embarking on your project. I think the biggest problem with this would be to control who's using it on their site. If somebody g...
A obfuscator won't help you at all if someone wants to figure out the code. The code still exists on the client machine and they can grab a copy of it and study it at their leisure. There is simply no way to hide code written in Javascript since the source code has to be handed to the browser for execution. If y...
Brad Abrams' [Framework Design Guidelines][1] book is all about this. Might be worth a look. [1]: http://www.amazon.com/Framework-Design-Guidelines-Conventions-Development/dp/0321246756/
I'd say yes, it's enough if you also make sure than you compress the code as well using a tool like [Dean Edward's Packer][1] or similar. If you think about what is possible with tools like .NET Reflector in terms of reverse engineering compiled code / IL in .NET, you realize that there's nothing you can do to complete...
You're always faced with the fact that any user that comes to your webpage will download some working version of your Javascript source. They _will_ have the source code. Obfuscating it may make it very difficult to be reused by someone with the intent to _steal_ your hard work. However, in many cases someone can ev...
If you want a Rails solution, **[Radiant CMS][1]** is a good option. It's simple, elegant, extensible and, of course, comes with all of the benefits of being based on Ruby on Rails. [1]: http://radiantcms.org/
Briefly: 1. Always use transactions 2. Don't use `Close()`, instead wrap your calls on an `ISession` inside a `using` statement From [the documentation](http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html_single/#manipulatingdata-flushing): > From time to time the `ISession` will execute the SQ...
Gishu has the right idea : for( int idx = 0; idx < vectorLength; idx++) { if (!conditionAtVectorPosition( v, idx ) && checkedRow(v, idx)) setValueInVector( v, idx ); } private boolean checkedRow(Vector v, int idx) { for( rowIdx = 0; rowIdx < n; rowIdx++ )...
I'm not too sure to understand the first continue. I would copy Gishu and write something like ( sorry if there are some mistakes ) : for( int idx = 0; idx < vectorLength; idx++) { if( !conditionAtVectorPosition( v, idx ) && CheckedEntireMatrix(v)) setValueInVector( v, idx ); } ...
A simple linked list can be used for this. Basically you add new items to the end, and remove too old items from the start, it is a cheap data structure. example-code: list.push_end(new_data) while list.head.age >= age_limit: list.pop_head() If the list will be busy enough to warrant chopp...
.Net drawing clipping bug
|winforms|system.drawing|gdi+|graphics|
gdi+ DrawLines function has a clipping bug that can be reproduced by running the following code: protected override void OnPaint(PaintEventArgs e) { PointF[] points = new PointF[] { new PointF(73.36f, 196), new PointF(75.44f, 32), new PointF(77.52f, 32), ...
|winforms|graphics|gdi+|system.drawing|
gdi+ DrawLines function has a clipping bug that can be reproduced by running the following c# code. When running the code two line paths appear that should be identical, because both of them are inside the clipping region, but when the clipping region is set one of the line segment is not drawn. protected over...
How do I close a popup window, and open the next page in the main window in ROR?
|ruby|ruby-on-rails|html|popup|
I have a popup window containing a form which gathers data for a report. When I click submit in that window, I want it to close the popup, and open the report in the original window that called the popup. I think I can open the report in the correct window by using { :target => <name of window> } in the form...
|html|ruby|ruby-on-rails|
I agree with [Daniel Auger][1] and [kronoz][2] that this smells like an exception that has something to do with threads. Beyond that, here are my other questions: 1. What does the complete error message say? What kind of exception is it? 2. Based on the stack trace you've provided here, isn't the exception thrown b...
You could use PEAR's mail function with Gmail's SMTP Server Note that when sending e-mail using Gmail's SMTP server, it will look like it came from your Gmail address, despite what you value is for $from. (following code taken from [About.com Programming Tips][1] ) <?php require_once "Mail.php"; ...
Other languages? Well, in Java you call e.printStackTrace(); It doesn't get much simpler than that.
It depends on what kind of sanitizing you are doing. For protecting against SQL injection, don't do anything to the data itself. Just use prepared statements, and that way, you don't have to worry about messing with the data that the user entered, and having it negatively affect your logic. You have to sanitize ...
Briefly: 1. Always use transactions 2. Don't use `Close()`, instead wrap your calls on an `ISession` inside a `using` statement From [the documentation](http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html_single/#manipulatingdata-flushing): > From time to time the `ISession` will execute the SQ...
I like tools that will perform more than one task, Notepad++ is a great notepad replacement and has a Document Monitor plugin (installs with standard msi) that works great. It also is portable so you can have it on a thumb drive for use anywhere. For a command line option, PowerShell (which is really a new command l...
A lot of the research on this is dedicated to detecting so-called "blue pill" attacks, that is, a malicious hypervisor that is actively attempting to evade detection. The classic trick to detect a VM is to populate the ITLB, run an instruction that **must** be virtualized (which necessarily clears out such process...
Make a generic list of textboxes: List<TextBox> textBoxes = new List<TextBox>(); for (int i = 0; i < 10; i++) { TextBox textBox = new TextBox(); textBox.Text = "Textbox " + i; textBoxes.Add(textBoxes); } for (int i = 0; i < textBoxes.Count; i++) { text...
Make a generic list of textboxes: List<TextBox> textBoxes = new List<TextBox>(); // Create 10 textboxes in the collection for (int i = 0; i < 10; i++) { TextBox textBox = new TextBox(); textBox.Text = "Textbox " + i; textBoxes.Add(textBoxes); } // Loop through ...
I always wrap a transaction in a using statement. using(IDbTransaction transaction ) { // logic goes here. transaction.Commit(); } Once the transaction moves out of scope, it is disposed. If the transaction is still active, it is rolled back. This behaviour fail-safes you from accidenta...
I always wrap a transaction in a using statement. using(IDbTransaction transaction ) { // logic goes here. transaction.Commit(); } Once the transaction moves out of scope, it is disposed. If the transaction is still active, it is rolled back. This behaviour fail-safes you from accidenta...