input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
Using PowerMock or How much do you let your tests affect your design? <p>I've been a fan of EasyMock for many years now, and thanks to SO I came across references to PowerMock and it's ability to mock Constructors and static methods, both of which cause problems when retrofitting tests to a legacy codebase. </p>
<p>O... | <p>I have to strongly disagree with this question.</p>
<p>There is no justification for a mocking tool that limits design choices. It's not just static methods that are ruled out by EasyMock, EasyMock Class Extension, jMock, Mockito, and others. These tools also prevent you from declaring classes and methods <code>fin... |
When to use If-else if-else over switch statments and vice versa <p>Why you would want to use a switch block over a series <code>if</code> statements?</p>
<p>Switch statements seem to do the same thing but take longer to type.</p>
| <p>As with most things you should pick which to use based on the context and what is conceptually the correct way to go. A switch is really saying "pick one of these based on this variables value" but an if statement is just a series of boolean checks.</p>
<p>As an example, if you were doing:</p>
<pre><code>int valu... |
How do I configure WinCE to use wildcard SSL certificates? <p>Our Windows CE 5.0 application has a problem with our wildcard SSL certificate (*.domain.com) - it won't accept it as valid.</p>
<p>I understand that Windows Mobile 6.0 has support for wildcard certificates (earlier versions don't) and that is built on WinC... | <p>This will accept all certs, modify as needed.</p>
<p>System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();</p>
<pre><code>public class TrustAllCertificatePolicy : System.Net.ICertificatePolicy
{
public TrustAllCertificatePolicy()
{ }
public bool CheckValidationResult(Serv... |
Refresh problems with databinding between Listview and ComboBox <p>I am wrestling with a binding problem in WPF/Silverlight. I have a Listview witch is filled by a DataContext form an EF linq query. In the same usercontrol are textboxes. When changing their values, the listview gets refresht and the data is changed in ... | <p>You are setting the DataContext of the ComboBox, but not the ItemsSource. In code, you are overwriting that DataContext by providing a list of control types, so that part of the XAML is ignored anyway.</p>
<p>Remove the DataContext declaration and use this instead:</p>
<pre><code>ItemsSource="{Binding}"
</code></p... |
How to programmatically manipulate an EPS file <p>I am looking for libraries that would help in programatically manipulating EPS (Encapsulated PostScript) files. Basically, what I want to do is following:</p>
<ul>
<li>Show / Hide preexisting layers in the EPS file (toggle them on and off)</li>
<li>Fill (color) named s... | <p>This is extremely difficult and here is why: a PS file is a program whose execution results in pixels put on a page. Instruction in a PS program are at the level of "draw a line using the current pen and color" or "rotate the coordinate system by 90 degrees" but there is no notion of layers or complex objects like y... |
Slow refresh on panel scrolling <p>I'm developing an user control that I need for a project, the control have around 13 rows, 7 columns of textboxes, comboboxes... everything on a form autoscrollable.
The problem is that in execution time when scrolling the content refreshing is very very slow.
Some idea?</p>
<p>Using... | <p>Try using <code>DoubleBuffered = true</code> within the constructor of your UserControl.</p>
|
How does object reuse work in .NET? <p>I've recently moved from VB6 to VB.NET and I am finally getting there with understanding the inner workings. I've been looking at my company's existing codebase and I am a little suprised. </p>
<p>I understand that when VB.NET creates a string it see's if the string is in memory ... | <p>Your understanding of strings is only applicable to string constants - not strings which are created in any other way.</p>
<p>If the thousands of Database objects are all "the same" then it sounds like they should actually be passing a reference to the same object around. You need to understand <a href="http://pobo... |
How can I replicate the trashing animation of Mail.app <p>In my iPhone app, I have put a UIBarBUtton of type UIBarButtonSystemItemTrash in my UIToolBar. When pressed, I'd like to replicate the animation of Mail.app: the bin opens, the UIView folds and flies into it.<br />
Is there a way to access this animation ithroug... | <p>Use the suckEffect type on an animation. Also: spewEffect, genieEffect, unGenieEffect, twist, tubey, swirl, cameraIris, cameraIrisHollowClose, cameraIrisHollowOpen, rippleEffect, charminUltra, zoomyIn, and zoomyOut. Doesn't work in the simulator.</p>
<pre><code>CATransition *animation = [CATransition animation];
an... |
css : round cornered div on hover <p>I am trying to accomplish something that seemed quite simple... </p>
<p>I have 3 divs that contain a radiobutton and some content:</p>
<pre><code> Content of DIV1,
[] this can be as long or as tall
as wanted
[] Content of DIV2
[] Content of DIV3
</code></pre>
<p>... | <p>this changes the CSS with jquery on the hover of a div</p>
<pre><code>print("<div id="output" class="div"></div>
<script>
jQuery(document).ready(function() {
$("#output").hover(function() {
$(this).css({ 'background-color': 'yellow', 'font-weight': 'bolder' });
}, function... |
Select either a file or folder from the same dialog in .NET <p>Is there an "easy" way to select either a file OR a folder from the same dialog?</p>
<p>In many apps I create I allow for both files or folders as input.
Until now i always end up creating a switch to toggle between file or folder selection dialogs or stic... | <p>Technically, it is possible. The shell dialog used by FolderBrowseDialog has the ability to return both files and folders. Unfortunately, that capability isn't exposed in .NET. Not even reflection can poke the required option flag.</p>
<p>To make it work, you'd have to P/Invoke SHBrowseForFolder() with the BIF_B... |
Performance Point, Dashboard Designer <ol>
<li>I am brand new to this product. Microsoft has some good free videos...but I am looking for a site where I can ask question about 'how to', or post problems..any recommendations?</li>
</ol>
<p>(<a href="http://www.microsoft.com/business/performancepoint/resources/training.... | <p>I would do the calculation on your database side. Then it's simple to just pull the caculated value into the dashboard. Dashboard Designer isn't the best at doing calculations (beyond normal aggregations like sum, average, etc).</p>
|
How can I hide some content from some users with PHP? <p>I have created an intranet for our company using PHP. The same menu appears on every page, and includes links to sensitive pages and documents (like Word files).</p>
<p>Currently only in-office employees have access to the site, but we'd like to open it up to so... | <p>If users are logging in, then you can use their login details to restrict access. You might want to look into the idea of <a href="http://en.wikipedia.org/wiki/Access_Control_Lists" rel="nofollow">Access Control Lists</a>.</p>
<p>If your users are logging in using Apache, then you can access their user name from $_... |
Assigning cout to a variable name <p>In ANSI C++, how can I assign the cout stream to a variable name? What I want to do is, if the user has specified an output file name, I send output there, otherwise, send it to the screen. So something like:</p>
<pre><code>ofstream outFile;
if (outFileRequested)
outFile.open(... | <p>Use a reference. Note that the reference must be of type <code>std::ostream</code>, not <code>std::ofstream</code>, since <code>std::cout</code> is an <code>std::ostream</code>, so you must use the least common denominator.</p>
<pre><code>std::ofstream realOutFile;
if(outFileRequested)
realOutFile.open("foo.t... |
Windows .Net controls - Creating property templates <p>Assume that all text box controls in my .Net Windows application created by dragging a TextBox control onto the Form editor should have the following default properties (some text box instances can override these properties) : <br></p>
<p>Text Align: Centre <br/>
... | <p>You have two options here.</p>
<p>The first is to create a method that iterates over all nested controls on a form, and picks the textboxes and change the properties, then call this property in the form's initialization code.</p>
<p>The other is to inherit the textbox control in question, and change the properties... |
Visual Studio shortcut for showing dropdown of available Enum values for function argument <p>When calling an overloaded argument in visual studio, visual studio often doesn't show the dropdown of available enumerated values available for a function argument. Is there a shortcut one can use the force the dropdown to b... | <p>CTRL + SHIFT + SPACEBAR to show methods overloads</p>
<p>CTRL + SPACEBAR to show Enum values</p>
|
Pass anonymous function by value in javascript? <p>I have a function that accepts an anonymous function as an argument and sets it to a variable (scoped) for reference. I then try to execute another function with that reference but it obviously fails since that function is out of scope.</p>
<p>I was wondering if anyo... | <pre><code> var tf = arguments.splice(i,1)
</code></pre>
<p>This returns an array into tf. Is eventListen expecting an array? If not use:-</p>
<pre><code> var tf = arguments.splice(i,1)[0]
</code></pre>
<p>Since you don't seem to have any other uses for your other arguments why are you using splice anyway?</p>
|
How can I hook into the UI rendering "engine" of ASP.NET Dynamic Data? <p>I have decorated my model using Metadata classes attached to my model classes via the MetadataType attribute. I have some use the Range attribute, Required attribute, etc. <em>and some custom attributes I have created.</em> </p>
<p>Now I want to... | <p>There is a dynamic data project for ASP.NET MVC, but I think it is pretty much on hold:</p>
<p><a href="http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=15459" rel="nofollow">http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=15459</a></p>
<p>I looked at it a while back and ... |
What are the possibly situations that .net Viewstate could stop working? <p>Consider the following code:</p>
<pre><code> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
If Page.IsPostBack Then
If ViewState("test") IsNot Nothing Then
Re... | <p>Figured it out, someone had changed the Page_Load event to handle Page.Init</p>
<pre><code>Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
</code></pre>
|
Changing the owner of an existing process in Linux <p>I would like to start tomcat (Web Server) as a privileged user, and then bring it back to an unprivileged user once it has started. Is there a way to do this programatically, or in general with Linux?</p>
<p>Thanks.</p>
| <p>The underlying system call that you need is <code>setuid(2)</code>, but it's not exposed by any of the Java APIs.</p>
<p>It's not hard to write a JNI wrapper that would give access to it though, although even then you'd need to find a suitable place in the Tomcat startup code to invoke <code>setuid</code> after the... |
How do I return multiple datatables from a SQL Server stored procedured? <p>I need to make two queries on two different tables and the data isn't really related. So when I call the stored proc through my code, I should be getting a DataSet with two DataTables, one DataTable for each query. How is that done in SQL Serve... | <p>Simply execute two SELECT statements in the proc:</p>
<pre><code>SELECT * FROM Foo
SELECT * FROM Bla
</code></pre>
<p>when you then Fill() a dataset, you'll get two datatables, one with the first resultset, the other with the second. </p>
|
auto-detecting components using spring annotations <p>I've managed to configure to spring to auto-detect my components using the @Autowire
annotation. However the problem is that not all the components are being Auto wired.<br />
Specifically My DAO's are being bound but my service objects aren't. I have to explicit... | <p>If spring is not complaining about anything but it's still not being wired, there are a few probable causes, from most to least likely:</p>
<ul>
<li>The service implementation is missing the proper annotation; i.e @Component, @Controller, @Service or one of the other annotations.</li>
<li>If the implementation is n... |
Generating absolute URLs from Seam emails <p>Is there a way to coax either the <code>h:outputLink</code> or <code>s:link</code> tags into generating absolute URLs? In a Seam email message, I want to be able to do something like</p>
<pre><code><s:link view="/someView.xhtml">
<f:param name="a" value="#{a.n... | <p>Never mind... I should have looked more closely at my copy of "Seam in Action" before asking this one. Setting the <code>urlBase</code> attribute on the <code>m:message</code> tag did the trick.</p>
|
WPF: Best way to raise a popup window that is modal to the page? <p>I am building a WPF app using navigation style pages and not windows.
I want to show a window inside a page, this window must be modal to the page, but allow the user to go to other page, and go back to the same page with the modal window in the same ... | <p>This <a href="http://stackoverflow.com/questions/173652/how-do-i-make-modal-dialog-for-a-page-in-my-wpf-application/173769#173769">StackOverflow answer</a> may help you on your way.
I created some sample code that some other users have asked for. I have added this to a blog post <a href="http://bradleach.wordpress.c... |
What is the best way to implement C#'s BackgroundWorker in Delphi? <p>I use C#'s <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx" rel="nofollow" title="BackgroundWorker">BackgroundWorker</a> object frequently to start a thread and perform a task. What's the easiest way to a... | <p>Look into <a href="http://otl.17slon.com/" rel="nofollow">OmniThreadLibrary</a> by Primoz Gabrijelcic, or into <a href="http://andy.jgknet.de/blog/?page_id=100" rel="nofollow">AsyncCalls</a> by Andreas Hausladen, which should both give you similar functionality.</p>
|
How do I create a workspace window for other windows using c# in visual studio 2008? <p>I'd like to create a workspace with status bar and menu, and within this workspace container have smaller windows of various types. </p>
<p>For example, if you un-maximise a worksheet in Excel but not the main window, it becomes a ... | <p>You want an MDI (Multiple Document Interface) Form</p>
<p>Just set the IsMdiContainer property of your main form to True, and you should be able to add other forms as mdi children.</p>
|
Tracking Clicks on a Flash Ad <p>When a site has third party flash ads, is it possible for the site to track clicks to the flash? As the flash files are not created by the site, they cannot be changed. But the site wants to confirm the click-through counts that the ad agency is reporting with its own click tracking.</p... | <p>Your loader technique seems the most sane. One of the benefits is, you can make it generic so that it can load any ad you want, with as many instances on the page as you need, while always yielding the same click data. This simplifies the need to capture multiple types of click data that different Flash ads someti... |
Is there a GIS "Hello World" Equivalent? <p>Is there the equivalent of the "Hello World" program for GIS applications?</p>
<p>I am looking to become more familiar with the development of GIS applications. What are the popular (and free/low cost) tutorials and/or sample applications that would help someone get started... | <p>You could start with some basic desktop mapping software like <a href="http://udig.refractions.net/">uDig</a> or <a href="http://www.qgis.org">Quantum GIS</a>. And download some <a href="http://www.google.com/search?q=free+gis+data">Shape files</a>. </p>
<p>From there you might want to take a look at <a href="http:... |
Using XmlSerializer with private and public const properties <p>What's the simplest way to get XmlSerializer to also serialize private and "public const" properties of a class or struct? Right not all it will output for me is things that are only public. Making it private or adding const is causing the values to not ... | <p><code>XmlSerializer</code> only looks at public fields and properties. If you need more control, you can implement <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.ixmlserializable.aspx">IXmlSerializable</a> and serialize whatever you would like. Of course, serializing a constant doesn't mak... |
Array posting in PHP <p>I am trying to post an array full of checkboxes and to open it in the next page..</p>
<p>It only gives me the last result, anyone know why? or how to fix it?</p>
<pre><code><form name="input" action="createevent.php" method="post">
Event title:
<input type="text" name="Eventtitle" s... | <p>PHP will only automatically make a POST value into an array if it ends in <code>[]</code>.</p>
<p>So you need to have <code>name="day[]"</code> instead of just <code>name="day"</code>.</p>
<p>(Note that this works for any POST value, and also with associative arrays instead of just auto-incrementing -- you can do ... |
Naming conventions for abstract classes <p>I distinctly remember that, at one time, the guideline pushed by Microsoft was to add the "Base" suffix to an abstract class to obviate the fact that it was abstract. Hence, we have classes like <code>System.Web.Hosting.VirtualFileBase</code>, <code>System.Configuration.Config... | <p>In <a href="http://www.amazon.co.uk/Framework-Design-Guidelines-Conventions-Libraries/dp/0321246756/ref=sr_1_2?ie=UTF8&qid=1231531546&sr=8-2" rel="nofollow">Framework Design Guidelines</a> p 174 states:</p>
<blockquote>
<p><strong>Avoid</strong> naming base classes with a "Base" suffix if the class is int... |
MVP and UserControls and invocation <p>I'm having some fun trying to get my head around some MVP stuf, as it pertains to User Controls. I'm using .NET WinForms (or something close to it) and Supervising Controller pattern (well, I think I am :). </p>
<p>The User Control is itself part of an MVP application (its the Vi... | <p>A presenter should be thought of as "autonomous state" in the presentation tier. This means that it is responsible for ensuring that the view's presentation of the model's state is in sync. The reason I bring this up is because the "pattern" of MVP often gets lost in the dogmatic view of <em>how</em> things should... |
why is the iframe contents empty? <p>I'm trying to understand this bit of code:</p>
<p>in display.php:</p>
<pre><code><html>
...
<body>
<table>
<tr>
<td>
User info: <iframe id="SpControlFrame1" name="SpControlFrame1" src="javascript:'';"path_src="index.php?cmd=Y... | <p>Without seeing the code in question, I couldn't really say what's happening. Your example presumes that the code in question is server-side, and when a particular variable/condition is met, then the iframe is created or populated by blah.php. </p>
<p>You would have to ensure that the same code is called when creat... |
Click Once Setup.exe returns 404 with IIS <p>Whenever I try to install a Click Once application, I always get a 404 error from the setup.exe file. I've checked the physical folder the web server points to and confirmed that setup.exe exists at the correct location.</p>
<p>The CO deployment also works fine if I open th... | <p>Recording The Answer for myself so I can look it up later</p>
<p>In IIS, check to make sure that in the folder's Properties, Home Directory Tab, Application Settings section, that it is running Scripts Only and not Scripts and Executables.</p>
|
SQL Cluster - using datasource (local) <p>Using (local) in the connection string doesn't work on my cluster. I'm assuming it's looking for the default instance on the currently active node instead of the Virtual SQL name. Anyone know how to make this work? </p>
<p>edit note:
I'd like to use (local) and not localho... | <p>The names (local) or (.) will always use the shared memory interface, rather than TCP or Named Pipes, and neither can be used against a clustered instance which requires TCP or Named Pipes over TCP. You can't use the shared memory interface against a non-local instance, which in the case of a cluster, the instance m... |
Rails: FasterCSV - Unique Occurences <p>I have my CSV file imported as such:</p>
<pre><code>records = FasterCSV.read(path, :headers => true, :header_converters => :symbol)
</code></pre>
<p>How can I get the <strong>unique occurences</strong> of my data? For instance, here some sample data:</p>
<pre><code>ID,T... | <p>If your data is not <strong>masive</strong> you can use the <a href="http://www.ruby-doc.org/stdlib/libdoc/set/rdoc/index.html" rel="nofollow">Set</a> class.</p>
<p>Here's an example: </p>
<pre><code>p ['cnn','test','test','test','test','cnn','cnn'].to_set.to_a
=> ["cnn", "test"]
</code></pre>
<p>Here's a simp... |
Why is the with() construct not included in C#, when it is really cool in VB.NET? <p>I am C# developer. I really love the curly brace because I came from C, C++ and Java background. However, I also like the other programming languages of the .NET Family such as VB.NET. Switching back and forth between C# and VB.NET is... | <p>Personally I don't like WITH when it's used after construction - if you need to do several things with an object after it's initialized, usually that behaviour should be encapsulated in the type itself. If you really want to do something like WITH, it's only a matter of declaring a short variable and optionally intr... |
What are some good resources to look into synchronizing contact data on mobile devices with a .NET application? <p>Basically we want to be able to somehow synchronize our .NET application's contacts with the contacts on a mobile device (Pocket PC, iPhone, Blackberry, etc) Preferably a one shot deal that can interface ... | <p>There are API's going to/from .Net and gmail, perhaps you could use a central Google account as the conduit:</p>
<p><a href="http://code.google.com/apis/contacts/docs/2.0/developers_guide_dotnet.html" rel="nofollow">Google Account Developers Guide: .NET - Contacts</a></p>
<p>Then there are ways then to go from gMa... |
SQL Exclude LIKE items from table <p>I'm trying to figure out how to exclude items from a select statement from table A using an exclusion list from table B. The catch is that I'm excluding based on the prefix of a field.</p>
<p>So a field value maybe "FORD Muffler" and to exclude it from a basic query I would do:</p>... | <p>I think this will do it:</p>
<pre><code>SELECT FieldName
FROM TableName
LEFT JOIN TableName2 ON UPPER(ColumnName) LIKE TableName2.FieldName2 + '%'
WHERE TableName2.FieldName2 IS NULL
</code></pre>
|
Render PDF in iTextSharp from HTML with CSS <p>Any idea how to render a PDF using iTextSharp so that it renders the page using CSS. The css can either be embedded in the HTML or passed in separately, I don't really care, just want it to work. </p>
<p>Specific code examples would be <em>greatly</em> appreciated.</p>
... | <p>It's not possible right now but nothing stops you from starting open-source project that will do it. I might actually start one, because I need it too!</p>
<p>Basically you will need parser that will convert html and css markup into iTextSharp classes. So <code><table></code> becames <code>iTextSharp.SimpleTa... |
How does Microsoft's Entity Framework inhibit test driven development? <p>MS's entity framework is considered among developers in the agile community to inhibit test driven development. It was <a href="http://efvote.wufoo.com/forms/ado-net-entity-framework-vote-of-no-confidence/" rel="nofollow">famously attacked</a> b... | <p>It's because it has no mocks - it encourages you to base your app around objects that directly ping the database, with no way to simulate it. One of the primary tenets of agile development is that tests are <em>fast</em>, so that running them is painless and you can continually be testing your code, but with EF, you... |
How to you inspect or look for .NET attributes? <p>I have an enumeration for Status for a Task. Some of the statuses are considered obsolete, and I have marked them as obsolete, as seen below:</p>
<pre><code>public enum TaskStatus
{
[Description("")]
NotSet = 0,
Pending = 1,
Ready = 2,
Open = 3,
... | <p>You could write a LINQ-query:</p>
<pre><code>var availableTaks = typeof (TaskStatus).GetFields(BindingFlags.Static | BindingFlags.GetField | BindingFlags.Public)
.Where(f => f.GetCustomAttributes(typeof (ObsoleteAttribute), false).Length == 0);
foreach(var task in availableTaks)
Console.WriteLine(task);
... |
Need a basic audio & video player library in Java <p>I need to display a series of images (perhaps BufferedImages) with variable frame rates as a video, synchronized with uncompressed audio. I also need the basic media controls of play, pause, seek, audio volume, etc.</p>
<p>Since I don't need to encode, decode, read ... | <p>I don't know if this is what you're looking for, but have you looked at Quicktime for Java here: <a href="http://developer.apple.com/quicktime/qtjava/index.html" rel="nofollow">http://developer.apple.com/quicktime/qtjava/index.html</a></p>
<p>It says, "QuickTime for Java provides a set of cross-platform APIs which ... |
Open Source HTML to PDF Renderer with Full CSS Support <p>I asked about getting iTextSharp to render a PDF from HTML and a CSS sheet before <a href="http://stackoverflow.com/questions/430280/render-pdf-in-itextsharp-from-html-with-css">here</a> but it seems like that may not be possible... So I guess I will have to tr... | <p>This command line tool is the business!
<a href="http://code.google.com/p/wkhtmltopdf">http://code.google.com/p/wkhtmltopdf</a></p>
<p>It uses webkit rendering engine(used in safari and KDE), I tested it on some complex sites and it was by far better than any other tool. </p>
|
PHP/Apache blocking on each request? <p>Ok, this may be a dumb question but here goes. I noticed something the other day when I was playing around with different HTML to PDF converters in PHP. One I tried (dompdf) took forever to run on my HTML. Eventually it ran out of memory and ended but while it was still runnin... | <p>did you had open sessions for each of the scripts?:) they might reuse the same sesion and that blocks until the session is freed by the last request...so they basically wait for each other to complete(in your case the long-running pdf generator). This only applies if you use the same browser.</p>
<p>Tip, not sure w... |
Prevent mutually recursive execution of triggers? <p>Suppose you have the tables <code>Presentations</code> and <code>Events</code>. When a presentation is saved and contains basic event information, such as location and date, an event will be created automatically using a trigger. (I'm afraid it's impossible for techn... | <p>I'm not sure about doing it per transaction, but do you need nested triggers switched on for other parts? If you switch them off on the server then a trigger won't fire from another trigger updating a table.</p>
<p>EDIT (answer from the comments): <strong>You will need to alter trigger A to use <a href="http://msdn... |
How to query (LINQ) multiple table association link? <p>I have tables association such as (CaseClient is a bridge table):</p>
<ul>
<li>Cases has many CaseClients</li>
<li>Client has many CaseClients</li>
<li>ClientType has many CaseClient</li>
</ul>
<p>The easiest way just use the view in database but I heard that wi... | <p>I think you want to use the Join method, from your bridging table and resolving each of your relationships. E.g.</p>
<pre><code>// Where CaseId and TypeId are your members of CaseClient
var x = caseClients.Join( cases, cc => cc.CaseId, c => c.Id)
.Join( types, cc => cc.Type... |
Linux system to manage configurations of servers? <p>I need a software to manage configurations of linux servers in one central location. It should be able to push changes to servers automaticly. Version control would be an advantage...</p>
| <p>I've heard good things about <a href="http://reductivelabs.com/trac/puppet/" rel="nofollow">Puppet</a> (as <a href="http://stackoverflow.com/users/23896/matli">matli</a> suggested) and <a href="http://en.wikipedia.org/wiki/Cfengine" rel="nofollow">Cfengine</a>, which are both listed at <a href="http://en.wikipedia.o... |
What is the significance of trailing slashes in a namespace URI? <p>I have been studying SOAP and WSDL in preparation for implementing a web service. One thing that I have encountered that puzzles me is that some of the URIs that I have seen use a trailing slash such as:</p>
<pre><code>http://www.w3.org/some-namespac... | <p><strong>Yes, the w3c guidelines regarding URI's you have read are correct</strong>. </p>
<p><strong>The two namespaces having not equal-strings-uri's are different namespaces. Even capitalization and white-space matters</strong>. </p>
<p>A namespace-uri does not mean that issuing a request for it should produce a ... |
Is there an open source C visual debugger for windows? <p>Is there an open source C visual debugger for windows?
I have heard about the visual C++ express free edition, but does it have a visual debugger?</p>
<p>Thanks.</p>
| <p>It's not open source (but then does it really need to be?) <a href="http://www.microsoft.com/express/vc/" rel="nofollow">Visual C++ 2008 Express Edition</a> is an IDE with an integrated debugger.</p>
<p>You can create a C++ project, delete the .cpp files and create/include your .c files.</p>
|
Domain Driven Design question <p>I would like to ask for a reccomended solution for this:
We have a list of Competitions.
Each competition has defined fee that a participatior has to pay
We have Participators
I have to know has a Participator that is on a Competition paid the fee or not. I am thinking about 2 so... | <p>sounds like a typical many to many relationship. i would model it with an Entry association class as follows:</p>
<pre><code>class Participator {
}
class Competition {
Currency fee
}
class Entry {
Competition competition
Participator participator
Boolean feePaid
}
</code></pre>
|
C# Reflection: Getting the fields of a DataRow from a Typed DataSet <p>I am currently building a method that takes an object that is of type <code>DataRow</code> from a typed DataSet, and then returning a string in <a href="http://en.wikipedia.org/wiki/Json" rel="nofollow">JSON</a> format of the fields in the DataRow (... | <p>Why don't you use <code>row.Table.Columns</code> property instead of reflection?</p>
|
Better way of returning the values of a column in Active Record? <p>Quick one, but thought I'd ask.</p>
<p>Is there a better way of getting the column values from a model's column than something like this?</p>
<pre><code>Item.count(:all, :group => 'status').reject! { |i, e| i.blank? }.collect { |i,e| i}
</code></p... | <pre><code>Item.find(:all, :select=>:status, :group => 'status', :conditions => "status != ''").collect{|r| r.status}
</code></pre>
|
Unexpected T_CLONE using Math_Matrix PEAR library <p>I've not used PEAR before, and so I'm probably doing something dumb. I've installed the Math_Matrix library, but when I include it I just get an error. My entire code is this:</p>
<pre><code><?php
$path = '/home/PEAR/Math_Matrix-0.8.0';
set_include_path(get_i... | <p>From the Math_Matrix I can see that it was last updated in 2003. Since then, PHP has added the <a href="http://www.php.net/clone" rel="nofollow"><code>clone</code> keyword</a>, which is conflicting with the <code>clone()</code> function defined in Matrix.php.</p>
<p>You need to update Matrix.php - a search & r... |
Flash upload image resize client side <p>Does anyone got an ideia on how to get client side image resize using flash.</p>
<p>Example:
Client chooses an image with 1200x800 and before it uploads it flash will turn it into half of it or something.</p>
<p>Any thoughts?</p>
| <p>Plupload is Opensource, has good documentation and supports multiple platforms, including Gears and HTML5!</p>
<p><a href="http://www.plupload.com/index.php">http://www.plupload.com/index.php</a><br>
<a href="http://www.plupload.com/example_all_runtimes.php">http://www.plupload.com/example_all_runtimes.php</a></p>
... |
Weird Behavior when using between? method for dates <p>Open up a Rails console and enter this:</p>
<pre><code>2.weeks.ago.between? 2.weeks.ago, 1.week.ago
</code></pre>
<p>Did it give you true or false? No really, try it a few more times and it will give you different answers.</p>
<p>Now, I'm thinking that because w... | <p>The cause is undoubtedly due to the resolution of the time function. Sometimes the two instances of 2.weeks.ago resolve to the same time and sometimes they don't. When you use yesterday you don't see the issue because it always resolves to zero hour instead of relative to the current time.</p>
<p>In a case like y... |
window border width and height in Win32 - how do I get it? <pre>
::GetSystemMetrics (SM_CYBORDER)
</pre>
<p>...comes back with 1 and I know the title bar is taller than ONE pixel :/</p>
<p>I also tried:</p>
<pre>
RECT r;
r.left = r.top = 0; r.right = r.bottom = 400;
::AdjustWindowRect (& r, ... | <p>The <a href="http://msdn.microsoft.com/en-us/library/ms633519(VS.85).aspx" rel="nofollow">GetWindowRect</a> and <a href="http://msdn.microsoft.com/en-us/library/ms633503(VS.85).aspx" rel="nofollow">GetClientRect</a> functions can be used calculate the size of all the window borders.</p>
<p>Suite101 has a article on... |
ASP.net: Display PDF in a asp.net web page <p>User click on a link button and it will direct them to a url that is dynmaically generated which a pdf file. The browser will prompt the user to either save or open it.</p>
<p>I want to know if it is possible to downlaod the pdf file to the server then show the pdf file in... | <p>I use <a href="http://sourceforge.net/projects/itextsharp/" rel="nofollow">itextsharp</a>, its a free open source c# port of the java itext library. </p>
<p>Makes generating dynamic pdfs in asp.net a breeze and there is lots of documentation/examples floating around.</p>
|
Storing Images to use in application <p>I would like to store some images to use in my C# application. They are png files and are currently in a folder with the dlls. Ideally I would like to have them included with the dll so i dont have to include the actual images with the installation. </p>
<p>What is the best w... | <p>The easiest is to just add them to your current project and then set their Build Action property to Embedded. I believe that automatically adds them to a resource file and then you can access them using reflection.</p>
<p>Here's an article on retrieving them:</p>
<p><a href="http://msdn.microsoft.com/en-us/library... |
How to render decoded HTML in a (i.e. a <br>) in GridView cell <p>I'm binding a GridView to an LINQ query. Some of the fields in the objects created by the LINQ statement are strings, and need to contain new lines.</p>
<p>Apparently, GridView HTML-encodes everything in each cell, so I can't insert a <br /> to cr... | <p>What about setting the <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.htmlencode.aspx"><code>HtmlEncode</code> property</a> to <code>false</code>? To me, this is much simpler.</p>
<pre class="lang-asp prettyprint-override"><code><asp:BoundField DataField="MyColumn" HtmlEnco... |
Is possible send a array in Obj-c for a variable arguments function? <p>In python it is easy to build a dictionary or array and pass it unpacked to a function with variable parameters</p>
<p>I have this:</p>
<pre><code>- (BOOL) executeUpdate:(NSString*)sql, ... {
</code></pre>
<p>And the manual way is this:</p>
<pr... | <p>Unfortunately, no. Objective-C doesn't have argument unpacking like you get in a lot of modern languages. There isn't even a good way to work around it that I've ever found.</p>
<p>Part of the problem is that Objective-C is essentially just C. It does multiple argument passing with C varargs, and there's no simple ... |
How to set default WPF Window Style in app.xaml? <p>I am trying to set the default Style for every window in my WPF Windows application in my app.xaml. So far i have this in app.xaml:</p>
<pre><code><Application.Resources>
<ResourceDictionary>
<Style x:Key="WindowStyle" TargetType="{x:Type W... | <p>To add on to what Ray says: </p>
<p>For the Styles, you either need to supply a Key/ID or specify a TargetType. </p>
<blockquote>
<p>If a FrameworkElement does not have an
explicitly specified Style, it will
always look for a Style resource,
using its own type as the key<br />
- Programming WPF (Sells, G... |
What is Google Apps? <p>What is google apps and why are so many startup companies using it?</p>
| <p><a href="http://www.google.com/apps/intl/en/business/index.html">Google Apps</a> is a collection of business software components delivered as a service, saving you from having to install Exchange, Office and the usual business stuff. Plus Google Apps allows people to write their own apps and install them on Google'... |
3D Polygons in Python <p>As far as I am aware there is no inbuilt polygon functionality for Python. I want to create a 3D map and figured that polygons would be the best way to go about it.</p>
<p>Not wanting to reinvent the wheel I did some googling and found that there's a lot of Python stuff out there, but I couldn... | <p>One of the most complete geography/mapping systems available for Python that I know about is <a href="http://geodjango.org/" rel="nofollow">GeoDjango</a>. This works on top of the <a href="http://www.djangoproject.com/" rel="nofollow">Django</a>, an MVC framework. With it comes a large collection of polygon, line ... |
Correct use of Lambda query <p>Consider the following code:</p>
<pre><code> private static void WriteProcesses(StreamWriter sw, DateTime d) {
sw.WriteLine("List of processes @ " + d.ToString());
Process[] localAll = Process.GetProcesses().Where(o => o.ProcessName.ToLower() != "svchost"... | <p>Change</p>
<pre><code>Process[] localAll = Process.GetProcesses().Where(o => o.ProcessName.ToLower() != "svchost");
</code></pre>
<p>to</p>
<pre><code>Process[] localAll = Process.GetProcesses().Where(o => o.ProcessName.ToLower() != "svchost").ToArray();
</code></pre>
<p><code>Where</code> is returning an ... |
Dynamic Proxy generation with LinFu <p>I am trying to build a dynamic proxy for an interface with LinFu. The proxy should just implement the getter methods of the properties that are defined by the interface and return for instance a value from a dictionary, where the key is the property name.</p>
<p><a href="http://c... | <p>Try:</p>
<pre><code>// The interceptor class must implement the IInterceptor interface
var yourInterceptor = new YourInterceptor();
var proxyFactory = new ProxyFactory();
IYourInterface proxy = proxyFactory.CreateProxy<IYourInterface>(yourInterceptor);
// Do something useful with the proxy here...
</code></pr... |
How to make sure redundant data is deleted in a many-to-many relationship <p>I'm trying to make sure some data is auto-deleted when there's no more references using cascade deletes. I'll explain with a <em>fake</em> database based on Stack Overflow.</p>
<p>I have a <code>Post</code> table. Each post has zero to many T... | <p>Unfortunately, you won't be able to use cascades here. Cascades don't work when you have a many-to-many relationships because you won't have a singular parent that references the child (in this case, you have multiple PostTags entries which could reference the Tags table).</p>
<p>Triggers would be a way to do this... |
Why can I assign an existing reference to a literal value in C++? <p>Consider the following:</p>
<pre><code>int ival = 1.01;
int &rval = 1.01; // error: non-const reference to a const value.
int &rval = ival;
rval = 1.01;
</code></pre>
<p>The first assignment of &rval to a literal value fails as expected... | <p><code>ival</code> isn't a literal value, <code>1.01</code> is the literal value. It's been copied to <code>ival</code> which is a variable, which most definitely can have it's references assigned to another variable.</p>
|
Data Modeling: What is a good relational design when a table has several foreign key constrainst to a single table? <p>I have 2 tables:
1. Employees
2. Vouchers</p>
<p>Employees table has a single primary key.
Vouchers table has 3 foreign key constraints referencing the Employees table.</p>
<p>The following is a sam... | <p>Strictly from a relational design point of view, the Vouchers table as three Foreign Keys. Whether you choose to enforce them, through CASCADE assertions or otherwise, is an implementation issue, but the relational design still exists. Presumably you want to enforce that, if one of the three fields is not NULL, then... |
As our favorite imperative languages gain functional constructs, should loops be considered a code smell? <p>In allusion to Dare Obasanjo's impressions on Map, Reduce, Filter (<a href="http://www.25hoursaday.com/weblog/2008/06/16/FunctionalProgrammingInC30HowMapReduceFilterCanRockYourWorld.aspx" rel="nofollow">Function... | <p><em>Let us change our traditional attitude to the construction of programs: Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do.</em></p>
<p>â Donald Knuth</p>
|
System Views text in SQL Server 2005 <p>I am looking for viewing the text of the system views and procedures in SQL Server 2005 using the object explorer or using sp_helptext.</p>
<p>actually i am coming from the SQL Server 2000 background, where we have the feature of retreiving the code of the view and the stored pr... | <p>Do you have access to SQL Server Management Studio? It is now sys.sp_helptext and can be browsed at master --> Programmability --> Stored Procedures --> System Stored Procedures in the object browser and executed with</p>
<pre><code>exec sys.sp_helptext ObjectName
</code></pre>
<p>All the information you are looki... |
What's the best way to save a one-to-many relationship in Linq2Sql? <p>I'm trying to figure out the best way to save a simple one-to-many relationship in Linq2Sql.</p>
<p>Lets assume we have the following POCO model (pseduo code btw):</p>
<p><em>Person has zero to many Vechicles.</em></p>
<pre><code>class Person
{
... | <pre><code>using (Db db = new Db())
{
var newPerson = db.People.SingleOrDefault(p => p.Id == person.Id) ?? new SqlContext.Person();
// Left to right stuff.
newPerson.Name = person.Name;
newPerson.Age = person.Age;
// add vehicles.
Vehicle firstV = new Vehicle();
firstV.Name = "some name"... |
Is there a O(1) way in windows api to concatenate 2 files? <p>Is there a O(1) way in windows API to concatenate 2 files?</p>
<p>O(1) with respect to not having to read in the entire second file and write it out to the file you want to append to. So as opposed to O(n) bytes processed. </p>
<p>I think this should be ... | <p>If the "new file" is only going to be read by your application, then you can get away without actually concatenating them on disk.</p>
<p>You can just implement a stream interface that behaves as if the two files have been concatenated, and then use that stream as opposed to what ever the default filestream impleme... |
Animate a StackPanel when the property Visibility changes <p>In WPF 3.5 (with SP1), I have simply <strong>StackPanel that I would like to animate when I change the property Visibility</strong>. I have no idea of the height of this StackPanel since its content determines its height. So when I change the property of my S... | <p>You can create and reuse custom StackPanel style that triggers animation when Visibility changes:</p>
<pre><code><Style x:Key="MyStyle" TargetType="{x:Type StackPanel}">
<Style.Triggers>
<Trigger Property="Visibility" Value="Visible">
<Trigger.EnterActions>
... |
How to get a user token from Logonuser for a user account with no password? <p>How can you get a user token from Logonuser for a user account with no password?</p>
<p>In particular Logonuser will fail for accounts that do not have passwords.<br />
You can validate an account by checking for a blank password + checking... | <p>This will fail if the registry setting LimitBlankPasswordUse is enabled, which it is by default. In order to disable this change the LimitBlankPasswordUse value under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa to zero. Or change the group policy setting under Security Options. </p>
<p>Be aware that thi... |
Naming: What would you call a rich API that wraps around a thin API <p>I have a "thin" (SOAP) API that only knows how to set and get entities in the underlying system.</p>
<p>I am about to to create a "rich" API that encapsulates the "thin" API and implements the logic that is required for complex operations that enta... | <p>Isn't the point of an API that it hides it's implementation? As such, the fact that your API calls a thinner API is irrelevant. Name your API appropriately for what it does, regardless of how it does it.</p>
|
Writing custom IEnumerator<T> with iterators <p>How can I write a custom <code>IEnumerator<T></code> implementation which needs to maintain some state and still get to use iterator blocks to simplify it? The best I can come up with is something like this:</p>
<pre><code>public class MyEnumerator<T> : IEnum... | <p>Why do you want to write an iterator class? The whole point of an iterator block is so you don't have to...</p>
<p>i.e.</p>
<pre><code>public IEnumerator<T> GetEnumerator() {
int position = 0; // state
while(whatever) {
position++;
yield return ...something...;
}
}
</code></pre>
... |
System.Net's Webclient in C# won't connect to server <p>Is there something I need to do to get System.Net working with Microsoft Visual C# 2008 Express Edition? I can't seem to get any web type controls or classes to work at all.. the below WebClient example always throws the exception "<strong>Unable to connect to the... | <p>(<strong>update</strong> - I meant <code>proxycfg</code>, not <code>httpcfg</code>; <code>proxycfg -u</code> will do the import)</p>
<p>First, there is nothing special about "express" here. Second, contoso is a dummy url.</p>
<p>What OS are you on? And do you go through a proxy server? If so, you might need to con... |
How can I call an executable to run on a separate machine within a program on my own machine (win xp)? <p>My objective is to write a program which will call another executable on a separate computer(all with win xp) with parameters determined at run-time, then repeat for several more computers, and then collect the res... | <p>You can use PsExec for this:</p>
<p><a href="http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx" rel="nofollow">http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx</a></p>
<p>You could also look at the open source alternative RemCom:</p>
<p><a href="http://rce.sourceforge.net/" rel="nofollow"... |
Bi-Directionnal Replication With SQL Server <p>Is there a way to make a bi-directionnal Replication with SQL Server ?</p>
<p>(BDD 1) Table 1 <=> (BDD 2) Table 1</p>
<p>Thanks.</p>
| <p>There are a few solutions that might suit your need. </p>
<ol>
<li><a href="http://msdn.microsoft.com/en-us/library/ms151329.aspx" rel="nofollow">Merge replication</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/ms151196.aspx" rel="nofollow">Peer to peer transactional replication</a></li>
<li><a href=... |
Hyperlinks within "about" text for iphone application <p>I'm on the final stretch of my first simple iPhone application. I'm building an "about" view, with credits/info/etc.</p>
<p>I am failing on the simplest thing: how can I embed hyperlinks into the text? I'm current using a UIView with a UILabel for the text.</p>
... | <p>Yep, use a UIWebView and put static HTML in it.</p>
<p>Like so:</p>
<pre><code>[myWebView loadHTMLString:@"<html><head></head><body style=\"font-family: sans-serif;\"> .... </body></html>" baseURL:nil];
</code></pre>
|
Automatic .toString() when calling a method? <p>I got the code of a former employee. There are many calls to methods like:</p>
<pre><code>foo(val,...);
</code></pre>
<p>where </p>
<pre><code>void foo(String s,...) {
...
}
</code></pre>
<p>and val is an int.</p>
<p>Of course, I get an error.</p>
<p>As a workarou... | <p>depending on the different types that are supposed to be passed as parameter, you could either accept an object and call .toString()</p>
<pre><code>void foo(Object o){
String s=o.toString();
...
}
</code></pre>
<p>or overload foo for specific types</p>
<pre><code>void foo(String s) {
...
}
void foo(int i... |
Recommendations of a high volume log event viewer in a Java enviroment <p>I am in a situation where I would like to accept a LOT of log events controlled by me - notably the logging agent I am preparing for slf4j - and then analyze them interactively.</p>
<p>I am not as such interested in a facility that presents form... | <p>You might implement a adapter for logback to send log4j events to a log4j receiver. This would enable you to use chainsaw. Or build an adapter which receives logback network events and exposes them for log4j.</p>
|
QNX c++ thread question <p>I have a question concerning this code which I want to run on QNX:</p>
<pre><code>class ConcreteThread : public Thread
{
public:
ConcreteThread(int test)
{
testNumber = test;
}
void *start_routine()
{
for(int i = 0; i < 10; i++)
{
sleep(1);
... | <p>Note 1: If you only have 1 processor the code can only be done sequentially no matter how many threads you create. Each thread is given a slice of processor time before it is swapped out for the next threads.</p>
<p>Note 2: If the main thread exits pthreads will kill all child threads before they have a chance to e... |
Paletted textures with 8-bit alpha channel in OpenGL ES <p>Can I get paletted textures with RGB palette and 8-bit alpha channel in OpenGLÂ ES? (I am targetting the iPhone OpenGL ES implementation.) After peeking into the OpenGL documentation it seems to me that there is support for paletted textures with alpha in the p... | <p>No. In general, graphics chips really don't like palletized textures (why? because reading any texel from it requires two memory reads, one of the index and another into the palette. Double the latency of a normal read).</p>
<p>If you're only after saving memory, then look into compressed texture formats. In iPhone... |
Fluent interfaces and leaky abstractions <p>What is a fluent interface? I can't find a good definition of this, but all I get are long code examples in a language I am not very familiar with (e.g. C++).</p>
<p>Also, what is a leaky abstraction?</p>
<p>Thanks</p>
| <p>A fluent interface is an API that allows you to write code that reads more or less like normal English. For example:</p>
<pre><code>Find.All.Questions(Where.IsAnswered == true);
</code></pre>
<p>Method-chaining is usually used as part of the implementation, but there is more to it than that. To quote <a href="http... |
Lookup Tables Best Practices: DB Tables... or Enumerations <p>If we have to store the available positions at a company (i.e. Manager, Team Lead, ... etc). What are the best practices for storing it? I have two opinions with comments... "sure, welcoming yours"<br/>
<b></p>
<ol>
<li>Storing it as DB table with colum... | <p>Generally you should only use enumeration where the is a clear set of items that will not change. Male/Female is a good example, otherwise lookup tables, with appropriately implemented foreign keys are pretty much always the best option.</p>
<p>There is a possible variation on the lookup table option where you pot... |
Entity Framework query with grouping (many to many) <p>I have a classical many to many scenario with three tables (students, courses, and third StudentsCourses assignment table).</p>
<p>I'm using EF in my new project and EF designer doesn't create third table.
I need to select all cources along with number of students... | <p>The EF designer hides the table. It's still there, but it just creates the assocation for you, so you can just reference students from courses or vice versa.</p>
|
Is WPF production ready? <p>I'm wondering if there are people out there with experience of WPF application development - and maybe more interesting - running WPF in production.</p>
<p>Is it mature enough to use in larger projects? What are the obvious pitfalls? Any best practices? (Databinding in WPF seems pretty nift... | <p>WPF came out with .NET 3.0. We're on 3.5 sp1, so if its not production ready MS has got a lot of essplainin' to do. Frankly, it was production ready when 3.0 came out.</p>
<p>I'm currently working on a project that uses WPF for templating and databinding (not for UI display, but I use UI classes to define templat... |
Where do you download Linux source code? <p>Say I'm interested in the source for one particular Linux utility, like <code>factor</code>. Where can I find the source code for that utility?</p>
| <p>You can also find out which package the binary comes from an download that packages source code.</p>
<p>On Debian (and Ubuntu and anything else that's based on Debian) you do that like this:</p>
<pre>
$ dpkg -S /usr/bin/factor
coreutils: /usr/bin/factor
$ apt-get source coreutils
</pre>
<p>The first command will ... |
Segfault from adding a variable <p>I'm admittedly a straight-C newbie, but this has got me stumped. I'm working on a linked list implementation for practice, and I'm getting a segfault by simply adding a variable to the split_node function:</p>
<pre><code>#include <stdio.h>
#include <string.h>
#include <... | <p>You need to dynamically allocate your nodes (using malloc).</p>
<p>As you have it, your new node is declared on the stack. When the split function returns, that new node is no longer valid memory.</p>
<p>Adding a variable causes a segfault because that variable changes the layout of the stack causing slightly dif... |
Two basic C++ questions about string literals and dynamic allocation <p>Are these two equivalent?</p>
<p>char * aString = "This is a string.";</p>
<p>char aString[] = "This is a string.";</p>
<p>From my understanding, C++ stores strings by their addresses, so the pointer is getting a valid address. I assume the stri... | <pre><code>char * aString = "This is a string.";
</code></pre>
<p>It's making a pointer <code>aString</code> point to a statically allocated char array containing <code>"This is a string."</code>. The string is <em>not</em> writable, even though the type of the pointer might suggest you could write to it. See the answ... |
Rails: how do you access RESTful helpers? <p>I'm trying to work through this <a href="http://guides.rubyonrails.org/routing_outside_in.html">guide to Rails routing</a>, but I got stuck in section <a href="http://guides.rubyonrails.org/routing_outside_in.html#_urls_and_paths">3.3</a>:</p>
<blockquote>
<p>Creating a R... | <p>You have several questions in there, most of which have already been answered by people below.</p>
<p>The answer to one that wasn't fully addressed however, is: yes you can use the script/console to see where your routes go. Just type in <code>app.[route_helper]</code> and it will respond with the path. For example... |
Mongrel hangs <p>I'm running into a problem in a Rails application.
After some hours, the application seems to start hanging, and I wasn't able to find where the problem was. There was nothing relevant in the log files, but when I tried to get the url from a browser nothing happened (like mongrel accept the request bu... | <p>I might get voted down for dodging the question, but I recently moved from nginx + mongrel to mod_rails and have been really impressed. Moving to a much simpler setup will undoubtedly save me headaches in the future. </p>
<p>It was a really easy transition, I'd highly recommend it.</p>
|
mysql select - how to retrieve a result for threaded/nested messages? <p>I'm creating a threaded message board and I'm trying to keep it simple. There's a message table, and then a replies table that has an 'reply_id' field that can be null to indicate a top level response, or a value that indicates a threaded respons... | <p>You're using the naive "textbook" way of storing trees, i.e. store a reference to the immediate parent. This design is called <strong>Adjacency List</strong>. There are other solutions:</p>
<ul>
<li><strong>Path Enumeration</strong>, where you store in each node of the tree a string encoding all its direct ancest... |
Array of structs and new / delete <p>I have a struct like this:</p>
<pre><code>class Items
{
private:
struct item
{
unsigned int a, b, c;
};
item* items[MAX_ITEMS];
}
</code></pre>
<p>Say I wanted to 'delete' an item, like so:</p>
<pre><code>items[5] = NULL;
</code></pre>
<p>And I created a... | <p>You need to call <code>delete</code> before setting it to NULL. (Setting it to NULL isn't required, it just helps reduce bugs if you accidentally try to dereference the pointer after deleting it.)</p>
<p>Remember that every time you use <code>new</code>, you will need to use <code>delete</code> later on the same po... |
How to reverse a Unicode string <p>It was hinted in a <a href="http://stackoverflow.com/questions/433525/choosing-asp-net-over-php-or-perl#433610">comment to an answer to this question</a> that PHP can not reverse Unicode strings. </p>
<blockquote>
<p>As for Unicode, it works in PHP
because most apps process it as... | <p>here's another approach using regex:</p>
<pre><code>function utf8_strrev($str){
preg_match_all('/./us', $str, $ar);
return implode(array_reverse($ar[0]));
}
</code></pre>
|
Extending XHTML <p>I'm playing around with writing a jQuery plugin that uses an attribute to define form validation behavior (yes, I'm aware there's already a validation plugin; this is as much a learning exercise as something I'll be using). Ideally, I'd like to have something like this:</p>
<p>Example 1 - input:</p>... | <p>If you want the result to be valid XHTML, I believe you'll need to use <a href="http://www.w3.org/TR/xml-names11" rel="nofollow">XML namespaces</a> rather than a custom DTD. Not only does the DTD <em>define</em> the language (and thus, a custom DTD isn't "really" XHTML), but it will throw any browsers that read it ... |
In LINQ to SQL, how do you pass parts of a LINQ query into a function <p>Is it possible to pass parts of a linq Query into a function?
I want create a common interface for my DAL that always uses the same query interface. For example, </p>
<pre><code>List<T> Get(Join j, Where w, Select s){
return curr... | <p>Well, the "join" is tricky, because it is very hard to express a join - but things like where / select / orderby are pretty easy...</p>
<p>Really, it is just a case of combining the various LINQ methods on <code>IQueryable<T></code>, which generally accept <code>Expression<Func<...>></code> for so... |
For Python support, what company would be best to get hosting from? <p>I want to be able to run WSGI apps but my current hosting restricts it. Does anybody know a company that can accommodate my requirements?</p>
| <p>My automatic response would be <a href="http://www.webfaction.com/">WebFaction</a>. </p>
<p>I haven't personally hosted with them, but they are primarily Python-oriented (founded by the guy who wrote CherryPy, for example, and as far as I know they were the first to roll out <a href="http://blog.webfaction.com/pyt... |
Should I create a interface and mock this class <p>I have this class called Table:</p>
<pre><code>class Table
{
public string Name
{
get
{
return this.wrapper.Eval(//some command);
//wrapper is pass in by the ctor and is a COM object.
}
}
}
</code></pre>
<p... | <p>Beyond the fact that there is usually no <em>one</em> perfect testing solution, I'd first go for mocking the COM object: there should be a interface available and you'll probably want to test everything "above" it.</p>
<p>If the <code>Table</code> contains non-trivial code (e.g. within the <code>Eval()</code>; anyt... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.