input
stringlengths
51
42.3k
output
stringlengths
18
55k
What sets Page.User.Identity.Name <p>I keep track of the current logged in userID and base the behavior of my site on this value. My code sets the logged in user ID with this statement:</p> <pre><code>FormsAuthentication.SetAuthCookie(UserID.ToString(), true); </code></pre> <p>Subsequently, I read this value <code>fr...
<p><code>FormsAuthenticationModule</code> handles <code>Application_OnAuthenticate</code> and assigns the <code>HttpContext.User</code> to a prinicipal object which is in turn used by <code>Page.User.Identity.Name</code>.</p> <p>Isn't there a time difference issue on the server and your desktop?</p>
java.util.ConcurrentModificationException in JasperReports <p>We have a web application deployed to Websphere 6.1.0.19 on Windows. We occasionally see this ConcurrentModificationException on a few of our reports. We are using JasperReports 2.0.5 in production. The full stacktrace is following:</p> <pre> java.util.C...
<p>This is caused by the backing store of the iterator being altered while the iterator is in use. This is not a concurrency problem related to threading, as it is easy enough to do on a single thread as well.</p> <p>More detailed description on this <a href="http://stackoverflow.com/questions/602636/concurrentmodifi...
Why does this WSDL file generate an empty service proxy in VS2008? <p>Why does <a href="http://services.fliqz.com/searchservice/20071001/service.svc?wsdl" rel="nofollow">this WSDL file</a> generate an empty service proxy in VS2008?</p> <p>If you look at the Reference.cs file generated, it's empty. Any ideas?</p>
<p>right click on service reference , cofigure , un-check “Reuse types in referenced assembles” and click OK. Try to Update Service Reference. This worked for me!</p>
How can I have an abstract and introduction on the same page of a Latex document? <p>I need to change the layout of my document to send my paper to a conference. My abstract is currenly on a separate page. The introduction should be straight after the abstract, not on the separate pages. </p> <blockquote> <p>How can...
<p>The conference should provide with at least information on how to format your paper, and often they have LaTeX styles ready, for instance <a href="http://www.ieee.org/web/publications/authors/index.html" rel="nofollow">at IEEE</a>, or <a href="http://www.acm.org/publications/latex%5Fstyle/" rel="nofollow">at ACM</a>...
Automatic Hibernate Transaction Management with Spring? <p>How far does the spring framework go with transaction handling? My reading of the book "Spring In Action" suggestions with its examples that you create DAO methods that don't worry about Session and Transaction management fairly simply by setting up a session f...
<p>There is some work you are supposed to do to be able to do just that but it's not much at all. Supposedly, you will use JPA with pick your own provider, e.g. Hibernate. Then you need to place persistence.xml that defines the persistence unit in the META-INF folder:</p> <pre><code>&lt;?xml version="1.0" encoding="U...
How do I dynamically create multiple controls in Silverlight? <p>I know how to create a list of Controls and add new instances of them to it:</p> <pre><code>private List&lt;FirstCircleControl&gt; Circles = new List&lt;FirstCircleControl&gt;(); FirstCircleControl mc = new FirstCircleControl(); Circles.Add(mc); </code><...
<p>I wonder why you might need to create them all at once and then add them to the list, but here's a solution:</p> <pre><code>Enumerable.Range(0, 10) .Select(x =&gt; new FirstCircleControl()) .ToList() // Forces creation of controls. .ForEach(x =&gt; Circles.Add(x)...
Dummy Item in ComboBox <p>I've reached the time for a design decision on how to indicate 'none selected' in a data bound ComboBox. I wish to apply this to all future occurrences where a ComboBox needs this. One cannot set SelectedIndex to -1 on data bound combos, nor can one set SelectedValue to null.</p> <p>Commonl...
<p>You can define the "empty item" in the markup, and append any data-bound items:</p> <pre><code>&lt;asp:DropDownList DataSourceID="..." AppendDataBoundItems="true" ...&gt; &lt;asp:ListItem Value="-1" Text="None"&gt;&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; </code></pre> <p>The key is to specify <strong>Appen...
Finding when an Iframe's content changes when in designMode <p>I have an Iframe which I have enabled <a href="http://www.mozilla.org/editor/midas-spec.html" rel="nofollow">designMode</a> on. Quite simply I would like to have a callback function called if the cursor in the Iframe moves or content changes. It seemed quit...
<p>OK, I have a solution:</p> <pre><code>if(document.addEventListener) { frames['writer'].document.addEventListener('keyup', updateStatus, false); frames['writer'].document.addEventListener('mouseup', updateStatus, false); } </code></pre> <p>It works a charm!</p>
How do I link a dynamic library with qmake into my app? <p>In my qmake .pro file I add my desired dynamic library to LIB which allows for compilation but doesn't link to the library in the compiled application (i.e. I get a library not found error at run time).</p> <p>The problem is that I have the library in my build...
<p>Put a wrapper script round your program so the current working directory is in the dynamic library search path:</p> <pre><code>#!/bin/bash export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. ./program </code></pre>
Definitive dot.net Single Sign-On Solution - Develop, Steal, or Buy? <p>The problem: We have several dozen one off applications in our environment scattered across a dozen servers. Some apps are secured with one-off form/db based logins. Some apps have permissions defined in web.config. Some apps have folder level ...
<p>ISA Server 2006 might be what you're looking for. (roughly.).<br /> See: <a href="http://www.microsoft.com/forefront/edgesecurity/isaserver/en/us/default.aspx" rel="nofollow">http://www.microsoft.com/forefront/edgesecurity/isaserver/en/us/default.aspx</a></p> <p>This can support forms based authentication, as well ...
How do I design a sub class with features not available in the base class? <p>For example suppose I have a class Vehicle and I wish for a subclass ConvertibleVehicle which has extra methods such as foldRoof(), turboMode(), foldFrontSeats() etc. I wish to instantiate as follows</p> <pre><code>Vehicle convertible = ne...
<p>Any objects that use Vehicle shouldn't know about ConvertibleVehicle and its specialized methods. In proper loosely coupled object-oriented design Driver would only know about the Vehicle interface. Driver might call startEngine() on a Vehicle, but it's up to subclasses of Vehicle to override startEngine() to handle...
Creating a Custom DTD for Visual Studio <p>I've got some custom templated controls which take JavaScript as template content, like so:</p> <pre><code>&lt;ns:Custom runat="server"&gt; &lt;contentTemplate&gt; var a = new Array(); for (var i=0; i&lt;a.length; i++) { // do something } &lt;/contentTem...
<p>I admit I'm not familiar with VS templated controls, but this looks like XML (given the "ns:" namespace), and the standard way to embed left angle brackets inside XML, without them being treated as tags, is with CDATA:</p> <pre><code>&lt;ns:Custom runat="server"&gt; &lt;contentTemplate&gt; &lt;![CDATA[ ...
What is the best Java-based Mailing List application allowing opt-in/opt-out <p>I'm looking for a java-based (preferable) mailing list application that allows users to opt-in/opt-out of mailing lists. Open-source is preferable but not mandatory.</p> <p>This product would be used to send email notifications to subscri...
<p>I would recommend using a hosted service for email marketing. Sure, you may find just the right software for the job. The main issue is deliverability. A mailing service increases the chances of your mail reaching the destination. It also provides very useful reports of how many opened and who clicked what. IMHO, th...
Mailing Address Verification, Etc. Get County from Zip <p>It seems fairly common today for websites to perform some address verification behind the scenes. For example, the 4 digit extension on zip codes is commonly filled in. In addition to filling in the 4 digit zip code extension, I would like to know what county ...
<p>If you've got cash, <a href="http://www.softwarecompany.com/dotnet/netaddress.htm" rel="nofollow">NetAddress</a> is built for .NET.</p> <p>It's also been asked on SO before: <a href="http://stackoverflow.com/questions/682093/address-validation-api">here</a>.</p>
Is it possible to make anonymous inner classes in Java static? <p>In Java, nested classes can be either <code>static</code> or not. If they are <code>static</code>, they do not contain a reference to the pointer of the containing instance (they are also not called inner classes anymore, they are called nested classes)....
<p>No, you can't, and no, the compiler can't figure it out. This is why FindBugs always suggests changing anonymous inner classes to named <code>static</code> nested classes if they don't use their implicit <code>this</code> reference.</p> <p><strong>Edit:</strong> Tom Hawtin - tackline says that if the anonymous clas...
Extract embedded resource without WebResource.axd <p>Are there any ways to programmatically extract an embedded resource instead of going through the WebResource.axd handler? I have the two parameters (d &amp; t) that are passed to the WebResource.axd handler. I'm hoping there's a way I can use those parameters to ex...
<p>You can use the Assembly class. The code below returns an embedded resource as a stream from the current assembly:</p> <pre><code>using System.Reflection; Assembly assembly = Assembly.GetExecutingAssembly(); Stream stream = assembly.GetManifestResourceStream("YourEmbeddedResource"); </code></pre>
Application Screen capture and rendering <p>I'm trying to write a simple app that will do a screen capture of an application and then rendering that capture in the 'main' application (ie, the application that took the screen capture). </p> <p>I've figured out how to get the window handle and get the application's scre...
<p>Screen capture is a Win32 FAQ for 18 years.<br /> See on <a href="http://news://nntp.aioe.org/comp.os.ms-windows.programmer.win32" rel="nofollow">win32 group</a> for standard code (MS and other), C and C++</p>
Best groovy closure idiom replacing java inner classes? <p>As new to groovy...</p> <p>I'm trying to replace the java idiom for event listeners, filters, etc.</p> <p>My working code in groovy is the following:</p> <pre><code>def find() { ODB odb = ODBFactory.open(files.nodupes); // data nucleus object database ...
<p>I think it would have helped you to get answers if you'd abstracted the problem so that it didn't rely on the Neodatis DB interface -- that threw me for a loop, as I've never used it. What I've written below about it is based on a very cursory analysis.</p> <p>For that matter, I've never used Groovy either, though ...
IPhone OpenGL ES single or multiple views? <p>I'm confused on what the best approach is when writing a game for the iphone. The game will be rendered with OpenGL , but im curious when creating the Start Screen, Menu's, High Score page, etc. Do you do all of that with OpenGL or do you create additional UIViews and use t...
<p>I don't think there is a best approach. If you have the time to code up menus and high score tables in OpenGL the you have a lot more flexibility - you could for example have a 3d animation going on in the background. </p> <p>If you code menus, high score tables, etc. using standard UIKit views and switch out the O...
The HTTP verb POST used to access path '/Membership/user/' is not allowed <p>This code: </p> <pre><code>private void Submit_Click(object sender, RoutedEventArgs e) { user temp = new user(); temp.Username = UserName.Text; temp.Password = Password.Text; dataBase.AddTouser(temp); IAsyncResult result = dataBase.Begin...
<p>I got a similar problem, it seems that there are problems with the url rewriting.</p> <p><a href="http://www.lukemelia.com/blog/archives/2007/01/05/aspnet-the-http-verb-post-used-to-access-path-is-not-allowed/" rel="nofollow">http://www.lukemelia.com/blog/archives/2007/01/05/aspnet-the-http-verb-post-used-to-access...
How to delete a PHP session? <p>It's possible I'm not properly deleting PHP sessions when the user signs out. I've noticed that if I sign out and sign back in without closing the browser, the session ID doesn't change but if I sign out, close the browser window, open a new one and sign in, the session ID will be differ...
<p>If you feel the need to force a new id <a href="http://pl.php.net/manual/en/function.session-regenerate-id.php" rel="nofollow">http://pl.php.net/manual/en/function.session-regenerate-id.php</a></p> <p>And to your question, from the manual:</p> <blockquote> <p>session_destroy() destroys all of the data associa...
Easiest way to programatically add aliases to Exchange 03/07 mailboxes? <p>We currently have a specific format for how our email addresses are defined, based upon name. This system originated some time ago and is beginning to become a bit of a hindrance. </p> <p>We would like to move to a new format, based along the l...
<p>Here's a MS KB that describes modifying the alias through extended MAPI. It looks like you'll need the Exchange Developers Kit to do this.</p> <p><a href="http://support.microsoft.com/kb/183249" rel="nofollow">http://support.microsoft.com/kb/183249</a></p>
How do you generate a AntiForgeryToken in a code behind file? <p>I have an action that resets a user's password. In that same action after the password is reset I want to login the user. I wanted to just use a "RedirectToAction" and send the username and password to my SignIn action. Since I have logic in that action t...
<p>The AntiForgeryToken is only valid for POST requests (GET requests are supposed to be idempotent... that is, not change state on the server). RedirectToAction does an HTTP/302 redirect, which is results in a GET request. Therefor, an AntiForgeryToken would make no sense for RedirectToAction.</p> <p>I would reconsid...
What programming tools haven't been written yet? <p>What tools would you like to have to make development easier, which either don't exist yet or are too niche/un-featured to be useful. This question was prompted by <a href="http://www.red-gate.com/" rel="nofollow">Redgate</a> (no connection) who are looking to build a...
<p>This may sound stupid to some people, but when I was learning COBOL back in school, you could tell the IDE to step over your code line by line for you, and if you touched the mouse, the debugger would pause as if you hit a break point. There are times when I would much rather watch the debugger than press F10 repea...
Matplotlib suddenly crashes after reinstalling Xcode? <p>I was happy in my world of python and matplotlib with a good level of familiarity. I notied Xcode on my Mac wasn't working so I installed the latest version from Apple and it somehow broke my install of matplotlib (or numpy?)! I'm now getting </p> <pre><code>......
<p>You're using Python from Fink, so Xcode doesn't have anything to do with it. <code>from numpy.core.ma import *</code> works fine with Apple's bundled Python and NumPy too.</p>
SML function call doesn't parse arguments as arguments <p>I'm getting what seems to be a precedence issue in calling an SML function, substitute:</p> <pre><code>fun substitute v new (typevar q) = ... </code></pre> <p>And I am calling this from another function:</p> <pre><code>fun new_type_vars (typevar v) non_gens =...
<p>I don't understand everything, since you don't give all the types of the different operations and variables.</p> <p>But the general problem you've got is as you already guessed, SML executes the function calls (and binds the variables) from the left side. Here an example:</p> <pre><code>fun f a:int b:int c:string ...
How can I deduce a day for a date object in javascript? <p>How can I deduce a day for a date object in javascript?</p> <p>Example:</p> <p>If I assig a date into an object as below: var date_value = this.cfg.getProperty(cfgPageDate);</p> <p>and the date format in date_value as below: Fri May 29 2009 00:00:00 GMT+1...
<pre><code>var dat = new Date('2009/05/29'); alert (dat.setDate(dat.getDate()-1)); </code></pre>
How to move a Grid Panel in WPF Window <p>HI,</p> <p>How do I move (drag) a Grid Panel inside a WPF Window? The Grid Panel does not have a Position or Location or X and Y coordinate porperty. All I am looking at is to move the Grid Panel from its current location to a new location using Mouse so that the controls that...
<p>Here's some code examples to get you started:</p> <p>In XAML:</p> <p>Create a grid and define a render transform on it:</p> <pre><code>&lt;Grid x:Name="grid" Background="Blue" Width="100" Height="100" MouseDown="Grid_MouseDown" MouseMove="Grid_MouseMove" MouseUp="Grid_MouseUp"&gt; &lt;Grid.Rende...
asp.net gridview control does not show paging numbers <p>My asp.net site has master page. On one of the pages that use master page, I have 2 grid view controls. Both are tied to their own datasourcecontrols. I tried to enable paging on the grid but paging does not show up. </p> <p>please help. </p>
<p>Try setting the PageSize property to something small, like 5, and see if it comes or not.</p> <p>Also try setting the <code>AllowCustomPaging="true"</code> property.</p>
Problems building VS database project on TFS build server <p>I have two Visual Studio database projects. Both build fine on my local dev environment. On the TFS build server, with a TFS build solution containing both projcets, one builds fine and the other fails with this error:</p> <pre><code>Task "SqlBuildTask" Cr...
<p>Ahh, the problem was that I didn't have the GDR release installed on the build server. One project was created with VSDB RTM, the other with VSDB GDR.</p> <p>If only there were better error messages to help diagnose this!</p>
Best way of dynamically setting color of control at runtime <p>I currently load controls at run time, and want to set the color, but not a named color. I was thinking I need to create a color object , set the color of this then assign it, any direction? Thanks</p>
<p>You can use Color.FromName() method to set colors : </p> <pre><code>txt.ForeColor = System.Drawing.Color.FromName("#00B300"); txt.ForeColor = System.Drawing.Color.FromName("red"); </code></pre>
Notification message using php <p>I am developing an application in php. I need to display a notification message on windows taskbar. So please help me...How to do it using php.</p>
<p>With PHP, your domain is the web browser. You can display a message in the browser or in a pop up window. You can't connect to the operating system.</p>
Silverlight child windows in MVVM pattern <p>I am trying to find the right way to get the data from a ChildWindow/popup using a MVVM pattern in Silverlight (3). For example: I have a main page with a data entry form and I want to open a popup with a list of customers. When user selects a customer I want to transfer sel...
<p>More problematic here is the use of View specific terms and types in your VMs. Click events, DialogResults should not be anywhere near your ViewModels. </p> <p>With regards to the question, I had a similiar question about this here: <a href="http://stackoverflow.com/questions/454868/handling-dialogs-in-wpf-with-m...
How do I connect to a CRM IFD web service? <p>I have taken the code from the SDK and made just one modification to set the authentication type but when I try to connect I get an "Unauthorized" error.</p> <p>My code is:</p> <pre><code>// Set up the CRM Service. CrmAuthenticationToken token = new CrmAuthenticationToken...
<p>When using SPLA (IFD) you need to also populate the token with a crmticket.The ticket can be retrieved by quering the CrmDiscoveryService. </p>
How to implement a Keyword Search in MySQL? <p>HI all, I am really a new sq l programmer, can some one help me in solving this. I have a table job where the fields are id,position,category,location,salary range, description, refno. I want to implement a <strong>keyword search</strong> from the front end. The keyword ca...
<p>For a single keyword on VARCHAR fields you can use <a href="http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html"><code>LIKE</code></a>:</p> <pre><code>SELECT id, category, location FROM table WHERE ( category LIKE '%keyword%' OR location LIKE '%keyword%' ) </code></pre> <p>For a descrip...
Where do you put your SQL Queries? <p>We are using a mix of EJB 2.1 and JDBC to access our Database. </p> <p>I just had a co-worker mention the idea to put his SQL Queries into a .properties file. </p> <p>How and Where do you put your SQL Queries?</p> <p>EDIT: </p> <p>Do you inline it with the code, put into the cl...
<p>In <a href="http://en.wikipedia.org/wiki/Data_Access_Object" rel="nofollow">DAOs</a> since I consider them part of my application and not a configurable (changeable by a sysadmin) element of the application.</p>
Using Codedom to write VB.Net Properties <p>Looking at the example code on <a href="http://msdn.microsoft.com/en-us/library/system.codedom.codepropertysetvaluereferenceexpression%28loband%29.aspx" rel="nofollow">MSDN</a>:</p> <p>This </p> <pre><code> ' Declares a type. Dim type1 As New CodeTypeDeclaration("Typ...
<p>Comment #3 on <a href="http://www.devcity.net/Articles/71/codedom%5F1.aspx" rel="nofollow">this DevCity article</a> suggests it shouldn't matter, but I do know that <a href="http://www.red-gate.com/products/reflector/" rel="nofollow">Reflector</a> does behave as you're expecting, although it <em>may</em> have it's o...
Unexpected result from sys.getrefcount <p>When I typed:</p> <pre><code>&gt;&gt;&gt; astrd = 123 &gt;&gt;&gt; import sys &gt;&gt;&gt; sys.getrefcount(astrd) 3 &gt;&gt;&gt; </code></pre> <p>I am not getting where is <code>astrd</code> used 3 times ?</p>
<p>It's not <code>astrd</code> that is referenced three times, but the value <code>123</code>. <code>astrd</code> is simply a name for the (immutable) number 123, which can be referenced however many times. Additionally to that, small integers are usually shared:</p> <pre><code>&gt;&gt;&gt; astrd = 123 &gt;&gt;&gt; sy...
Is Apache XML security library compatibile with IBM's JDK <p>I developed an application that uses Apache XML security library for xml encryption and signing. It runs on SUN's JDK without any problems, however, IBM JDK gives me tons of problems. </p> <p>It doesn't sign right (validation fails), pkcs11 provider fails to...
<p>Does this thread help - <a href="http://www.ibm.com/developerworks/forums/message.jspa?messageID=1315965" rel="nofollow">http://www.ibm.com/developerworks/forums/message.jspa?messageID=1315965</a>?</p> <p>I had trouble in the past with an SSL enabled web application in Apache Tomcat because Tomcat defaults to using...
Storing arbitrary meta-data in Microsoft Word document <p>I need to store custom meta-data in a Word document. The 'document properties' are limited to 255 bytes but I have data which is >> 10k</p> <p>We are using VBA to write a word extension to interact with our application and want to have our application data stor...
<p>Just tried this in the VBA editor immediate window:</p> <pre><code>ActiveDocument.Variables.Add "foo", String(10000, ".") ? Len(ActiveDocument.Variables("foo")) 10000 </code></pre> <p>Document variables are stored with the document. They seem to go up to 65280 Unicode characters, as I just found out (tested in Wo...
add request to django model method? <p>I'm keeping track of a user status on a model. For the model 'Lesson' I have the status 'Finished', 'Learning', 'Viewed'. In a view for a list of models I want to add the user status. What is the best way to do this?</p> <p>One idea: Adding the request to a models method would do...
<p>If your status is a value that changes, you have to break this into two separate parts.</p> <ol> <li><p>Updating the status. This must be called in a view function. The real work, however, belongs in the model. The view function calls the model method and does the save.</p></li> <li><p>Displaying the status. Th...
Need user to input string /check string length (C++) <p>I'll need to accept a string of 5 numbers from the user (only 5). Should I use </p> <pre><code>istringstream </code></pre> <p>for the same ?</p> <p>Can't I get away with something like this ?</p> <pre><code>int main() { char *InputMain; InputMain=(char...
<p>Unfortunately there is no portable way to restrict the number of characters input in C++. But whatever platform you are using will provide some mechanism: for example on Windows, look up <a href="http://msdn.microsoft.com/en-us/library/ms682073(VS.85).aspx" rel="nofollow">Console functions</a>.</p> <p>If you do go...
Clear fields on CreateUserWizard, Login control <p>I have a createuserwizard and a login control on a page. both of them are customized (standard textboxes are replaced by RadTextBoxes)</p> <p>When i enter a value in the form and refresh the browser without submitting, the forms retain their values. Is there any way i...
<p>Turned out to be the Behavior of RadTextBox in Mozilla firefox</p>
VB.NET How do I reduce int to 1 decimal place? <p>I'm using the code below to convert the file size in bytes (test file is 31718 bytes) to KB (30.974609375 KB) but I want to display this to one decimal place (i.e. 30.9 KB). How would I do this in VB.NET?</p> <pre><code>New FileInfo(FileName).Length / 1024 </code></pre...
<pre><code>Math.Round(New FileInfo(FileName).Length / 1024,1) </code></pre>
What does the suffix #DEN mean on the value of a variable <p>When debugging in VS2005 I have a float in the Locals window whose values is: <code>1.744e-039#DEN</code></p> <p>What does the <code>#DEN</code> signify/stand for?</p>
<p>This is for "<a href="http://en.wikipedia.org/wiki/Denormal_number">denormalized number</a>". See <a href="http://www.masonzhang.com/2008/09/floating-point-bit-value-of-inf-nan-den.html">this</a> for more info.</p>
How to store "wishlist" in database? <p>I am thinking of creating a "wishlist". Each user will be able to purchase wishes in a shop. How do I store the wishlist? I am thinking of creating an user table and a wishlist table. </p> <p>The structure of user table: Columns: id, username, password etc</p> <p>Columns: id, w...
<p>You should also have another table to store the purchases:</p> <p>Purchases</p> <ul> <li>Id</li> <li>UserId</li> <li>WishId</li> <li>PurchaseDate</li> </ul> <p>Users</p> <ul> <li>Id</li> <li>Name</li> <li>Password</li> </ul> <p>Wishes</p> <ul> <li>Id</li> <li>Wish</li> <li>Price</li> <li>Quantity</li> </ul> <...
Bitmap and geographic coordinates <p>I have an array of geographic coordinates. I must draw a circle on each geographic coordinate. And I must get a bitmap on which these circles located.</p> <p>Bitmap size is also in geographic coordinate.</p>
<p>Sounds like you need to read up on <a href="http://en.wikipedia.org/wiki/Map%5Fprojection" rel="nofollow">map projections</a>, and pick a suitable one to either look for implementations of, or implement yourself.</p>
Can I get the absolute path to the current script in KornShell? <p>Is it possible to find out the full path to the script that is currently executing in KornShell (ksh)?</p> <p>i.e. if my script is in <code>/opt/scripts/myscript.ksh</code>, can I programmatically inside that script discover <code>/opt/scripts/myscript...
<p>You could use:</p> <pre><code>## __SCRIPTNAME - name of the script without the path ## typeset -r __SCRIPTNAME="${0##*/}" ## __SCRIPTDIR - path of the script (as entered by the user!) ## __SCRIPTDIR="${0%/*}" ## __REAL_SCRIPTDIR - path of the script (real path, maybe a link) ## __REAL_SCRIPTDIR=$( cd -P -- "$(dir...
Can an email address contain international (non-english) characters? <p>If it's possible, should I accept such emails from users and what problems to expect when I will be sending mails to such addresses?</p>
<p>Officially, per <a href="http://tools.ietf.org/html/rfc6532" rel="nofollow">RFC 6532</a> - <strong>Yes</strong>.</p> <p>For a quick explanation, check out <a href="http://en.wikipedia.org/wiki/E-mail_address#Internationalization" rel="nofollow">wikipedia</a> on the subject.</p>
Mapping a ternary association with FluentNHibernate, using IDictionary<TKey,TValue> <p>I'm trying to map a ternary association using FluentNhibernate.</p> <p>I have 3 tables:</p> <ul> <li><code>TUser(PK int id, string name, ...)</code></li> <li><code>TGroup(PK int id, string name, ...)</code></li> <li><code>TRole(PK ...
<p>In response to the reply you got on the FNH group, make sure you are exporting your mapping files like:</p> <pre><code>.Mappings(m =&gt; m.FluentMappings.AddFromAssemblyOf&lt;MyObject&gt;() .ExportTo("path") </code></pre> <p>I tend to agree with that response because I have only ever seen that type of exceptio...
How do you create a read-only user in PostgreSQL <p>I'd like to create a user in PostgreSQL that can only do SELECTs from a particular database. In MySQL the command would be...</p> <pre><code>GRANT SELECT ON mydb.* TO 'xxx'@'%' IDENTIFIED BY 'yyy'; </code></pre> <p>What is the equivalent command or series of command...
<h2>Grant usage/select to a single table</h2> <p>If you only grant CONNECT to a database, the user can connect but has no other privileges. You have to grant USAGE on namespaces (schemas) and SELECT on tables and views individually like so:</p> <pre><code>GRANT CONNECT ON DATABASE mydb TO xxx; -- This assumes you're ...
Is Serialization reliable for object size estimation? <p>I use serialization, in order to estimate the amount of memory used for an object. I already read <a href="http://stackoverflow.com/questions/426396/how-much-memory-does-a-c-net-object-use">this</a>, and <a href="http://stackoverflow.com/questions/26570/sizeof-eq...
<p>The serialized form of data is not the same as in-memory; for example, a collection/dictionary will involve multiple objects for the items, the arrays, hash-buckets/indexes, etc - but the raw data (when serialized) will <em>typically</em> be just the data - so you might see less volume when serialized.</p> <p>Equal...
Problem exposing custom complex interface types in WCF services <p>I'm trying to get hold of an object from another application using WCF. With built in classes it works fine but I run into probems when trying to return a custom interface type from the WCF operation. </p> <p>Whether I include the interface in both app...
<p>The returned property <strong>OtherTest</strong> needs to be a concrete type and not an interface, otherwise the serialization will not work.</p>
jQuery fading/dimming other list elements when one is hovered over, I'm 90% there..? <p>I have an unordered list, which has maybe 30 items. When one of these items are hovered over, the rest of the list items fade to 30% and the hovered item stays at 100%; when you move away from the list, they all fade back up to 100%...
<p>This sounded like fun, so I implemented it. From the looks of things, your css selector can be simplified. I think you only want the topmost list item to fade in and out, but it's not clear from the example. This example highlights the topmost node and does the fading correctly. I think this is the effect you were g...
How can I prevent line breaks in PHP variable used as HTML email body <p>I've created a PHP script that takes the contents of an array and stuffs them into a variable called $body:</p> <pre><code>foreach($_POST as $var =&gt; $value) { if (($var != "Submit") &amp;&amp; ($value != "")) { $body .= $var .': '.filter_v...
<p>Print your <code>"\n&lt;br/&gt;"</code>. That way you'll always get your <code>&lt;BR&gt;</code> in new lines.</p>
How to mark a device in a way that can be retrived by HAL but does not require mounting or changing the label <p>I'm trying to find a way to mark a USB flash device in a way that I can programmaticly test for without mounting it or changing the label. </p> <p>Are there any properties I can modify about a device that w...
<p>You cannot modify this property, but the tuple (vendor_id, product_id, serial_number) is unique to each device, so you can use this as mark that is already there. You can enumerate the devices on the USB bus using lsusb or usblib.</p>
Modeling Tools that understand both Relational and LDAP <p>I am looking to do some modeling and would like to have a tool that can capture not only a relational model like ERWIN but also allow us to easily port to LDAP as an option.</p> <p>NOTE: Visio can connect to an existing LDAP server and draw, but does not allow...
<p>I haven't used it in a few years, but Microsoft has an Enterprise Architect version of Visio which allows for data modeling. I would be surprised if Visio didn't also handle LDAP.</p> <p>The data modeling part probably isn't as extensive as something like ErStudio, but it allows reverse engineering of ODBC data sou...
Monitor the console output from within the actionscript - flash application <p>I am loading an as2 swf into an as3 swf. When I am debugging the as3 application (I am using flex builder as my ide) I can see the debug output from the as2 app. You can't call functions or properties of an as2 swf from within an as3 swf so ...
<p>How about LocalConnection? Here's an <a href="http://www.learningactionscript3.com/2007/12/14/sending-data-from-avm2-to-avm1/#more-29" rel="nofollow">example</a> that may or may not suit your needs.</p>
Textbox on ReportViewer (RDLC) not wrapping but forcing a page break <p>Situation: My report uses several ReportViewer Textbox controls which grow and shrink, depending on the size of the bound text. When the text in the ReportViewer textbox control is too long to fit on the current page, a page break occurs <strong><...
<p>This is quite possible. The <strong>KeepTogether</strong> property of the textbox defaults to true, and is what keeps the textbox from splitting into more than one section. To get your textbox to wrap to the next page, just set <strong>KeepTogether</strong> to false. (Note that you have to use the <em>Property Windo...
100% to 100% Flex application preloader positioning <p>I've got a problem trying to apply a loading animation to my Flex application - a whole browser window occupant. I'm subclassing DownloadProgressBar class as described on Adobe's <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=app_container_4.html"...
<p>i have code to center my custom progress loader and is working very much fine from this article <a href="http://askmeflash.com/article_m.php?p=article&amp;id=7" rel="nofollow">http://askmeflash.com/article_m.php?p=article&amp;id=7</a> </p>
Class Zend_Test_PHPUnit_ControllerTestCase could not be found <p>When I run phpunit to test my controller there always comes the message: <code>Class Zend_Test_PHPUnit_Controller_TestCase could not be found ...</code></p> <p>All require_once are executed and run without errors.</p> <p>My files:</p> <p><strong>Test.p...
<p>The class is not in your include path, Or, you don't have the class at all.<br /> Steps to take: </p> <ol> <li>Find the class file</li> <li>Make sure the class is in your include path, including the auto_loader name parsing: Z_Y_YourClass will be looked at the include_path/Z/Y/YourClass.php</li> </ol> <p>Good Luc...
Why does this code compile and run successfully it seems it should get an index out of bounds <p>I was reading through some java code in a project I was working on and came along a method with something to this effect in it.</p> <pre><code>Object[] objs = null; objs[0] = str1; objs[1] = obj1; for(String str: strArray)...
<p>That should not run. objs[0] will give an error.</p> <p>Are you sure you are running the correct version of the file?</p>
Is it legal to write to std::string? <p>In std::string there are only const members to fetch the data like c_str(). However I can get a reference to the first element of the string via <code>operator[]</code> and I can write to it.</p> <p>For example, if I have function:</p> <pre><code>void toupper(char *first,char *...
<p>Herb Sutter has this to say (<a href="http://herbsutter.wordpress.com/2008/04/07/cringe-not-vectors-are-guaranteed-to-be-contiguous/#comment-483">http://herbsutter.wordpress.com/2008/04/07/cringe-not-vectors-are-guaranteed-to-be-contiguous/#comment-483</a>):</p> <blockquote> <p>current ISO C++ does require &amp;s...
WCF: How to get Host IP or Server Name <p>I have a WCF service that is hosted via IIS on multiple web servers. I have a logging method that logs the calls to the database and I'd like to log which server the call is executing on.</p> <p>Does anyone know how to get the host server name or IP address that the WCF call ...
<p>Use Dns.GetHostName(), because it's much better to get the name of the computer than the host IP. Consider the case when your host computer have more than one IP address, has virtual network cards (VMWare).</p>
Data import wizard library for .Net? <p>Does anyone know of a 3rd party data import wizard that can be embedded into applications? It should import from Excel, Access, SQLServer, csv, tab-separated flat file, XML, Oracle etc. We have a fixed data structure within our application and the user should be able to configure...
<p>If you can assume that your application has SQL Server available, it is fairly straightforward to programmatically set up a SSIS package to do this type of transformation. Your application would provide a UI where you could set up the metadata for the data source and map it to the destination. You could possibly e...
ClickOnce deployment error on upgraded .NET application <p>I have a Windows forms application that was developed in Visual Studio 2005 and deployed to an IIS server via ClickOnce. I've upgraded to VS2008 so I decided to upgrade and redeploy the application (in test). I ran the upgrade wizard, manually changed the proje...
<p>Please verify that you have .NET Framework 3.5 set as a prerequisite.</p> <p>Project Settings -> Publish -> Prerequisites</p>
How to do a Select in a Select <p>I have a table containing a unique ID field. Another field (REF) contains a reference to another dataset's ID field. Now I have to select all datasets where REF points to a dataset that doesn't exist.</p> <pre><code>SELECT * FROM table WHERE ("no dataset with ID=REF exists") </code></...
<p>3 ways</p> <pre><code>SELECT * FROM YourTable y WHERE NOT EXISTS (SELECT * FROM OtherTable o WHERE y.Ref = o.Ref) SELECT * FROM YourTable WHERE Ref NOT IN (SELECT Ref FROM OtherTable WHERE Ref IS NOT NULL) SELECT y.* FROM YourTable y LEFT OUTER JOIN OtherTable o ON y.Ref = o.Ref WHERE o.Ref IS NULL ...
best way of converting letters to base-10 <p>So far I have something such as: </p> <pre><code>if( Char.IsDigit( c ) ) return Int32.Parse( "" + c ); if( Char.IsLetter( c ) ) return Char.ToUpper( c ) - 'A' + 1; </code></pre>
<p>For the first one:</p> <pre><code>if (Char.IsDigit(c)) return c - '0'; </code></pre>
How to debug a windows service using breakpoints? <p>I have a windows service with a timer. Its very hard to debug it. Because I start the service and put break points in different parts of the code. When I attach the process, I expect the service to start from the very beginning instead of some randome place in the mi...
<p>I assume you're talking about .Net of course. I've always used the following code to debug my services. I place it where I want to the debugger to launch. Start the service and it automatically launches Visual Studio. Works well for me. </p> <p><code>System.Diagnostics.Debugger.Launch();</code></p> <p><code>System...
Bind multiple TextBoxes to one struct in WPF <p>How do i bind two TextBox objects to a <a href="http://msdn.microsoft.com/en-us/library/system.windows.size.aspx" rel="nofollow">System.Windows.Size</a> <strong>struct</strong>? The binding only has to work in this direction:</p> <p>(textBox1.Text + textBox2.Text) => (Si...
<p>Could you not just expose 2 properties - width and height from your model, along with a size property. The width and height would appear in your {Binding} expressions, and then when you want to get the size property, it initialises based on these two fields. </p> <p>Eg, your model might be something like;</p> <pre...
WiFi connection is dropped after user inactivity period <p>My iPhone application establishes a TCP connection through wifi to a remote server. However, if there is no user activity for a certain time, the device closes wifi and drops the connection. Is it possible to prevent it? I need the connection to be persistent w...
<p>Check out this URL: <a href="http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ApplicationEnvironment/ApplicationEnvironment.html#//apple_ref/doc/uid/TP40007072-CH7-SW59" rel="nofollow">http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOS...
How does the IN predicate work in SQL? <p>After prepairing an answer for <a href="http://stackoverflow.com/questions/761044/sql-query-help">this question</a> I found I couldn't verify my answer.</p> <p>In my first programming job I was told that a query within the <code>IN ()</code> predicate gets executed for every r...
<p>The warning you got about subqueries executing for each row is true -- for <strong>correlated subqueries.</strong></p> <pre><code>SELECT COUNT(*) FROM Table1 a WHERE a.Table1id NOT IN ( SELECT b.Table1Id FROM Table2 b WHERE b.id_user = a.id_user ); </code></pre> <p>Note that the subquery references the <code>id...
Optimal Way to Store/Retrieve Array in Table <p>I currently have a table in MySQL that stores values normally, but I want to add a field to that table that stores an array of values, such as cities. Should I simply store that array as a CSV? Each row will need it's own array, so I feel uneasy about making a new table a...
<p>The "right" way would be to have another table that holds each value but since you don't want to go that route a delimited list should work. Just make sure that you pick a delimiter that won't show up in the data. You can also store the data as XML depending on how you plan on interacting with the data this may be a...
Why won't this PHP iteration work? <p>I want to make the results of a foreach loop into a string variable I can use later all over (so I don't need to paste the foreach loop everywhere). I have this:</p> <pre><code>foreach($pairs as $d=&gt;$m) { $orderedpairs .= "[".$d."],[".$m."]"+"&lt;br /&gt;"; } echo $orderedpairs...
<p>You have a + in there for concatenation. You need .</p> <p>Also, you should define $orderedpairs as an empty string before the loop.</p>
Strange Rails Routing behaviour: two ids swapped around in nested resources <p>I have the following routing set up in my app (forms belong to a site):</p> <pre><code>map.resources :sites do |site| site.resources :forms end </code></pre> <p>However, when I try to go to a path for edit (or such) for a form using the ...
<p>The <code>edit_site_form_path</code> method has to have two parameters, the site_id and the form_id. So in your example you are only passing in the form_id. The first parameter is what ever model comes first in the method, in this case it is <code>site</code>. The second parameter is the form_id.</p> <p>A revamped...
Why csv.reader is not pythonic? <p>I started to use the <a href="https://docs.python.org/2/library/csv.html#csv.reader" rel="nofollow">csv.reader</a> in Python 2.6 but you can't use <code>len</code> on it, or slice it, etc. What's the reason behind this? It certainly feels very limiting.</p> <p>Or is this just an aban...
<p>I'm pretty sure you can't use len or slice because it is an iterator. Try this instead.</p> <pre><code>import csv r = csv.reader(...) lines = [line for line in r] print len(lines) #number of lines for odd in lines[1::2]: print odd # print odd lines </code></pre>
Hibernate: No CurrentSessionContext configured <p>I keep getting a :</p> <blockquote> <p>HibernateException: No CurrentSessionContext configured!</p> </blockquote> <p>in my code. The only information other searches that returned is that the culprit is:</p> <pre><code>&lt;property name="current_session_context_c...
<p>I believe you need to set your current_session_context_class to an actual class...I have my hibernate.cfg.xml configured for that as follows:</p> <pre><code>&lt;property name="hibernate.current_session_context_class"&gt;org.hibernate.context.ThreadLocalSessionContext&lt;/property&gt; </code></pre> <p>The above cod...
Fastest way to compare two data structures in java <p>I would like to know what is the fastest way in java 1.5 to compare two data structures.</p> <p>My data structure represents a tree that can be pretty big. I can traverse the whole data structure and compare the 2 node by node (which I guess will be slow). Or I can...
<p>Have you considered keeping a running hashCode which is continually updated as elements are inserted or removed from your trees? This way, comparing a tree at any given time by hashCode will be instantaneous.</p> <p>Depending on how you implement your hash function, and how frequently you insert and remove nodes, t...
DDD: Saving Changes to Model and accessing Repository <p>I have a Question object thats the root of the Question Aggregate. THe question has associated Answer Entities in its aggregate . When a new Answer object is created, the changes will be saved to DB via repository. Can I call a repository method SaveAnswer(Questi...
<p>Firstly, let me say there are no hard and fast rules here, this is my understanding of DDD and repository access, but it's a fairly subjective area...</p> <p>So, from a DDD perspective what you might want to do when adding an Answer to an existing Question is something like the following C# style pseudocode:</p> <...
.NET: Disposing a HashAlgorithm object <p>Objects that derive from HashAlgorithm such as MD5CryptoServiceProvider have a Dispose() method, but it's private. Instead it has a Clear() method which "Releases all resources" used by it.</p> <p>WTF?</p> <p>Is this how to correctly dispose of a HashAlgorithm then?</p> <pre...
<p>While the <code>Dipose()</code> method is private, if you cast it to <code>IDisposable</code> you can gain access to it. As others have said, though, <code>Clear()</code> will call it for you.</p> <p>A better approach, however, is to enclose the declaration and and assignment of the variable in a using() block:</p>...
How can I check for average concurrent events in a SQL table based on the date, time and duration of the events? <p>I have a set of call detail records, and from those records, I'm supposed to determine the average concurrent active calls per system, per hour (at a precision of one minute). If I query 7pm to 8pm, I sho...
<p>I think MarkusQ has the answer, but let me develop an alternative that you may find easier to use. I'll use my <a href="http://stackoverflow.com/questions/702500/sql-query-to-collapse-duplicate-values-by-date-range/712309#712309">customary method</a> of developing this as a series of simple transformations in views,...
VS2008 Immediate Window Lost <p>I work in Visual Studio 2008, and a moment ago, I lost access to the windows usually docked at the bottom of the IDE (Immediate, Error List, Search Results) and I can't find a way to get them back again.</p> <p>I tried</p> <ul> <li>Using all the possible shortcuts (<kbd>CTRL</kbd>+<kbd...
<p>The menu commands (which you've already tried)</p> <ul> <li>Debug > Windows > Immediate</li> <li>View > Find Results > Find Results</li> </ul> <p>or the keyboard shortcuts</p> <p><kbd>Ctrl</kbd> + <kbd>D</kbd>, <Kbd>I</kbd> or <kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <Kbd>I</kbd> (For the Immediate window)</p> <p>shou...
How to use custom serialization during .NET remoting? <p>I've written a custom serialization routine that does not use ISerializable or the SerialzableAttribute to save my objects to a file.</p> <p>I also remote these same objects and would like to use the same serialization technique. However, I don't want to implem...
<p>If you want to use <em>remoting</em> then you are limited to <code>BinaryFormatter</code>. Normally, you can use a "serialization surrogate" to provide a serializer separate to the formatter, but AFAIK this deoesn't work with .NET remoting.</p> <p>However; if you write your own RPC stack (over TCP/IP or HTTP, for ...
Active Directory - Django/Rails <p>I'm thinking about re-writing a web app in Django or Rails and wondering about authenticating against AD. Is one ecosystem better suited for this (libraries, etc) or is it a toss-up?</p> <p>(The app will be hosted on Linux)</p> <p>I have lots of reasons for the re-write, one them i...
<p>A quick google to give you some pointers on using Active Directory in these environments.</p> <ul> <li><a href="http://www.djangosnippets.org/snippets/501/" rel="nofollow">http://www.djangosnippets.org/snippets/501/</a></li> <li><a href="http://www.zorched.net/2007/06/04/active-directory-authentication-for-ruby-on-...
Best Way to Handle SQL Parameters? <p>I essentially have a database layer that is totally isolated from any business logic. This means that whenever I get ready to commit some business data to a database, I have to pass all of the business properties into the data method's parameter. For example:</p> <p><code>Public...
<p>So essentially you want to pass in a <a href="http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx" rel="nofollow">List</a> of <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlparameter.aspx" rel="nofollow">Parameters</a>?</p> <p>Why not redo your Commit function and have it accept a List ...
NHibernate Conceptual Aggregate Roots <p>I have a couple of entities that I want to treat as an aggregate. The problem is their association is conceptual rather than via foreign keys in the DB.</p> <p>The schema I was given: <img src="http://files.robtennyson.us/2009/2009-04-17%5F1414.png" alt="alt text" /></p> <p>M...
<p>You can map relations between tables based on non-primary-keys, but in a limited way. </p> <p>To give some specific advise, you have to ask a more specific question. Try to map it and if something does not work as you expect, ask.</p>
Getting Object Functionallity out of C++ code in C# <p>I have have a function in wrote in C++ that calls some functions in a old lib. This function creates some memory makes the calls and destroys the memory. To optimize this I would create an object that would keep the memory allocated until the object was destroyed. ...
<p>I prefer to write a managed wrapper in C++/CLI (formerly Managed C++), as it makes it much easier to explicitly do what you want with managed/unmanaged interoperability on the C++ side, and your C# doesn't get polluted with P/Invoke style code.</p> <p><strong>Edit</strong> Just noticed your comment "<em>However I'm...
SSRS 2005: Change column display from item column value/one row to something else? <p>I have a table/dataset like:</p> <pre><code>1/1/2009 | Training 1 | Mike 1/1/2009 | Training 1 | Bill 1/1/2009 | Training 1 | Steve </code></pre> <p>I would like to display as</p> <pre><code>1/1/2009 | Training 1 Mike, Bill, Steve...
<p>Without using SQL to generate the CSV, then try a matrix control to change the rows into columns and groups on the date/training... but you won't have commas in between.</p>
How do I keep my world data in synch in a multi-threaded game engine? <p>So I'm trying to create a simple multi-threaded game engine for the game I want to write. So far, everything has worked without any problems, I even know what steps I have to take to finish it.</p> <p>There is only one thing I don't know (well, t...
<p>No, there is not an accepted general answer, it is a current area of research in games development. </p> <p>My 2 cents is the conventional wisdom - which one to use really depends on your specific use case - if your game has lots of data (ie it's very memory intensive, like most blockbuster titles), you'll probabl...
Filer DataTable to exclude DBNull.Value <p>I receive a DataTable from excel file and data in the first Column looks like this:</p> <p>11129</p> <p>DBNull.Value</p> <p>29299</p> <p>29020</p> <p>DBNull.Value</p> <p>29020</p> <p>I'm using LINQ to select distict and it works if there are no DBNull.Value values as be...
<p>As hinted at in Jeremy's answer, If you've a reference to <a href="http://msdn.microsoft.com/en-us/library/bb360891.aspx" rel="nofollow">System.Data.DataSetExtensions.dll</a>, you'll get some handy extension methods for working with DataSets and DataTables using LINQ. Specifically, you can use the Field<code>&lt;int...
Axis 2 java2wsdl creates different wsdl than JBoss shows in the ?wsdl URL <p>I'm refactoring the way the client code for a bottom-up web service is built. The existing build creates the Java client code by using a deployment of the web service on JBoss 4.2 and executing the Axis 2 AntCodegenTask against <a href="http:...
<p>Deploy webservice on JBoss server. Save locally WSDL file and pass it as a parameter to Ant task. Hopefully generated classes would be correct, however it may happen that Axis 2 would not like to work with JBoss generated WSDL.</p> <p>In that case use wsconsume.bat provided with JBoss instead of AXIS ant task.</p> ...
How to capture output of execvp <p>I'm developing a program which executes a program using execvp. It needs to capture the results of the child process and parse them in the main process. It seems there is a way, using named pipes, and duping. I'm trying to hunt down a good example of this, but so far no luck. If anyon...
<p>You don't need named pipes; unnamed pipes work just fine. Actually, often you can just use <code>popen</code> instead of doing the <code>pipe</code>/<code>fork</code>/<code>dup</code>/<code>exec</code> yourself. <code>popen</code> works like this (though your <code>libc</code>'s implementation likely has more erro...
ASP.NET Store uploaded file sql server table <p>How do you store a file that was uploaded by an ASP.net webform into a sql server 2005 varbinary(max) field?</p> <p>Here is what I have so far:</p> <pre><code>protected void btnUpload_Click(object sender, EventArgs e) { for (int i = 0; i &lt; Request.Files.Count; i+...
<p>There's nice tutorial on how to upload a file directly into the database at <a href="http://www.4guysfromrolla.com/articles/120606-1.aspx" rel="nofollow">4GuysFromRolla</a></p>
How can I automatically fold a long C code in Vim? <p>I regularly run into C-codes without folding. It is irritating to read them if there is no folding, particularly with long files. How can I fold them?</p>
<p>To fold according to syntax</p> <pre><code>:set foldmethod=syntax </code></pre> <p>If you want to do it manually on the bits you want to fold away</p> <pre><code>:set foldmethod=manual </code></pre> <p>then create new folds by selecting / moving and pressing zf e.g.</p> <pre><code>shift-v j j zf </code></pre> ...
Do singleton exceptions work? <p>A collegue of mine at work gave a presentation on static factory methods (right out of Effective Java), and then gave an example of its use for obtaining static / singleton exceptions. </p> <p>This set off a red flag for me. Aren't exceptions stateful? Aren't they populated by the J...
<p>Singleton exceptions are supposed to be a performance optimization. The thinking is that you eliminate the cost of populating the stack trace when creating an exception which is usually the most expensive part of exceptions.</p> <p>If the exception were sufficiently unique and descriptive and the stacktrace was not...
Does anybody have a code review checklist for annual reviews? <p>I have a software engineer that I supervise and management needs a "code review" as part of his annual review. I'm thinking that there might be something out there that could help with this. Something along the lines of a list of categories and maybe a ra...
<p>I've got just what you need. It's a comprehensive assortment of already created documents including but not limited to review forms, inspection data spreadsheets, process descriptions, etc. : <p> <a href="http://www.processimpact.com/pr%5Fgoodies.shtml" rel="nofollow">http://www.processimpact.com/pr_goodies.shtml</a...
Matlab subclassing question <p>Question about subclassing in matlab, under the new class system. I've got class A with some protected properties:</p> <pre><code>classdef Table &lt; Base properties (SetAccess = protected, GetAccess = public) PropA = []; end %properties </code></pre> <p>I'd like to make a subclass...
<p>I don't believe this is possible. From <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/matlab%5Foop/brenyev-1.html#zmw57dd0e11935" rel="nofollow">MATLAB Documentation</a>:</p> <p>There are only two conditions that allow you to redefine superclass properties:</p> <ul> <li>The superclass property Abst...
How to display all elements in an arraylist? <p>Say I have a car class with attributes <code>make</code> and <code>registration</code>, and i create an ArrayList to store them. How do I display all the elements in the ArrayList?</p> <p>I have this code right now:</p> <pre><code>public Car getAll() { for(int i = ...
<p>Are you trying to make something like this?</p> <pre><code>public List&lt;Car&gt; getAll() { return new ArrayList&lt;Car&gt;(cars); } </code></pre> <p>And then calling it:</p> <pre><code>List&lt;Car&gt; cars = c1.getAll(); for (Car item : cars) { System.out.println(item.getMake() + " " + item.getReg())...
How do social networking websites compute friend updates? <p>Social networking website probably maintain tables for users, friends and events... </p> <p>How do they use these tables to compute friends events in an efficient and scalable manner?</p>
<p>Many of the social networking sites like Twitter don't use an RDBMS at all but a Message Queue application. A lot of them start out with a already present application like RabbitMQ. Some of them get big enough they have to heavily customize or build their own. Twitter is in the process of doing this for the second t...
Using Javascript OpenID Selector with Rails <p>Based on <a href="http://stackoverflow.com/questions/702114/stackoverflow-like-login-system-in-rails">this article</a>, it seems like SO is using <a href="http://code.google.com/p/openid-selector/" rel="nofollow">Javascript OpenID Selector</a> (JOIS) to handle OpenID login...
<p>In answer to #4, no. All the options provided by the OpenID Selector are standard OpenID Providers and the ruby OpenID library (I'm assuming you're talking about the Janrain one) supports all of them.</p> <p>Sorry I can't help you with the rest. I haven't actually used the Ruby library myself for over 3 years.</p...