instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>In Ruby you can reference variables inside strings and they are interpolated at runtime. </p> <p>For example if you declare a variable <code>foo</code> equals <code>"Ted"</code> and you declare a string <code>"Hello, #{foo}"</code> it interpolates to <code>"Hello, Ted"</code>. </p> <p>I've not been able to figur...
<p>Instead of interpolating, you could use <a href="http://ruby-doc.org/stdlib-2.1.1/libdoc/erb/rdoc/ERB.html" rel="nofollow noreferrer"><code>erb</code></a>. <a href="https://web.archive.org/web/20160401113123/http://www.rrn.dk/rubys-erb-templating-system" rel="nofollow noreferrer">This blog</a> gives simple example o...
<p>Using <a href="https://stackoverflow.com/users/11951/daniel-lucraft">daniel-lucraft</a>'s answer as my base (as he seems to be the only one that answered the question) I decided to solve this problem in a robust manner. Below you will find the code for this solution.</p> <pre><code># encoding: utf-8 class String ...
45,073
<p>The situation is as follows: I've got 2 models: 'Action' and 'User'. These models refer to the tables 'actions' and 'users', respectively.</p> <p>My action table contains a column <code>user_id</code>. At this moment, I need an overview of all actions, and the users to which they are assigned to. When i use <code>$...
<p>I designed and implemented the table-relationships feature in Zend Framework.</p> <p>My first comment is that you wouldn't use <code>findDependentRowset()</code> anyway -- you'd use <code>findParentRow()</code> if the Action has a foreign key reference to User.</p> <pre><code>$actionTable = new Action(); $actionRo...
<p>isn't creating a view sql table a good solution to make joint ? and after a simple table class to access it</p> <p>I would think it's better if your logic is in sql than in php </p>
29,061
<p>I wish Subversion had a better way of moving tags. The only way that I know to move a tag is to remove the file from the tag and then copy it again. Revision tree browsers don't seem to handle that very well. This also requires keeping the directory structure under the trunk and tag in sync.</p> <p>Use case: We hav...
<p>I don't think you can ever do this with the way that subversion operates. I believe the best solution would be to look at a tool like <a href="http://git.or.cz/" rel="nofollow noreferrer">git</a> which seems like it fits into your use case. You're production system could 'pull' in the "maps" that are accepted. Wh...
<p>Why don't you make a new tag for the current production version? Remember, Subversion is not CVS. So making a copy of the complete directory tree doesn't cost you anything.</p>
8,797
<p>I've used db4o with much success on many projects in the past. Over time it seems to have evolved greatly, and with modern trends like LINQ on everyone's tongue it has peaked my interest again, especially now that I know that it is starting to support transparent activation and persistence which intrigue me quite a ...
<p>In order to work around the performance cost of reporting via db4o, I'd suggest maintaining a highly denormalized (sqlite ?) database in parallel to your db4o container. Run reports against the db and normal app logic against db4o.</p> <p>Yes it's more work, but this way you'll have high performance reporting while...
<p>Far too late to be useful to you. But I suggest that people who find this question might want to look at Jasper Reports. There is a "commercial" version of the product. However, it's actually an open source solution and can be found on <a href="http://sourceforge.net/projects/jasperreports/" rel="nofollow">sourcefor...
10,539
<p>I'm running Apache on Windows XP via Xampplite, and could use help configuring my virtual directory. Here's what I'm hoping to do on my dev box:</p> <ol> <li>I want my source files to live outside of the xampp htdocs dir</li> <li>on my local machine I can access the project at <a href="http://myproject" rel="norefe...
<p>Figured it out: use <strong>Alias</strong> for #3, instead of VirtualHost, thus:</p> <pre><code>Alias /myproject "C:/path/to/my/project" &lt;Directory "C:/path/to/my/project"&gt; Options Indexes FollowSymLinks MultiViews ExecCGI AllowOverride All Order allow,deny Allow from all &lt;/Directory&gt; </code></p...
<p>Problem resolved in a simplest way and less steps No Need of creating virtual host just change the location of target directory.</p> <p>Here's what i have done for configuration: I've done it by editing the C:/xampp/apache/conf/httpd.conf file Changings that I have done in httpd.conf file Added this script right af...
33,828
<p>Context: The environment is .Net 3.0 + WPF land, the DB is abstracted well out into the distance and the solution would need to work for Office 2000 and up I guess.. </p> <p>The need is to get a customized report for which the user would like to have certain application windows/boxes (e.g. a trend graph) displayed ...
<p>I think you are going to have to look into writing an <a href="http://en.wikipedia.org/wiki/Object_Linking_and_Embedding" rel="nofollow noreferrer">OLE</a> embeddable/compatible application. It sounds like this may be a very large and complex task. </p> <p>Is there any reason that Excel cannot do the graph that y...
<p>I would strongly recommend making it dependant on Office 2007 and later. If you do so, you can use the ribbon and do .Net programming via VSTO.</p>
16,640
<p>I need to store large amount of data using RMS API through J2ME. </p> <p>How can I store that multiple-column data, given they must be hardcoded so I need to store those multiple columns and rows data.</p> <p>How can I do this in this, should I use <code>struct</code>s?</p>
<p>Well, RMS only allows you to store records that are arrays of bytes. You will have to decide for yourself how a record is stored, and if you want to store your data in a single or in multiple records. If you use the DataInputStream and DataOutputStream classes, you'll be able to read/write Strings, booleans, integer...
<p>Has Jeroen said RMS is quite basic. You can only store arrays of bytes. But, though it's basic, it's quite easy implement a more complex memory structure with an index stored in a record store and addressing other record stores containing data.</p> <p>Have a look to this page : <a href="http://developers.sun.com/m...
40,138
<p>I see on Stack Overflow and <a href="http://www.python.org/dev/peps/pep-0008/" rel="noreferrer">PEP 8</a> that the recommendation is to use spaces only for indentation in Python programs. I can understand the need for consistent indentation and I have felt that pain.</p> <p>Is there an underlying reason for spaces...
<p>The answer was given right there in the PEP [ed: this passage has been edited out in <a href="https://hg.python.org/peps/rev/fb24c80e9afb#l1.75" rel="noreferrer">2013</a>]. I quote:</p> <blockquote> <p>The <strong>most popular</strong> way of indenting Python is with spaces only.</p> </blockquote> <p>What other ...
<p>The universal problem with tabs is that they can be represented differently in different environment.<br> In a given editor, a tab might be 8 spaces or it might be 2.<br> In some editors, you can control this, while in others you can't.</p> <p>Another issue with tabs is how they are represented in printed output. ...
14,707
<p>For those not familiar with Core Image, here's a good description of it: <a href="http://developer.apple.com/macosx/coreimage.html" rel="nofollow noreferrer">http://developer.apple.com/macosx/coreimage.html</a></p> <p>Is there something equivalent to Apple's CoreImage/CoreVideo for Windows? I looked around and foun...
<p>There are a variety of tools for working with shaders (such as RenderMonkey and FX-Composer), but no direct equivalent to CoreImage.</p> <p>But stacking up fragment shaders on top of each other is not very hard, so if you don't mind learning OpenGL it would be quite doable to build a framework that applies shaders ...
<p>Adobe's new <a href="http://labs.adobe.com/wiki/index.php/Pixel_Bender_Toolkit" rel="nofollow noreferrer">Pixel Blender</a> is the closest technology out there. It is cross-platform -- it's part of the Flash 10 runtime, as well as the key pixel-oriented CS4 apps, namely After Effects and (soon) Photoshop. It's uncle...
18,890
<p>I found piston seems a decent tool for managing rails plugins, but when I try to do piston convert for my project with git based plugins, it just went dead completely and seems its trying to look for .svn with svn tools.</p> <p>I am on piston 1.4.0, is that git natively supported or I would have to build from edge?...
<p>I'm using piston 1.9.x for exactly this reason - since 1.9, it has <a href="http://blog.teksol.info/2008/03/17/piston-1-9-0-official-preview-release.html" rel="nofollow noreferrer">supported Git importing</a>.</p> <p>Instructions on installing can be found <a href="http://blog.teksol.info/2008/03/23/piston-1-9-1-im...
<p>check out <a href="http://github.com/evilchelu/braid/tree/master" rel="nofollow noreferrer">braid</a>.</p> <blockquote> <p>Simple tool to help track git and svn vendor branches in a git repository</p> </blockquote>
33,612
<p>I am trying to figure out what exactly is Appdomain recycling? When a aspx page is requested for the first time from a DotNet application, i understand that an appdomain for that app is created, and required assemblies are loaded into that appdomain, and the request will be served. Now, if the web.config file or th...
<p>Well, I think the thread was getting smoothly to a final conclusion, but in the end, it was otherwise.</p> <p>I'll try to answer the question based on my understanding and leveraging what i've just read about in other web sites.</p> <p>First of all, I myself try to avoid the term recycle other than for Application...
<p>If your pages are "updatable," they must be compiled before use. That means, yes, on first request the assemblies are loaded, compiled, and made ready for accessing. Whenever these files are changed (even some virus software can trigger this by changing the modified date of the files!), the appdomain gets recycled...
5,830
<p>Is there a built-in way to URL encode a string in Excel VBA or do I need to hand roll this functionality? </p>
<p>No, nothing built-in (<em>until Excel 2013 - <a href="https://stackoverflow.com/a/24301379/18771">see this answer</a></em>).</p> <p>There are three versions of <code>URLEncode()</code> in this answer.</p> <ul> <li>A function with UTF-8 support. <strong>You should probably use this one</strong> (or <a href="https:/...
<p>The best of both worlds. This function uses the new(ish) worksheet function <code>ENCODEURL()</code> if the workbook is open in Excel 2013 or newer.</p> <p>If it's an older version of Excel then this function uses <code>htmlfile</code> instead.</p> <p>You can also force this function to use <code>htmlfile</code> by ...
26,844
<p>I've got two controls in my Interface Builder file, and each of those controls I've created a separate delegate class for in code (Control1Delegate and Control2Delegate). I created two "Objects" in interface builder, made them of that type, and connected the controls to them as delegates. The delegates work just fin...
<p>You can add outlets from either delegate to the other delegate. There are two ways to add an outlet to an object in IB (assuming you're using Xcode/IB version 3.0 or later:</p> <ol> <li><p>If you have not generated the code for your delegate classes yet, select the desired delegate, then open the "Object Identity" ...
<p>I think you can create outlets on each one and cross-bind them so that they each have the same data all the time. If there's one model object they need to share, that's pretty tidy. I don't actually know how to do this; I think I saw it in an iPhone tutorial one time!</p>
11,233
<p>This is a two part question. A dumb technical query and a broader query about my possibly faulty approach to learning to do some things in a language I'm new to.</p> <p>I'm just playing around with a few Python GUI libraries (mostly wxPython and IronPython) for some work I'm thinking of doing on an open source app,...
<p>I'm not totally clear on the problem. You can certainly define a subclass of <code>System.Windows.Forms.Form</code> in IronPython in one module, and then import the form subclass in some other module:</p> <pre><code># in form.py from System.Windows.Forms import Form, Button, MessageBox class TrivialForm(Form): d...
<p>I'm not totally clear on the problem. You can certainly define a subclass of <code>System.Windows.Forms.Form</code> in IronPython in one module, and then import the form subclass in some other module:</p> <pre><code># in form.py from System.Windows.Forms import Form, Button, MessageBox class TrivialForm(Form): d...
47,300
<p>Our resident Flex expert is out for the day and I thought this would be a good chance to test this site out. I have a dropdown with a dataProvider that is working fine:</p> <pre><code>&lt;ep:ComboBox id="dead_reason" selectedValue="{_data.dead_reason}" dataProvider="{_data.staticData.dead_reason}" labelFiel...
<p>Try using an &lt;mx:Repeater&gt; Something like:</p> <pre><code>&lt;mx:Repeater dataProvider="{_data.staticData.dead_reason}"&gt; &lt;mx:RadioButton groupName="reasons" ...&gt; &lt;/mx:Repeater&gt; </code></pre>
<pre><code>&lt;mx:RadioButtonGroup id="RDO_Group"/&gt; &lt;mx:Repeater id="myRepeater" dataProvider="{_data.staticData.dead_reason}"&gt; &lt;mx:RadioButton id="rdo" label="{myRepeater.currentItem}" value="{myRepeater.currentItem}" groupName="RDO_Group"/&gt; &lt;/mx:Repeater&gt; </code></pre> <p> is the best way.</p>
17,083
<p>Have just started using <code>Google Chrome</code>, and noticed in parts of our site, e.g. all the links on the page, are bright red. They should be black with a dotted underline.</p> <p>Is there some gotcha in <code>WebKit</code> rendering that turns all links red regardless of the style?</p>
<p>Are all of the resources that you're linking to in the present at the locations where your page is seeking them (verify this by actually checking it). I've also had an issue when checking an app in Safari where I was attempting to pull a file that wasn't there and I had very similar output to yours (red links).</p>...
<p>Have you set a <code>:visited</code> setting in your stylesheet?</p>
6,820
<p>Ok I have two modules, each containing a class, the problem is their classes reference each other.</p> <p>Lets say for example I had a room module and a person module containing CRoom and CPerson.</p> <p>The CRoom class contains infomation about the room, and a CPerson list of every one in the room.</p> <p>The CP...
<p><strong>No need to import CRoom</strong></p> <p>You don't use <code>CRoom</code> in <code>person.py</code>, so don't import it. Due to dynamic binding, Python doesn't need to "see all class definitions at compile time".</p> <p>If you actually <em>do</em> use <code>CRoom</code> in <code>person.py</code>, then chang...
<p>@S.Lott if i don't import anything into the room module I get an undefined error instead (I imported it into the main module like you showed)</p> <blockquote> <p>Traceback (most recent call last):<br> File "C:\Projects\python\test\main.py", line 6, in <br> Ben = Room.AddPerson('Ben', 'Blacker', 'Male')<b...
19,134
<p>In dopplr [<a href="http://www.dopplr.com]" rel="nofollow noreferrer">http://www.dopplr.com]</a> there is an option to fill the city of travel and the site will automatically find the city around the world. Is there any web service or database for such a city lookup?</p>
<p><a href="http://www.geonames.org/" rel="noreferrer">http://www.geonames.org/</a> is useful - HTML query, download and web service.</p> <p>Also <a href="http://developer.yahoo.com/geo/" rel="noreferrer">http://developer.yahoo.com/geo/</a> - you'll need a Yahoo developer ID.</p>
<p>The best free database of world cities I have found is from MaxMind. See <a href="http://www.maxmind.com/app/geolitecity" rel="nofollow noreferrer">http://www.maxmind.com/app/geolitecity</a> It also includes geocoding information and population. Uses ISO standard for country and regions.</p>
41,953
<p>I'm working on a program that processes many requests, none of them reaching more than 50% of CPU (<strong>currently I'm working on a dual core</strong>). So I created a thread for each request, the whole process is faster. Processing 9 requests, a single thread lasts 02min08s, while with 3 threads working simultane...
<p>Do you have significant locking within your application? If the threads are waiting for each other a lot, that could easily explain it.</p> <p>Other than that (and the other answers given), it's very hard to guess, really. A profiler is your friend...</p> <p>EDIT: Okay, given the comments below, I think we're onto...
<p>It sounds like your application's performance may not be 'bound' by the amount of cpu resources available. If you're processing requests over the network, the cpu(s) may be waiting for the data to arrive, or for the network device to transfer the data. Alternatively, if you need to look up data to fulfill the reques...
33,344
<p>Lucene is an excellent search engine, but the .NET version is behind the official Java release (latest stable .NET release is 2.0, but the latest Java Lucene version is 2.4, which has more features).</p> <p>How do you get around this?</p>
<p>One way I found, which was surprised could work: Create a .NET DLL from a Java .jar file! Using <a href="http://www.ikvm.net/" rel="noreferrer">IKVM</a> you can <a href="http://www.apache.org/dyn/closer.cgi/lucene/java/" rel="noreferrer">download Lucene</a>, get the .jar file, and run:</p> <pre><code>ikvmc -target:...
<p>I converted the Lucene 2.4 from jar to dll through this way but now it gives me an error that 'Type or namespace Lucene could not be found'. I removed the old dll from the project and added reference for the new one. I really want to get rid of the old version as it took around 2 days and in the end during optimizat...
31,429
<p>I'm pretty sure one would do this using the os.plock(op) function, but I have no idea how. Also, if there's a better way, I'd be grateful to find out. Code snippets are very welcome. </p>
<p><a href="http://docs.python.org/library/subprocess" rel="noreferrer">Subprocess</a> replaces os.popen, os.system, os.spawn, popen2 and commands. A <a href="http://docs.python.org/library/subprocess#replacing-shell-pipe-line" rel="noreferrer">simple example for piping</a> would be:</p> <pre><code>p1 = Popen(["dmesg"...
<p>If you are doing low-level operating system forking and really want to avoid using pipes, it is possible to use shared memory-mapped files as well. This is not nearly as nice as using <code>subprocess</code> or <code>popen</code> pipes, but including the answer for completeness...</p> <p>There's a <a href="https://...
26,946
<p>My company is considering changing continuous integration servers (I won't say which one we have now, so I won't skew your responses in anyway :) ) I wondering if anybody has any recommendations? Best user experience, level of difficulty to maintain, etc...</p> <p>Our code is all in java, and we use ANT as a build...
<p>I recently implemented a <a href="http://hudson-ci.org/" rel="noreferrer">Hudson</a> server. Having previously used Cruise Control, <strong>I am very satisfied with Hudson and very impressed with its ease of setup and use.</strong> Adding new projects is infinitely easier than it was with Cruise Control.</p>
<p>I use <a href="http://continuum.apache.org" rel="nofollow noreferrer">Continuum</a> for my continuous integration server. No reason other than I was going to hire a development manager who had used at his last assignment so it seemed to make sense to pick something at least one of us was experienced with.</p> <p>Pr...
16,983
<p>I am using the MFC class <code>CSocket</code>. Nothing complicated - open a connection to a server and send a short message. The code works fine when I link with MFC in a DLL. However, the call to <code>CSocket::Create()</code> crashes when I link to MFC in a static library.</p> <p>I would like to use MFC in a s...
<p>According to <a href="http://support.microsoft.com/kb/193101" rel="nofollow">http://support.microsoft.com/kb/193101</a></p> <p>The handle maps used by the sockets need to be created for each thread. The following code shows a function to do this:</p> <pre><code> void SocketThreadInit() { #ifndef _AFXDLL ...
<p>Are you getting any linker warnings at all? Make sure you link the right CRT library depending on your "Code Generation" setting. For Multi-threaded static, you need libcmt.lib for release (libcmtd.lib for debug), also make sure _AFXDLL isn't defined.</p>
39,423
<p>Ought I to unit test constructors? Say I have a constructor like this:</p> <pre><code>IMapinfoWrapper wrapper; public SystemInfo(IMapinfoWrapper mapinfoWrapper) { this.wrapper = mapinfoWrapper; } </code></pre> <p>Do I need to write a unit test for this construtor? I don't have any getters for the wrapper varia...
<p>Unit testing is about testing the public states, behaviors, and interactions of your objects.</p> <p>If you simply set a private field in your constructor, what is there to test?</p> <p>Don't bother unit-testing your simple accessors and mutators. That's just silly, and it doesn't help anyone.</p>
<p>Unit Testing is about checking paths of execution, something often refered as <a href="http://www.lexjansen.com/pharmasug/2004/FDACompliance/FC06.pdf" rel="nofollow noreferrer">Cyclomatic Complexity</a></p> <p>If you have no path to choose from, no if, no loop, no GOTO (=P) its not very useful</p>
46,675
<p>I have a table with a large amount of information, how do i select just the last months worth? (ie just the last 31 cells in the column?)</p> <p>The data is in the form</p> <pre><code>date1 numbers date2 numbers . . . . . . daten numbers </code></pre> <p>where...
<p>Ideally there would be a column that has the date in it. Then you could do an advanced filter to filter on the date range that you require. Selecting the last 31 days will not always select just one month. It may select up to 3 days from the previous month as well.</p> <hr> <pre><code>Public Sub selectLastMonth...
<p>use</p> <pre><code>LastRow = Sheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell).Row </code></pre> <p>then you can get the range from LastRow-31 to LastRow if you have the date as specified then move the start point forward until the date value = date(if(now.month=1,now.year-1,now.year), if(now.month=1,1...
44,754
<p>For our online game, we have written tons of PHP classes and functions grouped by theme in files and then folders. In the end, we have now all our backend code (logic &amp; DB access layers) in a set of files that we call <strong>libs</strong> and we include our libs in our GUI (web pages, presentation layer) using ...
<ul> <li>Manage all includes manually, only where needed</li> <li>Set your include_path to only where it has to be, the default is something like .:/usr/lib/pear/:/usr/lib/php, point it only at where it has to be, php.net/set_include_path</li> <li>Don't use autoload, it's slow and makes APC and equivalent caches jobs a...
<p>It's been a while since I used php, but shouldn't the Zend Optimizer or Cache help in this case? Does php still load &amp; compile every included file again for every request?</p> <p>I'm not sure if autoloading is the answer. If these files are included, they are probably needed in the class including it, so they w...
11,880
<p>I've been able find information on symmetric encryption and hashing but I've been having quite a bit of trouble finding much information on any sort of public key encryption for java. What I'd like to do is make a very simple proof of concept program that takes a string ( or a file I suppose), encrypts it with a pub...
<p>There are quite a few resources on the web about that. Basically it turns around the KeyPairGenerator class.</p> <p>See <a href="http://www.informit.com/articles/article.aspx?p=170967&amp;seqNum=4" rel="noreferrer">http://www.informit.com/articles/article.aspx?p=170967&amp;seqNum=4</a> for an example program.</p>
<p>Normally, you use public key encryption to encrypt a symmetric key, in part because public key encryption is very slow. Typically, you'd send the recipient the following, so that they can decrypt your message:</p> <ol> <li>The symmetric key, encrypted with the recipient's public key.</li> <li>Parameters for the alg...
43,954
<p>I have a window (derived from JFrame) and I want to disable the close button during certain operations which are not interruptible. I know I can make the button not do anything (or call a handler in a WindowListener) by calling</p> <pre><code>setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); </code></pre> <p>...
<p>This is probably the best you are going to get:</p> <pre><code>setUndecorated(true); getRootPane().setWindowDecorationStyle(JRootPane.NONE); </code></pre> <p>This will remove the entire titlebar, java doesn't really specify a way to remove individual components of the titlebar</p> <p>edit:</p> <p>There may be a ...
<p>Please try this</p> <pre><code>frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { e.getWindow().setVisible(false); try { wait(); } catch (InterruptedException ex) { Logger.getLogger(WindowsActions.class.getNa...
34,834
<p>I have an array of RGB values, whose size I can guarantee to match the client area of a window on screen.</p> <p>Using the Win32 API, what are the easiest and fastest ways to get the contents of my array on the screen in response to a WM_PAINT message?</p> <p>If it makes it simpler/faster, we can assume it's a 32-...
<p>If you have complete control over your backing format, use a DIB format and a dummy BITMAPINFO structure. Then use <a href="http://msdn.microsoft.com/en-us/library/ms532346(VS.85).aspx" rel="nofollow noreferrer">SetDIBitsToDevice</a> to copy to the DC.</p> <p>Be aware of the peculiarities of the DIB format - every ...
<p>Use BitBlt</p>
35,582
<p><strong>Background</strong></p> <p>I am trying to create a copy of a business object I have created in VB.NET. I have implemented the ICloneable interface and in the Clone function, I create a copy of the object by serializing it with a BinaryFormatter and then de-serializing straight back out into another object ...
<p>Do you have an event that the UI is subscribing to? A {Foo}Changed event if data-binding, or perhaps INotifyPropertyChanged? You might have to mark the event backing field as [NonSerialized] (or however attributes look in VB - I'm a C# person...). If you are using field-like-events (i.e. the abbreviated syntax witho...
<p>An obvious question, but are you sure that you don't have a reference to MyControl from your Sheep object; be it an object or a list or anything? If this is the case this is what is preventing you from cloning your business object.</p> <p>The more than likely candidates would be a <strong>.Parent</strong> or <stron...
20,136
<p>I am studying for cryptography and I somehow stuck on understanding how DES works. Because it is around for a long time there should be nice tutorials like fancy diagrams, videos etc around the net. I searched but with no luck. Has anyone spotted anything "easy-to-digest" for the brain?</p>
<p>Bruce Schneier's Applied Cryptography is probably the funniest analysis you will find of it, but it is certainly not easy.</p>
<p>I have checked wikipedia, seems that I needed more. I also think that Schneier's book is perfect, I have it back home and could not transport it to where I study :-( shame....<br /> Nobody said this was going to be easy perhaps I should just read it many times and write it down on paper until it gets stuck to my bra...
20,810
<p>I want to read line n1->n2 from file foo.c into the current buffer.</p> <p>I tried: <code>147,227r /path/to/foo/foo.c</code></p> <p>But I get: "E16: Invalid range", though I am certain that foo.c contains more than 1000 lines.</p>
<pre><code>:r! sed -n 147,227p /path/to/foo/foo.c </code></pre>
<p>You will need to:</p> <pre><code>:r /path/to/foo/foo.c :d 228,$ :d 1,146 </code></pre> <p>Three steps, but it will get it done...</p>
29,736
<p>I know this is a dumb question. For some reason my mind is blank on this. Any ideas?</p> <p>Sorry should have been more clear. </p> <p>Using a <code>HtmlGenericControl</code> to pull in link description as well as image. </p> <pre><code> private void InternalCreateChildControls() { if (this.DataItem !...
<p>I'm assuming you want to generate an image dynamicly based upon an url.</p> <p>What I typically do is a create a very lightweight HTTPHandler to serve the images:</p> <pre><code>using System; using System.Web; namespace Example { public class GetImage : IHttpHandler { public void ProcessRequest...
<p>This is kind of a horrible question. I mean, .NET has an image control where you can set the source to anything you want. I'm not sure what you're wanting to be discussed.</p>
14,236
<p>My goal is to recognize simple gestures from accelerometers mounted on a sun spot. A gesture could be as simple as rotating the device or moving the device in several different motions. The device currently only has accelerometers but we are considering adding gyroscopes if it would make it easier/more accurate. </p...
<p>The accelerometers will be registering a constant acceleration due to gravity, plus any acceleration the device is subjected to by the user, plus noise. </p> <p>You will need to low pass filter the samples to get rid of as much irrelevant noise as you can. The worst of the noise will generally be higher frequency t...
<p>Adding to moonshadow's point about having to reset your baseline for gravity and rotation... </p> <p>Unless the device is expected to have stable moments of rest (where the only force acting on it is gravity) to reset its measurement baseline, your system will eventually develop an equivalent of vertigo.</p>
24,250
<p>I need to read the user's fingerprint from my application.</p> <p>What I really want is a simple SDK that works with a lot of inexpensive fingerprint readers but I can deal with something that works only with one specific model if that model is cheap and available worldwide.</p> <p>And <strong>it has to be royalty...
<p>There is no standard API for reading fingerprint data as far as I'm aware since it is a fairly new field and there's no standard way of doing it. Each manufacturer will provide their own API for reading the hardware. The API could just be IO specification to the hardware and there's no library whatsoever, which make...
<p>Symbol has an api for their MC75 handheld devices:</p> <p><a href="http://support.symbol.com/support/search.do?cmd=displayKC&amp;docType=kc&amp;externalId=12364&amp;sliceId=&amp;dialogID=104336066&amp;stateId=1%200%20104330426" rel="nofollow noreferrer">http://support.symbol.com/support/search.do?cmd=displayKC&amp;...
34,999
<p>I want to write a little app for myself which notifies me if there is a new version of php or mysql but I would need a feed or an xml file to read it from.</p>
<p>PHP.net provides one <a href="http://www.php.net/releases/index.php?serialize=1" rel="nofollow noreferrer">http://www.php.net/releases/index.php?serialize=1</a></p> <p>An alternative that may allow you to add additional software later is looking into the feeds provided by freshmeat: <a href="http://freshmeat.net/pr...
<p>You could probably subscribe to www.freshmeat.net's rss feed and only react when an even numbered version shows up.</p>
36,681
<p>One of the vagaries of my development system (Codegear C++Builder) is that some of the auto-generated headers insist on having... </p> <pre><code>using namespace xyzzy </code></pre> <p>...statements in them, which impact on my code when I least want or expect it.</p> <p>Is there a way I can somehow cancel/overrid...
<p>Nope. But there's a potential solution: if you enclose your include directive in a namespace of its own, like this...</p> <pre><code>namespace codegear { #include "codegear_header.h" } // namespace codegear </code></pre> <p>...then the effects of any using directives within that header are neutralized.</p> <p...
<pre><code>#include&lt;iostream&gt; #include&lt;stdio.h&gt; namespace namespace1 { int t = 10; } namespace namespace2 { int t = 20; } int main() { using namespace namespace1; printf("%d" , t); printf("%d" , namespace2::t); } </code></pre>
20,276
<p>I have URLs of the form <code>http://domain/image/⟨uuid⟩/42x42/some_name.png</code>. The Web server (nginx) is configured to look for a file <code>/some/path/image/⟨uuid⟩/thumbnail_42x42.png</code>, and if it does not exist, it sends the URL to the backend (Django via mod_wsgi) which then generates the thumbnail. Th...
<p>If it doesn't, the client's broken. Most clients will follow redirect loops until a maximum value. So yes, it should be fine until your backend doesn't generate the thumbnail for any reason.</p> <p>You could instead change URLs to be <a href="http://domain/djangoapp/generate_thumbnail" rel="nofollow noreferrer">htt...
<p>Yes, it's fine to re-direct to the same URI as you were at previously.</p>
15,367
<p>I'm using the ASP.net cache in a web project, and I'm writing a "status" page for it which shows the items in the cache, and as many statistics about the cache as I can find. Is there any way that I can get the total size (in bytes) of the cached data? The size of each item would be even better. I want to display th...
<p>I am looking at my performance monitor and under the <strong>ASP.NET Apps v2.0.50727</strong> category I have the following cache related counters:</p> <p><strong>Cache % Machine Memory Limit Used</strong></p> <p><strong>Cache % Process Memory Limit Used</strong></p> <p>There are also a lot of other cache related...
<p>Have not tried it. But maybe you can use <a href="http://www.aspalliance.com/CacheManager/Default.aspx" rel="nofollow noreferrer">Cache Manager plug-in for ASP.NET</a>. Or use it as example.</p>
44,771
<p>I have the following code:</p> <pre><code>var address; getAddress(0,0); function getAddress(latlng) { if (latlng != null) { geocoder.getLocations(latlng, function(addresses) { if(addresses.Status.code == 200) { address = addresses.Placemark[0].address.toString(); al...
<p>I think that your problems are all related to scope. Generally speaking, you don't want to rely on a global declaration of a variable to be used within the scope of a function. </p> <p>This should correct any scope issues with your function:</p> <pre><code>var address = getAddress(0,0); function getAddress(latlng...
<p>I can't see any reason why this won't work.</p> <p>To be doubley sure that nothing returning anything make the function call like this</p> <pre><code>window.alert(getAddress(0,0)); </code></pre> <p>And then see what is being output</p>
41,561
<p>If I'm using ConcurrentHashMap (where the put is thread safe) , and I supply a public function myPut that uses the ConcurrentHashMap put - do I need to synchronize my function? </p> <p>meaning : should this be synchronized?</p> <pre><code>ConcurrentHashMap map; public void myPut(int something) { this.map.pu...
<p>Concurrency utilities such as ConcurrentHashMap are designed so that you don't need to synchronize: they'll handle thread-safe access internally.</p> <p>What Tom says is true, that you need to think about the potential of the map reference to change. If the reference actually <em>doesn't</em> change, then in practi...
<p>No.<br> You can cal myPut multiple times at once.<br> The put will be called one at a time, because the HashTable's access needs to be one at a time. (see also concurrent writing in a shared memory)</p>
38,696
<p>When applying the Single Responsibility Principle and looking at a class's reason to change, how do you determine whether that reason too change is too granular, or not granular enough?</p>
<p>Make liberal use of [SuppressMessage] attribute to begin with. At least at the beginning. Once you get the count to 0 via the attribute, you then put in a rule that new checkins may not introduce FxCop violations. </p> <p>Visual Studio 2008 has a nice code analysis feature that allows you to ensure that code analys...
<p>An alternative to FxCop would be to use the tool <a href="http://www.ndepend.com/" rel="nofollow noreferrer">NDepend</a>. This tool lets write <strong>Code Rules over C# LINQ Queries</strong> (what we call <a href="http://www.ndepend.com/Features.aspx#CQL" rel="nofollow noreferrer">CQLinq</a>). <em>Disclaimer: I am ...
4,664
<p>Say I have the following class</p> <pre><code>MyComponent : IMyComponent { public MyComponent(int start_at) {...} } </code></pre> <p>I can register an instance of it with castle windsor via xml as follows</p> <pre><code>&lt;component id="sample" service="NS.IMyComponent, WindsorSample" type="NS.MyComponent, Wi...
<p>Edit: Used the answers below code with the Fluent Interface :)</p> <pre><code>namespace WindsorSample { using Castle.MicroKernel.Registration; using Castle.Windsor; using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; public class MyComponent : IMyComponent { public MyCompone...
<p>You can use the AddComponentWithProperties method of the IWindsorContainer interface to register a service with extended properties.</p> <p>Below is a 'working' sample of doing this with an NUnit Unit Test.</p> <pre><code>namespace WindsorSample { public class MyComponent : IMyComponent { public My...
11,341
<p>What is the best method of performing an scp transfer via the Java programming language? It seems I may be able to perform this via JSSE, JSch or the bouncy castle java libraries. None of these solutions seem to have an easy answer.</p>
<p>I ended up using <a href="http://www.jcraft.com/jsch/" rel="noreferrer">Jsch</a>- it was pretty straightforward, and seemed to scale up pretty well (I was grabbing a few thousand files every few minutes).</p>
<p>I wrote an scp server which is much easier than others. I use Apache MINA project (Apache SSHD) to develop it. You can take a look here: <a href="https://github.com/boomz/JSCP" rel="nofollow">https://github.com/boomz/JSCP</a> Also you can download the jar file from <code>/jar</code> directory. How to use? Take a loo...
24,337
<p>In traditional Waterfall, requirements were gathered - typically in a MS-Word document - following an esoteric template. In a "strict" waterfall model, this document is frozen after the requirement phase and a Change Control / Change Management process is responsible for introducing controlled changes. (**) [Typica...
<p>First, you can <strong>produce documentation and remain agile</strong>, if the customer or the Product Owner requests to have (read is ready to pay for) documentation.</p> <p>Grow your documentation incrementally and iteratively, as you'll do with code. Test a little , code a little and ... document a little. </p>...
<p>Since you have a document describing what the product should do, I would use it as the initial backlog and start splitting the work in bite size pieces ordered from highest to lowest priority. Each set of pieces would then be handled during an iteration. In brief, use Scrum with your initial document as the backlog....
29,137
<p>When using XmlDocument.Load , I am finding that if the document refers to a DTD, a connection is made to the provided URI. Is there any way to prevent this from happening?</p>
<p>After some more digging, maybe you should set the <a href="http://msdn.microsoft.com/en-us/library/system.xml.xmlreadersettings.xmlresolver.aspx" rel="noreferrer">XmlResolver</a> property of the XmlReaderSettings object to null.</p> <blockquote> <p>'The XmlResolver is used to locate and open an XML instance doc...
<p>Use an <code>XMLReader</code> to load the document and set the <code>ValidationType</code> property of the reader settings to <code>None</code>. </p>
26,533
<p>I can't figure out how to define the default constructor (when it exists overloads) for a type in StructureMap (version 2.5) by code.</p> <p>I want to get an instance of a service and the container has to inject a Linq2Sql data context instance into it.</p> <p>I wrote this in my 'bootstrapper' method :</p> <pre><...
<p>You can specify a constructor with the ConstructedBy(). Please try this:</p> <pre><code>ForRequestedType&lt;MyDataContext&gt;().TheDefault. Is.ConstructedBy(() =&gt; new MyDataContext()); </code></pre> <p>This worked for me. </p>
<p>I'm not sure how / if it can be done with the fluent interface / internal DSL. You can however use an attribute, if you're not fussed about <em>polluting your domain</em>?</p> <p>Tag your preferred constructor with [DefaultConstructor] StructureMap defaults to the greediest constructor by convention (constructor wi...
36,872
<p>I was wondering what are the benefits of using anything else but Java for Mobile Application Development.</p>
<p>Java is the most ubiquitous and for that alone it is your best choice.</p>
<p>The only reason I can think of is that you wouldn't need a Java runtime on the target device.</p> <p>Palm, for instance, allows you to code in C and talk directly to the OS routines in ROM. The C code compiles directly to the machine language without needing a runtime.</p>
16,059
<p>I'm facing weird "pillars" of underextrusion on outer walls of my XYZ test cube.</p> <p>On the pictures below I`ve printed PLA test cubes with a 0.4&nbsp;mm nozzle, 0.2&nbsp;mm height and 210/50&nbsp;&deg;C hotends/bed temperature.</p> <p>Gaps are appearing in walls parallel to both X and Y sides. The pictured sid...
<p>Localized underextrusion usually means you're oozing material somewhere it wasn't supposed to go. Since you have Marlin 2.0, linear advance might help solve that, and in general right retraction amount is important and turning off combing may be needed (combing over infill allows material to ooze).</p> <p>Also ther...
<p>Well, I could not track the problem and it lasted till two major updates:</p> <ol> <li>I have changed rods for ones with proper lenght</li> <li>I have reset all Cura settings to default</li> </ol>
1,591
<p>Could you use a 3D printer to make a 3D printer's parts? What is the most of a 3D printer that can be made this way? Could parts that break be replaced this way?</p>
<p>Yes, you can print most of the parts (electronics, linear guide rails, ball bearings and nuts and bolts, etc cannot be printed). Actually this was exactly the purpose of <a href="https://reprap.org/wiki/RepRap" rel="noreferrer">RepRap.org</a>:</p> <blockquote> <p>RepRap is humanity's first general-purpose self-re...
<p>You can print some of it but not all, as 3d printers can't print metal or silicon to make the boards and frame.</p>
1,154
<p>Is there any way to set a system wide memory limit a process can use in Windows XP? I have a couple of unstable apps which do work ok for most of the time but can hit a bug which results in eating whole memory in a matter of seconds (or at least I suppose that's it). This results in a hard reset as Windows becomes t...
<p>Use Windows <a href="http://msdn.microsoft.com/en-us/library/ms684161(VS.85).aspx" rel="noreferrer">Job Objects</a>. Jobs are like process groups and can limit memory usage and process priority.</p>
<p>Depending on your applications, it might be easier to limit the memory the language interpreter uses. For example with Java you can set the amount of RAM the JVM will be allocated.</p> <p>Otherwise it is possible to set it once for each process with the windows API</p> <p><a href="http://msdn.microsoft.com/en-us/l...
23,436
<p>Is there a way of converting special folder paths to a full file name (and back) or do I need to code my own (not hard I know, but no point if it exists)</p> <p>e.g. I want to store the file name of a template for an application, which the user can then change, it exists in the LocalApplicationData folder.</p> <p>...
<p>Look at: <a href="http://msdn.microsoft.com/en-us/library/system.environment.expandenvironmentvariables.aspx" rel="nofollow noreferrer">Environment.ExpandEnvironmentVariables</a></p> <p>After some looking around I don't think there is a built-in way available to convert it back, though.</p> <p>You can do this thou...
<p>The normal Windows way to identify "special folders" is by their <a href="http://msdn.microsoft.com/en-us/library/bb762494.aspx" rel="nofollow noreferrer">CSIDL</a>. Environment.SpecialFolder is just a small wrapper around it. As you noted, in a comment to chakrit's post, most CSIDLs simply do not have corresponding...
34,171
<p>In the web-application I'm developing I currently use a naive solution when connecting to the database:</p> <pre><code>Connection c = DriverManager.getConnection("url", "username", "password"); </code></pre> <p>This is pretty unsafe. If an attacker gains access to the sourcecode he also gains access to the databas...
<p>You can store the connection string in Web.config or App.config file and encrypt the section that holds it. Here's a very good article I used in a previous project to encrypt the connection string:</p> <p><a href="http://www.ondotnet.com/pub/a/dotnet/2005/02/15/encryptingconnstring.html" rel="noreferrer">http://www...
<p>I can recommend these techniques for .NET programmers: </p> <ul> <li>Encrypt password\connection string in config file</li> <li>Setup trusted connection between client and server (i.e. use windows auth, etc)</li> </ul> <p>Here is useful articles from CodeProject: </p> <ul> <li><a href="http://www.codeproject.co...
6,445
<p>I downloaded the free CodeRush Xpress version to try it. Is there a way to change the colors it uses for it's highlighting and line drawing? ie the matching braces. I have a dark color scheme and my monitor I have VS on must suck because I can't see the lines. Yet on the LCD I can. Is there a way to change the ...
<p>I use <em>CodeRush Xpress 9.2</em>. It is possible to configure some colors used for highlighting in the Options menu of <em>CodeRush Xpress</em>. You can find the menu in <em>Visual Studio</em> under <em>DevExpress</em> -> <em>Options</em>. Go to the <em>Painting</em> sub-item of the <em>Editor</em> item to control...
<p>If you're using a 64bit machine the path will be different: </p> <p><code>HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Developer Express\CodeRush for VS</code></p>
30,841
<p>I found this question, <a href="https://3dprinting.stackexchange.com/questions/10010/laser-is-engraving-the-negative-space">laser is engraving the negative space</a> in the close queue this morning as being off topic. I was about to respond, and through I'd look at the community view on meta. I found this question...
<p><strong>I say allow them.</strong> </p> <p>To let you know what's out there, I work at <a href="http://hyrel3d.com" rel="nofollow noreferrer">Hyrel</a>. </p> <p>Our printers can take <a href="https://www.youtube.com/watch?v=B0lvN-aPYHI" rel="nofollow noreferrer">spindle (milling) heads and additional axes</a>, and...
<p>This is a tricky one, as 3d printers are starting to be bundled with lasers. Note those kits will totally blind you. 3d printers are being bundled with everything, really if you look at the things <a href="http://diabasepe.com/" rel="nofollow noreferrer">http://diabasepe.com/</a> is making. (Cool guys btw)</p> <p>H...
66
<p>This error has been driving me nuts. We have a server running Apache and Tomcat, serving multiple different sites. Normally the server runs fine, but sometimes an error happens where people are served the wrong page - <strong>the page that <em>somebody else</em> requested!</strong></p> <p>Clues:</p> <ul> <li>The ...
<p>Could it be the thread-safety of your servlets?</p> <p>Do your servlets store any information in instance members.</p> <p>For example, something as simple as the following may cause thread-related issues:</p> <pre><code>public class MyServlet ... { private String action; public void doGet(...) { ...
<p>I'm no expert, but could it be some weird <a href="http://en.wikipedia.org/wiki/Network_address_translation" rel="nofollow noreferrer">Network Address Translation</a> issue?</p>
30,605
<p>I'm using Python's Imaging Library and I would like to draw some bezier curves. I guess I could calculate pixel by pixel but I'm hoping there is something simpler.</p>
<p>A bezier curve isn't that hard to draw yourself. Given three points <code>A</code>, <code>B</code>, <code>C</code> you require three linear interpolations in order to draw the curve. We use the scalar <code>t</code> as the parameter for the linear interpolation:</p> <pre><code>P0 = A * t + (1 - t) * B P1 = B * t + ...
<p>I found a simpler way creating a bezier curve (without aggraw and without complex functions). </p> <pre><code>import math from PIL import Image from PIL import ImageDraw image = Image.new('RGB',(1190,841),'white') draw = ImageDraw.Draw(image) curve_smoothness = 100 #First, select start and end of curve (pixels) c...
30,603
<p>What's the story behind our massive repitition of <code>./foo</code> and <code>cd ..</code>. Where do these two <code>.</code> and <code>..</code> come from? Where could they be seen as a way of navigating a file system tree for the first time?</p>
<p>Excerpt from an <a href="http://www.princeton.edu/~hos/mike/transcripts/thompson.htm" rel="noreferrer">interview with Ken Thompson</a> (9-6-89):</p> <blockquote> <p>Every time we made a directory, by convention we put it in another directory called directory - directory, which was dd. Its name was dd and ...
<p>I believe it was invented by Dennis Ritchie at Bell Labs in the early years of Unix.</p>
35,493
<p>I don't develop too many desktop / Windows Forms applications, but it had occurred to me that there may be some benefit to using the MVC (Model View Controller) pattern for Windows Forms .NET development.</p> <p>Has anyone implemented MVC in Windows Forms? If so, do you have any tips on the design?</p>
<p>What I've done in the past is use something similar, <a href="http://download.microsoft.com/download/3/a/7/3a7fa450-1f33-41f7-9e6d-3aa95b5a6aea/MSDNMagazineAugust2006en-us.chm" rel="noreferrer">Model-View-Presenter</a>.</p> <p>[NOTE: This article used to be available on the web. To see it now, you'll need to downl...
<p>Take a look at the MS Patterns and Practices Smart Client application block which has some guidance and classes which walk you through implementing a model view presenter patter in windows forms - take a look at the reference application included.</p> <p>For WPF this is being superseced by the <a href="http://www.c...
14,886
<p>I'm using this query to get all employees of {clients with name starting with lowercase "a"}:</p> <pre><code>SELECT * FROM employees WHERE client_id IN (SELECT id FROM clients WHERE name LIKE 'a%') </code></pre> <p>Column <code>employees.client_id</code> is an int, with <code>INDEX client_id (index_id)</code>. ...
<pre><code>SELECT employees.* FROM employees, clients WHERE employees.client_id = clients.id AND clients.name LIKE 'a%'; </code></pre> <p>Should be more quicker, since the optimiser can choose the most efficient plan. In writing it your way with a sub-query, you're forcing it to do the steps in a certain order ...
<pre><code>select * from X as _x where exists(select * from Y as _y where _y.someField = _x.someField) </code></pre> <p>Should do the trick for you ;)</p>
44,166
<p>With Ender 3 is there a way to configure printer extruder to go all way up when the printing finishes?</p> <p>Or even with the Ultimaker Cura software?</p> <p>I want this, because i'm going to put a switch on the top of the printer that will switch it off when the printer finishes (if i can make the arm with the e...
<p>The most safe way to move the printer up to the maximum print height is to use a concept known as "<strong>keywords</strong>" (sort of constants that are filled by the correct value when slicing) in Ultimaker Cura, certainly if you have multiple printers with different print area sizes.</p> <p>To use these keywords...
<p>If you use OctoPrint, there is a plugin that will allow you to take action on certain events, such as print completion. The action that it can take would allow you to turn of a TP-link smart plug; which would turn off the printer. You could then use the phone app to turn it back on.</p>
1,415
<p>How can I apply an Interface to a form class</p> <pre><code>partial class Form1 : Form, InterfaceA </code></pre> <p>Is this correct?</p> <p>Basically I would like to implement an Interface on a form. How To ....</p>
<p>A Form is just a class (that subclasses System.Windows.Forms.Form), so yes - standard syntax is fine, as you have it.</p> <p>Edit: As to your partial class part of the question, no, you need only declare that you implement the interface once. From MSDN...</p> <blockquote> <p>If any of the parts are declared abs...
<p>When working with partial classes in C#, either:</p> <ul> <li>any declaration with the ':' operator must specify exactly the same baseclass and interfaces </li> <li>specifying baseclass and interfaces on one of the declarations will suffice</li> </ul> <p>To make life easier for yourself, add the interface specs in...
48,060
<p>If you were an asynchronous javascript call in an Asp.Net MVC environment, and you had to work with a round-robin style of load balancer, would you be able to find your way home?</p> <p>edit: adding clarification ..using in-memory session state.</p>
<p>I'd configure my load balancer with stickey sessions to avoid this problem.</p> <p>With sticky sessions, you'll be directed to the same server over and over again during the session.</p>
<p>If your application is stateless, it shouldn't matter. Whether a standard HTTP request or Ajax based request to your server, if your application does not rely on server side state (such as a session), then it shouldn't matter if you hit different servers on subsequent requests.</p> <p><em>Edit</em> - given the que...
48,343
<p>Error message:</p> <blockquote> <p>fatal: git checkout: updating paths is incompatible with switching branches/forcing</p> </blockquote> <p>How to get past this Git checkout error?</p>
<p>By explicitly specifying “<code>git checkout HEAD $blah</code>” instead of just saying “<code>git checkout $blah</code>”, assuming you did want to check out a file.</p> <p>You don’t say what you were trying nor what you typed, however, so no one can give you anything but a blind guess.</p>
<p>When I encounter this message, it is because I have tried to do <code>git checkout -f $blah</code>, expecting to throw away local changes, as described in <code>git checkout --help</code>.</p> <p>Instead, I use <code>rm $blah &amp;&amp; git checkout $blah</code> to throw away local changes.</p>
21,724
<p>A simple question: I have a Model-View-Controller setup, with Models accessing a SQL database. In which part should I sanitize/check for malformed incoming data?</p>
<p>It's important to keep error handling as low as possible in the stack, but supplemental in other parts. If you keep the sanitizing in the controller, you could break the model by swapping out the controller with a looser one, but you can never break the model by being strict higher up in the stack. Keep the sanitizi...
<p>I tend to:</p> <ul> <li><p>Put <em>syntactic</em> validation in the view ("this field is numeric", "that field is a date"). This is often very easy or even implicit in your choice of view design (eg: using a date picker for date fields).</p></li> <li><p>Put <em>semantic</em> violation in a separate validator class ...
48,058
<p>I'm working on a website with a em-based layout (so it can stretch and compress gracefully when users increase or decrease font size). This site has a header that should be displayed across all pages. I have a "header" div in all pages, and the site-wide css file includes the code:</p> <pre><code>#header { wi...
<p>I think the Container above is the "right" choice. It could be also be genericized for type safety. The quick choice in this kind of situation is the final array idiom. The trick is that a any local variables referenced from the Runnable must be final, and thus can't be modified. So instead, you use a single element...
<p>Well, if it's sync you can just have a value holder of some kind external to the <code>run()</code> method.</p> <p>The classic is:</p> <pre><code>final Container container = new Container(); Display display = Display.getDefault(); display.syncExec(new Runnable() { public void run() { container.setValue("fo...
46,228
<p>On an ASP.NET MVC (Beta) site that I am developing sometimes calls to ActionLink will return to me URLs containing querying strings. I have isolated the circumstances that produce this behavior, but I still do not understand why, instead of producing a clean URL, it decides to using a query string parameter. I know ...
<p>Not sure why different views are producing different URLs.</p> <p>But you can get rid of that sortBy param by assigning a default value to the first route.</p> <p>new { sortBy = "" }</p> <p>During generation, if sortBy matches the default, the route engine will skip that parameter (if it's in the query string).</...
<p>I think it is picking up your first Route. It too has the action All. And because the sortby is not specified it is exposing it as a querystring parameter</p> <p>This will still work with the action method 'All' on the PhotosController, because it just fills the sortby parameter with the query string value.</p> <p...
27,736
<p>We are migrationg from CVS to SVN and embracing some kind of revision management in order to enforce order to development/testing/release cycle. We are currently testing, developing and releasing on the same code line, we know its a bad practice and we want to make end to it.</p> <p>What are your experience, know h...
<p>Subversion makes it easier to branch than CVS (in <a href="http://git.or.cz/" rel="nofollow noreferrer">GIT</a> branches are even cheaper). I recommended that you make branches for major revisions, and have a planned merging of the branches back into the trunk. <em>Be vary careful of going long periods of not merg...
<p>A very good resource for source control :</p> <ul> <li><a href="http://www.infoq.com/articles/agile-version-control" rel="nofollow">Agile-Version-Control</a></li> </ul>
20,217
<p>I am writing a simple Python web application that consists of several pages of business data formatted for the iPhone. I'm comfortable programming Python, but I'm not very familiar with Python "idiom," especially regarding classes and objects. Python's object oriented design differs somewhat from other languages I'v...
<p>The empty Record class and the free-floating function that (generally) applies to an individual Record is a hint that you haven't designed your class properly.</p> <pre><code>class Record( object ): """Assuming rtda and pnl must exist.""" def __init__( self ): self.da= 0 self.rt= 0 s...
<p>Using a ORM for an iPhone app might be a bad idea because of performance issues, you want your code to be as fast as possible. So you can't avoid boilerplate code. If you are considering a ORM, besides SQLAlchemy I'd recommend Storm.</p>
14,240
<p>In Cura Slicer, is it possible to change the direction that the filament is laid down when making the top layer?</p> <p><a href="https://i.stack.imgur.com/6AIdx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6AIdx.png" alt="enter image description here" /></a></p> <p>For example, in the above pic...
<p>Yes. Set &quot;Top Surface Skin Layers&quot; (roofing layers) to at least 1 and &quot;Top Surface Skin Line Directions&quot; to 0 or 90 as appropriate (instead of 45 and 135).</p>
<h2>Yes with a few tricks:</h2> <p>You could turn the item by 45°, then all layers are turned to follow the local X and Y-axis of the body itself, but not the global X and Y of the printer - there'll be a 45° conversion between the items local coordinates and the printers global ones.</p> <p>Or you could choose a diffe...
2,084
<p>I have been tasked with finding an open source DOM XML parser. The parser must minimally support XPath 1.0. Schema support is desired, but not a deal breaker</p> <p>The files we are parsing will be small so speed and memory consumption are not a large concern. </p> <p>Any OO language (C++, C#, Java, etc.). </p...
<p>The ever-excellent <a href="http://jaxen.codehaus.org/" rel="nofollow noreferrer">Jaxen</a> may be useful to you here. It's a Java XPath implementation used for both JDom and Dom4J. </p> <p>In refactoring out the common functionality to traverse the two DOM implementations, you now have an XPath engine which can qu...
<p>To answer this question well, I think you need to supply a little more context. Having said that, I am finding that the new Object Model (XElement etc) for Xml in .NET 3.5 supporting Linq to XML makes XML navigation vastly, and I really do mean an order of magnitude, easier and better than using a DOM</p>
48,284
<p>I have created HTTP handlers. </p> <p>How do I create global variables for these handlers like I can with ASP.net web pages in global.asax?</p>
<p>Add the variables to the Application instance:</p> <pre><code>System.Web.HttpContext.Current.Application["MyGlobalVariable"] = myValue; </code></pre> <p>Or, if the variable only need to live for the life of an individual request, use the Context object's Items collection:</p> <pre><code>System.Web.HttpContext.Cur...
<p>If your handler is specified as reusable you can also use static class members.</p>
25,855
<p>Has anyone seen a good twin slider control for .Net (Win forms or WPF).</p> <p>I'm looking for something that will allow me to select a range from within a set so the first slider would be the start of the range and the second would be the end.</p> <p>I remember seeing a Swing double slider but it was 6 years ago ...
<p>Devexpress have a good one: </p> <p>The RangeTrackBarControl control extends the functionality provided by the TrackBarControl enabling end-users to select a range of values. Two sliders can be used to set the minimum and maximum values: </p> <p><a href="http://www.devexpress.com/Help/XtraEditors/img/RangeTrackBar...
<p>For some reason, I cannot comment on the previous answer. DevExpress does not appear to offer any free controls any more; only a free 30-day trial.</p>
20,949
<p>I'm attempting to resize pngs with transparent backgrounds in PHP and the code samples I've found online don't work for me. Here's the code I'm using, advice will be much appreciated!</p> <pre><code>$this-&gt;image = imagecreatefrompng($filename); imagesavealpha($this-&gt;image, true); $newImage = imagecreatetruec...
<p>From what I can tell, you need to set the blending mode to <code>false</code>, and the save alpha channel flag to <code>true</code> <strong>before</strong> you do the imagecolorallocatealpha()</p> <pre><code>&lt;?php /** * https://stackoverflow.com/a/279310/470749 * * @param resource $image * @param int $newWi...
<p>Nor the above solution worked for me. This is the way what i found out to solve the issue.</p> <pre><code>// upload directory $upload_dir = "../uploads/"; // valid image formats $valid_formats = array("jpg", "jpeg", "png"); // maximum image size 1 mb $max_size = 1048576; // crop image width, height $nw = $nh = 800;...
35,273
<p>This snippet works well if I try to write in a user directory but as soon as I try to write in Program Files, it just executes silently and the file has not been copied (no exception). If I try to copy the file in C:\ or in C:\Windows I catch an UnauthorizedAccessException.</p> <p>Do you know another way to get the...
<p>If you are running under Vista then the system just redirects writes to the program files folder, this is done so old program that keep their configuration in the program directory will continue to work when the user is not an Admin (or UAC is enabled).</p> <p>All you have to do is add a manifest to your program th...
<p>Code access security grants or denies permissions to your <em>code</em>. It can't be used to override permissions that are granted/denied to the current user.</p>
19,307
<p>When defining a method on a class in Python, it looks something like this:</p> <pre><code>class MyClass(object): def __init__(self, x, y): self.x = x self.y = y </code></pre> <p>But in some other languages, such as C#, you have a reference to the object that the method is bound to with the "thi...
<p>I like to quote Peters' Zen of Python. "Explicit is better than implicit."</p> <p>In Java and C++, '<code>this.</code>' can be deduced, except when you have variable names that make it impossible to deduce. So you sometimes need it and sometimes don't.</p> <p>Python elects to make things like this explicit rath...
<p>There is also another very simple answer: according to the <a href="http://www.python.org/dev/peps/pep-0020/" rel="nofollow noreferrer">zen of python</a>, "explicit is better than implicit".</p>
9,377
<p>I've seen binary trees and binary searching mentioned in several books I've read lately, but as I'm still at the beginning of my studies in Computer Science, I've yet to take a class that's really dealt with algorithms and data structures in a serious way.</p> <p>I've checked around the typical sources (Wikipedia, ...
<p>Red Black trees are good for creating well-balanced trees. The major problem with binary search trees is that you can make them unbalanced very easily. Imagine your first number is a 15. Then all the numbers after that are increasingly smaller than 15. You'll have a tree that is very heavy on the left side and has n...
<p>If you would like to see how a Red-Black tree is supposed to look graphically, I have coded an implementation of a Red-Black tree that you can <a href="http://brockwoolf.com/redblacktree" rel="nofollow noreferrer">download here</a></p>
4,107
<p>I have a <code>contacts</code> table which contains fields such as <code>postcode</code>, <code>first name</code>, <code>last name</code>, <code>town</code>, <code>country</code>, <code>phone number</code> etc, all of which are defined as <code>VARCHAR(255)</code> even though none of these fields will ever come clos...
<p>In storage, <code>VARCHAR(255)</code> is smart enough to store only the length you need on a given row, unlike <code>CHAR(255)</code> which would always store 255 characters.</p> <p>But since you tagged this question with MySQL, I'll mention a MySQL-specific tip: as rows are copied from the storage engine layer to...
<p>It's good practice to allocate only a little over what you need. Phone numbers would never go this large. </p> <p>One reason is that unless you validate against large entries, no doubt someone will use all there is. Then you might run out of space in your row. I'm not sure about MySQL limit but 8060 is the max ...
32,811
<p>I'm slowly learning Objective-C and Cocoa, and the only way I see so far to capture key events in Text Views is to use delegation, but I'm having trouble finding useful documentation and examples on how to implement such a solution. Can anyone point me in the right direction or supply some first-hand help? </p>
<p>Generally, the way you implement it is simply to add the required function to your view's controller, and set its delegate. For example, if you want code to run when the view loads, you just delegate your view to the controller, and implement the awakeFromNib function.</p> <p>So, to detect a key press in a text vie...
<p>I've done some hard digging, and I did find an answer to my own question. I'll get at it below, but thanks to the two fellas who replied. I think that Stack Overflow is a fantastic site already--I hope more Mac developers find their way in once the beta is over--this could be a great resource for other developers lo...
3,244
<p>I have just installed darcs 2.1.2.2. When I type darcs help, sth less-like shows up. When I dismiss it with q it goes away but I don't get prompt and can't execute any commands. C-c doesn't work either. I am using bash on gentoo.</p>
<p>I have no idea what darcs is, but when bash fails to return to the prompt that some command as part of a pipeline is still running. For instance if you ran:</p> <pre><code>cmd | less </code></pre> <p>And exited less, but cmd did not die from a broken pipe, then cmd would continue to run and bash would continue to...
<p>In this situation (terminal messed up, can't see what you're typing) the "reset" command will often fix things.</p> <p>I would try again with a newer darcs, eg version 2.3 released today. If the problem still happens, you can probably change this behaviour - see the darcs manual. Otherwise, folks on the #darcs irc ...
48,791
<p>I would like to generate some JavaScript on the server side in ASP.Net MVC. Is there a view engine that supports this? Ideally I would like to be able to get JavaScript from an url like: </p> <pre><code>http://myapp/controller/action.js </code></pre> <p>I've looked at the MonoRail project, and they seem to have th...
<p>I wanted to extend this idea to not only allow Javascript views, but more or less any type of document. To use it, you just put the views for *.js urls in a subfolder of your controller's view folder:</p> <pre><code>\Views +-\MyController +-\js | +-Index.aspx &lt;- This view will get rendered if you request /My...
<p>If you just want to generate a javascript based on the ViewData you can create your own custom result. <a href="http://blog.maartenballiauw.be/post/2008/05/13/ASPNET-MVC-custom-ActionResult.aspx" rel="nofollow noreferrer">Here</a> is an example.</p>
45,275
<p>What features of C++ should be avoided in embedded systems?</p> <p>Please classify the answer by reason such as:</p> <ul> <li>memory usage </li> <li>code size</li> <li>speed</li> <li>portability</li> </ul> <p>EDIT: Lets' use an ARM7TDMI with 64k ram as a target to control the scope of the answers.</p>
<p><strong>RTTI and Exception Handling:</strong></p> <ul> <li>Increases code-size</li> <li>Decreases performance</li> <li>Can often be replaced by cheaper mechanisms or a better software-design.</li> </ul> <p><strong>Templates:</strong></p> <ul> <li>be careful with them if code-size is an issue. If your target CPU h...
<p>If you are using a development environment targeted toward embedded development or a particular embedded system, it should have limited some of the options for you already. Depending on the resource capabilities of your target, it will turn off some of the aforementioned items (RTTI, exceptions, etc.). This is the...
14,715
<p>I need to read a properties files that's buried in my package structure in <code>com.al.common.email.templates</code>.</p> <p>I've tried everything and I can't figure it out.</p> <p>In the end, my code will be running in a servlet container, but I don't want to depend on the container for anything. I write JUnit t...
<p>When loading the Properties from a Class in the package <code>com.al.common.email.templates</code> you can use</p> <pre><code>Properties prop = new Properties(); InputStream in = getClass().getResourceAsStream("foo.properties"); prop.load(in); in.close(); </code></pre> <p>(Add all the necessary exception handling)...
<p>use the below code please : <pre> Properties p = new Properties(); StringBuffer path = new StringBuffer("com/al/common/email/templates/"); path.append("foo.properties"); InputStream fs = getClass().getClassLoader() .getResourceAsStream(path.toString());</p> <...
43,208
<p>I have a touch screen kiosk that displays a webpage and a pdf document. Can I remove the menu bar? Users must not have "save", "print" and other such features.</p> <p>Update</p> <p><a href="http://flickr.com/photos/23021917@N05/2209106577/" rel="nofollow noreferrer">random screenshot on flickr</a> - I am refering ...
<p>OK - you should be able to set up most of that in the pdf document itself. </p> <p>This is going from the menus in Acrobat Pro 9: File -> Properties -> Initial View </p> <p>There are some options there for: Hide menu bar, tool bars, window controls</p> <p>This has been around in acrobat for a while, so most v...
<p>Good discussion on using IE7 in Kiosk mode: <a href="http://samanathon.com/internet-explorer-7s-kiosk-mode/" rel="nofollow noreferrer">http://samanathon.com/internet-explorer-7s-kiosk-mode/</a></p> <hr /> <p>If Firefox is on option for you, see this plugin:</p> <blockquote> <p><a href="https://addons.mozilla.org/en-...
25,452
<p>Say each row in a table has data pertaining to one particular user. The user has a password to access the system.</p> <p>How do I encrypt a column of data using InnoDB so that no one other than the user who's data it is can read the data ? I was thinking of something like using one of the MySQL encryption functions...
<p>I don't know if there is much sense in encrypting data with user's password hash, <em>especially</em> if you keep hash itself in the database. In that case anyone who can access the encrypted data can also access the password hash and decrypt the data.</p> <p>Another approach would be to encrypt the data with the a...
<p>I don't think that's the best approach, unless you're enforcing that users can never change their password, or you have a way to re-encrypt everything each time a user changes his/her password.</p>
29,421
<p>I'm looking for an efficient way of searching through a dataset to see if an item exists. I have an arraylist of ~6000 items and I need to determine which of those doesn't exist in the dataset by comparing each item within the arraylist with data in a particular column of the dataset.</p> <p>I attempted to loop th...
<p>Try switching your array list to Generics. From what I understand they are much faster than an array list.</p> <p>Here is a previous SO on <a href="https://stackoverflow.com/questions/94884/generics-vs-array-lists">Generics vs Array List</a> </p>
<p>Get the Dim statements out of the loop.... Your performance is suffering from repeated variable instantiation and reallocation. </p> <p>Also remove any statements you dont need (rowfilter = "")</p> <pre><code>Dim alLDAPUsers As ArrayList Dim DomainUsername As String Dim curStu, maxStu As Integer Dim filteredView A...
30,137
<p>Is C drive treated as the root folder in windows when one says \folder1\folder2\ in linux and windows C:\folder1\folder2.</p>
<p>In Windows it's relative to what drive your current working directory is at the time. If your current directory is in the C drive then C:\ would be the root. If the current directory is the D drive then D:\ would be the root. There is no absolute root.</p>
<p>As a matter of fact, windows has a root folder. The folder, though not visible, is known as 'i386'</p>
18,307
<p>I'm getting an unexpected T_CONCAT_EQUAL error on a line of the following form:</p> <pre><code>$arg1 .= "arg2".$arg3."arg4"; </code></pre> <p>I'm using PHP5. I could simply go an do the following:</p> <pre><code>$arg1 = $arg1."arg2".$arg3."arg4"; </code></pre> <p>but I'd like to know whats going wrong in the fi...
<p>This would happen when $arg1 is undefined (doesn't have a value, was never set.)</p>
<p>sounds like you forgot a semicolon on the line above this one.</p>
20,413
<p>I want to take a look on Fluent NHibernate but unfortunately I cannot find any information on how to build it from the sources. Maybe someone can help me? What tools I need for building it?</p>
<p>The Build.bat file only contains one command, and that is "rake" which is <a href="http://rake.rubyforge.org/" rel="nofollow noreferrer">Ruby Make</a>. This runs rake in the current folder, using the file "rakefile" to build the project.</p> <p>So, you need rake to be able to build using the bat file. If you are us...
<p>I've already built it using VS, so the question is 'which tools I need to build it using the Build.bat file'</p>
44,628
<p>Disclaimer: I'm fairly new to python!</p> <p>If I want all the lines of a file until (edit: and including) the line containing some string <code>stopterm</code>, is there a way of using the list syntax for it? I was hoping there would be something like:</p> <pre><code>usefullines = [line for line in file until sto...
<pre><code>from itertools import takewhile usefullines = takewhile(lambda x: not re.search(stopterm, x), lines) from itertools import takewhile usefullines = takewhile(lambda x: stopterm not in x, lines) </code></pre> <p>Here's a way that keeps the stopterm line:</p> <pre><code>def useful_lines(lines, stopterm): ...
<p>I'd go with <a href="https://stackoverflow.com/questions/337223/python-item-for-item-until-stopterm-in-item#337285">Steven Huwig's</a> or <a href="https://stackoverflow.com/questions/337223/python-item-for-item-until-stopterm-in-item#337279">S.Lott's</a> solutions for real usage, but as a slightly hacky solution, he...
43,754
<p>I'm using Jquery's toggle event to do some stuff when a user clicks a checkbox, like this:</p> <pre><code>$('input#myId').toggle( function(){ //do stuff }, function(){ //do other stuff } ); </code></pre> <p>The problem is that the checkbox isn't being ticked when I click on the checkbox. (All the stuff I've ...
<p>Use the <code>change</code> event instead of the <code>toggle</code> event, like such:</p> <pre><code>$('input#myId').change(function () { if ($(this).attr("checked")) { //do the stuff that you would do when 'checked' return; } //Here do the stuff you want to do when 'unchecked' }); </c...
<p>I did a similar approach but simply using the checked attribute such as</p> <pre><code> //toggles checkbox on/off $("input:checkbox").change( function(){ if(!this.checked){ this.checked=true; } else{ this.checked=false; } } ...
46,357
<p>Dijkstra's <a href="http://en.wikipedia.org/wiki/Shunting_yard_algorithm" rel="noreferrer" title="Wikipedia: Shunting Yard algorithm">Shunting Yard algorithm</a> is used to parse an infix notation and generate <a href="http://en.wikipedia.org/wiki/Reverse_Polish_notation" rel="noreferrer" title="Wikipedia: Reverse P...
<p>Since RPN is also known as postfix notation, I tried googling <a href="http://www.google.com/search?hl=en&amp;q=convert+%22postfix+to+infix%22&amp;btnG=Search" rel="noreferrer">convert "postfix to infix"</a> and got quite a few results. The first several have code examples, but I found the <a href="http://www.rubyq...
<p>If you're not worried about removing redundant parentheses, then the following Lisp code will work:</p> <pre><code>(defun rpn-to-inf (pre) (if (atom pre) pre (cond ((eq (car (last pre)) 'setf) (list (rpn-to-inf (first pre)) '= (rpn-to-inf (second pre)))) ((eq (car (last pre)) 'expt) ...
11,221
<p>I am working on a web application with many images, using ASP.NET MVC. I want to be able to cache the images in memory to improve the performance, but I would like to hear what is the best way to do this. </p> <p>1) The images are accessible from URL, like <a href="http://www.site.com/album/1.jpg" rel="nofollow nor...
<p>Wont the webserver and downstream caches be handling this for static resources anyway? Not sure there's many performance gains to be had, but knowing nothing of the app or setup I could be wrong.</p> <p>To implement I'd setup a page that took an image filename and served it either from disk or from the asp.net in m...
<p>Thanks for the response. I think I was thinking the wrong direction. I just found out Flickr is using Squid to cache images. </p>
23,658
<p>One of the responses to <a href="https://stackoverflow.com/questions/198721/converting-a-word-document-into-usable-html-in-php">a question I asked yesterday</a> suggested that I should make sure my database can handle UTF-8 characters correctly. How I can do this with MySQL?</p>
<p><strong>Update:</strong> </p> <p>Short answer - You should almost always be using the <code>utf8mb4</code> charset and <code>utf8mb4_unicode_ci</code> collation.</p> <p>To alter database:</p> <pre><code>ALTER DATABASE dbname CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; </code></pre> <p>See: </p> <ul> <li><...
<p><code>SET NAMES UTF8</code></p> <p>This is does the trick</p>
24,716
<p>I have developed a Windows CE 4.2 Application in VS 2003. When i deploy the CAB file in the device having X86 has its processor, a short cut for the application is created in Start >> Program >> Application. But I want a short cut for the application on the desktop.</p> <p>I modified the INF file to add a new shor...
<p>I would check out the link: <a href="http://msdn.microsoft.com/en-us/library/ms938387.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms938387.aspx</a></p> <p>That should get you well on your way. Basically shortcuts in CE are just ASCII files of the format:</p> <p>21#\Windows\solitare.exe<...
<p>After modifying the INF file, how did you regenrate the CAB? You must <em>not</em> use the menu item in Studio (can't recall if '03 had that option) as it will overwrite your INF.</p> <p>If you're manually generating the CAB with CABWIZ, then show us your INF file, as you likely have something wrong there.</p>
20,961
<p>This is similar to <a href="https://stackoverflow.com/questions/105212/linux-recursively-list-all-files-in-a-directory-including-files-in-symlink-dire">this question</a>, but I want to include the path relative to the current directory in unix. If I do the following:</p> <pre><code>ls -LR | grep .txt </code></pre> ...
<p>Use find:</p> <pre><code>find . -name \*.txt -print </code></pre> <p>On systems that use GNU find, like most GNU/Linux distributions, you can leave out the -print.</p>
<p>You can implement this functionality like this<br> Firstly, using the ls command pointed to the targeted directory. Later using find command filter the result from it. From your case, it sounds like - always the filename starts with a word <code>file***.txt</code></p> <pre><code>ls /some/path/here | find . -name '...
30,476
<p>I have a incoming stream of bytes (unsigned char) from either a file or network. I need this data placed in a class, and is looking for a NET-way of doing this. </p> <p>I bet some does this all the time, so I guess there is a better method to do this than using BitConverter. </p> <p>I realize I supplied too litle ...
<p>As Jon mentioned, it's not clear, what you need. Maybe you are talking about maybe it is <a href="http://msdn.microsoft.com/en-us/library/72hyey7b(VS.71).aspx" rel="nofollow noreferrer">Binary serialization</a> what you are looking for?</p>
<p>you can use the std::string class. One of its constructors takes char* as an argument so you can go straight from char* to string. and string is a great way of storing your character strings. go to <a href="http://www.cppreference.com/" rel="nofollow noreferrer">http://www.cppreference.com/</a> for more information...
40,451
<p>I have a strange, sporadic issue. </p> <p>I have stored procedure that returns back 5 small tables (e.g. IDs and Text Descriptions for Status drop down lists and such). The code calls this and places the returning dataset into ASP.Net cache. Separate methods are called to retrieve individual tables from the data...
<p>The ASP.NET Cache will only work directly on the objects you insert in it's IEnumerable list. </p> <p>If you add a List&lt;> of objects as one cache item, it will either keep the entire list or it will discard the entire list from cache. It will never go arround the list and remove single items from it. The same sh...
<p>The fact that the DataSet is cached is immaterial.</p> <p>A table can't be removed from a DataSet other than explicitly.</p> <p>You'll have to debug to find out what's going on, logically one of:</p> <ul> <li><p>the table's been explicitly removed from the DataSet</p></li> <li><p>the DataSet was removed from the ...
43,970
<p>I'm tackling project euler's <a href="http://projecteuler.net/index.php?section=problems&amp;id=220" rel="nofollow noreferrer">problem 220</a> (looked easy, in comparison to some of the others - thought I'd try a higher numbered one for a change!)</p> <p>So far I have:</p> <pre><code>D = "Fa" def iterate(D,num):...
<p>Python strings are not going to be the answer to this one. Strings are stored as immutable arrays, so each one of those replacements creates an entirely new string in memory. Not to mention, the set of instructions after 10^12 steps will be at least 1TB in size if you store them as characters (and that's with some m...
<p>You could treat D as a byte stream file.</p> <p>Something like:-</p> seedfile = open('D1.txt', 'w'); seedfile.write("Fa"); seedfile.close(); n = 0 while (n <p>warning totally untested</p>
45,993
<p>There is not official standard dealing with the layout of <strong>about boxes</strong>, which display the credits of a computer software and other information.</p> <p><strong>What should a good about box contain?</strong> <em>And...</em> is it okay to put an <a href="http://en.wikipedia.org/wiki/Easter_egg_(virtua...
<p>Looking at a few examples of About boxes:</p> <ul> <li>Name of the software</li> <li>Name of the publisher/author</li> <li>Copyright and licensing information</li> <li>Version information</li> <li>A nice logo</li> </ul> <p>These days, it probably wouldn't hurt to have a way to directly go to the website for the so...
<p>I tend to add program name, version, company copyright, contact information, license information. I also add various variables for problem resolving. Winows version, servicepack, dll version if i use critical dll's etc. A large application icon. Sometimes I add an easter egg or some keycombo that launch parts of the...
47,856