input
stringlengths
51
42.3k
output
stringlengths
18
55k
Implementing ESB (Enterprise Service Bus) in a functional language <p>I am hoping that an architecture question is reasonable on Stackoverflow, so I am asking this here.</p> <p>I have been trying to see where a functional language would be useful outside of math-oriented problems, and it dawned on me that an ESB (Ente...
<p>Hard to say anything more insightful than "yes, you're right." The first production uses of Clojure are exactly that.</p>
Receiving chunked data from a Socket to a single buffer <p>I'm trying to write a simple SNPP (Simple Network Paging Protocol) client using sockets. Everything seems to be working well, except for a small inconsistency between servers.</p> <p>When I send a command, I need to read the reply, which is usually a single ch...
<p>For chunked responses I would recommend you reading data like this:</p> <pre><code>using (var resultStream = new MemoryStream()) { const int CHUNK_SIZE = 2 * 1024; // 2KB, could be anything that fits your needs byte[] buffer = new byte[CHUNK_SIZE]; int bytesReceived; while ((bytesReceived = socket.R...
How do you force a makefile to rebuild a target <p>I have a makefile that builds and then calls another makefile. Since this makefile calls more makefiles that does the work it doesnt really change. Thus it keeps thinking the project is built and upto date. </p> <pre><code>dnetdev11 ~ # make make: `release' is up to d...
<p>The <code>-B</code> switch to make, whose long form is <code>--always-make</code>, tells <code>make</code> to disregard timestamps and make the specified targets. This may defeat the purpose of using make, but it may be what you need.</p>
Simple iterator looping gives unexpected result <p>I am sure it's an obvious error with my logic, but I can't seem to work out what I am doing wrong. Quite simply I have an array list of security codes, I want to compute the correlation between each combination of security codes. My code is as follows:</p> <pre><code>...
<p>A quick test application having removed references to code we don't know about works fine for me.</p> <p>Is it possible that something's throwing an unchecked exception which you're not handling? If you could post a short but <em>complete</em> program demonstrating the problem, that would help immensely. Take a cop...
Which Java HTML templating technology works in a way that is closest to Ruby (erb/haml)? <p>Among the Java <a href="http://en.wikipedia.org/wiki/Template%5Fengine%5F%28web%29" rel="nofollow">templating solutions</a> such as Apache Velocity, Freemarker, Hamlets, Tapestry, StringTemplate, JSP, JSP Weaver (others?) which ...
<p>The practice of mixing code and data is frowned upon in Java much more so than in Ruby. The recommended Java practice is to use taglibs instead of code blocks. I mention this only because if you write your Java templates in the same way as typical Ruby templates, other Java developers (I'm assuming you work on a tea...
Problems in dynamically generating an Image in silverlight <p>I am dynamically adding an image to a canvas object which was working for a while and suddenly stopped displaying for some particular reason.</p> <p>Here is the code :</p> <pre><code>public void shootProjectile() { var projectileImage = new Image(); ...
<p>If you have the image build type set to Resource, then try removing the leading '/' from the image URI.</p>
When is it appropriate to use NOLOCK? <p>I am having timeout issues and deadlocks from time to time with some long running queries.</p> <p>I'm wondering when is it most appropriate to use NOLOCK and where?</p> <p>Do I use it on the updates &amp; inserts? or reads?</p>
<p>Note that you can specify nolock on a per table basis.</p> <p>I typically used nolock in complex SELECT queries, but only for the little lookup tables that almost never changed, and for display-only data. You know the tables that list the prices for the current half year, or lookups of ids to strings etc. Stuff th...
C# - ListBox DataSource property and binding an ArrayList <p>I created an ArrayList which contains KeyValuePair&lt;string, string&gt; objects. There are ListBoxes which I would like to bind to that list so that I do not have to fill them by iteration, copying at the same time all the data I have in the above mentioned ...
<p>.NET list boxes have this functionality built in. You've already set the <code>DataSource</code> property, so to display just the keys in the list, set:</p> <pre><code>listBox.DisplayMember = "Key"; </code></pre>
What's the best way to use Obj-C 2.0 Properties with mutable objects, such as NSMutableArray? <p>I have an Obj-C 2.0 class that has an NSMutableArray property. If I use the following code, then the synthesised setter will give me an immutable copy, not a mutable one:</p> <pre><code>@property (readwrite, copy) NSMutabl...
<p>I ran into the same problem some time ago and found a <a href="http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocProperties.html#//apple%5Fref/doc/uid/TP30001163-CH17-SW17">document on the Apple Developer Connection</a> recommending to provide your own implementation of t...
Implementing a 4-heap using an array <p>What kind of math do you use to traverse the 4-heap when using an array to store all the elements? Specifically, how do you find the index of a parent node to a specific leaf?</p> <p>Let's say I have the following array:</p> <p>0|1|2|3|4|5|6|7|8|9|10|... etc.</p> <p>with the h...
<p>First a simple observation. Root is at <em>1</em>, so all children begin at <em>2</em>. Before index <em>i</em> there are <em>i-1</em> vertices (remember, index 0 is not a vertex!) in the heap, each has 4 children exactly. So <em>i</em><sup>th</sup> children will be at <em>2+4*(i-1)</em> to <em>2+4*i-1</em> for exam...
Is WPF an ECMA standard library? <p>Is WPF an ECMA standard library? Or it is just a part of MS .net implementation? Any references please?</p>
<p>it is not.</p> <p>the C# and CLR is ECMA, but WPF is not.</p> <p>In more detail, BCL is ECMA but FCL is not.</p> <p>WPF &amp; WinForms should be FCL.</p>
Append git's branch name to command prompt <p>I wanted to use one of the Git-completion.bash features but I can't customize the look I'd like to have. Here is relevant part of my .bash_profile:</p> <pre><code>source ~/.git-completion.bash function prompt { local WHITE="\[\033[1;37m\]" local GREEN="\[\033[0;32m\]" loc...
<p>The trick to get the quoting right is to have eveything double-quoted, except for <code>$(__git_ps1 "(%s)")</code>, which is single-quoted.</p> <pre><code>source ~/.git-completion.bash function prompt { local WHITE="\[\033[1;37m\]" local GREEN="\[\033[0;32m\]" local CYAN="\[\033[0;36m\]" local GRAY="\[\033[0;37m\]"...
use space as a delimiter with cut command <p>I want to use space as a delimiter with the <code>cut</code> command.</p> <p>What syntax can I use for this?</p>
<pre><code>cut -d ' ' -f 2 </code></pre> <p>Where 2 is the field number of the space-delimited field you want.</p>
How do I add more than one row with Zend_Db? <p>I have an array with information which looks more or less like this:</p> <pre><code>$data[] = array('content'=&gt;'asd'); $data[] = array('content'=&gt;'asdf'); </code></pre> <p>And I want to add both entries into the Database.</p> <pre><code>$db-&gt;insert('table', $d...
<p>I don't think Zend_Db supports insertion of multiple rows. </p> <p>But if you just have two rows or a little more you can just use a loop.</p> <pre><code>foreach ($data as $row) { $db-&gt;insert('table', $row) } </code></pre> <p><hr> <a href="http://stackoverflow.com/users/20860/bill-karwin">Bill Karwin</a>, ...
Run startupscript on Fedora 8 Core <p>I'm using Amazon EC2 with a Fedora 8 Core AMI. I have an EBS volume mounted at /ebsmnt, and a startupscript located at /ebsmnt/startupscript.sh . Currently I have to login to the server, cd to /ebsmnt/ and run the script manually. How can I make Fedora run this script automatically...
<p>The contents of the file /etc/rc.local are executed on startup.<br /> note: You will have to add the full path to the script.</p> <p>Does the script understand the "Start" and "Stop" parameters? If so it could be added to the runlevels. </p>
Creating executable files in Linux <p>One thing I plan to be doing is writing (painfully simple) Perl scripts, and I'd like to be able to run them without explicitly calling Perl from the terminal. I appreciate that, to do this, I need to grant them execute permissions. Doing this with chmod is easy enough, but it also...
<p>Make file executable:</p> <blockquote> <p>chmod +x file</p> </blockquote> <p>Find location of perl: </p> <blockquote> <p>which perl</p> </blockquote> <p>This should return something like </p> <blockquote> <p>/bin/perl sometimes /usr/local/bin</p> </blockquote> <p>Then in the first line of your script add...
MySQL Fulltext Searching ideographic (Asian) characters <p>I have a database full of Asian-character filled records (Chinese, Japanese, and Korean) alongside those with Latin-character filled records (English, Français, you name it), and I want to perform fulltext searches on them.</p> <p>MySQL says:</p> <blockquote...
<p>It depends on the size of the dataset. If we're talking hundred of thousands of rows, I'd probably take a look at one of the excellent independent full text search solutions available. I've actually never had to deal with this problem mysqlf, so I'm not sure of which solutions that includes support for asian languag...
What's wrong with this class? <p>For some reason, one of my Ruby on Rails classes produces this sort of error everytime I try to call any method on it:</p> <pre><code>undefined method `create' for Thread:Class </code></pre> <p>I created this class just like any other, using <code>./script/generate model Thread</code>...
<p>There is already a Thread class in ruby maybe its a name clash</p>
Should I create a blog in rails or use something that already exists? <p>In my next rails project I'm going to need blogging functionality. I'm wondering whether anyone has any good suggestions, or should I just roll my own? (Probably not in 15 minutes) </p> <p>I think the most important feature will be to display cod...
<p>How's your free time?</p> <blockquote> <p>Five years, that's how long that little idea took. Plus 2 years of adding bells and whistles. And that, folks, is why I'm giving in and using a blog host. Because I have lots of ideas, lots of things to say and to explore, but only a few dozen years left at best. I can't ...
LinqToSQL and auditing changed fields <p>Here's another one of these LinqToSQL questions where I'm sure I must have missed the boat somewhere, because the behavior of the O/R Designer is very puzzling to me...</p> <p>I have a base class for my LinqToSQL tables, which I called <code>LinqedTable</code>. I've successful...
<p>You can use GetChangeSet on the DataContext to retrieve a list of updates, inserts and deletes that have occurred on all tables within a context. You can use ITable.GetOriginalEntityState to retrieve the original values of a changed entity. However, when you retrieve the original values of a deleted or updated rec...
Extending JPA entity mapping <p>I'm looking for an easy way to extend existing JPA mapping. The idea is as follows:</p> <p>I have an EAR project with EJB3+JPA module which has ClassA annotated and mapped to table class_a. But I want some other module (another EJB module) to have ClassB which adds more properties to Cl...
<p>The implemented solution is as follows. I have one jar and two EJB modules:</p> <ol> <li><p>The jar is the base one. It holds the base entities and local interface for the extension:</p> <pre><code>@Entity public class BaseEntity { public long id; @Id @GeneratedValue public long getId() {... ... ot...
Bumping up bottom element <p>On this site: <a href="http://www.catonthecouchproductions.com/new/" rel="nofollow">http://www.catonthecouchproductions.com/new/</a> - I have been trying to remove the space between the two red borders, for I can keep my latest projects box without scrolling. Right now it has a slight scrol...
<p>First of all your site is looking great!</p> <p>As for the red border causing a horizontal scroll bar, the only way to fix that is remove the border all together. It seems as if that blue box at the bottom stretches to 100% of the page width. Unfortunately when you ad a 1 pixel border it adds two pixels to the widt...
How does "FOR" work in cmd batch file? <p>I've been programming in dozens of languages for 20 years but I could never understand how "FOR" work in windows cmd shell batch file, no matter how hard I tried. I read </p> <p><a href="http://rads.stackoverflow.com/amzn/click/0470046163">http://www.amazon.com/Windows-Admini...
<p>None of the answers actually work. I've managed to find the solution myself. This is a bit hackish, but it solve the problem for me:</p> <pre><code>echo off setlocal enableextensions setlocal enabledelayedexpansion set MAX_TRIES=100 set P=%PATH% for /L %%a in (1, 1, %MAX_TRIES%) do ( for /F "delims=;" %%g in ("!P...
What advantages does Sass provide over regular CSS? <p>I'm trying to decide on technologies for a presentation layer. I have heard Sass talked about enthusiastically but am resistant to learn something new without knowing why it's better than the alternative - in this case plain CSS. Any feedback on Sass would be welco...
<p>I have a <a href="http://vimeo.com/4335944" rel="nofollow">screencast</a> that shows Sass and Compass (the Sass-based stylesheet framework) in action. It's an hour long, but it shows how Sass and Compass work and how they enable new ways of approaching website design by enabling sharing of implementation without com...
how can I create a temporary folder in java? <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/617414/create-a-temporary-directory-in-java">Create a temporary directory in Java</a> </p> </blockquote> <p>Duplicate: <a href="http://stackoverflow.com/questions/375...
<p>I've never seen a good solution for this, but this is how I've done it.</p> <pre><code>File temp = File.createTempFile("folder-name",""); temp.delete(); temp.mkdir(); </code></pre>
How do I Sort Collections in Objective-C? <p>I have an integer array in my Objective-C program. I'd like to sort it (ascending or descending, doesn't matter). In C++ I'd use the sort algorithm in the STL Algorithm library. How can I do this?</p>
<p>The "Cocoa" way is to create NSNumber objects, add them to an NSArray, and use the <code>sortUsingSelector:@selector(compare:)</code> method (or one of the other NSArray sort methods). </p> <p>If you want to create a C array of primitive NSInteger (int) values, you can use the built-in <a href="http://www.cpprefere...
Why does the x value change in this program? <p>I have created this code, and when I run it, don't get any errors until the arrow leaves the screen (ie: (*I)->x>maxx), after which the O will randomly teleport (Well, I'm guessing its not random, but I'm trying to find a pattern to it).</p> <p>EDIT: the random teleport...
<p>In check(), the test</p> <pre><code>((*I)-&gt;x &gt; maxx) </code></pre> <p>should be</p> <pre><code>((*I)-&gt;x &gt;= maxx) </code></pre> <p>. This is an off-by-one error that lets the > get one square off the screen. When the display routine tries to display it, it clobbers the display symbol for the X.</p>
Does Duff's Device work in other languages? <p>Many years ago while working on a tight graphics I/O problem, Tom Duff unrolled a loop and created his <a href="http://en.wikipedia.org/wiki/Duff%27s%5Fdevice" rel="nofollow">Duff's Device</a> as follows:</p> <pre><code>dsend(to, from, count) char *to, *from; int count; {...
<p>You can do it in any language that supports computed GOTO statements (Fortran, some BASICs, etc.)</p>
UILabel memory leak? <p>I have an NSTimer that fires off every second, and on that second I update a UILabel by setting the text property like so:</p> <pre><code>remainglbl.text = [NSString stringWithFormat:@"%i:%02i", var1, var2]; </code></pre> <p>It works fine, but when I run it in xcode with Start With Performance...
<p>I believe the problem was that I did not understand the performance tools. Running with the Activity Monitor does not show increasing memory usage. </p>
WPF and initial focus <p>It seems that when a WPF application starts, nothing has focus.</p> <p>This is really weird. Every other framework I've used does just what you'd expect: puts initial focus on the first control in the tab order. But I've confirmed that it's WPF, not just my app -- if I create a new Window, and...
<p>I had the bright idea to dig through Reflector to see where the Focusable property is used, and found my way to this solution. I just need to add the following code to my Window's constructor:</p> <pre><code>Loaded += (sender, e) =&gt; MoveFocus(new TraversalRequest(FocusNavigationDirection.Next)); </code></pre...
Serialize MVC ViewDataDictionary <p>I'm using SQL state server for session variables. I'm also storing ViewData in TempData so I can access the ModelState across a redirect. The problem is that the ViewDataDictionary is not serializable. Is there a way to hook into the session storage logic to serialize the ViewData...
<p>I think you're breaking a fundamental idea of the MVC pattern.</p> <p>You shouldn't need the session variable. You pass the model to the view, then the model is passed back to the controller. It doesn't matter if it's a redirect or not.</p>
JTable or some other Java table class with advanced cell selection? <p>Right now I'm using a JTable for what I'm doing. After looking through the Java API and various web resources, I don't think a JTable is going to cut it anymore. What I'm looking for is a table for which I can specify very strict selection procedure...
<p>Doesn't sound like you are really modeling a 'table'. (JTable assumes table semantics and uses a List selection model.) However, I don't think it's that far removed from a matrix, if you are willing to hack the JTable code.</p> <p>An alternative is your own (yep) component: A JPanel that contains the matrix cell...
What .sdf files. How it is diffrent from .mdf files.Does it works with linq to Sql? <p>I am playing with wpf and when i have created database it is created with the .sdf files. I want to know details of .sdf files. How it is diffrent then the standard .mdf files and will they support linq to sql? Because i am not able...
<p>An SDF file is a Sql Server Mobile file. It is also referred to as Sql Server compact. It is predominantly used in mobile development but recently more and more common in single user desktop developments as well. </p> <p>Visual Studio 2008 does not support Linq to Sql for Sql Server Mobile but the Framework does. Y...
Simple way to create an ERD for a database design review <p>I am working on a new application that uses a jet (MS Access) database. I have built the database using FluentNHibernate's AutoMapping feature from my C# objects.</p> <p>I need to present this database for an on-line WebEx design review on Tuesday and am loo...
<p>Since you have Visio 2007, you can "reverse engineer" the DB from either a SQL Server, Access or other driver compatible data source.</p> <ol> <li>Create a new database document (aka: Database Model Diagram)</li> <li>From the new "Database" menu select reverse engineer</li> </ol> <p>From that point on, you'll be c...
Hide Error Report window <p>I have the following problem:<br> My ASP.Net application receives a C++ source code of simple console programm, compiles it with cl.exe (command line VC++ compiler) and runs it using System.Diagnostics.Process.</p> <p>ASP.Net application runs on PC, which can be used for other work (it is n...
<p>Starting with Windows Vista, you can use the WinAPI function <code>WerAddExcludedApplication</code>to disable "Windows Error Reporting" for a specific application.</p> <p>See: <a href="http://msdn.microsoft.com/en-us/library/bb513617(VS.85).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/bb513617(VS.85...
DropDownList binding problem <p>I have two DropDownListBoxes one is called ddlDay and the other is ddlMonth. As their names suggests, ddlDay has values from 01 to 31 (not dynamic) and ddlMonth has values from 01 to 12. These values are not dynamically set.</p> <p>When the page loads, I am getting values from the db.. ...
<p>Try this to set initial values : </p> <pre><code>ddlDay.ClearSelection() ddlDay.Items.FindByValue(int.InterviewDate.Day.ToString("00")).Selected = True ddlMonth.ClearSelection() ddlMonth.Items.FindByValue(int.InterviewDate.Month.ToString("00")).Selected = True </code></pre> <p><strong>NOTE :</strong> ClearSelecti...
Forcing page refresh on click of back button <p>I've 2 asp.net pages..page A and page B. On clicking a link on page A, user gets redirected to page B.When on page B, if user clicks browser's back button, I need to forcefully invoke page refresh of page A. How do I achieve this functionality? Note:Code needs to be compa...
<p>There is some button property like Autopostback, you can try it and see if ti helps!</p>
PHP SID not showing <p>I cannot get my SID working ...</p> <pre><code>&lt;?php session_start(); // Or maybe pass along the session id, if needed echo '&lt;br /&gt;&lt;a href="page2.php?' . SID . '"&gt;page 2&lt;/a&gt;';?&gt; </code></pre> <p>does not show up SID number but session_id is working not sure if I am missi...
<p>The SID constant will show an empty string if a a cookie with the name of <a href="http://www.php.net/manual/en/session.configuration.php#ini.session.name">session.name</a> has been detected by PHP. See <a href="http://www.php.net/manual/en/session.constants.php">the manual page</a>. That means, that SID will contai...
Photoshop blending mode to OpenGL ES without shaders <p>I need to imitate Photoshop blending modes ("multiply", "screen" etc.) in my OpenGL ES 1.1 code (<strong>without</strong> shaders).</p> <p>There are some docs on how to do this <strong>with</strong> HLSL:</p> <ul> <li><a href="http://web.archive.org/web/20090222...
<p>Most photoshop blend-modes are based upon the Porter-Duff blendmodes.</p> <p>These requires that all your images (textures, renderbuffer) are in premultiplied color-space. This is usually done by multiplying all pixel-values with the alpha-value before storing them in a texture. E.g. a full transparent pixel will l...
CLR interfering with C++ STD? <p>I have some code compiling under the clr and other code that is unmanaged in a single project.</p> <p>My common.h file includes all the std library headers that I need. It is included by manager.h (forward declaration for manager.cpp (no CLR)), which is included by main_window.h (WinFo...
<p>Have you tried wrapping #pragma unmanaged / #pragma managed around the functions you need to stay unmanaged? While written in a kind of "breathless enthusiasm" tone, <a href="http://www.ondotnet.com/pub/a/dotnet/2003/03/03/mcppp2.html" rel="nofollow">http://www.ondotnet.com/pub/a/dotnet/2003/03/03/mcppp2.html</a> d...
HowTo put region of Pyglet image into PIL Image? <p>My app reads frames from video (using pyglet), extracts a 'strip' (i.e. region - full width by 1 to 6 video lines), then pastes each strip (appends it) into an image that can later be written out an *.png file.</p> <p>Problem is Pyglet GL images are stored in graphic...
<p>I know it's bad form to reply to one's own question, but I worked out an answer which may be useful to others, so here it is...</p> <p>nextframe = source.get_next_video_frame() # get first video frame while nextframe != None:# returns None at EOF</p> <pre><code># ### extract strip data, conver to PIL Image-fr...
Problem with paths in a java jar <p>I have a folder called Etc which has an image I want to use in another file in the same folder, Example.java. So I have Etc\image.png and Etc\Example.java. I've tried using "Etc/image.png" as the image path, but that didn't work. How should I go about this?</p> <p>Also, suppose the ...
<p>You can use <code>Class.getResource()</code>, which uses the class loader to obtain a URL to the resource. For example:</p> <pre><code>import java.net.URL; import javax.swing.ImageIcon; public class Example { public ImageIcon getImage() { URL url = Example.class.getResource( "image.png" ); if(...
Problems with nested form fields showing up <p>I'm attempting to implement nested object forms for my site, using Ryan Daigle's blog post as a guide (<a href="http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes" rel="nofollow">http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rai...
<p>What is going on in your controller? I haven't read the tutorial yet, and can't seem to pull it up right now (down?) but are you building out an object in memory to fill out? </p> <p>in your controller, in your "new" action, make sure that you are </p> <pre><code>@instruction = Instruction.new @instruction.steps.b...
Is there an equivalent of isitruby19 for rubinius? <p>Is there a web site that indicates which gems work on rubinius (or other implementations of ruby), like isitruby19.com indicates which gems work on ruby 1.9? (I'm curious about heckle working with rubinius in particular)</p>
<p>Yes, see here: <a href="http://isitrubinius.com/">http://isitrubinius.com/</a></p>
Date bookmarklet needs leading zero on single digit months and days <p>I have a bookmarklet I use to check daily log files. However the bookmarklet I use only delivers the month and day in single digits, however the log files use double digits.</p> <p>For example my bookmarklet delivers: <a href="http://url/log/2009-5...
<p>it's kind of a pain, but what I've done is to do stuff like this:</p> <pre><code>("0"+d.getDate()).slice(-2) </code></pre> <p>(add a leading zero, and <code>slice(-2)</code> takes the last 2 characters)</p>
Drag-and-drop files onto an NSTableView? <p>I have an <code>NSTableView</code> which I wish to allow users to drag-and-drop video files onto. When they drop the file, it'll get added as a row in the table view.</p> <p>How would I go about doing this? Currently the tableview's takes its data from an Array Controller (w...
<p>NSTableView handles drag-and-drop differently from generic views, which is overall a good thing. It means that you don't have to manually handle the complicated highlighting, cell tracking and inserting behaviours that tables require.</p> <p>A description of what is required can be found <a href="http://developer.a...
Multiple responses from one AJAX request <p>Not really looking for code examples here, just concepts. </p> <p>I have three sections on a page now that are being updated via three separate AJAX calls to PHP scripts, which return JSON. What would be the easiest way to condense these three calls into one larger call and ...
<p>I like Cris' method, but think I can provide a little improvement. As you already have 3 seperate entities, to reduce the need for recoding everything, you could do something along the lines of combining you PHP into one file via <code>include 'page.php'</code> and sending an object back via JSON with properties na...
Is there a way to override action scripts operators, in particular I would like to override the equals operator <p>Is it possible to override the equals() operator (ie. for customer classes where equality may be determined by 2 or more fields matching).</p>
<p>if you mean overloading "==" as a synonym for equals() then you can't, as ActionScript doesn't offer operator overloading. Just write an equals() method for your class and use that...</p>
Databinding To A Property I Create In .Net 2.0 <p>I'm doing some binding in .Net 2.0. It's been a hassle! I have a DataTable (I was trying to use a DataRow, but it was having none of that) and a BindingNavigator (which seemed to be the magic ingredient) with a BindingSource, and I'm programmatically binding controls to...
<p>I worked it out: the property needs to be public, and you need to add the BindableAttribute to the property, like so:</p> <pre><code>[Bindable(true)] public Guid SetID { get; set; } </code></pre>
Find a pattern of binary numbers using shift-right and bitwise-AND? <p>I'm attempting to write a function in assembly that will detect if a longer binary number contains a smaller binary pattern.</p> <p>Example:<br /> Does <strong>100111</strong> contain <strong>1001</strong>?</p> <p>When I read this problem I figure...
<p>The problem is that "partial matches" also return a non-zero value for your AND check:</p> <pre><code>100111 AND 001001 = 000001 </code></pre> <p>So this tests if <em>any</em> of the bits match, but you want to make sure <em>all</em> bits are the same. The result of the AND needs to be equal to the pattern you are...
Is there a good jQuery plugin or JS code for time durations? <p>I basically want to produce the following:</p> <p>from int 67 to 1 minute 7 seconds</p> <p>from int 953 to 15 minutes 53 seconds</p> <p>from int 3869 to 1 hour 4 minutes 29 seconds</p> <p>pseudo code:</p> <pre><code>// original &lt;span class="time"&g...
<p>Borrowing most of <a href="#818875">Guffa's answer</a>, this should do the trick as a jQuery plugin:</p> <pre><code>jQuery.fn.time_from_seconds = function() { return this.each(function() { var t = parseInt($(this).text(), 10); $(this).data('original', t); var h = Math.floor(t / 3600); ...
How can I pass values from one form to another? <p>Consider the situation where I have two windows forms, say <code>F1</code> and <code>F2</code>. After using <code>F1</code>, I have now called <code>F2.ShowDialog()</code>. This puts <code>F2</code> on the screen as well. Now that both forms are visible, how can I p...
<p>Has anyone considered simply passing the value to the form in the tag attribute.</p> <pre><code>Form newForm = new form(); newForm.Tag = passValue; newform.showmodal(); </code></pre> <p>when newform is shown the load (or any other) routine can use the data in tag</p> <pre><code>public void load() { if (this.Tag...
How to know query generated by Fluent NHibernate <p>I am using linq to Nhibernate to fire some select query to data base.</p> <p>My question is, how do I know, the query generated by Fluent NHibernate?</p>
<p>With Fluent NHibernate, you can turn on <code>show_sql</code> like this:</p> <pre><code>Fluently.Configure() .Database( MsSqlConfiguration.MsSql2005.ShowSql().ConnectionString(...) )... </code></pre> <p>NHibernate will now print every sql statement to <code>Console.Out</code>.</p>
comments in C/C++ <p>I come from writing PHP code, and there I was using PHPDoc standards, in order to write comments in the code.</p> <p>Now I'm trying to learn C/C++ (I'm using Visual Studio 2005), but I also wish to write good comments. </p> <p>Is any standard to use or/and a tool which will automatize the documen...
<p>Try reading <a href="http://www.stack.nl/~dimitri/doxygen/docblocks.html" rel="nofollow">documenting for Doxygen</a>. It can create documentation according to comments as well as cute little diagrams of your program structure with Graphviz.</p>
Open a view in UITabBarController <p>I need to open programatically a certain tab in my tab bar.</p> <p>I tried calling the following method from my UITabBarController:</p> <pre><code>self.selectedViewController = myVController; </code></pre> <p>Which doesn't work.</p> <p>What is the right way to open a tab?</p> <...
<p>Regarding the <code>selectedIndex</code> property, Apple's docs say:</p> <blockquote> <p>In versions of iPhone OS prior to version 3.0, this property reflects the index of the selected tab bar item only. Attempting to set this value to an index of a view controller that is not visible in the tab bar, bu...
How can I group/reuse named scopes in Rails? <p>How do I group named scopes? For example, I have two models, User and Activity. A user can have many activities.</p> <p>Activity has two named scopes:</p> <pre><code>Activity.ordered_by_created_at Activity.top_20 </code></pre> <p>I want to create a new named scope <cod...
<p>You can probably do this:</p> <pre><code>class Activity &lt; ActiveRecord::Base def self.recent ordered_by_created_at.top_20 end end </code></pre>
How to optimize PDF file size? <p>I have an input PDF file (usually, but not always generated by pdfTeX), which I want to convert to an output PDF, which is visually equivalent (no matter the resolution), it has the same metadata (Unicode text info, hyperlinks, outlines etc.), but the file size is as small as possible....
<p>Optimize PDF Files</p> <p>Avoid Refried Graphics</p> <p>For graphics that must be inserted as bitmaps, prepare them for maximum compressibility and minimum dimensions. Use the best quality images that you can at the output resolution of the PDF. Inserting compressed JPEGs into PDFs and Distilling them may recompre...
How would you describe math in comments? <p>Well as the questions says...</p> <p>An equation might be more meaningful in its math-notated form than it is in code. Being able to put math in comments could improve readabibity on my projects.</p> <p>In .NET btw.</p>
<p>I just use multiple lines to do it thus:</p> <pre><code>// Work out average as: sum (values) // -------------- // count (values) // // and distance between points as: // _______________________ // / 2 2 // d = \/ (x1 - x0) + (y1 - ...
Working with a QString encoding <p>Is there a Python library which can detect (and perhaps decode) encoding of the string?</p> <p>I found <a href="http://pypi.python.org/pypi/chardet" rel="nofollow"><code>chardet</code></a> but it gives me an error, using:</p> <pre><code>chardet.detect(self.ui.TextFrom.toPlainText())...
<p>You need to convert your <code>QString</code> to a Python string before passing it to <code>chardet</code>. Change this:</p> <pre><code>chardet.detect(self.ui.TextFrom.toPlainText()) </code></pre> <p>to this:</p> <pre><code>chardet.detect(str(self.ui.TextFrom.toPlainText())) </code></pre>
Good Open Source Code to learn Web Programming <p>Hi can someone point me to some Good Open Source Code to learn Web Programming (Language doesn't matter).</p> <p>i'm looking for source code of web-applications not frameworks</p> <p>I'm not a beginner, I can code to some extent. I want to know how stuffs are done in ...
<p>Well, this question is a bit vague. Are you looking for open source web frameworks, or open source code written in web frameworks But try looking at <a href="http://tomcat.apache.org/" rel="nofollow">Tomcat</a>, <a href="http://www.djangoproject.com/" rel="nofollow">Django</a>, <a href="http://www.asp.net/mvc/" re...
QTP: Getting the value of a checkbox <p>I want to know that how many checkboxes are present on the home page of <a href="http://www.gmail.com" rel="nofollow">www.gmail.com</a> and also I want to check the checkbox is checked or not .....</p> <p>My code is....</p> <pre><code>Set obj= Description.Create() obj("name").v...
<p>You're running the <code>GetROProperty</code> function on the Page object rather than the check-box you found (I don't know why <code>Page</code> has a <code>checked</code> property) but if you run on the test object returned by <code>ChildObjects</code> you will get the correct value (1 for <code>true</code> 0 for ...
GAE + Django. app-engine-patch or django-gae-helpers? <p>I'm building app using GAE and wanted to use Django for that. Which "patch" is better? app-engine-patch or django-gae-helpers? I mean functionality and future of them (will one of them die soon).</p>
<p>If by django-gae-helpers you refer to <a href="http://code.google.com/p/django-gae-helpers/" rel="nofollow">http://code.google.com/p/django-gae-helpers/</a> then there's nothing you can use there yet.</p> <p>I haven't tried app-engine-patch but I've used goole-app-engine-django. It took a bit of trial and error to ...
In WPF, how do I get the content of a tabItem to fill available space? <p>I do not know what I am doing wrong here. In the XAML below, the Border does not fill the available space on the tabItem (just lots of whitespace). How do I fill the entire tab page?</p> <pre><code>&lt;TabControl&gt; &lt;TabItem Header="Plan...
<p>I figured this out with the help of Matt Hamilton. This actually works fine if you are using a regular TabControl (default Template). </p> <p>I am using a xaml "theme" that alters the default control template. That is causing the layout to fail, so I will have to investigate and figure out what is wrong.</p>
Compare strings in haskell <p>I have two strings given as arguments to a Haskell function. s1 is smaller than s2 if s1 is shorter than s2 or if they have the same length and s1 is lexicographically smaller than s2.</p>
<p>I'd use something like the following:</p> <pre><code>smaller :: String -&gt; String -&gt; Bool smaller s1 s2 | len1 /= len2 = (len1 &lt; len2) | otherwise = (s1 &lt; s2) where (len1, len2) = (length s1, length s2) </code></pre> <p>Here's a sample run, in Hugs:</p> <p...
Automatic variables in the tests of conditionals : GNU Make <p>I am kind of stuck here. We have two makefiles (A requirement that I can't change)</p> <ul> <li><p>defs.mk : It contains the source file names &amp; their extra compile flags (apart from the standard flags) e.g: C_FILES = c/src/main/rule_main.c rule_main_O...
<p>I usually take advantage of <a href="http://www.gnu.org/software/autoconf/manual/make/Conditional-Functions.html">conditional functions</a>:</p> <pre><code>SPECIFIC_FLAGS=$(if $(findstring $(CUSTOM_FLAG),TRUE),$(IF_TRUE),$(IF_FALSE)) </code></pre> <p>Or use <a href="http://www.gnu.org/software/make/manual/make.htm...
DuplicateHandle(), use in first or second process? <p>The Windows API DuplicateHandle() <a href="http://msdn.microsoft.com/en-us/library/ms724251" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms724251</a>(VS.85).aspx Requires the Object handle to be duplicated and a handle to both the original process AND th...
<p>If I understood correctly, you want to synchronize two unrelated processes through the same event. If so, you can use named events.</p> <p>Create one using <a href="http://msdn.microsoft.com/en-us/library/ms682396%28VS.85%29.aspx" rel="nofollow">CreateEvent</a> API function, provide it a name, then from the second ...
No @XmlRootElement generated by JAXB <p>I'm trying to generate Java classes from the FpML (Finanial Products Markup Language) version 4.5. A ton of code is generated, but I cannot use it. Trying to serialize a simple document I get this:</p> <pre><code>javax.xml.bind.MarshalException - with linked exception: [com.su...
<p>To tie together what others have already stated or hinted at, the rules by which JAXB XJC decides whether or not to put the <code>@XmlRootElement</code> annotation on a generated class are non trivial (<a href="http://weblogs.java.net/blog/2006/03/03/why-does-jaxb-put-xmlrootelement-sometimes-not-always">see this ar...
to perform validation for amout(price) in ASP.net <p>I'm using 'Amount' as a column in my datatable for my application.</p> <p>I want to perform the following validations w.r.t 'Amount' which is a string variable.</p> <p>1) i want to check if the amount has more than 2 digits after the decimal point</p> <p>2) if the...
<p>You can create a validated numeric textbox like this:</p> <pre><code>&lt;asp:TextBox ID="txtDollars" Runat="server" /&gt; &lt;asp:CustomValidator runat="server" ErrorMessage="Only a valid number with no more than two decimal places is allowed." ClientValidationFunction="validateDollars" /&gt; &l...
How to test that test if a path is (or isn't) writable without writing nothing in it <p>Suppose you have the following subversion httpd server:</p> <pre><code>http://svn.mycompany.com/svn/&lt;project-name&gt; </code></pre> <p>Suppose you have complex authorization rules that specify who can read where and you have wr...
<p>Simplest way is to set up a replica (with <code>svnhotcopy</code>, <code>svnsync</code> or another way) and do the tests there.</p>
Query returning same sums - oracle sql <p>Wonder if anyone can shed any light on a sql query I'm working with;</p> <p>I have built this query;</p> <pre><code>SELECT SUM(TICKET_TYPE.PRICE) AS TOTALCINEMASALES, CINEMA.LOCATION, PERFORMANCE.PERFORMANCE_DATE FROM RESERVATION, TICKET, TICKET_TYPE, CINEMA, PERFORMANCE ...
<p>You forgot to join CINEMA, probably with PERFORMANCE.</p> <p>Guess: </p> <pre><code>AND CINEMA.CINEMA_ID = PERFORMANCE.CINEMA_ID </code></pre> <p>You could use the ANSI joins, when you get used to it, it is actually easier to read:</p> <pre><code>SELECT SUM(TICKET_TYPE.PRICE) AS TOTALCINEMASALES, CINEMA.LOCATIO...
How to disable XP themes in WPF application? <p>I have a WPF application (.NET 3.0, VS2008) that displays data in a tab control. Custom colors are required on virtually all controls in this application : basically white foreground and green background.</p> <p>My problem is that when an XP theme (say Luna) is active, i...
<p>Your best bet, to ensure a consistent behavior and appearance across operating systems, would be to re-template the TabItem control and then use a Trigger to modify a part of your new template when a TabItem is selected. Try something like the following: </p> <pre><code>&lt;Grid&gt; &lt;Grid.Resources&gt; &lt;Sty...
How do I test the quality of an encryption algorithm? <p>I want to test an encryption algorithm for strength. It doesn't have to be strong, it just has to resist accidental cracking and say, a determined hacker with 10-hours to waste. (I wrote <a href="http://stackoverflow.com/questions/819765/need-a-very-fast-encryp...
<p>I suspect that the usual answer would be "If you need to ask this question the best you can hope for is kid-sister grade encryption."</p> <p><hr /></p> <p>But if you must, you might start by applying the usual randnomness tests to the output (<a href="http://stackoverflow.com/questions/778718/how-to-test-random-nu...
How can I get multiple memories from a Perl regex match? <p>The purpose of the regex search is to determine all template class instances from C++ header files. The class instances can be formarted such as:</p> <pre><code>CMyClass&lt;int&gt; myClassInstance; CMyClass2&lt; int, int &gt; myClass2Instacen; </code></pre> ...
<p>First, if you are going to slurp files, you should use <a href="http://search.cpan.org/~drolsky/File-Slurp-9999.13/" rel="nofollow">File::Slurp</a>. Then you can do:</p> <pre><code>my $contents = read_file $file; </code></pre> <p>read_file will croak on error.</p> <p>Second, [^typename] does not exclude just the ...
JQuery : adding 5 id's on the fly (instead of classes) <p>I'm dealing with this situation :</p> <ul> <li>I have a color animation script which targets by id (it's not JQuery but pure javascript)</li> <li>then I have a dynamic list without ids : 'ul' somePHP throwing list items '/ul'</li> <li>and finally I have JQuery ...
<p>So you have an ordinary <code>&lt;ul&gt;&lt;/ul&gt;</code> and want to give every <code>&lt;li&gt;</code> in it a unique id? Try the jQuery command <a href="http://docs.jquery.com/Core/each" rel="nofollow">"each"</a>:</p> <pre><code>$("li").each(function(index, element){$(element).attr("id", index);}); </code></pre...
Which is faster/more efficient: Dictionary<string,object> or Dictionary<enum,object>? <p>Are <strong>enum</strong> types faster/more efficient than <strong>string</strong> types when used as dictionary keys? </p> <pre><code>IDictionary&lt;string,object&gt; or IDictionary&lt;enum,object&gt; </code></pre> <p>As a matte...
<p>Certainly the <code>enum</code> version is better (when both are applicable and make sense, of course). Not just for performance <em>(it can be better or worse, see Rashack's very good comment)</em> as it's checked compile time and results in cleaner code.</p> <p>You can circumvent the comparer issue by using <code...
Risk of using Apache mod_proxy <p>I am now exploring to use Apache's mod_proxy's directive, eg ProxyPass, as part of solution for cross-domain scripting restriction (for html/ajax/flash code). However, I am afraid by enabling mod_proxy, I would risk having the server as open proxy.</p> <p>What's the risk, and how to m...
<p>Since you specifically mentioned ProxyPass, I'll assume you're using mod_proxy as a reverse proxy. </p> <p>If that's the case, just make sure ProxyRequests is off. It isn't needed for reverse proxies. </p> <p>In a forward proxy configuration, if you were to enable ProxyRequests without setting access restriction...
Is there a SOAP::Lite equivalent library in ruby? <p>I want to build a SOAP client using ruby. I tried using the soap4r library to generate ruby classes out of the WSDL file, but the issue with this was that all the methods it generated were of optional kind, instead of NAME/VALUE pairs. Given that some methods have a ...
<p>Also take a look at <a href="http://github.com/rubiii/savon/" rel="nofollow">Savon</a>.</p>
Oracle connection string without tnsnames.ora file <p>I am using the .NET framework with the System.Data.OracleClient namespace. I have the oracle 11 client installed on my computer. I do not want to use the tnsnames.ora file to store connection information.</p> <p>Could someone please tell me what the connection st...
<p>Starting with 10g clients, you can use the <a href="http://www.orafaq.com/wiki/EZCONNECT">EZCONNECT</a> feature, which does not require to edit the TNSNAMES.ORA file : <code>username/password@servername:port/instance</code>. For instance :</p> <pre><code>Data Source=localhost:1521/XE;Persist Security Info=True;User...
How can I change the default configuration for WCF? <p>I have WCF Client initialized like this</p> <pre><code> MyServiceClient client = new MyServiceClient(); </code></pre> <p>so it uses the app.config to read the endPoints. I would like to dynamically change the default config file to a file I define. I know I can ...
<p>Check out this article here: <a href="http://www.paraesthesia.com/archive/2008/11/26/reading-wcf-configuration-from-a-custom-location.aspx" rel="nofollow">Read WCF Configuration from a Custom Location</a>.</p> <p>It basically involves creating a custom ServiceHost that will read the configuration from a different f...
Which projects do you include in your solutions <p>How do you commonly lay out your solutions in Visual Studio? Recently, I've kept the BLL, DAL and presentation in different classes and planned to add a test solution as I learn TDD. However, after recently watching a video from Rob Conery and viewing a project from an...
<p>First, you need to understand Rob's coding habits. He uses an MVC-esque approach to development (if not pure MVC) and uses his ORM SubSonic.</p> <p>The use of MVC is the reason for the "Model" class, since SubSonic 2.1 contains Migrations, he is using the SQL Repository for those migrations, so that he can version...
IoC: How to create objects dynamically <p>I have a problem to understand how to use IoC in a scenario where I need to create objects dynamically. Lets assume I have this classes:</p> <pre><code>abstract class Field { public Field( ICommandStack commandStack ) {} } abstract class Entity { public readonly Collectio...
<p>I'd use a FieldFactory and inject the factory with a reference to the container (or to an interface that abstracts it if you are not happy with taking a strong dependency on your container).</p> <p>Otherwise, it's turtles all the way down. You need some object to ask the container for a new instance at some point. ...
WAP vs XHTML-MP <p>Last year we develop intranet web site using WAP and ASP.NET for server side, the site was already on production and was considered successful. We use low end handset which had built in Openwave version 6. </p> <p>Now we update the application using XHTML-MP, because we think this will be the future...
<p>May I ask how much css formatting are you doing? It's recommended that you don't use css extensively to format the page since many handsets don't have enough power to process that (at least a few years ago, that was the case).</p>
List<Customer> all or nothing <p>I am creating a webservice using Windows Communication Foundation (WCF) and I currently don't know what the best way to do validation with it is.</p> <p>I have two methods: <code>CreateCustomer(Customer)</code> and <code>CreateCustomers(List&lt;Customer&gt;)</code>. </p> <p>If a cli...
<p>In this type of situation, I would recommend a Transaction like approach.</p> <p>Basically, you would validate all, if they don't pass, throw the exception, or other validation failed events, with the customer(s) that did not pass using an identifier or the actual objects. This will allow the person on the other s...
How would you implement an scrollable grid in your iPhone app? <p>I have about 50 images of 50 x 50 pixel size each. I want the user to pick one of them. So first I thought about an UITableView, but that's just not the right thing. It wastes a lot of screen space. Rather than putting all images one below the other, it ...
<p>I'm doing something very similar in my app- an NxN grid with an image underneath, and another subview on top to draw the "lines", all owned by a UIScrollView. I recommend having a separate view to draw the images, something like:</p> <pre><code>-(void) drawRect(CGRect rect) { CGRect smallerRect = CGRectMake(x,...
Change Culture DateTimePicker For .Net Specially Persian Calendar <p>. net datetimepicke can not Change to Persian calendar I Need A Multi Culture DateTimePicker that support geregorian And Persian And Hijri Cultures.</p>
<p>Check this out. <a href="http://www.codeproject.com/KB/selection/FarsiLibrary.aspx?fid=287863&amp;df=90&amp;mpp=25&amp;noise=3&amp;sort=Position&amp;view=Quick&amp;fr=176" rel="nofollow">CodeProject: Farsi Library</a></p>
How do you use Notepad++ regex pipe | for strings longer than one character? <p>I'm trying to get notepad++ to regex find all instances of "abc" and "def" in the following sentence:</p> <blockquote> <p>The abc went to the def.</p> </blockquote> <p>None of the following syntaxes seem to work:</p> <ul> <li>abc|def</...
<p><strike>It's nothing special about "longer than one character", Notepad++ doesn't support the | character in regex. Not even "a|d" works. See <a href="http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Unsupported_Regex_Operators" rel="nofollow">the regex help page</a>.</strike> Version 6.1.1 of Note...
In Unix, how do you remove everything in the current directory and below it? <p>I know this will delete everything in a subdirectory and below it:</p> <pre><code>rm -rf &lt;subdir-name&gt; </code></pre> <p>But how do you delete everything in the current directory as well as every subdirectory below it and the content...
<p>Practice safe computing. Simply go up one level in the hierarchy and don't use a wildcard expression:</p> <pre><code>cd ..; rm -rf -- &lt;dir-to-remove&gt; </code></pre> <p>The two dashes <code>--</code> tell <code>rm</code> that <code>&lt;dir-to-remove&gt;</code> is not a command-line option, even when it begins...
How to show Number of Views (like This link/page has been viewed 68 times) in rails? <p>How to show Number of Views (like : This link/page has been viewed 68 times) in rails? I sthere any gem or plugin available for it ?</p>
<p>If you are following the usual MVC pattern, then a View is a representation of the object model and the best way to track a view count would be to simply add a 'number of times viewed' counter to the table.</p>
C# regex match only parts of complete words in string <p>Before asking this question I have Googled for this problem and I have looked through all StackOverflow related questions.</p> <p>The problem is pretty simple</p> <p>I have a string "North Atlantic Treaty Organization"</p> <p>I have a pattern "a.*z", at moment...
<p>ANIZ in orgANIZation is <strong>not</strong> a complete word -- it's a part of a word. Your pattern btw is not what you wrote -- <code>a*z</code> would not match as you describe; you're probably using <code>a.*z</code> instead, which would. So, try <code>a[^ ]*z</code> so it won't match spaces. If there are other...
Why it is not possible to create a generic fill method in Java? <p>I have the following classes:</p> <pre><code>abstract class DTO{ } class SubscriptionDTO extends DTO { } </code></pre> <p>and the following generic method:</p> <pre><code>protected void fillList(ResultSet rs, ArrayList&lt;? extends DTO&gt; l) thro...
<p>You should be using <code>&lt;? super DTO&gt;</code> (or <code>&lt;? super SubscriptionDTO&gt;</code>, as <a href="http://stackoverflow.com/users/4725/tom-hawtin-tackline">Tom Hawtin - tackline</a> points out) as the generic parameter of the <code>ArrayList</code>.</p> <p>From item 28 of <a href="http://java.sun.co...
Create a WPF library in Visual Studio Express <p>I am trying to make my code more reusable by placing commonly recurring utility classes and user controls into a packaged library. The IDE is making this difficult, as so far, I have found that it always defaults to Windows Forms user controls and disabling my ability to...
<p><a href="http://dotupdate.wordpress.com/2007/12/05/how-to-add-a-wpf-control-library-template-to-visual-c-express-2008/">Here are</a> detailed step-by-step instructions on how to create a template for that.</p>
How can I use Rhino Mocks to mock a MEF export? <p>With reference to the Managed Extensibility Framework (MEF), I'm trying to work out how to create clean tests with mocks.</p> <p>I have an exported component which has three <strong>private</strong> imports. Each imported object (field) needs to be mocked. Given that ...
<p>My question has been answered <a href="http://mef.codeplex.com/Thread/View.aspx?ThreadId=55271">here</a>.</p> <p><hr /></p> <p>Hi Nathan</p> <p>There's a couple of different options here.</p> <ol> <li><p>Using a batch, you can call the AddExportedObject method to add a mock instance to the container. AddExported...
Best practices when including/using a "partial view"? <p>In modern web frameworks like Rails and symfony the concept of partial includes or partial views is well documented and recommended.</p> <p>What I am having trouble with lately is deciding how much design to include in the partial.</p> <p>It's kind of hard to e...
<p>I use partials for pieces of view code that are used in more than one place. If the code is going to be duplicated or re-used in several places, then it is a prime candidate to be DRY'd up and placed into a partial.</p> <p>As far as styling code, all that should reside in your CSS files</p>
Should I use .erb or .rhtml files for a Rails app in which all Controller logic exists in Views? <p>I'm just starting to learn Rails. I created an empty Rails app. And instead of writing a Controller, I want to put all of my Controller logic in my Views instead of in separate Controller classes. </p> <p>To do this, sh...
<p>First of all, they are virtually the same thing but you should use the new standard naming format of .html.erb</p> <p>Second of all, <strong>stop what you are doing and reconsider everything!!!!!</strong></p> <p>The whole point of MVC is to separate logic from display and vice versa. Most of your logic should be ...
Merging two Images with CodeIgniter Image Manipulation Class <p>I am developing a new project in CodeIgniter (CI), and would like to find a CI solution to this current issue. I've got one image, which resembles a picture frame. I would like for uploaded images to be modified to have this frame in their background.</p> ...
<p>If the images are going to be shown on your own website, it would probably be easier to simply use CSS (especially if your bottom image simply gives a border...). Of course, if you want people to be downloading these files with the frame, that's a different story.</p> <p>I don't think CI has a built in method in th...
first mysql trigger failing <p>Ok, I've started writing my first trigger in mysql, it doesn't give an errors, but it doesn't work either...</p> <pre><code>DELIMITER $$ DROP TRIGGER `cc`.`update_expires_date_trig`$$ CREATE TRIGGER `update_expires_date_trig` BEFORE INSERT ON `credit_test_acc` FOR EACH ROW BEGIN U...
<p>As far as I know, it must be rewritten like this to work as you expect it to work:</p> <pre><code>DELIMITER $$ DROP TRIGGER `cc`.`update_expires_date_trig`$$ CREATE TRIGGER `update_expires_date_trig` BEFORE INSERT ON `credit_test_acc` FOR EACH ROW BEGIN SET NEW.date_expires_acc = DATE_ADD(CURDATE(), INTERVAL 6...
Why are Console.In Console.Out & Console.Error Properties Read Only? <p>Does anybody know why the Console.In, Console.Out and Console.Error properties are read only? One would probably assume because Microsoft didn't intend on having anybody change them, but the framework includes related Console.SetIn(), Console.SetOu...
<p>Complete guess, but it could be because the <code>Set*</code> methods have the <code>HostProtectionAttribute</code> applied to them. I don't know offhand whether you can apply an attribute just to the setter part of a property. It's certainly something I've never had to do, and in fact <code>HostProtectionAttribute<...
Call back style <p>I am writing an iPhone application which in numerous places needs to perform non HTTP or FTP networking of a very simple request response type.</p> <p>I've wrapped all this up into a SimpleQuery class that integrates with the run loop. </p> <pre><code>SimpleQuery *lookup = [[SimpleQuery alloc] init...
<p>An option which is used commonly in Apple's code (for example, in UIControl) is to provide both a target object and a selector. This works only if there is a single callback, and is more appropriate than a delegate in that case. (If there are multiple callbacks, then you'll probably have to go with a delegate and th...
How do you make a Text Label display how many rows there are in the table <p>I am using Core Data and want a Text Label to display how many rows there are in the table, what code would I need to enter in the class file's to do this?</p>
<p>Set up a fetch request on your managed object context like you normally would, and call <code>countForFetchRequest:</code>. Don't forget to subscribe to <code>NSManagedObjectContextObjectsDidChangeNotification</code> so you can update it when objects are added or removed!</p>
Any good references or tools available for converting ASP to ASP.NET? <p>What tools, practices, or documentation have you used in your conversion process that you would recommend to others?</p>
<p>You could try Microsoft's </p> <p><a href="http://www.asp.net/downloads/archived/migration-assistants/asp-to-aspnet/" rel="nofollow">ASP to ASP.NET 1.x Migration Assistant</a></p> <blockquote> <p>The ASP to ASP.NET v1.x Migration Assistant is designed to help you convert ASP pages and applications to ASP.N...