instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I'm a big fan of the Jadclipse plugin and I'd really like to upgrade to Eclipse 3.4 but the plugin currently does not work. Are there any other programs out there that let you use jad to view source of code you navigate to from Eclipse? (Very useful when delving into ambiguous code in stack traces).</p>
<p>I'm successfully using JadClipse with Eclipse 3.4</p> <p>Eclipse 3.4.0.I20080617-2000<br> JadClipse 3.3.0 </p> <p>It just works!</p> <p>EDIT: Actually, see <a href="https://stackoverflow.com/questions/122110/is-there-a-way-to-get-jadclipse-working-with-eclipse-3-4/224779#224779">OlegSOM's answer</a> below for th...
<p>I was just able to successfully install jadclipse with Ganymede. In order to do this I: 1) Installed via the help-> software updates <a href="http://webobjects.mdimension.com/jadclipse/3.3" rel="nofollow noreferrer">http://webobjects.mdimension.com/jadclipse/3.3</a></p> <p>2) Put the Jad executable into a director...
14,846
<p>At home we have a proxy server. At work we don't. Firefox irritates in this regard: whenever I launch it, it defaults to the proxy server. If I do Tools>Options>Settings and select "No proxy", no problem. However, if I shutdown Firefox and restart it, I have to do the Tools>Options>Settings thing all over again beca...
<p>Use <a href="http://foxyproxy.mozdev.org/" rel="nofollow noreferrer">FoxyProxy</a>, much more flexible to configure</p>
<p>I used a local automatic proxy configuration script for years with great success. The trick was identifying from the URL or IP address where I was.</p> <p>/Allan</p>
9,496
<p>I think in this case there is no need to declare a public constructor since the class is not accessible outside the package anyway. But is there some hidden impact when the class has only package private constructor?</p>
<p>No, you don't have to declare the public constructor; package private constructors will be just as usable. Classes outside the package wouldn't be able to use the constructor anyway, since they can't see the class.</p>
<p>If your class is package private then the access levels indicated by the modifier keyword <code>public</code> together with the default <em>package private</em> access level of the constructor are equivalent.</p> <p>You can however indicate the behavior you intent the method to have in case the class visibility is ...
30,128
<p>I need WCF service with 3 endpoints </p> <ol> <li>High</li> <li>Normal</li> <li>Low</li> </ol> <p>Most of messages will come through Normal and Low Endpoints. If Message on High will appear it have to be processed asap.</p> <p>Does anyone knows how to do it ???</p>
<p>Why not run two separate endpoint processes, one for low/normal and a separate one for high. You could even locate it on separate (better?) hardware if you have the capacity. Otherwise if you have to do it in a single process, then a Priority Queue seems to me what you'll need.</p>
<p>I guess you'll have to implement that priority yourself.</p> <p>If a high priority comes in you'll have to stop everything else (save its state or something) and start doing whatever it is that needs to be done.</p> <p>just a thought</p>
22,193
<p>I have a class which implements UserControl. In .NET 2005, a Dispose method is automatically created in the MyClass.Designer.cs partial class file that looks like this:</p> <pre><code> protected override void Dispose(bool disposing) { if (disposing &amp;&amp; (components != null)) { components....
<p>In such a case I move the generated <code>Dispose</code> method to the main file and extend it. Visual Studio respects this.</p> <p>An other approach would be using a partial method (C# 3.0).</p>
<p>there is a Unloaded event for the UserControl that you can use to clean up,</p>
20,245
<p>I was wondering if in Java I would get any odd behaviour if I synchronise twice on the same object?</p> <p>The scenario is as follows</p> <pre><code>pulbic class SillyClassName { object moo; ... public void method1(){ synchronized(moo) { .... method2(); ...
<h1>Reentrant</h1> <p>Synchronized blocks use <em>reentrant</em> locks, which means if the thread already holds the lock, it can re-aquire it without problems. Therefore your code will work as you expect.</p> <p>See the bottom of the <a href="https://docs.oracle.com/javase/tutorial/index.html" rel="noreferrer">Java Tut...
<p>No, the second method will not stop if called by the first. No odd results will occur (Except a slight overhead for checking the lock. This won't matter much. From Java 6 onwards, you have lock coarsening in the JVM - <a href="https://www.oracle.com/java/technologies/javase/6performance.html" rel="nofollow noreferre...
31,080
<p>It is connected to BI and merging of data from different data sources and would make that process more smooth.</p> <p>And is there an optimal migration strategy from a database without Guids to a version with Guids without information losses?</p>
<p>Edited after reading Frans Bouma's answer, since my answer has been accepted and therefore moved to the top. Thanks, Frans.</p> <p>GUIDs do make a good unique value, however due to their complex nature they're not really human-readable, which can make support difficult. If you're going to use GUIDs you might want...
<p>I used to not like GUID at all, but I've grown to love it. I love it because it is relatively uniform and adopted, and I end up writing less code by using it, and maintaining that code, than I would normally write and maintain.</p> <p>It is especially useful for storage of files, where you need to guarantee that a...
47,276
<p>I'm finding myself writing a bunch of related functions dealing with different nouns (clusters, sql servers, servers in general, files, etc.) and put each of these groups of functions in separate files (say cluster_utils.ps1, for example). I want to be able to "import" some of these libraries in my profile and othe...
<p>Building on <a href="https://stackoverflow.com/questions/279974/importing-libraries-in-powershell#282098">Steven's answer</a>, another improvement might be to allow loading multiple files at once:</p> <pre><code>$global:scriptdirectory = 'C:\powershellscripts' $global:loaded_scripts = @{} function require { para...
<p>I think you'll find the "modules" functionality of PowerShell v2 to be very satisfying. Basically takes care of this for you.</p>
35,391
<p>I'm running a SQL query on SQL Server 2005, and in addition to 2 columns being queried from the database, I'd also like to return 1 column of random numbers along with them. I tried this:</p> <pre><code>select column1, column2, floor(rand() * 10000) as column3 from table1 </code></pre> <p>Which kinda works, but t...
<p>I realize this is an older post... but you don't need a view.</p> <pre><code>select column1, column2, ABS(CAST(CAST(NEWID() AS VARBINARY) AS int)) % 10000 as column3 from table1 </code></pre>
<p>You need to use a UDF</p> <p>first:</p> <pre><code>CREATE VIEW vRandNumber AS SELECT RAND() as RandNumber </code></pre> <p>second:</p> <pre><code>CREATE FUNCTION RandNumber() RETURNS float AS BEGIN RETURN (SELECT RandNumber FROM vRandNumber) END </code></pre> <p>test:</p> <pre><code>SELECT dbo.RandNumber...
12,049
<p>In VB.NET, which is better to use: function overloading or default parameters?</p>
<p>if the parameters are optional (i.e. the overloads are a subset of the parameters that the full procedure signature accepts) then default or optional parameters would make more sense.</p> <p>If the overload is allowing a different type for the parameter or is a semantically different parameter that will be interpre...
<p>FYI</p> <p>If you want to add a parameter to a function or method that is called from other assemblies, then:</p> <p>You can overload by making an additional function with the extra parameter.</p> <p>Or you can add an optional parameter, BUT: You have to recompile all of the assemblies that call this function, ev...
39,115
<p>I am working on a small intranet site for a small company, where user should be able to post. I have imagined a very simple authentication mechanism where people just enter their email address, and gets sent a unique login url, that sets a cookie that will always identify them for future requests.</p> <p>In my temp...
<p>There is <strong>no need</strong> to write a context processor for the user object if you already have the <a href="https://docs.djangoproject.com/en/dev/topics/auth/default/#authentication-data-in-templates" rel="noreferrer"><code>"django.core.context_processors.auth"</code></a> in <a href="https://docs.djangoproje...
<p>Use context_processors. <a href="https://docs.djangoproject.com/en/2.2/ref/settings/#std:setting-TEMPLATES-OPTIONS" rel="nofollow noreferrer">https://docs.djangoproject.com/en/2.2/ref/settings/#std:setting-TEMPLATES-OPTIONS</a></p> <blockquote> <p>settings.py</p> </blockquote> <pre><code>'OPTIONS': { 'co...
6,286
<p>I am currently working on a project with specific requirements. A brief overview of these are as follows: </p> <ul> <li>Data is retrieved from external webservices</li> <li>Data is stored in SQL 2005</li> <li>Data is manipulated via a web GUI</li> <li>The windows service that communicates with the web services ha...
<p>Why not use a SQL Job instead of the Windows Service? You can encapsulate all of you db "trigger" code in Stored Procedures. Then your UI and SQL Job can call the same Stored Procedures and create the triggers the same way whether it's manually or at a time interval.</p>
<p>The way I see it is this.</p> <p>You have a Windows Service, which is playing the role of a scheduler and in it there are some classes which simply call the webservices and put the data in your databases.</p> <p>So, you can use these classes directly from the WebUI as well and import the data based on the WebUI tr...
2,545
<p>I usually store my connectionstring in web.config or in the application settings of my Visual Studio project. The application I'm currently working on makes a lot of trips to the database which means it will look up the connectionstring every time. Should I be putting the connectionstring in the cache or should I be...
<p>I wouldn't cache the connection object, that will defeat the built-in connection pooling -- ADO.NET will handle connections (assuming you instantiate and close them) efficiently by itself.</p> <p>As far as the connection string itself, you shouldn't need to cache it if you load it from connection -- the connection ...
<p>Keep it in a configuration file. Use a robust data access strategy provided by tools like NHibernate or Linq to Sql.</p>
6,235
<p>I am using <code>GridView</code> in my application for populating datas. </p> <p>Is there any easy way to copy a gridview to datatable ?</p> <p>Actually, in my <code>GridView</code> one of the control is textbox.<br> So I can edit that control at any time... What I need is on the button click whatever changes I ma...
<p>The preferable way would be to use data binding. If you manage to get bidirectional data binding to work, your DataTable is updated automatically.</p> <p>Performance wise, you would probably get best speed out of a dynamically generated table where your textboxes have an Id that you can interpret easily on the post...
<p>The preferable way would be to use data binding. If you manage to get bidirectional data binding to work, your DataTable is updated automatically.</p> <p>Performance wise, you would probably get best speed out of a dynamically generated table where your textboxes have an Id that you can interpret easily on the post...
41,807
<p>I've been asked to come up with a grant proposal for a new 3D printer. My question is:</p> <blockquote> <p>What supporting components and training would be most beneficial to support educational use in a K-8 school? In other words what things am I missing in my list below? </p> </blockquote> <p>Specific suggesti...
<p>Typically the black pigments in polymers are mineral based. If you are having true WiFi issues then it sounds like your filiment is using black iron oxide also called <a href="https://en.wikipedia.org/wiki/Magnetite" rel="nofollow noreferrer">magnetite</a> for the black pigment. This is the same material they use in...
<p>Typically the black pigments in polymers are mineral based. If you are having true WiFi issues then it sounds like your filiment is using black iron oxide also called <a href="https://en.wikipedia.org/wiki/Magnetite" rel="nofollow noreferrer">magnetite</a> for the black pigment. This is the same material they use in...
1,263
<p>First of all, I'm fairly sure snapping to grid is fairly easy, however I've run into some odd trouble in this situation and my maths are too weak to work out specifically what is wrong.</p> <p>Here's the situation</p> <p>I have an abstract concept of a grid, with Y steps exactly Y_STEP apart (the x steps are worki...
<p>Ok, I'm answering my own question here, as alexk mentioned, using int to truncate was my mistake. </p> <p>The behaviour I'm after is best modeled by math.floor().</p> <p>Apologies, the original question does not contain enough information to really work out what the problem is. I didn't have the extra bit of inf...
<p>Do you have a typo in positionChanged() ?</p> <pre><code>def positionChanged(self, newPos): self.snappedPos = snapToGrid(newPos, Y_OFFSET, Y_STEP) </code></pre> <p>I guess you are off by one pixel because of the accuracy problems during float division. Try changing your snapToGrid() to this:</p> <pre><code>de...
14,433
<p>I have a server dropdownlist in an <a href="http://en.wikipedia.org/wiki/Ajax_%28programming%29" rel="noreferrer">Ajax</a> updatepanel. When I use the mouse to click on an item it fires the postback but when I click the up/down arrow to change entries, this is not firing. What could be reason?</p>
<p>Try this:</p> <pre><code>&lt;asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" onKeyUp="this.blur();"&gt; </code></pre> <p>With <strong>onKeyUp="this.blur();"</strong> the control will lose focus when a key is unpressed, and that wil...
<p>I think you have to leave the control if you are using the keyboard in order to fire the event.</p>
29,543
<p>I want to put songs on a web page and have a little play button, like you can see on Last.fm or Pandora. There can be multiple songs listed on the site, and if you start playing a different song with one already playing, it will pause the first track and begin playing the one you just clicked on. I think they use Fl...
<p>There are <strong>many</strong> flash mp3 players that you can use that do this. Usually, you just have to edit a text file to point at the mp3s you want to have available.</p> <p>Here is the first one that showed up on a google search for <code>flash mp3 player</code>: <a href="http://www.flashmp3player.org/demo.h...
<p>This is fairly simple if you want to embed the WMP you can use all the controls via JavaScript. There is a great MSDN section on it but I cant seem to find it now.<br /><br />Edit: I found <a href="http://msdn.microsoft.com/en-us/library/ms909930.aspx" rel="nofollow noreferrer">this</a> on MSDN it contains the prope...
7,059
<p>In which parts of a project writing unit tests is nearly or really impossible? Data access? ftp?</p> <p>If there is an answer to this question then %100 coverage is a myth, isn't it?</p>
<p><a href="http://www.artima.com/weblogs/viewpost.jsp?thread=126923" rel="noreferrer">Here</a> I found (via <a href="http://haacked.com/archive/2008/07/22/unit-test-boundaries.aspx" rel="noreferrer">haacked</a> something Michael Feathers says that can be an answer:</p> <p>He says, </p> <blockquote> <p>A test is no...
<p>If the code to set up the state required for a unit test becomes significantly more complex than the code to be tested I tend to draw the line, and find another way to test the functionality. At that point you have to ask how do you know the unit test is right!</p>
13,472
<p>I have been recently (and repeatedly) asked by customers about <a href="http://en.wikipedia.org/wiki/Instructions_per_second" rel="nofollow noreferrer">MIPS</a> needed to run our software. Usually we was able to get rid of this questions by explaining the customer that this is really depend on the cpu/os/hw (our sof...
<p>OK you realize that this is fraught with disclaimers &amp; warnings -- CPU speeds, memory speeds, cache hits, MMU page tables flushes, bus contention, etc... (if it's a heavy-duty embedded system) all factor significantly into the decision....</p> <p><strong>Having said that</strong>.... what I would do is this. G...
<p>I/S is a "weak" metric for a system with an operating system.</p> <p>In the nitty-gritty, what you have to do is </p> <ol> <li>figure out the worst-case instruction path and count how many cycles it takes to execute(this means reading the assembly for that CPU and reviewing the CPU handbook that tell you # of cycl...
37,975
<p>I want to create some text in a canvas:</p> <pre><code>myText = self.canvas.create_text(5, 5, anchor=NW, text=&quot;TEST&quot;) </code></pre> <p>Now how do I find the width and height of <code>myText</code>?</p>
<pre><code>bounds = self.canvas.bbox(myText) # returns a tuple like (x1, y1, x2, y2) width = bounds[2] - bounds[0] height = bounds[3] - bounds[1] </code></pre> <p>See the <a href="https://anzeljg.github.io/rin2/book2/2405/docs/tkinter/canvas-methods.html" rel="nofollow noreferrer">TkInter reference</a>.</p>
<p>JUST USE THIS FUNCTION:</p> <pre><code>def Height(Canvas, Object): Height = Canvas.bbox(Object) return Height[3] - Height[1] def Width(Canvas, Object): Width = Canvas.bbox(Object) return Width[2] - Width[0] def Position(Canvas, Object, X1=False, X2=False, Y1=False, Y2=False): Position = Canvas....
13,712
<p>What is the best way to integrate an external script into the Zend Framework? Let me explain because I may be asking this the wrong way. I have a script that downloads and parses an XML file. This script, which runs as a daily cron job, needs to dump its data into the database.</p> <p>I am using Zend Framework for ...
<p>In your library directory you should have your own library next to the Zend library folder. Whatever you call it (Mylib, Project, ...) you should include it into the Zend Autoloader and that's done as follows:</p> <pre><code>require_once 'Zend/Loader/Autoloader.php'; $loader = Zend_Loader_Autoloader::getInstance();...
<p>I just came across something that may be germane to this question. <a href="http://www.ibm.com/developerworks/opensource/library/os-php-fwk5/?ca=dgr-btw01PHP-CRON-Tasks" rel="nofollow noreferrer">This IBM developerWorks article.</a></p> <p>The author recommends simply creating a scripts folder in the ZF hierarchy a...
39,103
<p>I have a two-level hierarchy displayed in a WPF TreeView, but I only want the child nodes to be selectable - basically the top level nodes are for categorisation but shouldn't be selectable by themselves. </p> <p>Can I achieve this?</p> <p>Thanks...</p>
<p>Define styles for each type of items, like Bijington wrote. for non-selectable nodes set the Focusable-Property of the container (TreeViewItem for TreeViews) to false.</p>
<p>I've written at attached property that will unselect a treeviewitem as soon as it's selected:</p> <pre><code>public class TreeViewItemHelper { public static bool GetIsSelectable(TreeViewItem obj) { return (bool)obj.GetValue(IsSelectableProperty); } public static void SetIsSelectable(TreeVie...
30,971
<p>I have a web application with users and their documents. Each user can have many documents:</p> <p>user.rb: </p> <pre><code>has_many :documents </code></pre> <p>document.rb:</p> <pre><code>belongs_to :user </code></pre> <p>document_controller.rb:</p> <pre><code>def index @documents = Document.find(:all) en...
<p>You set a relationship in your User class to your Document class. This will automatically add a method to your User objects that returns a list of all documents related to a particular user:</p> <pre><code>def index @documents = @current_user.documents end </code></pre> <p>See the <a href="http://api.rubyonrails...
<pre><code>def index @documents = Document.find(:all, :conditions =&gt; {:user_id =&gt; session[:user_id]}) end </code></pre>
26,672
<p>Does anyone know how to remove the extra branding on the google custom search? </p> <p>they've added a button and other things like text that says "gadgets powered by google".</p> <p>there has to be a way to pipe the CSE data into a normal form, right?</p> <p><a href="http://www.google.com/coop/cse/" rel="nofollo...
<p>I guess the normal way is to buy their <a href="http://groups.google.com/group/google-custom-search-creating-and-editing/browse_thread/thread/b0551aded8c00c15/1e26df13af8a9d95" rel="nofollow noreferrer">Business edition</a> ;)</p> <p>Still there seems to be some <a href="http://markmail.org/message/fts56cobltlha5x4...
<p>well the business edition's main benefit is that the search results don't have ads in them. so really google shouldn't care if people are modding the search form on the free service since it will still bring them ad revenue. </p> <p>i looked at the page you linked to, it might out of date cause their latest code sp...
48,425
<p>I have an update query being run by a cron task that's timing out. The query takes, on average, five minutes to execute when executed in navicat.</p> <p>The code looks roughly like this. It's quite simple:</p> <pre><code>// $db is a mysqli link set_time_limit (0); // should keep the script from timing out $query...
<p>I had the same problem somwhere, and "solved" it with the following code (first two lines of my file):</p> <pre><code>set_time_limit(0); ignore_user_abort(1); </code></pre>
<p>Assuming you are on linux, Debian based systems have separate configurations for mod_php/php cgi and php-cli. This shouldn't be too difficult to set up on a different linux system that doesn't separate cgi/cli configuration.</p> <p>Once you have separate configs, I would adjust your php cli configuration. Disable s...
47,721
<p>Master table contains ID and PersonName.<br> Course table contains ID, CourseName.<br> Detail table contains ID, MasterID, CourseID, StartDate,EndDate</p> <p>I want to create report that shows list of persons (PersonName) and the only last course they took (so every person is listed only once):</p> <p>PersonName -...
<pre><code>select m.PersonName, c.CourseName from Master m join Detail d on d.MasterID = m.ID join Course c on c.ID = d.CourseID where d.StartDate = (select max(d2.StartDate) from Detail d2 where d2.MasterID = m.ID ) </code></pre>
<pre><code> Select personname,coursename from details inner join course on course.id = details.courseid inner join master on master.id = details.masterid inner join (select max(startdate) , courseid,masterid from details group by masterid,courseid ) as tb1 on tb1.courseid = details.courseid a...
45,901
<p>Is it possible for me to turn on audit logging on my mysql database?</p> <p>I basically want to monitor all queries for an hour, and dump the log to a file.</p>
<p>UPDATE: NO LONGER VALID FOR MYSQL 5.6+</p> <p>Start mysql with the --log option:</p> <pre><code>mysqld --log=log_file_name </code></pre> <p>or place the following in your <code>my.cnf</code> file:</p> <pre><code>log = log_file_name </code></pre> <p>Either one will log all queries to log_file_name.</p> <p>You can als...
<p>For the record, general_log and slow_log were introduced in 5.1.6:</p> <p><a href="http://dev.mysql.com/doc/refman/5.1/en/log-destinations.html" rel="nofollow noreferrer">http://dev.mysql.com/doc/refman/5.1/en/log-destinations.html</a></p> <blockquote> <p>5.2.1. Selecting General Query and Slow Query Log Output Dest...
39,060
<p>I have a custom performance counter category. Visual Studio Server Explorer refuses to delete it, claiming it is 'not registered or a system category'. Short of doing it programmatically, how can I delete the category? Is there a registry key I can delete?</p>
<p>As far as I know, there <strong>is no way</strong> to safely delete them except programatically (they're intended for apps to create and remove during install) but it is trivial to do from a <a href="http://Microsoft.com/PowerShell" rel="noreferrer">PowerShell</a> command-line console. Just run this command:</p> <p...
<p>You could disable it using the microsoft resource kit tool - install it from </p> <p><a href="http://download.microsoft.com/download/win2000platform/exctrlst/1.00.0.1/nt5/en-us/exctrlst_setup.exe" rel="nofollow noreferrer">http://download.microsoft.com/download/win2000platform/exctrlst/1.00.0.1/nt5/en-us/exctrlst_s...
16,959
<p>For better or worse, we have a solution that relies on multiple databases that all reference a common administration database. Databases ship as part of modules, and not all modules are required for an installation (probably why we have multiple databases in the first place). The admin database is required, howeve...
<p>We have the exact same problem and quite frankly, it sucks. Our only solution we found effective was option D and using the business layer to try and keep things in sync (encasing in transactions etc.)</p>
<p>I wonder if SQL Server has a feature like Oracle's materialized views? This is an object that you define with a query like a view, but the results of the query get stored as a table. There are then various mechanisms for automatically refreshing.</p> <p>If there is such a feature, I would suggest making a materia...
33,345
<p>According to the <a href="http://ca3.php.net/manual/en/function.get-magic-quotes-gpc.php" rel="noreferrer">PHP manual</a>, in order to make code more portable, they recommend using something like the following for escaping data:</p> <pre><code>if (!get_magic_quotes_gpc()) { $lastname = addslashes($_POST['lastna...
<p>Magic quotes are inherently broken. They were meant to sanitize input to the PHP script, but without knowing how that input will be used it's impossible to sanitize correctly. If anything, you're better off checking if magic quotes are enabled, then calling stripslashes() on $_GET/$_POST/$_COOKIES/$_REQUEST, and the...
<p>Regarding using a database specific escaping function, you pretty much need to. I have found just using <code>addslashes()</code> to fail in rare cases with MySQL. You can write a function to escape which determines which DB you are using and then use the approriate escape function.</p>
27,147
<p>I intend to develop a system that is entirely based on modules. The system base should have support for finding out about plugins, starting them up and being able to provide ways for those modules to communicate. Ideally, one should be able to put in new modules and yank out unused modules at will, and modules shoul...
<p>You should definitely look at <a href="http://www2.osgi.org/Specifications/HomePage" rel="noreferrer">OSGi</a>. It aims at being <em>the</em> component/plugin mechanism for Java. It allows you to modularize your code (in so-called bundles) and update bundles at runtime. You can also completely hide implementation pa...
<p>They are many way to do it but something simple can be by using Reflection. You write in your XML file name of file (that would be a class in reallity). You can than check what type is it and create it back with reflection. The class could have a common Interface that will let you find if the external file/class is ...
10,344
<p>I've set up Passenger in development (Mac OS X) and it works flawlessly. The only problem came later: now I have a custom <code>GEM_HOME</code> path and ImageMagick binaries installed in <code>"/usr/local"</code>. I can put them in one of the shell rc files that get sourced and this solves the environment variables ...
<p>I know of two solutions. The first (documented <a href="http://www.viget.com/extend/rubyinline-in-shared-rails-environments/" rel="noreferrer">here</a>) is essentially the same as manveru's—set the ENV variable directly in your code.</p> <p>The second is to create a wrapper around the Ruby interpreter that Passenge...
<p>I've run into this issue as well. It <a href="http://groups.google.com/group/phusion-passenger/browse_thread/thread/79474d37028f2a03" rel="nofollow noreferrer">appears</a> that Passenger doesn't passthrough values set using the <code>SetEnv</code> apache directive - which is unfortunate.</p> <p>Perhaps it might be...
10,485
<p>I want to list the thumbnails of a set of photos in a listctrl. But the only way to achieve this is to use the setImageList method to bind a image list to the CListCtrl object and insert items like this: InsertItem (int nItem, LPCTSTR lpszitem, int nImage). I also must modify the listctrl's style by ModifyStyle(LVS_...
<p>Why do you think it's not a good approach? Your other options are to make it an owner-drawn control and render the images yourself, or use a callback for the images via CListCtrl::SetCallbackMask. </p> <p>List controls use image lists for a reason; the bitmaps are stored in a way that is most efficient for renderin...
<p>Given that you need these sorts of extended features, sounds like you must use owner-draw. A good example is <a href="http://www.codeproject.com/KB/list/CGridListCtrlEx.aspx" rel="nofollow noreferrer">here</a>. It doesn't show how to draw the image, but once you've got the owner-draw procedure set up you should be a...
28,304
<p>I'm using a device that's got GPRS media to connect to a PC running stunnel. On TCPIP connections, the number of sessions is limitless. However, when it comes to SSL connections, it could only go as far as 1062 successful sessions. I've tried it like 3 times but makes no difference. I've checked the OpenSSL codes ...
<p>Are you connecting via a phone provider - could that be the issue?</p>
<p>Are you connecting via a phone provider - could that be the issue?</p>
7,979
<p>Please read the whole question. I'm not looking for an approach to managing multi-lingual content, but I'm looking for a way to actually get that multi-lingual content. This usually falls within technical recommendations on most projects I work on, and I hope someone can offer some help. We are working with a client...
<p>I have yet to see a dynamic translation service that would be suitable for the content of a professional website. Language translation is not (yet) a mechanical activity - it requires thought and analysis. Your clients would best be served by outsourcing translation (or hiring a translator).</p>
<p>Normally you would need two teams: a forward translation and a backward translation and you do this in parallel (3-4 four teams would be good) - you then check where the backward translation are in agreement (hopefully this is at 75-85%), you then get an expert to give your recommendations on the remaining 15-25%. Y...
16,988
<p>I have the following CSS and HTML snippet being rendered.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>textarea { border:1px solid #999999; width:100%; margin:...
<p>Why not forget the hacks and just do it with CSS?</p> <p>One I use frequently:</p> <pre class="lang-css prettyprint-override"><code>.boxsizingBorder { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } </code></pre> <p>See browser support <a href="http://...
<p>How about negative margins?</p> <pre><code>textarea { border:1px solid #999999; width:100%; margin:5px -4px; /* 4px = border+padding on one side */ padding:3px; } </code></pre>
34,084
<p>What MySQL query will do a text search and replace in one particular field in a table?</p> <p>I.e. search for <code>foo</code> and replace with <code>bar</code> so a record with a field with the value <code>hello foo</code> becomes <code>hello bar</code>.</p>
<p>Change <code>table_name</code> and <code>field</code> to match your table name and field in question:</p> <pre><code>UPDATE table_name SET field = REPLACE(field, 'foo', 'bar') WHERE INSTR(field, 'foo') &gt; 0; </code></pre> <ul> <li><a href="https://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_re...
<p>I used the above command line as follow: update TABLE-NAME set FIELD = replace(FIELD, 'And', 'and'); the purpose was to replace And with and ("A" should be lowercase). The problem is it cannot find the "And" in database, but if I use like "%And%" then it can find it along with many other ands that are part of a word...
15,222
<p>Switch statement fallthrough is one of my personal major reasons for loving <code>switch</code> vs. <code>if/else if</code> constructs. An example is in order here:</p> <pre><code>static string NumberToWords(int number) { string[] numbers = new string[] { "", "one", "two", "three", "four", "five", ...
<p>(Copy/paste of an <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c?answer=90432#90432">answer I provided elsewhere</a>)</p> <p>Falling through <code>switch</code>-<code>case</code>s can be achieved by having no code in a <code>case</code> (see <code>case 0</code>), or using the special <code>g...
<p>You forgot to add the "break;" statement into case 3. In case 2 you wrote it into the if block. Therefore try this:</p> <pre><code>case 3: { ans += string.Format("{0} hundred and ", numbers[number / 100]); break; } case 2: { int t = (number / 10) % 10; if (t == ...
20,982
<p>So lets say I have a dataset based on:</p> <pre><code>SELECT TopicLink.*, Topic.Name AS FromTopicName, Topic_1.Name AS ToTopicName FROM TopicLink INNER JOIN Topic ON TopicLink.FromTopicId = Topic.TopicId INNER JOIN Topic AS Topic_1 ON TopicLink.ToTopicId = Top...
<p>I think you can achive this by providing your own update command for the ADO.net DataAdaptor. Check out the sample provided <a href="http://www.ondotnet.com/pub/a/dotnet/excerpt/progvisbasic_ch08-2/index.html?page=4" rel="nofollow noreferrer">here</a>.</p>
<p>It's my understanding that as long as you've selected the entire primary key from every table you'll be updating, you should be fine, since ADO.NET will know what to do with the updated data automatically. If your returned data doesn't have the primary keys in it, though, ADO.NET won't know which rows in the tables ...
21,751
<p>I know this sounds like a point-whoring question but let me explain where I'm coming from.</p> <p>Out of college I got a job at a PHP shop. I worked there for a year and a half and thought that I had learned all there was to learn about programming.</p> <p>Then I got a job as a one-man internal development shop a...
<p><strong>Documentation</strong>. The <a href="http://www.php.net/manual/en/" rel="noreferrer">documentation</a> gets my vote. I haven't encountered a more thorough online documentation for a programming language - everything else I have to piece together from various websites and man pages.</p>
<p>Boolean casting, which is particularly helpful for redwall_hp's first example, above.</p> <p>Instead of:</p> <pre><code>$var = ($_POST['my_checkbox']=='checked') ? TRUE : FALSE; </code></pre> <p>You can type:</p> <pre><code>$var = !!($_POST['my_checkbox']=='checked'); </code></pre>
8,661
<p>C#: How do you save a list of items like a Combobox to the .NET Settings file?</p>
<p>The only collection type of use that the Settings Designer lets you use is System.Collections.ArrayList. If you do use an ArrayList, all of its elements' types must be serializable (have the [Serializable] attribute or implement System.Runtime.Serialization.ISerializable.)</p> <p>Here's some code to get data from...
<p>You can use <code>System.Collections.Specialized.StringCollection</code> type to save ComboBox items. First create variable of this type in Settings Designer, e.g. CboItems.</p> <p>To read items:</p> <pre><code>if (Properties.Settings.Default.CboItems != null) comboBox1.Items.AddRange(Properties.Settings.Default...
49,303
<p>Like the question says, if I have a request for a page on my site like this</p> <p><a href="http://somename.something.here/Dada.aspx" rel="nofollow noreferrer">http://somename.something.here/Dada.aspx</a></p> <p>to something like this</p> <p><a href="https://somename.something.here/Dada.aspx" rel="nofollow norefe...
<p>I prefer to (a) not redirect local connections (to ease development under VS), and (b) use a UriBuilder instead of a string.Replace as it's a bit more exact.</p> <pre><code>if (!Request.IsLocal &amp;&amp; !Request.IsSecureConnection) { var ub = new UriBuilder(Request.Url); ub.Scheme = Uri.UriSchemeHttps; ...
<p>Send a Redirect Header (302) to the browser.</p> <p>Example:</p> <pre><code>Response.Redirect("WebForm2.aspx") </code></pre> <p>Article on the <a href="http://www.developer.com/net/asp/article.php/3299641" rel="nofollow noreferrer">difference between Server.Transfer and Response.Redirect</a></p>
49,504
<p>In SQL Server 2005, the query analyzer has told me many times to create a non-clustered index on a primary ID column of a table which already has a clustered index. After following this recommendation, the query execution plan reports that the query should be faster.</p> <p>Why would a Non-Clustered index on the s...
<p>A clustered index has all the data for the table while a non clustered index only has the column + the location of the clustered index or the row if it is on a heap (a table without a clustered index). So if you do a count(column) and that column is indexed with a non clustered index SQL server only has to scan the ...
<p>A clustered index will generally be faster, but you can only have 1 clustered index. So if the table <em>already has</em> a clustered index on a different column, then a non-clustered index is the best you can do.</p>
6,342
<p>So, I need some help. I am working on a project in C++. However, I think I have somehow managed to corrupt my heap. This is based on the fact that I added an <code>std::string</code> to a class and assigning it a value from another <code>std::string</code>:</p> <pre><code>std::string hello = "Hello, world.\n"; /* e...
<p>These are relatively cheap mechanisms for possibly solving the problem:</p> <ol> <li>Keep an eye on my <a href="https://stackoverflow.com/questions/1069/heap-corruption-under-win32-how-to-locate">heap corruption question</a> - I'm updating with the answers as they shake out. The first was balancing <code>new[]</co...
<p>As far as I can tell your code is correct. Assuming exampleString is an std::string that has class scope like you describe, you ought to be able to initialize/assign it that way. Perhaps there is some other issue? Maybe a snippet of actual code would help put it in context.</p> <p>Question: Is exampleString a point...
2,906
<p>I’m using a RepRap printer, PLA (Hatchbox 1.75&nbsp;mm), SketchUp, and Slic3r. The heated bed is covered with a blue polyester sticker. When I print small holes (1 to 1.5 mm radius), slicer software considers the holes outside edges for the first layer and prints them before the internal first layer. The problem is...
<p>are you using hairspray or tape to help with bed adhesion? If not that might help.</p> <p>Also try printing the first layer slower or try adjusting the bed level offset so you are squishing the first layer down a bit more.</p>
<p>You didn't say what type of bed you have, but I'm guessing glass. Do you have a BuildTak or comparable generic surface you could clip on and use? I've never had adhesion problems like this with my Ender 3, which came with a BuildTak clone; PLA just sticks, with no brim, no glue, no hairspray, etc.</p>
1,282
<p>I am developing an Adobe AIR application which stores data locally using a SQLite database. At any time, I want the end user to synchronize his/her local data to a central MySQL database.</p> <p>Any tips, advice for getting this right? Performance and stability is the key (besides security ;))</p>
<p>Some performance notes about new/delete and malloc/free:</p> <p>malloc and free <strong>do not</strong> call the constructor and deconstructor, respectively. This means your classes won't get initalized or deinitialized automatically, which could be bad (e.g. uninitalized pointers)! This doesn't matter for POD da...
<p>Good answers all.</p> <p>On the performance issue, <a href="https://stackoverflow.com/questions/266373/one-could-use-a-profiler-but-why-not-just-halt-the-program">this</a> provides a method that most can't imagine will work, but a few know it does, surprisingly well.</p> <p>The 90/10 rule is true. In my experience...
42,610
<p>I am building a really basic Cocoa application using WebKit, to display a Flash/Silverlight application within it. Very basic, no intentions for it to be a browser itself.</p> <p>So far I have been able to get it to open basic html links (<code>&lt;a href="..." /&gt;</code>) in a new instance of Safari using </p> ...
<p>I made from progress last night and pinned down part of my problem.</p> <p>I am already using <code>webView:decidePolicyForNewWindowAction:request:newFrameName:decisionListener:</code> and I have gotten it to work with anchor tags, however the method never seems to get called when JavaScript is invoked.</p> <p>How...
<p>Explanation:</p> <p>Windows created from JavaScript via window.open go through createWebViewWithRequest. All window.open calls result in a createWebViewWithRequest: with a null request, then later a location change on that WebView.</p> <p>For further information, <a href="https://lists.apple.com/archives/webkitsdk...
33,992
<p>I have a Postgresql database on which I want to do a few cascading deletes. However, the tables aren't set up with the ON DELETE CASCADE rule. Is there any way I can perform a delete and tell Postgresql to cascade it just this once? Something equivalent to</p> <pre><code>DELETE FROM some_table CASCADE; </code></...
<p>No. To do it just once you would simply write the delete statement for the table you want to cascade.</p> <pre><code>DELETE FROM some_child_table WHERE some_fk_field IN (SELECT some_id FROM some_Table); DELETE FROM some_table; </code></pre>
<p>The delete with the cascade option only applied to tables with foreign keys defined. If you do a delete, and it says you cannot because it would violate the foreign key constraint, the cascade will cause it to delete the offending rows.</p> <p>If you want to delete associated rows in this way, you will need to de...
15,715
<p>I'm trying to work my way through Ron Jeffries's Extreme Programming Adventures in C#. I am stuck, however, in Chapter 3 because the code does not, and <b>cannot</b>, do what the author says it does. </p> <p>Basically, the text says that I should be able to write some text in a word-wrap enabled text box. If I then...
<p>Try emailing Ron Jeffries directly. I have the book - somewhere, but I don't remember it not working. His email address is ronjeffries at acm dot org and put [Ron] in the subject line. </p> <p>(And for those wondering - his email info was right from his website <a href="http://www.xprogramming.com/welcome.htm" rel=...
<pre><code>print("using System; </code></pre> <p>using System.Collections; using System.Collections.Generic; using System.Text;</p> <p>namespace NotepadOne {</p> <p>public class TextModel {</p> <pre><code>private String[] lines; private int selectionStart; private int cursorPosition; public TextModel() { } publi...
39,964
<p>I'm getting the following error when I try to use the JSTL XML taglib:</p> <pre><code>/server-side-transform.jsp(51,0) According to TLD or attribute directive in tag file, attribute xml does not accept any expressions </code></pre> <p>I'm looking into the tlds etc, but if anyone knows what this is an can save me ...
<p>Your code is picking up an "incorrect" version of x-1_0.tld, probably due to classpath issues. I see for instance on my current classpath, I have one version of x-1_0.tld that ALLOWS runtime-expressions ${syntax} in this tag and one that does not. The one in standard.jar does not allow EL expressions, while the one ...
<p>I realize this question was asked quite a while ago but I just ran into the same problem. In my case, the example I was following directed me to use:</p> <pre><code>&lt;%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %&gt; </code></pre> <p>When I should have been using:</p> <pre><code>&lt;%@ taglib prefi...
49,434
<p>I am facing problem with an Oracle Query in a .net 2.0 based windows application. I am using <code>System.Data.OracleClient</code> to connect to oracle database. Name of database is <code>myDB</code>. Below the the connection string I am using:</p> <pre><code>Data Source=(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PRO...
<p>This looks like an issue with name resolution, try creating a public synonym on the table:</p> <p>CREATE PUBLIC SYNONYM <em>MyTempTable</em> for <em>MyTempTable</em>;</p> <p>Also, what exactly do you mean by <strong>wrong result</strong>, incorrect data, error message?</p> <hr> <p>Edit: What is the name of the s...
<p>Try adding</p> <pre><code>CONNECT_DATA=(SID=myDB)(SERVICE_NAME=ORCL) </code></pre> <p>in the connection string.</p>
5,890
<p>We have a VXML project that a 3rd party parses to provide us with a phone navigation system. We require them to enter an id code to leave a message, which is later reviewed by our company.</p> <p>We currently have this working as follows:</p> <pre><code>Response.Cache.SetCacheability(HttpCacheability.NoCache); Str...
<p>Yes, just write directly to the Response <code>Output</code> (IO.StreamWriter) or <code>OutputStream</code> (IO.Stream):</p> <pre><code>XmlTextWriter XML_Writer = new XmlTextWriter(HttpContext.Current.Response.OutputStream, HttpContext.Current.Response.Encoding); //... XML_Writer.Flush(); </code></pre>
<p>After that I can just call XML_Writer.Flush(), right? That'll flush the XML to the stream?</p>
18,697
<p>I need to change the capitalization of a set of files in a subversion working copy, like so:</p> <pre> svn mv test.txt Test.txt svn mv test2.txt Test2.txt svn mv testn.txt Testn.txt ... svn commit -m "caps" </pre> <p>How can I automate this process? Standard linux install tools available.</p>
<p>ls | awk '{system("svn mv " $0 " " toupper(substr($0,1,1)) substr($0,2))}'</p> <p>obviously, other scripting languages will work just as well. awk has the advantage that it it ubiquitous.</p>
<p>I typically do this by redirecting the 'ls' output to a file, using vim macros to massage each filename into the command line I want, then execute the file as a shell script. It's crude but effective.</p>
24,310
<p>When an audio or midi clip is played (triggered), its name needs to be sent using OSC to <a href="http://vvvv.org/" rel="nofollow noreferrer">another application</a>.</p> <p><a href="http://www.assembla.com/wiki/show/live-api" rel="nofollow noreferrer">LiveAPI</a> is an interface which allows one to explore and aut...
<p>According to <a href="http://svn2.assembla.com/svn/live-api/trunk/docs/Ableton%20Live%20API/modules/Clip.Clip.html" rel="nofollow noreferrer">the LiveAPI documentation</a>, the Clip object has a "name" attribute which holds the clip name. Presumably that's what you want to send in your OSC packets.</p> <p>Also, it...
<p>I know about Max 4 Live, but as I see it, it's kind of a different thing. Yes, it will probably be able to interface with Live to do all the stuff which people do now with LiveAPI. Some even think that M4L may not even go through LiveAPI, and use some internal interface instead (since Ableton and Cycling 74 are deve...
49,066
<p>I'd like to customize and modify some parts on Thingiverse, beyond just simple scaling for 3D printing.</p> <p>I've been looking for some tools that convert the STL files into something that is easily edited, but so far all that I've found are really buggy and crash frequently as soon as one loads a reasonably comp...
<p>If you want to do basic edits to an STL, a program such as <a href="http://www.meshmixer.com/" rel="noreferrer">MeshMixer</a> might be right for your. It offers the ability to combine and subtract models, add custom supports, and similar, in a fairly straight forward manner.</p> <p>An alternative that allows your t...
<p>If you want a WYSIWYG-style editor and are not content with OpenSCAD, I found 123D Design (Autodesk, definitively not FOSS but free for hobbyists) to have (on a Mac) a compromise between power and ease of use that most appealed to me.</p> <p>If you insist on FOSS probably Blender comes closest, but I found it to be...
177
<p>As prescribed by Yahoo!, gzip'ng files would make your websites load faster. The problem? I don't know how :p</p>
<p><a href="http://www.webcodingtech.com/php/gzip-compression.php" rel="nofollow noreferrer">http://www.webcodingtech.com/php/gzip-compression.php</a></p> <p>Or if you have Apache, try <a href="http://www.askapache.com/htaccess/apache-speed-compression.html" rel="nofollow noreferrer">http://www.askapache.com/htaccess/...
<p><a href="http://developer.yahoo.com/performance/rules.html#gzip" rel="nofollow noreferrer">http://developer.yahoo.com/performance/rules.html#gzip</a> </p> <p>This is the reference if any asks me about my reference loading gzipped files</p>
37,669
<p>Assume I have an ASP.NET MVC app that's not doing anything too fancy (no P/Invoke, no unsafe, etc).</p> <p>I've considered the idea of running on Mono to support Linux, among other platforms. I haven't used Mono in a long time. What are the top issues I'm likely to face?</p>
<ul> <li>Mono doesn't support Themes</li> <li>Mono doesn't have a great GC which means it'll leak more memory and fragment the RAM for you</li> <li>Mono doesn't create literal controls the same way .Net does for "empty spaces" which might be a problem</li> </ul> <p>Except for those issues you should mostly be safe for...
<p>You mentioned ASP.NET MVC, which runs on .net 3.5, and mono is for framework 2.0.<br> ScottHansleman wrote blog entry on how to run mvc on 2.0, you can try it. Or use Monorail (or ProMesh.NET) which runs on mono out-of-the-box. They are all MVC frameworks for .net...</p>
47,858
<h1>Duplicate from : <a href="https://stackoverflow.com/questions/16432/c-string-output-format-or-concat">String output: format or concat in C#?</a></h1> <p>Especially in C# world using String.Format for everything is really common, normally as VB.NET developer unless I have to* I don't String.Format, </p> <p>I prefe...
<p>If you're ever going to localize your application (and it's often hard to rule that out at the start), then String.Format is to be much preferred, for two reasons:</p> <ol> <li>You have only one string literal to translate</li> <li>You can change the order of the values, which may make more sense in another languag...
<p>Personally I find that String.Format is easier to read, the string is presented as one consecutive text. It depends though on how many parameters there are, if you need to hunt for the right parameter to understand it, then ...</p>
45,495
<p>I've written a database generation script in <a href="http://en.wikipedia.org/wiki/SQL" rel="noreferrer">SQL</a> and want to execute it in my <a href="http://en.wikipedia.org/wiki/Adobe_Integrated_Runtime" rel="noreferrer">Adobe AIR</a> application:</p> <pre><code>Create Table tRole ( roleID integer Primary Key...
<p>I wound up using this. It is a kind of a hack, but it actually works pretty well. </p> <p>The only thing is you have to be very careful with your semicolons. : D</p> <pre><code>var strSql:String = stream.readUTFBytes(stream.bytesAvailable); var i:Number = 0; var strSqlSplit:Array = strSql.split(";"); for (i ...
<p>What about making your delimiter something a little more complex like ";\n" which would not show up all that often. You just have to ensure when creating the file you have a line return or two in there. I end up putting two "\n\n" into the creation of my files which works well.</p>
2,250
<p>What does <code>InitializeComponent()</code> do, and how does it work in WPF?</p> <p>In general first, but I would especially be interested to know the gory details of order of construction, and what happens when there are Attached Properties.</p>
<p>The call to <code>InitializeComponent()</code> (which is usually called in the default constructor of at least <code>Window</code> and <code>UserControl</code>) is actually a method call to the partial class of the control (rather than a call up the object hierarchy as I first expected).</p> <p>This method locates ...
<p>Looking at the code always helps too. That is, you can actually take a look at the generated partial class (that calls <strong>LoadComponent</strong>) by doing the following:</p> <ol> <li>Go to the Solution Explorer pane in the Visual Studio solution that you are interested in.</li> <li>There is a button in the too...
30,498
<p>In Django, given excerpts from an application <em>animals</em> likeso:</p> <p>A <em>animals/models.py</em> with: </p> <pre><code>from django.db import models from django.contrib.contenttypes.models import ContentType class Animal(models.Model): content_type = models.ForeignKey(ContentType,editable=False,null=Tr...
<p>Alright, here's what I've done, and it seems to work and be a sensible design (though I stand to be corrected!).</p> <p>In a core library (e.g. mysite.core.views.create_update), I've written a decorator:</p> <pre><code>from django.contrib.contenttypes.models import ContentType from django.views.generic import crea...
<p>AFAICT, cats and dogs are on different DB tables, and maybe there's no Animal table. but you're using one URL pattern for all. somewhere you need to choose between each.</p> <p>I'd use a different URL patter for cats and dogs, both would call <code>'create_update.update_object'</code>; but using a different <code...
26,206
<p>This is one of those ajax "alternate flow" questions. Normally I expect my ajax request to return a part of the page. But sometimes it may return a full page with html, head and body tag. </p> <p>At the time I return from my ajax-request I can detect if this is a full page, but is it possible to trigger a full page...
<p>I don't think it's possible to do directly.</p> <p>You'd be better off saving the HTML somewhere and sending back a URL where it can be retrieved, then using <code>location.href = ...</code>;</p>
<p>At least in <em>Firefox</em>, you can use the <a href="https://developer.mozilla.org/en/DOM/window.location" rel="nofollow noreferrer">window.location</a> property. The <em>location</em> object contains information about the URL of the document and provides methods for changing that URL. You can also assign to this...
28,808
<p>Is there anybody who has successfully accessed a Web service from an Oracle stored procedure? If so, was it a Java stored procedure? A PL/SQL stored procedure?</p> <p>Is there any reason why I should not be trying to access a WS from a stored proc?</p> <p>Here are a couple refs that I found so far</p> <ul> <li>...
<p>First off, what sort of web service are you calling? I am assuming either SOAP or REST.</p> <p>For REST web services, UTL_HTTP is often more than sufficient, combined with a bit of XPath in a simple PL/SQL stored procedure.</p> <p>For SOAP web services, it depends on how sophisticated you need (or want) to be. Y...
<p>It's fairly simple to wrap UTL_HTTP in a convenience function:</p> <pre><code>FUNCTION post ( p_url IN VARCHAR2, p_data IN CLOB, p_timeout IN BINARY_INTEGER DEFAULT 60 ) RETURN CLOB IS -- v_request utl_http.req; v_response utl_http.resp; v_buffer CLOB; v_chunk VARCH...
38,289
<p>In the following code I loop through a map and test if an element needs to be erased. Is it safe to erase the element and keep iterating or do I need to collect the keys in another container and do a second loop to call the erase()?</p> <pre><code>map&lt;string, SerialdMsg::SerialFunction_t&gt;::iterator pm_it; fo...
<h2>C++11</h2> <p>This has been fixed in C++11 (or erase has been improved/made consistent across all container types).<br> The erase method now returns the next iterator.</p> <pre><code>auto pm_it = port_map.begin(); while(pm_it != port_map.end()) { if (pm_it-&gt;second == delete_this_id) { pm_it = p...
<p>This is how I would do it, approximately:</p> <pre><code>bool is_remove( pair&lt;string, SerialdMsg::SerialFunction_t&gt; val ) { return val.second == delete_this_id; } map&lt;string, SerialdMsg::SerialFunction_t&gt;::iterator new_end = remove_if (port_map.begin( ), port_map.end( ), is_remove ); port_map...
33,054
<p>I have an application that imports data from a pickled file. It works just fine in Windows but Mac and Linux behaviour is odd.</p> <p>In OS X, the pickled file (file extension ".char") is unavailable as a selection unless I set the file type to *.*. Then, if I select a file that has the .char extension, it won't lo...
<p>Probably you didn't open the file in binary mode when writing and/or reading the pickled data. In this case newline format conversion will occur, which can break the binary data.</p> <p>To open a file in binary mode you have to provide "b" as part of the mode string:</p> <pre><code>char_file = open('pickle.char', ...
<p>Use dos2unix tool</p> <pre><code>dos2unix pickle.char </code></pre>
35,990
<p>If I have a method such as:</p> <pre><code>private function testMethod(param:string):void { // Get the object that called this function } </code></pre> <p>Inside the testMethod, can I work out what object called us? e.g.</p> <pre><code>class A { doSomething() { var b:B = new B(); b.fooBar(); } } ...
<p>Sorry the answer is no (see edit below). Functions received a special property called <code>arguments</code> and in AS2 it used to have the property <code>caller</code> that would do roughly what you want. Although the arguments object is still available in AS3 the caller property was removed from AS3 (and therefor...
<p>I'd second the idea of explicitly passing a "callingObject" parameter. Unless you're doing really tricky stuff, it should be better for the caller to be able to supply the target object, anyway. (Sorry if this seems obvious, I can't tell what you're trying to accomplish.)</p>
23,662
<p>all! Typing from Italy This little piece of code works if the matrix size is less then 800 and fails with a segmentation fault for higher sizes.... I have tried it with gcc 4.3.2 compiler in linux and macosx and VisualStudio compiler in windows. Seemsthe problem is in the stack size..... how can I increase it ? How ...
<p>Default stack size in OpenMP is 4-8 MB. There's an environment variable called STACKSIZE you can change (for example to 16384, which is 16 MB). See chapter 5-5 of <a href="http://dlc.sun.com/pdf/819-3694/819-3694.pdf" rel="nofollow noreferrer">this PDF</a>.</p>
<p>you can adjust the stack size through the shell with</p> <p><code>'ulimit -s newstacksize'</code> </p> <p>-- try 1000000</p>
40,469
<p>I have an Array of Objects that need the duplicates removed/filtered. I was going to just override equals &amp; hachCode on the Object elements, and then stick them in a Set... but I figured I should at least poll stackoverflow to see if there was another way, perhaps some clever method of some other API?</p>
<p>I would agree with your approach to override <code>hashCode()</code> and <code>equals()</code> and use something that implements <code>Set</code>.</p> <p>Doing so also makes it absolutely clear to any other developers that the non-duplicate characteristic is required.</p> <p>Another reason - you get to choose an i...
<p>A <code>Set</code> is definitely your best bet. The only way to remove things from an array (without creating a new one) is to null them out, and then you end up with a lot of null-checks later.</p>
46,604
<p>Currently we're using hand-rolled SQL in Data-Access objects and a lot of stored-procedures and triggers which amount to around 20k lines of code. We're finding that simple changes are causing a couple of days' work to fix, and its causing deadlines to slip.</p> <p>Changes include modifications to tables to cope wi...
<p>You might want to checkout this book on <a href="https://rads.stackoverflow.com/amzn/click/com/0321293533" rel="nofollow noreferrer" rel="nofollow noreferrer">Refactoring Databases: Evolutionary Database Design</a>.</p>
<p>Here are my suggestions:</p> <ol> <li>Try to get rid of the least used functionality. Question the features that are not used all the time. Each feature in an application has several levels of costs associated with it (maintaining, support, regression testing, code complexity, etc.). </li> <li>Stay away from Stored...
39,190
<p>can i somehow compare two numbers in regex? i want regex that is correct for 10-12, but incorrect for 12-10. I mean that 10 must be smaller than 12. I want to do it in Javascript.</p>
<p>If the input is always of the form X-Y, then why not use the split() function with '-' as the delimiter and then compare the two parts with ></p> <p>You can't compare numerical values using RegExps.</p>
<p>I wouldn't use regex for this. I'd split the string on the operator, then compare the two resulting numbers based on what operator I found (I'm assuming <code>10+12</code> and <code>12+10</code> would both be legal).</p>
38,257
<p>I have just installed boost for the first time on my Intel Mac, and it works fine in general, as long as I use only boost's header files.</p> <p>But when I try to use a lib, in my case the regex lib, my app links and launches fine, but then it soon crashes in a regex related destructor.</p> <p>This even happens wi...
<p>I find the <code>YAPE::Regex::Explain</code> module very helpful -</p> <pre><code>C:\&gt;perl -e "use YAPE::Regex::Explain;print YAPE::Regex::Explain-&gt;new(qr/['-])-&gt;explain;" The regular expression: (?-imsx:['-]) matches as follows: NODE EXPLANATION -------------------------------------...
<p>1st line: characters inside [] (' and -) are matched and replaced (s) by nothing, thus removed. /g means global and will try to match everything in the string.</p> <p>2nd line: \w means a word character, + means more than once. ? means 0 or once. "." means anything. So it means find any word character found more th...
49,957
<p>I set a passphrase when creating a new SSH key on my laptop. But, as I realise now, this is quite painful when you are trying to commit (<a href="http://en.wikipedia.org/wiki/Git_%28software%29" rel="noreferrer">Git</a> and <a href="http://en.wikipedia.org/wiki/Apache_Subversion" rel="noreferrer">SVN</a>) to a remot...
<p>Short answer:</p> <pre><code>$ ssh-keygen -p </code></pre> <p>This will then prompt you to enter the keyfile location, the old passphrase, and the new passphrase (which can be left blank to have no passphrase).</p> <hr> <p>If you would like to do it all on one line without prompts do:</p> <pre><code>$ ssh-keyge...
<p>On the <strong>Mac</strong> you can store the passphrase for your private ssh key in your Keychain, which makes the use of it transparent. If you're logged in, it is available, when you are logged out your root user cannot use it. Removing the passphrase is a bad idea because anyone with the file can use it.</p> <...
13,748
<p>I want to have two items on the same line using <code>float: left</code> for the item on the left.</p> <p>I have no problems achieving this alone. The problem is, I want the two items to <strong>stay</strong> on the same line <em>even when you resize the browser very small</em>. You know... like how it was with tab...
<p>Wrap your floating <code>&lt;div&gt;</code>s in a container <code>&lt;div&gt;</code> that uses this cross-browser min-width hack:</p> <pre><code>.minwidth { min-width:100px; width: auto !important; width: 100px; } </code></pre> <p>You <em>may</em> also need to set "overflow" but probably not.</p> <p>This works be...
<p>The way I got around this was to use some jQuery. The reason I did it this way was because A and B were percent widths.</p> <p>HTML:</p> <pre><code>&lt;div class="floatNoWrap"&gt; &lt;div id="A" style="float: left;"&gt; Content A &lt;/div&gt; &lt;div id="B" style="float: left;"&gt; Con...
33,359
<p>I have code that looks like the following, which works fine for displaying the message, but can't figure out any way to get a hold of the stack trace. </p> <pre><code>try { throw new RuntimeException("This is bad stuff!"); } catch (Exception e ) { mainForm.append("Exception: " + e.getMessage()); } </code><...
<p>see this article: <a href="http://lwuit.blogspot.com/2008/12/redirecting-output-on-s60-devices.html" rel="nofollow noreferrer">http://lwuit.blogspot.com/2008/12/redirecting-output-on-s60-devices.html</a></p> <p>too bad there is no System.setErr(PrintWriter) or Thread.getStackTrace()</p> <p>I don't think there is a...
<p>I've created a tool that can be used to log proper stack traces also in CLDC. Check it out at <a href="http://jarrut.sourceforge.net" rel="nofollow noreferrer">http://jarrut.sourceforge.net</a>. It's still very new and it might have some rough edges, but it works for me and I couldn't imagine developing MIDlets with...
43,379
<p>I currently have WHM/cPanel on my server, but it doesn't integrate properly with any Java EE App Server. I installed Tomcat manually, and have made it work through Apache, but the configuration is more fragile than I'd like.</p> <p>So, I'm trying to find a replacement where a Java EE App Server can be properly inte...
<p><a href="http://www.parallels.com/products/plesk/" rel="nofollow noreferrer">Plesk</a> is a similar commercial hosting management suite similar to CPanel, in fact most hosting providers who offer WHM/CPanel also offer Plesk, which has built in Tomcat support. Plesk runs natively on CentOS but it is only free for us...
<p>We have been using <a href="http://geronimo.apache.org/" rel="nofollow noreferrer">Apache Geronimo</a> here at work for about two years and it has been rock solid. It has its own built-in control panel that allows us to deploy/start/stop each app separately. You may want to give it a try.</p>
12,247
<p>does any one know how to get the current motherboard, processor or HD temperature statistics?<br> In GNU/Linux, I know I could use something like hddtemp or sensord to get the info, and then parse it... but in Windows: How can I do this? And, Can it be done with with C# or Java or any other hight level programming ...
<p>I would argue that when the right configurations are in place, it can be superior to windows's one.</p> <p><a href="http://www.lm-sensors.org/" rel="nofollow noreferrer">http://www.lm-sensors.org/</a> is what does all the work. I had that plugged into RRDgraph &amp; Munin and I was monitoring the temperature of my ...
<p>This is going to vary quite a bit depending on your hardware. Once you figure out from your hardware vendor whether you have sensors on your motherboard, you might look into using SNMP and the HOST-RESOURCE MIB. </p> <p>Use the Add/Remove Windows Components Wizard under Management and Monitoring Tools to get SNMP...
15,033
<p>Yesterday I've tried to get serious about rightly caching some PHP generated pages (think "Articles with comments"). Big fail.</p> <p>Long story short: I set the ETag header, set the Last-Modified one and check server side every Article browser request with them to see if I can send back a 304.</p> <p>The problem ...
<p>You should always set "Expires" if you want browser re-validate.</p> <p>Firefox3 do checking is based on "Expires" header. If it is missing, firefox3 will makeup an expires date for performance.</p> <p>Reference, <a href="http://blog.httpwatch.com/2008/10/15/two-important-differences-between-firefox-and-ie-caching...
<p>You can inspect the current FF cache entries at </p> <pre><code>about:cache </code></pre> <p>This will show you the expirey dates the FF stored with each cache entry.</p>
42,289
<p>I've done some WPF programing and one thing I never got was the command pattern. Every example seems to be for built in ones, edit, cut, paste. Anyone have an example or suggestion of best practice for custom commands?</p>
<p>Ah ha! A question I can answer! Firstly, I should mention that I have personally found it easier to define and hook up commands in code rather than in XAML. It allows me to hook up the handlers for the commands a little more flexibly than an all XAML approach does.</p> <p>You should work out what commands you want ...
<p>The thing about XAML is that it is fine for 'simple' programs, but sadly, it doesn't work well when you want to do things like share functions. Say you have several classes and UI's all of which had commands that were never disabled, you'd have to write a 'CanAlwaysExecute' method for each Window or UserControl! Tha...
2,990
<p>The long of it is I built an installer in visual studio that gave me this cheery error when I tried to use the program: </p> <blockquote> <p>Retrieving the COM class factory for component with CLSID {EC10E7E8-797E-4495-A86D-3E9EADA6D5BB} failed due to the following error: 80040154.</p> </blockquote> <p>F...
<p>Tool + Options, Project and Solutions, Build and Run, set "MSBuild project build output verbosity" to Detailed. You'll get a ton of diagnostics in the Output window.</p> <p>FWIW, the error message you get is a simple "class not registered" error. Fix with Regsvr32.exe</p>
<p>two guesses:</p> <ul> <li>build is not succeeding </li> <li>your post/pre build events are defined in a project config that is not being built, like you define your events in the "debug" build but are building the "release" build. </li> </ul> <p>are you building the solution from the command line or anything like ...
36,759
<p>SQL Server (2005/2008)</p> <p>Each of the below statements have the same result. Does anyone know if one outperforms the other?</p> <pre><code>insert into SOMETABLE values ('FieldOneValue','FieldTwoValue',3,4.55,'10/10/2008 16:42:00.000') insert into SOMETABLE select 'FieldOneValue','FieldTwoValue',3,4.55,'...
<p>I just tested this.</p> <p>5 million iterations of both approaches on two sets of hardware, one a server with 16GB RAM, one a notebook with 1GB.</p> <p>Result: They appear to be the same.</p> <p>The query plans for these are the same, and the performance differential is statistically insignificant.</p>
<p><em>ignore this comment, its wrong. sorry about that :(</em></p> <p>I know you can't use INSERT VALUES() when you're entering more than one row.</p> <p>INSERT INTO Table SELECT 1, 2, 3, (SELECT 4 FROM Table2 WHERE columnA = columnB)</p>
23,481
<p>What would be the best strategy to generate anagrams.</p> <blockquote> <pre><code>An anagram is a type of word play, the result of rearranging the letters of a word or phrase to produce a new word or phrase, using all the original letters exactly once; ex. </code></pre> <ul> <li><strong>Eleven plus two</st...
<p>Most of these answers are horribly inefficient and/or will only give one-word solutions (no spaces). My solution will handle any number of words and is very efficient.</p> <p>What you want is a trie data structure. Here's a <strong>complete</strong> Python implementation. You just need a word list saved in a fil...
<p>Off the top of my head, the solution that makes the most sense would be to pick a letter out of the input string randomly and filter the dictionary based on words that start with that. Then pick another, filter on the second letter, etc. In addition, filter out words that can't be made with the remaining text. Th...
7,894
<p>I have an object that is mapped to a cookie as a serialized base-64 string. I only want to write out a new cookie if there are changes made to the object stored in the cookie on server-side.</p> <p>What I want to do is get a hash code when the object is pulled from the cookie/initialized and compare the original ha...
<p>GetHashCode() should always be in sync with Equals(), and Equals() isn't necessarily guaranteed to check for <em>all</em> of the fields in your object (there's certain situations where you want that to not be the case).</p> <p>Furthermore, GetHashCode() isn't guaranteed to return unique values for all possible obje...
<p>I personally would say go with the plan you have.. A good hash code is the best way to see if an object is "as-is".. Theres tons of hashing algorithms you can look at, check out the obvious <a href="http://en.wikipedia.org/wiki/Hash_function" rel="nofollow noreferrer">Wikipedia page</a> on hash functions and go from...
5,519
<p>What are the different database options on Windows Mobile available? I have used CEDB and EDB for linear dataset needs.</p> <p>I have heard of SQL server 2005 Mobile edition. But what are the advantages over others (if there is any)</p>
<p>I've found both sqllite and codebase to be easy to implement and install. Easier (and more stable) than the Microsoft options, which seem to be in serious flux.</p>
<p>I would avoid using CEDB any more as I beleave that WM7 is dropping support for it. </p>
7,887
<p>I have a .NET application, which is using an open source C++ compression library for compressing images. We are accessing the C++ library via managed C++. I'm seeing heap corruption during compression. A call to _CrtIsValidHeapPointer is finding an error on a call to free() when cleaning up after compression.</p>...
<p>In native code, if the corruption always occurs in the same place in memory, you can use a <a href="http://msdn.microsoft.com/en-us/library/350dyxd0.aspx" rel="nofollow noreferrer">data breakpoint</a> to break the debugger when that memory is changed. Unfortunately, you cannot set a data breakpoint in the managed C+...
<p><a href="http://www-01.ibm.com/software/awdtools/purifyplus/win/" rel="nofollow noreferrer">Rational Purify for Windows</a> supports .NET, so I guess that could be used.</p>
5,536
<p>I'm just learning Ruby on Rails. I've read a few books, I've watched lots of Railscasts, I've looked at some examples. </p> <p>However, when working on my first serious project with Rails, I've gotten hung up on how to properly implement some very basic web site features that most tutorials I've seen lack.</p> <p>...
<p><a href="http://www.opensourcerails.com/" rel="noreferrer">Open Source Rails</a> is a repository of sites implemented in rails.</p>
<p>Heres a howto on highlighting the current menu item in the page you are on</p> <p><a href="http://snippets.dzone.com/posts/show/2016" rel="nofollow noreferrer">http://snippets.dzone.com/posts/show/2016</a></p>
21,145
<p>I've got a third-party program that's making WMI queries to local WMI providers (so it's not using DCOM, so packet-sniffers are out). I'd like to find out what queries these are.</p> <p>It's also on XP, so the new Vista WMI tracing infrastructure is out, as well, unfortunately.</p> <p>Any pointers?</p>
<p>Have you tried setting the WMI logging level to Verbose using wmimgmt.msc? (More info on the <a href="http://msdn.microsoft.com/en-us/library/aa392285.aspx" rel="nofollow noreferrer">MSDN Logging WMI Activity</a> page)</p> <p>You should then see the queries logged to the %windir%\system32\wbem\logs\wbemcore.log fil...
<p>I believe that WMI uses DCOM for communication, you can use WireShark to do a packet capture of the DCOM packets. I believe that the dissector in WireShark for DCOM is usable though it still might help to reference <a href="http://www.microsoft.com/msj/0398/dcom.aspx" rel="nofollow noreferrer">this article</a> (old...
49,965
<p>Is it possible to create a trigger that will not be in a transaction? </p> <p>I want to update data on a linked server with a trigger but due to firewall issues we can't create a distributed transaction between the two servers.</p>
<p>What you probably want is a combination of a queue that contains updates for the linked server and a process that reads data from the queue and updates the remote server. The trigger will then insert a message into the queue as part of the normal transaction. This data will be read by the separate process and used...
<p>I know it's not helpful, so I'll probably get downvoted for this, but really, the solution is to fix the firewall problem.</p> <p>I think if you use remote (not linked) servers (which are not the preferred option these days) then you can use SET REMOTE_PROC_TRANSACTIONS OFF to prevent the use of DTC for remote tran...
4,012
<p>I have a vb6 form with an ocx control on it. The ocx control has a button on it that I want to press from code. How do I do this?</p> <p>I have:</p> <pre><code>Dim b As CommandButton Set b = ocx.GetButton("btnPrint") SendMessage ocx.hwnd, WM_COMMAND, GetWindowLong(b.hwnd, GWL_ID), b.hwnd </code></pre> <p>but it d...
<p>I believe the following will work:</p> <pre><code>Dim b As CommandButton Set b = ocx.GetButton("btnPrint") b = True </code></pre> <p><code>CommandButton</code>s actually have two functions. One is the usual click button and the other is a toggle button that acts similar to a <code>CheckBox</code>. The default prop...
<p>Do you have access to the OCX code? You shouldn't really be directly invoking the click of a button. You should refactor the code so that the OCX button click code calls a function, e.g.</p> <pre><code>CMyWindow::OnLButtonDown() { this-&gt;FooBar(); } </code></pre> <p>Then from your VB6 app, directly call the Fo...
6,237
<p>Let's say that there is a solution that contains two projects (Project1 and Project2).</p> <p>Project1 is set as a StartUp Project (its name is displayed in a bold font). I double-click some file in Project2 to open it. The file opens, but something else happens too - Project2 gets set as a StartUp Project.</p> <p...
<p>The way to select a startup project is described in <a href="http://blogs.msdn.com/saraford/default.aspx" rel="noreferrer">Sara Ford's blog "Visual Studio Tip of the Day</a>" (highly recommended). She has a post there about <a href="http://blogs.msdn.com/saraford/archive/2008/07/29/did-you-know-how-to-select-the-sta...
<p>I ran into a bug where the project in bold would not be the startup project despite it being selected in the solution properties as the "single startup project".</p> <p>One work around for this bug was un-checking deploy, from the Configuration Manager, for the non-bold project that was being incorrectly used as th...
2,645
<p>I'd like to run a script to populate my database. I'd like to access it through the Django database API.</p> <p>The only problem is that I don't know what I would need to import to gain access to this.</p> <p>How can this be achieved?</p>
<p>Import your settings module too</p> <pre><code>import os os.environ["DJANGO_SETTINGS_MODULE"] = "mysite.settings" from mysite.polls.models import Poll, Choice </code></pre> <p>should do the trick.</p>
<p>In addition to your own models files, you need to import your settings module as well.</p>
22,020
<p>Continuous Integration toolchains for .NET, Java, and other languages are relatively well defined, but the C++ market seems to have a lot of diversity. </p> <p>By CI "toolchain" I specifically mean tools for the build scripts, automated testing, coding standards checking, etc.</p> <p>What are C++ teams using for ...
<p>Another option might be <a href="http://buildbot.net/trac" rel="noreferrer">buildbot</a>.</p> <p>It's written in python, but is not just for python apps. It can execute any script for doing your build. If you look at their success stories, there appear to be a wide variety of languages.</p>
<p>As with seemingly every other task in C++, I'm just barely limping along with continuous integration. My setup starts with Eclipse. I set it to generate make files for my projects. I have ant scripts that do the overall build tasks by running 'make all' or 'make clean' on the appropriate makefiles. These ant scripts...
4,547
<p>I was taking a look through some open-source C++ code and I noticed a lot of double underscores used within in the code, mainly at the start of variable names.</p> <pre><code>return __CYGWIN__; </code></pre> <p>Just wondering: Is there a reason for this, or is it just some people's code styles? I would think that i...
<p>From <a href="http://www.doc.ic.ac.uk/lab/cplus/c++.rules/chap5.html" rel="noreferrer">Programming in C++, Rules and Recommendations</a> :</p> <blockquote> <p>The use of two underscores (`__') in identifiers is reserved for the compiler's internal use according to the ANSI-C standard.</p> <p>Underscores (`_'...
<p>In addition to libraries which many other people responded about, Some people also name macros or #define values for use with the preprocessor. This would make it easier to work with, and may have allowed bugs in older compilers to be worked around.</p> <p>Like others mentioned, it helps prevent name collision and ...
27,720
<p>I think the best part of flash is the possibility to create not squared user interfaces, so I like the idea to create desktop apps using flash. I know AIR is for that but it doesn't allow real access to OperatingSystem apis and dlls and the commercial options are kind of difficult to customize.</p>
<p>You can try ScreenweaverHX:</p> <p><a href="http://haxe.org/com/libs/swhx" rel="nofollow noreferrer">http://haxe.org/com/libs/swhx</a></p> <p>It's the Haxe-based successor of the old Screenweaver. However, it's not as simple as the old version used to be. Most likely you need to take a look to the basics of Haxe a...
<p>Try flajector. it's powerfull converter from flash to exe. You can to develop your application using AIR. And then you can convert it into desktop application .exe</p>
9,501
<p>It seems like deployment of <code>VSTO</code> code is very cumbersome.</p> <p>My use case is I need to enforce a certain content structure in word. Am I better of doing it all in VBA?</p>
<p>It really depends on what makes most sense for your project. If it's only going to be for certain files and a couple users, I would recommend VBA. </p> <p>If it's more complex and needs to work on all files for all users, I think a VSTO plugin would be the way to go. It really depends on your situation and complexi...
<p>Keep in mind that it is not only the limitations of VBA as a language, but also the lack of industrial strength tools like unit test frameworks and source control that can be frustrating. You may trade off speed of development with long term frustration because of this if you stick to VBA.</p> <p>You could do both,...
35,247
<p>I long thought that in C, all variables had to be declared at the beginning of the function. I know that in C99, the rules are the same as in C++, but what are the variable declaration placement rules for C89/ANSI C?</p> <p>The following code compiles successfully with <code>gcc -std=c89</code> and <code>gcc -ansi<...
<p>It compiles successfully because GCC allows the declaration of <code>s</code> as a GNU extension, even though it's not part of the C89 or ANSI standard. If you want to adhere strictly to those standards, you must pass the <code>-pedantic</code> flag.</p> <p>The declaration of <code>c</code> at the start of a <code>...
<p>You should declare all variable at the top or "locally" in the function. The answer is: </p> <p><strong>It depends</strong> on what kind you system you are using:</p> <p>1/ Embedded System (especially related to lives like Airplane or Car): It does allow you to use dynamic memory (eg: calloc, malloc, new...). Imag...
36,718
<p>I am aware of the <a href="http://msdn.microsoft.com/en-us/library/system.timezone(VS.80).aspx" rel="noreferrer">System.TimeZone</a> class as well as the many uses of the <a href="http://msdn.microsoft.com/en-us/library/system.datetime.tostring(VS.80).aspx" rel="noreferrer">DateTime.ToString()</a> method. What I ha...
<p>Here's my quick hack method I just made to work around this.</p> <pre><code>public static String TimeZoneName(DateTime dt) { String sName = TimeZone.CurrentTimeZone.IsDaylightSavingTime(dt) ? TimeZone.CurrentTimeZone.DaylightName : TimeZone.CurrentTimeZone.StandardName; String sNewName = ...
<p>Ok, It's been 4 years (and almost a week), it's time we brought LINQ into the discussion...</p> <p>Putting together Criag's and Bob's ideas...</p> <pre><code>public static String TimeZoneName2(DateTime dt) { var return ToCurrentTimeZoneShortString(dt) .Split(new char[]{' '}, StringSplitOptions...
21,759
<p>For example I have a situation where I have something like this (contrived) example:</p> <pre><code>&lt;div id="outer" style="margin: auto&gt; &lt;div id="inner1" style="float: left"&gt;content&lt;/div&gt; &lt;div id="inner2" style="float: left"&gt;content&lt;/div&gt; &lt;div id="inner3" style="float: l...
<p>Try the <a href="https://addons.mozilla.org/en-US/firefox/addon/60" rel="nofollow noreferrer">Web Developer Plugin</a> for Firefox. Specifically, the <strong>Information -> Display Block Size</strong> and <strong>Outline -> Outline Block Level Elements</strong> options. This will allow to see the borders of your e...
<p>In Firebug's CSS tab, you can see what style rules apply to a selected elements in the cascading order. This may or may not help you in your problem.</p> <p>My guess would be that something about the content of #inner3 is causing it to wrap below the first line, and the #outer is just getting sized to accommodate t...
6,664
<p>Are SQL Server timeouts (SELECT queries, in particular) logged in the ERRORLOG file?</p> <p>Background is a customer with a web site having occasional "Request timeout" messages, looking to me assuming that the timeout is caused by a database timeout. There are no timeout errors in the ERRORLOG in question.</p>
<p>No. You will need to use SQL Profiler. A standard trace with the <strong>Lock Timeout</strong> event and <strong>Deadlock Graph</strong> events should do it.</p> <ul> <li><p><a href="http://msdn.microsoft.com/en-us/library/ms189107.aspx" rel="noreferrer">Lock:Timeout Event Class</a></p></li> <li><p><a href="http://...
<p>You could also use Event Notifications that get raised on the timeout and deadlock events. After it fires, you can write it to a table and or send yourself an email.</p> <p>I've shown the general technique here:</p> <blockquote> <h2><a href="http://weblogs.sqlteam.com/mladenp/archive/2008/07/18/Immediate-deadloc...
37,732
<p>I am creating a custom WPF control that let's say for simplicity sake has a vertical stack panel with a "title" TextBlock, followed by a ContentPresenter. I want the font size for the "title" to be 5 Points LARGER than the size used in the content, which is inherited by whatever container the user places this contro...
<p>I did it with an IValueConverter as follows:</p> <p>Created a class FontSizeConverter that derives from IValueConverter. The Convert method adds 10 to the value, and the ConvertBack method subtracts 10.</p> <pre><code>public class FontSizeConverter : IValueConverter { #region IValueConverter Members publ...
<p>I did it with an IValueConverter as follows:</p> <p>Created a class FontSizeConverter that derives from IValueConverter. The Convert method adds 10 to the value, and the ConvertBack method subtracts 10.</p> <pre><code>public class FontSizeConverter : IValueConverter { #region IValueConverter Members publ...
40,175