instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I'm trying to create an access control system. </p> <p>Here's a stripped down example of what the table I'm trying to control access to looks like:</p> <pre><code>things table: id group_id name 1 1 thing 1 2 1 thing 2 3 1 thing 3 4 1 thing 4 5 2 thing...
<p>I don't know the Postgres SQL dialect, but maybe something like:</p> <pre><code>select thing.*, coalesce ( ( select access from access where userid = 1 and type = 'thing' and object_id = thin...
<p>Tony:</p> <p>Not a bad solution, I like it, seems to work. Here's your query after minor tweaking:</p> <pre><code>SELECT things.*, coalesce ( ( SELECT access FROM access WHERE user_id = 1 AND type = 'thing' AND object_id = things.id ...
24,507
<p>I'm using python and CherryPy to create a simple internal website that about 2 people use. I use the built in webserver with CherryPy.quickstart and never messed with the config files. I recently changed machines so I installed the latest Python and cherrypy and when I run the site I can access it from localhost:808...
<p>That depends on how you are running the cherrypy init.</p> <p>If using cherrypy 3.1 syntax, that wold do it:</p> <pre><code>cherrypy.server.socket_host = 'www.machinename.com' cherrypy.engine.start() cherrypy.engine.block() </code></pre> <p>Of course you can have something more fancy, like subclassing the server ...
<pre><code>import cherrypy class HelloWorld(object): def index(self): return "Hello World!" index.exposed = True cherrypy.server.socket_host = '0.0.0.0' # put it here cherrypy.quickstart(HelloWorld()) </code></pre>
14,113
<p>We are planning on moving for MS Source Safe (ouch) to SVN. We are working mostly in a Microsoft environment (windows, Visual Studio, .NET) and we have developers in multiple sites. I heard about VisualSVN and integration with visual studio. On the other hand I can get someone to host SVN for me and use TortoiseSVN....
<blockquote> <p>I heard about VisualSVN and integration with visual studio</p> </blockquote> <p>Point to note, VisualSVN (the one that integrates with VStudio) is <em>not</em> a server technology at all, it is simply a integrated GUI front end to SVN, and in fact works <em>through</em> TortoiseSVN (which is <stron...
<p>You can get hosting of secure svn repositories from a variety of sources: <a href="http://beanstalkapp.com/" rel="nofollow noreferrer">http://beanstalkapp.com/</a> and many others. Often free if the usage (users, data, etc.) is limited.</p> <p>VisualSVN does integrate with Visual Studio but not like SourceSafe does...
3,599
<p>Hoi!</p> <p>I have a form I wish to submit, but I need to add the PHPSESSID, because some clients allow no cookies.</p> <p>There are several javascript functions on my page which displays a list of users (search, sort, open details), the page is generated by PHP.</p> <p>Now I am looking for an elegant way to have...
<p>(from another Q, since removed)</p> <p>Machine type: This is a quick little bit of code I based on some that gets the linker timestamp. This is in the same header, and it seems to work - it returns I386 when compiled -any cpu-, and x64 when compiled with that as the target platform.</p> <p>The Exploring PE Headers...
<p>Unix OS have a utility called "file" which identifies files. The rules for identifying are kept in a description file called "magic". You could try file to see if it is able to identify your files correctly and grab the appropriate rules out of the magic file.</p>
24,099
<p>The code I have pasted below is meant to display images on the middle 2 links without text and go back to text on the reset and fourth link. I have set display:none for the span tag only, but it does nothing. Is there anyway to do what I am after simply, without using a framework?</p> <p>edit: example</p> <pre><co...
<p>The <code>rel</code> attribute is supposed to describe the relationship of the link to the current document. It should have one of the values described <a href="http://www.w3.org/TR/html401/types.html#type-links" rel="nofollow noreferrer">here</a>. A DIV is a block-level grouping element, whereas a SPAN is an inli...
<p>The rel attribute isn't typically used by many UAs (user agents) however it specifies what relation the linked page is to the current page.</p> <p>Certain pseudo-standards have popped up around the place for example Mozilla uses the <a href="http://simonwillison.net/2002/Oct/17/mozillaPrefetching/" rel="nofollow no...
43,707
<p>Here I am faced with an issue that I believe(or at least hope) was solved 1 million times already. What I got as the input is a string that represents a length of an object in imperial units. It can go like this:</p> <pre><code>$length = "3' 2 1/2\""; </code></pre> <p>or like this:</p> <pre><code>$length = "1/2\...
<p>Here is my solution. It uses <a href="http://php.net/eval" rel="nofollow noreferrer">eval()</a> to evaluate the expression, but don't worry, the regex check at the end makes it completely safe.</p> <pre><code>function imperial2metric($number) { // Get rid of whitespace on both ends of the string. $number = ...
<p>The regexp would look something like this: </p> <pre><code>"([0-9]+)'\s*([0-9]+)\"" </code></pre> <p>(where \s represents whitespace - I'm not sure how it works in php). Then you extract the first + second group and do</p> <pre><code>(int(grp1)*12+int(grp2))*2.54 </code></pre> <p>to convert to centimeters.</p>
42,095
<p>I have a query that selects all appropriate record in a table 'hotels' and then for each hotel looks for booked room of certain type in table 'booked_rooms' and all of that for certain period. So first I'm taking out all hotel_ids from 'hotel_table', based on the location provided from the search form, and for each...
<p>Not knowing PHP, can you do it in one query?</p> <pre><code>SELECT booked_rooms.*, hotels.* FROM 'hotels' JOIN 'booked_rooms' ON hotels.hotel_id = booked_rooms.hotel_id WHERE hotels.city='$city" AND ( booked_rooms.arrival_date BETWEEN '$arrival_date' AND '$departure_date' OR booked_rooms.departure_...
<p>First of all, you have an error in your first SQL in that you haven't quoted your cityname properly. Then you don't fetch the <code>hotel_id</code> out of the resultset. And then you have the second loop in the wrong place.</p> <p>Try the following:</p> <pre><code>if( isset($_GET['book']) ) { $sql = mysql_quer...
40,830
<p>I have an array of values that is passed to my function from a different part of the program that I need to store for later processing. Since I don't know how many times my function will be called before it is time to process the data, I need a dynamic storage structure, so I chose a <code>std::vector</code>. I do...
<p>If you can construct the vector after you've gotten the array and array size, you can just say:</p> <pre><code>std::vector&lt;ValueType&gt; vec(a, a + n); </code></pre> <p>...assuming <code>a</code> is your array and <code>n</code> is the number of elements it contains. Otherwise, <code>std::copy()</code> w/<code...
<p>Assuming you know how big the item in the vector are: </p> <pre><code>std::vector&lt;int&gt; myArray; myArray.resize (item_count, 0); memcpy (&amp;myArray.front(), source, item_count * sizeof(int)); </code></pre> <p><a href="http://www.cppreference.com/wiki/stl/vector/start" rel="nofollow noreferrer">http://www.cp...
32,389
<p>Working on a movie website and would love to find an API that I could use to get information about different movies. I code in PHP but I'm assuming this would probably return XML.</p>
<p>I can recommend <a href="http://www.themoviedb.org/" rel="nofollow noreferrer">themoviedb.org</a>. We have been using their <a href="http://api.themoviedb.org/2.0/docs/" rel="nofollow noreferrer">API</a> in an open source movie managing application with great success.</p>
<p>For getting straight-up information about movies (for instance, basic genre and title information) the Amazon associates data works pretty good. There is the condition that the data be used primarily to drive traffic to Amazon, which is something to keep in mind.</p> <p>There should be a PHP library already writte...
45,891
<p>I'd like to use the Wiimote (accelerometers, gyroscopes, infrared camera, etc, etc, etc) on various applications.</p> <p>It's a bluetooth device, and I know others have connected it to their computer.</p> <ul> <li>What's the easiest way to start using it in my software - are there libraries for C#, for instance?<...
<p>Have you seen <a href="http://procrastineering.blogspot.com/" rel="noreferrer">Johnny Chung Lee's 'Procrastineering' Blog</a>? He's written a lot on the subject of using wii remotes and has some fantastic demonstration videos. <strong>[Edit]</strong> I just found out Mr Lee did <a href="http://www.ted.com/index.php/...
<blockquote> <p>what's the current easiest way to connect a wiimote to the computer?</p> </blockquote> <p>I not found solution for connect wiimote within my software, you have to connect manually into Windows, but on Windows register bluetooth device it very take time, Try Toshiba bluetooth stack it more convenien...
21,050
<p>This is my first time attempting to call an ASP.NET page method from jQuery. I am getting a status 500 error with the responseText message that the web method cannot be found. Here is my jQuery $.ajax call:</p> <pre><code>function callCancelPlan(activePlanId, ntLogin) { var paramList = '{"activePlanId":"' + act...
<p>Your web method needs to be public and static.</p>
<p>First Of All Don't Forget To Include using System.Web.Services;</p> <p>And Make Sure Your Method Should Be Public And Static and avoid adding Multiple Scripts in same Page like jquerymin.js shouldn't be used for every Function/Method in same Page</p> <p>[WebMethod] public static sting MethodName(){}</p> <p>I Had The...
21,707
<p>I work in a teaching hospital and we have a research project we're interested in pursuing. We'd like to 3D Print tubes we'd implant into rats to help with nerve regeneration. We're interested in the shape of the tubes right now, more so than what material it is or whether it's biocompatible etc.. </p> <p>So thi...
<p>This is an interesting question. A good thing to note when we start talking about SLA and other jewelry grade 3d printing, that you will have to factor in the materials toxicity when we start talking about medical applications. You can also look into DLP 3d printers but they will not have as good quality. </p> <p>W...
<p>FDM/FF printers can#t achieve those resolutions due to several constraints. The biggest problems are wall thickness and resolution:</p> <p>The print needs to be made from walls that are at least one nozzle wide. Commonly available nozzles go down to the 0.15 to 0.2 mm area, so the thinnest wall has to be at least th...
1,284
<p>The following source code alerts the following results:</p> <p><strong>Internet Explorer 7</strong>: 29<br> <strong>Firefox 3.0.3</strong>: 37 (correct)<br> <strong>Safari 3.0.4 (523.12.9)</strong>: 38<br> <strong>Google Chrome 0.3.154.9</strong>: 38 </p> <p>Please ignore the following facts: </p> <ul> <li>Webk...
<p>IE tries to be helpful and hides text nodes that contain only whitespace.</p> <p>In the following:</p> <pre><code>&lt;p&gt; &lt;input&gt; &lt;/p&gt; </code></pre> <p>W3C DOM spec says that <code>&lt;p&gt;</code> has 3 child nodes ("\n", <code>&lt;input&gt;</code> and "\n"), IE will pretend there's only one.</p> ...
<p>Well... I'd say the reason it that it is IE. I don't think the programers had a specific intention to do it that way.</p>
35,611
<p>In ASP.NET, the tilde (~) is treated as a token in URLs and treats paths prefixed with that as relative to the application root. This is well-known functionality.</p> <p>In MOSS, there are other tokens, such as ~sitecollection/mypath... which behaves in a similar way, but treats the path as relative to the site col...
<p>It may not be the only place, but <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.getserverrelativeurlfromprefixedurl.aspx" rel="nofollow noreferrer">SPUtility.GetServerRelativeUrlFromPrefixedUrl()</a> will parse URLs with ~site and ~sitecollection. MOSS also provides <a hre...
<p>I don't know for sure - but I'd bet that code is buried in one of the SharePoint HTTPModules or HTTPHandlers that run for every request.</p>
43,837
<p>We've used both JWebUnit and HttpUnit in the past to do functional tests of web applications. Both of them seem to have issues in handling javascript. We are not particularly interested in testing the javascript at this point, but JWebUnit and HttpUnit tests have broken since we added some small Ajax components (Doj...
<p><a href="http://webtest.canoo.com/webtest/manual/Downloads.html" rel="nofollow noreferrer">Canoo's WebTest</a> is pretty good and can handle what you're looking for.</p>
<p>Go with Canoon. Canoon is built upon HtmlUnit, and was previously built upon HttpUnit. </p> <p>yc</p>
38,563
<p>You guys were very helpful yesterday. I am still a bit confused here though. </p> <p>I want to make it so that the numbers on the rightmost column are rounded off to the nearest dollar:</p> <p><a href="http://www.nextadvisor.com/voip_services/voip_calculator.php?monthlybill=50&amp;Submit=Submit" rel="nofollow no...
<p>Do you want rounded up/down/truncated to the nearest dollar?</p> <p>Here are some suggested functions you can use:</p> <p><strong>Rounding</strong></p> <p><a href="http://us.php.net/manual/en/function.round.php" rel="noreferrer">round</a></p> <p><a href="http://us.php.net/manual/en/function.floor.php" rel="noref...
<p><code>money_format()</code> is a function that returns a string value of a formatted number. You have control over the formatting and, obviously, your number. A simple example, if you have your value in the variable <code>$myNumber</code>, you could incorporate the result into a given table's data cell like so;</p> ...
44,979
<p><strong>My Goal</strong></p> <p>I would like to have a main processing thread (non GUI), and be able to spin off GUIs in their own background threads as needed, and having my main non GUI thread keep working. Put another way, I want my main non GUI-thread to be the owner of the GUI-thread and not vice versa. I'm no...
<p><strong>Application.Run</strong> method displays one (or more) forms and initiates the standard message loop which runs until all the forms are closed. You cannot force a return from that method except by closing all your forms or forcing an application shutdown.</p> <p>You can, however, pass an <strong>Application...
<p>I'm sure this is possible if you hack at it hard enough, but I'd suggest it is not a good idea.</p> <p>'Windows' (that you see on the screen) are highly coupled to processes. That is, each process which displays any GUI is expected to have a Message Loop, which processes all of the messages which are involved with ...
2,501
<p>On this page (<a href="http://www.bonniesphere.com/blog/elsewhere/" rel="nofollow noreferrer">http://www.bonniesphere.com/blog/elsewhere/</a>) the "li" items have an image instead of a bullet. But the image is centered vertically, and in multi-line entries it doesn't look good. Can anyone tell me if there is somethi...
<p>replace <strong>center</strong> with <strong>top</strong>:</p> <pre><code>background: transparent url(img/ol.gif) no-repeat scroll left top; </code></pre>
<pre><code>.entry ul {list-style-type:none;} .entry ul li{padding: 0 0 0 15px; background: url(img/ol.gif) no-repeat left top center; margin-left:10px;} </code></pre> <p>Just typed that out of the top of my head, but the "top" attribute might do it. You could try and replace the left or center with the top tag, can't...
45,852
<p>I have a bunch of latitude/longitude pairs that map to known x/y coordinates on a (geographically distorted) map.</p> <p>Then I have one more latitude/longitude pair. I want to plot it on the map as best is possible. How do I go about doing this?</p> <p>At first I decided to create a system of linear equations for...
<p>Are there any more specific details on the kind of distortion? If, for example, your latitudes and longitudes are "distorted" onto your 2D map using a Mercator projection, the conversion math is <a href="http://www.wikipedia.org/wiki/Mercator_projection" rel="noreferrer">readily available</a>.</p> <p>If the map is...
<p>the problem is that the sphere can be distorted a number of ways, and having all those points known on the equator, lets say, wont help you map points further away.</p> <p>You need better 'close' points, then you can assume these three points are on a plane with the fourth and do the interpolation --knowing that th...
2,415
<p>I have an ellipse centered at (0,0) and the bounding rectangle is x = [-5,5], y = [-6,6]. The ellipse intersects the rectangle at (-5,3),(-2.5,6),(2.5,-6),and (5,-3)</p> <p>I know nothing else about the ellipse, but the only thing I need to know is what angle the major axis is rotated at.</p> <p>seems like the ans...
<p>The gradient of the ellipse is identical to the gradient of the intersects with the bounding rectangle along one side of the ellipse. In your case, that's the line from (-2.5,6) to (5,-3), the top side of your ellipse. That line has a vertical drop of 9 and a horizontal run of 7.5.</p> <p>So we end up with the fo...
<ol> <li>Set the angle of the ellipse = 0</li> <li>Calculate the 4 points of intersection </li> <li>Work out the error between the calculated intersection points and the desired ones (i.e. sum the 4 distances).</li> <li>If error is too large use the secant method or Newton-Rhapson to work out a new angle for the ellips...
15,994
<p>I am writing a coding standards document for a team of about 15 developers with a project load of between 10 and 15 projects a year. Amongst other sections (which I may post here as I get to them) I am writing a section on code formatting. So to start with, I think it is wise that, for whatever reason, we establish ...
<p>First find a automated code-formatter that works with your language. Reason: Whatever the document says, people will inevitably break the rules. It's much easier to run code through a formatter than to nit-pick in a code review.</p> <p>If you're using a language with an existing standard (e.g. Java, C#), it's eas...
<p>It obviously varies depending on languages and technologies. By the look of your example name space I am going to guess java, in which case <a href="http://java.sun.com/docs/codeconv/" rel="nofollow noreferrer">http://java.sun.com/docs/codeconv/</a> is a really good place to start. You might also want to look at s...
6,991
<p>Using the CRM views, is there a way to retrieve a list of all of the activities linked to a specific account?</p> <p>I want it to retrieve not only those associated with the account directly, but also those associated with the account's contacts, cases, etc. I am trying to replicate the list generated when you clic...
<p>I've used something like this. Effectively I build a table var with all the guids of the items I want to search (in my case accounts and contacts) then I query AcitivtyParty for all activities where they are a party on the activity - then over to Activity to get the details.</p> <pre><code>Declare @account_guid va...
<p>check out the post below, it use a retrieve plugin to rollup activities for a custom entity, which is not supported by out-of-box CRM: <a href="http://www.catapulterp.com/blog/2013/03/11/rolling-up-custom-entities-in-microsoftcrm-2011-and-crm-online/" rel="nofollow">http://www.catapulterp.com/blog/2013/03/11/rollin...
48,497
<p>I've created a login submit form in HTML but for some reason autocompletion does not work in firefox.</p> <p>This is what happens in Firefox: - I give username and password and click on the login button - Firefox prompts me if I would like to remember the password. I press 'remember' and login works. - I log out an...
<p>Does your login URL include a session ID that changes each time?</p>
<p>I pasted your HTML into an empty HTML document, removed the <code>onsubmit=""</code> javascript code, typed in a username and password and hit submit, got prompted to save the password, and the next time I hit reload - FF3 autofilled both fields.</p> <p>WorksForMe(tm).</p> <p>I wonder if removing the <code>onsubm...
40,128
<p>I am working on an application that will sport a web-based point of sale interface.</p> <p>The point of sale PC (I am not sure as of now whether it will run on Linux or Windows) must have a fiscal printer attached to it, but like any web app, it is the server which processes all stuff. Both server and PoS machines ...
<p>I did something similar to this a couple of yrs. ago. But in my case the server and the PC where in the same lan. Is your PoS within the lan? If so, I'll explain it to you.</p> <p>In the mean time, if you have the "little app" covered you can take a look at the following:</p> <p><a href="http://java.sun.com/j2se/1...
<p>That's why you have applets. But applets run in a security sandbox. However, if the right kind of privileges are given to the applet running in a webapp, it can open socket, write to files, write to serial port, etc.</p>
18,841
<p>When using the <a href="http://en.wikipedia.org/wiki/Pimpl_idiom" rel="nofollow noreferrer">pImpl idiom</a> is it preferable to use a <code>boost:shared_ptr</code> instead of a <code>std::auto_ptr</code>? I'm sure I once read that the boost version is more exception friendly?</p> <pre><code>class Foo { public: ...
<p>You shouldn't really use std::auto_ptr for this. The destructor won't be visible at the point you declare the std::auto_ptr, so it might not be called properly. This is assuming that you are forward declaring your pImpl class, and creating the instance inside the constructor in another file.</p> <p>If you use <a hr...
<p>Don't try so hard to shoot yourself in the foot, in C++ you have plenty of opportunities :) There is no real need to use either auto pointers, since you perfectly know when your object should go in and out of life (in your constructor(s) and destructor).</p> <p>Keep it simple.</p>
40,100
<p>I got myself the Ender 3. The Home position is about 1 mm left and 2 mm in front of the front left corner. Now, the hotend center axis is 11 mm from the carrier plate with the &quot;Mk 10&quot; cooler mounted right onto a pair of 5 mm pegs that are part of the plate. As I want to change to an e3D v6, which has a dia...
<p>When homing the printer, the hot end carriage will be instructed to hit the (mechanical or optical) end stops. From this point a well configured firmware knows where to find the origin of the heat bed. </p> <p>For the printer to know the origin of the bed, offsets are defined in the firmware from the end stop locat...
<p><em>Following on from 0scar's answer</em></p> <hr /> <p>To change or obtain your EEPROM settings you need to open Repetier Host (for Linux or Windows, v2.1.3 - the OSX version I tried, v1.1.0, didn't seem to have this functionality).</p> <h3>To change existing settings</h3> <p>From <a href="https://forum.repetier.co...
963
<p>In a <a href="http://www.hackification.com/2008/12/03/linq-to-entities-the-blackberry-storm-of-orms/" rel="nofollow noreferrer">controversial blog post</a> today, Hackification pontificates on what appears to be a bug in the new LINQ To Entities framework: </p> <blockquote> <p>Suppose I search for a customer:</p>...
<p>Jon,</p> <p>I've been playing with linq to entities also. It's got a long way to go before it catches up with linq to SQL. I've had to use linq to entities for the Table per Type Inheritance stuff. I found a good article recently which explains the whole 1 company 2 different ORM technologies thing <a href="http://...
<p>I don't know much about ORMs, but as a user of LinqToSql and LinqToEntities I would hope that when you try to query Orders for Alice it does the extra query for you when you make the linq query (as opposed to not querying anything or querying everything for every row).</p> <p>It seems natural to expect </p> <pre><...
44,015
<p>I have a <a href="https://flex3drive.com/" rel="nofollow noreferrer">Flex3Drive</a> remote-direct-drive extruder I bought for my Ender 3 (with the original extruder motor), and I'm pretty happy with it except for abysmal retraction performance due to the 40:1 reduction, which requires the motor to turn about 480° to...
<p>In general I would use <a href="https://github.com/rcarlyle/StepperSim" rel="nofollow noreferrer">https://github.com/rcarlyle/StepperSim</a> which takes into account more parameters.</p> <p>You can play with voltage and current to see which combination gives you the best results for your motor.</p> <p>Or you can cha...
<p>I was considering buying a Fl3xdrive but had this exact fear, that the speed (rotation) required for retractions was too much.</p> <p>I stumbled upon this post while looking for a project for a step-up gearbox. I found a <a href="https://www.thingiverse.com/thing:3714978" rel="nofollow noreferrer">Nema 17 Gearbox &q...
1,894
<p>I've been involved in developing coding standards which were quite elaborate. My own experience is that it was hard to enforce if you don't have proper processes to maintain it and strategies to uphold it.</p> <p>Now I'm working in, and leading, an environment even less probable to have processes and follow-up stra...
<p>Prefer <a href="http://en.wikipedia.org/wiki/Resource_acquisition_is_initialization" rel="noreferrer">RAII</a>.</p> <p>STL's auto (and shared in boost &amp; C++0x) pointers may help.</p>
<p>No tabs (allows better use of external/other tools) and a fixed spaces inserted for tabs.</p>
30,058
<p>I'm working on an internal project for my company, and part of the project is to be able to parse various "Tasks" from an XML file into a collection of tasks to be ran later.</p> <p>Because each type of Task has a multitude of different associated fields, I decided it would be best to represent each type of Task wi...
<p>I use reflection to do this. You can make a factory that basically expands without you having to add any extra code.</p> <p>make sure you have "using System.Reflection", place the following code in your instantiation method.</p> <pre><code>public Task CreateTask(XmlElement elem) { if (elem != null) { ...
<p>@ChanChan</p> <p>I like the idea of reflection, yet at the same time I've always been shy to use reflection. It's always struck me as a "hack" to work around something that should be easier. I did consider that approach, and then figured a switch statement would be faster for the same amount of code smell.</p> <p>...
4,696
<p>What principles do you generally follow when doing class design?</p>
<h3>Principles Of Object Oriented Class Design (the &quot;SOLID&quot; principles)</h3> <ul> <li><strong>SRP: The Single Responsibility Principle</strong> A class should have one, and only one, reason to change.</li> <li><strong>OCP: The Open Closed Principle</strong> You should be able to extend a classes behavior, w...
<p>I usually try to fit the class into one of the oo <a href="http://en.wikipedia.org/wiki/Design_pattern_(computer_science)" rel="nofollow noreferrer">design patterns.</a></p>
12,404
<p>How do you format the date time to just date? </p> <p>For example, this is what I retrieved from the database: 12/31/2008 12:00:00 AM, but I just want to show the date and no time.</p>
<p>Either use one of the <a href="http://msdn.microsoft.com/en-us/library/az4se3k1.aspx" rel="noreferrer">standard date and time format strings</a> which only specifies the date (e.g. "D" or "d"), or a <a href="http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx" rel="noreferrer">custom date and time format string</a...
<p>Or, if for some reason you don't like any of the more sensible answers, just discard everything to the right of (and including) the space.</p>
46,551
<p>Is there a tutotial or help file, suitable for a beginner c# programmer to use.</p>
<p>The primary documentation for the Farseer Physics engine is on the homepage.</p> <p><a href="http://www.codeplex.com/FarseerPhysics/Wiki/View.aspx?title=Documentation&amp;referringTitle=Home" rel="noreferrer">http://www.codeplex.com/FarseerPhysics/Wiki/View.aspx?title=Documentation&amp;referringTitle=Home</a></p> ...
<p>Great webcast with a Farseer tutorial - <a href="http://msdn.microsoft.com/en-us/hh781459.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/hh781459.aspx</a></p>
12,763
<p>How do you go about building a complete keyboard-accessible web application? Assuming that this for a controlled deployment environment (for use within an org) where access is restricted (not open to public). </p> <p>Update: Forgot to mention that this is aimed at improving data entry efficiency and is not disabili...
<p>Well, first of all, you have to make strong assumptions in order to have a chance to reach your goal:</p> <ul> <li><strong>You'll have to support only one browser.</strong> If not, you're ready for a pain in the ass process as all the browser have different already predefined shortcuts.</li> <li><strong>You'll work...
<p>The <a href="http://discuss.joelonsoftware.com/help/topics/basics/KeyboardShortcuts.html" rel="nofollow noreferrer">keyboard shortcut functionality in Fogbugz</a> is some of the best keyboard support I've seen in a web application.</p> <p>It obviously entails writing a lot of Javascript - I'm not sure if Joel has d...
47,341
<p>Does anyone have any info on creating/drawing a customised ListView object?</p> <p>Currently Im working on a project that requires a customised look and feel within the application. I am using a standard (Windows.Forms) ListView which is not in the same style as the rest of the GUI. We are NOT using a toolbox for c...
<p>From what I can tell you will need to actually make some Win32 calls using <code>NM_CUSTOMDRAW</code> to actually change the paint behavior of the control. <a href="https://web.archive.org/web/20061221082010/http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic34342.aspx" rel="nofol...
<p>From what I can tell you will need to actually make some Win32 calls using <code>NM_CUSTOMDRAW</code> to actually change the paint behavior of the control. <a href="https://web.archive.org/web/20061221082010/http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic34342.aspx" rel="nofol...
22,819
<p>When I connect my digital camera with my computer, a dialog box containing all the registered programs can be used to get images from the camera will appear. Now I want to add my own program in the list, so that when I click the item of my program, I can use my own program to get images from the digital camera.</p> ...
<p>WIA has a Device Manager object that provides an interface that allows for programs to register for event notifications.</p> <h2>Contacting the Device Manager</h2> <p>You use the <code>IWiaDevMgr</code> interface to interact with the device manager. You get a pointer to that interface with a call to <code>CoCreate...
<p>You need to use the WIA (Windows Image Acquisition) interface. IWiaDevMgr provides three methods to do this: RegisterEventCallbackProgram, RegisterEventCallbackCLSID, and RegisterEventCallbackInterface. If you want Windows to start your program when the user clicks you in the Autoplay dialog, you can use either Regi...
42,075
<p>I am trying to so something like <a href="https://stackoverflow.com/questions/48475/database-design-for-tagging">Database Design for Tagging</a>, except each of my tags are grouped into categories.</p> <p>For example, let's say I have a database about vehicles. Let's say we actually don't know very much about vehi...
<p>This is yet another variation on the <a href="http://en.wikipedia.org/wiki/Entity-attribute-value_model" rel="nofollow noreferrer">Entity-Attribute-Value</a> design.</p> <p>A more recognizable EAV table looks like the following:</p> <pre><code>CREATE TABLE vehicleEAV ( vid INTEGER, attr_name VARCHAR(20...
<p>I think your solution is to simply add a manufacturer column to your vehicles table. It's an attribute that you know all the vehicles will have (i.e. cars don't spontaneously appear by themselves) and by making it a column in your vehicle table you solve the issue of having one and only one manufacturer for each ve...
48,790
<p>Three buttons, Save, Cancel, Close looks messy, yet after the user has saved the data should they really click a Cancel button?</p> <p>I need the 'Save' button to leave the form open.</p> <p>What is best practice?</p> <p>Thanks</p>
<p>The standard on Windows is OK and Cancel. The OK button will save and close the screen. The cancel button will close and lose changes. If they want to periodically save changes then add an Apply button. This will save and continue without closing.</p>
<p>What happens if the user doesn't want to save the information? Does the form roll back the changes to be displayed again, or does it shut down? If the form needs to close right away, then by all means, dispose of the cancel button. If there is something else that might need to happen, then you might want to keep it ...
25,309
<p>Is there a way to search for multiple strings simultaneously in Vim? I recall reading somewhere that it was possible but somehow forgot the technique.</p> <p>So for example, I have a text file and I want to search for "foo" and "bar" simultaneously (not necessarily as a single string, can be in different lines alto...
<pre><code>/^joe.*fred.*bill/ : find joe AND fred AND Bill (Joe at start of line) /fred\|joe : Search for FRED OR JOE </code></pre>
<pre><code>/(foo|bar) </code></pre>
15,965
<p><code>fopen</code> is failing when I try to read in a very moderately sized file in <code>PHP</code>. <code>A 6 meg file</code> makes it choke, though smaller files around <code>100k</code> are just fine. i've read that it is sometimes necessary to recompile <code>PHP</code> with the <code>-D_FILE_OFFSET_BITS=64</...
<p>Are you sure that it's <code>fopen</code> that's failing and not your script's timeout setting? The default is usually around 30 seconds or so, and if your file is taking longer than that to read in, it may be tripping that up.</p> <p>Another thing to consider may be the memory limit on your script - reading the fi...
<p>Have you tried file() ?</p> <p><a href="http://is2.php.net/manual/en/function.file.php" rel="nofollow noreferrer">http://is2.php.net/manual/en/function.file.php</a></p> <p>Or file_ get_contents()</p> <p><a href="http://is2.php.net/manual/en/function.file-get-contents.php" rel="nofollow noreferrer">http://is2.php....
19,616
<p>I'm looking for a log viewer with similar capablilties as Chainsaw, in which I can tail Glassfish log files over for instance SSH/SCP. Does anyone know if such a tool exist?</p>
<p>OtrosLogViewer user VFSFileSystems and can load logs from remote server (ftp, sftp, smb, http). It supports java.util.logging.XMLFormatter and java.util.logging.SimpleFormatter. See: <a href="http://code.google.com/p/otroslogviewer/" rel="noreferrer">http://code.google.com/p/otroslogviewer/</a></p>
<p>VFSLogFilePatternReceiver uses Jakarta Commons-VFS, so it supports SFTP and SCP. See: <a href="http://commons.apache.org/vfs/filesystems.html#SFTP" rel="nofollow noreferrer">http://commons.apache.org/vfs/filesystems.html#SFTP</a></p>
22,629
<p><strong>Is there some way to force some files to not be merged automatically (force me to manage the merge) when merging a branch back into the main tree?</strong> </p> <p>For example, I have web.config files that have specific paths based on whether I'm in the Dev or Production system. So, when I need to merge my ...
<p>One way I've seen this handled is:</p> <ol> <li>Keep your configs in separate directories (dev, uat, prod, etc.)</li> <li>Check these in to SVN </li> <li>Modify your build process so that it copies the appropriate config into the bin/ directory, based on a command-line parameter</li> </ol>
<p>If you aren't concerned with sharing configuration information (such as database access), you could easily wrap the dev/prod specific sections in an if->then.</p> <pre><code>if (production) { db = prod } else { db = dev } </code></pre> <p>I've seen a few methods on determining environment, from the machine's...
28,476
<p>How do you get Perl to stop and give a stack trace when you reference an undef value, rather than merely warning? It seems that <code>use strict;</code> isn't sufficient for this purpose.</p>
<pre><code>use warnings FATAL =&gt; 'uninitialized'; use Carp (); $SIG{__DIE__} = \&amp;Carp::confess; </code></pre> <p>The first line makes the warning fatal. The next two cause a stack trace when your program dies.</p> <p>See also <code>man 3pm warnings</code> for more details.</p>
<p>You have to do this manually. The above "answers" do not work! Just test out this:</p> <pre><code>use strict; use warnings FATAL =&gt; 'uninitialized'; use Carp (); $SIG{__DIE__} = \&amp;Carp::confess; my $x = undef; # it would be enough to say my $x; if (!$x-&gt;{test}) { print "no warnings, no errors\n"; } </cod...
10,337
<p>I've got a somewhat primitive framework I've been using for most of my projects, but a general design issue came to mind that I haven't been able to work out yet. For a given application, should I separate the application-specific class structure from the framework's structure, or is building on top of the framework...
<p>What it really comes down to is what are you going to do when you update Framework\Control.php in Application XYZ. Are you going to go back to Application ABC and make that same change? What if it's a critical bug?</p> <p>For maintainability of all of your projects I'd go with your second option.</p>
<p>What it really comes down to is what are you going to do when you update Framework\Control.php in Application XYZ. Are you going to go back to Application ABC and make that same change? What if it's a critical bug?</p> <p>For maintainability of all of your projects I'd go with your second option.</p>
27,132
<p>I need to find the PID of the current running process on a Linux platform (it can be a system dependent solution). Java does not support getting the process ID, and JRuby currently has a bug with the Ruby method, Process.pid.</p> <p>Is there another way to obtain the PID?</p>
<p>If you have <a href="http://en.wikipedia.org/wiki/Procfs" rel="nofollow noreferrer">procfs</a> installed, you can find the process id via the /proc/self symlink, which points to a directory whose name is the pid (there are also files here with other pertinent information, including the PID, but the directory is all ...
<p>You can try getpid() in <a href="https://github.com/jnr/jnr-posix" rel="nofollow">JNR-Posix</a>.</p> <p>It also has a Windows POSIX wrapper that calls getpid() off of libc. No JNI needed.</p>
16,707
<p>I'm having trouble getting pictures supported with PIL - it throws me this:</p> <pre><code>IOError: decoder jpeg not available </code></pre> <p>I installed PIL from binary, not realizing I needed libjpeg.</p> <p>I installed libjpeg and freetype2 through fink. </p> <p>I tried to reinstall PIL using instructions f...
<p>I had the similar 'jpeg decoder problem' recently when deploying a django project on a product RHEL box that required PIL. I downloaded PIL, and ran 'python setup.py install' instantly, and was happy that everything was working, until I bumped into the problem. Solution: libjpeg was already installed on the system, ...
<p>Is the python path still looking at the old binary version of libjpeg?</p> <p>You will need to modify it to point to the new place if it is.</p> <p>When you compiled the new version of the PIL did it say that it found libjpeg? It will compile happily without it (iirc) and the first sign of trouble you will see is ...
31,005
<p>I have a delegate, say:</p> <pre><code>public delegate void MyDelegate(); </code></pre> <p>I have an event, say:</p> <pre><code>public MyDelegate MyEvent; </code></pre> <p>While invoking the event I am receiving an error message:</p> <blockquote> <p>"MyEvent += expected ....."</p> </blockquote> <p>How do I r...
<p>You can only invoke the event from within the class where you declared it. In any other place, you can only add or remove handlers from the event delegate via the operators <code>+=</code> and <code>-=</code>, hence the error message.</p>
<p>Also you might want to take a look at this post about <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c#9282">avoiding checking for null delegates</a></p>
37,550
<p>My application is a vb6 executable, but some newer forms in the system are written in C#. I would like to be able to set the C# form's Owner property using a handle to the main application window, so that the dialogs remain on top when tabbing back and forth between my app and other apps.</p> <p>I can get the hwnd...
<p>So you are calling a C# Windows Form class from VB6, which means you are probably using either <code>Show()</code> or <code>ShowDialog()</code>, correct? Both of those methods also take an IWin32Window parameter, which simply defines an object that returns an IntPtr property named Handle.</p> <p>So...you need to ad...
<p>This is too long to post as a comment...</p> <p>I think the problem you are running in to is the way you wrapped the code I presented in the ShowDialog overload. If you follow what your <code>GetWindowFromHost</code> code is doing it goes through the following steps:</p> <ol> <li>Creates a new IntPtr from the hwnd...
26,266
<p>What benchmark would test how well my hardware rates, for my ASP.NET, SQL Server, IIS product?</p> <p>I have two servers, one runs my code much faster than the other and I believe their configurations are close to equivalent and therefore I want to benchmark the two.</p> <p>I <strong>do not</strong> want this ques...
<p>I would say the single best solution I've found for this problem is <a href="http://msdn.microsoft.com/en-us/vsts2008/test/default.aspx" rel="nofollow noreferrer">Visual Studio Team Test Edition</a>. You can write your stress tests in whatever .NET language you like and its learnable and discoverable. The metrics ...
<p>I too have heard good things about VS test edition. However for testing of web apps, Jmeter is a great free tool, and quicker to get running.</p> <p><a href="http://jmeter.apache.org/" rel="nofollow noreferrer">http://jmeter.apache.org/</a></p>
34,613
<p>I have a PHP script that needs to determine if it's been executed via the command-line or via HTTP, primarily for output-formatting purposes. What's the canonical way of doing this? I had thought it was to inspect <code>SERVER['argc']</code>, but it turns out this is populated, even when using the 'Apache 2.0 Handle...
<p>Use the <a href="http://php.net/php_sapi_name" rel="noreferrer"><code>php_sapi_name()</code></a> function.</p> <pre class="lang-php prettyprint-override"><code>if (php_sapi_name() == "cli") { // In cli-mode } else { // Not in cli-mode } </code></pre> <p>Here are some relevant notes from the docs:</p> <blo...
<p>I think</p> <pre><code>$_SERVER['REMOTE_ADDR'] </code></pre> <p>will not be populated from the CLI.</p> <p>Also, all the HTTP_* keys in the $_SERVER superglobal won't be populated from the CLI, or do it the right way hop just mentioned :-)</p>
20,951
<p>Can anyone tell me what version of the .NET framework (CLR and BCL) is req'd for the recently-released MS Sync Framework (for support of occasionally-connected-applications)?</p> <p>Its listed as Sync Framework V1 for ADO.NET v2.0 but none of its listed req'ments say anything about the .NET fx version that is requi...
<p>Sync Services for ADO.NET 2.0 requires ADO.NET 2.0 on the server. Sync Services requires ADO.NET 2.0 for desktop clients or .NET Compact Framework 2.0 Service Pack 2 for device clients.</p> <p>So, you should have .net framework 2.0 or above.</p>
<p>If it specifies ADO.NET 2.0, then you'll need at least .NET 2.0. ADO.NET changed a lot between 1.1 and 2.0</p>
19,261
<p>I am using the E3D v6 hotend with the titan extruder. Everytime I go to do a test print, just enough stringy filament oozes comes out of the hotend "right before" it lays down the first layer. I have no idea why it oozes out the little bit of filament before it prints.... The unwanted filament builds up while some o...
<p>As the filament in the melt chamber heats up, it's going to inevitably ooze a little bit. Make sure you watch for this and clean it off as the hot-end heats up, and setup you slicing software to print a skirt, which will print a few loops around the outside of your print, separated by a few mm, to deal with ooze an...
<p>In general, it's a bit normal to have <em>some</em> filament ooze during warm-up. However, if it seems to be an abnormal amount, you may want to consider reducing your target temperature.</p> <p>Keep in mind that ideal extrusion temperatures are subjective to the source of your filament. Not all filament is of the ...
332
<p>I want to create Windows service in such a way :</p> <p>-> It takes input database information ...</p> <p>-> at completion of service it notifies user for completion of process.</p> <p>How can I do this with Windows service in C#.Net?</p> <p>Thanks</p>
<p>I think you are asking three questions:</p> <ol> <li>How do I create a Windows Service</li> <li>How do I open and read data from a database</li> <li>How do I notify a user</li> </ol> <p>Answers:</p> <ol> <li><a href="http://www.codeproject.com/KB/dotnet/simplewindowsservice.aspx" rel="nofollow noreferrer">Example...
<p>Based on some of the clues you provided in your question, I think you should probably look at WCF:</p> <p><a href="http://msdn.microsoft.com/en-us/netframework/aa663324.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/netframework/aa663324.aspx</a></p>
42,786
<p>I'm making a small web application in Seaside. I have a login component, and after the user logs in I want to send along a cookie when the next component renders itself. Is there a way to get at the object handling the response so I can add something to the headers it will output?</p> <p>I'm trying to avoid using W...
<p>There is currently no built-in way to add cookies during the action/callback phase of request processing. This is most likely a defect and is noted in this issue: <a href="http://code.google.com/p/seaside/issues/detail?id=48" rel="nofollow noreferrer">http://code.google.com/p/seaside/issues/detail?id=48</a></p> <p>...
<p>I've just looked into this in depth, and the answer seems to be no. Specifically, there's no way to get at the response from the WARenderCanvas or anything it can access (it holds onto the WARenderingContext, which holds onto the WAHtmlStreamDocument, which holds onto the response's <em>stream</em> but not the resp...
11,390
<p>I am looking for a way to add a drop down list in WPF to a menu. This used to be really easy in winforms and so I am expecting you experts to know just now to do it in WPF. Thanks.</p> <p>Sorry if this is a bad question, it is late and I don't want to think.</p>
<p>It is very easy to add any UIElement to any control, You can just add Combobox to a Menu control and create menu as bellow.</p> <pre><code>&lt;Menu&gt; &lt;MenuItem Header="File"&gt; &lt;MenuItem Header="Open"/&gt; &lt;MenuItem Header="Close"/&gt; &lt;Separator/&gt; &lt;ComboBox ...
<p>While this is very easy to do as Jobi Joy has shown, I think it has horrible usability. The Menu control supports multiple levels of menu items and I would go down that route for UI consistency.</p>
23,919
<p>I have seen this in a lot of XML comments for classes in the .NET Framework BCL but have never been able to find documentation that explains what it does.</p> <p>As an example, looking at System.Object reveals the following comments:</p> <pre><code>namespace System { /// &lt;summary&gt;Supports all classes ...
<p>Just a guess: the All vs Common tabs in intellisense?</p>
<p>It is the same as decorating your member with EditorBrowsableAttribute. I would guess values 0,1 and 2 corresponds to Always, Advanced and Never.</p>
35,595
<p>Not many are aware of this feature, but Python's functions (and methods) can have <a href="http://www.python.org/dev/peps/pep-0232/" rel="noreferrer">attributes</a>. Behold:</p> <pre><code>&gt;&gt;&gt; def foo(x): ... pass ... &gt;&gt;&gt; foo.score = 10 &gt;&gt;&gt; dir(foo) ['__call__', '__class__', '__d...
<p>I typically use function attributes as storage for annotations. Suppose I want to write, in the style of C# (indicating that a certain method should be part of the web service interface)</p> <pre><code>class Foo(WebService): @webmethod def bar(self, arg1, arg2): ... </code></pre> <p>then I can def...
<p>I was always of the assumption that the only reason this was possible was so there was a logical place to put a doc-string or other such stuff. I know if I used it for any production code it'd confuse most who read it.</p>
43,881
<p>Anyone know whether it is possible to put mod_python under JBoss like you can Apache HTTPD? Given that JBoss has Tomcat inside it would seem to be a reasonable thing to do.</p> <p>If not mod_python is there any python support under JBoss which will keep the interpreter in memory?</p>
<p>I'm not sure about running <code>mod_perl</code> in JBoss, but here are a couple of approaches you might want to consider:</p> <h3>Enabling CGI</h3> <p>You can enable CGI within tomcat. See <a href="http://www.wellho.net/forum/Perl-Programming/Running-Perl-CGI-scripts-under-Apache-Tomcat.html" rel="nofollow noreferr...
<p>Have you looked into <a href="http://www.jython.org/Project/" rel="nofollow noreferrer">Jython</a>? Tomcat is built in Java after all.</p>
39,212
<p>Does anyone know if it is possible to add other controls to a Flex 3 Alert? What I need is a modal dialoge that allows the user to type in a filename before clicking OK or CANCEL. This seems like it would be best achieved with an Alert but in the documentation I don't see an obvious way to add a TextInput (or any ot...
<p>I believe you are looking for a flex Title Window. The Alert allows configuring of buttons and text of the buttons. There are some examples of the title window <a href="https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/containers/TitleWindow.html" rel="nofollow noreferrer">here</a>.</p>
<p>I believe creating your own component to serve this purpose is your only route. You can always use the styles of the alert dialog though so it will look like all other alerts and keep a similar feel throughout your application.</p>
25,324
<p>I'm doing some straight up asynchronous calls from javascript using the XMLHTTPRequest object. On success, with certain return values, I would like to do an asynchonous post back on an update panel and run some server side methods. This is about how I'm implementing it now:</p> <pre><code>&lt;script language="java...
<p>Be very careful with UpdatePanels, they can be very heavy if not used properly as I explain <a href="http://www.aaron-powell.com/blog.aspx?id=1195" rel="nofollow noreferrer">here</a>.</p> <p>But the JavaScript for submitting a form is:</p> <pre><code>__doPostBack('eventTarget','eventArguments'); </code></pre> <p>...
<p>You can remove the hidden button and call</p> <p>__doPostBack('upStatus','');</p> <p>This will cause an asynchronous update for that update panel</p>
44,869
<p>I just downloaded and installed the latest Adventure Works database from <a href="http://www.codeplex.com/MSFTDBProdSamples/Release/ProjectReleases.aspx?ReleaseId=16040" rel="nofollow noreferrer">http://www.codeplex.com/MSFTDBProdSamples/Release/ProjectReleases.aspx?ReleaseId=16040</a> to do some more playing around...
<p>According to this <a href="http://www.sqlskills.com/blogs/bobb/post/SQL-Server-2008-data-types-in-LINQ-to-SQL-and-EF-they-(mostly)-did-it.aspx" rel="noreferrer">blog post</a> it's everything except the spatial types (Geometry and Geography) and the HierarchyID data type.</p> <p>As for why? Well they release support...
<p>SqlGeography and LINQ to SQL</p> <p>Problem: Its a case when we use spatial data types (<code>Geometry</code>, <code>Geography</code>) supported by SQL Server 2008 in LINQ to SQL.</p> <p>Solution: Step 1: Create a view that is based on the desired table and that does not include the unsupported data type (just...
22,817
<p>Given a point such as (0, 0, 0) and a vector like (x, y, z). What is the easiest way to align the negative Z-axis centered at (0, 0, 0) to point in the direction of this vector? Examples using OpenGL would be welcome, but not neccessary.</p>
<p>There's lots of different ways to rotate a coordinate-frame to point in a given direction; they'll all leave the z-axis pointed in the direction you want, but with variations in how the x- and y-axes are oriented.</p> <p>The following gets you the shortest rotation, which may or may not be what you want.</p> <pre>...
<p>There are lots of resources out there about rotating your coordinates (or rotating objects, which amounts to the same thing). I learnt a lot from <a href="http://tfpsly.free.fr/Docs/3dIca/3dica2.htm#chap23" rel="nofollow noreferrer">this site</a>, both about how to program in multiple dimensions and especially <a h...
23,567
<p>In LINQ to SQL, is it possible to check to see if an entity is already part of the data context before trying to attach it?</p> <p>A little context if it helps...</p> <p>I have this code in my <code>global.asax</code> as a helper method. Normally, between requests, this isn't a problem. But right after signing i...
<p>My rules:</p> <ol> <li>Don't initialize with the default values in declaration (<code>null</code>, <code>false</code>, <code>0</code>, <code>0.0</code>…).</li> <li>Prefer initialization in declaration if you don't have a constructor parameter that changes the value of the field.</li> <li>If the value of the field c...
<p>I normally try the constructor to do nothing but getting the dependencies and initializing the related instance members with them. This will make you life easier if you want to unit test your classes.</p> <p>If the value you are going to assign to an instance variable does not get influenced by any of the parameter...
4,419
<p>Are the formulas represented in a <a href="http://en.wikipedia.org/wiki/Abstract_syntax_tree" rel="nofollow noreferrer">syntax tree</a> then recalculated using a design pattern like the Visitor pattern? How would you go about reproducing the recalculation process in code?</p>
<p>Probably, as you say, one guess is that Excel creates a bunch of ASTs, one for each indipendent group of cells, where the leaves are the originating, static data, and the nodes are formulas.</p> <p>Then it calculates the result for each node, with a <a href="http://en.wikipedia.org/wiki/Tree_traversal#Iterative_tra...
<blockquote> <p>Are the formulas represented in an AST then recalculated using a design pattern like the Visitor pattern?</p> </blockquote> <p>You're thinking <a href="http://en.wikipedia.org/wiki/Interpreter_pattern" rel="nofollow noreferrer">interpreter</a>, not visitor. While treewalking using a visitor can be em...
40,652
<p>I thought the answer was ABS, but I read about how some people used it to print parts that were used in plumbing, and they failed when put under constant load, and some said that PETG is better for this application. I want to print bases for my table legs, would PETG be a better material to use?</p>
<p>The CR-6 SE uses strain gauge based sensing for the auto leveling. This implies that the nozzle itself is the probe for the leveling procedure. It is important that there is no filament left on the nozzle and no debris is on the bed (of so, this causes incorrect measurement of the bed surface and results in a too la...
<p>It almost looks like that nozzle is too far away from the bed. Try releveling your bed.</p>
2,194
<p>I have a n-tier winform client server application running against sqlserver DB. I want it to be able sometimes to run "offline" (not connected to the DB) and on reconnect, reconsile the changes to the main DB. Now, this i have tough architecture decision to make: should i use database replication or manage it myself...
<p><em>(<strong>Disclaimer</strong>: I'm assuming that you've already considered using .NET DataSets and discounted them, given that they're designed to help with just the problem domain that you're describing.)</em></p> <p>I used to work for a company that developed a point-of-sale system for its nationwide chain of ...
<p>I've never done anything like that before, but it looks to me that if you go that way you might get into serious problems...</p> <p>Technically I don't think that it's really that hard to implement. Basically you will have to set a copy of the database on each client and synchronise with the server every time the c...
48,442
<p>What is the best source of free Vista style graphics for application development? I want <strong>32x32</strong> and <strong>16x16</strong> that I can use in a Winforms application.</p>
<p>If you're using Visual Studio Professional or above, you've got a zip file of icons in your VS path under <code>Common7\VS2008ImageLibrary</code>. Some of the images use the Vista style.</p>
<p>Best place I've found for commercial toolbar icons etc is <a href="http://glyfx.com" rel="nofollow noreferrer">glyfx.com</a>.</p>
5,837
<p>The situation: I have a pieceofcrapuous laptop. One of the things that make it pieceofcrapuous is that the battery is dead, and the power cable pulls out of the back with little effort.</p> <p>I recently received a non-pieceofcrapuous laptop, and I am in the process of copying everything from old to new. I'm trying...
<p>I find RoboCopy is a good alternative to xcopy. It supports high latency connections much better and supports resuming a copy.</p> <h3>References</h3> <p><a href="http://en.wikipedia.org/wiki/Robocopy" rel="noreferrer">Wikipedia - robocopy</a></p> <h3>Downloads</h3> <p><strong>Edit</strong> Robocopy was introduc...
<p>I would suggest using <a href="http://optics.ph.unimelb.edu.au/help/rsync/rsync_pc1.html" rel="nofollow noreferrer">rsync</a>, several ports are available, but <a href="http://www.itefix.no/i2/node/10650" rel="nofollow noreferrer">cwrsync</a> seems to work nicely on Windows.</p>
8,312
<p>I need some help with what is probably a newbie question in terms of modifying phpBB.</p> <p>I have a whole system developed in PHP, and I would like to integrate phpBB so that people can navigate into the forums and post seamlessly, without logging in again.</p> <p>Now, using the phpBB users table as the users ta...
<p>This is an old question so I'm sure you've worked something out by now, but if you need to refactor things in the future, this is entirely possible with authentication plugins in phpBB3:</p> <p><a href="http://wiki.phpbb.com/Authentication_plugins" rel="noreferrer">http://wiki.phpbb.com/Authentication_plugins</a></...
<p>You can use the below to login into phpBB:</p> <pre><code>$result=$auth-&gt;login($username, $password); if ($result['status'] == LOGIN_SUCCESS) { echo "You're logged in"; } else { echo $user-&gt;lang[$result['error_msg']]; } </code></pre>
35,350
<p>Working on a somewhat complex page for configuring customers at work. The setup is that there's a main page, which contains various "panels" for various groups of settings. </p> <p>In one case, there's an email address field on the main table and an "export" configuration that controls how emails are sent out. I...
<p>A quick caveat for my answer - it's nearly 10 years since I worked with <a href="http://www.progress.com/" rel="noreferrer">Progress</a> so my knowledge is probably more than a little out of date.</p> <p>Checking the <a href="http://www.psdn.com/library/servlet/KbServlet/download/1078-102-885/langref.pdf" rel="nore...
<p>A quick google search turns up this: <a href="http://bytes.com/forum/thread174440.html" rel="nofollow noreferrer">http://bytes.com/forum/thread174440.html</a></p> <p>Read the message towards the bottom by greg@turnstep.com (you either want oid or ctid depending on what guarantees you want re persistence and unique...
12,299
<p>I currently use Visual Studio 2008 SP1 and have been migrating older projects into VS2008 but existing SSIS and SSRS (2005) projects have not been compatible with VS2008. It has been a pain to maintain those BIDS projects as a separate solution.</p> <p>I have been considering upgrading to SQL2008 but because our d...
<p>BIDS for SQL Server 2005 is based on Visual Studio 2005. AFAIK it won't install directly into VS2008. </p>
<p>This seemed to work fine but I did run into a slight snag, at least with SSRS. I don't seem to be able to deploy to SSRS 2005 from BIDS 2008. Seems to be some significant changes in the RDL between 2005 and 2008.</p> <p>So until we get SS2008 onto our servers it seems we're stuck maintaining two solutions - one f...
29,335
<p>I'm looking for an abstract base class or master page solution that will prevent anyone from doing XSRF using both a token and ttl. Can anyone point me in the right direction?</p> <p>Edit: The ideal solution will leverage the cookie that the default membership provider sends down to the client.</p>
<p>You could put a hidden field on your masterpage, generate a key during the Page_Load event of your master page, assign the key as the value of your hidden field and then add that value to your cookie. Then you just compare those values.</p>
<p>I started a base class that a master page can inherit. I opt'd to use viewstate instead of putting a hidden input down because with this approach I don't need to worry about multiple forms on a page/etc. It also takes a little more work to find this value than a simple "view source"</p> <p>The below are a few iss...
26,961
<p>I am using a FormView to update an existing SQL Server record. The rows from the sqldatasource display fine in the FormView and I can edit them. When I click Update, I get the ItemUpdating event but not the ItemUpdated event and the revisions are not written to the database. </p> <p>Can anyone help me in this ple...
<p>In your ItemUpdating event handler, make sure of the following things:</p> <p>-If you are not using optimistic concurrency checking, remove any old values the FormView may be placing in the OldValues collection.</p> <p>-Make sure that all of the parameters required by your stored procedure, query, or data source h...
<p>If you take out the ItemUpdating event and the ItemUpdated event, does your SQL statement execute without errors?</p> <p>If so, why don't you post some of the code you are using?</p>
22,685
<p>I have a page with some dynamically added buttons. If you click a button before the page has fully loaded, it throws the classic exception:</p> <blockquote> <pre><code>Invalid postback or callback argument. Event validation is enabled using in configuration or in a page. For </code></pre> <p>security purposes...
<p>I answered a similar question <a href="https://stackoverflow.com/questions/140303/aspnet-unable-to-validate-data#254581">here</a>. To quote:</p> <p>Essentially, you'll want to get the ViewState to load at the top of the page. In .NET 3.5 SP1 the <em>RenderAllHiddenFieldsAtTopOfForm</em> property was added to the Pa...
<p>What if you set those button's visible property to false by default and at the end of the page load or event validation you set their visible property to true? This way restricting them from clicking the button until the page has fully loaded.</p>
31,727
<p>We have a website; which, till now had only HTML pages. Now we are redeveloping it in ASP .Net.</p> <p>This means that all the .html pages will be changed to .aspx extension. The problem is, there are a lot of external references to these pages, and we dont want to go and chage each and every link to aspx right awa...
<p>if you do some sort of url rewriting you can have all the links stay the same and just serve up the aspx pages, request for index.html gets mapped to index.aspx</p> <p>here's what ms says about asp.net url rewriting:</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms972974.aspx" rel="nofollow noreferrer">h...
<p>Here's how we handled a similar situation.</p> <ol> <li><p>Setup IIS to map html extension to ASP.Net instead of handling it directly.</p></li> <li><p>In the HttpApplication.BeginRequest handler see if the request is being made for a html file that has been migrated to aspx if so then serve out the aspx page instea...
25,543
<p>How do you insert/update a column through Linq To SQL and Linq To SQL use the default values? In particular I'm concerned with a timestamp field.</p> <p>I've tried setting that column to readonly and autogenerated, so it stopped trying to put in DateTime.MinValue, but it doesn't seem to be updating on updates.</p>...
<p>The database default value would only insert the value on creating the row. It would do nothing for update, unless you want to add a triggger.</p> <p>Alternately, you can add a partial method to your DataContext class. Add a new file you your project:</p> <pre><code>public partial class YourDatabaseDataContext {...
<p>Seems like you just forgot to set <strong>AutoSync</strong> to <strong>always</strong> for the property.</p>
28,222
<p>I have a generic method defined like this:</p> <pre><code>public void MyMethod&lt;T&gt;(T myArgument) </code></pre> <p>The first thing I want to do is check if the value of myArgument is the default value for that type, something like this:</p> <pre><code>if (myArgument == default(T)) </code></pre> <p>But this d...
<p>To avoid boxing, the best way to compare generics for equality is with <code>EqualityComparer&lt;T&gt;.Default</code>. This respects <code>IEquatable&lt;T&gt;</code> (without boxing) as well as <code>object.Equals</code>, and handles all the <code>Nullable&lt;T&gt;</code> "lifted" nuances. Hence:</p> <pre><code>if(...
<p>Don't know if this works with your requirements or not, but you could constrain T to be a Type that implements an interface such as IComparable and then use the ComparesTo() method from that interface (which IIRC supports/handles nulls) like this:</p> <pre><code>public void MyMethod&lt;T&gt;(T myArgument) where T :...
9,109
<p>Thanks for reading. I'm a bit new to jQuery, and am trying to make a script I can include in all my websites to solve a problem that always drives me crazy...</p> <p>The problem: Select boxes with long options get cut off in Internet Explorer. For example, these select boxes: <a href="http://discoverfire.com/test/s...
<p>To modify each select, try this:</p> <pre><code>$('select').each(function(){ $('option', this).each(function() { // your normalizing script here }) }); </code></pre> <p>The second parameter (this) on the second jQuery call scopes the selecter ('option'), so it is essentially 'all option elements within ...
<p>I was able to replicate your results for all selects on a page in IE7 using this code, which I find much simpler than the span method you are using, but you can replace the "resize" function with whatever code suits your needs.</p> <pre><code>function resize(selectId, size){ var objSelect = document.getElementB...
24,209
<p>I'm working with SQL Server 2005 and Windows Server 2000 and wonder if there are any 'automated' ways of blocking SQL Injection attacks while I shore up my code.</p> <p>Some have suggested that there are ways to:</p> <ol> <li>Put in some kind of ISAPI or HTTP module that filters request post and querystrings for i...
<p>You didn't specify a language. Here's one for .NET:</p> <p><a href="http://www.dotnetactivedirectory.com/" rel="nofollow noreferrer">http://www.dotnetactivedirectory.com/</a></p>
<p>If you're using .NET 3.5, you can use the <a href="http://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.aspx" rel="nofollow noreferrer">System.DirectoryServices.AccountManagement</a> namespace to make AD operations a whole lot easier.</p>
46,133
<p><em>(This question specifically in C#, but applies generally to .NET)</em> </p> <p>I have a largish application that has a fairly good design, and is broken into major sections over interfaces (this was done to assist parallel development).</p> <p>We now have a primary set of concrete classes that implement the re...
<p>You want to look at IoC containers. (Spring.NET, StructureMap, Windsor, etc.)</p>
<p>Using an IoC container will create a pool or collection of your objects that you can dynamically load. The frameworks that Romain suggested will use a configuration file that describes the objects and how they are instantiated. </p>
29,235
<p>I am really new to Python and I have been looking for an example on how to write a Web Service (XML - SOAP) in Python with Google App Engine with no luck. </p> <p>Can anyone point me to an article or give me an example on how to do this?</p>
<p>I was curious about this myself and not finding anything I decided to try to get something to work. The short answer is that it turns out a SOAP service can actually be done using the latest alpha <a href="http://pywebsvcs.sourceforge.net/zsi.html" rel="noreferrer">ZSI library</a>. However it isn't simple and I didn...
<p>You could take a look at the <a href="http://bottlepy.org/docs/dev/" rel="nofollow">Bottle</a> framework. It's a Python framework which with you can easily create a REST api. In my opinion, REST is definitely better than SOAP. It can be easily consumed by any software able to speak http, and it's faster to implement...
42,965
<p>I know the combination <kbd>Ctrl</kbd>+<kbd>A</kbd> to jump to the beginning of the current command, and <kbd>Ctrl</kbd>+<kbd>E</kbd> to jump to the end. </p> <p>But is there any way to jump word by word, like <kbd>Alt</kbd>+<kbd>&larr;</kbd>/<kbd>&rarr;</kbd> in Cocoa applications does?</p>
<p>Out of the box you can use the quite bizarre <kbd>Esc</kbd>+<kbd>F</kbd> to move to the beginning of the next word and <kbd>Esc</kbd>+<kbd>B</kbd> to move to the beginning of the current word.</p>
<p>Just check the &quot;<strong>Use Option as meta key</strong>&quot; option in <strong>Terminal &gt; Preferences &gt; Settings &gt; [profile] &gt; Keyboard</strong>, as mentioned here already by @cris-page.</p> <p>Note however, that in macOS Catalina (10.15) and newer, <strong>zsh</strong> becomes the default shell fo...
10,686
<p>I've been using the macro from <a href="http://weblogs.asp.net/koenv/archive/2008/02/14/quick-attach-and-detach-debugger.aspx" rel="nofollow noreferrer">this blog entry</a> for attaching the Visual Studio debugger to an already running instance of the Web Application I'm currently working on. However, if I have more...
<p>This code will get you a list of all ports for the projects in the current solution:</p> <pre><code>Sub GetWebProjectPorts() Dim ports As String For Each prj As Project In DTE.Solution.Projects For Each p As EnvDTE.Property In prj.Properties If p.Name.Contains("DevelopmentServerPort") T...
<p>If you go to the properties for your web project and look under the "Web" tab, you can specify which port the project will always start up on. Then you can click "Enable Edit and Continue" so you don't have to stop debugging and restart continuously.</p>
16,442
<p>I have a legacy DLL written in C that contains a function that returns a string, and I need to access this function from Delphi. The only info I have about the DLL is the VB declare for accessing the function:</p> <p>Public Declare Function DecryptStr Lib "strlib" (Str As String) As String </p> <p>I've tried the f...
<p>Consider rewriting your test code as follows:</p> <pre><code>var p1, p2 : pchar; begin GetMem( p1, 255 ); // initialize GetMem( p2, 255 ); StrPLCopy( p2, 'some string to decrypt', 255 ); // prevent buffer overrun StrPLCopy( p1, DecryptStr( p2 ), 255); // make a copy since dll will free its internal buffer...
<p>I agree with CesarB, try to declare it with stdcall directive as:</p> <pre><code>function DecryptStr(s: PChar): PChar; stdcall; external 'strlib.dll'; </code></pre> <p>if it doesn't work, post the VB declaration here.</p>
29,338
<p>Are "out" parameters a bad thing in .NET? Any good articles/discussions on this topic?</p>
<p>Well, I have <a href="http://pobox.com/~skeet/csharp/parameters.html" rel="noreferrer">an article on what ref/out do</a> - but it doesn't discuss whether or not you should use them.</p> <p>Basically <code>out</code> parameters are usually a sign that you want to effectively return two results from a method. That's ...
<p>FxCop doesn't think it's a good idea...</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms182146(VS.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms182146(VS.80).aspx</a></p>
35,553
<p>I have a class proposing translations utilities. The translations themselves should be reloaded every 30 minutes. I use Spring Timer support for that. Basically, my class looks like :</p> <pre><code>public interface Translator { public void loadTranslations(); public String getTranslation(String key); } </c...
<p>Use some form of locking mechanism to only perform the task if it is not already in progress. Acquiring the locking token must be a one-step process. See:</p> <pre><code>/** * @author McDowell */ public abstract class NonconcurrentTask implements Runnable { private boolean token = true; private synchron...
<p>Keep a handle on the load thread to see if it's running?</p> <p>Or can't you just use a synchronized flag to indicate if a load is in progress?</p>
18,352
<p>From what I understand, it takes a really long time for the heated bed to heat up using an MK2a heated bed. I've heard some people suggest that using <a href="http://forums.reprap.org/read.php?4,584582" rel="nofollow">Polyisocyanurate (PIR) foam</a> (insulation that takes quite a bit of heat to catch on fire) can b...
<p>An alternative solution that is used with some <a href="https://www.think3dprint3d.com/3D-Printer-Kits/complete-3D-printer-kits/Kossel-Mini-3dPrinter-Kit" rel="nofollow">Kossel Mini</a> models, is a simple <a href="https://lh4.googleusercontent.com/RNWfKpkiA_cg16D6gPqcQ4e1uCFmW4-lIV-KVZYnFJyn3EtbCrsH_sXHKXZxkrlPjnHD...
<p>If you use a seperate powersupply for your bed (or if your controller has a built in voltage regulator so it doesn't damage at higher voltages) you can sometimes find an small potentiometer near the connection terminals of your powersupply, turning this potentiometer up can raise the outputvoltage of your powersuppl...
185
<p>What's the best way to run scheduled tasks in a Rails environment? Script/runner? Rake? I would like to run the task every few minutes.</p>
<p>I'm using the rake approach (as supported by <a href="https://devcenter.heroku.com/articles/scheduler" rel="noreferrer">heroku</a>)</p> <p>With a file called lib/tasks/cron.rake ..</p> <pre><code>task :cron =&gt; :environment do puts "Pulling new requests..." EdiListener.process_new_messages puts "done." end...
<p>I'm not really sure, I guess it depends on the task: how often to run, how much complicated and how much direct communication with the rails project is needed etc. I guess if there was just <em>"One Best Way"</em> to do something, there wouldn't be so many different ways to do it.</p> <p>At my last job in a Rails p...
36,289
<p>Given my background as a generalist, I can cover much of the area from analog electronics to writing simple applications that interface to a RDBMS backend.</p> <p>I currently work in a company that develops hardware to solve industry-specific problems. We have an experienced programmer that have written business a...
<p>At the end of the day, everything is an API.</p> <p>Need to write code for an SPI peripheral inside a microcontroller? Well, get the datasheet or hardware manual, and look at the SPI peripheral. It's one, big, complex API.</p> <p>The problem is that you have to understand the hardware and some basic EE fundament...
<p>Agreed on the "hard" term is quite relative. </p> <p>I would say different, as you would need to employ different development patterns that you won't use in other kind of environment. The time constraint for instance could requires a learning curve. However being curious, would be a quality for a developer, wouldn'...
28,663
<p>I have a stored procedure in SQL 2005. The Stored Procedure is actually creating temporary tables in the beginning of SP and deleting it in the end. I am now debugging the SP in VS 2005. In between the SP i would want to know the contents into the temporary table. Can anybody help in in viewing the contents of the t...
<p>There are several kinds of temporary tables, I think you could use the table which is not dropped after SP used it. Just make sure you don't call the same SP twice or you'll get an error trying to create an existing table. Or just drop the temp table after you see it's content. So instead of using a table variable (...
<p>This helped me.</p> <pre><code>SELECT * FROM #Name USE [TEMPDB] GO SELECT * FROM syscolumns WHERE id = ( SELECT id FROM sysobjects WHERE [Name] LIKE '#Name%') </code></pre> <p>this gives the details of all the temp table</p>
15,322
<p>Here is some simple Perl to count the number of times a value occurs in an array. This runs without any warnings.</p> <pre><code>use warnings; use strict; my @data = qw(1 1 2 3 4 5 5 5 9); my %histogram; foreach (@data) { $histogram{$_}++; } </code></pre> <p>When the loop body is changed to</p> <pre><code>$h...
<p>The + operator evaluates both the form to the left and the form to the right of it, then returns the sum of both. The hash call evaluation does not see any special context.</p> <p>The ++ operator has some special magic built in. Quoting from the perlop manpage, regarding the ++ operator: </p> <blockquote> <p>"u...
<p>As Brian mentioned: it still does it, it just warns you. Warnings tell you about certain manipulations with effects you might not have intended. </p> <p>You are specifically <em>asking</em> for the value of <code>$histogram{$_}</code>, adding 1 to it and then assigning it to the same slot. It's the same way that I ...
32,598
<p>I need to convert the punycode <code>NIATO-OTABD</code> to <code>nñiñatoñ</code>.</p> <p>I found <a href="http://0xcc.net/jsescape/" rel="noreferrer">a text converter in JavaScript</a> the other day, but the punycode conversion doesn't work if there's a dash in the middle.</p> <p>Any suggestion to fix the "dash" i...
<p>I took the time to create the punycode below. It it based on the C code in RFC 3492. To use it with domain names you have to remove/add <code>xn--</code> from/to the input/output to/from decode/encode.</p> <p>The <code>utf16-class</code> is necessary to convert from JavaScripts internal character representation to u...
<p>Some's answer is absolutely awesome! Worked exactly how I was hoping for domains. However, I needed it to work for emails too. So I used Some's code and added a check for emails, then, with a little more logic, got it working for emails. I am not a JavaScript dev by any streach of the imagination, but I can make stu...
22,186
<p>vi treats dash <code>-</code> and space <code>&nbsp;</code> as word separators for commands such as <code>dw</code> and <code>cw</code>.</p> <p>Is there a way to add underscore <code>_</code> as well?</p> <p>I quite often want to change part of a variable name containing underscores, such as changing <code>src_bra...
<p>In case you're using vim, you can change that by setting the <code>iskeyword</code> option (<code>:he iskeyword</code>). If that is not an option, you can always use <code>ct_</code> instead of counting.</p>
<p>To delete to the next underscore enter &quot;df_&quot; To change to the next underscore enter &quot;cf_&quot; NOTE: don't include the double quotes.</p>
27,842
<p>I'm trying to process a credit card transaction in .net and it works perfectly in Safari, Opera, and IE. When I try the same transaction in Firefox it sends two requests and I end up with a double charged card. From a quick search on Google it seems that this is an issue with Firebug but I am unable to find a way to...
<p>Use a <a href="http://en.wikipedia.org/wiki/Cryptographic_nonce" rel="noreferrer"><strong>nonce</strong></a>, a unique key which is only used once.</p> <p>Send a unique number along with the form fields to the browser (this is often done with a hidden input field), and store a copy on the server with the transactio...
<p>I've had the same issue -- didn't realise it was specific to FireBug though. You really should fix this properly anyway, in case the user clicks the back button and re-submits.</p> <p>The usual way is to have a unique token for the transaction in a hidden field in the form. When the server-side receives the form,...
35,858
<p>I am responsible for the User Interface of an application written completely in Visual C++ using MFC and some third-part controls. I would like to use C# (WinForms or even better WPF) to improve the application look&amp;feel.</p> <p>I would like some advices about how to do it. Links, articles, examples...</p> <p...
<p>The basic libraries are <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/" rel="nofollow noreferrer">built into flash</a>. Then on top of that there is <a href="http://www.adobe.com/products/flex/" rel="nofollow noreferrer">flex</a>, which gives you an entire RIA framework. Then there are 3rd party...
<p>Assuming I understand your question correctly, <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/" rel="nofollow noreferrer">the Flash Player API</a> is the "standard library" for Flash applications (the <code>flash.*</code> packages).</p> <p>For more application programming -oriented libraries, th...
23,166
<p>One thing I've started doing more often recently is <strong>retrieving some data</strong> at the beginning of a task <strong>and storing it in a $_SESSION['myDataForTheTask']</strong>. </p> <p>Now it seems very convenient to do so but I don't know anything about performance, security risks or similar, using this ap...
<p>Well Session variables are really one of the only ways (and probably the most efficient) of having these variables available for the entire time that visitor is on the website, there's no real way for a user to edit them (other than an exploit in your code, or in the PHP interpreter) so they are fairly secure.</p> ...
<p>I use this approach a fair bit, I don't see any problem with it. Unlike cookies, the data isn't stored at the client-side, which is often a big mistake.</p> <p>Like anything though, just be careful that you're always sanitising user input, especially if you're putting user input into the $_SESSION variable, then la...
10,325
<p>This article <a href="http://www.petefreitag.com/articles/gctuning/" rel="noreferrer">here</a> suggests to use <code>-XX:+UseParNewGC</code> "To enable a parallel young generation GC with the concurrent GC". </p> <p>My confusion is that in order to enable both parallel and concurrent GC, should I</p> <ul> <li>use...
<p>Since the document you linked was for a 1.4.2 VM that's what I'll assume you're using (JVMs 5 and 6 behave differently). </p> <p>From <a href="https://web.archive.org/web/20120624153924/http://java.sun.com/docs/hotspot/gc1.4.2/" rel="nofollow noreferrer">http://java.sun.com/docs/hotspot/gc1.4.2/</a></p> <blockquot...
<p>You cannot enable two GC options at the same time. I would suggest you to use CMS which is better than and next generation GC compare to UseParNewGC. and if you use Java 1.7 or later and heap size is relatively bigger (like > 4GB) consider using G1.</p>
27,138
<p>Is there a way to generate a hash of a string so that the hash itself would be of specific length? I've got a function that generates 41-byte hashes (SHA-1), but I need it to be 33-bytes max (because of certain hardware limitations). If I truncate the 41-byte hash to 33, I'd probably (certainly!) lost the uniqueness...
<p>The way hashes are calculated that's unfortunately not possible. To limit the hash length to 33 bytes, you will have to cut it. You could xor the first and last 33 bytes, as that might keep more of the information. But even with 33 bytes you don't have that big a chance of a collision.</p> <p>md5: <a href="http://w...
<p>Use Apache's DigestUtils:</p> <p><a href="http://commons.apache.org/codec/api-release/org/apache/commons/codec/digest/DigestUtils.html#md5Hex(java.lang.String)" rel="nofollow noreferrer">http://commons.apache.org/codec/api-release/org/apache/commons/codec/digest/DigestUtils.html#md5Hex(java.lang.String)</a></p> <p...
21,367
<p>What the minimum basic setup required to begin developing a Firefox extension?</p>
<p>Step 1: Use the <a href="https://addons.mozilla.org/en-US/developers/tools/builder" rel="nofollow noreferrer">Add-on Builder</a> to generate all the necessary files.</p> <p>Step 2: Extract the downloaded files into your development area.</p> <p>Step 3: Create a text file in your profile's extensions folder named a...
<p>I suggest testing on the Portable edition of Firefox.</p>
34,599
<p>What's an elegant way in <strong>Classic ASP</strong> to check if session cookies are enabled in a user's browser using server side code (because javascript might be disabled as well).</p> <p>I have a solution of my own but it looks ugly as hell.</p> <p>@James - that doesn't differentiate between setting a session...
<p>Unless you specify an expiry on the cookie it will <strong>be</strong> a session cookie. The term <em>session</em> is a bit overloaded in HTTP. When the IE dialog refers to a session cookie it means any cookie that is only stored in process memory and not persisted to disk, therefore only lives for the duration of...
<p>Well, the "ugly as hell" method we used, was to set a cookie and redirect to a new page. In the code for the new page, see if the cookie was set. Since the only way to get to the second page is to be redirected there when the cookie is set, it's presence or absence should tell the state of the browser.</p>
36,119