instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<pre><code>inline int factorial(int n) { if(!n) return 1; else return n*factorial(n-1); } </code></pre> <p>As I was reading <a href="https://rads.stackoverflow.com/amzn/click/com/0201543303" rel="noreferrer" rel="nofollow noreferrer">this</a>, found that the above code would lead to "infinite compilation" if n...
<p>First, the <code>inline</code> specification on a function is just a hint. The compiler can (and often does) completely ignore the presence or absence of an <code>inline</code> qualifier. With that said, a compiler <em>can</em> inline a recursive function, much as it can unroll an infinite loop. It simply has to ...
<p>Some compilers (I.e. Borland C++) do not inline code that contains conditional statements (if, case, while etc..) so the recursive function in your example would not be inlined.</p>
23,083
<p>I'm currently using ImageMagick to determine the size of images uploaded to the website. By calling ImageMagick's "identify" on the command line it takes about 0.42 seconds to determine a 1MB JPEG's dimensions along with the fact that it's a JPEG. I find that a bit slow.</p> <p>Using the Imagick PHP library is even...
<p>If you're using PHP with GD support, you can try <a href="http://www.php.net/manual/en/function.getimagesize.php" rel="nofollow noreferrer">getimagesize()</a>.</p>
<p>If you're using PHP I'd suggest using the Imagick library rather than calling <code>exec()</code>. The feature you're looking for is <a href="http://www.php.net/manual/en/imagick.pingimage.php" rel="nofollow">Imagick::pingImage()</a>.</p>
11,609
<p>I have shell script which starts with:</p> <pre><code>sdir=`dirname $0` sdir=`(cd "$sdir/"; pwd)` </code></pre> <p>And this usually gets expanded (with 'sh -h') into </p> <pre><code>++ dirname /opt/foo/bin/bar + sdir=/opt/foo/bin ++ cd /opt/foo/bin/ ++ pwd + sdir=/opt/foo/bin </code></pre> <p>but for single user...
<p>The culprit is cd, try this instead</p> <pre><code>sdir=`dirname $0` sdir=`(cd "$sdir/" &gt;/dev/null; pwd)` </code></pre> <p>This happens because when you specify a non absolute path and the directory is found in the environment variable CDPATH, cd prints to stdout the value of the absolute path to the directory ...
<p>It's possible that user has some funky alias for "cd". Perhaps you could try making it do "/usr/bin/cd" (or whatever "cd" actually runs by default) instead.</p>
37,913
<p>I'm reading data from a table( from a MySQL Database) with Hibernate SQL Query. The thing is, the table contains a colum that is mapped to a char in Hibernate Model, and sometimes this column is empty. And I suppose this is where my exception comes from. How can I map a colum of char to my hibernate model without ge...
<p>I am assuming from your question that you're mapping this to a primitive character. Next time, please post the stacktrace that you receive (you may leave out where you call it, you could only include the hibernate stuff if your project is too sensitive).</p> <p>If you do map to a primitive character, and it is nul...
<p>Search your JBoss (server) whether <code>mysql.jar</code> (mysql-connector-java-5.1.7-bin) is present in lib files or not. Even I faced the same problem, after adding the <code>mysql.jar</code> file it is working fine.</p>
19,590
<p>I've written a batch execution framework and in it I want (in some scenarios) to load an assembly from the GAC where there may be multiple versions but I just want to load the <em>latest version</em>.<br> Is this even possible?</p> <p>TIA</p>
<p>You should be able to use a publisher policy with a BindingRedirect. See this SO <a href="https://stackoverflow.com/questions/185187/how-to-make-publisher-policy-file-redirect-assembly-request">answer</a>.</p>
<p><a href="http://blog.domaindotnet.com/2008/09/20/fusion_c_sharp_wrapper_for_linq_to_gac_access/" rel="nofollow noreferrer">Linq to Gac</a> can query the GAC. You can <a href="http://msdn.microsoft.com/en-us/library/system.appdomain.load.aspx" rel="nofollow noreferrer">load assembly</a> at runtime once you know what ...
35,925
<p>A program written in Visual C/C++ 2005/2008 might not compile with another compiler such as GNU C/C++ or vice-versa. For example when trying to reuse code, which uses windows.h, written for a particular compiler with another, what are the differences to be aware of?</p> <p>Is there any information about how to prod...
<p>The first thing to do when trying to compile code written for MSVC to other compilers is to compile it with Microsoft-extensions switched off. (Use the /Za flag, I think). That will smoke out lots of things which GCC and other compilers will complain about.</p> <p>The next step is to make sure that Windows-specific...
<blockquote> <p>A program written in Visual C/C++ 2005/2008 might not compile with another compiler such as GNU C/C++ or vice-versa.</p> </blockquote> <p>This is true if you either (1) use some sort of extension available in one compiler but not another (the C++ standard, for instance requires the <code>typename</co...
37,711
<p>I've been doing some work with the JAX-RS reference implementation (Jersey). I know of at least two other frameworks (Restlet &amp; Apache CXF).</p> <p>My question is: Has anyone done some comparison between those frameworks and if so, which framework would you recommend and why?</p>
<p>FWIW we're using Jersey as its packed full of features (e.g. WADL, implicit views, XML/JSON/Atom support) has a large and vibrant developer community behind it and has great <a href="http://www.javakaffee.de/blog/2008/04/21/jersey-spring-integration-mostly-complete/" rel="noreferrer">spring integration</a>. </p> <p...
<p>I would use no framework. Just the one that comes with your applications server. If you use specifics of one framwork you'll lose portability and you'll be in the hell of what if the vendor of the app server includes a different version of your favourite framework. I'll stick to jax-ws.</p>
10,634
<p>If I wanted to work using dates and time going millions of years into the past/future how would I do it in C/C++/C#? </p> <p>For example say I was working on an algorithm to see if a comet was going to hit the earth? Are there commercial or open source libraries that do this?</p> <p>Most DateTime values only work ...
<p>Astronomers use their own calendar, different from the civil, Gregorian calendar.</p> <p><a href="http://scienceworld.wolfram.com/astronomy/JulianDate.html" rel="nofollow noreferrer">Astronomical Julian Dates</a> are what they use.</p> <p>Look at <a href="http://en.wikipedia.org/wiki/Julian_day" rel="nofollow nore...
<p>You just need more bits to store the value and/or use larger increments of time to represent by the timestamp. Instead of ms, do years, then possibly use a math library/API designed for very large numbers if that isn't enough (and depending on your precision requirements) or use floating point.</p>
48,213
<p>We all hear a lot about scaling issues in Rails.</p> <p>I was just curious what the actual costs in handling a HTTP request is in the Rails framework. Meaning, what has to happen for each and every request which comes in? Is there class parsing? Configuration? Database Connection establishment?</p>
<p>That actually depends a lot on which web server you're using, and which configuration you're using, not to mention the application design itself. Configuration and design issues involved include:</p> <ul> <li>Whether you're using fastcgi, old-school cgi, or some other request handling mechanism (affects whether you...
<p>Until the release of Phusion Passenger (aka mod_rails) the "standard" for deployment was not FastCGI but using a cluster of Mongrel servers fronted by Apache and mod_proxy (or Nginx etc).</p> <p>The main issue behind the "Rails doesn't scale" is the fact that there are some quite complicated threading issues which ...
19,443
<p>I have a picture that I need to resize to a specific dimension and then move one of the corner to a place higher than before so the image is not rectangular anymore but some kind of polygon. Is there a library that could help me with this kind of image manipulation or does someone knows the name of this operation?</...
<p><a href="http://www.antigrain.com/" rel="nofollow noreferrer">Anti-Grain Geometry</a> is an interesting graphical library. There is also a .NET wrapper called <a href="http://www.creativedocs.net/devs/agg" rel="nofollow noreferrer">CreativeDocs.NET</a>.</p>
<p>I don't know if it can help for certain but you might want to look at CxImage:</p> <p><a href="http://www.xdp.it/cximage.htm" rel="nofollow noreferrer">http://www.xdp.it/cximage.htm</a></p>
29,682
<p>I've build my WinForm app on windows machine and the app is working ok. When I user nhibernate 1.2.1 the app also worked on linux machine using mono, but now when i upgraded app to nhibernate 2.0.1 it works only in windows. I've get error: NHibernate.InvalidProxyTypeException: The following types may not be used as...
<p>You can try and disable the NHibernate Config proxy validator. it seems to not work with mono.</p> <p>You can do this by adding: <code>&lt;property name="use_proxy_validator"&gt;false&lt;/property&gt;</code> in your app/web.config nhibernate section.</p> <p>For an example config with this property set, see here: ...
<p>This might be of interest:</p> <p><a href="http://softwaredevscott.spaces.live.com/blog/cns!1A9E939F7373F3B7!251.entry" rel="nofollow noreferrer">http://softwaredevscott.spaces.live.com/blog/cns!1A9E939F7373F3B7!251.entry</a></p>
20,892
<p>When requesting hardware for a WebLogic server, what hardware would best improve its performance? Should I give it lots of memory, CPU, fast hard drives? The OS is going to be Redhat 4 either Standard or Enterprise.</p>
<p>Memory is cheap. Give it as much as you can. 4 gigs is what, $50?</p>
<p>That of course depends a lot on what type of applications you run on the server. I know that our WebLogic portal eats quite a lot of memory (10+ gigs) while other apps make due with a lot less.</p>
34,373
<p>Is it possible to cancel out of a long running process in VB6.0 without using DoEvents?</p> <p>For example:</p> <pre><code>for i = 1 to someVeryHighNumber ' Do some work here ' ... if cancel then exit for end if next Sub btnCancel_Click() cancel = true End Sub </code></pre> <p>I assu...
<p>Nope, you got it right, you definitely want DoEvents in your loop.</p> <p>If you put the <code>DoEvents</code> in your main loop and find that slows down processing too much, try calling the Windows API function <code>GetQueueStatus</code> (which is much faster than DoEvents) to quickly determine if it's even neces...
<p>You could start it on a separate thread, but in VB6 it's a royal pain. DoEvents should work. It's a hack, but then so is VB6 (10 year VB veteran talking here, so don't down-mod me).</p>
18,811
<p>I have some data files to import into a database with some "unique" delimiters:</p> <p>Field Separator (FS): SOH (ASCII character 1)</p> <p>Record Separator (RS) : STX (ASCII character 2) +’\n’</p> <p>I'd like to import the files into Postgres using the COPY command but while I can specify a custom field delimite...
<p>Based on the suggestion given by <a href="https://stackoverflow.com/users/7903/patrick-cuff">Patrick</a>, I have been able to do it using Perl:</p> <p>cat file | perl -pe 's/\002\n/\002\002/g' | perl -pe 's/\n/ /g' | perl -pe 's/\002\002/\n/g' </p>
<p>Could you do multiple passes through the file? Pass 1 converts all \002\n to \002\002 say. Pass 2 could convert all the \n to spaces. Pass 3 can convert all the \002\002 to \n.</p>
49,767
<p>does anyone know of a macro or add-on for VS 2008 which reformats xml-comments? There has been this really smart CommentReflower for the older version of VS, but I couldn't find a release supporting VS 2008.</p> <p>Any ideas? Thanks in advance!</p> <p>Matthias</p>
<p>I have used the <a href="http://www.slickedit.com/index.php?option=com_content&amp;task=view&amp;id=389&amp;Itemid=57" rel="nofollow noreferrer">SlickEdit</a> tools in the past to help keep XML comments inline.</p>
<p>I would suggest taking a look at AutoHotKey to create a small script which can do that for you.</p>
11,184
<p>If I have a query to return all matching entries in a DB that have "news" in the searchable column (i.e. <code>SELECT * FROM table WHERE column LIKE %news%</code>), and one particular row has an entry starting with "In recent World news, Somalia was invaded by ...", can I return a specific "chunk" of an SQL entry? K...
<pre><code>select substring(column, CHARINDEX ('news',lower(column))-10, 20) FROM table WHERE column LIKE %news% </code></pre> <p>basically substring the column starting 10 characters before where the word 'news' is and continuing for 20.</p> <p>Edit: You'll need to make sure that ...
<p>If you are using MSSQL you can perform all kinds VB-like of substring functions as part of your query.</p>
32,492
<p>Here's a minimal batch file, <code>demo.bat</code>, to illustrate my problem:</p> <pre><code>@ECHO off set /p foo=Enter foo: echo. echo you typed "%foo%" sqlcmd -? set /p bar=Enter bar: echo. echo you typed "%bar%" </code></pre> <p>I have an input file <code>foo.txt</code> that looks like so:</p> <pre> foo_val...
<p>I can successfully run tests with only the following 6 NUnit files present:</p> <ul> <li>nunit.core.dll</li> <li>nunit.core.interfaces.dll</li> <li>nunit.framework.dll</li> <li>nunit.util.dll</li> <li>nunit.console-runner.dll</li> <li>nunit-console.exe</li> </ul>
<p>For 2.6, in addition to Mooki's list, I had to add:</p> <ul> <li>nunit-agent.exe</li> </ul>
44,473
<p>I have an Excel Spreadsheet like this</p> <pre> id | data for id | more data for id id | data for id id | data for id | more data for id | even more data for id id | data for id | more data for id id | data for id id | data for id | more data for id </pre> <p>Now I want to group the data of one id b...
<p>I use this formula to get the input for a conditional formatting:</p> <pre><code>=IF(B2=B1,E1,1-E1)) [content of cell E2] </code></pre> <p>Where column B contains the item that needs to be grouped and E is an auxiliary column. Every time that the upper cell (B1 on this case) is the same as the current one (B2),...
<p>I use this rule in Excel to format alternating rows:</p> <ol> <li>Highlight the rows you wish to apply an alternating style to.</li> <li>Press "Conditional Formatting" -> New Rule</li> <li>Select "Use a formula to determine which cells to format" (last entry)</li> <li>Enter rule in format value: <strong><code>=MOD(...
4,665
<p>I've been noticing in some of my linear advance test towers that the (very minor/fine) ripple pattern in walls varies with the K factor, which made me think that it isn't coming from any vibration in the print head motion, but rather from quantization of the extruder into discrete steps (i.e. wall gets slightly thic...
<p>Your calculations about the theoretical extruder resolution are spot on. I did a similar calculation to evaluate which extruder to use with different hot ends, I paste the results. The dark cells are the input cells, the rest is calculated. You can see that for some lines I entered directly the mm/microstep value, s...
<h2>Short answer</h2> <p><em>Usually</em> no.</p> <h2>Long answer</h2> <p>There are several big factors that limit how small things you can print. The bigger ones are pretty much:</p> <ul> <li>Positional accuracy and settings (limited by steps/mm in X, Y, Z)</li> <li>Nozzle diameter</li> </ul> <p>Now, why don't you nee...
1,602
<p>I have an application that can list the opened windows of the current session. It uses the EnumWindows method from the user32.dll.</p> <p>I would like to run this code from a windows service, but as the service is not attached to a user session, it returns nothing obviously.</p> <p>So the question is, how can I en...
<p>As far as I'm aware, you can't access the windows of one session from another. It's also worth noting that there's not really any such thing as "the current session" - there may be multiple users logged on through terminal services, or XP's fast user switching.</p> <p>One approach to this would be to add a program ...
<p>The accepted answer is not correct.</p> <blockquote> <p>So the question is, how can I enumerate the open windows of another user session?</p> </blockquote> <p>You can enumerate the open windows of any session if you're running as a service running as the local System account.</p> <p>To do this first enumerate t...
39,680
<p>I have tried to integrate the Picasa API on iphone, compiles fine, but I am seeing the following error in launch.</p> <p>dyld: Library not loaded: @loader_path/../Frameworks/GData.framework/Versions/A/GData Referenced from: /Users/jacksu/Library/Application Support/iPhone Simulator/User/Applications/9A7E3F54-022F...
<p>If you keep the GData.framework, then you need to make sure that it is not a required framework but rather a weak framework. A weak framework means, the app will not require it when first launched and only try to load it when a function call to the framework is referenced, but in your case since the library is stati...
<p>You cannot use dynamic libraries on iPhone (outside of Apple's frameworks, of course). All libraries must be statically linked.</p>
30,940
<p>We have an existing C++ application that we are going to gradually replace with a new Java-based system. Until we have completely reimplemented everything in Java we expect the C++ and Java to have to communicate with each other (RMI, SOAP, messaging, etc - we haven't decided).</p> <p>Now my manager thinks we'll n...
<p>There is <a href="http://laurentschneider.com/wordpress/2008/08/read-uncommitted.html" rel="noreferrer">an example on Laurent Schneider's blog</a> of using the DBMS_XA package inside Oracle to permit multiple sessions to work in the same transaction. So it would be possible to have Java and C++ sessions participati...
<p>I believe JBoss Transaction Manager supports 2pc tx propagation across web service calls. You could, I suppose integrate your systems that way, but the performance would stink.</p>
6,563
<p>How can I dismiss dialog in Cocoa application when user presses Esc or Enter key? I have OK button, is it possible to make it default button?</p>
<p>If you present the alert panel using the <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSAlert_Class/Reference/Reference.html" rel="noreferrer"><code>NSAlert</code></a> class or, <code>NSRunAlertPanel</code> family of functions, or the <code>NSBeginAlertSheet</code> family ...
<p>Just assign the "escapeKey" or "cancelKey" in the IB in the property "key equivalent" for the buttons you want and it will work fine. Also if you assign that keys the buttons gets a different highlighting.</p>
10,340
<p>I've got a really simple rails question here but I can't seem to find the answer anywhere. I guess some of the problems stem from me following a tutorial for Rails 1.2 with Rails 2.1. Anyway..</p> <p>I'm writing a blog system and I'm implementing the comments bit. I have comments displaying fine once I've created t...
<p>Does <code>redirect_to :action =&gt; 'show', :id =&gt; params[:id]</code> with quotes around show work?</p>
<p>yes, you use old rails style.</p> <p>Something new: </p> <pre><code> form_for :comment, :url =&gt; { :post_id =&gt; @post } do |f| f.text_area :body submit_tag "Post" end </code></pre> <p>you can use resources for posts and comments, search google for better tutorial or install rails 1.2.6: </p> <...
27,578
<p>There have been several questions already posted with specific questions about <a href="http://en.wikipedia.org/wiki/Dependency_injection" rel="noreferrer">dependency injection</a>, such as when to use it and what frameworks are there for it. However,</p> <p><strong>What is dependency injection and when/why should ...
<p><strong>Dependency Injection</strong> is passing dependency to other <strong>objects</strong> or <strong>framework</strong>( dependency injector).</p> <p>Dependency injection makes testing easier. The injection can be done through <strong>constructor</strong>. </p> <p><code>SomeClass()</code> has its constructor a...
<p>Any nontrivial application is made up of two or more classes that collaborate with each other to perform some business logic. Traditionally, each object is responsible for obtaining its own references to the objects it collaborates with (its dependencies). <strong>When applying DI, the objects are given their depend...
15,886
<p>I'd like to learn how to program in Assembler. I've done a bit of assembly before (during my A-Level Computing course) but that was very definitely a simplified 'pseudo-assembler'. I've borrowed my Dad's old Z80 Assembler reference manual, and that seems quite interesting so if possible I'd like to have a go with Z8...
<blockquote> <p>I've found a few bits of software that suggest they might do this - but they either refuse to compile, or don't seem to work properly. Has anyone got any suggestions?</p> </blockquote> <p>Write one. You're best off picking a nice, simple instruction set (Z80 should be perfect). I remember doing thi...
<p>Take a look at <a href="http://www.z80.info/z80emu.htm" rel="nofollow noreferrer">Thomas Scherrer Z80 Emulators</a> for a listing of potential emulators you could use.</p>
4,717
<p>I have been given the task of implementing a login handler. The only detail the handler captures is username and password. Initially I was going to use a JSP that posted to a servlet. Where the servlet carried out a db lookup and also validated the user credentials. Upon successful login you are redirected but u...
<p>Security is composed of following aspects:</p> <ol> <li>Authentication</li> <li>Authorization</li> <li>Transport layer security - Encryption</li> </ol> <p>Authentication: - this consists of checking the credentials of the user; most of the times this is implemented through login mechanism. Your task of creating lo...
<p>The simpler method should suffice unless you are doing <em>really</em> <em>really</em> sensitive stuff. Just remember the most important (and simple) bit: keep a password hash in the database, not the real password.</p>
14,582
<ol> <li><p>Is there a open source or free suite that can integrate testcases, tests, bugs and possibly the fixes(source code) together. Maintaining the requirements in this system is not a necessity (though, it would be nice to enter a requirement id for each testcase in a custom field). We are a small organization an...
<p>Use Testlink and integrate it with bug tracker link Mantis.</p> <p>Let me know if you need any help in this.</p>
<p>JIRA has plugins for scanning CVS commit comments, using them to associate source code changes with tracked issues.</p>
17,574
<p>In other words:</p> <ol> <li>Log on as Bert (who is an administrator)</li> <li>Using fast user switching, log on as Ernie (Bert remains logged on)</li> <li>Switch back to Bert</li> <li>Bert logs Ernie off</li> </ol> <p>What is the best way to achieve step 4?</p>
<p><code>sudo launchctl bootout user/$(id -u &lt;username&gt;)</code></p> <p>Replace <code>&lt;username&gt;</code> with the target user's user name.</p>
<p><a href="http://macosx.com/tech-support/mac/force-shutdown-logoff-restart-via-applescript/25909.html" rel="nofollow noreferrer">This forum post</a> has a bash script for OSX that should do the trick. It takes a username as an argument and logs off that user.</p> <p>I've not tried it, so your mileage may vary. But i...
10,452
<p>I have code that references a web service, and I'd like the address of that web service to be dynamic (read from a database, config file, etc.) so that it is easily changed. One major use of this will be to deploy to multiple environments where machine names and IP addresses are different. The web service signatur...
<p>When you generate a web reference and click on the web reference in the Solution Explorer. In the properties pane you should see something like this:</p> <p><img src="https://www.codeproject.com/KB/XML/WSDLDynamicURL/URL_Behavior_Dynamic.GIF" alt="Web Reference Properties"></p> <p>Changing the value to dynamic wi...
<p>open solition explorer</p> <p>right click the webservice change URL Behavior to Dynamic</p> <p>click the 'show all files' icon in solution explorer</p> <p>in the web reference edit the Reference.cs file</p> <p>change constructer</p> <pre><code>public Service1() { this.Url = "URL"; // etc. string variab...
15,242
<p>In <a href="https://3dprinting.stackexchange.com/a/3116/37">this question</a> I was told that I should use silver solder to connect the heating element to the power supply.</p> <p>(I was also told that a ceramic extruder head was the way to go, but I'm working with what I have)</p> <p>I bought two types of silver ...
<p>The first is not suitable. ASTM96TS Sn96Ag4 has a melting point of 221–229&nbsp;&deg;C according to <a href="https://en.wikipedia.org/wiki/Solder" rel="nofollow noreferrer">Wikipedia</a>. Pb96Ag4 would be OK, but that is not lead free so doesn't seem to match your description. <em>Update from comment to explain the ...
<p>Use ferrules to join wires, and on your board either solder directly (it doesn't matter what solder you use because it's not going to get hot if your wires are gauged properly). Or use soft copper wires and clamping terminals without the wires being tinned or risk a fire hazard. </p> <p>Tinning makes the surface h...
482
<p>How to do this in Java - passing a collection of subtype to a method requiring a collection of base type?</p> <p>The example below gives:</p> <pre><code>The method foo(Map&lt;String,List&gt;) is not applicable for the arguments (Map&lt;String,MyList&gt;) </code></pre> <p>I can implement by creating a class hierar...
<p>Change <code>foo</code> to:</p> <pre><code>private void foo(Map &lt;String, ? extends List&gt; in) { } </code></pre> <p>That will restrict what you can do within <code>foo</code>, but that's reasonable. You know that any value you fetch from the map will be a list, but you don't know what kind of value is valid to...
<p>as jon s says:</p> <pre><code>private void foo (Map &lt;String, ? extends List&gt; in { ... } </code></pre> <p>will fix the errors. you will still have warnings though. take a look the get-put principle at: <a href="http://www.ibm.com/developerworks/java/library/j-jtp07018.html" rel="nofollow noreferrer">http://ww...
38,181
<p>What is the initial cost of setting up CruiseControl?</p>
<p>Not more than two to three hours worth if you're new to it. The first time I used it I had something that checked out the latest version from subversion, compiled it using MSBuild and then upload it in less than that time.</p>
<p>How do you define 'cost'? It's free to download so there's no monetary cost.</p> <p>In terms of time it should take between 1/2 - 1 day, depending on how complicated your configuration is.</p>
29,618
<p>If I have two tables... Category and Pet. </p> <p>Is there a way in LINQ to SQL to make the result of the joined query map to a another strongly typed class (such as: PetWithCategoryName) so that I can strongly pass it to a MVC View?</p> <p>I currently have Category and Pet classes... should I make another one?</p...
<blockquote> <p>How would I go about using LoadWith? I'm not finding much help online. Any good resources? </p> </blockquote> <p>I found this online: <a href="http://blogs.msdn.com/wriju/archive/2007/10/04/linq-to-sql-change-in-datacontext-from-beta-1-to-beta-2.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/w...
<p>If you use the LoadWith LoadOption then your Pet query will do an eager load on categories, so that you will be able to do</p> <p>MyPet.Category.Name without incurring an extra query, so you'll have the data joined and strongly typed without the risk of running multiple queries for Categories as you loop or bind on...
22,000
<p>I have created a design with fusion 360. I tried to print it with my M3D Pro printer but it seems the designs have a flaw. </p> <p>If I try to print the bottom part, the second layer is wrong. It seems to have moved to the left by a few centimeters.</p> <p>Here is the link to the <code>.stl</code> files and pictur...
<blockquote> <p>and found out it has a resistance of 1.5kΩ, while it should have a resistance of 4.7kΩ, so I suspect this is the main reason behind this high reading. Now the only thing left to figure out is how the resistance of this resistor changed.</p> </blockquote> <p>You can't measure the resistance of a resis...
<blockquote> <p>and found out it has a resistance of 1.5kΩ, while it should have a resistance of 4.7kΩ, so I suspect this is the main reason behind this high reading. Now the only thing left to figure out is how the resistance of this resistor changed.</p> </blockquote> <p>You can't measure the resistance of a resis...
762
<p>I'm using javax.mail to retrieve mails from GMail using IMAP. I want to also obtain the tags being applied to each mail, so I'm iterating over all the folders in the store (which actually are tags) and downloading mails for each other.</p> <p>I was using the method <a href="http://java.sun.com/products/javamail/jav...
<p>Got the answer from <a href="http://groups.google.com/group/Gmail-Help-POP-and-IMAP-en/browse_thread/thread/17d4d02403b8f77c/ecc0065603bb08bf#ecc0065603bb08bf" rel="nofollow noreferrer">gmail forums</a>: there is a "message-id" header that contains the value I was looking for.</p>
<p>I think the only way is to use a hash that you calculate yourself based on the message headers.</p>
26,991
<p>I've been learning python for a while now with some success. I even managed to create one or two (simple) programs using PyGtk + Glade.</p> <p>The thing is: I am not sure if the best way to use GTK with python is by building the interfaces using Glade.</p> <p>I was wondering if the more experienced ones among us (...
<p>I would say that it depends: if you find that using Glade you can build the apps you want or need to make than that's absolutely fine. If however you actually want to learn how GTK works or you have some non-standard UI requirements you will <strong>have</strong> to dig into GTK internals (which are not that complic...
<p>You may use glade-2 to design, and use <a href="https://gist.github.com/shellexy/0ad0864b7e4e99a0a95d" rel="nofollow">glade2py.py</a> to generating the pure pygtk code, it use pygtkcompat to support gtk3</p>
7,048
<p>I'm not asking about specific implementations, I'm not asking about the global world view of cross site single sign on mechanisms, I just want to know what the community thinks about the underlying usability of OpenID. Do you think using a URL issued by a (to the non-technical observer) random assortment of provider...
<p>Yes.</p> <p>First, choosing a provider is difficult. If I was a less experienced user, I would ask "why do I need to share my information with X to use a site run by Y?" And then, once you get over that, you have to choose who to trust with your information. I, personally, went with Verisign because I trust Verisig...
<p>I think there are aspects of OpenID that pose usability problems for many users, but could probably be resolved via UI improvements. For instance, a <strong>URL</strong> is almost inherently unusable for most users. But there's no reason that can't be abstracted so the user simply chooses their provider and inputs t...
32,933
<p>When running a Jasper report in which the SQL is embedded in the report file (.jrxml), is it possible to see the SQL that is executed? Ideally, I'd also like to see the values that are substituted for each of the $P{} placeholders.</p> <p>Cheers,</p> <p>Don</p>
<p>JasperReports uses the Jakarta Commons Logging API. Commons Logging has a discovery mechanism that connects to logging API you are using in your project. </p> <p>You need to configure logger named "net.sf.jasperreports" in your logging configuration file to control the logging level of JasperReports.</p> <p>If you...
<p>You can adjust your log4j settings to log the running SQL...</p>
25,704
<p>Has anyone used Lucene.NET rather than using the full text search that comes with sql server?</p> <p>If so I would be interested on how you implemented it. </p> <p>Did you for example write a windows service that queried the database every hour then saved the results to the lucene.net index?</p>
<p>Yes, I've used it for exactly what you are describing. We had two services - one for read, and one for write, but only because we had multiple readers. I'm sure we could have done it with just one service (the writer) and embedded the reader in the web app and services.</p> <p>I've used lucene.net as a general data...
<p>I used Lucene.NET along with MySQL. My approach was to store primary key of db record in Lucene document along with indexed text. In pseudo code it looks like:</p> <ul> <li><p>Store record: </p> <p>insert text, other data to the table<br> get latest inserted ID<br> create lucene document<br> put (ID, text) into lu...
5,772
<p>I am considering log-shipping of <a href="http://www.postgresql.org/docs/8.2/static/runtime-config-wal.html" rel="noreferrer">Write Ahead Logs (WAL)</a> in PostgreSQL to create a warm-standby database. However I have one table in the database that receives a huge amount of INSERT/DELETEs each day, but which I don't ...
<p>Unfortunately, I don't believe there is. The WAL logging operates on the page level, which is much lower than the table level and doesn't even know which page holds data from which table. In fact, the WAL files don't even know which pages belong to which <em>database</em>.</p> <p>You might consider moving your high...
<p>I'd consider <a href="http://www.danga.com/memcached/" rel="nofollow noreferrer">memcached</a> for use-cases like this. You can even spread the load over a bunch of cheap machines too.</p>
5,903
<p>Using the GamerServices component for XNA to access Xbox/GfW Live for networking purposes requires developers and players each to have a US$100/year subscription to Microsoft's Creators Club. That's not much of an issue for Xbox360 XNA projects as you need the subscription anyway to be able to put your game on the 3...
<p>Perhaps you could try <a href="http://code.google.com/p/lidgren-network-gen3" rel="nofollow noreferrer">Lidgren</a></p>
<p>Well, you can use sockets, obviously, and using sockets you can create a seperate, dedicated server app, which you can't do with Live (as far as I know). You could also try SteamWorks; I haven't heard of anyone trying that, however.</p>
12,576
<p>Is this even a valid question? I have a .NET Windows app that is using MSTDC and it is throwing an exception:</p> <blockquote> <p>System.Transactions.TransactionManagerCommunicationException: Network access for Distributed Transaction Manager (MSDTC) has been disabled. Please enable DTC for network access in th...
<p>Use this for windows Server 2008 r2 and Windows Server 2012 R2</p> <ol> <li><p>Click <strong>Start</strong>, click <strong>Run</strong>, type <strong>dcomcnfg</strong> and then click <strong>OK</strong> to open <strong>Component Services</strong>.</p></li> <li><p>In the console tree, click to expand <strong>Compone...
<p>MSDTC can be configured with MsDtc PowerShell module, e.g.:</p> <pre><code># Import the module Import-Module -Name MsDtc # Set the DTC config $dtcNetworkSetting = @{ DtcName = 'Local' AuthenticationLevel = 'NoAuth' InboundTransactionsEnabled = $true Out...
2,930
<p>The default rails XML builder escapes all HTML, so something like:</p> <pre class="lang-ruby prettyprint-override"><code>atom_feed do |feed| @stories.each do |story| feed.entry story do |entry| entry.title story.title entry.content "&lt;b&gt;foo&lt;/b&gt;" end end end </code></pre...
<p>turns out you need to do </p> <pre><code>entry.content "&lt;b&gt;foo&lt;/b&gt;", :type =&gt; "html" </code></pre> <p>althought wrapping it in a CDATA stops it working.</p>
<p><a href="http://builder.rubyforge.org/classes/Builder/XmlMarkup.html" rel="nofollow noreferrer">http://builder.rubyforge.org/classes/Builder/XmlMarkup.html</a></p> <blockquote> <p>The special XML characters &lt;, >, and &amp; are converted to &lt;, &gt; and &amp; automatically. Use the &lt;&lt; operation to inser...
13,207
<p>When you are doing integration tests with either just your data access layer or the majority of the application stack. What is the best way prevent multiple tests from clashing with each other if they are run on the same database?</p>
<p>Transactions.</p> <p>What the ruby on rails unit test framework does is this:</p> <pre><code>Load all fixture data. For each test: BEGIN TRANSACTION # Yield control to user code ROLLBACK TRANSACTION End for each </code></pre> <p>This means that</p> <ol> <li>Any changes your test makes to the databas...
<p>I wanted to accept both Free Wildebeest's and Orion Edwards' answers but it would not let me. The reason I wanted to do this is that I'd come to the conclusion that these were the two main ways to do it, but which one to chose depends on the individual case (mostly the size of the database).</p>
8,700
<p>Is there a <strong>JavaScript</strong> equivalent of <strong>Java</strong>'s <code>class.getName()</code>?</p>
<blockquote> <p>Is there a JavaScript equivalent of Java's <code>class.getName()</code>?</p> </blockquote> <p><em><strong>No</strong></em>.</p> <p><strong>ES2015 Update</strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name#Function_names_in_classes" rel="noref...
<p>Use <code>class.name</code>. This also works with <code>function.name</code>.</p> <pre><code>class TestA {} console.log(TestA.name); // "TestA" function TestB() {} console.log(TestB.name); // "TestB" </code></pre>
43,063
<p>I want to track how much traffic I'm getting on an RSS feed that is set up using .Net 2.0 &amp; SQL Server. </p> <p>Is there an industry standard on what metrics I should use, for example, page hits? </p>
<p>Feedburner analysis gives you statistics like: <a href="https://i.stack.imgur.com/o5Mj5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o5Mj5.png" alt="alt text"></a><br> <sub>(source: <a href="http://www.blogperfume.com/feed-analysis/feed-analysis1.png" rel="nofollow noreferrer">blogperfume.com</...
<p>Instead of tracking it yourself, I would encourage you to use a service like <a href="http://www.feedburner.com/" rel="nofollow noreferrer">FeedBurner</a>. Even if you don't want to use a 3rd party service it will give you an idea of what other people track for RSS feeds.</p>
12,093
<p>I'm working on a webservice + AJAX interface, and I'm worried about authentication. This moment I'm passing username and password to the webservice as arguments, but I fear that this approach is highly insecure. I was told that ssl could solve my problem, but I want more alternatives.</p> <p>My webservice is writte...
<p>AJAX request are no different to normal request.</p> <p>Since you have an AJAX interface I guess you can have a page where users log-in. When they log-in store a cookie at the browser. This cookie can then be sent back with every AJAX request. </p> <p>Your PHP script can "authenticate" the AJAX request using the c...
<p>If I'm understanding the question, you have 1) AJAX posts to PHP, 2) PHP calls web service. You should have an SSL certificate for step 1. For step 2, an SSL certificate on the web service machine would also be secure. An alternative would be to set up a secure VPN between the web server and the web service's serve...
41,939
<p>Is there a way to perform a full text search of a subversion repository, including all the history?</p> <p>For example, I've written a feature that I used somewhere, but then it wasn't needed, so I svn rm'd the files, but now I need to find it again to use it for something else. The svn log probably says something ...
<pre><code>git svn clone &lt;svn url&gt; </code></pre> <pre><code>git log -G&lt;some regex&gt; </code></pre>
<p>I came across this <a href="http://www.m0interactive.com/archives/2009/04/23/quick_way_searching_comments_from_svn_using_bash_script.html" rel="nofollow">bash script</a>, but I have not tried it.</p>
6,586
<p>I haven't played with CSS for too long a time and am without references at the moment. My question should be fairly easy but googling isn't bringing up a sufficient answer. So, adding to the collective knowledge...</p> <pre><code>|#header---------------------------------------------------------------| | ...
<p>Its quite a common misconception that you need a <code>clear:both</code> div at the bottom, when you really don't. While foxy's answer is correct, you don't need that non-semantic, useless clearing div. All you need to do is stick an <code>overflow:hidden</code> onto the container:</p> <pre><code>#sub-title { overf...
<p>Something like this perhaps...</p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;style&gt; #container { width:600px; } #head, #sub-title ...
41,895
<p>I have a two-dimensional array (of Strings) which make up my data table (of rows and columns). I want to sort this array by any column. I tried to find an algorithm for doing this in C#, but have not been successful.</p> <p>Any help is appreciated.</p>
<p>Load your two-dimensional string array into an actual DataTable (System.Data.DataTable), and then use the DataTable object's Select() method to generate a sorted array of DataRow objects (or use a DataView for a similar effect).</p> <pre><code>// assumes stringdata[row, col] is your 2D string array DataTable dt = n...
<p>Assuming it is a jagged array, you can use LINQ or Array.Sort() method to sort it.</p> <p><strong>Method 1: Using LINQ</strong></p> <pre><code>var myOrderedRows = myArray.OrderBy(row =&gt; row[columnIndex]).ToArray(); </code></pre> <p>Here, LINQ creates a new IEnumerable which needs to be converted to array (using <...
28,761
<p>Alright, I have been doing the following (variable names have been changed):</p> <pre><code> FileInputStream fis = null; try { fis = new FileInputStream(file); ... process ... } catch (IOException e) { ... handle error ... } finally { if (fis != null) fis.close(); } </code> </pre> <p>Rece...
<p>For Java 7 and above <a href="http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html" rel="noreferrer">try-with-resources</a> should be used:</p> <pre><code>try (InputStream in = new FileInputStream(file)) { // TODO: work } catch (IOException e) { // TODO: handle error } </code></pre>...
<p>Are you concerned primarily with getting a clean report from FindBugs or with having code that works? These are not necessarily the same thing. Your original code is fine (although I would get rid of the redundant <code>if (fis != null)</code> check since an <code>OutOfMemoryException</code> would have been thrown o...
18,934
<p>What compatibility issues have you found when developing with Visual FoxPro 9 on Windows Vista?</p>
<p>My company has no current plans to move to vista, so we haven't tested compatability issues yet. Doug Hennig has an excellent article on the subject however:</p> <p><a href="http://my.advisor.com/articles.nsf/aid/18897" rel="nofollow noreferrer">http://my.advisor.com/articles.nsf/aid/18897</a></p> <p>These links...
<p>Our company found some issues with the Vista Windows color and appearance settings. Evidently FoxPro does not handle the new Vista graphics very well. I believe we fixed these issues by having the users switch back to the Windows "Classic" appearance settings.</p>
27,926
<p>As most of you would know, if I drop a file named app_offline.htm in the root of an asp.net application, it takes the application offline <a href="http://asp-net-whidbey.blogspot.com/2006/04/aspnet-20-features-appofflinehtm.html" rel="nofollow noreferrer">as detailed here</a>.</p> <p>You would also know, that while...
<p>The handling of app_offline.htm is hardcoded in the ASP.NET pipeline, and can't be modified: see <code>CheckApplicationEnabled()</code> in <code>HttpRuntime.cs</code>, where it throws a very non-configurable 404 error if the application is deemed to be offline.</p> <p>However, <a href="http://support.microsoft.com/...
<p>An advantage of app_offline.htm and httpRuntime enable = "False", highlighted in the 1st link in the original question, is that the app domain of the application is no longer loaded, which may be desirable for substantial site changes. A slight modification to leppie's answer (which still serves 404's) is to add a d...
12,618
<p>How do I properly set the default character encoding used by the JVM (1.5.x) programmatically?</p> <p>I have read that <code>-Dfile.encoding=whatever</code> used to be the way to go for older JVMs. I don't have that luxury for reasons I wont get into.</p> <p>I have tried:</p> <pre><code>System.setProperty("file.e...
<p>Unfortunately, the <code>file.encoding</code> property has to be specified as the JVM starts up; by the time your main method is entered, the character encoding used by <code>String.getBytes()</code> and the default constructors of <code>InputStreamReader</code> and <code>OutputStreamWriter</code> has been permanent...
<p>We set there two system properties together and it makes the system take everything into utf8</p> <pre><code>file.encoding=UTF8 client.encoding.override=UTF-8 </code></pre>
47,247
<p>I have a field (say, foo) in a table in a SQL Server database that was originally defined as nullable, but new requirements indicate that this field must be non-null.</p> <p>What's the best way of updating this field to non-null via an update script without deleting the contents of the table? I tried generating a ...
<p>You've got to set a value to any rows with <code>NULL</code> in the <code>NULL</code>able column before you change it to <code>NOT NULL</code>.</p> <pre><code>-- Clean up the data which won't comply with the schema changes UPDATE t SET foo = 0 WHERE foo IS NULL -- Apply the NOT NULL ALTER TABLE t ALTER COLUMN foo ...
<p>You can set a default value to the not-nullable field. If you want to change it from nullable to not-nullable you must provide some value that can be assigned to rows with null value in that field.</p>
38,015
<p>In Toyota manufacturing lines they always know what path a part have traveled. Just so they can be sure they can fix it of something goes wrong. Is this applicable in software too?</p> <p>All error messages should tell me exactly what path they traveled. Some do, the error messages with stack trace. Is this a corre...
<p>A good idea where practicable. Unfortunately, it is usually prohibitively difficult to keep track of the entire history of the state of the machine. You just can't tag each data structure with where you got it from, and the entire state of <em>that</em> object. You might be able to store just the external events and...
<p>This is a good approach. But be aware that you shouldn't over-do logging. Otherwise you couldn't find the interesting informations in all the noise, and it reduces the overall performance (e.g. anonymous object creation, depending on the language).</p>
13,605
<p>How can I convert a RGB Color to HSV using C#?<br/> I've searched for a fast method without using any external library.</p>
<p>Note that <code>Color.GetSaturation()</code> and <code>Color.GetBrightness()</code> return HSL values, not HSV.<br> The following code demonstrates the difference.</p> <pre><code>Color original = Color.FromArgb(50, 120, 200); // original = {Name=ff3278c8, ARGB=(255, 50, 120, 200)} double hue; double saturation; do...
<p>FIRST: make sure you have a color as a bitmap, like this:</p> <pre><code>Bitmap bmp = (Bitmap)pictureBox1.Image.Clone(); paintcolor = bmp.GetPixel(e.X, e.Y); </code></pre> <p>(e is from the event handler wich picked my color!)</p> <p>What I did when I had this problem a whilke ago, I first got the rgba (red, gree...
46,910
<p>So I'm writing a framework on which I want to base a few apps that I'm working on (the framework is there so I have an environment to work with, and a system that will let me, for example, use a single sign-on)</p> <p>I want to make this framework, and the apps it has use a Resource Oriented Architecture.</p> <p>N...
<p>I prefer to use reg ex over making my own format since it is common knowledge. I wrote a small class that I use which allows me to nest these reg ex routing tables. I use to use something similar that was implemented by inheritance but it didn't need inheritance so I rewrote it.</p> <p>I do a reg ex on a key and ...
<p>Try taking look at <a href="http://en.wikipedia.org/wiki/Model-view-controller" rel="nofollow noreferrer">MVC</a> pattern.<br /> Zend Framework uses it for example, but also CakePHP, CodeIgniter, ...</p> <p>Me personally don't like the MVC model, but it's most of the time implemented as "View for web" component.</p...
15,282
<p>I would like to write a program that will identify a machine( for licensing purposes), I tought about getting the following information and to compile an xml file with this data:</p> <ol> <li>MAC address.</li> <li>CPU data (serial, manufacture, etc)</li> <li>MotherBoard Identification. (serial, manufacture, etc)</l...
<p>Using <a href="http://msdn.microsoft.com/en-us/library/aa394582.aspx" rel="nofollow noreferrer">WMI</a> and getting the motherboard's serial number should be enough (the other options are less secure, since an old computer may not have a network adapter and/or the CPU can be changed more likely than the motherboard)...
<p>GetAdaptersInfo() will give you the MAC address. Here's an example of how to use it for this purpose.</p> <pre><code>/** ************************************* return string containing first MAC address on computer NOTE: requires adding Iphlpapi.lib to project */ string GetMac() { char data[4096]; Z...
42,636
<p>The team in which I work has been getting problems with the visual inheritance of the forms in the Java platform.</p> <p>We want to develop a base JFrame with some controls in it and to have inherited forms from that base JFrame. The designer of the Netbeans 6.1 does not paint the controls of the base form in the i...
<p>AFAIK, Matisse is not really designed to create inhereted forms. It is designed for composition (i.e. create a custom JComponent and drop it into your Matisse Form).</p> <p>The form designer does not use the java file to create the form, it uses the "form" file. This does not get inhereted. If you absolutely need t...
<p>Jaguard, you must change the access var control (right-click on control, select 'customize code', see the botton of the window)</p>
39,794
<p>So, I am kinda new to ASP.net development still, and I already don't like the stock ASP.net controls for displaying my database query results in table format. (I.e. I would much rather handle the HTML myself and so would the designer!)</p> <p>So my question is: What is the best and most secure practice for doing th...
<p>I believe you're looking for a <code>&lt;Repeater&gt;</code> control. It contains some functionality similar to the GridViews, but allows you hand-craft all of the HTML for the Header, Item, and Footers yourself. Simply call the databinding code as you would for a gridview, and change the ASPX page to suit your ex...
<p>If you're more interested in hand Coding your HTML, it might be worth looking at the <a href="http://www.asp.net/mvc/" rel="nofollow noreferrer">ASP.NET MVC project</a>. You get a little more control over things than standard WebForms.</p> <p>As an aside, plugging data access code in the Page_Load is never a good ...
9,403
<p>If you have a C# function with Sqlaccess, is it mandatory to close all objects/handles, or is everything cleaned up automatically once you exit the function</p> <p>For example:</p> <pre><code>void DoSqlStuff() { SqlConnection sqlConn = new SqlConnection(...); SqlCommand cmd = new SqlCommand(...); SqlDa...
<p>You should close the SqlConnection object as soon as you're done with it. If you don't then the connection will remain open, and will not be available to handle other requests. </p> <p>The using statement is useful for this. It will call Dispose() on the object for you:</p> <pre><code>using (SqlConnection cn = ...
<p>Any class handling SQL stuff like Connections should implement the IDisposable interface as stated by Microsoft .NET coding guidelines.</p> <p>Thus, you should probably close and dispose your connection in your Dispose method. </p>
42,521
<p>If I change the WCF, do I have to run some sort of update on all client computers that are accessing the service? (i.e. run svutils.exe and update all app.config's etc?)</p>
<p>Read about data contact versioning:</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms731138.aspx" rel="nofollow noreferrer">Data Contact Versioning:</a></p> <p><a href="http://msdn.microsoft.com/en-us/library/ms731083.aspx" rel="nofollow noreferrer">Forward-Compatible Data Contracts</a></p> <p><a href="h...
<p>Not unless the message changes and the change is required to use your service.</p>
27,907
<p>In regular Java, you can get the text of a stack trace by passing a PrintWriter to printStackTrace. I have a feeling I know the answer to this (i.e. "No") but,</p> <p>Is there any way to obtain the text of a stack trace in JavaME as a String?</p> <p><strong>Update:</strong></p> <p>I should mention that I'm restri...
<p>AFAIK there is no way to get the stack trace as a string value, unless a specific platform provides a means to override the default System.err stream. On the BlackBerry platform, it throws out the stack trace on <code>catch(Exception)</code> in order to save memory, however it doesn't do this on <code>catch(Throwabl...
<p>You can have the PrintWriter write to a ByteArrayOutputStream and reconstruct the String from the bytes.</p> <pre><code>try{ throw new Exception("Message"); } catch (Exception ex){ ByteArrayOutputStream out = new ByteArrayOutputStream(); ex.printStackTrace(new PrintStream(out)); System.out.prin...
27,872
<p>I can successfully run my Grails application in Jetty. It succeeds in connecting to my MsSql database and everything is fine. When I deploy that same application in Tomcat 6 on the same machine, I receive the following error on startup in the Tomcat log:</p> <pre><code>Caused by: java.net.ConnectException: Connec...
<p>What does your DataSource.groovy file look like? When you run your app with 'grails run-app', Grails uses the datasource in the "development" section. When you produce a war file with 'grails war' and deploy it to an application server, Grails uses the datasource in the "production" section. You may need to make sur...
<p>What does your DataSource.groovy file look like? When you run your app with 'grails run-app', Grails uses the datasource in the "development" section. When you produce a war file with 'grails war' and deploy it to an application server, Grails uses the datasource in the "production" section. You may need to make sur...
46,647
<p>I have a page results page (you get there after submitting your search query elsewhere) whit a whole bunch of gridviews for different type of data objects.</p> <p>Obviously, some of the queries take longer than the others. How can I make each gridview render as soon as it has the data it needs?</p> <p>This has bee...
<p>@Gareth Jenkins</p> <p>The page will execute all of the queries before returning even the first update panel, so he won't save any time there.</p> <p>The trick to do this is to move each of your complex gridviews into a user control, in the user control, get rid of the Object DataSource crap, and do your binding i...
<p>Could you put the DataGrids inside panels that have their visibility set to false, then call a client-side javascript function from the body's onload event that calls a server side function that sets the visibility of the panels to true?</p> <p>If you combined this with an asp:updateProgress control and wrapped the...
8,425
<p>In VisualStudio (Pro 2008), I have just noticed some inconsistent behaviour and wondered if there was any logical reasoning behind it</p> <p>In a WinForms project, if I use the line</p> <pre><code>if(myComboBox.Items[i] == myObject) </code></pre> <p>I get a compiler warning that I might get 'Possible unintended r...
<p>The compile warning for the first sample is because any custom == operator for your class would be ignored and the references compared (maybe not what you intended, hence the warning).</p> <p>It's not possible to specify that an operator should be overridden on an interface, so this will <em>always</em> be a refere...
<p>Lagerdalek,</p> <p>The warning is generated because you need to cast the item from the Items collection back into the orginal type that was bound to the combo box, before comparing; otherwise you may get unexpected results as the compiler warns.</p> <p>Here is an example:</p> <pre><code>myComboBox.DataSource = Co...
12,395
<p>It seems to me that the key USP of Flash/Silverlight is the ability to provide access (albeit indirectly) to the graphics subsystem of the client, enabling video, smooth transitions and "fancy" visual effects.</p> <p>This sounds like a good idea, and a natural evolution/extension of HTML. But surely it would be bet...
<p>W3C did create another technology, sort of.</p> <p>SVG is a pretty nice vector graphics standard that, combined with scripting, can do a bunch of things Flash can do, but all in plain XML and JavaScript instead of a lump of binary gunge. It's tricky to call this a Flash replacement as it works so very differently, ...
<p>The W3C has no real authority to "take a role" in the development of a proprietary technology. They can only be <strong>given</strong> such a role if the company that owns the technology decides to give it to them, and so far neither Adobe nor Microsoft has done so.</p>
40,181
<p>I have a group by clause in a sql statement and need to use an aggregate function to minus all the values in each group instead of adding like the Sum() function.</p> <p>i.e. </p> <pre><code>SELECT Sum(A) FROM ( SELECT 2 AS A UNION SELECT 1) AS t1 </code></pre> <p>..so will evaluate 2+1 and return 3.</...
<p>How will you identify the item to be subtracted from? </p> <p>Once that's been identified it's a <code>SUM()</code> multiplied by <code>-1</code> and then added to that value.</p> <p><strong>Edit:</strong> </p> <p>If it's the first value to be taken as the subtracted from then take that value, double it, then tak...
<p>SUM() works, as 2+1 == 1+2, whereas 2-1 != 1-2, so such a function would produce different results when the ORDER BY changes, if it were to exist.</p>
35,472
<p>I understand the best way to count the number of rows in an SQL table is count(*) (or equivalently count(PrimaryKey)).</p> <ol> <li>Is this O(1)?</li> <li>If not, why not?</li> </ol> <p>Why not just implement a counter and return it for this specific query? Is it because this query is not a common use case?</p> <...
<p>In <em>some</em> RDBM's this is O(1) (most notably MySQL), put AFAIK it is generally frowned upon and considered an "ugly performance hack". The reasons is that if you have transactions (which every real RDBM should have), the total number of rows in the table might or might not be equal to the total number <em>you ...
<p>A database could store the number of rows in a table and respond O(1) to <code>select count(*) From MyTable</code></p> <p>But, really, what good would that do them? Any variation from that (say <code>select count(*) from MyTable where Category = 5</code>) would require a full table scan (or index scan) and would b...
49,018
<p>StackOverflow user jolson had a very nice piece of code that exemplifies how one can register menthods without using strings, but expression trees <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c#52998">here</a>.</p> <p>Is it possible to have something similar for properties instead of methods...
<p>You can write something along this:</p> <pre><code>static void RegisterMethod&lt;TSelf, TProp&gt; (Expression&lt;Func&lt;TSelf, TProp&gt;&gt; expression) { var member_expression = expression.Body as MemberExpression; if (member_expression == null) return; var member = member_expression.Member; ...
<p>I posted a full example of this <a href="http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/f44dc57a9dc5168d/02c312dcf8a9a769#4805324df6b30218" rel="noreferrer">here</a> (see also the post about "<code>this</code>" underneath it)</p> <p>Note it deals with the <code>LambdaEx...
36,441
<p>We have a process that needs to run every two hours. It's a process that needs to run on it's own thread so as to not interrupt normal processing.</p> <p>When it runs, it will download 100k records and verify them against a database. The framework to run this has a lot of objects managing this process. These obj...
<p>There is not that much difference between the two solutions. I tend to prefer the one where the thread is created each time.</p> <p>Having a thread lying around <strong>consumes resources</strong> (memory at least). In a garbage collected language, it may be easy to have some object retained in this thread, thus us...
<p>I think it's just a matter of taste. Both are good. Use the one which you find easier to implement. :)</p>
44,315
<p>In a digital signal acquisition system, often data is pushed into an observer in the system by one thread. </p> <p>example from <a href="http://en.wikipedia.org/wiki/Observer_pattern" rel="nofollow noreferrer">Wikipedia/Observer_pattern</a>:</p> <pre><code>foreach (IObserver observer in observers) observer.Up...
<p>If you want to have the data source to always be on the safe side of concurrency, you should have at least one pointer that is always safe for him to use. So the Observer object should have a lifetime that isn't ended before that of the data source.</p> <p>This can be done by only adding Observers, but never remov...
<p>You could send a message to all observers informing them the data source is terminating and let the observers remove themselves from the list.</p> <p>In response to the comment, the implementation of the subject-observer pattern should allow for dynamic addition / removal of observers. In C#, the event system is a ...
10,778
<p>I'm new to 3D Printing. I've created this star from Blender3d. As far as I know, most printers require a flat bottom.</p> <p>As you can see (blue line is Z-axis, red line is X-axis, green line Y-axis), the star doesn't have any flat sides or points.</p> <p><a href="https://i.stack.imgur.com/Mh6Bw.png" rel="norefer...
<p>Typical FDM desktop 3D printers might struggle with this model as it requires you to either print large overhangs and use support structure (when printed laying down), or lacks a natural flat bottom surface to get good print adhesion (when printed upright). A couple of suggestions:</p> <ol> <li><p>Some FDM printers...
<p>Typical FDM desktop 3D printers might struggle with this model as it requires you to either print large overhangs and use support structure (when printed laying down), or lacks a natural flat bottom surface to get good print adhesion (when printed upright). A couple of suggestions:</p> <ol> <li><p>Some FDM printers...
313
<p>I’m writing a prototype WCF enabled distributed app, to try and find out any issues I’ll have upgrading my existing “sending xml over tcp to communicate” apps I’ve got. I’m using Callback Contracts to register clients with a server (Singleton in ServiceHost) and so far all the communications between client and serv...
<p>Hmmm... that's a difficult one. The problem here is you can't even make sure both the client and the server timers are in sync.</p> <p>If what you want to do is send some out-of-band data, so that you don't need to modify your methods, you can use the method suggested <a href="http://microsoft.apress.com/asptodayar...
<p>Hmmm... that's a difficult one. The problem here is you can't even make sure both the client and the server timers are in sync.</p> <p>If what you want to do is send some out-of-band data, so that you don't need to modify your methods, you can use the method suggested <a href="http://microsoft.apress.com/asptodayar...
19,356
<p>I am writing a program that will draw a solid along the curve of a spline. I am using visual studio 2005, and writing in C++ for OpenGL. I'm using FLTK to open my windows (fast and light toolkit).</p> <p>I currently have an algorithm that will draw a Cardinal Cubic Spline, given a set of control points, by breaking...
<p>You are correct in forming two vectors from the three points in two adjacent line segments and then using the arccosine of the dot product to get the angle between them. To make use of this angle you need to determine the axis around which the rotation should occur. Take the cross product of the same two vectors to ...
<p>Have you considered <a href="http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/glu/lookat.html" rel="nofollow noreferrer"><code>gluLookAt</code></a>? Put your control point as the eye point, the next point as the reference point, and make the up vector perpendicular to the difference between the t...
34,653
<p>I'm fairly new to ASP.NET and trying to learn how things are done. I come from a C# background so the code-behind portion is easy, but thinking like a web developer is unfamiliar.</p> <p>I have an aspx page that contains a grid of checkboxes. I have a button that is coded via a Button_Click event to collect a list ...
<p>All a usercontrol(.ascx) file is is a set of controls that you have grouped together to provide some reusable functionality. The controls defined in it are still added to the page's control collection (.aspx) durring the page lifecylce. The ModalPopupExtender uses javascript and dhtml to show and hide the controls...
<p>Sorry, but I'm confused. You can't call an ascx directly, so...</p> <p>Is your modal code that you are calling from within the same page, like a hidden panel, etc; </p> <p>Or is it another aspx page that you are calling on a click event?</p>
3,378
<p>I have a component which writes/generates javascript from a server side renderer. This component can be used in multiple times in a same page. However, once the page is loaded I have to collect all the variables or JSO written by this multiple components in the page. How can I do this so that I will have a collectio...
<p>You will need to be a little more specific about your problem, maybe with an example page but here are some thoughts.</p> <p>If you have a server-side component that writes JavaScript during page generation, I would generate a function call each time, something like:</p> <pre><code>Component_appendArray(['First', ...
<p>Although I do not understand the entire scenario, let me suggest that if you are printing out variables throughout the HTML in order to use them after the page loads, that you instead use hidden input fields. I see this often, where variables are used to pass values to a function or a script at the bottom of the pag...
23,844
<p>I am planning to give a Technical presentation for a product we are building. Intended audience is Technical developers. So, most of the time, I will be debugging trough the code in Visual Studio, performance analysis, some architecture review etc.</p> <p>I have read couple of <a href="http://www.hanselman.com/blog...
<p>Put interesting comments in the code.</p> <p>// This better not fail during my next presentation, stupid @#$@#%$ code.</p> <p>Don't talk about them, let them be found by the audience.</p> <p>-Adam</p>
<p>If you use slides at all, follow <a href="http://blog.guykawasaki.com/2005/12/the_102030_rule.html" rel="nofollow noreferrer">Guy Kawasaki's 10/20/30 rule</a>:</p> <ul> <li>No more than 10 slides</li> <li>No more than 20 minutes spent on slides</li> <li>No less than 30 point type on slides</li> </ul> <p>-Adam</p>
8,450
<p>What are my options when it comes to implementing page compression is asp.net.Right now I have a custom home grown httpmodule and its not very mature.</p> <p><strike>Google links me to <a href="http://www.codeplex.com/MbCompression" rel="nofollow noreferrer">MbCompression</a>. The project has few views and download...
<p>There are companies which will translate resource files in the standard formats for fees; I think that's how most large companies do it.</p> <p>I asked a similar question recently <a href="https://stackoverflow.com/questions/185291/best-way-to-design-for-localization-of-strings">here</a> about the best way to struc...
<p>I think it depends on how accessible you want the languages to be, which probably depends very much on what the project is in the first place (professional, hobby, etc)</p> <p>In my hobby work I have the locale-specific strings stored in a simple external JSON file (XML or even a simple INI would work just as well,...
23,072
<p>I am looking for some websites that have <strong>actual</strong> screenshots of web applications, as well as, things like login screens, grids/tables, edit forms, CSS examples and so on.</p> <p>I find that <strong>looking</strong> at other applications helps with the creative process when designing and styling my o...
<p>This one could help: <a href="http://patterntap.com/" rel="nofollow noreferrer">http://patterntap.com</a></p>
<p>Indeed there is! <a href="http://browsershots.org/" rel="nofollow noreferrer">http://browsershots.org/</a> </p> <p>Have fun! :)</p>
47,924
<p>Suppose you're the product manager for an internal enterprise web application that has 2000 users and 7 developers. You have a list of 350 future features, each ranging from 5 to 150 developer days of work.</p> <p>How do you choose what features to work on, and how do you run the release process?</p> <p>Here's wha...
<p>There's a great book that helps cover this topic called <em>Agile Estimating and Planning</em> by Mike Cohn. It has some great ways to estimate and plan releases. Including a planning game called planning poker where the engineering team gets together with cards to estaimate user stories. Each engineer plays a card ...
<p>Surely you don't have 350 <em>independent</em> features, some must depend on others. Put them all into some task management software which allows you to define which tasks depend on which other ones, and you might soon find that you've got a much easier decision process...</p>
36,845
<p>An existing process changes the status field of a booking record in a table, in response to user input.</p> <p>I have another process to write, that will run asynchronously for records with a particular status. It will read the table record, perform some operations (including calls to third party web services), and...
<p>There are several reasons, which were discussed on the Fog Creek forum here: <a href="http://discuss.fogcreek.com/joelonsoftware5/default.asp?cmd=show&amp;ixPost=173704&amp;ixReplies=5" rel="noreferrer">http://discuss.fogcreek.com/joelonsoftware5/default.asp?cmd=show&amp;ixPost=173704&amp;ixReplies=5</a></p> <p>The...
<p>Instead of making raw MSMQ calls, it might be easier if you implement your sevice as a queued COM+ component and make queued function calls from your client application. In the end, the asynchronous service still uses MSMQ in the background, but your code will be much clearer and easier to use.</p>
49,803
<p>I am trying my hardest to define a list of CodeAnalysisRules that should be omitted from the Code Analysis tools when MSBuild executes my TFSBuild.proj file.</p> <p>But each time I test it, my list of Code Analysis Rules to exclude are ignored and Team Build just simply honors the Code Analysis Rules settings for e...
<p>We do this via the Code Analysis Check-in Policy. You can configure this via Team System. To implement, simply choose your rules and then Right Click Solution -> Replace Code Analysis Settings with Check-in Policy.</p>
<p>Well, it took me a while to find this but here is the best answer I could find</p> <p><a href="http://bloggingabout.net/blogs/rick/archive/2007/09/04/howto-disable-specific-code-analysis-rules-for-a-team-build.aspx" rel="nofollow noreferrer">http://bloggingabout.net/blogs/rick/archive/2007/09/04/howto-disable-speci...
35,266
<p>I am working on a project right now that involves receiving a message from another application, formatting the contents of that message, and sending it to a printer. The technology of choice is C# windows service. The output could be called a report, I suppose, but a reporting engine is not necessary. A simple te...
<p>Trust me, you will spend more money trying to search/develop a solution for this as compared to buying a third party component. Do not reinvent the wheel and go for the paid solution.</p> <p>Printing is a complex problem and I would love to see the day when better framework support is added for this.</p>
<p>I think we are going to go the third party route. I like the XSL -> HTML -> PDF -> Printer flow... Winnovative's <a href="http://www.winnovative-software.com/" rel="nofollow noreferrer">HTML to PDF</a> looks good for the first part, but I'm running into a block finding a good PDF printing solution... any suggestion...
2,953
<p>I am setting-up my DataGridView like this:</p> <pre><code> jobs = new List&lt;DisplayJob&gt;(); uxJobList.AutoGenerateColumns = false; jobListBindingSource.DataSource = jobs; uxJobList.DataSource = jobListBindingSource; int newColumn; newColumn = uxJobList.Columns.Ad...
<p>If you want to support sorting and searching on the collection, all <strong>it takes it to derive a class from your BindingList parameterized type</strong>, and override a few base class methods and properties.</p> <p>The best way is to extend the BindingList and do those following things:</p> <pre><code>protected...
<p>Martijn excelent code but only one detail u need to validate null cells or empty :)</p> <pre><code>if (!_customComparisons.TryGetValue(prop.Name, out comparison)) { // Check to see if the property type we are sorting by implements // the IComparable interface. Type interfaceType = prop.PropertyType.GetI...
35,540
<p>I'm trying to use <code>strtotime()</code> to respond to a button click to advance -1 and +1 days (two buttons) relative to the day advanced to on the previous click. </p> <p><strong>Example:</strong> </p> <ul> <li>It's the 10th of the month, I click "-1 day" button, and now the date reads as the 9th. </li> <li...
<p>Working from previous calls to the same script isn't really a good idea for this type of thing.</p> <p>What you want to do is always pass two values to your script, the date, and the movement. (the below example is simplified so that you only pass the date, and it will always add one day to it)</p> <p>Example</p> ...
<p>After a moment of inspiration, the solution to my question became apparent to me (I was riding my bike). The '$now' part of </p> <pre><code>strtottime( string $time {,int $now ]) </code></pre> <p>needs to be set as the current date. Not "$time()-now", but "the current date I'm concerned with / I'm looking at m...
3,015
<p>I am programming a game on the iPhone. I am currently using NSTimer to trigger my game update/render. The problem with this is that (after profiling) I appear to lose a lot of time between updates/renders and this seems to be mostly to do with the time interval that I plug into NSTimer. </p> <p>So my question is...
<p>You can get a better performance with threads, try something like this:</p> <pre><code>- (void) gameLoop { while (running) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [self renderFrame]; [pool release]; } } - (void) startLoop { running = YES; #ifdef THREADE...
<p>Use the CADisplayLink, you can find how in the OpenGL ES template project provided in XCODE (create a project starting from this template and give a look to the EAGLView class, this example is based on open GL, but you can use CADisplayLink only for other kind of games</p>
12,186
<p>I first got an error usign the code below, explaining that "DataGridLinkButton' must be placed inside a form tag with runat=server."</p> <p>Now I've tried setting AllowSorting to false, as well as removing the sort expression from each column, with the same error. Then I tried creating a new, plain, DataGrid, with...
<p>Add the following empty method to your code. That should fix it. </p> <pre><code>public override void VerifyRenderingInServerForm(Control control) { } </code></pre>
<p>public override void VerifyRenderingInServerForm(Control control) { }</p> <p>more help look on<br> <a href="http://techdotnets.blogspot.com/" rel="nofollow noreferrer">http://techdotnets.blogspot.com/</a></p>
15,492
<p>I have a std::multimap where key is a custom class. Something like this:</p> <pre><code>Class X { public: std::string s; int x; operator &lt;(const X&amp; other) const { return s &lt; other.s; } }; std::multimap&lt;X, int&gt; mymap; </code></pre> <p>Now, I'd like to use upper_bound and lower_bound to i...
<p>Since <code>class X</code> is the key for the multimap, the parameter to <code>upper_bound()</code>/<code>lower_bound()</code> needs to be of that type. If <code>class X</code> has an implicit conversion from <code>std::string</code> (which is the type of <code>X::s</code>) then you can use that as the parameter to...
<p>you only need to provide an operator == and &lt;.</p> <p>upper_bound and lower_bound are just like any other find-type method, so you need the same kind of object to compare with - in your case, a 'dummy' object with the required value of s.</p> <p><strong>edit</strong>: the comments are correct that you only need...
26,509
<p>I have a requirement to allow a user of this ASP.NET web application to upload a specifically formatted Excel spreadsheet, fill arrays with data from the spreadsheet, and bind the arrays to a Oracle stored procedure for validation and insertion into the database. I must be able to read the data from the Excel sprea...
<p>I found a great lightweight open source API on Codeplex for doing this called ExcelDataReader. </p> <p>It can transform an input stream of an excel file into a <code>System.Data.DataSet</code> object (probably parsing using BIFF specs). </p> <p>Here's the link:</p> <blockquote> <p><a href="http://www.codeplex....
<p>Could you have your users upload a CSV file instead? Dealing with a plain text file would be much easier. I had a similar issue before and I asked the users and they were OK, saved me tons of work.</p> <p>Good luck.</p>
32,828
<p>How do I set a variable to the result of select query without using a stored procedure? </p> <hr> <p>I want to do something like: OOdate DATETIME</p> <pre><code>SET OOdate = Select OO.Date FROM OLAP.OutageHours as OO WHERE OO.OutageID = 1 </code></pre> <p>Then I want to use OOdate in this query:</p> <pre><code...
<p>You can use something like</p> <pre><code>SET @cnt = (SELECT COUNT(*) FROM User) </code></pre> <p>or</p> <pre><code>SELECT @cnt = (COUNT(*) FROM User) </code></pre> <p>For this to work the SELECT must return a single column and a single result and the SELECT statement must be in parenthesis.</p> <p><strong>Edit...
<p>What do you mean exactly? Do you want to reuse the result of your query for an other query? </p> <p>In that case, why don't you combine both queries, by making the second query search inside the results of the first one <code>(SELECT xxx in (SELECT yyy...)</code></p>
20,529
<p>Does anyone know of an application (hosted or otherwise) that I could use to keep track of details for a number of web sites? I manage 50+ web sites that range from custom solutions to open source platforms (WordPress, Joomla). I started to write my own but wanted to see if there is anything out there already.</p>...
<p>You could use either Backpack or Highrise from <a href="http://37signals.com" rel="nofollow noreferrer">37 Signals</a> to track each project individually (e.g. creating tasks, milestones, notes, even documentation using writeboard). These are more of project managers and intranet-type software, so I'm not sure if th...
<p>I don't know of any specific application that does what you're describing. However, Joomla! has a email-based release notification system set up that you could hook into: <a href="http://www.joomla.org/download.html" rel="nofollow noreferrer">http://www.joomla.org/download.html</a></p> <p>There should be an RSS fee...
39,122
<p>What is the best way to unit test a method that calls into multiple methods, for example:</p> <pre><code>modify(string value) { if(value.Length &gt; 5) replaceit(value); else changeit(value); } </code></pre> <p>This pseudo code has a modify method that (currently) calls either <code>replaceit()</code> or...
<p>This is a classic state-based test vs. behavior-based test scenario.</p> <p>In this ridiculously simple example testing the output is fine. At some point though, you'll run into tests where inspecting the state after execution is complicated. Instead you want to check the behavior (e.g. verify that changeit was ca...
<p>Same as Justin Standard, <em>plus</em> passing <code>null</code> as value (which obviously will fails for the code snippet you give us ;)) Basic rule for Unit testing is "test only what is specific to the method under test". And it quite ... uncommon to have a method that doesn't call another one.</p>
47,470
<p>We have a number of users with Windows Mobile 6 and need to apply minor changes. eg. update a registry setting. One option is push and execute an executable file using our device management software.</p> <p>I'd like this to be a little more friendly for the admins who are familiar with scripting in VBScript/JScript...
<p>I work on windows mobile full time and have never really come across a good Windows Mobile scripting implementation unfortunately. For some reason MS has never seen the need for it. For example, even though you can actually get a command console on WM, it does not support running batch files, even though all the c...
<p>There is also a <a href="http://www.cebeans.com/" rel="nofollow noreferrer">Visual Basic Runtime</a> to run VBScript</p>
4,844
<p>What would be the easiest way to be able to send and receive raw network packets. Do I have to write my own JNI wrapping of some c API, and in that case what API am I looking for?</p> <p>EDIT: I want to be able to do what wireshark does, i.e. record all incomming packets on an interface, and in addition be able to ...
<p>If you start with the idea that you need something <em>like</em> a packet sniffer, you'll want to look at <a href="http://netresearch.ics.uci.edu/kfujii/jpcap/doc/" rel="nofollow noreferrer">http://netresearch.ics.uci.edu/kfujii/jpcap/doc/</a>.</p>
<p><a href="http://www.maxim-ic.com/products/microcontrollers/tini/" rel="nofollow noreferrer">TINI</a> is a java ethernet controller, which may have libraries and classes for directly accessing data from ethernet frames to TCP streams. You may be able to find something in there that implements your needed classes. If ...
6,124
<p>Is there any way to increase the heap size for Java ME on a device? I'm developing an application for a Nokia N95, but am bumping into memory issues when I try to do image processing of larger images. The phone has plenty of heap space available, but seems to restrict the amount allowed to be used by Java ME to 1M...
<p>Short answer: No.</p> <p>Longer answer: Heap-size is hardcoded in device VM. If you are running out of memory you need to split you task into more smaller sub tasks to allow GC to kick in. With limited memory only limited operations are possible. You figure...</p>
<p>On some J2ME handsets setting Midlet-Heap-Size jad attributes works. Say a handset has only 2MB heap, setting this jad attribute to say 3MB increases the Heap to 3MB. You can try this out, it worked on very few handsets for me though.</p>
45,285
<p>Making a small app, and I want a function to execute 50% of the time. So if I were to dbl click the exe half the time the function would execute, and the other half it wouldn't. I can't seem to find anyway to easily do this, the one solution I tried seemed to determine the chance on compile rather than on run. Th...
<p>Generate a random decimal number between 0 and 1. If it is greater than 0.5 run, if it is less than or equal to 0.5 do not run. </p>
<p>If you want it to randomly run, others have already provided that solution. If you want a more deterministic behavior (it must run exactly every second time), you will need to store state between executions.</p> <p>You can save the state in either the registry or on the file system by (for example) attempting to r...
29,196
<p>As an extension from <a href="https://3dprinting.stackexchange.com/questions/264/when-to-use-1-75mm-vs-3mm-filament">this</a> question, is there any reason that you would not be able to use 1.75&nbsp;mm filament in a printer that takes 3mm filament? I know you would have to change the filament size in the slicing o...
<p>Typically an extruder and hot end are designed for one or the other, and cannot support the other without mechanical changes.</p> <p>The extruder may not be able to grip a smaller diameter filament with enough force to assure even feeding and retraction.</p> <p>The hot end, however, is much more complex. The filam...
<ol> <li><p>It may work for a short time but you're going to fill the melt chamber quickly and possibly overflow to a point where the filament isn't constrained causing a messy jam. All the molten plastic will likely flow backwards to a point where the diameter isn't 3mm any longer (probably next to your drive gear) b...
145