input
stringlengths
51
42.3k
output
stringlengths
18
55k
Is there a free/open-source JavaScript-to-JavaScript compacting compiler (like Google's)? <p>If you look at the source of Google pages with JavaScript, you'll find that the JavaScript is clearly not readable -- or maintainable. For example, all variables and functions are one-letter named (at least, the first 26 are......
<p><a href="http://developer.yahoo.com/yui/compressor/" rel="nofollow">YUI Compressor</a> is a Java app that will compact and obfuscate your Javascript code. It is a Java app that you run from the command line (and would probably be part of a build process).</p> <p>Another one is <a href="http://code.google.com/p/min...
Error with Windows Installer ... "Unable to get installer types" <p>Good morning everyone,</p> <p>I'm experiencing an error when using the windows installer to install an event source in a product I am deploying.</p> <p>The error message I receive states the following ...</p> <blockquote> <p>Unable to get installe...
<p>I have never seen that error, but the path c:\temp\program.exe is very strange. Are you trying to run the installer from the c:\temp\ directory?</p> <p>Are you certain the output of all projects and all third-party DLLs you use are included in the Deployment project? Click on all included files in the Deployment pr...
Adobe air window with no chrome badly calculates dimensions when maximized <p>When i maximize an air window that has no chrome (no system chrome, no flex chrome but i think it's the same even if only flex chrome is used) a few pixels on all sides go offscreen. </p> <p>Anyone has a solution for this or knows why it hap...
<p>It's actually easiest to set the air window to the size of the monitor, then set your custom UI to the size of the monitor minus a few pixels. That's the only workaround that I've come up with.</p> <p>The only downside to this approach may be a small rendering performance loss, since the AIR window has to take alph...
What tools do I need to do Silverlight development? <p>I already own Visual Studio 2008 Team Version, and have an MSDN subscription...and I am an experienced ASP.Net developer.</p> <p>What do I need to install to do Silverlight development, and can all of those tools be installed alongside my current "production" deve...
<p>Download the Silverlight 2.0 SDK and Visual Studio 2008 Tools</p> <p>Microsoft® Silverlight™ 2 Software Development Kit</p> <p>Microsoft® Silverlight™ Tools for Visual Studio 2008 SP1</p> <p>Check here for the links</p> <p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=4E03409A-77F3-413F...
Any new hope? Making a window an MDI child <p>Got some C# forms/controls that can be called up either from a C# control on a Winform in a Winforms MDI app OR the same C# control used by a PowerBuilder MDI app via COM.</p> <p>I've been using the WinAPI call SetParent to attach forms to the MDI.</p> <ol> <li>It works (...
<p>In the end, we found that the difference was that PB was doing the equivalent of setting .MDIParent for the control PX (the one where calling up form D worked) but not for PY. </p> <p>Once that was sorted then we were then getting the correct MDIParent handle and all is now well.</p>
What language/tool should I use for HTML parsing? <p>I have a couple of websites that I want to extract data from and based on previous experiences, this isn't as easy as it sound. Why? Simply because the HTML pages I have to parse aren't properly formatted (missing closing tag, etc.).</p> <p>Considering that I have n...
<p>You can use pretty much any language you like <strong>just don't try and parse HTML with regular expressions.</strong></p> <p>So let me rephrase that and say: you can use any language you like that has a HTML parser, which is pretty much everything invented in the last 15-20 years.</p> <p>If you're having issues w...
Javascript calling C# function under Silverlight <p>I have a Silverlight application using C#, with 2 main functions that I want to make accessible from JavaScript functions. I have done the RegisterScriptableObject() in the class and set-up the [ScriptableMember] for the functions I want access to.</p> <p>This the S...
<p>As timheuer said, [Scriptable] on your Silverlight methods.</p> <p>Call this in your class:</p> <pre><code>HtmlPage.RegisterScriptableObject("Page", this); </code></pre> <p>Call the Silverlight methods marked as Scriptable from your javascript like this:</p> <pre><code>function CenterMap(latitude, longitude) { ...
Can I change a nested master page's master dynamically? <p>Okay, so we all know about changing a master page dynamically in a page's OnPreInit event.</p> <p>But what about a nested master page? Can I change a master's master?</p> <p>There is no OnPreInit event exposed in the MasterPage class.</p> <p>Any ideas?</p>
<p>Just tested this and it works from the PreInit of the Page that is using the nested MasterPage.</p> <pre><code>protected void Page_PreInit(object sender, EventArgs e) { this.Master.MasterPageFile = "/Site2.Master"; } </code></pre> <p>Obviously you will need to ensure that the ContentPlaceholderIds are consiste...
OnValidating Event in a custom control <p>When does the <code>OnValidate</code> event fire in the life-cycle of a control?</p> <p>I'm creating a <code>DateBox</code> that will allow the user to enter a date in MM/DD/YYYY format (text) and need to verify that the date is in that format. It'll never be converted to a da...
<p><a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.aspx" rel="nofollow">MaskedTextBox Control</a> might help you.</p>
How to get users to pay attention to problems? <p>We occasionally need to notify users about warnings or problems. But often times, especially if it's a common problem, users will just dismiss the warning and continue. Often times users won't even remember seeing the warning, but we check their logs and see that severa...
<p>If you want users to pay attention to warnings, use them in moderation!</p> <p>The big problem with the UAC in Vista is that people are getting so many notifications, that they stop reading <em>who</em> is exactly requesting access to <em>what</em>, they just give permission without thinking.</p> <p>Another exampl...
Setting non-canonical mode on stdin with Ruby <p>I'm playing around with making a simple terminal-based game with Ruby, and I'm currently trying to come up with a way of reading input from the terminal.</p> <p>So far I've been using <code>gets</code>, but I'd like to have the game react instantly without requiring a n...
<p>Your problem is outside of ruby. </p> <p>Easiest answer: wrap your IO in %x{stty -raw echo} and %x{stty -raw echo} to change the mode with stty.</p> <p>You'll probably want to do and ensure an exit handler to make certain the mode is set back when you exit.</p> <p>-- MarkusQ</p>
Where should I implement functionality in Page object - constructor or OnPreInit? <p>A question I have been thinking about for a while - would Stackoverflow users commonly implement significant functionality in a constructor (specifically in classes derived from the System.Web.UI.Page class) , or should we keep the log...
<p>I think your reasoning is very sound - I agree that <code>OnPreInit</code> is the proper place for such logic.</p>
Oracle Trigger: raise_application_error <p>I want to use the raise_application_error-procedure to stop the login process. I wrote a trigger, that checks the TERMINAL String, if it is right (I know that isn't realy secure, but at first, it is enough) So the Trigger works fine and does what i want, but the raise_applicat...
<p>Read this ask tom-thread: <a href="http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3236035522926" rel="nofollow">http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3236035522926</a> </p>
svn externals not adding all files <p>We have an external app_code folder shared among multiple projects. I have noticed that when I do an svn update using tortoise svn that not all the files within the folder get added to my app_code working folder. If I delete the whole folder and do an update all files are added. Th...
<p>Make sure that all your repositories have different uuids.</p>
"Program has exited with status 101" <p>Can someone give me a bit more information on this error please?</p> <p>Console only logs Program exited with status value:101.</p> <p>If you imagine I have a nsmutablearray:</p> <p><img src="http://farm4.static.flickr.com/3547/3301056092%5F8d3ab78225.jpg?v=0" alt="alt text" /...
<p>I believe that's the result code when your program is automatically closed for using too much memory.</p> <p>It's not a true crash, so it won't stop execution or invoke gdb.</p>
Castle Windsor: suppress exceptions thrown by Resolve() <p>When resolving a component which the Windsor container cannot find, an exception is thrown.</p> <p>StructureMap has a TryGetInstance method, which returns null of it can't find the requested component.</p> <p>Does Castle Windsor has something like this? Or am...
<p>You can check if the MicroKernel has an instance of the component registered before calling the Resolve method of the Windsor container.</p> <p>Something like the following should work.</p> <pre><code>if ( windsor.Kernel.HasComponent( componentType ) ) { return windsor.Resolve( componentType ); } return null;...
ASP.NET MVC jQuery migration from 1.2.6 to 1.3.2 <p>I have a problem with jQuery migration from 1.2.6 to 1.3.2 in my project. The intellisense for jQuery in VS doesn't work.</p> <p>To test this issue I created new project, added jQuery to master page, built solution and checked intellisense - works OK.</p> <p>After t...
<p>Actually, you have to install a new intellisense file. Check <a href="http://blogs.ipona.com/james/archive/2009/01/14/jquery-1.3-and-visual-studio-2008-intellisense.aspx" rel="nofollow">this</a> out. </p>
C# Begin/EndReceive - how do I read large data? <p>When reading data in chunks of say, 1024, how do I continue to read from a socket that receives a message bigger than 1024 bytes until there is no data left? Should I just use BeginReceive to read a packet's length prefix only, and then once that is retrieved, use Rece...
<p>No - call <code>BeginReceive</code> again from the callback handler, until <code>EndReceive</code> returns 0. Basically, you should keep on receiving asynchronously, assuming you want the fullest benefit of asynchronous IO.</p> <p>If you look at the MSDN page for <a href="http://msdn.microsoft.com/en-us/library/dxk...
C# setting multiple properties through a single assignment <p>I have a property that is assigned as:</p> <pre><code>public string propertyA{get;set;} </code></pre> <p>I want to call a method automatically when this property is set to assign another property in the class. Best way to trigger the call?</p>
<p>You don't have to use that syntax that is just shorthand. If you expand it you can do whatever you like in the setter.</p> <pre><code> public string PropertyA { get { return a; } set { a = value; doStuff(); } } </code></pre>
What is the best way to generate an ID for a SQL Insert? <p>What is the best, DBMS-independent way of generating an ID number that will be used immediately in an INSERT statement, keeping the IDs roughly in sequence?</p>
<p>DBMS independent? That's a problem. The two most common methods are auto incrementing columns, and sequences, and most DBMSes do one or the other but not both. So the database independent way is to have another table with one column with one value that you lock, select, update, and unlock.</p> <p>Usually I say "...
How can I return multiple rows as a single row in T-SQL? <p>A few months ago our vendor added a capability to our ticketing system which lets us add any number of custom fields to a ticket. I'd like to query these fields out along with the other call information for reporting purposes, but each extensible field is sto...
<p>Try to look at <a href="http://stackoverflow.com/questions/488020/what-is-your-most-useful-sql-trick-to-avoid-writing-more-code/488897#488897">this answer</A>.</p> <p>It does exactly what you want to do.</p>
What is the memory footprint for .NET Framework Compact Edition? <p>What is the memory footprint for .NET Framework Compact Edition? </p> <p>Thanks.</p>
<p>According to <a href="http://en.wikipedia.org/wiki/.NET%5FMicro%5FFramework" rel="nofollow">this wikipedia page</a>, it's about 12MB</p> <p>But then again, <a href="http://msdn.microsoft.com/en-us/library/s6x0c3a4.aspx" rel="nofollow">this page</a> says it'll run in 128KB to 1MB.</p> <p>My guess is that it's going...
How do I deregister an anonymous handler? <p>C# 2.0 has a neat feature called anonymous functions. This is intended to be used mostly with events: </p> <pre><code>Button.Click += delegate(System.Object o, System.EventArgs e) { System.Windows.Forms.MessageBox.Show("Click!"); }; </code></pre> <p>Now,...
<p>No, anonymous functions will not get deregistered automatically. You should make sure to do it yourself, if the event should not be hooked up for the whole lifetime of your application.</p> <p>To do this, of course, you would have to store the delegate reference, to be able to de-register it. Something like:</p> ...
Performance implications of sql 'OR' conditions when one alternative is trivial? <p>I'm creating a stored procedure for searching some data in my database according to some criteria input by the user.</p> <p>My sql code looks like this:</p> <pre><code>Create Procedure mySearchProc ( @IDCriteria bigint=null, ... @MaxD...
<p>OR clauses are notorious for causing performance issues mainly because they require table scans. If you can write the query without ORs you'll be better off.</p>
Calling .net assembly from vb6 results in runtime error 424 <p>I'm running into some trouble calling a .net assembly from vb6 and was hoping SO could help.</p> <p>In VB.net I built a ComClass and kept the default constructor and GUIDs. When deploying, I REGASM.exe the dll, which is located in the same folder as the V...
<p>Try REGASM /CODEBASE. This allows you to load the dll where it is instead of the GAC.</p>
How to stop Flex / AIR XOR-ing a fill? <p>If you try the following code:</p> <pre><code>g.beginFill(0xFF0000); g.drawRect(0, 0, 50, 50); g.drawRect(25, 25, 50, 50); g.endFill(); </code></pre> <p>You would think that it would draw 2 overlapping red squares. However, it doesn't - it draws two red squares except for the...
<p>All calls prior to endFill() will just store the points of the polygon you want to draw and connect them once endFill() is called. Since the code in your example has an overlapping part, it will be filtered out when the actual lines of the polygon are drawn. I actually don't know if this is intended behavior of the ...
how to exclude external jar while creating executable jar in eclipse or commandline? <p>I have written a program in Eclipse IDE which uses BouncyProvider class of BouncyCastle.jar. So to compile my class I added BouncyCastle.jar in my project classpath and it compiles perfectly.</p> <p>Now I want to export my project ...
<p>It sounds like you want to use the "Export JAR File" wizard instead of the "Export Runnable JAR File" wizard. When exporting a <em>runnable</em> jar file, Eclipse attempts to pack everything needed to run the application into a single archive. On the other hand, the "Export JAR File" wizard gives you more control ov...
SVN Merge Branch from one Repo into Trunk of other Repo <p>I have two repositories which live on separate servers, call them repo-1 and repo-2.</p> <p>To start both "trunks" were equal:</p> <p>repo-1/trunk == repo-2/trunk</p> <p>Meanwhile changes were being commited to repo-1/trunk and I was working on and commiting...
<p>First figure out the revision where the trees were the same. Then merge that from that revision to HEAD of the repo-1 repository to your repo-2 working copy.</p> <p>Using the commandline client it's similar to this, if you want to merge changes between r123 and r456</p> <pre><code>svn merge http://domain.tld/repos...
SharePoint WebPart Permissions <p>Hi I am using the SharePoint namespace for a webpart and I encounter some permission errors when I try to use the System account. Is there a way I can use a defined user instead of the system account?</p> <p>Right now I have:</p> <pre><code>SPUserToken sysToken = SPContext.Current.S...
<p>You may need to use RunWithElevatedPermissions to get access to the System account to work, as per the following blog post:</p> <p><a href="http://solutionizing.net/2009/01/06/elegant-spsite-elevation/" rel="nofollow">http://solutionizing.net/2009/01/06/elegant-spsite-elevation/</a></p>
GCC without Xcode on OS X <p>I've just unwrapped my new MacBook Pro (<em>yay</em>!) and am now setting it up properly for development. Since I want to avoid clutter, I'm wondering if I really need to install the Xcode tools at all (I never use the IDE or Mac specific tools), since I'll install a newer version of GCC an...
<p>In order to perform an easy and successful install of MacPorts, already having tools from the xCode installer is necessary. You only need the install option that places a copy of the unix/header files outside of xcode; everything else can remain uninstalled.</p>
Spring-modules caching not working... silently <p>I'm trying to use declarative caching from the Spring Modules project. </p> <p>It's not working ie. nothing appears to be getting cached. </p> <p>Here's my configuration:</p> <pre><code>&lt;bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheMana...
<p>You should create an ehcache.xml file for your config since I don't believe the fail safe cache works with declarative caching. We set up our caching using the ehcache Spring modules XML schema and annotations. If using an explicit ehcache.xml does not solve your issue, then I can dig up some code that does it (clos...
How would I search through a DataSet and change data in it before it gets bound? <pre><code>Try Dim ds As DataSet = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings("connstr").ConnectionString, CommandType.StoredProcedure, "Get_All", New SqlParameter("@userid", Session("userid"))) rptBundles.Da...
<p>If you're using a Repeater, or whatever datasource bound control, I would use the ItemDataBound event and set those values to your controls.</p> <p>If this was your basic HTML</p> <pre><code>&lt;html&gt; &lt;asp:Repeater id="repeater" runat="server" OnItemDataBound="repeater_ItemDatabound"&gt; &lt;ItemTempl...
ASP.NET Gridview with all records editable <p>I thought this would be simple, but I sure am having a lot of trouble doing this:</p> <p>The title of this question may be a bit misleading. I don't have to use a gridview. In fact, I know the GridView is probably not the way to go on this. I just didn't know how else to t...
<p>I would be inclined to use the ListView personally for this, since you can insert Rows with it. Your LayoutTemplate would be a table with a &lt;tr runat="server" ID="itemPlaceHolder" /&gt; in it. Your ItemTemplate would have your TextBox's (and optional a save button per row. Then you could have an InsertItemTempla...
What is LenB actually doing on none string parameters <p>I have this bit of code that is being converted from vb6 to vb.net. I need to know what LenB is doing in this bit of code.</p> <pre><code>Dim singleValue As Single 'var for conversion use(4byte -&gt; 1single)' Dim bytes() As Byte Dim valueB() As Byte 'this gets ...
<p>LenB() returns the length in bytes of a variable. The most common example is for strings, where it returns the size of the string in bytes rather than the number of characters, regardless of character encoding. For other types it returns the size of an object- the size of a single being 4. The reason they would d...
Linking classes in Geany <p>I am writing a CLI application for Linux in Geany (a C++ IDE). I want to link a simple config file reader class so it can be used in my program. Just including it doesn't work, I get undefined reference errors. I know how to do this in Dev-C++ on Windows, but not Geany. Thanks for helping!</...
<p>You are not linking in appropriate libraries. There must be something called Linker Options. Check the documentation out.</p>
Django development server shutdown error <p>Hey all, Whenever i shut down my development server (./manage.py runserver) with CTRL+c i get following message:</p> <pre><code>[24/Feb/2009 22:05:23] "GET /home/ HTTP/1.1" 200 1571 [24/Feb/2009 22:05:24] "GET /contact HTTP/1.1" 301 0 [24/Feb/2009 22:05:24] "GET /contact/ HT...
<p>It appears that you are using the Mac's default python install. I know this has been reputed to have odd issues from time to time. I would recommend install MacPython and installing Django into that python instance. </p>
If Quartz Scheduler dies, how do I stop the child Java processes that it started? <p>I'm currently using Quartz Scheduler as a replacement for Cron on our Windows 2003 Server Box. I have two specific Jobs that needed to be started in a new VM, so I'm using the ProcessBuilder object in Java 5 to get my "Process" object...
<p>If the Quartz JVM exits normally, you can just destroy the processes in a finally block. This may obviate the need for a shutdown hook. A shutdown hook may not execute on abnormal JVM termination. The Runtime javadocs state, </p> <blockquote> <p>If the virtual machine aborts then no guarantee can be made about wh...
Need to monitor directory change, and perform action <p>1st of all: I'm not programmer, neither Linux guru, just have to work with Linux, Oracle, shell scripts.</p> <p>My current task is to monitor a table in Oracle (tool: sqlplus), and if it contains a certain row, then watch a linux directory for a growing tmp file,...
<p>How about creating a hard link in another directory, then, when the file "disappears" in the original location, the hard link will still have access to the content.</p>
WebForm_SaveScrollPositionSubmit is undefined - ASP.NET <p>I'm upgrading an ASP.NET 1.1 app and have things working but am seeing the Javascript error referenced in the title. From research it appears that ASP.NET is not spitting out the javascript that is used to maintain scroll position between postbacks.</p> <p>I ...
<p>Do you have any httphandlers or httpmodules that do any kind of request filtering or re-writing ? or anything special in global.asax that would prevent the javascript from coming down ? I would guess that something is blocking the built in axd request to get the javascript that deals with WebForm_SaveScrollPositionS...
MulticastSocket not responding after failure <p>I get a SocketException when trying to call joinGroup(addr) on MulticastSocket. This is only happening on a Windows machine that we have setup to auto start our appliction when the machine is booted up.</p> <p>It seems like the exception is thrown because Windows has no...
<p>I never did find out WHY the socket would not recieve messages after joining the group successfully. I did come up with a work around, however.</p> <p>I loop through all the network interfaces and make sure there is a valid one in the list and it is up and running. The next thing I do is try setting that network ...
Need loop to copy chunks from byte array <p>I have to process a large byte array that is passed to my function. I need to copy the content from this incoming byte array in smaller "chunks" to an outbound byte array.</p> <p>For every "chunk" of data created in the outbound array, I need to call a web service.</p> <p>U...
<p>You might want to look into <a href="http://msdn.microsoft.com/en-us/library/system.array.copy.aspx">Array.Copy</a> or <a href="http://msdn.microsoft.com/en-us/library/system.buffer.blockcopy.aspx">Buffer.BlockCopy</a>; this will clean things up a bit, since you won't have to copy all of the bytes individually:</p> ...
Continuing a statement on the next line WITH A COMMENT <p>If I have a statement in Ruby that I want to continue on the next line, normally I would add a backslash at the end of the line like this:</p> <pre><code>print x \ + y </code></pre> <p>But if I have comments on the line, it doesn't work:</p> <pre><code>print ...
<p>You need to plus sign on the first line. I dont think comments work with the blackslash</p> <pre><code>puts 'abc' + #Start abc 'def' #Add def </code></pre>
Visual Studio 2008 Debugger Has Gone South <p>Dell Dimension 5621 - Win XP SP2 VS Studio 6.0 &amp; 2008. We support ASP pages. </p> <p>Usually I have had no problems using Visual Studio 2008 debugger with ASP pages from VStudio 6.0. In fact, up until last week, worked great. I was actually commenting to boss week ago ...
<p>The standard <strong>bad</strong> answer usually is uninstall and then reinstall visual studio. Annoying answer too as it doesn't really explain what happened.</p>
asp.net Authorization: location and IPrincipal.IsInRole <h2>Scenario</h2> <p>I'm using a Custom <code>IPrincipal</code> and <code>IIdentity</code> to do asp.net authorization. I set the <code>Principal</code> and <code>Identity</code> during the <code>PostAuthenticateRequest</code> event using an <code>IHttpModule</c...
<p>Don't use the tilde (~) at the start of paths for &lt;location> elements, as they are not interpreted there. In your example, path="admin/user_search.aspx" should be correct.</p>
Visual Studio Builds per day <p>Is there any way to log the number of builds done during a development day in Visual Studio, or anywhere we can hook into something to get at the metadata?</p> <p>I'm curious how many times on average I build/day * how long it takes per build... </p> <p>Any thoughts?</p> <p>UPDATE: so...
<p>One option would be to create a couple of scripts in your favorite scripting language and add them to the <em>pre and post build events</em> of the project settings.</p> <p>Now every time you run a build the scripts will be run and you can have the scripts track whatever information you require.</p> <p>But natural...
ASP.NET: Button Outside UpdatePanel Fails to PostBack <p>I have a donation form that contains an update panel that contains a dropdown for predetermined amounts plus the "Other" option". When "Other" is selected the dropdown has triggered the partial postback and renders the update panel with the additional "Other" te...
<p>Is this possibly a validator blocking you? Is your button supposed to ignore any validators? If so, you should set CausesValidation="false" on the button so that it will fire even if the validators in the panel are invalid.</p> <p>Otherwise, the button's click event will be stopped by the validators in the panel.<...
Unix O_CREAT flag without mode specified <p>The definition of the UNIX <em>open()</em> function when used with the O_CREAT flag is that it requires a third argument named <em>mode</em> in order to set the files' privileges. </p> <p>What if that <em>mode</em> is not specified?</p> <pre><code>int file; static const cha...
<p>The POSIX standard (IEEE 1003.1:2008) prototypes <code>open()</code> as:</p> <pre><code>int open(const char *path, int oflag, ...); </code></pre> <p>The section describing the behaviour of <code>O_CREAT</code> doesn't say what will happen if you omit the necessary third argument, which means the behaviour is undef...
Using Excel (Or Calc) as a web-app frontend or embedded widget <p><strong>Problem:</strong> When dealing with web-applications that require grid-based input (but is not a fullblown spreadsheet like Google's) there is a common problem. Either the web-GUI sucks, or it is tied behind some heavily-specialized API that take...
<p>This is common practice for data-heavy intranet applications. In the past, you would have used VB for Applications. Today, the Open XML SDK offers a very elegant way of hooking into the open and close events of the document. Excel will execute your managed code upon open (to populate the spreadsheet) and upon close/...
Looking for a radial coordinates description of gear teeth <p>I don't need a physically accurate function, but something that hints at the involute curves, etc. I was just using <code>r = 2 + sin^2</code>, which gets the idea across, but it looks like - ahem. Googling around, you can find plenty of information on how...
<pre><code>from pylab import * nteeth = 30 inner = 10 outer = 12 # these are in teeth-hundredths, but half the actual measurement bottom_width = 22 top_width = 15 def involute_r(angle): '''angle is given in teeth-hundredths''' angle = angle % 100 if angle &gt; 50: # symmetry angle = 100 -...
How do I make an HTML element repaint within a Javascript loop? <p>I have some Javascript which "animates" a colour change on an HTML element, as follows:</p> <pre><code>var element = document.getElementById("someid"); while (i &lt; 255) { element.style.color = 'rgb(' + i + ',' + i + ',' + i + ')'; i++; sl...
<pre><code>function changeColor() { changeColorIncremental(0); } function changeColorIncremental(i) { var element = document.getElementById("someid"); element.style.color = 'rgb(' + i + ',' + i + ',' + i + ')'; if (i &lt; 255) { // Note the 50 millisecond wait below. Decrease this to speed u...
Why are there self-duplicating curly brackets in persisted WPF RichTextBox? <p>Our tester threw curly brackets at our persisting WPF RichTextBoxes. On save and reopen, there are magically more curly brackets.</p> <p>I've condensed the issue / code down.</p> <pre><code>&lt;Window x:Class="WpfApplication1.Window1" xml...
<p>I'll test the code more thoroughly tonight, but does it happen when the braces are not at the start of the text? E.g., if your run was "Hello{World}" does it still do this?</p> <p>As you probably know, curly braces are significant in WPF because they are used for markup extensions. The following markup wouldn't wor...
Code Contracts, will you use them? <p>Microsoft just released <a href="http://msdn.microsoft.com/en-us/devlabs/dd491992.aspx" rel="nofollow">Code Contracts</a>, a tool that integrates with Visual Studio and allows you to define contracts for your .Net code and get runtime <em>and</em> compile time checking.</p> <p>Wat...
<p>I think the majority of developers using c# 4.0 will use them myself included especially when creating a library that you plan to expose to anyone. It may make your code more verbose in areas but the advantages it has should outweigh the lines of code and time spent.</p>
Why does my repeater keep crashing on Eval(NULL) values? <pre><code>&lt;asp:Repeater ID="rptLessons" runat="server"&gt; &lt;ItemTemplate&gt; &lt;tr&gt; &lt;td&gt;&lt;%#Eval("fullname")%&gt;&lt;/td&gt; &lt;td&gt;&lt;%#isCompleted(Eval("totallessons"), Eval("completedlessons"), Eval("...
<p>You need to give a stack trace to be sure.</p> <p>But I can see several issues:</p> <ol> <li>DIV#0 errors inside FormatPercent</li> <li>NULL errors.</li> </ol> <p>Example Solution</p> <p>&lt;%#isCompleted(System.Convert.ToInt32(Eval("totallessons")), System.Convert.ToInt32(Eval("completedlessons")), System.Conve...
Test whether a property is declared in the derived class <p>I have two classes</p> <pre><code>public class A { public int BaseA {get;set;} } public Class B: A { public int BaseB {get;set;} } </code></pre> <p>I can get the Properties for the Class B by using typeof(B).GetProperties(). However, this would include b...
<p>Look at using BindingFlags.DeclaredOnly when calling Type.GetProperties().</p>
How would I get a cron job to run every 30 minutes? <p>I'm looking to add a <code>crontab</code> entry to execute a script every 30 minutes, on the hour and 30 minutes past the hour or something close. I have the following, but it doesn't seem to run on 0.</p> <pre><code>*/30 * * * * </code></pre> <p>What string do I...
<p>Do:</p> <pre><code>0,30 * * * * your_command </code></pre>
How to hide back button in the first view on iPhone? <p>I add 3 views for an application and they need to switch from 1-2-3.</p> <p>Now I add a toolBar and a button 'OK' on the bottom of SwitchViewController, so they can share the button to go to next view. </p> <p>But how to add a 'Back' button so that I can switch ...
<p>It sounds like what you're trying to do is use a UINavigationController. If you instantiate a UINavigationController with the <code>initWithRootViewController</code> initializer you can pass it your first UIViewController. Then you just need to tie whatever action you want to a method that calls <code>[myUINavigat...
How do you perform a left outer join using linq extension methods <p>Assuming I have a left outer join as such:</p> <pre><code>from f in Foo join b in Bar on f.Foo_Id equals b.Foo_Id into g from result in g.DefaultIfEmpty() select new { Foo = f, Bar = result } </code></pre> <p>How would I express the same task using ...
<pre><code>var qry = Foo.GroupJoin( Bar, foo =&gt; foo.Foo_Id, bar =&gt; bar.Foo_Id, (x,y) =&gt; new { Foo = x, Bars = y }) .SelectMany( x =&gt; x.Bars.DefaultIfEmpty(), (x,y) =&gt; new { Foo=x.Foo, Bar=y}); </code></pre>
What is the best approach to calculate a formula which changes value each day? <p>I use the following columns stored in a SQL table called tb_player:</p> <p>Date of Birth (Date), Times Played (Integer), Versions (Integer)</p> <p>to calculate a "playvalue" (integer) in the following formula:</p> <p>playvalue = (Today...
<p>In a property/method on the object, in C#/VB.NET (your .NET code).</p> <p>The time to execute a simple property like this is <strong>nothing</strong> compared to the time to call out-of-process to a database (to fetch the rows in the first place), or the transport time of a web-page; you'll <strong>never</strong> n...
Is there a way to determine what configuration file MySQL is using? <p>Is there a command I can run within MySQL to determine where/which configuration file MySQL is using?</p>
<p>As of ver 5.0, no. But look at <a href="http://stackoverflow.com/questions/580331/mysql-how-to-determine-which-config-file-is-being-used">http://stackoverflow.com/questions/580331/mysql-how-to-determine-which-config-file-is-being-used</a> for how to look from <em>outside</em> MySQL.</p>
Why ‘No database selected’ SQLException? <p>why this program is not executing when it goes in to the do while loop second time and why it is giving the exception "Exception java.sql.SQLException: [MySQL][ODBC 5.1 Driver][mysqld-5.0.51a-community-nt]No database selected"</p> <pre><code>//import java.io.InputStream;...
<p>Unless you have to use the jdbc/odbc driver I would use the straight mysql jdbc driver. You can download it free from mysql.</p> <p>then </p> <pre><code>public void LoadDriver() { // Load the JDBC-ODBC bridge driver try { Class.forName("com.mysql.jdbc.Driver"); } catch (Cl...
What's better at freeing memory with PHP: unset() or $var = null <p>I realise the second one avoids the overhead of a function call (<strong>update</strong>, is actually a language construct), but it would be interesting to know if one is better than the other. I have been using <code>unset()</code> for most of my codi...
<p>As (it was in 2009) mentioned in <a href="http://us2.php.net/manual/en/function.unset.php#86347">unset</a> (now 2013, that man page don't include that anymore)</p> <blockquote> <p><code>unset()</code> does just what its name says - unset a variable. It does not force immediate memory freeing. PHP's garbage collec...
How to create a check constraint between two columns in SQL? <p>I am trying to create a Basic pay (BP) table with</p> <pre><code>CREATE TABLE bp ( bpid VARCHAR(5), FOREIGN KEY (bpid) REFERENCES designation(desigid), upperlimit DECIMAL(10,2) NOT NULL, lowerlimit DECIMAL(10,2) NOT NULL, incre...
<p>It might (probably does) depend on the data base you use.</p> <p>Comparing to the oracle syntax (e.g. here: <a href="http://www.techonthenet.com/oracle/check.php" rel="nofollow">http://www.techonthenet.com/oracle/check.php</a>), what you are missing might be a ',' between NULL and CONSTRAINT</p>
Storing username that last modified database row via EJB3.0 and JPA <p>I'd like to store username that has last modified table row to as a field in every table.</p> <p>I have following setup: an user logs in, web layer calls some EJB 3.0 beans. Those EJB beans create and modify some JPA entities. Now, I'd like that u...
<p>You can use an EJB interceptor (@Around) on the EJB class to get the current user (using standard EJB api) and storing the name in the threadlocal variable. This would work transparently for remote and local calls.</p>
ASP.NET 2.0 add styles dynamically to page in a control <p>I need to add to the page from within a custom control. I can't use a stylesheet (.css) because I'm using a url(...) and need to resolve the url.</p> <p>Right now I'm doing:</p> <pre><code>Page.Header.Controls.Add(new LiteralControl("&lt;style type='text/css...
<p>I guess it's not a bad solution for the problem. If you had an <em>external stylesheet file</em>, this piece of code will do the work:</p> <pre><code>HtmlLink cssRef = new HtmlLink(); cssRef.Href = "styles/main.css"; cssRef.Attributes["rel"] = "stylesheet"; cssRef.Attributes["type"] = "text/css"; Page.Header.Contro...
LINQ Query to insert data into the database <p>In my database, I have a table named Students, with 3 Columns (SNo, SName, Class).</p> <p>I want to insert the value of only SName. </p> <p>Can anybody tell me how to write the LINQ Query for this.</p> <p>Thanks, Bharath. </p>
<p>Do you mean you want to <em>query</em> only the name? In which case:</p> <pre><code>var names = ctx.Students.Select(s=&gt;s.Name); </code></pre> <p>or in query syntax:</p> <pre><code>var names = from s in ctx.Students select s.Name; </code></pre> <p>To <em>insert</em> you'd need to create a number of...
How can I implement conditional updating in Oracle? <p>I'm new to oracle and having a problem with one of my SQL Queries.</p> <p>There are 2 Users: <code>User1</code> and <code>User2</code>:</p> <pre> Tab1 Tab2 -------- -------- EmpNo EmpNo EmpName ...
<pre><code>UPDAT UZRTOO.TABTOO.IMPKNOW TEATOO SETT DEZIGNASHUN IZ EQL DOTZ WHAR IS HVING (SLEKT NUTHN FRUM UZRWON.TABWON TEAWON WAR IS HVING TEAWON.IMPKNOW IZ EQL TEATOO.IMPKNOW) </code></pre> <p><strong>Update</strong></p> <p>A word of explanation; the original phrasing of the questio...
Implementing ridge detection <p>I'm trying to write a ridge detection algorithm, and all of the sources I've found seem to conflate edge detection with ridge detection. Right now, I've implemented the Canny edge detection algorithm, but it's not what I want: for example, given a single line in the image, it will effect...
<p>Maybe you need to think in terms of cleaning up the line you already have, rather than a Canny-like edge detection. It feels like you should be able to do something with <a href="http://en.wikipedia.org/wiki/Morphological%5Fimage%5Fprocessing"><strong>image morphology</strong></a>, in particular I'm thinking of the ...
Breaking an interface <p>What are the most important guidelines to follow if you need to break an interface in a .NET application? How do these guidelines change before and after your application has been deployed?</p> <p>I know there are other questions that debate when/where interfaces should be used, however I don...
<p>It depends on the contract (implied or explicit) with the consumers of your interface.</p> <p>If all consumers are rebuilt when you rebuild the interface then <strong>managing</strong> changing it is simple, simply change it and fix all the breaks (fixing the breaks themselves <em>may</em> be complex).</p> <p>If y...
MSBuild exec task with for <p>I am trying to run the following commands as part of an MSBuild script:</p> <pre><code>for /R . %f in (*.targets) do copy /Y "%f" "C:\Program Files (x86)\MSBuild\Microso ft\VisualStudio\TeamBuild" </code></pre> <p>The commands is implemented in an exec the following way:</p> <pre><code>...
<p>I have just explained in your previous question. In that case you need to add extra % in front of your variables. It is explained in help of FOR command as follows</p> <blockquote> <p>To use the FOR command in a batch program, specify %%variable instead of %variable.</p> </blockquote>
How do I do conditional validation in ActiveRecord with n conditions? <p>I am providing a web service to be called by external companies. The required data covers several models including person, address etc. I want to validate the received data conditionally based upon some fields within the request. I will eventually...
<p>I did something similar with phone numbers. Your approach is very similar to what I did myself. To answer your questions:</p> <ol> <li>I stored the validation configuration in a YAML file. Hovewer, if your data is going to grow to a large extent, you should consider using database.</li> <li>I load and parse data on...
Exception when destroying TReader <p>The following code throws an EZDecompressionError with message 'Invalid ZStream operation' whenever the line</p> <pre><code>Reader.Free </code></pre> <p>is executed. Can someone tell me what's wrong with this code?</p> <pre><code>Reader := nil; Decompressor := nil; InputFile := T...
<p>Smasher </p> <p>TReader does a <strong>FStream.Seek(FBufPos - FBufCount, soCurrent)</strong> in its destructor.</p> <p>The error get's raised because of a backwards seek. If you call <strong>Reader.FlushBuffer</strong> and <strong>Reader.Position := soFromBeginning</strong> before freeing the reader, does the err...
Trying to store password to database <p>Hi i'm doing a test how hash and salt passwords. Well , i can add hash and salt password to the Database but i got stuck to store passwords from database. i have a simple Database :</p> <pre><code> Table _______ ...
<p>Try:</p> <pre><code>public bool ValidateApplicationUser(string userName, string password) { DataClasses1DataContext dc = new DataClasses1DataContext(); var saltValue = dc.ProvaHs.Where(c =&gt; c.UserName == userName) .Select(c =&gt; c.Salt) .SingleOrDefau...
STEP/EXPRESS tools for .NET <p>Has anyone had any experience with using the <a href="http://en.wikipedia.org/wiki/Standard%5Ffor%5Fthe%5FExchange%5Fof%5FProduct%5Fmodel%5Fdata/">STEP</a> and <a href="http://en.wikipedia.org/wiki/EXPRESS%5F%28data%5Fmodeling%5Flanguage%29/">EXPRESS</a> formats in a .Net environment?</p>...
<p>I know this is an old question, but I thought I'd answer for anyone else who stumbles upon it.</p> <p>If you need to work with <code>STEP</code> and <code>EXPRESS</code> and don't want CAD libraries, or if you need an uncommon or custom schema, take a look at (<strong>shameless plug!</strong>) <a href="http://githu...
Subclassing classes with completely independent inheritance trees that cannot be modified <p>How would someone join two classes each with independent inheritance trees to bridge context boundaries, given the restrictions that neither class's inheritance trees can be modified to inherit from the other?</p> <p>i.e., if ...
<p>Composition.</p> <p>Create a new class that inherits from neither but has an instance of both the classes you want to use within it, then expose the methods you want to call.</p> <p>Google "Composition over Inheritence" for much better ramblings on the subject than mine</p>
Contraint - unique or empty <p>There is a nvarchar column in a table that allows empty values. Once there is a none-empty value it must be uniqe. </p> <p>Is it possible to define this rule without a trigger?</p> <p>EDIT: </p> <p><a href="http://decipherinfosys.wordpress.com/2007/11/30/multiple-null-values-in-a-uniq...
<p>There is a work-around for the multiple NULL values in a unique key column in <a href="http://decipherinfosys.wordpress.com/2007/11/30/multiple-null-values-in-a-unique-index-in-sql-serverdb2-luw/" rel="nofollow">http://decipherinfosys.wordpress.com/2007/11/30/multiple-null-values-in-a-unique-index-in-sql-serverdb2-l...
(Fluent) NHibernate : One entity composed of fields from different tables <p>Is there a way of writing an NHibernate mapping so that you can have an entity that is composed of fields from different DB tables?</p> <p>For Example is I have a Person and Address table, I want address fields to appear in my person object.<...
<p>If you are using Fluent NHibernate you can use WithTable, as in this example:</p> <pre><code>public class PersonMap : ClassMap&lt;Person&gt; { public PersonMap() { Id(x =&gt; x.Key, "[Key]"); // Explicitly specify escaped column name to // avoid problems with reserved words ...
Should NullRefs ever be caught? <p>I recently made the statement to a colleague that:</p> <blockquote> <p>NullReferenceExceptions should <em>never</em> be explicitly caught</p> </blockquote> <p>I used the word never.... hmmm. I've never seen a appropriate use case myself for catching them but I wanted to check if...
<p>It depends on why; see Eric Lippert's <a href="http://blogs.msdn.com/ericlippert/archive/2008/09/10/vexing-exceptions.aspx" rel="nofollow">blog entry</a>. If they are "boneheaded exceptions", then no - just fix the calling code. In the rare case that they are "vexing exceptions" (i.e. the code you are calling has tr...
iPhone Development Related Podcasts? <p>Anyone have any suggestions for good iPhone development related podcasts?</p> <p>Only one I've run across is <a href="http://www.mobileorchard.com/" rel="nofollow">http://www.mobileorchard.com/</a> and was looking for some others.</p>
<p>Just came across a reference to a new podcast, <a href="http://itunes.apple.com/podcast/build-and-analyze/id404064215" rel="nofollow">Build and Analyse</a>.</p>
Update several columns at once in Derby <p>DB2 supports this syntax:</p> <pre><code>UPDATE DEST D SET (AAA,BBB) = ( SELECT MAX(Z.AAA), MAX(Z.BBB) FROM OTHER O WHERE O.ID = D.ID ) </code></pre> <p>i.e. I can run a select which returns more than one column and copy the results into various columns of the destinatio...
<p>Presumably, you can do this:</p> <pre><code>UPDATE DEST D SET AAA = (SELECT MAX(Z.AAA) FROM OTHER O WHERE O.ID = D.ID), BBB = (SELECT MAX(Z.BBB) FROM OTHER O WHERE O.ID = D.ID) </code></pre> <p>I didn't say anything about efficient - but it is likely more efficient than either splitting the update into...
how to access SVN using VBScript <p>We'r maintaing some test scripts written in VBScript in SVN and everyday morning we get the latest copy of these files and run the tests. We are doing this manually at the moment. However we want to automated this whole operation. </p> <p>How do we access SVN using VBScript to copy ...
<p>So long as svn is in your path...</p> <pre><code>Set objShell = WScript.CreateObject("WScript.shell") objShell.exec ("cmd svn update C:\Projects\Project1 --username buildrobot --password IAmARobot1") </code></pre>
How to get some interactivity with a JTable <p>I Have a JTable where the data model contains information from a sql query. Want to get the added ability to take me to a new jpanel by double-clicking a row in the jtabel.</p> <p>Thnx</p>
<p>You can add a MouseListener to a JTable and then handle the mouseClicked event.</p> <p>The following code shows a mouseClicked implementation that finds out what row was double clicked. You can then navigate to a panel using this information.</p> <pre><code>public void mouseClicked(MouseEvent event) { if (event....
Implement map in javascript that supports object methods as mapped functions? <p>I recently tried to use an implementation of map in javascript to create a bunch of items, then apply them to an objects add method.</p> <p>Firstly with a bog standard implementation of map.</p> <pre><code>var map = function (fn, a) { ...
<blockquote> <p>Trying to call map( Menu.add , languages )</p> </blockquote> <p>Here your problem is almost certainly that of JavaScript's lack of bound methods.</p> <p>The setting of ‘this’ for a function is determined only at call-time, by examining how the method was obtained. If you say one of:</p> <pre><c...
String.Join vs. StringBuilder: which is faster? <p>In a <a href="http://stackoverflow.com/questions/585215/can-i-rewrite-this-more-elegantly-using-linq">previous question</a> about formatting a <code>double[][]</code> to CSV format, Marc Gravell <a href="http://stackoverflow.com/questions/585215/can-i-rewrite-this-more...
<p>Short answer: it depends.</p> <p>Long answer: <strong>if you already have an array of strings to concatenate together (with a delimiter), String.Join is the fastest way of doing it.</strong></p> <p>String.Join can look through all of the strings to work out the exact length it needs, then go again and copy all the...
Data files not deployed with ClickOnce application <p>I have a WinForms app that I deploy using ClickOnce. In the application project I have some files marked as Content which is also marked as "Data File" in the Application Files dialog in the Publish settings. I have also some content files that are marked as "Includ...
<p>After some more trial and error I found that the DirectoryNotFound exception occurs when my data files are located in subfolders of a subfolder. If data files are located in the project root or in a first level subfolder everything works as expected.</p> <p>The problem seems also to be related to the fact that in s...
How do I get my Threads to not block one another? <p>I have 2 Threads, one that's polling a mailbox for messages then sleeping <code>while (!quit)</code> and another that's supposed to change the <code>quit</code> flag should the user enter <code>'Q'</code>. It seems that the scanning Thread blocks the other Thread fro...
<p>How are two different instances of two different classes sharing the <code>quit</code> variable? Try using an AtomicBoolean, shared between your two threads.</p> <p>Also, how do you know the scanning thread is blocking the other one? From your code, I can't see them sharing any resources except for the <code>quit</...
Is it possible to program for Sony Ericsson mobile phones(symbian) using Visual Studio? <p>This question is just out of curiosity, I own a P1i and it would be nice to play with it :)</p> <p>A link to some documentation would be fine :)</p>
<p>It isn't officially supported, but apparently you can get it to work:</p> <p><a href="http://www3.symbian.com/faq.nsf/7b5405edb1250e7c802569ee005d054e/30398b3e9500a24d80256c7f00693a91?OpenDocument" rel="nofollow">http://www3.symbian.com/faq.nsf/7b5405edb1250e7c802569ee005d054e/30398b3e9500a24d80256c7f00693a91?OpenD...
App.config and ConfigurationManager <p>If I call the OpenMappedExeConfiguration() method and specify a config file (filemap) as a parameter, does this mean that the ConfigurationManager will use the newly specified config file from that point onwards and ignore app.config?</p> <p>I know that ConfigurationManager looks...
<p>As far as I remember it will just open the configuration and return the <code>Configuration</code> object, its not going to change the default one.</p>
.NET: Hitting the back button messes up my event handler <p>Hey all. I have a ASP.NET page that lists a bunch of user accounts.</p> <p>If I click on a user, an event called LinkChosen is fired, which opens the account view page for that user.</p> <p>I can also search for users, which narrows down the list. This event...
<p>Are you pressing the "Enter Key" when you do a search. If so the first button in the page is usually the one that will get submitted on an Enter keypress.</p> <p>You can set DefaultButton on the page, or on a panel.</p> <p>So if you need two buttons to both respond to Enter presses in their respective portions of ...
Discovering linux disk configurations from the command line <p>How can I discover if a remote machine is configured with or without hardware or software RAID? All I know is i have 256GB at present, I need to order more space but before I can I need to know how the drives are configured.</p> <p><em>df</em> lists the dr...
<p>Software RAID would not be /dev/sdb - dev/md0. Nor is it LVM.</p> <p>So it's either real hardware RAID, or a raw disk.</p> <p><code>lspci</code> might show you and RAID controllers plugged in.</p> <p><code>dmesg | grep sdb</code> might tell you some more about the disk.</p> <p><code>sdparm /dev/sdb</code> might ...
I want to hide system commands issued from system() <p>Writing a program in c++ and I want to issue a system command from the system() function but I don't want the user to see the command (because the command includes a pwd) in the executable window. I need to copy a file from the user's directory onto the server wit...
<p>The command line of running processes is considered public information in most operating systems.</p> <p>Therefore it is a very bad idea to pass passwords on the command line.</p> <p>There are two common workarounds to this problem, both of which require the support of the executable being called:</p> <ul> <li>in...
How do I replace outbound link URLs in a PDF document, using PHP <p>I have a PDF document with some external links.</p> <p>I'd like to parse the document, replace the destination of the links then close (and serve) the PDF document, all using PHP</p> <p>I know I can do this with PDFLib but I don't want to incur this ...
<p>I don't think there is a text/hyperlink changer class for PHP. The closest products, like <a href="http://www.accesspdf.com/pdftk/" rel="nofollow">pdftk</a>, only does higher-level stuff like merging, splitting and applying watermarks.</p> <p>Changing a pdf is much more difficult than generating it, so you need to ...
How can I reverse a NSArray in Objective-C? <p>I need to reverse my <code>NSArray</code>.</p> <p>As an example:</p> <p><code>[1,2,3,4,5]</code> must become: <code>[5,4,3,2,1]</code></p> <p>What is the best way to achieve this?</p>
<p>There is a much easier solution, if you take advantage of the built-in <code>reverseObjectEnumerator</code> method on <code>NSArray</code>, and the <code>allObjects</code> method of <code>NSEnumerator</code>:</p> <pre><code>NSArray* reversedArray = [[startArray reverseObjectEnumerator] allObjects]; </code></pre> <...
Can I generate values for a custom parameter such as a timestamp for a Visual Studio Item Template? <p>I would like to include the current timestamp as part of a Visual Studio Item Template (the timestamp of when the file is created by the user). Is this possible?</p>
<p>You can cause code to be executed when a template is expanded by implementing a wizard. The wizard need not have a user interface, but can populate a dictionary of name/value pairs. The values can then be substituted into the template.</p> <p>Look in the Visual Studio SDK documentation for the topic named "How to: ...
Table layout using std::cout <p>How do I format my output in C++ streams to print fixed width left-aligned tables? Something like </p> <pre><code>printf("%-14.3f%-14.3f\n", 12345.12345, 12345.12345); </code></pre> <p>poducing</p> <pre><code>12345.123 12345.123 </code></pre>
<p>Include the standard header <a href="http://www.cplusplus.com/query/search.cgi?q=iomanip"><code>&lt;iomanip&gt;</code></a> and go crazy. Specifically, the <code>setw</code> manipulator sets the output width. <code>setfill</code> sets the filling character.</p>
Javascript encoding question <p>We have an external .js file that we want to include in a number of different pages. The file contains code for sorting a table on the client-side, and uses the ▲ and ▼ characters in the script to indicate which column is sorted and in which direction.</p> <p>The script was origina...
<p>The encoding of the JavaScript file depends on the encoding of the HTML page, where it is embedded. If you have a UTF-8 JavaScript file and a ISO-8859-1 HTML page the JavaScript is interpreted as ISO-8859-1.</p> <p>If you load the JavaScript from as a external file you could specify the encoding of the JavaScript:<...
ASP.NET Membership/Roles/FormsAuth - how can I login as a super-user? <p>I'm working on a web application that uses the ASP.NET 2.0 Membership and Roles providers with Forms Authentication. There are various roles in the system. I need to have a user role that is essentially a super-user that can "login" as any user ac...
<p>Why don't you have a SuperUser role that can do anything? Then the user can be just part of that role.</p> <p>If what you really need to have is an ability for an administrator to impersonate someone else, I don't know what is the additional flag for? If it marks the currently logged in user giving him super powers...
How can I use "using" in C# without getting "InvalidOperationException"? <p>I am trying to replce the follwing code that works fine</p> <pre><code>TcpClient oC = new TcpClient(ip, port); oC = new TcpClient(ip, port); StreamReader messageReader; try { messageReader = new StreamReader(oC.GetStream(), Encoding.ASCII)...
<p>Try calling oc.Connect before creating a StreamReader. Until a socket is connected, there is nothing to actually read and hence the exception.</p>
Subversion: how to nuke a repository? <p>Is there a way to <strong>completely</strong> erase a Subversion repository so that users can't access to old revisions?</p> <p>PS: I have root access on the repositories machine.</p>
<p>Just remove the root folder of the repository, but saving the <code>conf/</code> folder it has inside. Then, create a new repository with <code>svnadmin create</code>, and overwrite the old configuration folder on it.</p> <p>EDIT (for completeness): as Tunnuz and Jim T have pointed out, you may want to save also th...
Obtaining selected item, value or index from drop down list in formview after button press <p>I have a formview with an insertion template. In this template there is a drop down list with a number of items I want users to be able to select from. Beside the drop down list there is a button which I am using to add the ...
<p>It seems like you are binding your DDL on postbacks as well. If the ddl data isnt hardcoded and you have the call for your ddl databind function in the Page_Load, you need to call the function like this to ensure it is not bound on postback:</p> <pre><code>if(!IsPostBack) { BindDDL(); } </code></pre> <p>Otherw...
Eliminating temporary ASP.Net Files <p>How do you prevent ASP.NET from creating too many temporary files? My website creates gigabytes of temporary files, and that overflows the main partition on the server. How do I prevent this from happening?</p>
<p>Where are these temp files beeing generated? </p> <p>If it's in the "Temporary ASP.NET Files" folder, it's a result of your application beeing recompiled. Checkout <a href="http://msdn.microsoft.com/en-us/library/ms366723.aspx">MSDN</a> for more information on dynamic compilation. One possible solution could be to ...