instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I have some data. I want to go through that data and change cells (for example - Background color), if that data meets a certain condition. Somehow, I've not been able to figure it out how to do this seemingly easy thing in Silverlight.</p>
| <p>This is slightly old code (from before RTM), but does something like what you're looking for. It checks some data on an object in a row and then sets the colour of the row accordingly.</p>
<p><strong>XAML:</strong></p>
<pre><code><my:DataGrid x:Name="Grid" Grid.Row="1" Margin="5" GridlinesVisibility="None" Prep... | <p>I've generally written custom ValueConverters for each data type being bound that return Visibility, Colour, etc.</p>
<p>This gives a single point where the customisation rules are defined and I've found works very well.</p>
<p>Robin's second link describes writing a custom ValueConverter.</p>
| 49,360 |
<p>I am trying to creating an optional association between a couple of tables. I have one table called Invoice. The Invoice table has a FK reference to the Customer table through the CustomerId field. The Invoice table also has a not enforced FK reference to the Project able through the ProjectId field.</p>
<p>Is t... | <p>I'm not sure how you'd do it without enormous, horrible redundancy. The standard way to handle a many-to-many relationship between two tables is via a third table that contains two primary key values, one for the first table, one for the second table, with a unique constraint (read 'index') on the combination of al... | <p>If you are using hibernate-annotations, there is a @ManyToMany, not sure about the XML equivalent. It should appear in the API documentation of your distribution</p>
| 46,268 |
<p>We have a stored procedure that runs nightly that in turn kicks off a number of other procedures. Some of those procedures could logically be run in parallel with some of the others. </p>
<ul>
<li>How can I indicate to SQL Server whether a procedure should be run in parallel or serial — ie: kicked off of as... | <p>I had to research this recently, so found this old question that was begging for a more complete answer. Just to be totally explicit: <strong>TSQL does <em>not</em></strong> (by itself) <strong>have the ability to launch other TSQL operations asynchronously</strong>.</p>
<p>That doesn't mean you don't still have a ... | <p>Create a couple of SQL Server agent jobs where each one runs a particular proc.</p>
<p>Then from within your master proc kick off the jobs.</p>
<p>The only way of waiting that I can think of is if you have a status table that each proc updates when it's finished. </p>
<p>Then yet another job could poll that tabl... | 45,543 |
<p>Python Decimal doesn't support being constructed from float; it expects that you have to convert float to a string first.</p>
<p>This is very inconvenient since standard string formatters for float require that you specify number of decimal places rather than significant places. So if you have a number that could h... | <h3>Python <2.7</h3>
<pre><code>"%.15g" % f
</code></pre>
<p>Or in Python 3.0:</p>
<pre><code>format(f, ".15g")
</code></pre>
<h3>Python 2.7+, 3.2+</h3>
<p>Just pass the float to <code>Decimal</code> constructor directly, like this:</p>
<pre><code>from decimal import Decimal
Decimal(f)
</code></pre>
| <p>You can use JSON to accomplish it</p>
<pre><code>import json
from decimal import Decimal
float_value = 123456.2365
decimal_value = json.loads(json.dumps(float_value), parse_float=Decimal)
</code></pre>
| 40,833 |
<p>Anyone know the <code><%= %></code> or <code>Response.Write()</code> code for getting the version of .Net my web app is running on?</p>
| <p><code>System.Environment.Version</code> will give you that.</p>
| <pre><code>System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion
</code></pre>
| 46,176 |
<p>We have literally 100's of Access databases floating around the network. Some with light usage and some with quite heavy usage, and some no usage whatsoever. What we would like to do is centralise these databases onto a managed database and retain as much as possible of the reports and forms within them.</p>
<p>The... | <p>We upsize (either using the upsize wizard or by hand) users to SQL server. It's usually pretty straight forward. Replace all the access tables with linked tables to the sql server and keep all the forms/reports/macros in access. The investment in access isn't lost and the users can keep going business as usual. You ... | <p>So? Dedicate a server to your Access databases. </p>
<p>Now you have the benefit of some sort of usage tracking, and also the ability to pay more attention to some of the important decentralised data that is stored in these apps.</p>
<p>This is what you were going to do anyway, only you wanted to use a different d... | 6,944 |
<p>When designing a ASP.net WebForm application what are some important steps to take (or hacks if you like to use the term) to ensure the best possible performance (in terms of speed, stability, and scalability)?</p>
| <p>Here's a good Best Practices written by microsoft. Chapter 6 is specific to ASP.NET, but the whole document is .NET in general.</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/ms998530.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms998530.aspx</a></li>
</ul>
| <p>1 - Turn on content compression on iis</p>
<p>2 - Cache everything you can</p>
<p>This will do for the majority of webapps out there.</p>
| 46,063 |
<p>I am using Delphi 7 and ICS components to communicate with php script and insert some data in mysql database...</p>
<p>How to post unicode data using http post ?</p>
<p>After using utf8encode from tnt controls I am doing it to post to PHP script </p>
<pre><code><?php
echo "Note = ". $_POST['note'];
if($_POST[... | <p>Your example code shows your data coming from a TNT Unicode control. That value will have type <code>WideString</code>, so to get UTF-8 data, you should call <code>Utf8Encode</code>, which will return an <code>AnsiString</code> value. Then call <code>UrlEncode</code> on that value. Make sure <code>UrlEncode</code>'s... | <p>I would expect (without knowing for sure) that you'd have to output them as &#nnnnn entities (with the number in decimal rather than hex ... I think)</p>
| 39,253 |
<p>I have to preface this with the fact that I love jQuery as a JavaScript language extension and YUI as a rich set of free controls. So here is my question, is there going to be any problems down the line if I mix jQuery and YUI together in an MVC app I am working on.</p>
<p>I want to use jQuery for the heavy liftin... | <p>Speaking from some experience in developing a small tool myself, I've used YUI's rich control set with Prototype for DOM manipulation in the past and experienced no issues. Admittedly, this was a small tool that didn't use a wide array of the controls.</p>
<p>Even so, I'm always hesitant to use multiple frameworks ... | <p>I think it shouldn't be a problem because YUI is all contained in "namespaces", so it shouldn't break anything (I don't know if jquery break things around YUI, but as long as it doesn't extend basic object there shouldn't be any problem).
I remember Dustin Diaz come out with a library similar to jquery and builded a... | 24,644 |
<p>I have just set up my new 3D printer. However, the build plate keeps slipping while printing. I tried to use binder clips to keep the plate in place, but this makes the build plate unlevel, messing up my prints. What are some other ways to prevent the build plate from slipping. I was considering using duct tape, but... | <p>I use kapton tape to fixate the glass plates to the heated beds on two of my printers, one a Prusa i3 clone, the other a CoreXY. The tape is able to withstand higher temperatures, and is very thin, so it doesn't have the drawbacks of limiting the print area or high chance the nozzle hitting the clips.</p>
<p><a href... | <p>I'm not sure what "the build plate keeps slipping while printing. I tried to use binder clips to keep the plate in place" means, but if you have a build surface and a bottom heated bed, you can look for "silicone thermal pad 0.5mm".</p>
<p>You can put it between build surface and lower bed, so th... | 1,899 |
<p>I have several databases where the transaction log (.LDF) is many times larger than the database file (.MDF).</p>
<p>What can I do to automatically shrink these or keep them from getting so large?</p>
| <p>That should do the job</p>
<pre><code>use master
go
dump transaction <YourDBName> with no_log
go
use <YourDBName>
go
DBCC SHRINKFILE (<YourDBNameLogFileName>, 100) -- where 100 is the size you may want to shrink it to in MB, change it to your needs
go
-- then you can call to check that all went fi... | <p>try sp_force_shrink_log which you can find here
<a href="http://www.rectanglered.com/sqlserver.php" rel="nofollow noreferrer">http://www.rectanglered.com/sqlserver.php</a></p>
| 19,722 |
<p>My question about the reconfiguration delay when switching between Access 2003 and 2007 the comment was made:</p>
<p><em>Btw, you can't avoid the reconfiguration between Access 2007 and earlier versions. Access 2007 uses some of the same registry keys as earlier versions and they have to be rewritten when opening A... | <p>It works most of the time but it's not perfectly safe, which is why Microsft refuses to support multiple installations of Microsoft Office on the same pc. The recommended solution is to install a virtual machine and install the second Microsoft Office version on the virtual machine. Then you can switch from one ve... | <p>It seems to me that the instance of Access you open will inherit the registry settings at the time it is open. So, if you open A2K7, you'll get the registry settings that it writes in its "configuring Office" procedures. If while A2K7 is still open, you open A2K3, it will reconfigure the registry settings and inheri... | 18,957 |
<p>In C#, what makes a field different from a property, and when should a field be used instead of a property?</p>
| <p>Properties expose fields. Fields should (almost always) be kept private to a class and accessed via get and set properties. Properties provide a level of abstraction allowing you to change the fields while not affecting the external way they are accessed by the things that use your class.</p>
<pre><code>public cla... | <p>After reading all answers I didn't find an answer about concurrent access.</p>
<p>Let's say you have an API endpoint that can be accessed asynchronous and you are using the static field to store data and need to have exclusive access to the static field at all.</p>
<p>To reproduce this sample you will need a load te... | 37,696 |
<p>I have a simple Word to Pdf converter as an MSBuild Task. The task takes Word files (ITaskItems) as input and Pdf files (ITaskItems) as output. The script uses a Target transform for conversion:</p>
<pre><code><Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersio... | <p>I found the problem. It turns out that I had some logic in the Task that would turn any relative path specified for a PDF file into an absolute path. Once I removed that and changed the script to this:</p>
<pre><code> <Target Name="Convert"
Inputs="@(WordDocuments)"
Outputs="@(WordDocuments-... | <p>Here's my example of a task that performs incremental builds on items found recursively through subdirectories:</p>
<pre><code> <Target Name="Build" Inputs="@(RequestTextFiles)" Outputs="@(RequestTextFiles -> '%(Rootdir)%(Directory)%(Filename).out')">
<DoSomething SourceFiles="@(RequestTextFiles)"... | 22,778 |
<p>Since Rails is not multithreaded (yet), it seems like a threaded web framework would be a better choice for a Facebook application. (reason being is cuz each Rails process can only handle one request at a time, and facebook actions tend to be slow, because there is a lot of network communication between your app an... | <p>We've used merb_facebooker in one of our projects (<a href="http://www.rockthevote.com/" rel="nofollow noreferrer">Rock the Vote</a>), and it worked out pretty well. Testing Facebook apps is quite annoying, as you don't have control of the middleware, so watch out for your expectations of the FB API and make sure yo... | <p>Have you looked at <a href="http://rubyforge.org/projects/starling/" rel="nofollow noreferrer">Starling</a>? It's the server used by twitter to handle their messages. It's a persistent queue server that allows you to delegate jobs to workers. </p>
| 11,493 |
<p>I am currently working on a leave application (which is a subset of my e-scheduler project) and I have my database design as follows:</p>
<pre><code>event (event_id, dtstart, dtend... *follows icalendar standard*)
event_leave (event_id*, leave_type_id*, total_days)
_leave_type (leave_type_id, name, max_carry_forw... | <p>I'm not following the schema very well (it looks like each leave_type would have a carry forward? There's no user on the event* tables?) but you should be able to dynamically derive the balance at any point in time - including across years. </p>
<p>AAMOF, normalization rules would require you to be able to <em>deri... | <p>There is always a better design!! </p>
<p>Does your current design work? How many users do you expect (ie does it matter you would have to run x thousand queries).</p>
<p>If the problem of the current design is only at the beginning of the year then perhaps you could live with it!</p>
<p>Cheers</p>
<p>NZS</p>
| 21,982 |
<p>i’m trying to create a url string that works like this:</p>
<pre><code>/app/process/example.com/index.html
</code></pre>
<p>so in other words,</p>
<pre><code>/app/process/$URL
</code></pre>
<p>i then retrieve the url with </p>
<pre><code>$this->uri->segment(3);
</code></pre>
<p>the forward slashes in the... | <p>I think the error message you are getting is not from codeigniter but from your web server. </p>
<p>I replicated this using Apache2 without even using CodeIgniter: I created a file index.php, and then accessed <code>index.php/a/b/c</code> - it worked fine. If I then tried to access <code>index.php/a/b/c%2F</code> I... | <p>Change your permitted_uri_chars index in config file</p>
<pre><code>$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
</code></pre>
| 40,180 |
<p>I have an old Excel 4 macro that I use to run monthly invoices. It is about 3000 lines and has many Excel 5 Dialog Box sheets (for dialog boxes). I would like to know what the easiest way would be to change it into VBA and if it is worth it. Also, if once I have converted it to VBA, how to create a standalone applic... | <p>I have attempted this before and in the end you do need to rewrite it as Biri has said.</p>
<p>I did quite a bit of this work when our company was upgrading from Windows NT to Windows XP. I often found that it is easier not to look at the old code at all and start again from scratch. You can spend so much time tr... | <p>Here is a good artikel about this topic: <a href="http://msdn.microsoft.com/en-us/library/aa192490.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa192490.aspx</a></p>
<p>You can download VB2008-Express for free at: <a href="http://www.microsoft.com/express/default.aspx" rel="nofollow noref... | 11,617 |
<p>Being stuck with a legacy database schema that no longer reflects your data model is every developer's nightmare. Yet with all the talk of refactoring code for maintainability I have not heard much of refactoring outdated database schemas. </p>
<p>What are some tips on how to transition to a better schema without... | <p>Here's a whole catalogue of database refactorings:</p>
<p><a href="http://databaserefactoring.com/" rel="noreferrer">http://databaserefactoring.com/</a></p>
| <p>Is all data access limited to stored procedures? If not, the task could be nearly impossible. If so, you just have to make sure your data migration scripts work well transitioning from the old to the new schema, and then make sure your stored procedures honor theur inputs and outputs. </p>
<p>Hopefully none of t... | 12,998 |
<p>Is it possible to read damaged media (cd, hdd, dvd,...) even if windows explorer bombs out?</p>
<p>What I mean to ask is, whether there is a set of APIs or something that can access the disk at a very low level (below explorer?) and read whatever can be retrieved even if it is only partial, especially if you can st... | <p>The main problem with Windows Explorer is that it doesn't support resuming copying after a read error. Most superficially scratched CDs, for example, will fail on different areas of the disk every time you eject and reinsert them.</p>
<p>Therefore, with a utility that supports resuming copy operations, it is possib... | <p>I don't know what layer exists between Windows Explorer and the Win32 APIs. You can try to write a program with the Win32 File I/O stuff. If that doesn't work, then you have to write your own device driver to get any lower.</p>
| 24,150 |
<p>I have a function inside a loop inside a function. The inner function acquires and stores a large vector of data in memory (as a global variable... I'm using "R" which is like "S-Plus"). The loop loops through a long list of data to be acquired. The outer function starts the process and passes in the list of dataset... | <p>use variables in the outer function instead of global variables. This gets you the best of both approaches: you're not mutating global state, and you're not copying a big wad of data. If you have to exit early, just return the partial results.</p>
<p>(See the "Scope" section in the R manual: <a href="http://cran.r-... | <p>It's tough to say definitively without knowing the language/compiler used. However, if you can simply pass a pointer/reference to the object that you're creating, then the size of the object itself has nothing to do with the speed of the function calls. Manipulating this data down the road could be a different sto... | 10,511 |
<p>We have a highly specialized DAL which sits over our DB. Our apps need to use this DAL to correctly operate against this DB.</p>
<p>The generated DAL (which sits on some custom base classes) has various 'Rec' classes (Table1Rec, Table2Rec) each of which represents the record structure of a given table.</p>
<p>Here... | <p>Not sure if I fully understand the question, but you can have nullable data types in XML. </p>
<p>So this...</p>
<pre><code>Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.Basi... | <p>Web services are designed to expose operation(methods) & data contracts but not internal implementation logic. This is a "good thing" in the world of service-oriented architecture. The scenario you describe is a remote/distributed object architecture. Web services will not support what you are trying to do. Plea... | 28,977 |
<p>I recently installed Windows 2008 Server to replace a crashed hard drive on a web server with a variety of web pages including several classic ASP applications. One of these makes extensive use of file uploads using a com tool that has worked for several years.</p>
<p>More information: </p>
<p>My users did not pro... | <p>There is a size limit that you will probably need to set - what's the 500 error?</p>
| <p>There is a size limit that you will probably need to set - what's the 500 error?</p>
| 9,519 |
<p>I'm looking for solutions that will allow me to have a Live Video feed setup at one location and, via the internet, watch the video stream at a remote location.</p>
<p>The goal is to have a live high quality video training session that remote users can watch from their own locations.</p>
<p>Any technology will wor... | <p>I think the soultion for you is DaCast, a self-service platform for live streaming. When you sign up an account, you are 20 minutes away from your first streaming. As long as you have a webcam, you can easily stream live throughout the internet. You can somply send a link of your DaCast channel page to all viewers, ... | <p>Have you tried Video Lan Client (VLC) They have ability to stream/capture video from either a video camera or video file.</p>
<p><a href="http://www.videolan.org/vlc/" rel="nofollow noreferrer">http://www.videolan.org/vlc/</a></p>
<p>(there is a checkbox at the bottom of the new dialog for streaming/saving option... | 44,339 |
<p>I am new with Linq and I would like to sort some data that are in the BindingList. Once I did my Linq query, I need to use back the BindingList collection to bind my data.</p>
<pre><code> var orderedList = //Here is linq query
return (BindingList<MyObject>)orderedList;
</code></pre>
<p>This compiled but fai... | <pre><code>new BindingList<MyObject>(orderedList.ToList())
</code></pre>
| <p>That above only works when your linq query's select projection is explicitly typed as MyObject rather than select new which creates an instance of an anonymous object. In such cases the typeof(orderedList.ToList()) winds up as something akin to this: System.Collections.Generic.List<<>f__AnonymousType1></p>
<p... | 41,185 |
<p>Are there any O/R mappers out there that will automatically create or modify the database schema when you update the business objects? After looking around it seems that most libraries work the other way by creating business object from the database schema.</p>
<p>The reason I'd like to have that capability is that... | <p><a href="http://www.hibernate.org/343.html" rel="nofollow noreferrer">NHibernate</a> can generate the database schema from the business objects for you.</p>
| <p>Can NHibernate update the schema or does it drop and recreate it?</p>
| 48,576 |
<p>If I create a UserControl and add some objects to it, how can I grab the HTML it would render?</p>
<p>ex.</p>
<pre><code>UserControl myControl = new UserControl();
myControl.Controls.Add(new TextBox());
// ...something happens
return strHTMLofControl;
</code></pre>
<p>I'd like to just convert a newly built User... | <p>You can render the control using <code>Control.RenderControl(HtmlTextWriter)</code>.</p>
<p>Feed <code>StringWriter</code> to the <code>HtmlTextWriter</code>.</p>
<p>Feed <code>StringBuilder</code> to the <code>StringWriter</code>.</p>
<p>Your generated string will be inside the <code>StringBuilder</code> object.</p... | <p>Call its <code>.RenderControl()</code> method.</p>
| 36,712 |
<p>As the subject says I want to insert an image into the 2nd column of grid
defined with 2 columndefintions.</p>
<p>Programmatically that is???</p>
<p>I cannot see how to select the column using grid.Children.insert(1, img)
does not work.</p>
<p>Malcolm</p>
| <pre><code>Image imgControl = new Image();
Grid.SetColumn(imgControl, 1);
gridContainer.Children.Add(imgControl);
</code></pre>
<p>Objects contained in a grid are positioned based on the attached dependency properties Column Row ColumnSpan and RowSpan which are set as shown above.</p>
| <p>The row/column index on an element in WPF is an attached property. You set it using a static method on Grid, like this:</p>
<pre><code>Grid.SetColumn(img, 1);
</code></pre>
<p>More info <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.grid.setcolumn.aspx" rel="noreferrer">here</a>, and more... | 45,040 |
<p>This might be an odd question, but when I scale my image in C# I need it to be pixelated and not anti-aliased. Just like in MSpaint when you scale.</p>
<p>I hope images anti-alias by default in C#, or else I changed something I didn't want to.</p>
<p>I've tried playing around with the <code>Graphics.InterpolationM... | <p>Actually, you're right with InterpolationMode, as <a href="http://msdn.microsoft.com/en-us/library/k0fsyd4e.aspx" rel="nofollow noreferrer">the docs say</a>. Just set it to InterpolationMode.NearestNeighbor. In your code sample, you never set m_interpolationMode.</p>
| <p>Well, you could implement the scale yourself and do a simple linear interpolation (I.E. don't do any neighbor averaging like bicubic)... Those look nice and blocky.</p>
| 23,655 |
<p>The following returns </p>
<blockquote>
<p>Type of conditional expression cannot be determined because there is no implicit conversion between 'double' and '<null>'</p>
</blockquote>
<pre><code>aNullableDouble = (double.TryParse(aString, out aDouble) ? aDouble : null)
</code></pre>
<hr>
<p>The reason why... | <pre><code>aNullableDouble = double.TryParse(aString, out aDouble) ? (double?)aDouble : null;
</code></pre>
| <p>.NET supports <a href="http://msdn.microsoft.com/en-us/library/1t3y8s4s.aspx" rel="nofollow noreferrer">nullable types</a>, but by declaring them as such you have to treat them a bit differently (as, understandably, something which is normally a value type now is sort of reference-ish).</p>
<p>This also might not h... | 10,921 |
<p>I'd like to know the standard way to benchmark a SQL Sever Query, preferably I'd like to know about the tools that come with SQL Server rather than 3rd Party tools.</p>
| <p>set showplan_text on
will show you the execution plan (to see it graphically use <kbd>CTRL</kbd> + <kbd>K</kbd> (sql 2000) or <kbd>CTRL</kbd> + <kbd>M</kbd> (sql 2005 +)</p>
<p>set statistics IO on
will show you the reads</p>
<p>set statistics time on
will show you the elapsed time</p>
| <p>+1 on the execution plan. From here you can see where all the time is being spent in your particular query. Eg. 85% of the time is spent table scanning a particular table, can you put an index on that table to improve it? etc etc.</p>
| 5,523 |
<p>I have a JSP accessed through JBoss. It renders a list (a search result).
If the response gets big, approximately larger than 200k the response is truncated. I can see how the page just ends in the middle of a tag in Firefox. IE totally freaks out an so does Fiddler.
Responses smaller than 200k are no problem.</p>
... | <p>If your JSP renders a very complex html page, then it might just be the browsers tripping over their own feet. Can you retrieve the page via wget or curl? Is it truncated then, too?</p>
| <p>I second Henning's suggestion. I have used JSPs on JBoss to return multi megabyte responses, I would look at the code or possibly an intermediate proxy server rather than JBoss.</p>
| 24,985 |
<p>In .NET, a value type (C# <code>struct</code>) can't have a constructor with no parameters. According to <a href="https://stackoverflow.com/questions/203695/structure-vs-class-in-c#204009">this post</a> this is mandated by the CLI specification. What happens is that for every value-type a default constructor is crea... | <p><strike> <strong>Note:</strong> the answer below was written a long time prior to C# 6, which is planning to introduce the ability to declare parameterless constructors in structs - but they still won't be called in all situations (e.g. for array creation)</strike> (in the end this feature <a href="https://stackove... | <p>Here's my solution to the no default constructor dilemma. I know this is a late solution, but I think it's worth noting this is a solution. </p>
<pre><code>public struct Point2D {
public static Point2D NULL = new Point2D(-1,-1);
private int[] Data;
public int X {
get {
return this.D... | 43,277 |
<p>How do I run a function on a loop so all the results go straight into a list and is there a way to run a function which acts on all the values in a list?</p>
| <p>Theres a couple ways to run a function on a loop like that - You can either use a list comprehension</p>
<pre><code>test = list('asdf')
[function(x) for x in test]
</code></pre>
<p>and use that result</p>
<p>Or you could use the map function</p>
<pre><code>test = list('asdf')
map(function, test)
</code></pre>
<... | <p>This example shows how to do it (run it in an interpreter)</p>
<pre><code>>>> def square(x):
... return x*x
...
>>> a = [1,2,3,4,5,6,7,8,9]
>>> map(square,a)
[1, 4, 9, 16, 25, 36, 49, 64, 81]
</code></pre>
| 32,381 |
<p>I need to set an environment variable in Python and find the address in memory where it is located. Since it's on Linux, I don't mind about using libraries that only work consistently on Linux (if that's the only way). How would you do this?</p>
<p>Edit: The scope of the problem is as follows: I'm trying to hack a ... | <p>The built in function id() returns a unique id for any object, which just happens to be it's memory address. </p>
<p><a href="http://docs.python.org/library/functions.html#id" rel="nofollow noreferrer">http://docs.python.org/library/functions.html#id</a></p>
| <p>Pass the address itself in an environment variable, and just read it with os.getenv().</p>
| 39,959 |
<p>I need something like <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Set.html" rel="noreferrer">this</a>, a collection of elements which contains no duplicates of any element. Does Common Lisp, specifically SBCL, have any thing like this? </p>
| <p>For a quick solution, just use hash tables, as has been mentioned before.</p>
<p>However, if you prefer a more principled approach, you can take a look at <a href="http://common-lisp.net/project/fset/" rel="noreferrer">FSet</a>, which is “a functional set-theoretic collections library”. Among others, it contains c... | <p>Lisp hashtables are CLOS based. Specs <a href="http://clhs.lisp.se/Body/t_hash_t.htm" rel="nofollow noreferrer">here</a>.</p>
| 20,019 |
<p>I keep getting this error when trying to re-order items in my ReorderList control.</p>
<p>"Reorder failed, see details below.</p>
<p>Can't access data source. It does not a DataSource and does not implement IList."</p>
<p>I'm setting the datasource to a DataTable right now, and am currently trying to use an Arra... | <p>I figured it out. I converted the DataTable to an ArrayList then bound to the control. Thanks everyone for reading!</p>
| <p>I've used it successfully in the past without much issue (binding to a List). Could you post some snippets of what you have in your front-end and code-behind?</p>
| 15,655 |
<p>I've been using the following snippet in developements for years. Now all of a sudden I get a DB Error: no such field warning</p>
<pre><code>$process = "process";
$create = $connection->query
(
"INSERT INTO summery (process) VALUES($process)"
);
if (DB::isError($create)) die($create->getMessage($create));... | <p>It's always better to use prepared queries and parameter placeholders. Like this in Perl DBI:</p>
<pre><code>my $process=1234;
my $ins_process = $dbh->prepare("INSERT INTO summary (process) values(?)");
$ins_process->execute($process);
</code></pre>
<p>For best performance, prepare all your often-used queri... | <p>Ditto what Zan Lynx said about placeholders. But you may still be wondering why your code failed.</p>
<p>It appears that you forgot a crucial detail from the previous code that worked for you for years: quotes.</p>
<p>This (tested) code works fine:</p>
<pre><code>my $thing = 'abcde';
my $sth = $dbh->prepare("I... | 42,615 |
<p>Can a macro be written in Scheme (with <code>define-syntax</code>, for example) which will take expressions like this:</p>
<pre><code>(op a b c d e f g h i j)
</code></pre>
<p>And yield expressions like this as output?</p>
<pre><code>(op (op (op (op (op (op (op (op (op a b) c) d) e) f) g) h) i) j)
</code></pre>
... | <pre><code>(define bop list)
(define-syntax op
(syntax-rules ()
((op a b) (bop a b))
((op a b c ...) (op (bop a b) c ...))))
</code></pre>
<p>For example, <code>(op 1 2 3 4)</code> expands to <code>(bop (bop (bop 1 2) 3) 4)</code> and evaluates to <code>(((1 2) 3) 4)</code>.</p>
| <p>To show how the answer works out:</p>
<pre><code>(op 1 2 3 4)
</code></pre>
<p>This is an op with 4 statements, so the 2nd case gets selected with a=1, b=2, c=3, ...=4:</p>
<pre><code>(op (bop 1 2) 3 4)
</code></pre>
<p>This is an op with 3 statements, so 2nd case again. a=(bop 1 2), b=3, c=4:</p>
<pre><code>(o... | 44,191 |
<p>If you visit <a href="http://www.maplesoft.com/company/news/index.aspx" rel="nofollow noreferrer">this page</a> in Internet explorer, and choose a value from the "Current Media Releases" dropdown on the top right, eventually IE will try to redirect you to an ugly url containing this string:</p>
<p>__EVENTTARGET=sel... | <p>Went to the site. Other than some javascript errors that are popping, it appears to be working fine.</p>
<p>==
Error: $ is not defined
Source file: <a href="http://www.maplesoft.com/ScriptResource.axd?d=kNY1h-WYJzKkuCdZqmndbpb67jRr2cZCC6s2tf_nrnwCcH6rvds1RZUYXUp0gdMqnu-6-o6rl1eH-wm7AO9xVw2&t=633640679588907500... | <p>The problem only occurs in IE. It works fine in Firefox, and obviously Chrome as well.</p>
| 45,525 |
<p>I have a query that is currently using a correlated subquery to return the results, but I am thinking the problem could be solved more eloquently perhaps using ROW_NUMBER().</p>
<p>The problem is around the profile of a value v, through a number of years for an Item. Each item has a number of versions, each with i... | <p>I would do it with a CTE:</p>
<pre><code>WITH Result AS
(
SELECT Row_Number() OVER (PARTITION BY ItemId, Year
ORDER BY ItemversionId DESC) AS RowNumber
,ItemId
,ItemversionId
,Year
,Value
FROM table
)
SELECT ItemId
,ItemversionId
,Year
,Value
FROM Result
WHERE RowNumber = 1
ORDER B... | <p>I think it's okay how you do it. You could check if there is a <strong>composite index on ItemId and Year</strong>.</p>
<p>You could inspect the query plan to see the impact of that query.</p>
<p>If there is an "Item" table in your database you could try another approach. <strong>Insert a column ItemVersionId</str... | 35,051 |
<p>My company is heavily invested in the MS BI Stack (SQL Server Reporting Services, -Analysis Services and -Integration Services), but I want to have a look at what the seemingly most talked about open-source alternative Pentaho is like.</p>
<p>I've installed a version, and I got it up and running quite painlessly. S... | <p>I reviewed multiple Bi stacks while on a path to get off of Business Objects. A lot of my comments are preference. Both tool sets are excellent. Some things are how I prefer chocolate fudge brownie ice cream over plain chocolate.</p>
<p>Pentaho has some really smart guys working with them but Microsoft has been o... | <p>If you are looking for a robust, low cost alternative to the big boys LogiXML has dashboarding and ad hoc reporting on a .NET platform. We've been using them since late 2006 when Pentaho was just starting, but I haven't looked at it in awhile. </p>
| 18,186 |
<p>I am trying to upload a file or stream of data to our web server and I cant find a decent way of doing this. I have tried both <code>WebClient</code> and <code>WebRequest</code> both have their problems. </p>
<p><strong>WebClient</strong><br>
Nice and easy but you do not get any notification that the asynchronous ... | <p>The way i get around it is through INotifyPropertyChanged and event notification.</p>
<p>The essentials:</p>
<pre><code> public void DoIt(){
this.IsUploading = True;
WebRequest postRequest = WebRequest.Create(new Uri(ServiceURL));
postRequest.BeginGetRequestStream(new AsyncCallback(RequestOpe... | <p>Matt Berseth had some thoughts in this, might help:</p>
<p><a href="http://mattberseth.com/blog/2008/07/aspnet_file_upload_with_realti_1.html" rel="nofollow noreferrer">http://mattberseth.com/blog/2008/07/aspnet_file_upload_with_realti_1.html</a></p>
<p><strong>@Dan</strong> - Apologies mate, I coulda sworn Matt's... | 3,372 |
<p>As you may know, in <code>VS 2008</code> <kbd>ctrl</kbd>+<kbd>tab</kbd> brings up a nifty navigator window with a thumbnail of each file. I love it, but there is one tiny thing that is annoying to me about this feature: <em>the window stays around after releasing the <kbd>ctrl</kbd> key</em>. When doing an <kbd>alt<... | <p>You probably have the text-to-speech narrator enabled.</p>
<p><a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2467648&SiteID=1&mode=1" rel="nofollow noreferrer">http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2467648&SiteID=1&mode=1</a></p>
<blockquote>
<p>Just uncheck all ch... | <p>Just in case anyone still needed a fix for this (I've encountered this behavior in VS2010) what you can do is:<br /></p>
<ul>
<li>Close VS</li>
<li>Enable sticky keys</li>
<li>Reopen VS</li>
<li>Disable sticky keys</li>
</ul>
<p>This solved it for me.</p>
| 3,758 |
<p>My firm have a talented and smart operations staff who are working very hard. I'd like to give them a SQL-execution tool that helps them avoid common, easily-detected SQL mistakes that are easy to make when they are in a hurry. Can anyone suggest such a tool? Details follow.</p>
<p>Part of the operations team remit... | <p>If your people are using the mysql(1) program to run queries, you can use the <a href="http://dev.mysql.com/doc/refman/5.1/en/mysql-tips.html" rel="nofollow noreferrer">safe-updates</a> option (aka i-am-a-dummy) to get you part of what you need. Its name is somewhat misleading; it not only prevents UPDATE and DELET... | <p>You might find <a href="http://www.red-gate.com/Products/SQL_Prompt/index.htm" rel="nofollow noreferrer">SQL Prompt</a> from redgate useful. I'm not sure what database engine you're using, as it's only for MSSQL Server</p>
| 3,623 |
<p>I've created a list using the SharePoint (MOSS 2007) Issue Tracking List. A "Comments" field is automatically created in this list. The Comments column has extra functionality that provides a sort of history/log whenever an edit is made to a list item. Unfortunately, a comment entry is created even when an insign... | <p>The "Comments" field is actually an "Append-Only Comments" Column . You should be able to add this to any custom list. (You will need versioning turned on on the list to operate in the same manner as it does in issue tracker.)</p>
<p>As far as not getting "blank" entries, the only way to do this, would be to turn... | <p>This post may help: <a href="https://chuvash.eu/2012/04/02/add-comments-column-to-your-sharepoint-list/" rel="nofollow noreferrer">Add Comments column to your sharepoint list</a></p>
<blockquote>
<ol>
<li><p>List Settings - > Versioning Settings -> Item Version History = Yes</p>
</li>
<li><p>Add “Append-only c... | 28,661 |
<p>When I add a # in insert mode on an empty line in Vim while editing python files, vim moves the # to the beginning of the line, but I would like the # to be inserted at the tab level where I entered it.</p>
<p>For example, when writing this in vim</p>
<pre><code>for i in range(10):
#
</code></pre>
<p>the # do... | <p>I found an answer here <a href="http://vim.wikia.com/wiki/Restoring_indent_after_typing_hash" rel="noreferrer">http://vim.wikia.com/wiki/Restoring_indent_after_typing_hash</a></p>
<p>It seems that the vim smartindent option is the cause of the problem.
The referenced page above describes work-a-rounds but after rea... | <p>I removed <code>set smartindent</code> from <code>~/.vimrc</code> but it still didn't disable smartindent. When I opened a .py file and ran <code>:set smartindent?</code> it displayed <code>smartindent</code>.</p>
<p>Turns out that further down in the <code>~/.vimrc</code> was this line:</p>
<pre><code>autocmd Buf... | 46,124 |
<p>When browsing the cube in Microsoft SQL Server Analysis Services 2005, I would like to peek at the MDX (supposedly) queries generated by client access tools such as Excel. Is there a tool or method that enables me to do just that?</p>
<p>I'm really looking for something like Oracle's v$sessions -- I know about sp_w... | <p>Use SQL Server Profiler - it can connect to Analysis Services... When you create a trace make sure you click "Show All Events" and capture the "Execute MDX" events.</p>
| <p>I remember doing something along these lines a few years ago. I am not sure that Analysis Services will actually log the MDX it uses, but it does log something. I believe you can right-click the server properties in AS, and there is a tab to tell it a file to log queries to. </p>
<p>(Sorry I cant be more specific, ... | 39,285 |
<p>While working on a tool that allows to exchange images of several third-party applications and thus creating individual "skins" for those applications, I have stumbled across a jpg-format about which I cannot seem to find any decent informations.</p>
<p>When looking at it in a hex-editor, it starts with the tag "CF... | <p><a href="http://linux.die.net/man/1/file" rel="nofollow noreferrer"><code>file(1)</code></a> should give you some useful information. You can also use ImageMagick's <a href="http://www.imagemagick.org/script/identify.php" rel="nofollow noreferrer"><code>identify(1)</code></a> program (optionally with the <code>-ver... | <p>CF stands for "Compression Factor". CF-10 means factor ten, and I don't think it's different from any "standard" jpeg.</p>
| 13,875 |
<p>I've been slowly working on a personnel project to run a webmud like game using extjs as my frontend. One of the design choices I made was to allow user-generated evaluated code for game logic. So when the player enters a new "room" a number of state scripts would be called along the lines of "has player been here... | <p>I wouldn't recommend evaluating user-contributed PHP-code -- even within a runkit sandbox. PHP is a very complex language, and it's closely tied to its environment. Without knowing the specifics, I would anticipate that there are numerous holes that people could leverage to break out of the sandbox.</p>
<p>There ar... | <p>There is a PHP Sandbox for basic stuff available. It's early stages but looks promising.</p>
<p><a href="http://www.phpclasses.org/package/7015-PHP-Execute-external-PHP-scripts-in-a-separate-process.html" rel="nofollow">http://www.phpclasses.org/package/7015-PHP-Execute-external-PHP-scripts-in-a-separate-process.ht... | 29,850 |
<p>I have a directory structure like the following;</p>
<blockquote>
<p>script.php</p>
<p>inc/include1.php<br/>
inc/include2.php</p>
<p>objects/object1.php<br/>
objects/object2.php</p>
<p>soap/soap.php</p>
</blockquote>
<p>Now, I use those objects in both <code>script.php</code> and <code>/soap/s... | <p>This should work </p>
<pre><code>$root = realpath($_SERVER["DOCUMENT_ROOT"]);
include "$root/inc/include1.php";
</code></pre>
<hr>
<p><strong>Edit:</strong> added imporvement by <a href="https://stackoverflow.com/questions/4369/include-files-requiring-an-absolute-path#4388">aussieviking</a></p>
| <blockquote>
<blockquote>
<p>@Flubba, does this allow me to have folders inside my include directory? flat include directories give me nightmares. as the whole objects directory should be in the inc directory.</p>
</blockquote>
</blockquote>
<p>Oh yes, absolutely. So for example, we use a single layer of subfo... | 2,638 |
<p>Let say I have a sheet in with columns Customer and CreatedDate with lots of row with data. Anyone who knows how to setup (through VBA or Formula) a second sheet that displays rows from the first sheet based on certain where statements, i.e. all rows with customers "created this month." (similar to a select ... wher... | <p>You can create a Pivot Table out of your data, then slice-n-dice it lots of ways.</p>
| <p>There isn't an exact equivalent to the SQL <code>select ... where</code> functionality in Excel, but take a look at the <code>VLOOKUP</code> function. It may be what you are looking for. If that doesn't have enough functionality, you will probably have to use VBA:</p>
<pre><code>
Dim DataRange as Range
Dim RowNum a... | 42,952 |
<p>Does anybody know any resources on this subject?</p>
<p>I'm developing an embedded application for 2x16 LCD display. Ideally I would like to have a general (display independent) framework, that could be used virtually on any display - one or more segment(s) LED, 1x16, 2x16 LCD, etc.
Also would like to learn about g... | <p>I would design it for a single-line interface, using more lines would give you more space.</p>
<p>I would go for at least 4 buttons:</p>
<ul>
<li>MENU</li>
<li>UP</li>
<li>DOWN</li>
<li>OK</li>
</ul>
<p>If you specify the line width (like 16), then this would work for 16x2, 16x1 and 16 7-segment displays.... and ... | <p>I don't know of any "project" or library built for this explicit purpose.</p>
<p>I recommend that you take the approach of having a "display layer" code that operates on the concepts of screens and fields. The screen is responsible for "owning" all the fields on the screen, and the fields are responsible for speci... | 26,584 |
<p>We have a couple of web servers using load balancer. Machines are running IIS6 on port 81. Externally, site is accessable using port 80. External name and name of the machine are different.</p>
<p>We're getting </p>
<pre><code>System.ServiceModel.EndpointNotFoundException: The message with To '<url>' cannot ... | <pre><code>[ServiceBehavior(AddressFilterMode=AddressFilterMode.Any)]
</code></pre>
<p>Putting this attribute on service solves the problem.</p>
| <p>What is the specific load balancer? Using an F5 BIG-IP we got it working fairly easily, but we were using the same port and (relative) uri on the nlb as individual machines (so we can treat an individual machine the same as the farm if we choose). Obviously each machine has a different name, but this setup also allo... | 32,694 |
<p>In C++, is it safe to extend scope via a reference?</p>
<p>In code, what I mean is: </p>
<pre><code>MyCLass& function badIdea()
{
MyClass obj1;
...
return obj1;
}
</code></pre>
| <p>It is NOT safe to extend the scope via reference. Objects in C++ are not reference counted when obj1 goes out of scope it will be deleted, refering to the result of badIdea() will only get you into trouble</p>
| <p>Please clarify what you do mean.</p>
<p>Assuming you intend to do this:</p>
<pre><code>int * p = NULL;
{
int y = 22;
p = &y;
}
*p = 77; // BOOM!
</code></pre>
<p>Then no, absolutely not, scope does not get extended by having a reference.</p>
<p>You may want to look at smart pointers, e.g. from boost libr... | 32,032 |
<p>We have a classic ASP application that simply works and we have been loathe to modify the code lest we invoke the wrath of some long-dead Greek gods.</p>
<p>We recently had the requirement to add a feature to an application. The feature implementation is really just a database operation requires minimal change to ... | <p>Have you got <strong>set nocount on</strong> set in both stored procedures? I had a similar issue once and whilst I can't remember exactly how I solved it at the moment, I know that had something to do with it!</p>
| <p>Example code might help :) Are you trying to return two tables from the stored procedure; I don't think ADO 2.6 can handle multiple tables being returned.</p>
| 13,301 |
<p>If you have the following:</p>
<pre><code>$var = 3; // we'll say it's set to 3 for this example
if ($var == 4) {
// do something
} else if ($var == 5) {
// do something
} else if ($var == 2) {
// do something
} else if ($var == 3) {
// do something
} else {
// do something
}
</code></pre>
<p>If... | <p>Here's how we did it when I used to write software for radar systems. (Speed matters in radar. It's one of the few places where "real time" actually means "real" instead of "fast".)</p>
<p>[I'll switch to Python syntax, it's easier for me and I'm sure you can interpret it.]</p>
<pre><code>if var <= 3:
if ... | <p>With code where it is purely an equality analysis I would move it to a switch/case, as that provides better performance.</p>
<pre><code>$var = 3; // we'll say it's set to 3 for this example
switch($var)
{
case 4:
//do something
break;
case 5:
//do something
break;
case:
//do ... | 20,822 |
<p>I've been battling PHP's email reading functions for the better part of two days. I'm writing a script to read emails from a mailbox and save any attachments onto the server. If you've ever done something similar, you might understand my pain: <strong>PHP doesn't play well with email!</strong></p>
<p>I've connected... | <p>I found a quick guide how to treat emails with PHP: <a href="http://www.linuxscope.net/articles/mailAttachmentsPHP.html" rel="nofollow noreferrer">here</a>.</p>
<p>At the bottom of that page there's a attachment-body <code>echo</code>:</p>
<pre><code>if (substr($ContentType,0,4) == "text") {
echo imap_qprint($file... | <p>MIME data is base-64 encoded, so I think you should be able to decode it using base64_decode</p>
| 19,659 |
<p>I have a Flex App that allows you to dynamically build an animation. It has a UI and a display of the resulting animation, which is a custom Class extending UIComponent. Is there some way to allow users to save/export the dynamically generated Component to a SWF, for reuse in other Flash/Flex Apps?</p>
| <p>You can easily export a screenshot, but i don't think you can save a swf.
see this thread:
<a href="http://www.actionscript.org/forums/showthread.php3?t=145846" rel="nofollow noreferrer">http://www.actionscript.org/forums/showthread.php3?t=145846</a></p>
| <p>You can export the component (or components) in a SWC design-time library or an RSL run-time library to share between applications.</p>
| 38,346 |
<p>Im sure this will be a simple one but have a project that started as a test.<br>
When it was created it was saved as "Project2.dpr"</p>
<p>Now the test is no longer a 'test', i would like to change the projects name to something more meaningful. </p>
<p>whats the best way to do this?</p>
<p>Any issues with just c... | <p>Just do "Save Project as" from the file menu in Delphi giving it the name you want and, later on when you feel like, remove the Project2.* files from your folder as they are not needed anymore.</p>
| <p>FYI: Starting with Delphi 8 you can simply right-click the project in the project manager and select "Rename" (or simply press F2). This has the benefit over the "Save As" approach that you don't end up with a copy.</p>
<p>(sorry, no Delphi 7 - thanks to Lars for the update)</p>
| 38,086 |
<p>I have the HTML given below:</p>
<pre><code><ul id="thumbsPhotos">
<li src="/images/1alvaston-hall-relaxing-lg.jpg" onclick="updatePhoto (this.title)"><img src="/images/1alvaston-hall-relaxing-sl.jpg" width="56" height="56"></li>
<li onclick="updatePhoto(this.title)" src="">... | <p>Not tested, but here's a regex which might do it for you...</p>
<pre><code>// find:
<li ([^>]*)src="(.*?)"(.*?)>
// replace:
<li $1title="$2"$3>
</code></pre>
<p><strong>Update</strong>: tested and it works on your example.</p>
<p>If you wanted to run this on the client side using Javascript (for ... | <p>You could most likely use a RegEx replace that matches on the src attribute and do the conversion. I see that you want to also add the title attribute even if there is no match, that should be possible as well.</p>
<p>I'll try to dig up some RegEx examples for this.</p>
| 27,949 |
<p>I'm using a Visual Studio web setup project to install an application that extends the functionality of Project Server. I want to call a method from the PSI ( Project Server Interface ) from one of the custom actions of my setup project, but every time a get a "401 Unauthorized access" error. What should I do to be ... | <p>It sounds like in the console situation you are running with your current user credentials, which have access to the PSI. When running from the web, it's running with the creds of the IIS application instance. I think you'd either need to set up delegation to pass the session creds to the IIS application, or use som... | <p>I finally found the answer. You can call the LoginWindows PSI service an set the credentials to NetworkCredentials using the appropriate user, password and domain tokens. Then you can call any PSI method, as long as the credentials are explicit. Otherwise, using DefaultCredentials you'll get an Unauthorized Access e... | 4,111 |
<p>I'm trying to create a deployment tool that will install software based on the hardware found on a system. I'd like the tool to be able to determine if the optical drive is a writer (to determine if burning software sould be installed) or can read DVDs (to determine if a player should be installed). I tried uing the... | <p>You can use WMI to enumerate what Windows knows about a drive; get the <a href="http://msdn.microsoft.com/en-us/library/aa394132(VS.85).aspx" rel="nofollow noreferrer"><code>Win32_DiskDrive</code></a> instance from which you should be able to grab the the <a href="http://msdn.microsoft.com/en-us/library/aa394346(VS.... | <p>Platform SDK - IDiscMaster::EnumDiscRecorders (XP / 2003)</p>
<p>DirectX and DirectShow has extensive interfaces to work with DVD</p>
<p>Else enumerate disk drives and try firing a DeviceIonControlCode that supports extarcting the type info. </p>
<p>Good luck</p>
| 11,543 |
<p>I have an intermittent problem with some code that writes to a Windows Event Log, using C# and .Net's <code>EventLog</code> class.</p>
<p>Basically, this code works day-to-day perfectly, but very occasionally, we start getting errors like this:</p>
<blockquote>
<p>"System.ArgumentException: Only the
first eigh... | <p>The <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx" rel="nofollow noreferrer">documentation</a> states that:</p>
<blockquote>
<p>You can only use the Source to write
to one log at a time</p>
</blockquote>
<p>So I suspect this problem is caused by your multithreaded app callin... | <p>Thanks Bruno,</p>
<p>So, am I mistaken in thinking that the EventLog instance in the Log method is different from the EventLog instance in the same method call in a different thread? Or am I just getting confused about object instances inside a static method?</p>
<p>OK, so I have several wrapper methods to the Log... | 42,122 |
<p>I'd like to eliminate dependencies on hardcoded paths for configuration data in my Java apps, I understand that using ResourceBundle will help me use the classloader to find resources.</p>
<p>Can someone tell me how I would replace a hardcoded path to a resource (say a .properties configuration data file required b... | <p>Prior to Java 6, ResourceBundle typically allowed:</p>
<ul>
<li>Strings from a group of localised properties files, using <a href="http://java.sun.com/javase/6/docs/api/java/util/PropertyResourceBundle.html" rel="nofollow noreferrer">PropertyResourceBundle</a></li>
<li>Objects from a group of localised classes, usi... | <p>The trick behind Resource.getBundle(..) is the use of the classloader. You can load everything thats in your classpath by accessing it via this.getClass().getClassLoader().
Resource.getBundle(..) is a practical helper to use it in the resource/locatization topic.</p>
| 18,712 |
<p>I'm currently in the process of updating a site from preview 2 of ASP.NET MVC to the Beta release. I'm down to my last compile error with no solution in site after an exhaustive search. I have some code in Global.asax.cs which sets up IOC using the Windsor container:</p>
<pre><code>ControllerBuilder.Current.SetCont... | <p>PublicKeyToken=null doesn't seem right...</p>
<p><strong>Edit:</strong> I was right, the PublicKeyToken should be "31bf3856ad364e35". It sounds like they're linked against a private build of System.Web.Mvc.dll that isn't signed.</p>
| <p>Check that you've updated the appropriate assembly references to 3.5.0.0 in your web.config file, as described in the update notes for the beta.</p>
| 46,718 |
<p>The install instructions are:</p>
<pre><code>$ python setup.py build
$ sudo python setup.py install # or su first
</code></pre>
<p>This gives me an .egg file. How do I tell the install to dump the files as a normal, uncompressed library?</p>
<p>Thanks!</p>
| <p>OK, I hate to answer my own question, but:</p>
<p>find your python site-packages (mine is /usr/local/lib/python2.5/site-packages )</p>
<p>then:</p>
<pre><code>$ unzip MySQL_python-1.2.2-py2.5-linux-i686.egg
</code></pre>
<p>This worked fine for me</p>
| <p>This will tell setuptools to not zip it up:</p>
<pre><code>sudo python setup.py install --single-version-externally-managed
</code></pre>
| 33,627 |
<p>How can I find out the number of dimensions in an array in Classic ASP ( VBScript ) .</p>
<p>I am being passed an Array with multiple dimensions but I only want to look at the last. Seems easy in other languages.</p>
| <pre><code>Ubound(MySingleDimensionalArray, 2) ' Number of Array Elements
Ubound(MyMultiDimensionalArray, 1) ' Number of Columns
Ubound(MyMultiDimensionalArray, 2) ' Number of Rows
</code></pre>
| <pre><code>function ArrayDimensions( theArray )
dim Result,test
Result = 0
if isarray(theArray) then
on error resume next
do
test = -2
test = ubound(theArray,result+1)
if test > -2 then result = result + 1
loop until test=-2
... | 34,441 |
<p>I am currently doing some socket programming using C/C++. To be able to use a somewhat cleaner interface, and a more OO structure, I decided to write a few simple wrapper classes around parts of the C socket API, but while doing so I stumbled upon a problem:</p>
<p>Given the following code:</p>
<pre><code>// Globa... | <p>The problem is that it first looks in the scope of your class, and finds a foo function. The lookup will stop then, and the compiler tries to match arguments. Since it only has the one foo function in that scope in your class, calling the function fails.</p>
<p>You need to explicitly state that you want to call the... | <p>You must use the scope resolution try:</p>
<p>::foo(1);</p>
| 41,482 |
<p>I have my J2EE application deployed into a JBossAS. My Application has to respond to two different hostnames (<a href="https://foo.com/myApp" rel="nofollow noreferrer">https://foo.com/myApp</a> and <a href="https://bar.com/myApp" rel="nofollow noreferrer">https://bar.com/myApp</a>). It is the same instance of the ap... | <p>With SSL you have to use two different I.P. addresses if you wish to use different SSL certificates. This isn't a shortcoming in Tomcat/JBoss, it is just the reality of the protocol.</p>
<p>I can't remember the technical reason off the top of my head (Google knows), but it comes down to the server not being able to... | <p>two apps can share one keystore which holds two certificates. The certificate is issued for a given domain. Define the second domain as a virtual host with different domain and do not touch the server.xml. It should work this way.</p>
| 25,532 |
<p>Let's say we're tracking the end-user IP for a web service:</p>
<pre><code>ip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If ip = "" Then
ip = Request.ServerVariables("REMOTE_ADDR")
End If
</code></pre>
<p>I've read that this is the best method of retrieving end-user IP because it works even for users on... | <p><code>REMOTE_ADDR</code> is generated by the web server based on the connection from the client. <code>HTTP_X_FORWARDED_FOR</code> is based on a HTTP header sent by the client.</p>
<p>You can't trust input from the client, particularly input that is easily faked, such as HTTP headers. Clients can stick <strong>an... | <p>If the users are using a transparent proxy then the above code will get the real IP address. If they're using an anonymous proxy, though (like Anonymizer) then there's really no way to get the users actual IP address.</p>
| 41,093 |
<p>Does anyone know of existing software or algorithms to calculate a package size for shipping multiple items?</p>
<p>I have a bunch of items in our inventory database with length, width and height dimesions defined. Given these dimensions I need to calculate how many of the purchased items will fit into predefined ... | <p>This is a <a href="http://en.wikipedia.org/wiki/Bin_packing_problem" rel="noreferrer">Bin Packing</a> problem, and it's NP-hard. For small number of objects and packages, you might be able to simply use the brute force method of trying every possibility. Beyond that, you'll need to use a heuristic of some sort. The ... | <p>After lot of searching i have found a <a href="https://github.com/davidmchapman/3DContainerPacking" rel="nofollow noreferrer">GitHub</a> repository that might help someone. Function <code>PackingService.Pack()</code> takes list of <code>Container</code> and list of <code>Item</code>(s) to be packed as parameter and ... | 16,979 |
<p>I've been using ISAPI_Rewrite from Helicon (<a href="http://www.helicontech.com/isapi_rewrite/" rel="nofollow noreferrer">http://www.helicontech.com/isapi_rewrite/</a>) on a Server 2003 box for years and have always had good luck with it.</p>
<p>I'm migrating all the sites on the 2003 box to a new shiny Server 2008... | <p>IIS7 does have the functionality built in, as you mentioned. You can either use a custom HttpModule, as described in <a href="http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx" rel="nofollow noreferrer">Tip/Trick: Url Rewriting with ASP.NET</a>.</p>
<p>Alternatively, you co... | <p>Yes, check out the <a href="http://www.iis.net/extensions/URLRewrite" rel="nofollow noreferrer">IIS 7 URL Rewrite Module</a>.</p>
| 39,079 |
<p>I've got a text file full of records where each field in each record is a fixed width. My first approach would be to parse each record simply using string.Substring(). Is there a better way? </p>
<p>For example, the format could be described as:</p>
<pre><code><Field1(8)><Field2(16)><Field3(12)>... | <p>Use <a href="http://www.filehelpers.net/" rel="noreferrer">FileHelpers</a>.</p>
<p>Example:</p>
<pre><code>[FixedLengthRecord()]
public class MyData
{
[FieldFixedLength(8)]
public string someData;
[FieldFixedLength(16)]
public int SomeNumber;
[FieldFixedLength(12)]
[FieldTrim(TrimMode.Right)]
... | <p>Nope, Substring is fine. That's what it's for.</p>
| 19,675 |
<p>I am trying to test the likelihood that a particular clustering of data has occurred by chance. A robust way to do this is Monte Carlo simulation, in which the associations between data and groups are randomly reassigned a large number of times (e.g. 10,000), and a metric of clustering is used to compare the actual... | <p>Here's some code for sampling without replacement based on Algorithm 3.4.2S of Knuth's book Seminumeric Algorithms.</p>
<pre><code>void SampleWithoutReplacement
(
int populationSize, // size of set sampling from
int sampleSize, // size of each sample
vector<int> & samples // output,... | <p>Another algorithm for sampling without replacement is described <a href="http://rosettacode.org/wiki/Knuth%27s_algorithm_S" rel="nofollow">here</a>. </p>
<p>It is similar to the one described by John D. Cook in his answer and also from Knuth, but it has different hypothesis: The population size is unknown, but the ... | 40,169 |
<p>I have two assemblies with the same name in the Global Assembly cache, but with different version numbers. How do I tell my program which version to reference?</p>
<p>For the record, this is a VB.Net page in an ASP.Net web site.</p>
| <p>As long as the version number is different (which would be required), you can specify the proper version through your web.config file. This is how I have things setup in one of my apps to reference the proper version of Crystal Reports, since we have multiple versions in the GAC:</p>
<pre><code><system.web>
... | <p>To install an assembly in the GAC you have to give it a strong name. Strong names are never duplicated. So to specify which assembly you want to use you reference it by the strong name.</p>
| 30,310 |
<h3>ANSWER:</h3>
<p>If you ever see these lines and are mistified like I was, here's what they mean.</p>
<p><code>Thread[AWT-EventQueue-0] (Suspended (exception NullPointerException))</code></p>
<p><code>EventDispatchTread.run() line: not available [local variables unavailable]</code></p>
<p>It's not that the variables... | <p>Welcome to the complexity of writing GUI code.</p>
<p>When you run a Swing program, a background thread called the Event Dispatch Thread is created. When the user clicks on a JButton, for example, JButton creates and fires an event using this Event Dispatch Thread. Hence the name: it's the thread that dispatches ev... | <p>You might have forgotten to actually set an ActionCommand.</p>
<p>In the <a href="http://java.sun.com/javase/6/docs/api/java/awt/event/ActionEvent.html#getActionCommand()" rel="nofollow noreferrer">ActionEvent API Doc</a> there's a note regarding possible null results of getActionCommand().</p>
| 44,661 |
<p>In a Linux embedded application I'm developing, there is the need to record some events that happen from time to time. These records are saved on a MTD flash device and once written there is no need to change them or do efficient searches, but read access is required to show the data back to the user.
A big problem ... | <p>I'm not expert on embeded systems, but I would think that a CSV would probably be best. It basically can't be corrupted, or if it does, then you can easily see the error and fix it manually (new line or just removing a line). I have been working on receiving the data from an embeded system where they have a lot of c... | <p>Two csv/text files. Start a new pair each time the system restarts. Write each event to the first file, flush the file to store, write the record to the second file, then flush again.</p>
<p>This way, if you crash during the first write all the data in the second copy (up until that write) will still be there.</p>
... | 20,770 |
<p>I am currently encountering a problem where under certain circumstances, the extruder stutters when it starts a new layer. I am printing on an Anycubic i3 Mega and am slicing with Cura 3.6.0. The problem seems to occur in the main part of prints, as well as in supports. However it seems to only occur after a retract... | <p>You retraction settings may be too high. Direct drive extruders require less retraction than Bowden style extruders. Typical retraction settings for direct drive are 1.5mm at 50mm/s and for Bowden, 4mm at 50mm/s. The speed usually makes more of a difference than distance beyond a certain point.</p>
<p>You can get a... | <p><em>Definition: <strong>Sparse layer fill</strong> (called stuttering by the OP)</em></p>
<hr />
<h2>Why a sparsely filled support structure... (at the support bottom)</h2>
<p>Support structures are added by Ultimaker Cura as the first part of the layer before it progresses to the rest of the print object. The botto... | 1,100 |
<p>How can I Submit an InfoPath form to a SharePoint library AND to an email box at the same time when the user hits SUBMIT?</p>
<p>I need my form to be approved by several users in a particular order; then re-submitted to the SharePoint site, and to another email box so that the next approver can see the approvals, a... | <p>You can add an additional DataSource for submission (send to SharePoint library) and add a rule to your submit button before the save&close rules.</p>
<p>BUT - I would suggest a method that is based on workflows and a form that is held on a SharePoint site. I had a very similar task, where approvals were needed... | <p>Sorry for asking but have you considered using a workflow rather then emails? I'm not sure whether the basic workflows in WSS 3.0 will cater for your senario but the MOSS workflow should be more than adequate.</p>
| 29,107 |
<p>How do you build a hierarchical set of tags with data in PHP?</p>
<p>For example, a nested list:</p>
<pre><code><div>
<ul>
<li>foo
</li>
<li>bar
<ul>
<li>sub-bar
</li>
</ul>
... | <p><em>Edit: Added formatting</em></p>
<p>As already said in the comments, your data structure is somewhat strange. Instead of using text manipulation (like OIS), I prefer DOM:</p>
<pre><code><?php
$nested_array = array();
$nested_array[] = array('name' => 'foo', 'depth' => 0);
$nested_array[] = array('name... | <p>You mean something like</p>
<pre><code>function array_to_list(array $array, $width = 3, $type = 'ul', $separator = ' ', $depth = 0)
{
$ulSpace = str_repeat($separator, $width * $depth++);
$liSpace = str_repeat($separator, $width * $depth++);
$subSpace = str_repeat($separator, $width * $depth);
forea... | 41,158 |
<p>I've been thinking a lot lately about how to go about doing functional programming in C (<em>not</em> C++). Obviously, C is a procedural language and doesn't really support functional programming natively.</p>
<p>Are there any compiler/language extensions that add some functional programming constructs to the lang... | <p>You can use GCC's nested functions to simulate lambda expressions, in fact, I have a macro to do it for me:</p>
<pre><code>#define lambda(return_type, function_body) \
({ \
return_type anon_func_name_ function_body \
anon_func_name_; \
})
</code></pre>
<p>Use like this:</p>
<pre><code>int (*max)(int, ... | <p>What is it about C that you want to make functional, the syntax or the semantics? The semantics of functional programming could certainly be added to the C compiler, but by the time you were done, you'd essentially have the equivalent of one of the existing functional languages, such as Scheme, Haskell, etc.</p>
<p... | 26,558 |
<p>I'm trying to use a Microsoft Access database for a demo project that I'm thinking of doing in either CodeIgniter or CakePHP. Ignoring the possible folly of using Microsoft Access, I haven't been able to figure out precisely how the connection string corresponds to the frameworks' database settings. In straight PHP,... | <p>Try setting up a DSN and changing to the following:</p>
<pre><code>$db['access']['hostname'] = "<dsn name>";
$db['access']['username'] = "";
$db['access']['password'] = "";
$db['access']['database'] = "<dsn name>";
</code></pre>
<p>There's also a section in the CodeIgniter documentation that addresses ... | <p>Would it be possible to use the SQL Express (free!) engine instead and just import/export your MS Access db? You could thank me later on that. :-)</p>
<p>Another option is to use the ADOdb library instead of CI's native DB library, though you'll lose the Active Record support from CI, and have to rewrite certain li... | 21,562 |
<p>Experienced with Rails / ActiveRecord 2.1.1</p>
<ul>
<li>You create a first version with (for example) ruby script\generate scaffold product title:string description:text image_url:string</li>
<li>This create (for example) a migration file called 20080910122415_create_products.rb</li>
<li>You apply the migration wi... | <p>You should be able to use </p>
<pre><code>rake db:migrate:up
</code></pre>
<p>to force it to go forward, but then you risk missing interleaved migrations from other people on your team</p>
<p>if you run </p>
<pre><code>rake db:migrate
</code></pre>
<p>twice, it will reapply all your migrations.</p>
<p>I enco... | <p>This is not the expected behaviour. I was going to suggest reporting this as a bug on lighthouse, but I see you've <a href="http://rails.lighthouseapp.com/projects/8994/tickets/1021-rake-dbmigrate-doesnt-detect-new-migration" rel="nofollow noreferrer">already done so</a>! If you provide some more information (incl... | 9,568 |
<p>Anyone know of a link to a good article/tutorial for getting started using jQuery for AJAX calls rather than ASP.NET AJAX? I'm trying to avoid using UpdatePanels entirely in this app, which I haven't been able to accomplish in the past.</p>
| <p>The most complete article I've ever found about this topic is <a href="https://www.codeproject.com/Articles/95525/ASP-NET-and-jQuery-to-the-Max" rel="nofollow noreferrer">ASP.NET and jQuery to the Max</a>.</p>
<p>It avoids update panel, script manager and viewstate.</p>
| <p>Damien Edwards just gave an awesome talk on this topic at the recent MIX11 conference. You can <a href="https://web.archive.org/web/20110724072836/http://channel9.msdn.com/events/MIX/MIX11/FRM12" rel="nofollow noreferrer">watch the video online (archived - click any download links below the player)</a> and download ... | 24,765 |
<p>Suppose I have a COM object which users can access via a call such as:</p>
<pre><code>Set s = CreateObject("Server")
</code></pre>
<p>What I'd like to be able to do is allow the user to specify an event handler for the object, like so:</p>
<pre><code>Function ServerEvent
MsgBox "Event handled"
End Function
... | <p>This is how I did it just recently. Add an interface that implements IDispatch and a coclass for that interface to your IDL:</p>
<pre><code>[
object,
uuid(6EDA5438-0915-4183-841D-D3F0AEDFA466),
nonextensible,
oleautomation,
pointer_default(unique)
]
interface IServerEvents : IDispatch
{
[id... | <p>I ended up following the technique described <a href="http://www.mp3car.com/vbulletin/digitalmods-scripts-api/81425-how-create-c-com-object-streetdeck.html" rel="nofollow noreferrer">here</a>.</p>
| 8,691 |
<p>I need to prompt an alert message when a user selects a particular option in a select menu. Is there a way to do this using jQuery?</p>
| <p>assuming your select has an ID of myselect, and the value you want to check is "myval"</p>
<pre><code>$("#myselect").change(function() {
if($(this).val() == "myval")
{
alert('message');
}
});
</code></pre>
<p>I havent tested this but the concept should be sound</p>
| <p>I recently bumped into the <a href="http://nadiana.com/jquery-confirm-plugin" rel="nofollow noreferrer">jQuery Confirm Plugin</a>. It may or may be what you are looking for.</p>
| 44,368 |
<p>When writing CUDA applications, you can either work at the driver level or at the runtime level as illustrated on this image (The libraries are CUFFT and CUBLAS for advanced math):</p>
<p><a href="https://i.stack.imgur.com/TD51p.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/TD51p.jpg" alt="CUDA layer mo... | <p>The CUDA runtime makes it possible to compile and link your CUDA kernels into executables. This means that you don't have to distribute cubin files with your application, or deal with loading them through the driver API. As you have noted, it is generally easier to use. </p>
<p>In contrast, the driver API is hard... | <p>There are some real issues with argument alignment and the driver API. Check out the CUDA 2.2 beta (or later) documentation for more information.</p>
| 30,079 |
<p>I have two PHP files that I need to link. How can I link the files together using PHP? The effect I want is to have the user click a button, some information is proccessed on the page, and then the result is displayed in a different page, depending on the button the user clicked.Thanks</p>
| <p>It sounds like you might want an HTML form:</p>
<pre><code><form method="post" action="other_file.php">
<input name="foo" type="..."... /> ...
</form>
</code></pre>
<p>Then <code>$_POST["foo"]</code> will contain the value of that input in other_file.php.</p>
| <p>In PHP's most basic setup, you can use two independent files: one generates the form, the second handles the response. You can also handle this with one file that checks to see if the form as been posted.</p>
<pre><code> if (isset($_POST['foo'])) { ... }
</code></pre>
<p>or</p>
<pre><code> if ($_SERVER['REQUEST_... | 29,403 |
<p>When we serialize an enum from C# to SQL Server we use a NCHAR(3) datatype with mnemonic values for each value of the enum.
That way we can easily read a SELECT qry.</p>
<p>How do you save enum to your database?</p>
<p>What datatype do you use?</p>
| <p>A better way would be to store as an int. That way you can deserialise/cast from the DB right back to the correct enum value.</p>
<p>If the enum is likely to be changed in the future then use explicit values e.g.</p>
<pre><code>public enum ActionType
{
Insert = 1,
Update = 2,
Delete = 3
}
</code></pre>
<p>T... | <p>nchar(3) for mnemonics?</p>
<p>As Martin pointed out, use a lookup table with INT as PK, VARCHAR identifier as UK, and NVARCHAR description.</p>
<p>You can write a stored procedure to script the table values as C# enum or as C# public consts.</p>
<p>Thus the values are documented both in the database and in the C... | 48,585 |
<p>Modelsim, an HDL simulator, allows you to specify the font used by the output. Fixed width fonts allow for more orderly output, but many fixed width fonts are not easy on the eyes. What would you recommend? I currently use Lucida Console.</p>
<p>I've tried Inconsolata and Consolas per some recommendations, but M... | <p>See the answers to this question: <a href="https://stackoverflow.com/questions/4689/recommended-fonts-for-programming">Recommended Fonts for Programming?</a></p>
| <p><a href="http://damieng.com/blog/2007/11/14/droid-sans-mono-great-coding-font" rel="nofollow noreferrer">Droid Sans Mono</a> and <a href="http://www.bitstream.com/font_rendering/products/dev_fonts/vera.html" rel="nofollow noreferrer">Bitstream Vera Sans Mono</a> are both liberally licensed and very readable to my ey... | 26,308 |
<p>I'm getting notifications to back up my encryption key for EFS in Vista, however i haven't enabled bit locker or drive encryption.</p>
<p>Anyone know how to find out what files may be encrypted or have an explanation for why it would notify me?</p>
| <p>To find out which files on your system have been encrypted with EFS, you can simply run this command:</p>
<pre><code>CIPHER.EXE /U /N
</code></pre>
| <p>Clippy noticed that you have sensitive information in your files and automatically encrypted them.</p>
<p>Are you sure it's for EFS? I've had things prompt me to backup my keys before, but I didn't know exactly what they were to. I was assuming it was like a DRM protected file or something. It was a while ago so i ... | 3,279 |
<p>I have a .NET UserControl (FFX 3.5). This control contains several child Controls - a Panel, a couple Labels, a couple TextBoxes, and yet another custom Control. I want to handle a right click anywhere on the base Control - so a right click on any child control (or child of a child in the case of the Panel). I'd ... | <p>If the labels are in a subcontrol then you'd have to do this recursively:</p>
<pre><code>void initControlsRecursive(ControlCollection coll)
{
foreach (Control c in coll)
{
c.MouseClick += (sender, e) => {/* handle the click here */});
initControlsRecursive(c.Controls);
}
}
... | <p>To handle a <em>MouseClick</em> event for right click on all the controls on a custom <em>UserControl</em>:</p>
<pre><code>public class MyClass : UserControl
{
public MyClass()
{
InitializeComponent();
MouseClick += ControlOnMouseClick;
if (HasChildren)
AddOnMouseClickHa... | 30,805 |
<p>After discussion with colleagues regarding the use of the 'var' keyword in C# 3 I wondered what people's opinions were on the appropriate uses of type inference via var?</p>
<p>For example I rather lazily used var in questionable circumstances, e.g.:-</p>
<pre><code>foreach(var item in someList) { // ... } // Type... | <p>I still think <code>var</code> can make code more readable in some cases. If I have a Customer class with an Orders property, and I want to assign that to a variable, I will just do this:</p>
<pre><code>var orders = cust.Orders;
</code></pre>
<p>I don't care if Customer.Orders is <code>IEnumerable<Order></co... | <p>Don't use that, makes your code unreadable.</p>
<p>ALWAYS use as strict typing as possible, crutches only makes your life hell.</p>
| 6,278 |
<p>Using cyanoacrylate to glue PLA parts sometimes leaves a white residue or haze near the glue locations. Is there an easy way to remove it?</p>
<p>I've tried water and alcohol swabs but after drying the haze remains.</p>
<p><a href="https://i.stack.imgur.com/cw1pu.jpg" rel="nofollow noreferrer" title="Photo showing ... | <h2>Make sure to set the scale properly for your use case!</h2>
<p>In CAD, you define your measurement space in either Inch or in Millimeter units, and that is your grid. In blender, the native unit is the meter.</p>
<p>This can be easily converted in exporting (remember to set it to scale!), but it is best to just set... | <p>It doesn't matter, you scale it in the slicer or elsewhere. You're not going to slice the STL file in Blender. You'll probably need to do more work to get things print ready outside blender anyway.</p>
<p>So when I use blender I don't even bother checking what units it's using. I don't use it for parts design or tec... | 2,123 |
<p>I am using Lotus Notes as my email client, and how to change the defailt email delete date to something new so my older emails don't get deleted after pre-defined date?</p>
| <p>go to TOOLS -> Change Delete Date , you can put any number of days to change the default delete date of selected email.</p>
| <p>Lotus Notes email does not automatically delete email - There is no "default delete date". </p>
<p>It does have a setting to automatically delete email from your Trash folder after a specified amount of hours (but mail only gets put in the Trash if you delete it). You can find this setting by clicking More >> Pre... | 11,093 |
<p>I have a collection of HTML documents for which I need to parse the contents of the <meta> tags in the <head> section. These are the only HTML tags whose values I'm interested in, i.e. I don't need to parse anything in the <body> section.</p>
<p>I've attempted to parse these values using the XPath... | <p>You can likely use the <a href="http://jerichohtml.sourceforge.net/doc/index.html" rel="nofollow noreferrer">Jericho HTML Parser</a>. In particular, have a look at <a href="http://jerichohtml.sourceforge.net/samples/console/src/FindSpecificTags.java" rel="nofollow noreferrer">this</a> to see how you can go about fin... | <p><a href="http://jtidy.sourceforge.net/" rel="nofollow noreferrer">JTidy</a> should provide a good starting point for this.</p>
| 38,344 |
<p>I keep it in single line, if it's short. Lately I've been using this style for longer or nested ternary operator expressions. A contrived example:</p>
<pre><code>$value = ( $a == $b )
? 'true value # 1'
: ( $a == $c )
? 'true value # 2'
: 'false value';
</cod... | <p>The ternary operator is generally to be avoided, but this form can be quite readable:</p>
<pre><code> result = (foo == bar) ? result1 :
(foo == baz) ? result2 :
(foo == qux) ? result3 :
(foo == quux) ? result4 :
fail_result;
</code></pre>
<p>This way... | <p>I tend not to use the ternary operator at all as I find if .. else much more readable.</p>
| 30,127 |
<p>I want a recommendation on an ISP which has Subversion installed so I can get a repository started. So far I found out discount.asp doesn't have that on their servers and will not support it. So I'm looking for a recommendation</p>
| <p>What's your price range?
Do you want a straght SVN provider or do you want to host a website too?</p>
<p>For Straight SVN Hosting Check out</p>
<p><a href="http://cvsdude.com/" rel="nofollow noreferrer">http://cvsdude.com/</a></p>
<p><a href="http://www.assembla.com/" rel="nofollow noreferrer">http://www.assembla... | <p><a href="http://csoft.net" rel="nofollow noreferrer">csoft.net</a> is pretty good. They've been around for a long time, they're cheap, good, open source friendly, very geek friendly, and accounts come with SVN (and with the more expensive plans, a ton of other features). Also, ever tried to deal with frontline tec... | 12,494 |
<p>I have an array of mouse points, a stroke width, and a softness. I can draw soft circles and soft lines. Which algorithm should I use for drawing my array of points? I want crossed lines to look nice as well as end points. </p>
| <p>I would definitely choose the Bezier for that purpose, and in particular I will implement the piecewise cubic Bezier - it is truly easy to implement and grasp and it is widely used by 3D Studio max and Photoshop.</p>
<p>Here is a good source for it:
<a href="http://local.wasp.uwa.edu.au/~pbourke/surfaces_curves/bez... | <p>I think maybe you're looking for a spline algorithm.</p>
<p>Here is a spline tutorial, which you might find helpfull:</p>
<p>[<a href="http://www.doc.ic.ac.uk/~dfg/AndysSplineTutorial/index.html]" rel="nofollow noreferrer">http://www.doc.ic.ac.uk/~dfg/AndysSplineTutorial/index.html]</a></p>
<p>The subject is also... | 11,146 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.