qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
87,713
<p>For example, right now I have a roll-my-own solution that uses data files that include blocks like:</p> <pre><code>PlayerCharacter Fighter Hitpoints 25 Strength 10 StartPosition (0, 0, 0) Art Model BigBuffGuy Footprint LargeFootprint end InventoryItem Sword InventoryItem Shield InventoryItem...
[ { "answer_id": 87725, "author": "Bill K", "author_id": 12943, "author_profile": "https://Stackoverflow.com/users/12943", "pm_score": 3, "selected": false, "text": "<p>Yaml is a good solution and very close to what you have. Search for it.</p>\n" }, { "answer_id": 87736, "aut...
2008/09/17
[ "https://Stackoverflow.com/questions/87713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16639/" ]
For example, right now I have a roll-my-own solution that uses data files that include blocks like: ``` PlayerCharacter Fighter Hitpoints 25 Strength 10 StartPosition (0, 0, 0) Art Model BigBuffGuy Footprint LargeFootprint end InventoryItem Sword InventoryItem Shield InventoryItem HealthPotion ...
Yaml is a good solution and very close to what you have. Search for it.
87,734
<p>If the major axis of the ellipse is vertical or horizontal, it's easy to calculate the bounding box, but what about when the ellipse is rotated?</p> <p>The only way I can think of so far is to calculate all the points around the perimeter and find the max/min x and y values. It seems like there should be a simpler ...
[ { "answer_id": 87965, "author": "PierreBdR", "author_id": 7136, "author_profile": "https://Stackoverflow.com/users/7136", "pm_score": 2, "selected": false, "text": "<p>I think the most useful formula is this one. An ellipsis rotated from an angle phi from the origin has as equation:</p>\...
2008/09/17
[ "https://Stackoverflow.com/questions/87734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2214/" ]
If the major axis of the ellipse is vertical or horizontal, it's easy to calculate the bounding box, but what about when the ellipse is rotated? The only way I can think of so far is to calculate all the points around the perimeter and find the max/min x and y values. It seems like there should be a simpler way. If t...
You could try using the parametrized equations for an ellipse rotated at an arbitrary angle: ``` x = h + a*cos(t)*cos(phi) - b*sin(t)*sin(phi) [1] y = k + b*sin(t)*cos(phi) + a*cos(t)*sin(phi) [2] ``` ...where ellipse has centre (h,k) semimajor axis a and semiminor axis b, and is rotated through angle phi. You ca...
87,747
<p>I want to create a list of columns in SQL Server 2005 that have identity columns and their corresponding table in T-SQL.</p> <p>Results would be something like:</p> <p>TableName, ColumnName</p>
[ { "answer_id": 87773, "author": "Kevin Crumley", "author_id": 1818, "author_profile": "https://Stackoverflow.com/users/1818", "pm_score": 6, "selected": false, "text": "<p>sys.columns.is_identity = 1</p>\n\n<p>e.g.,</p>\n\n<pre><code>select o.name, c.name\nfrom sys.objects o inner join s...
2008/09/17
[ "https://Stackoverflow.com/questions/87747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to create a list of columns in SQL Server 2005 that have identity columns and their corresponding table in T-SQL. Results would be something like: TableName, ColumnName
Another potential way to do this for SQL Server, which has less reliance on the system tables (which are subject to change, version to version) is to use the INFORMATION\_SCHEMA views: ``` select COLUMN_NAME, TABLE_NAME from INFORMATION_SCHEMA.COLUMNS where COLUMNPROPERTY(object_id(TABLE_SCHEMA+'.'+TABLE_NAME), COLUMN...
87,753
<p>How can I resize an image, with the image quality unaffected?</p>
[ { "answer_id": 87763, "author": "Randy", "author_id": 9361, "author_profile": "https://Stackoverflow.com/users/9361", "pm_score": 5, "selected": false, "text": "<p>Unless you're doing vector graphics, there's no way to resize an image without potentially losing some image quality.</p>\n"...
2008/09/17
[ "https://Stackoverflow.com/questions/87753", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1368/" ]
How can I resize an image, with the image quality unaffected?
As [rcar](https://stackoverflow.com/questions/87753/resizing-an-image-without-losing-any-quality#87763) says, you can't without losing some quality, the best you can do in c# is: ``` Bitmap newImage = new Bitmap(newWidth, newHeight); using (Graphics gr = Graphics.FromImage(newImage)) { gr.SmoothingMode = Smoothing...
87,758
<p>I have several old 3.5in floppy disks that I would like to backup. My attempts to create an image of the disks have failed. I tried using the UNIX utility dd_rescue, but when the kernel tries to open (<code>/dev/fd0</code>) I get a kernel error,</p> <pre><code>floppy0: probe failed... </code></pre> <p>I would li...
[ { "answer_id": 88447, "author": "user10392", "author_id": 10392, "author_profile": "https://Stackoverflow.com/users/10392", "pm_score": 3, "selected": true, "text": "<p>I think you'll find the best resource <a href=\"http://www.hpcc.org/datafile/hpil/lif_utils.html\" rel=\"nofollow noref...
2008/09/17
[ "https://Stackoverflow.com/questions/87758", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4778/" ]
I have several old 3.5in floppy disks that I would like to backup. My attempts to create an image of the disks have failed. I tried using the UNIX utility dd\_rescue, but when the kernel tries to open (`/dev/fd0`) I get a kernel error, ``` floppy0: probe failed... ``` I would like an image because some of the floppi...
I think you'll find the best resource [here](http://www.hpcc.org/datafile/hpil/lif_utils.html). Also, if you're going to use raw dd, LIF format has 77 cylinders vs 80 for a normal floppy.
87,760
<p>Ive been smashing my head with this for a while. I have 2 completely identical .wmv files encoded with wmv3 codec. I put them both through ffmpeg with the following command:</p> <pre><code>/usr/bin/ffmpeg -i file.wmv -ar 44100 -ab 64k -qscale 9 -s 512x384 -f flv file.flv </code></pre> <p>One file converts just fin...
[ { "answer_id": 87837, "author": "davr", "author_id": 14569, "author_profile": "https://Stackoverflow.com/users/14569", "pm_score": 2, "selected": false, "text": "<p>Well the obvious answer is that the audio is encoded differently in the second wmv file, so they are not completely identic...
2008/09/17
[ "https://Stackoverflow.com/questions/87760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Ive been smashing my head with this for a while. I have 2 completely identical .wmv files encoded with wmv3 codec. I put them both through ffmpeg with the following command: ``` /usr/bin/ffmpeg -i file.wmv -ar 44100 -ab 64k -qscale 9 -s 512x384 -f flv file.flv ``` One file converts just fine, and gives me the follow...
It is in fact the audio format, which causes trouble. Audio formats are identified by its TwoCC (0x0162 here). You can look up the different TwoCCs here: <http://wiki.multimedia.cx/index.php?title=TwoCC> and you'll find: 0x0162 Windows Media Audio Professional V9 This codec isn't supported yet by ffmpeg and mencoder...
87,795
<p>All I want is to update an ListViewItem's text whithout seeing any flickering.</p> <p>This is my code for updating (called several times):</p> <pre><code>listView.BeginUpdate(); listViewItem.SubItems[0].Text = state.ToString(); // update the state listViewItem.SubItems[1].Text = progress.ToString(); // update t...
[ { "answer_id": 87840, "author": "ctacke", "author_id": 13154, "author_profile": "https://Stackoverflow.com/users/13154", "pm_score": 0, "selected": false, "text": "<p>If you only want to update the text, simply set the changed SubItem's text directly rather than updating the entire ListV...
2008/09/17
[ "https://Stackoverflow.com/questions/87795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10833/" ]
All I want is to update an ListViewItem's text whithout seeing any flickering. This is my code for updating (called several times): ``` listView.BeginUpdate(); listViewItem.SubItems[0].Text = state.ToString(); // update the state listViewItem.SubItems[1].Text = progress.ToString(); // update the progress listView....
To end this question, here is a helper class that should be called when the form is loading for each ListView or any other ListView's derived control in your form. Thanks to "Brian Gillespie" for giving the solution. ``` public enum ListViewExtendedStyles { /// <summary> /// LVS_EX_GRIDLINES /// </summary>...
87,812
<p>Say I have the following class</p> <pre><code>MyComponent : IMyComponent { public MyComponent(int start_at) {...} } </code></pre> <p>I can register an instance of it with castle windsor via xml as follows</p> <pre><code>&lt;component id="sample" service="NS.IMyComponent, WindsorSample" type="NS.MyComponent, Wi...
[ { "answer_id": 87893, "author": "Gareth", "author_id": 1313, "author_profile": "https://Stackoverflow.com/users/1313", "pm_score": 0, "selected": false, "text": "<p>You need to pass in an IDictionary when you ask the container for the instance.</p>\n\n<p>You'd use this Resolve overload o...
2008/09/17
[ "https://Stackoverflow.com/questions/87812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
Say I have the following class ``` MyComponent : IMyComponent { public MyComponent(int start_at) {...} } ``` I can register an instance of it with castle windsor via xml as follows ``` <component id="sample" service="NS.IMyComponent, WindsorSample" type="NS.MyComponent, WindsorSample"> <parameters> <st...
Edit: Used the answers below code with the Fluent Interface :) ``` namespace WindsorSample { using Castle.MicroKernel.Registration; using Castle.Windsor; using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; public class MyComponent : IMyComponent { public MyComponent(int start_a...
87,818
<p>Hi I am trying to find a way to read the cookie that i generated in .net web application to read that on the php page because i want the users to login once but they should be able to view .net and php pages ,until the cookie expires user should not need to login in again , but both .net and php web applications are...
[ { "answer_id": 87834, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>any cookie given to a browser will be readable by server processing the request --- they're language agnostic.</p>\n\n<p>try...
2008/09/17
[ "https://Stackoverflow.com/questions/87818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Hi I am trying to find a way to read the cookie that i generated in .net web application to read that on the php page because i want the users to login once but they should be able to view .net and php pages ,until the cookie expires user should not need to login in again , but both .net and php web applications are on...
You mention that : > > but both .net and php web applications are on different servers > > > Are both applications running under the same domain name? (ie: www.mydomain.com) or are they on different domains? If they're on the same domain, then you can do what you're trying to do in PHP by using the $\_COOKIE var...
87,821
<p>Is it possible to use an <strong>IF</strong> clause within a <strong>WHERE</strong> clause in MS SQL?</p> <p>Example:</p> <pre><code>WHERE IF IsNumeric(@OrderNumber) = 1 OrderNumber = @OrderNumber ELSE OrderNumber LIKE '%' + @OrderNumber + '%' </code></pre>
[ { "answer_id": 87833, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 3, "selected": false, "text": "<p>Use a <a href=\"http://msdn.microsoft.com/en-us/library/ms181765.aspx\" rel=\"noreferrer\">CASE</a> statement instea...
2008/09/17
[ "https://Stackoverflow.com/questions/87821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/299/" ]
Is it possible to use an **IF** clause within a **WHERE** clause in MS SQL? Example: ``` WHERE IF IsNumeric(@OrderNumber) = 1 OrderNumber = @OrderNumber ELSE OrderNumber LIKE '%' + @OrderNumber + '%' ```
Use a [CASE](http://msdn.microsoft.com/en-us/library/ms181765.aspx) statement **UPDATE:** The previous syntax (as pointed out by a few people) doesn't work. You can use CASE as follows: ``` WHERE OrderNumber LIKE CASE WHEN IsNumeric(@OrderNumber) = 1 THEN @OrderNumber ELSE '%' + @OrderNumber END ``...
87,831
<p>Nant seems very compiler-centric - which is guess is because it's considered a .NET development system. But I know it can be done! I've seen it. The platform we're building on has its own compiler and doesn't use 'cl.exe' for c++. We're building a C++ app on a different platform and would like to override with our ...
[ { "answer_id": 87844, "author": "Serafina Brocious", "author_id": 4977, "author_profile": "https://Stackoverflow.com/users/4977", "pm_score": 2, "selected": false, "text": "<p>You need to write your own task. <a href=\"http://www.atalasoft.com/cs/blogs/jake/archive/2008/05/07/writing-cu...
2008/09/17
[ "https://Stackoverflow.com/questions/87831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/424554/" ]
Nant seems very compiler-centric - which is guess is because it's considered a .NET development system. But I know it can be done! I've seen it. The platform we're building on has its own compiler and doesn't use 'cl.exe' for c++. We're building a C++ app on a different platform and would like to override with our own ...
Here is one I did for Delphi. Each 'arg' is a separate param with a value defined elsewhere. The target is called with the params set up before calling it. ``` <target name="build.application"> <exec program="dcc32" basedir="${Delphi.Bin}" workingdir="${Application.Folder}" verbose="true"> <arg value="${Ap...
87,877
<p>I am trying to build a dependency graph of tables based on the foreign keys between them. This graph needs to start with an arbitrary table name as its root. I could, given a table name look up the tables that reference it using the all_constraints view, then look up the tables that reference them, and so on, but ...
[ { "answer_id": 88217, "author": "Milan Babuškov", "author_id": 14690, "author_profile": "https://Stackoverflow.com/users/14690", "pm_score": 2, "selected": false, "text": "<p>Simplest way to do this is to copy all the FK info into a simple, 2-column (parent,child) table, and then use the...
2008/09/17
[ "https://Stackoverflow.com/questions/87877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9940/" ]
I am trying to build a dependency graph of tables based on the foreign keys between them. This graph needs to start with an arbitrary table name as its root. I could, given a table name look up the tables that reference it using the all\_constraints view, then look up the tables that reference them, and so on, but this...
``` select parent, child, level from ( select parent_table.table_name parent, child_table.table_name child from user_tables parent_table, user_constraints parent_constraint, user_constraints child_constraint, user_tables child_table where parent_table.table_name = parent_constraint.tabl...
87,902
<p>I am trying to validate user id's matching the example:</p> <pre><code>smith.jack or smith.jack.s </code></pre> <p>In other words, any number of non-whitespace characters (except dot), followed by exactly one dot, followed by any number of non-whitespace characters (except dot), optionally followed by exactly one ...
[ { "answer_id": 87919, "author": "BCS", "author_id": 1343, "author_profile": "https://Stackoverflow.com/users/1343", "pm_score": 1, "selected": false, "text": "<pre><code>[^\\s.]+\\.[^\\s.]+(\\.[^\\s.]+)?\n</code></pre>\n\n<p>BTW what you asked for allows \".\" and \"..\"</p>\n" }, { ...
2008/09/17
[ "https://Stackoverflow.com/questions/87902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to validate user id's matching the example: ``` smith.jack or smith.jack.s ``` In other words, any number of non-whitespace characters (except dot), followed by exactly one dot, followed by any number of non-whitespace characters (except dot), optionally followed by exactly one dot followed by any number...
^([^.\s]+)\.([^.\s]+)(?:\.([^.\s]+))?$
87,909
<p>Is it possible to set the title of a page when it's simply a loaded SWF?</p>
[ { "answer_id": 87984, "author": "madcolor", "author_id": 13954, "author_profile": "https://Stackoverflow.com/users/13954", "pm_score": 0, "selected": false, "text": "<p>I would think you would be able to do it. You would have to access the javascript DOM. </p>\n\n<p>A couple links that ...
2008/09/17
[ "https://Stackoverflow.com/questions/87909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/69665/" ]
Is it possible to set the title of a page when it's simply a loaded SWF?
This is how I would do it: ``` ExternalInterface.call("document.title = 'Hello World'"); ``` Or more generalized: ``` function setPageTitle( newTitle : String ) : void { var jsCode : String = "function( title ) { document.title = title; }"; ExternalInterface.call(jsCode, newTitle); } ```
87,934
<p>In Notepad++, I was writing a JavaScript file and something didn't work: an alert had to be shown when a button was clicked, but it wasn't working.</p> <p>I has used the auto-complete plugin provided with Notepad++, which presented me with <code>onClick</code>.</p> <p>When I changed the capital <code>C</code> to a...
[ { "answer_id": 87958, "author": "Prestaul", "author_id": 5628, "author_profile": "https://Stackoverflow.com/users/5628", "pm_score": 6, "selected": true, "text": "<p>Javascript is <strong>ALWAYS</strong> case-sensitive, html is not.</p>\n\n<p>It sounds as thought you are talking about wh...
2008/09/17
[ "https://Stackoverflow.com/questions/87934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11795/" ]
In Notepad++, I was writing a JavaScript file and something didn't work: an alert had to be shown when a button was clicked, but it wasn't working. I has used the auto-complete plugin provided with Notepad++, which presented me with `onClick`. When I changed the capital `C` to a small `c`, it did work. So first of a...
Javascript is **ALWAYS** case-sensitive, html is not. It sounds as thought you are talking about whether html attributes (e.g. onclick) are or are not case-sensitive. The answer is that the attributes are not case sensitive, but the way that we access them through the DOM is. So, you can do this: ``` <div id='divYo'...
87,970
<p>I'd like to populate an arraylist by specifying a list of values just like I would an integer array, but am unsure of how to do so without repeated calls to the "add" method.</p> <p>For example, I want to assign { 1, 2, 3, "string1", "string2" } to an arraylist. I know for other arrays you can make the assignment...
[ { "answer_id": 88017, "author": "Sunny Milenov", "author_id": 8220, "author_profile": "https://Stackoverflow.com/users/8220", "pm_score": 4, "selected": true, "text": "<p>Array list has ctor which accepts ICollection, which is implemented by the Array class.</p>\n\n<pre><code>object[] my...
2008/09/17
[ "https://Stackoverflow.com/questions/87970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16866/" ]
I'd like to populate an arraylist by specifying a list of values just like I would an integer array, but am unsure of how to do so without repeated calls to the "add" method. For example, I want to assign { 1, 2, 3, "string1", "string2" } to an arraylist. I know for other arrays you can make the assignment like: ``` ...
Array list has ctor which accepts ICollection, which is implemented by the Array class. ``` object[] myArray = new object[] {1,2,3,"string1","string2"}; ArrayList myArrayList = new ArrayList(myArray); ```
87,986
<p>In C# you can get the original error and trace the execution path (stack trace) using the inner exception that is passed up. I would like to know how this can be achieved using the error handling try/catch in sql server 2005 when an error occurs in a stored procedure nested 2 or 3 levels deep. </p> <p>I am hoping...
[ { "answer_id": 88941, "author": "Daniel", "author_id": 6852, "author_profile": "https://Stackoverflow.com/users/6852", "pm_score": 0, "selected": false, "text": "<p>One way you could do this would be to create an in memory table and insert rows into it when you catch an exception. You w...
2008/09/17
[ "https://Stackoverflow.com/questions/87986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11989/" ]
In C# you can get the original error and trace the execution path (stack trace) using the inner exception that is passed up. I would like to know how this can be achieved using the error handling try/catch in sql server 2005 when an error occurs in a stored procedure nested 2 or 3 levels deep. I am hoping that functi...
The best way to handle this is using OUTPUT parameters and XML. The sample code below will demonstrate how and you can modify what you do with the XML in the TopProcedure to better handle your response to the error. ``` USE tempdb go CREATE PROCEDURE SubProcedure @RandomNumber int, @XMLErrors XML OUTPUT AS BEGIN BEGIN...
87,999
<p>Well the docs finally said it, I need to take it easy on my wrist for a few months. Being that I'm a .NET Developer this could end my livelihood for a little while, something I'm not anxious to do. That said, are there any good handsfree options for developers? Anyone had success using any of the speech recognition...
[ { "answer_id": 88070, "author": "Tom Ritter", "author_id": 8435, "author_profile": "https://Stackoverflow.com/users/8435", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://www.hanselman.com/blog/SpeechRecognitionInWindowsVistaImListening.aspx\" rel=\"nofollow noreferrer\">S...
2008/09/17
[ "https://Stackoverflow.com/questions/87999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16868/" ]
Well the docs finally said it, I need to take it easy on my wrist for a few months. Being that I'm a .NET Developer this could end my livelihood for a little while, something I'm not anxious to do. That said, are there any good handsfree options for developers? Anyone had success using any of the speech recognition sof...
### It's out there, and it works... There are quite a few speech recognition programs out there, of which [Dragon NaturallySpeaking](http://www.nuance.com/naturallyspeaking/) is, I think, one of the most widely used ones. I've used it myself, and have been impressed with its quality. That being a couple of years ago, ...
88,011
<p>For various reasons, such as cookies, SEO, and to keep things simple, I would like to make apache automatically redirect any requests for <a href="http://www.foobar.com/anything" rel="nofollow noreferrer">http://www.foobar.com/anything</a> to <a href="http://foobar.com/anything" rel="nofollow noreferrer">http://foob...
[ { "answer_id": 88034, "author": "UnkwnTech", "author_id": 115, "author_profile": "https://Stackoverflow.com/users/115", "pm_score": -1, "selected": false, "text": "<pre><code>RewriteEngine On\nRewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]\nRewriteRule ^(.*)$ http://domain.com/$1 [R=301,...
2008/09/17
[ "https://Stackoverflow.com/questions/88011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14569/" ]
For various reasons, such as cookies, SEO, and to keep things simple, I would like to make apache automatically redirect any requests for <http://www.foobar.com/anything> to <http://foobar.com/anything>. The best I could come up with is a mod\_rewrite-based monstrosity, is there some easy simple way to tell it "Redirec...
It's as easy as: ``` <VirtualHost 10.0.0.1:80> ServerName www.example.com Redirect permanent / http://example.com/ </VirtualHost> ``` Adapt host names and IPs as needed :)
88,078
<p>I wand to construct an MSI which, in its installation process, will deploy itself along with its contained Files/Components, to the TargetDir.</p> <p>So MyApp.msi contains MyApp.exe and MyAppBootstrapperEmpty.exe (with no resources) in its File Table.</p> <p>The user launches a MyAppBootstrapperPackaged.exe (conta...
[ { "answer_id": 88366, "author": "EBGreen", "author_id": 1358, "author_profile": "https://Stackoverflow.com/users/1358", "pm_score": 1, "selected": false, "text": "<p>So if I understand, then I think I would have the app create a transform (MST) that has the content files and apply that t...
2008/09/17
[ "https://Stackoverflow.com/questions/88078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8787/" ]
I wand to construct an MSI which, in its installation process, will deploy itself along with its contained Files/Components, to the TargetDir. So MyApp.msi contains MyApp.exe and MyAppBootstrapperEmpty.exe (with no resources) in its File Table. The user launches a MyAppBootstrapperPackaged.exe (containing MyApp.msi a...
Add an uncompressed medium to your wxs like this: ``` <Media Id='2'/> ``` And then create a component with a File element like this: ``` <File Source='/path/to/myinstaller.msi' Compressed='no' DiskId='2' /> ``` This will make the installer look for a file called "myinstaller.msi" on the installation medium, in th...
88,094
<p>I seem to make this mistake every time I set up a new development box. Is there a way to make sure you don't have to manually assign rights for the ASPNET user? I usually install .Net then IIS, then Visual Studio but it seems I still have to manually assign rights to the ASPNET user to get everything running correct...
[ { "answer_id": 88124, "author": "Jonathan Rupp", "author_id": 12502, "author_profile": "https://Stackoverflow.com/users/12502", "pm_score": 3, "selected": true, "text": "<p>Install IIS, then .NET. The .NET installation will automatically register the needed things with IIS.</p>\n\n<p>If...
2008/09/17
[ "https://Stackoverflow.com/questions/88094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16636/" ]
I seem to make this mistake every time I set up a new development box. Is there a way to make sure you don't have to manually assign rights for the ASPNET user? I usually install .Net then IIS, then Visual Studio but it seems I still have to manually assign rights to the ASPNET user to get everything running correctly....
Install IIS, then .NET. The .NET installation will automatically register the needed things with IIS. If you install .NET first, run this: ``` %windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i ``` to run the registration parts, and ``` %windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -...
88,096
<p>I am working on a project with peek performance requirements, so we need to bulk (batch?) several operations (for example persisting the data to a database) for efficiency.</p> <p>However, I want our code to maintain an easy to understand flow, like:</p> <pre><code>input = Read(); parsed = Parse(input); if (parsed...
[ { "answer_id": 88169, "author": "Sklivvz", "author_id": 7028, "author_profile": "https://Stackoverflow.com/users/7028", "pm_score": 0, "selected": false, "text": "<p>I don't know if this is what you need, because it's sqlserver based, but have you tried taking a look to <a href=\"http://...
2008/09/17
[ "https://Stackoverflow.com/questions/88096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
I am working on a project with peek performance requirements, so we need to bulk (batch?) several operations (for example persisting the data to a database) for efficiency. However, I want our code to maintain an easy to understand flow, like: ``` input = Read(); parsed = Parse(input); if (parsed.Count > 10) { sta...
Common problem - instead of calling Persist I usually load up commands (or smt along those lines) into a Persistor class then after the loop is finished I call Persistor.Persist to persist the batch. Just a few pointers - If you're generating sql the commands you add to the persistor can represent your queries someho...
88,235
<p>Recently I ran into this error in my web application:</p> <blockquote> <p>java.lang.OutOfMemoryError: PermGen space</p> </blockquote> <p>It's a typical Hibernate/JPA + IceFaces/JSF application running on Tomcat 6 and JDK 1.6. Apparently this can occur after redeploying an application a few times.</p> <p>What ca...
[ { "answer_id": 88262, "author": "Chris", "author_id": 16907, "author_profile": "https://Stackoverflow.com/users/16907", "pm_score": 10, "selected": true, "text": "<p>The solution was to add these flags to JVM command line when Tomcat is started:</p>\n<pre><code>-XX:+CMSClassUnloadingEnab...
2008/09/17
[ "https://Stackoverflow.com/questions/88235", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16907/" ]
Recently I ran into this error in my web application: > > java.lang.OutOfMemoryError: PermGen space > > > It's a typical Hibernate/JPA + IceFaces/JSF application running on Tomcat 6 and JDK 1.6. Apparently this can occur after redeploying an application a few times. What causes it and what can be done to avoid i...
The solution was to add these flags to JVM command line when Tomcat is started: ``` -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled ``` You can do that by shutting down the tomcat service, then going into the Tomcat/bin directory and running tomcat6w.exe. Under the "Java" tab, add the arguments to the "...
88,269
<p>In certain unknown situations selenium does not detect that a page has loaded when using the open method. I am using the Java API. For example (This code will not produce this error. I don't know of an externally visible page that will.):</p> <pre><code>Selenium browser = new DefaultSelenium("localhost", 4444, "*fi...
[ { "answer_id": 88315, "author": "Jim Deville", "author_id": 1591, "author_profile": "https://Stackoverflow.com/users/1591", "pm_score": 1, "selected": false, "text": "<p>When I do Selenium testing, I wait to see if a certain element is visible (waitForVisible), then I do my action. I usu...
2008/09/17
[ "https://Stackoverflow.com/questions/88269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4356/" ]
In certain unknown situations selenium does not detect that a page has loaded when using the open method. I am using the Java API. For example (This code will not produce this error. I don't know of an externally visible page that will.): ``` Selenium browser = new DefaultSelenium("localhost", 4444, "*firefox", "http:...
I faced this problem quite recently. All JS-based solutions didn't quite fit ICEFaces 2.x + Selenium 2.x/Webdriver combination I have. What I did and what worked for me is the following: In the corner of the screen, there's connection activity indicator. ``` <ice:outputConnectionStatus id="connectStat" ...
88,276
<p>I've been trying to figure this out for about two weeks. I'm able to create email items in people's folders, read the folders, all that stuff but for the life of me I can not get anything to work with the calendars.</p> <p>I can provide examples of the XML I'm sending to WebDav but hoping someone out there has done...
[ { "answer_id": 92523, "author": "Robert Sanders", "author_id": 16952, "author_profile": "https://Stackoverflow.com/users/16952", "pm_score": 2, "selected": false, "text": "<p>I did this in a Java program a few years back, and the way I did it was to PUT a VCALENDAR document into the fold...
2008/09/17
[ "https://Stackoverflow.com/questions/88276", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've been trying to figure this out for about two weeks. I'm able to create email items in people's folders, read the folders, all that stuff but for the life of me I can not get anything to work with the calendars. I can provide examples of the XML I'm sending to WebDav but hoping someone out there has done this and ...
I did this in a Java program a few years back, and the way I did it was to PUT a VCALENDAR document into the folder. One quirk is that the VCALENDAR had to be enclosed within an RFC822 message. It's a bizarre combination of WebDAV, email, and iCAL/VCAL, but it worked at the time on Exchange 2003 hosted at Link2Exchange...
88,306
<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...
[ { "answer_id": 90665, "author": "Avi", "author_id": 9983, "author_profile": "https://Stackoverflow.com/users/9983", "pm_score": 2, "selected": false, "text": "<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 ...
2008/09/17
[ "https://Stackoverflow.com/questions/88306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2766176/" ]
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? I'm trying to avoid using WASession>>...
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: <http://code.google.com/p/seaside/issues/detail?id=48> This is currently slated to be fixed for Seaside 2.9 but I don't know if it will even be backported t...
88,311
<p>I'm currently generating an 8-character pseudo-random uppercase string for "A" .. "Z":</p> <pre><code>value = ""; 8.times{value &lt;&lt; (65 + rand(25)).chr} </code></pre> <p>but it doesn't look clean, and it can't be passed as an argument since it isn't a single statement. To get a mixed-case string "a" .. "z" ...
[ { "answer_id": 88338, "author": "easeout", "author_id": 10906, "author_profile": "https://Stackoverflow.com/users/10906", "pm_score": 0, "selected": false, "text": "<p>To make your first into one statement:</p>\n\n<pre><code>(0...8).collect { |n| value &lt;&lt; (65 + rand(25)).chr }.joi...
2008/09/17
[ "https://Stackoverflow.com/questions/88311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10157/" ]
I'm currently generating an 8-character pseudo-random uppercase string for "A" .. "Z": ``` value = ""; 8.times{value << (65 + rand(25)).chr} ``` but it doesn't look clean, and it can't be passed as an argument since it isn't a single statement. To get a mixed-case string "a" .. "z" plus "A" .. "Z", I changed it to:...
``` (0...8).map { (65 + rand(26)).chr }.join ``` I spend too much time golfing. ``` (0...50).map { ('a'..'z').to_a[rand(26)] }.join ``` And a last one that's even more confusing, but more flexible and wastes fewer cycles: ``` o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten string = (0...50).map { o[rand(o.length...
88,325
<p>I have a class:</p> <pre><code>class MyClass: def __init__(self, foo): if foo != 1: raise Error("foo is not equal to 1!") </code></pre> <p>and a unit test that is supposed to make sure the incorrect arg passed to the constructor properly raises an error:</p> <pre><code>def testInsufficientArgs(self): ...
[ { "answer_id": 88346, "author": "Jerub", "author_id": 14648, "author_profile": "https://Stackoverflow.com/users/14648", "pm_score": 6, "selected": true, "text": "<p>'Error' in this example could be any exception object. I think perhaps you have read a code example that used it as a metas...
2008/09/17
[ "https://Stackoverflow.com/questions/88325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/577/" ]
I have a class: ``` class MyClass: def __init__(self, foo): if foo != 1: raise Error("foo is not equal to 1!") ``` and a unit test that is supposed to make sure the incorrect arg passed to the constructor properly raises an error: ``` def testInsufficientArgs(self): foo = 0 self.assertRaises((Er...
'Error' in this example could be any exception object. I think perhaps you have read a code example that used it as a metasyntatic placeholder to mean, "The Appropriate Exception Class". The baseclass of all exceptions is called 'Exception', and most of its subclasses are descriptive names of the type of error involve...
88,326
<p>Does <a href="http://elmah.github.io/" rel="nofollow noreferrer">ELMAH</a> logged exceptions even when they do not bubble up to the application? I'd like to pop up a message when an exception occurs and still log the exception. Currently I've been putting everything in try catch blocks and spitting out messages, b...
[ { "answer_id": 841426, "author": "Michael La Voie", "author_id": 65843, "author_profile": "https://Stackoverflow.com/users/65843", "pm_score": 7, "selected": false, "text": "<p>ELMAH has been updated to support a new feature called <a href=\"https://code.google.com/p/elmah/wiki/DotNetSla...
2008/09/17
[ "https://Stackoverflow.com/questions/88326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16891/" ]
Does [ELMAH](http://elmah.github.io/) logged exceptions even when they do not bubble up to the application? I'd like to pop up a message when an exception occurs and still log the exception. Currently I've been putting everything in try catch blocks and spitting out messages, but this gets tedious.
ELMAH has been updated to support a new feature called [Signaling](https://code.google.com/p/elmah/wiki/DotNetSlackersArticle#Error_Signaling). This allows you to handle exceptions how you want, while still logging them to ELMAH. ``` try { int i = 5; int j = 0; i = i / j; //Throws exception } catch (Excep...
88,399
<p>I saw <a href="https://stackoverflow.com/questions/73319/duplicate-a-whole-line-in-vim#73357">this same question for VIM</a> and it has been something that I myself wanted to know how to do for Emacs. In ReSharper I use CTRL-D for this action. What is the least number of commands to perform this in Emacs?</p>
[ { "answer_id": 88408, "author": "Arthur Thomas", "author_id": 14009, "author_profile": "https://Stackoverflow.com/users/14009", "pm_score": -1, "selected": false, "text": "<p>well ive usually used:</p>\n\n<pre>Ctl-Space (set the mark)\nmove to end of line\nCtl-K kill line\nCtl-Y * 2 (yan...
2008/09/17
[ "https://Stackoverflow.com/questions/88399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4872/" ]
I saw [this same question for VIM](https://stackoverflow.com/questions/73319/duplicate-a-whole-line-in-vim#73357) and it has been something that I myself wanted to know how to do for Emacs. In ReSharper I use CTRL-D for this action. What is the least number of commands to perform this in Emacs?
I use ``` C-a C-SPACE C-n M-w C-y ``` which breaks down to * `C-a`: move cursor to start of line * `C-SPACE`: begin a selection ("set mark") * `C-n`: move cursor to next line * `M-w`: copy region * `C-y`: paste ("yank") The aforementioned ``` C-a C-k C-k C-y C-y ``` amounts to the same thing (TMTOWTDI) * `C-a...
88,434
<p>I'm trying to build a better username/password field for my workplace and would like to be able to complain when they have their caps lock on.</p> <p>Is this possible? And if so I'd like to have it detected before the client types their first letter.</p> <p>Is there a non-platform specific way to do this?</p>
[ { "answer_id": 88456, "author": "Nick Craver", "author_id": 13249, "author_profile": "https://Stackoverflow.com/users/13249", "pm_score": 6, "selected": true, "text": "<p>Try this, from java.awt.Toolkit, returns a boolean:</p>\n\n<pre><code>Toolkit.getDefaultToolkit().getLockingKeyState(...
2008/09/17
[ "https://Stackoverflow.com/questions/88434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
I'm trying to build a better username/password field for my workplace and would like to be able to complain when they have their caps lock on. Is this possible? And if so I'd like to have it detected before the client types their first letter. Is there a non-platform specific way to do this?
Try this, from java.awt.Toolkit, returns a boolean: ``` Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK) ```
88,454
<p>Most of the MVC samples I have seen pass an instance of the view to the controller like this</p> <pre><code>public class View { Controller controller = new Controller(this); } </code></pre> <p>Is there any advantage to passing a class which provides access to just the the properties and events the controlle...
[ { "answer_id": 90767, "author": "Seldaek", "author_id": 6512, "author_profile": "https://Stackoverflow.com/users/6512", "pm_score": 0, "selected": false, "text": "<p>This is probably not the solution you want, but just to help you with the log parsing, you can use this to get counts for ...
2008/09/17
[ "https://Stackoverflow.com/questions/88454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35031/" ]
Most of the MVC samples I have seen pass an instance of the view to the controller like this ``` public class View { Controller controller = new Controller(this); } ``` Is there any advantage to passing a class which provides access to just the the properties and events the controller is interested in, like th...
My advice is to use the cached framework regardless of your user-base. The fact is, you won't be alone in doing so and it will only be a matter of time before it pays off (even if it is on return visits).
88,460
<p>I'm trying to use libvirt with virsh to manage my kvm/qemu vms. The problem I have is with getting it to work with public IPs. The server is running ubuntu 8.04.</p> <p>libvirt keeps trying to run it as:</p> <pre><code>/usr/bin/kvm -M pc -m 256 -smp 3 -monitor pty -no-acpi \ -drive file=/opt/virtual-machines/c...
[ { "answer_id": 90689, "author": "AgentK", "author_id": 14868, "author_profile": "https://Stackoverflow.com/users/14868", "pm_score": 4, "selected": true, "text": "<p>I followed the bridged networking guide at <a href=\"https://help.ubuntu.com/community/KVM\" rel=\"noreferrer\">https://he...
2008/09/17
[ "https://Stackoverflow.com/questions/88460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11105/" ]
I'm trying to use libvirt with virsh to manage my kvm/qemu vms. The problem I have is with getting it to work with public IPs. The server is running ubuntu 8.04. libvirt keeps trying to run it as: ``` /usr/bin/kvm -M pc -m 256 -smp 3 -monitor pty -no-acpi \ -drive file=/opt/virtual-machines/calculon/root.qcow2,if=...
I followed the bridged networking guide at <https://help.ubuntu.com/community/KVM> and have the following in /etc/network/interfaces: ``` auto eth0 iface eth0 inet manual auto br0 iface br0 inet static address 192.168.0.10 network 192.168.0.0 netmask 255.255.255.0 broadcast 192.168.0.2...
88,473
<p>Does anybody know how to apply a "where in values" type condition using LINQ-to-Entities? I've tried the following but it doesn't work:</p> <pre><code>var values = new[] { "String1", "String2" }; // some string values var foo = model.entitySet.Where(e =&gt; values.Contains(e.Name)); </code></pre> <p>I believe t...
[ { "answer_id": 88486, "author": "Aaron Powell", "author_id": 11388, "author_profile": "https://Stackoverflow.com/users/11388", "pm_score": 0, "selected": false, "text": "<p>Yes it does translate to SQL, it generates a standard IN statement like this:</p>\n\n<pre><code>SELECT [t0].[col1]\...
2008/09/17
[ "https://Stackoverflow.com/questions/88473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16948/" ]
Does anybody know how to apply a "where in values" type condition using LINQ-to-Entities? I've tried the following but it doesn't work: ``` var values = new[] { "String1", "String2" }; // some string values var foo = model.entitySet.Where(e => values.Contains(e.Name)); ``` I believe this works in LINQ-to-SQL thoug...
It is somewhat of a shame that [Contains is not supported in Linq to Entities](http://msdn.microsoft.com/en-us/library/bb738638.aspx). IN and JOIN are not the same operator (Filtering by IN never changes the cardinality of the query).
88,481
<p>I see that Adobe AIR uses WebKit as its render and I see that WebKit (at least the most current build) has some SVG support. Does this mean (and has anyone specifically tried) that an Adobe AIR application could render SVG on an HTML page?</p>
[ { "answer_id": 88513, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Adobe AIR can only support SVG once Adobe updates their version of WebKit (AIR's HTML rendering engine) and enables the SVG ...
2008/09/17
[ "https://Stackoverflow.com/questions/88481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8256/" ]
I see that Adobe AIR uses WebKit as its render and I see that WebKit (at least the most current build) has some SVG support. Does this mean (and has anyone specifically tried) that an Adobe AIR application could render SVG on an HTML page?
On the offchance that it's helpful (and that you don't already know), Flex can embed SVG at ~~runtime~~ compile time, which effectively converts it to SWF format and embeds it as a resource. ``` [Embed(source="assets/frog.svg")] [Bindable] public var SvgAsset:Class; ``` More info at Adobe's [embedding assets article...
88,485
<p>This is a follow up question to <a href="https://stackoverflow.com/questions/85815/how-to-tell-if-a-javascript-function-is-defined">This Question</a>. </p> <p>I like (and understand) the solution there. However, in the code I am working in, another way to solve the same problem is used:</p> <pre><code>function exi...
[ { "answer_id": 88498, "author": "kch", "author_id": 13989, "author_profile": "https://Stackoverflow.com/users/13989", "pm_score": 2, "selected": false, "text": "<p>just use <code>typeof</code>.</p>\n\n<pre><code>typeof(foobar) // -&gt; undefined\ntypeof(alert) // -&gt; function\n</cod...
2008/09/17
[ "https://Stackoverflow.com/questions/88485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2515/" ]
This is a follow up question to [This Question](https://stackoverflow.com/questions/85815/how-to-tell-if-a-javascript-function-is-defined). I like (and understand) the solution there. However, in the code I am working in, another way to solve the same problem is used: ``` function exist(sFN) { if(self[sFN]) retu...
Your condition is checking the existence of the "sFN" property in the "self" object. Anything that isn't null, undefined, 0, and "" will evaluate to true. As others have said, you can use typeof, or instanceof to see if it's actually a function. Looking at your linked example, you should read up on the difference b...
88,518
<p>I'm a complete perl novice, am running a perl script using perl 5.10 and getting this warning: </p> <pre><code>$* is no longer supported at migrate.pl line 380. </code></pre> <p>Can anyone describe what $* did and what the recommended replacement of it is now? Alternatively if you could point me to documentation t...
[ { "answer_id": 88528, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https://Stackoverflow.com/users/4727", "pm_score": 1, "selected": false, "text": "<p>It turns on multi-line mode. Since perl 5.0 (from 1994), the correct way to do that is adding a <em><code>m</code>...
2008/09/17
[ "https://Stackoverflow.com/questions/88518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8479/" ]
I'm a complete perl novice, am running a perl script using perl 5.10 and getting this warning: ``` $* is no longer supported at migrate.pl line 380. ``` Can anyone describe what $\* did and what the recommended replacement of it is now? Alternatively if you could point me to documentation that describes this that w...
From [perlvar](http://perldoc.perl.org/perlvar.html#%24*): > > Use of $\* is deprecated in modern Perl, supplanted by the /s and /m modifiers on pattern matching. > > > If you have access to the place where it's being matched just add it to the end: ``` $haystack =~ m/.../sm; ``` If you only have access to th...
88,522
<p>I wanting to show prices for my products in my online store. I'm currently doing:</p> <pre><code>&lt;span class="ourprice"&gt; &lt;%=GetPrice().ToString("C")%&gt; &lt;/span&gt; </code></pre> <p>Where GetPrice() returns a decimal. So this currently returns a value e.g. "£12.00"</p> <p>I think the correct HTML...
[ { "answer_id": 88535, "author": "Nick Craver", "author_id": 13249, "author_profile": "https://Stackoverflow.com/users/13249", "pm_score": 2, "selected": false, "text": "<p>Try this, it'll use your locale set for the application:</p>\n\n<pre><code>&lt;%=String.Format(\"{0:C}\",GetPrice())...
2008/09/17
[ "https://Stackoverflow.com/questions/88522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11538/" ]
I wanting to show prices for my products in my online store. I'm currently doing: ``` <span class="ourprice"> <%=GetPrice().ToString("C")%> </span> ``` Where GetPrice() returns a decimal. So this currently returns a value e.g. "£12.00" I think the correct HTML for an output of "£12.00" is "`&pound;12.00`", so ...
The £ symbol (U+00A3), and the html entities & #163; and & pound; should all render the same in a browser. If the browser doesn't recognise £, it probably won't recognise the entity versions. It's in ISO 8859-1 (Latin-1), so I'd be surprised if a Mozilla browser can't render it (my FF certainly can). If you see a $ ...
88,546
<p>In Perl, a conditional can be expressed either as</p> <pre><code>if (condition) { do something } </code></pre> <p>or as</p> <pre><code>(condition) and do { do something } </code></pre> <p>Interestingly, the second way seems to be about 10% faster. Does anyone know why?</p>
[ { "answer_id": 88611, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https://Stackoverflow.com/users/4727", "pm_score": 4, "selected": false, "text": "<p>I've deparsed it, and it really shouldn't be faster. The opcode tree for the first is</p>\n\n<pre><code>LISTOP (0x...
2008/09/17
[ "https://Stackoverflow.com/questions/88546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In Perl, a conditional can be expressed either as ``` if (condition) { do something } ``` or as ``` (condition) and do { do something } ``` Interestingly, the second way seems to be about 10% faster. Does anyone know why?
I've deparsed it, and it really shouldn't be faster. The opcode tree for the first is ``` LISTOP (0x8177a18) leave [1] OP (0x8176590) enter COP (0x8177a40) nextstate LISTOP (0x8177b20) scope OP (0x81779b8) null [174] UNOP (0x8177c40) dofile SVOP (0x8177b58) const [1] PV (0...
88,554
<p>In <em>C++</em>, I can have take input like this: </p> <pre><code>cin &gt;&gt; a &gt;&gt; b &gt;&gt; c; </code></pre> <p>And <code>a</code> can be <code>int</code>, <code>b</code> can be <code>float</code>, and <code>c</code> can be whatever... How do I do the same in <em>python</em>?</p> <p><code>input()</code> ...
[ { "answer_id": 88587, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>You generally shouldn't use <code>input()</code> in production code. If you want an <code>int</code> and then a <code>float<...
2008/09/17
[ "https://Stackoverflow.com/questions/88554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10096/" ]
In *C++*, I can have take input like this: ``` cin >> a >> b >> c; ``` And `a` can be `int`, `b` can be `float`, and `c` can be whatever... How do I do the same in *python*? `input()` and `raw_input()`, the way I'm using them, don't seem to be giving me the desired results.
You generally shouldn't use `input()` in production code. If you want an `int` and then a `float`, try this: ``` >>> line = raw_input().split() >>> a = int(line[0]) >>> b = float(line[1]) >>> c = " ".join(line[2:]) ``` It all depends on what exactly you're trying to accomplish, but remember that readability counts. ...
88,558
<p>I am making a game in C++ and am having problems with my derived class. I have a base class called GameScreen which has a vitrual void draw() function with no statements. I also have a derived class called MenuScreen which also has a virtual void draw() function and a derived class from MenuScreen called TestMenu ...
[ { "answer_id": 88620, "author": "Curt Hagenlocher", "author_id": 533, "author_profile": "https://Stackoverflow.com/users/533", "pm_score": 3, "selected": false, "text": "<p>If gsScreens is a list of objects instead of a list of pointers (as your code suggests), then you're not storing wh...
2008/09/17
[ "https://Stackoverflow.com/questions/88558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am making a game in C++ and am having problems with my derived class. I have a base class called GameScreen which has a vitrual void draw() function with no statements. I also have a derived class called MenuScreen which also has a virtual void draw() function and a derived class from MenuScreen called TestMenu which...
If gsScreens is a list of objects instead of a list of pointers (as your code suggests), then you're not storing what you think you're storing in it. What's happening is that -- instead of putting a TestMenu into the list, you're actually constructing a new MenuScreen using the compiler-generated copy constructor and ...
88,570
<p>Does anyone know if it's possible to use regex capture within Apache's DirectoryMatch directive? I'd like to do something like the following:</p> <pre><code>&lt;DirectoryMatch ^/home/www/(.*)&gt; AuthType Basic AuthName $1 AuthUserFile /etc/apache2/svn.passwd Require group $1 admin &lt;/DirectoryMat...
[ { "answer_id": 88704, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>What you are trying to do looks very similar to <a href=\"http://httpd.apache.org/docs/2.0/howto/public_html.html\" rel=\"no...
2008/09/17
[ "https://Stackoverflow.com/questions/88570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16960/" ]
Does anyone know if it's possible to use regex capture within Apache's DirectoryMatch directive? I'd like to do something like the following: ``` <DirectoryMatch ^/home/www/(.*)> AuthType Basic AuthName $1 AuthUserFile /etc/apache2/svn.passwd Require group $1 admin </DirectoryMatch> ``` but so far I'...
You could tackle the problem from a completely different angle: enable the perl module and you can include a little perl script in your httpd.conf. You could then do something like this: ``` <Perl> my @groups = qw/ foo bar baz /; foreach ( @groups ) { push @PerlConfig, qq| <Directory /home/www/$_> blah </Directory...
88,573
<p>In C++, you can specify that a function may or may not throw an exception by using an exception specifier. For example:</p> <pre><code>void foo() throw(); // guaranteed not to throw an exception void bar() throw(int); // may throw an exception of type int void baz() throw(...); // may throw an exception of some uns...
[ { "answer_id": 88591, "author": "Kris Kumler", "author_id": 4281, "author_profile": "https://Stackoverflow.com/users/4281", "pm_score": 2, "selected": false, "text": "<p>Generally I would not use exception specifiers. However, in cases where if any other exception were to come from the ...
2008/09/17
[ "https://Stackoverflow.com/questions/88573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3146/" ]
In C++, you can specify that a function may or may not throw an exception by using an exception specifier. For example: ``` void foo() throw(); // guaranteed not to throw an exception void bar() throw(int); // may throw an exception of type int void baz() throw(...); // may throw an exception of some unspecified type ...
No. Here are several examples why: 1. Template code is impossible to write with exception specifications, ``` template<class T> void f( T k ) { T x( k ); x.x(); } ``` The copies might throw, the parameter passing might throw, and `x()` might throw some unknown exception. 2. Exception-specifications tend ...
88,613
<p>How do I tokenize the string:</p> <pre><code>&quot;2+24*48/32&quot; </code></pre> <p>Into a list:</p> <pre><code>['2', '+', '24', '*', '48', '/', '32'] </code></pre>
[ { "answer_id": 88639, "author": "Cristian", "author_id": 680, "author_profile": "https://Stackoverflow.com/users/680", "pm_score": 2, "selected": false, "text": "<p>Regular expressions:</p>\n\n<pre><code>&gt;&gt;&gt; import re\n&gt;&gt;&gt; splitter = re.compile(r'([+*/])')\n&gt;&gt;&gt;...
2008/09/17
[ "https://Stackoverflow.com/questions/88613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do I tokenize the string: ``` "2+24*48/32" ``` Into a list: ``` ['2', '+', '24', '*', '48', '/', '32'] ```
It just so happens that the tokens you want split are already Python tokens, so you can use the built-in `tokenize` module. It's almost a one-liner; this program: ```py from io import StringIO from tokenize import generate_tokens STRING = 1 print( list( token[STRING] for token in generate_tokens(Strin...
88,651
<p>Is it possible to get notifications using <a href="http://www.microsoft.com/sql/technologies/reporting/default.mspx" rel="nofollow noreferrer">SQL Server Reporting Services</a>? Say for example I have a report that I want by mail if has for example suddenly shows more than 10 rows or if a specific value drop below 1...
[ { "answer_id": 90762, "author": "Simon Munro", "author_id": 3893, "author_profile": "https://Stackoverflow.com/users/3893", "pm_score": 0, "selected": false, "text": "<p>I wouldn't go down the ntofications services route - it is pretty much a deprecated feature of SQL Server and even if ...
2008/09/17
[ "https://Stackoverflow.com/questions/88651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/298/" ]
Is it possible to get notifications using [SQL Server Reporting Services](http://www.microsoft.com/sql/technologies/reporting/default.mspx)? Say for example I have a report that I want by mail if has for example suddenly shows more than 10 rows or if a specific value drop below 100 000. Do I need to tie Notification Se...
I'd agree with Simon re Notification Services Also, data driven SSRS Subscriptions are not available unless you use Enterprise Edition (and isn't available if you use SharePoint Integrated Mode). An alternate way would be to create an Agent job that runs a proc. The proc could check the conditions you require and kic...
88,682
<p>What's the best way to serialize a HashTable (or a data best navigated through a string indexer) with SOAP/XML?</p> <p>Let's say I have a <code>Foo</code> that has an property <code>Bar[] Bars</code>. A <code>Bar</code> object has a key and a value. By default, this serializes to the following XML:</p> <pre><code>...
[ { "answer_id": 88707, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>ISerializable isn't used for xml serialization; its used for binary serialization. You would be better implementing IXmlSer...
2008/09/17
[ "https://Stackoverflow.com/questions/88682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7242/" ]
What's the best way to serialize a HashTable (or a data best navigated through a string indexer) with SOAP/XML? Let's say I have a `Foo` that has an property `Bar[] Bars`. A `Bar` object has a key and a value. By default, this serializes to the following XML: ``` <Foo> <Bars> <Bar key="key0" value="value0"/> ...
I really don't think that what you want reflects the structure better. To define a schema (think XSD) for this you would have to know all of the potential keys in advance since you indicate that you want each one to be a separate custom type. Conceptually Bars would be an array of objects holding objects of type Key0, ...
88,710
<p>I need to create a repeatable process for deploying SQL Server Reporting Services reports. I am not in favor of using Visual Studio and or Business Development Studio to do this. The rs.exe method of scripting deployments also seems rather clunky. Does anyone have a very elegant way that they have been able to de...
[ { "answer_id": 88722, "author": "cori", "author_id": 8151, "author_profile": "https://Stackoverflow.com/users/8151", "pm_score": 0, "selected": false, "text": "<p>I know you say that you're not in favor of the Business Development Studio to do this, but I've found the built-in tools to b...
2008/09/17
[ "https://Stackoverflow.com/questions/88710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16980/" ]
I need to create a repeatable process for deploying SQL Server Reporting Services reports. I am not in favor of using Visual Studio and or Business Development Studio to do this. The rs.exe method of scripting deployments also seems rather clunky. Does anyone have a very elegant way that they have been able to deploy r...
We use rs.exe, once we developed the script we have not needed to touch it anymore, it just works. Here is the source (I slightly modified it by hand to remove sensitive data without a chance to test it, hope I did not brake anything), it deploys reports and associated images from subdirectories for various languages....
88,717
<p>I want to load one or more DLLs dynamically so that they run with a different security or basepath than my main application. How do I load these DLLs into a separate AppDomain and instantiate objects from them?</p>
[ { "answer_id": 88758, "author": "Andy", "author_id": 3857, "author_profile": "https://Stackoverflow.com/users/3857", "pm_score": 2, "selected": false, "text": "<p>You can use the <a href=\"http://msdn.microsoft.com/en-us/library/44s54yc4.aspx\" rel=\"nofollow noreferrer\">AppDomain.Creat...
2008/09/17
[ "https://Stackoverflow.com/questions/88717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16979/" ]
I want to load one or more DLLs dynamically so that they run with a different security or basepath than my main application. How do I load these DLLs into a separate AppDomain and instantiate objects from them?
More specifically ``` AppDomain domain = AppDomain.CreateDomain("New domain name"); //Do other things to the domain like set the security policy string pathToDll = @"C:\myDll.dll"; //Full path to dll you want to load Type t = typeof(TypeIWantToLoad); TypeIWantToLoad myObject = (TypeIWantToLoad)domain.CreateInstanceFr...
88,743
<p>I'm using jmockit for unit testing (with TestNG), and I'm having trouble using the Expectations class to mock out a method that takes a primitive type (boolean) as a parameter, using a matcher. Here's some sample code that illustrates the problem.</p> <pre><code>/***************************************************...
[ { "answer_id": 89215, "author": "DJ.", "author_id": 10638, "author_profile": "https://Stackoverflow.com/users/10638", "pm_score": 1, "selected": false, "text": "<p>the issue is the combination of Expectation usage and that Matchers does not support primitive type.</p>\n\n<p>The Matchers ...
2008/09/17
[ "https://Stackoverflow.com/questions/88743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16977/" ]
I'm using jmockit for unit testing (with TestNG), and I'm having trouble using the Expectations class to mock out a method that takes a primitive type (boolean) as a parameter, using a matcher. Here's some sample code that illustrates the problem. ``` /******************************************************/ import sta...
So the problem appears to be in Expectations.with(): ``` protected final <T> T with(Matcher<T> argumentMatcher) { argMatchers.add(argumentMatcher); TypeVariable<?> typeVariable = argumentMatcher.getClass().getTypeParameters()[0]; return (T) Utilities.defaultValueForType(typeVariable.getClass(...
88,773
<p>There must be a generic way to transform some hierachical XML such as:</p> <pre><code>&lt;element1 A="AValue" B="BValue"&gt; &lt;element2 C="DValue" D="CValue"&gt; &lt;element3 E="EValue1" F="FValue1"/&gt; &lt;element3 E="EValue2" F="FValue2"/&gt; &lt;/element2&gt; ... &lt;/element1&gt; </code>...
[ { "answer_id": 88867, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>We already have a Pro*C program reading from an Oracle database, it calls a perl script which in turn executes some Java to ...
2008/09/17
[ "https://Stackoverflow.com/questions/88773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
There must be a generic way to transform some hierachical XML such as: ``` <element1 A="AValue" B="BValue"> <element2 C="DValue" D="CValue"> <element3 E="EValue1" F="FValue1"/> <element3 E="EValue2" F="FValue2"/> </element2> ... </element1> ``` into the flattened XML (html) picking up selected a...
I'm not 100% sure of what you are trying to do but this solution may work if your element1, element2 and element3 are nested consistently. ``` <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"> <xsl:output...
88,775
<p>I work at a college and have been developing an ASP.NET site with many, many reports about students, attendance stats... The basis for the data is an MSSQL server DB which is the back end to our student management system. This has a regular maintenance period on Thursday mornings for an unknown length of time (depen...
[ { "answer_id": 88782, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": false, "text": "<p>Drop an html file called \"app_offline.htm\" into the root of your virtual directory. Simple as that.</p>\n\n<p><a href=\"h...
2008/09/17
[ "https://Stackoverflow.com/questions/88775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16989/" ]
I work at a college and have been developing an ASP.NET site with many, many reports about students, attendance stats... The basis for the data is an MSSQL server DB which is the back end to our student management system. This has a regular maintenance period on Thursday mornings for an unknown length of time (dependen...
I would suggest doing it in Application\_PreRequestHandlerExecute instead of after an error occurs. Generally, it'd be best not to enter normal processing if you know your database isn't available. I typically use something like below ``` void Application_PreRequestHandlerExecute(Object sender, EventArgs e) { string ...
88,791
<p>I was wondering what people thought of using properties as object initializers in C#. For some reason it seems to break the fundamentals of what constructors are used for.</p> <p>An example...</p> <pre><code>public class Person { string firstName; string lastName; public string FirstName { g...
[ { "answer_id": 88802, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>IMHO its sweet. Most objects are newed up with the default constructor, and must have some properties set before they are r...
2008/09/17
[ "https://Stackoverflow.com/questions/88791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/342514/" ]
I was wondering what people thought of using properties as object initializers in C#. For some reason it seems to break the fundamentals of what constructors are used for. An example... ``` public class Person { string firstName; string lastName; public string FirstName { get { return firstName...
What you see here is some syntatic sugar provided by the compiler. Under the hood what it really does is something like: **Person p = new Person( FirstName = "Joe", LastName = "Smith" );** ``` Person _p$1 = new Person(); _p$1.FirstName = "Joe"; _p$1.LastName = "Smith"; Person p = _p$1; ``` So IMHO you are not reall...
88,831
<p>Anyone has ever programmed a PHP (or Perl) function to get the ceiling value Excel style?</p>
[ { "answer_id": 88837, "author": "Paolo Bergantino", "author_id": 16417, "author_profile": "https://Stackoverflow.com/users/16417", "pm_score": 2, "selected": false, "text": "<p>Sorry, not quite clear what 'Excel style' is, but PHP has a <a href=\"http://us3.php.net/ceil\" rel=\"nofollow ...
2008/09/18
[ "https://Stackoverflow.com/questions/88831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Anyone has ever programmed a PHP (or Perl) function to get the ceiling value Excel style?
*"Microsoft Excel's ceiling function does not follow the mathematical definition, but rather as with (int) operator in C, it is a mixture of the floor and ceiling function: for x ≥ 0 it returns ceiling(x), and for x < 0 it returns floor(x). This has followed through to the Office Open XML file format. For example, CEIL...
88,838
<p>In Java, I have a String and I want to encode it as a byte array (in UTF8, or some other encoding). Alternately, I have a byte array (in some known encoding) and I want to convert it into a Java String. How do I do these conversions?</p>
[ { "answer_id": 88847, "author": "Jorge Ferreira", "author_id": 6508, "author_profile": "https://Stackoverflow.com/users/6508", "pm_score": 4, "selected": false, "text": "<pre><code>String original = \"hello world\";\nbyte[] utf8Bytes = original.getBytes(\"UTF-8\");\n</code></pre>\n" },...
2008/09/18
[ "https://Stackoverflow.com/questions/88838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14570/" ]
In Java, I have a String and I want to encode it as a byte array (in UTF8, or some other encoding). Alternately, I have a byte array (in some known encoding) and I want to convert it into a Java String. How do I do these conversions?
Convert from `String` to `byte[]`: ``` String s = "some text here"; byte[] b = s.getBytes(StandardCharsets.UTF_8); ``` Convert from `byte[]` to `String`: ``` byte[] b = {(byte) 99, (byte)97, (byte)116}; String s = new String(b, StandardCharsets.US_ASCII); ``` You should, of course, use the correct encoding name. ...
88,918
<p>This is my first experience using the Zend Framework. I am attempting to follow the <a href="http://framework.zend.com/docs/quickstart/introduction" rel="nofollow noreferrer">Quick Start</a> tutorial. Everything was working as expected until I reached the section on the <a href="http://framework.zend.com/docs/quicks...
[ { "answer_id": 89347, "author": "dragonmantank", "author_id": 204, "author_profile": "https://Stackoverflow.com/users/204", "pm_score": 2, "selected": false, "text": "<p>Assuming that you have the ErrorController plugin loaded into your front controller, make sure that in your bootstrap ...
2008/09/18
[ "https://Stackoverflow.com/questions/88918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3210/" ]
This is my first experience using the Zend Framework. I am attempting to follow the [Quick Start](http://framework.zend.com/docs/quickstart/introduction) tutorial. Everything was working as expected until I reached the section on the [Error Controller and View](http://framework.zend.com/docs/quickstart/create-an-error-...
You have ErrorHandler.php. It should be ErrorController.php. Controllers all need to be named following the format of NameController.php. Since you don't have it named properly the dispatcher cannot find it.
88,929
<p>Is there a command that would allow me to check if the string <code>"xyz"</code> was ever in file <code>foo.c</code> in the repository and print which revisions they were found in? </p>
[ { "answer_id": 89008, "author": "CaptainPicard", "author_id": 15203, "author_profile": "https://Stackoverflow.com/users/15203", "pm_score": 6, "selected": true, "text": "<p>This will print any commits where the diff contains xyz</p>\n\n<pre><code>git log -Sxyz foo.c\n</code></pre>\n" }...
2008/09/18
[ "https://Stackoverflow.com/questions/88929", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4883/" ]
Is there a command that would allow me to check if the string `"xyz"` was ever in file `foo.c` in the repository and print which revisions they were found in?
This will print any commits where the diff contains xyz ``` git log -Sxyz foo.c ```
88,931
<p>When defining or calling functions with enough arguments to span multiple lines, I want vim to line them up. For example,</p> <pre><code>def myfunction(arg1, arg2, arg, ... argsN-1, argN) </code></pre> <p>The idea is for argsN-1 to have its 'a' lined up with args1.</p> <p>Does anyone have a way to ...
[ { "answer_id": 89119, "author": "solinent", "author_id": 13852, "author_profile": "https://Stackoverflow.com/users/13852", "pm_score": 3, "selected": false, "text": "<p>I believe you have to issue the command:</p>\n\n<pre><code>:set cino=(0\n</code></pre>\n\n<p>This is when using cindent...
2008/09/18
[ "https://Stackoverflow.com/questions/88931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7706/" ]
When defining or calling functions with enough arguments to span multiple lines, I want vim to line them up. For example, ``` def myfunction(arg1, arg2, arg, ... argsN-1, argN) ``` The idea is for argsN-1 to have its 'a' lined up with args1. Does anyone have a way to have this happen automatically in...
The previous poster had it, but forgot the `set` ``` :set cino=(0<Enter> ``` From `:help cinoptions-values` ``` The 'cinoptions' option sets how Vim performs indentation. In the list below, "N" represents a number of your choice (the number can be negative). When there is an 's' after the number, Vim multiplies t...
88,957
<p>When <code>{0}</code> is used to initialize an object, what does it mean? I can't find any references to <code>{0}</code> anywhere, and because of the curly braces Google searches are not helpful.</p> <p>Example code:</p> <pre><code>SHELLEXECUTEINFO sexi = {0}; // what does this do? sexi.cbSize = sizeof(SHELLEXECU...
[ { "answer_id": 88960, "author": "Don Neufeld", "author_id": 13097, "author_profile": "https://Stackoverflow.com/users/13097", "pm_score": 9, "selected": true, "text": "<p>What's happening here is called <strong>aggregate</strong> initialization. Here is the (abbreviated) definition of a...
2008/09/18
[ "https://Stackoverflow.com/questions/88957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17027/" ]
When `{0}` is used to initialize an object, what does it mean? I can't find any references to `{0}` anywhere, and because of the curly braces Google searches are not helpful. Example code: ``` SHELLEXECUTEINFO sexi = {0}; // what does this do? sexi.cbSize = sizeof(SHELLEXECUTEINFO); sexi.hwnd = NULL; sexi.fMask = SEE...
What's happening here is called **aggregate** initialization. Here is the (abbreviated) definition of an aggregate from section 8.5.1 of the ISO spec: > > An aggregate is an array or a class with no user-declared constructors, no private or protected non-static data members, no base classes, and no virtual functions....
88,991
<p>I do not mean the compile errors because I made a syntax mistake or whatever. In C++ we can create compile time errors based on conditions as in the following example:</p> <pre><code>template&lt;int&gt; struct CompileTimeError; template&lt;&gt; struct CompileTimeError&lt;true&gt; {}; #define STATIC_CHECK(expr, msg...
[ { "answer_id": 89017, "author": "Daniel Spiewak", "author_id": 9815, "author_profile": "https://Stackoverflow.com/users/9815", "pm_score": 2, "selected": false, "text": "<p>There is no way to produce any actions based on compile-time logic in Java without the use of a separate tool. Tec...
2008/09/18
[ "https://Stackoverflow.com/questions/88991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6508/" ]
I do not mean the compile errors because I made a syntax mistake or whatever. In C++ we can create compile time errors based on conditions as in the following example: ``` template<int> struct CompileTimeError; template<> struct CompileTimeError<true> {}; #define STATIC_CHECK(expr, msg) { CompileTimeError<((expr) != ...
There is no way to do this in Java, not in the same way it works for you in C++. You could perhaps use annotations, and run [apt](http://java.sun.com/j2se/1.5.0/docs/guide/apt/GettingStarted.html) before or after compilation to check your annotations. For example: ``` @MyStaticCheck(false, "Compile Time Error, kind-...
89,051
<p>What I'd like to know is if there is a nice way to queue jQuery functions to execute after a set amount of time. This wouldn't pause the execution of other functions, just the ones following in the chain. Perhaps an example of what I'd envisage it would look like would illustrate:</p> <pre><code>$('#alert') .sh...
[ { "answer_id": 89076, "author": "Prestaul", "author_id": 5628, "author_profile": "https://Stackoverflow.com/users/5628", "pm_score": 4, "selected": true, "text": "<p>You can't do that, and you probably don't want to. While it certainly looks pretty, there is no mechanism in Javascript t...
2008/09/18
[ "https://Stackoverflow.com/questions/89051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
What I'd like to know is if there is a nice way to queue jQuery functions to execute after a set amount of time. This wouldn't pause the execution of other functions, just the ones following in the chain. Perhaps an example of what I'd envisage it would look like would illustrate: ``` $('#alert') .show() .wait...
You can't do that, and you probably don't want to. While it certainly looks pretty, there is no mechanism in Javascript that will allow you do to that without just looping in "wait" until the time has passed. You could certainly do that but you risk seriously degrading the browser performance and if your timeout is lon...
89,118
<p>I am getting an 403 access forbidden when attempting to open a page under a vhost where the document root is sitting on a different drive than where apache is sitting. I installed using the apachefriends release. This is my httpd-vhosts.conf file: </p> <p><pre><code> NameVirtualHost 127.0.0.1</p> <p>&lt;VirtualHos...
[ { "answer_id": 91885, "author": "Mark Embling", "author_id": 6844, "author_profile": "https://Stackoverflow.com/users/6844", "pm_score": 6, "selected": false, "text": "<p>Somewhere, you need to tell Apache that people are allowed to see contents of this directory.</p>\n\n<pre><code>&lt;D...
2008/09/18
[ "https://Stackoverflow.com/questions/89118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6752/" ]
I am getting an 403 access forbidden when attempting to open a page under a vhost where the document root is sitting on a different drive than where apache is sitting. I installed using the apachefriends release. This is my httpd-vhosts.conf file: ``` NameVirtualHost 127.0.0.1 ``` <VirtualHost 127.0.0.1> ServerNam...
You did not need ``` Options Indexes FollowSymLinks MultiViews Includes ExecCGI AllowOverride All Order Allow,Deny Allow from all Require all granted ``` the only thing what you need is... ``` Require all granted ``` ...inside the directory section. See Apache 2.4 upgrading side: <http://httpd.apache.org/docs/2...
89,154
<pre><code>boolean a = false, b = true; if ( a &amp;&amp; b ) { ... }; </code></pre> <p>In most languages, <code>b</code> will not get evaluated because <code>a</code> is false so <code>a &amp;&amp; b</code> cannot be true. My question is, wouldn't short circuiting be slower in terms of architecture? In a pipeline, do...
[ { "answer_id": 89170, "author": "user10392", "author_id": 10392, "author_profile": "https://Stackoverflow.com/users/10392", "pm_score": 1, "selected": false, "text": "<p>How can a nested if not stall? Actually if a and b are both variables and not expressions with side effects, they can...
2008/09/18
[ "https://Stackoverflow.com/questions/89154", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12682/" ]
``` boolean a = false, b = true; if ( a && b ) { ... }; ``` In most languages, `b` will not get evaluated because `a` is false so `a && b` cannot be true. My question is, wouldn't short circuiting be slower in terms of architecture? In a pipeline, do you just stall while waiting to get the result of a to determine if...
Short-circuiting boolean expressions are exactly equivalent to some set of nested ifs, so are as efficient as that would be. If b doesn't have side-effects, it can still be executed in parallel with a (for any value of "in parallel", including pipelining). If b has side effects which the CPU architecture can't cancel...
89,178
<p>For example:</p> <pre><code>&gt;&gt;&gt; x = [1, 1, 2, 'a', 'a', 3] &gt;&gt;&gt; unique(x) [1, 2, 'a', 3] </code></pre> <p>Assume list elements are hashable.</p> <p><strong>Clarification:</strong> The result should keep the first duplicate in the list. For example, [1, 2, 3, 2, 3, 1] becomes [1, 2, 3].</p>
[ { "answer_id": 89197, "author": "solinent", "author_id": 13852, "author_profile": "https://Stackoverflow.com/users/13852", "pm_score": 0, "selected": false, "text": "<p>I have no experience with python, but an algorithm would be to sort the list, then remove duplicates (by comparing to p...
2008/09/18
[ "https://Stackoverflow.com/questions/89178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16976/" ]
For example: ``` >>> x = [1, 1, 2, 'a', 'a', 3] >>> unique(x) [1, 2, 'a', 3] ``` Assume list elements are hashable. **Clarification:** The result should keep the first duplicate in the list. For example, [1, 2, 3, 2, 3, 1] becomes [1, 2, 3].
``` def unique(items): found = set() keep = [] for item in items: if item not in found: found.add(item) keep.append(item) return keep print unique([1, 1, 2, 'a', 'a', 3]) ```
89,188
<p>Is it possible to get the x,y coordinates of a Flex app within an HTML page? I know you can use ExternalInterface.ObjecID to get the "id attribute of the object tag in Internet Explorer, or the name attribute of the embed tag in Netscape" but I can't seem to get past that step. It seems like it should be possible ...
[ { "answer_id": 89286, "author": "Robert", "author_id": 4959, "author_profile": "https://Stackoverflow.com/users/4959", "pm_score": 0, "selected": false, "text": "<p>If you are trying just to measure where it's at within a page as the external user the only thing that pops into my mind is...
2008/09/18
[ "https://Stackoverflow.com/questions/89188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15899/" ]
Is it possible to get the x,y coordinates of a Flex app within an HTML page? I know you can use ExternalInterface.ObjecID to get the "id attribute of the object tag in Internet Explorer, or the name attribute of the embed tag in Netscape" but I can't seem to get past that step. It seems like it should be possible to ge...
I think the easiest thing to do is to include some kind of JavaScript library on the HTML page, say jQuery, and use it's functions for determining the position and size of DOM nodes. I would do it more or less like this: ``` var jsCode : String = "function( id ) { return $('#' + id).offset(); }"; var offset : Object ...
89,193
<p>Speaking as a non-C# savvy programmer, I'm curious as to the evaluation semantics of LINQ queries like the following:</p> <pre><code>var people = from p in Person where p.age &lt; 18 select p var otherPeople = from p in people where p.firstName equals "Daniel" ...
[ { "answer_id": 89211, "author": "David Thibault", "author_id": 5903, "author_profile": "https://Stackoverflow.com/users/5903", "pm_score": 1, "selected": false, "text": "<p><code>people</code> and <code>otherPeople</code> contain objects of type <code>IQueryable&lt;Person></code>.</p>\n\...
2008/09/18
[ "https://Stackoverflow.com/questions/89193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9815/" ]
Speaking as a non-C# savvy programmer, I'm curious as to the evaluation semantics of LINQ queries like the following: ``` var people = from p in Person where p.age < 18 select p var otherPeople = from p in people where p.firstName equals "Daniel" select p ...
They are composable. This is possible because LINQ queries are actually expressions (code as data), which LINQ providers like LINQ-to-SQL can evaluate and generate corresponding SQL. Because LINQ queries are lazily evaluated (e.g. won't get executed until you iterate over the elements), the code you showed won't actua...
89,228
<p>How do I call an external command within Python as if I'd typed it in a shell or command prompt?</p>
[ { "answer_id": 89237, "author": "nimish", "author_id": 3926, "author_profile": "https://Stackoverflow.com/users/3926", "pm_score": 8, "selected": false, "text": "<pre><code>import os\nos.system(\"your command\")\n</code></pre>\n\n<p>Note that this is dangerous, since the command isn't cl...
2008/09/18
[ "https://Stackoverflow.com/questions/89228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17085/" ]
How do I call an external command within Python as if I'd typed it in a shell or command prompt?
Use the [`subprocess`](https://docs.python.org/library/subprocess.html) module in the standard library: ```py import subprocess subprocess.run(["ls", "-l"]) ``` The advantage of [`subprocess.run`](https://docs.python.org/library/subprocess.html#subprocess.run) over [`os.system`](https://docs.python.org/library/os.ht...
89,245
<p>Suppose a large composite application built on several foundation components packaged in their own assemblies: (database reading, protocol handlers, etc.). For some deployments, this can include over 20 assemblies. Each of these assemblies has settings or configuration information. Our team tends to like the VS ...
[ { "answer_id": 89261, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 5, "selected": true, "text": "<p>You use one master config file that points to other config files. <a href=\"http://blog.andreloker.de/post/2008/06/Keep-your...
2008/09/18
[ "https://Stackoverflow.com/questions/89245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6996/" ]
Suppose a large composite application built on several foundation components packaged in their own assemblies: (database reading, protocol handlers, etc.). For some deployments, this can include over 20 assemblies. Each of these assemblies has settings or configuration information. Our team tends to like the VS setting...
You use one master config file that points to other config files. [Here's an example of how to do this.](http://blog.andreloker.de/post/2008/06/Keep-your-config-clean-with-external-config-files.aspx) --- In case the link rots, what you do is specify the [configSource](http://msdn.microsoft.com/en-us/library/system.co...
89,246
<p>I’m trying to run this SQL using get external.</p> <p>It works, but when I try to rename the sub-queries or anything for that matter it remove it.</p> <p>I tried <code>as</code>, <code>as</code> and the name in <code>''</code>, <code>as</code> then the name in <code>""</code>, and the same with space. What is the...
[ { "answer_id": 89314, "author": "jttraino", "author_id": 3203, "author_profile": "https://Stackoverflow.com/users/3203", "pm_score": 1, "selected": false, "text": "<p>You could get rid of your <code>dbo.d_agent_define</code> subquery and just add in a join to the agent define table.</p>\...
2008/09/18
[ "https://Stackoverflow.com/questions/89246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13122/" ]
I’m trying to run this SQL using get external. It works, but when I try to rename the sub-queries or anything for that matter it remove it. I tried `as`, `as` and the name in `''`, `as` then the name in `""`, and the same with space. What is the right way to do that? Relevant SQL: ``` SELECT list_name, app_name, ...
You could get rid of your `dbo.d_agent_define` subquery and just add in a join to the agent define table. Would this code work? ``` select list_name, app_name, map.fname + ' ' + map.lname as agent_login, input, convert(varchar,dateadd(ss,TAC_BEG_tstamp,'01/01/1970')) as tac_seconds from dbo.maps_report_list list ...
89,257
<p>I've run into what appears to be a variable scope issue I haven't encountered before. I'm using Perl's CGI module and a call to DBI's do() method. Here's the code structure, simplified a bit:</p> <pre><code>use DBI; use CGI qw(:cgi-lib); &amp;ReadParse; my $dbh = DBI-&gt;connect(...............); my $test = $in{tes...
[ { "answer_id": 89282, "author": "Alex M", "author_id": 9652, "author_profile": "https://Stackoverflow.com/users/9652", "pm_score": 2, "selected": false, "text": "<p><code>use strict;</code>. Always.</p>\n\n<p>Try declaring</p>\n\n<pre><code>our %in;\n</code></pre>\n\n<p>and seeing if tha...
2008/09/18
[ "https://Stackoverflow.com/questions/89257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17092/" ]
I've run into what appears to be a variable scope issue I haven't encountered before. I'm using Perl's CGI module and a call to DBI's do() method. Here's the code structure, simplified a bit: ``` use DBI; use CGI qw(:cgi-lib); &ReadParse; my $dbh = DBI->connect(...............); my $test = $in{test}; $dbh->do(qq{INSER...
Per the DBI documentation: Binding a tied variable doesn't work, currently. DBI is pretty complicated under the hood, and unfortunately goes through some gyrations to be efficient that are causing your problem. I agree with everyone else who says to get rid of the ugly old cgi-lib style code. It's unpleasant enough to...
89,285
<p>I've been trimming the UI of our website by doing the following in the onload event of that control:</p> <pre><code>btnDelete.isVisible = user.IsInRole("can delete"); </code></pre> <p>This has become very tedious because there are so many controls to check again and again. As soon as I get it all working, designe...
[ { "answer_id": 89295, "author": "Christian Hagelid", "author_id": 202, "author_profile": "https://Stackoverflow.com/users/202", "pm_score": 2, "selected": false, "text": "<p>One simple suggestion would be to group controls into panels based on access rights</p>\n" }, { "answer_id...
2008/09/18
[ "https://Stackoverflow.com/questions/89285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14396/" ]
I've been trimming the UI of our website by doing the following in the onload event of that control: ``` btnDelete.isVisible = user.IsInRole("can delete"); ``` This has become very tedious because there are so many controls to check again and again. As soon as I get it all working, designers request to change the UI...
One simple suggestion would be to group controls into panels based on access rights
89,332
<p>I frequently use <code>git stash</code> and <code>git stash pop</code> to save and restore changes in my working tree. Yesterday, I had some changes in my working tree that I had stashed and popped, and then I made more changes to my working tree. I'd like to go back and review yesterday's stashed changes, but <code...
[ { "answer_id": 89388, "author": "Nathan Jones", "author_id": 5848, "author_profile": "https://Stackoverflow.com/users/5848", "pm_score": 6, "selected": false, "text": "<p><code>git fsck --unreachable | grep commit</code> should show the sha1, although the list it returns might be quite l...
2008/09/18
[ "https://Stackoverflow.com/questions/89332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/893/" ]
I frequently use `git stash` and `git stash pop` to save and restore changes in my working tree. Yesterday, I had some changes in my working tree that I had stashed and popped, and then I made more changes to my working tree. I'd like to go back and review yesterday's stashed changes, but `git stash pop` appears to rem...
Once you know the hash of the stash commit you dropped, you can apply it as a stash: ```bash git stash apply $stash_hash ``` Or, you can create a separate branch for it with ```bash git branch recovered $stash_hash ``` After that, you can do whatever you want with all the normal tools. When you’re done, just blow...
89,418
<p>Assume I have an "images" folder directory under the root of my application. How can I, from within a .css file, reference an image in this directory using an ASP.NET app relative path. </p> <p>Example:</p> <p>When in development, the path of <strong>~/Images/Test.gif</strong> might resolve to <strong>/MyApp/Ima...
[ { "answer_id": 89431, "author": "Allain Lalonde", "author_id": 2443, "author_profile": "https://Stackoverflow.com/users/2443", "pm_score": 3, "selected": false, "text": "<p>In case you didn't know you could do this...</p>\n\n<p>If you give a relative path to a resource in a CSS it's rela...
2008/09/18
[ "https://Stackoverflow.com/questions/89418", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10834/" ]
Assume I have an "images" folder directory under the root of my application. How can I, from within a .css file, reference an image in this directory using an ASP.NET app relative path. Example: When in development, the path of **~/Images/Test.gif** might resolve to **/MyApp/Images/Test.gif** while, in production, i...
Unfortunately Firefox has a stupid bug here... the paths are relative to the path of the page, instead of being relative to the position of the CSS file. Which means if you have pages in different positions in the tree (like having Default.aspx in the root and Information.aspx in the View folder) there's no way to have...
89,441
<p>I have Visual Studio web test attached nicely to a data source, but I need to be able to iterate over each entry in the data source. How should I do this?</p>
[ { "answer_id": 89492, "author": "Ola Karlsson", "author_id": 10696, "author_profile": "https://Stackoverflow.com/users/10696", "pm_score": 2, "selected": true, "text": "<p>This <a href=\"http://www.codeguru.com/csharp/.net/net_general/visualstudionetadd-ins/article.php/c12645__2/\" rel=\...
2008/09/18
[ "https://Stackoverflow.com/questions/89441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13813/" ]
I have Visual Studio web test attached nicely to a data source, but I need to be able to iterate over each entry in the data source. How should I do this?
This [article](http://www.codeguru.com/csharp/.net/net_general/visualstudionetadd-ins/article.php/c12645__2/) seems to Discuss something quite like what you're talking about. Good luck. Ola **EDIT:** From the linked article, your DataSource is exposed to your test via an attribute. ``` [DataSource("System.Data.SqlCli...
89,465
<p>Currently, WScript pops up message box when there is a script error. These scripts are called by other processes, and are ran on a server, so there is nobody to dismiss the error box. </p> <p>What I'd like is for the error message to be dumped to STDOUT, and execution to return the calling process. Popping as a MSG...
[ { "answer_id": 89511, "author": "X-Cubed", "author_id": 10808, "author_profile": "https://Stackoverflow.com/users/10808", "pm_score": 0, "selected": false, "text": "<p>You haven't stated what language you're using. If you're using VBScript, you can write an error handler using the <a hre...
2008/09/18
[ "https://Stackoverflow.com/questions/89465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
Currently, WScript pops up message box when there is a script error. These scripts are called by other processes, and are ran on a server, so there is nobody to dismiss the error box. What I'd like is for the error message to be dumped to STDOUT, and execution to return the calling process. Popping as a MSGBox just h...
This is how you should be running Script batch jobs: ``` cscript //b scriptname.vbs ```
89,480
<p>For reasons I won't go into, I wish to ban an entire company from accessing my web site. Checking the remote hostname in php using gethostbyaddr() works, but this slows down the page load too much. Large organizations (eg. hp.com or microsoft.com) often have blocks of IP addresses. Is there anyway I get the full lis...
[ { "answer_id": 89494, "author": "fabiopedrosa", "author_id": 2731698, "author_profile": "https://Stackoverflow.com/users/2731698", "pm_score": 1, "selected": false, "text": "<p>Take a look at .htaccess if you're using apache: <a href=\"http://httpd.apache.org/docs/1.3/howto/htaccess.html...
2008/09/18
[ "https://Stackoverflow.com/questions/89480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15947/" ]
For reasons I won't go into, I wish to ban an entire company from accessing my web site. Checking the remote hostname in php using gethostbyaddr() works, but this slows down the page load too much. Large organizations (eg. hp.com or microsoft.com) often have blocks of IP addresses. Is there anyway I get the full list, ...
How about an .htaccess: ``` Deny from x.x.x.x ``` if you need to deny a range say: 192.168.0.x then you would use ``` Deny from 192.168.0 ``` and the same applies for hostnames: ``` Deny from sub.domain.tld ``` or if you want a PHP solution ``` $ips = array('1.1.1.1', '2.2.2.2', '3.3.3.3'); if(in_array($_SERV...
89,488
<p>I've been trying to implement a C#-like event system in C++ with the tr1 function templates used to store a function that handles the event. </p> <p>I created a vector so that multiple listeners can be attached to this event, i.e.:</p> <pre><code>vector&lt; function&lt;void (int)&gt; &gt; listenerList; </code></p...
[ { "answer_id": 89542, "author": "Matt Cruikshank", "author_id": 8643, "author_profile": "https://Stackoverflow.com/users/8643", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://www.boost.org/doc/libs/1_36_0/doc/html/function/faq.html\" rel=\"nofollow noreferrer\">FAQ #1</a>...
2008/09/18
[ "https://Stackoverflow.com/questions/89488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17136/" ]
I've been trying to implement a C#-like event system in C++ with the tr1 function templates used to store a function that handles the event. I created a vector so that multiple listeners can be attached to this event, i.e.: ``` vector< function<void (int)> > listenerList; ``` I'd like to be able to remove a handl...
I don't know if you're locked into std C++ and tr1, but if you aren't, it seems like your problem could be completely avoided if you just used something like boost::signal and boost::bind to solve your original problem - creating an event system - instead of trying to roll your own.
89,504
<p>I've got a standard Rails app with Nginx and Mongrel running at <a href="http://mydomain" rel="noreferrer">http://mydomain</a>. I need to run a Wordpress blog at <a href="http://mydomain.com/blog" rel="noreferrer">http://mydomain.com/blog</a>. My preference would be to host the blog in Apache running on either the...
[ { "answer_id": 89512, "author": "Ian P", "author_id": 10853, "author_profile": "https://Stackoverflow.com/users/10853", "pm_score": 0, "selected": false, "text": "<p>Seems to me that something like a rewrite manipulator would do what you want. Sorry I don't have anymore details -- just t...
2008/09/18
[ "https://Stackoverflow.com/questions/89504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14619/" ]
I've got a standard Rails app with Nginx and Mongrel running at <http://mydomain>. I need to run a Wordpress blog at <http://mydomain.com/blog>. My preference would be to host the blog in Apache running on either the same server or a separate box but I don't want the user to see a different server in the URL. Is that p...
I think joelhardi's solution is superior to the following. However, in my own application, I like to keep the blog on a separate VPS than the Rails site (separation of memory issues). To make the user see the same URL, you use the same proxy trick that you normally use for proxying to a mongrel cluster, except you prox...
89,543
<p>I want to set something up so that if an Account within my app is disabled, I want all requests to be redirected to a "disabled" message.</p> <p>I've set this up in my ApplicationController:</p> <pre><code>class ApplicationController &lt; ActionController::Base before_filter :check_account def check_account ...
[ { "answer_id": 89637, "author": "flukus", "author_id": 407256, "author_profile": "https://Stackoverflow.com/users/407256", "pm_score": 0, "selected": false, "text": "<p>If theres not too many overrides then just put the if in the redirect filter</p>\n\n<p>if action != disabled\n redirec...
2008/09/18
[ "https://Stackoverflow.com/questions/89543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14530/" ]
I want to set something up so that if an Account within my app is disabled, I want all requests to be redirected to a "disabled" message. I've set this up in my ApplicationController: ``` class ApplicationController < ActionController::Base before_filter :check_account def check_account redirect_to :controll...
You could also use a `skip_before_filter` for the one controller/method you don't want to have the filter apply to.
89,588
<p>You do <code>AssignProcessToJobObject</code> and it fails with "access denied" but only when you are running in the debugger. Why is this?</p>
[ { "answer_id": 89589, "author": "1800 INFORMATION", "author_id": 3146, "author_profile": "https://Stackoverflow.com/users/3146", "pm_score": 6, "selected": true, "text": "<p>This one puzzled me for for about 30 minutes.</p>\n\n<p>First off, you probably need a UAC manifest embedded in yo...
2008/09/18
[ "https://Stackoverflow.com/questions/89588", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3146/" ]
You do `AssignProcessToJobObject` and it fails with "access denied" but only when you are running in the debugger. Why is this?
This one puzzled me for for about 30 minutes. First off, you probably need a UAC manifest embedded in your app ([as suggested here](https://stackoverflow.com/questions/53208/how-do-i-automatically-destroy-child-processes-in-windows#53214)). Something like this: ``` <?xml version="1.0" encoding="UTF-8" standalone="yes...
89,607
<p>I have added some code which compiles cleanly and have just received this Windows error:</p> <pre><code>--------------------------- (MonTel Administrator) 2.12.7: MtAdmin.exe - Application Error --------------------------- The exception Privileged instruction. (0xc0000096) occurred in the application at location ...
[ { "answer_id": 89643, "author": "Tim Williscroft", "author_id": 2789, "author_profile": "https://Stackoverflow.com/users/2789", "pm_score": 2, "selected": false, "text": "<p>I saw this with Visual c++ 6.0 in the year 2000.</p>\n\n<p>The debug C++ library had calls to physical I/O instruc...
2008/09/18
[ "https://Stackoverflow.com/questions/89607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3137/" ]
I have added some code which compiles cleanly and have just received this Windows error: ``` --------------------------- (MonTel Administrator) 2.12.7: MtAdmin.exe - Application Error --------------------------- The exception Privileged instruction. (0xc0000096) occurred in the application at location 0x00486752. `...
To answer the question, a privileged instruction is a processor op-code (assembler instruction) which can only be executed in "supervisor" (or Ring-0) mode. These types of instructions tend to be used to access I/O devices and protected data structures from the windows kernel. Regular programs execute in "user mode" (...
89,609
<p>I'm looking for the best way to take a simple input:</p> <pre><code>echo -n "Enter a string here: " read -e STRING </code></pre> <p>and clean it up by removing non-alphanumeric characters, lower(case), and replacing spaces with underscores.</p> <p>Does order matter? Is <code>tr</code> the best / only way to go ab...
[ { "answer_id": 89642, "author": "Devin Reams", "author_id": 16248, "author_profile": "https://Stackoverflow.com/users/16248", "pm_score": 0, "selected": false, "text": "<p>After a bit of looking around it seems <code>tr</code> is indeed the simplest way:</p>\n\n<pre><code>export CLEANSTR...
2008/09/18
[ "https://Stackoverflow.com/questions/89609", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16248/" ]
I'm looking for the best way to take a simple input: ``` echo -n "Enter a string here: " read -e STRING ``` and clean it up by removing non-alphanumeric characters, lower(case), and replacing spaces with underscores. Does order matter? Is `tr` the best / only way to go about this?
As dj\_segfault points out, the shell can do most of this for you. Looks like you'll have to fall back on something external for lower-casing the string, though. For this you have many options, like the perl one-liners above, etc., but I think tr is probably the simplest. ``` # first, strip underscores CLEAN=${STRING/...
89,650
<p>I would like to pass an argument(s) to a method being defined using define_method, how would I do that?</p>
[ { "answer_id": 89661, "author": "easeout", "author_id": 10906, "author_profile": "https://Stackoverflow.com/users/10906", "pm_score": 9, "selected": true, "text": "<p>The block that you pass to define_method can include some parameters. That's how your defined method accepts arguments. ...
2008/09/18
[ "https://Stackoverflow.com/questions/89650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1681/" ]
I would like to pass an argument(s) to a method being defined using define\_method, how would I do that?
The block that you pass to define\_method can include some parameters. That's how your defined method accepts arguments. When you define a method you're really just nicknaming the block and keeping a reference to it in the class. The parameters come with the block. So: ``` define_method(:say_hi) { |other| puts "Hi, " ...
89,705
<p>I'm going through the problems on projecteuler.net to learn how to program in Erlang, and I am having the hardest time creating a prime generator that can create all of the primes below 2 million, in less than a minute. Using the sequential style, I have already written three types of generators, including the Sieve...
[ { "answer_id": 89726, "author": "theo", "author_id": 7870, "author_profile": "https://Stackoverflow.com/users/7870", "pm_score": -1, "selected": false, "text": "<p>I love Project Euler.</p>\n\n<p>On the subject of prime generators, I am a big fan of the Sieve of Eratosthenes.</p>\n\n<p>F...
2008/09/18
[ "https://Stackoverflow.com/questions/89705", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8040/" ]
I'm going through the problems on projecteuler.net to learn how to program in Erlang, and I am having the hardest time creating a prime generator that can create all of the primes below 2 million, in less than a minute. Using the sequential style, I have already written three types of generators, including the Sieve of...
The 'badarity' error means that you're trying to call a 'fun' with the wrong number of arguments. In this case... %%L = for(1,N, fun() -> spawn(fun(I) -> wait(I,N) end) end), The for/3 function expects a fun of arity 1, and the spawn/1 function expects a fun of arity 0. Try this instead: ``` L = for(1, N, fun(I) -> ...
89,708
<p>I am trying to extract a gif image embedded as a resource within my ISAPI dll using WebBroker technology. The resource has been added to the DLL using the following RC code:</p> <pre><code>LOGO_GIF RCDATA logo.gif </code></pre> <p>Using resource explorer I verified it is in the DLL properly.</p> <p>using the fol...
[ { "answer_id": 90236, "author": "Jim McKeeth", "author_id": 255, "author_profile": "https://Stackoverflow.com/users/255", "pm_score": 1, "selected": false, "text": "<p>If I remember correctly you are actually dealing with an instance of the web server, not the dll. I don't remember the ...
2008/09/18
[ "https://Stackoverflow.com/questions/89708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9217/" ]
I am trying to extract a gif image embedded as a resource within my ISAPI dll using WebBroker technology. The resource has been added to the DLL using the following RC code: ``` LOGO_GIF RCDATA logo.gif ``` Using resource explorer I verified it is in the DLL properly. using the following code always throws an excep...
RCDATA is a [pre-defined](http://msdn.microsoft.com/en-us/library/aa381039(VS.85).aspx) resource type with an integer ID of RT\_RCDATA (declared in Types unit). Try accessing it this way: ``` rc := tResourceStream.Create(hInstance,'LOGO_GIF', MakeIntResource(RT_RCDATA)); ```
89,745
<p>I am trying to find the virtual file that contains the current users id. I was told that I could find it in the proc directory, but not quite sure which file.</p>
[ { "answer_id": 89763, "author": "Adam Pierce", "author_id": 5324, "author_profile": "https://Stackoverflow.com/users/5324", "pm_score": 2, "selected": false, "text": "<p>I'm not sure that can be found in <code>/proc</code>. You could try using the <code>getuid()</code> function or the <c...
2008/09/18
[ "https://Stackoverflow.com/questions/89745", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17162/" ]
I am trying to find the virtual file that contains the current users id. I was told that I could find it in the proc directory, but not quite sure which file.
You actually want `/proc/self/status`, which will give you information about the currently executed process. Here is an example: ``` $ cat /proc/self/status Name: cat State: R (running) Tgid: 17618 Pid: 17618 PPid: 3083 TracerPid: 0 Uid: 500 500 500 500 Gid: 500 500 500 500 FDSize: 32 Groups: 10 ...
89,752
<p>How can I get <strong>hierarchy recordset</strong> in ms access through <strong>select</strong> statement?</p>
[ { "answer_id": 89763, "author": "Adam Pierce", "author_id": 5324, "author_profile": "https://Stackoverflow.com/users/5324", "pm_score": 2, "selected": false, "text": "<p>I'm not sure that can be found in <code>/proc</code>. You could try using the <code>getuid()</code> function or the <c...
2008/09/18
[ "https://Stackoverflow.com/questions/89752", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can I get **hierarchy recordset** in ms access through **select** statement?
You actually want `/proc/self/status`, which will give you information about the currently executed process. Here is an example: ``` $ cat /proc/self/status Name: cat State: R (running) Tgid: 17618 Pid: 17618 PPid: 3083 TracerPid: 0 Uid: 500 500 500 500 Gid: 500 500 500 500 FDSize: 32 Groups: 10 ...
89,791
<p>When I start my process from Visual Studio, it is always created inside a job object. I would like to know how to turn this behaviour off. Any ideas?</p> <p>I expect that it is created in a job object to be debugged. I want to place my program in a different job object.</p> <p>It's not the hosting process. I'm tal...
[ { "answer_id": 93065, "author": "mdb", "author_id": 8562, "author_profile": "https://Stackoverflow.com/users/8562", "pm_score": 1, "selected": false, "text": "<p>I'm not aware of any ways to control this aspect of processes spawned for debugging by VS.NET. But there's a workaround, which...
2008/09/18
[ "https://Stackoverflow.com/questions/89791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3146/" ]
When I start my process from Visual Studio, it is always created inside a job object. I would like to know how to turn this behaviour off. Any ideas? I expect that it is created in a job object to be debugged. I want to place my program in a different job object. It's not the hosting process. I'm talking about a [Job...
This happens when `devenv.exe` or `VSLauncher.exe` run in compatibility mode. The [Program Compatibility Assistant](http://msdn.microsoft.com/en-us/library/bb756937.aspx) (PCA) attaches a job object to the Visual Studio process, and every child process inherits it. Check if the job name (as reported by Process Explorer...
89,820
<p>I am using mssql and am having trouble using a subquery. The real query is quite complicated, but it has the same structure as this:</p> <pre><code>select customerName, customerId, ( select count(*) from Purchases where Purchases.customerId=customerData.customerId ) as numberTransactions fro...
[ { "answer_id": 89831, "author": "Jonathan Rupp", "author_id": 12502, "author_profile": "https://Stackoverflow.com/users/12502", "pm_score": 4, "selected": true, "text": "<p>use the field number, in this case:</p>\n\n<pre><code>order by 3\n</code></pre>\n" }, { "answer_id": 89834,...
2008/09/18
[ "https://Stackoverflow.com/questions/89820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6062/" ]
I am using mssql and am having trouble using a subquery. The real query is quite complicated, but it has the same structure as this: ``` select customerName, customerId, ( select count(*) from Purchases where Purchases.customerId=customerData.customerId ) as numberTransactions from customerData...
use the field number, in this case: ``` order by 3 ```
89,866
<p>We are creating a Real-Time Process in VxWorks 6.x, and we would like to limit the amount of memory which can be allocated to the heap. How do we do this?</p>
[ { "answer_id": 89911, "author": "Benoit", "author_id": 10703, "author_profile": "https://Stackoverflow.com/users/10703", "pm_score": 3, "selected": true, "text": "<p>When creating a RTP via rtpSpawn(), you can specify an environment variable which controls how the heap behaves.<br>\nTher...
2008/09/18
[ "https://Stackoverflow.com/questions/89866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10703/" ]
We are creating a Real-Time Process in VxWorks 6.x, and we would like to limit the amount of memory which can be allocated to the heap. How do we do this?
When creating a RTP via rtpSpawn(), you can specify an environment variable which controls how the heap behaves. There are 3 environment variables: ``` HEAP_INITIAL_SIZE - How much heap to allocate initially (defaults to 64K) HEAP_MAX_SIZE - Maximum heap to allocate (defaults to no limit) HEAP_INCR_SIZE -...
89,873
<p>Is it possible to manipulate the components, such as <code>year</code>, <code>month</code>, <code>day</code> of a <code>date</code> in VBA? I would like a function that, given a day, a month, and a year, returns the corresponding date.</p>
[ { "answer_id": 89892, "author": "Nescio", "author_id": 14484, "author_profile": "https://Stackoverflow.com/users/14484", "pm_score": 2, "selected": false, "text": "<p>There are several date functions in VBA - check this <a href=\"http://www.classanytime.com/mis333k/sjdatetime.html\" rel=...
2008/09/18
[ "https://Stackoverflow.com/questions/89873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10439/" ]
Is it possible to manipulate the components, such as `year`, `month`, `day` of a `date` in VBA? I would like a function that, given a day, a month, and a year, returns the corresponding date.
``` DateSerial(YEAR, MONTH, DAY) ``` would be what you are looking for. `DateSerial(2008, 8, 19)` returns `8/19/2008`
89,897
<p>Maybe the need to do this is a 'design smell' but thinking about another question, I was wondering what the cleanest way to implement the <strong>inverse</strong> of this:</p> <pre><code>foreach(ISomethingable somethingableClass in collectionOfRelatedObjects) { somethingableClass.DoSomething(); } </code></pre> <...
[ { "answer_id": 89933, "author": "J D OConal", "author_id": 17023, "author_profile": "https://Stackoverflow.com/users/17023", "pm_score": 3, "selected": false, "text": "<p>Something like this?</p>\n\n<pre><code>foreach (ParentType parentType in collectionOfRelatedObjects) {\n if (!(par...
2008/09/18
[ "https://Stackoverflow.com/questions/89897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12726/" ]
Maybe the need to do this is a 'design smell' but thinking about another question, I was wondering what the cleanest way to implement the **inverse** of this: ``` foreach(ISomethingable somethingableClass in collectionOfRelatedObjects) { somethingableClass.DoSomething(); } ``` i.e. How to get/iterate through all t...
this should do the trick: ``` collectionOfRelatedObjects.Where(o => !(o is ISomethingable)) ```
89,908
<p>I have three models:</p> <pre><code>class ReleaseItem &lt; ActiveRecord::Base has_many :pack_release_items has_one :pack, :through =&gt; :pack_release_items end class Pack &lt; ActiveRecord::Base has_many :pack_release_items has_many :release_items, :through=&gt;:pack_release_items end class PackReleaseIt...
[ { "answer_id": 90003, "author": "Misplaced", "author_id": 13710, "author_profile": "https://Stackoverflow.com/users/13710", "pm_score": 4, "selected": true, "text": "<p>It appears that your usage of has_one :through is correct. The problem you're seeing has to do with saving objects. F...
2008/09/18
[ "https://Stackoverflow.com/questions/89908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13179/" ]
I have three models: ``` class ReleaseItem < ActiveRecord::Base has_many :pack_release_items has_one :pack, :through => :pack_release_items end class Pack < ActiveRecord::Base has_many :pack_release_items has_many :release_items, :through=>:pack_release_items end class PackReleaseItem < ActiveRecord::Base ...
It appears that your usage of has\_one :through is correct. The problem you're seeing has to do with saving objects. For an association to work, the object that is being referenced needs to have an id to populate the `model_id` field for the object. In this case, `PackReleaseItems` have a `pack_id` and a `release_item_...
89,909
<p>I know how to do this if I iterate through all of the characters in the string but I am looking for a more elegant method.</p>
[ { "answer_id": 89915, "author": "easeout", "author_id": 10906, "author_profile": "https://Stackoverflow.com/users/10906", "pm_score": -1, "selected": false, "text": "<p>use a regex and see if it matches!</p>\n\n<pre><code>([a-z][A-Z][0-9]\\_\\-)*\n</code></pre>\n" }, { "answer_id...
2008/09/18
[ "https://Stackoverflow.com/questions/89909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4527/" ]
I know how to do this if I iterate through all of the characters in the string but I am looking for a more elegant method.
A regular expression will do the trick with very little code: ``` import re ... if re.match("^[A-Za-z0-9_-]*$", my_little_string): # do something here ```
89,987
<p>My DataView is acting funny and it is sorting things alphabetically and I need it to sort things numerically. I have looked all across the web for this one and found many ideas on how to sort it with ICompare, but nothing really solid.</p> <p>So my questions are </p> <ol> <li>How do I implement ICompare on a Data...
[ { "answer_id": 90498, "author": "rslite", "author_id": 15682, "author_profile": "https://Stackoverflow.com/users/15682", "pm_score": 2, "selected": false, "text": "<p>For the first issue - IIRC you can't sort a DataView with a comparer. If you just need to sort numerically a field you mu...
2008/09/18
[ "https://Stackoverflow.com/questions/89987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7644/" ]
My DataView is acting funny and it is sorting things alphabetically and I need it to sort things numerically. I have looked all across the web for this one and found many ideas on how to sort it with ICompare, but nothing really solid. So my questions are 1. How do I implement ICompare on a DataView (Looking for cod...
For the first issue - IIRC you can't sort a DataView with a comparer. If you just need to sort numerically a field you must be sure that the column type is numeric and not string. Some code would help to elucidate this. For the second issue also you can't do that directly in the DataView. If you really need to sort th...
89,989
<p>I want to download a lot of urls in a script but I do not want to save the ones that lead to HTTP errors.</p> <p>As far as I can tell from the man pages, neither <code>curl</code> or <code>wget</code> provide such functionality. Does anyone know about another downloader who does?</p>
[ { "answer_id": 90009, "author": "Thomas", "author_id": 14637, "author_profile": "https://Stackoverflow.com/users/14637", "pm_score": 5, "selected": false, "text": "<p>I think the <code>-f</code> option to <code>curl</code> does what you want:</p>\n\n<blockquote>\n <p><code>-f</code>, <c...
2008/09/18
[ "https://Stackoverflow.com/questions/89989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65724/" ]
I want to download a lot of urls in a script but I do not want to save the ones that lead to HTTP errors. As far as I can tell from the man pages, neither `curl` or `wget` provide such functionality. Does anyone know about another downloader who does?
One liner I just setup for this very purpose: (works only with a single file, might be useful for others) ``` A=$$; ( wget -q "http://foo.com/pipo.txt" -O $A.d && mv $A.d pipo.txt ) || (rm $A.d; echo "Removing temp file") ``` This will attempt to download the file from the remote Host. If there is an Error, the fil...
90,023
<h2>Update: giving a much more thorough example.</h2> <p>The first two solutions offered were right along the lines of what I was trying to say <em>not</em> to do. I can't know location, it needs to be able to look at the whole document tree. So a solution along these lines, with /Books/ specified as the context will...
[ { "answer_id": 90795, "author": "rslite", "author_id": 15682, "author_profile": "https://Stackoverflow.com/users/15682", "pm_score": 3, "selected": true, "text": "<p>It's not clear for me from your example what you're actually trying to achieve. Do you want to return a new XML with all t...
2008/09/18
[ "https://Stackoverflow.com/questions/90023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8507/" ]
Update: giving a much more thorough example. -------------------------------------------- The first two solutions offered were right along the lines of what I was trying to say *not* to do. I can't know location, it needs to be able to look at the whole document tree. So a solution along these lines, with /Books/ spec...
It's not clear for me from your example what you're actually trying to achieve. Do you want to return a new XML with all the nodes stripped out except those that fulfill the condition? If yes, then this looks like the job for an XSLT transform which I don't think it's built-in in MSSQL 2005 (can be added as a UDF: <htt...
90,029
<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...
[ { "answer_id": 90072, "author": "blowdart", "author_id": 2525, "author_profile": "https://Stackoverflow.com/users/2525", "pm_score": 1, "selected": false, "text": "<p>You can use WMI to enumerate what Windows knows about a drive; get the <a href=\"http://msdn.microsoft.com/en-us/library/...
2008/09/18
[ "https://Stackoverflow.com/questions/90029", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
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 fo...
You can use WMI to enumerate what Windows knows about a drive; get the [`Win32_DiskDrive`](http://msdn.microsoft.com/en-us/library/aa394132(VS.85).aspx) instance from which you should be able to grab the the [`Win32_PhysicalMedia`](http://msdn.microsoft.com/en-us/library/aa394346(VS.85).aspx) information for the physic...
90,049
<p>I'm using a table to design the layout of my web page. I want the table to fill the page even if it doesn't contain much content. Here's the CSS I'm using:</p> <pre class="lang-css prettyprint-override"><code>html, body { height: 100%; margin: 0; padding: 0; } #container { min-height: 100%; wi...
[ { "answer_id": 90109, "author": "Vincent McNabb", "author_id": 16299, "author_profile": "https://Stackoverflow.com/users/16299", "pm_score": 4, "selected": true, "text": "<p>Just use the <code>height</code> property instead of the <code>min-height</code> property when setting <code>#cont...
2008/09/18
[ "https://Stackoverflow.com/questions/90049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17216/" ]
I'm using a table to design the layout of my web page. I want the table to fill the page even if it doesn't contain much content. Here's the CSS I'm using: ```css html, body { height: 100%; margin: 0; padding: 0; } #container { min-height: 100%; width: 100%; } ``` And I place something like th...
Just use the `height` property instead of the `min-height` property when setting `#container`. Once the data gets too big, the table will automatically grow.
90,052
<p>Ok, so i'm working on a regular expression to search out all the header information in a site.</p> <p>I've compiled the regular expression:</p> <pre><code>regex = re.compile(r''' &lt;h[0-9]&gt;\s? (&lt;a[ ]href="[A-Za-z0-9.]*"&gt;)?\s? [A-Za-z0-9.,:'"=/?;\s]*\s? [A-Za-z0-9.,:'"=/?;\s]? ''', re.X) ...
[ { "answer_id": 90095, "author": "habnabit", "author_id": 10999, "author_profile": "https://Stackoverflow.com/users/10999", "pm_score": 2, "selected": false, "text": "<p>Parsing things with regular expressions works for regular languages. HTML is not a regular language, and the stuff you ...
2008/09/18
[ "https://Stackoverflow.com/questions/90052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Ok, so i'm working on a regular expression to search out all the header information in a site. I've compiled the regular expression: ``` regex = re.compile(r''' <h[0-9]>\s? (<a[ ]href="[A-Za-z0-9.]*">)?\s? [A-Za-z0-9.,:'"=/?;\s]*\s? [A-Za-z0-9.,:'"=/?;\s]? ''', re.X) ``` When i run this in python r...
This question has been asked in several forms over the last few days, so I'm going to say this very clearly. Q: How do I parse HTML with Regular Expressions? ================================================ A: Please Don't. ================ Use [BeautifulSoup](http://www.crummy.com/software/BeautifulSoup/), [html5li...
90,067
<p>I'm using the following html to load dojo from Google's hosting.</p> <pre><code>&lt;script src="http://www.google.com/jsapi"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt;google.load("dojo", "1.1.1");&lt;/script&gt; &lt;script type="text/javascript"&gt; dojo.require("dojox.gfx"); ... </code></pre> <p>Thi...
[ { "answer_id": 90088, "author": "William Keller", "author_id": 17095, "author_profile": "https://Stackoverflow.com/users/17095", "pm_score": 0, "selected": false, "text": "<p>I believe that google becomes the namespace for your imported libraries. Try: <code>google.dojo.require</code>.</...
2008/09/18
[ "https://Stackoverflow.com/questions/90067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17209/" ]
I'm using the following html to load dojo from Google's hosting. ``` <script src="http://www.google.com/jsapi"></script> <script type="text/javascript">google.load("dojo", "1.1.1");</script> <script type="text/javascript"> dojo.require("dojox.gfx"); ... ``` This errors out on the requre line with an error like dojox...
Differently from when you reference the .js files directly from the <script> tag (note that google js api also supports this, see [here](http://code.google.com/apis/ajaxlibs/documentation/#dojo)), google.load is not synchronous. This means that when your code reach google.load, it will not wait for dojo to be fully loa...