qid
int64 4
22.2M
| question
stringlengths 18
48.3k
| answers
list | date
stringlengths 10
10
| metadata
list |
|---|---|---|---|---|
93,091
|
<p>Why is it that they decided to make <code>String</code> immutable in Java and .NET (and some other languages)? Why didn't they make it mutable?</p>
|
[
{
"answer_id": 93099,
"author": "jsight",
"author_id": 1432,
"author_profile": "https://Stackoverflow.com/users/1432",
"pm_score": -1,
"selected": false,
"text": "String"
},
{
"answer_id": 93170,
"author": "Evan DiBiase",
"author_id": 2399475,
"author_profile": "https://Stackoverflow.com/users/2399475",
"pm_score": 3,
"selected": false,
"text": "String"
},
{
"answer_id": 93212,
"author": "aaronroyer",
"author_id": 16982,
"author_profile": "https://Stackoverflow.com/users/16982",
"pm_score": 2,
"selected": false,
"text": "String"
},
{
"answer_id": 93366,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "String"
},
{
"answer_id": 666375,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "String"
},
{
"answer_id": 668679,
"author": "LordOfThePigs",
"author_id": 80779,
"author_profile": "https://Stackoverflow.com/users/80779",
"pm_score": 6,
"selected": false,
"text": " | myString |\n v v\n\"The quick brown fox jumps over the lazy dog\" <-- shared char[]\n ^ ^\n | | myString.substring(0,5)\n"
},
{
"answer_id": 691399,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "String"
},
{
"answer_id": 838489,
"author": "Triynko",
"author_id": 88409,
"author_profile": "https://Stackoverflow.com/users/88409",
"pm_score": 2,
"selected": false,
"text": "STRING"
},
{
"answer_id": 4001768,
"author": "Andrei Rînea",
"author_id": 1796,
"author_profile": "https://Stackoverflow.com/users/1796",
"pm_score": 2,
"selected": false,
"text": "SecureString"
},
{
"answer_id": 19736826,
"author": "Lu4",
"author_id": 504325,
"author_profile": "https://Stackoverflow.com/users/504325",
"pm_score": 0,
"selected": false,
"text": "using System;\nusing System.Runtime.InteropServices;\n\nnamespace Guess\n{\n class Program\n {\n static void Main(string[] args)\n {\n const string str = \"ABC\";\n\n Console.WriteLine(str);\n Console.WriteLine(str.GetHashCode());\n\n var handle = GCHandle.Alloc(str, GCHandleType.Pinned);\n\n try\n {\n Marshal.WriteInt16(handle.AddrOfPinnedObject(), 4, 'Z');\n\n Console.WriteLine(str);\n Console.WriteLine(str.GetHashCode());\n }\n finally\n {\n handle.Free();\n }\n }\n }\n}\n"
},
{
"answer_id": 28908793,
"author": "Bauss",
"author_id": 2026276,
"author_profile": "https://Stackoverflow.com/users/2026276",
"pm_score": 3,
"selected": false,
"text": "public static unsafe void MutableReplaceIndex(string s, char c, int i)\n{\n fixed (char* ptr = s)\n {\n *((char*)(ptr + i)) = c;\n }\n}\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2936/"
] |
93,100
|
<p>We all know that prepared statements are one of the best way of fending of SQL injection attacks. What is the best way of creating a prepared statement with an "IN" clause. Is there an easy way to do this with an unspecified number of values? Take the following query for example.</p>
<pre><code>SELECT ID,Column1,Column2 FROM MyTable WHERE ID IN (1,2,3)
</code></pre>
<p>Currently I'm using a loop over my possible values to build up a string such as. </p>
<pre><code>SELECT ID,Column1,Column2 FROM MyTable WHERE ID IN (@IDVAL_1,@IDVAL_2,@IDVAL_3)
</code></pre>
<p>Is it possible to use just pass an array as the value of the query paramter and use a query as follows?</p>
<pre><code>SELECT ID,Column1,Column2 FROM MyTable WHERE ID IN (@IDArray)
</code></pre>
<p>In case it's important I'm working with SQL Server 2000, in VB.Net</p>
|
[
{
"answer_id": 93247,
"author": "digiguru",
"author_id": 5055,
"author_profile": "https://Stackoverflow.com/users/5055",
"pm_score": 3,
"selected": false,
"text": "Create Function [dbo].[SeparateValues]\n(\n @data VARCHAR(MAX),\n @delimiter VARCHAR(10) \n) \n RETURNS @tbldata TABLE(col VARCHAR(10))\nAs\nBegin\n DECLARE @pos INT\n DECLARE @prevpos INT\n\n SET @pos = 1 \n SET @prevpos = 0\n\n WHILE @pos > 0 \n BEGIN\n\n SET @pos = CHARINDEX(@delimiter, @data, @prevpos+1)\n\n if @pos > 0 \n INSERT INTO @tbldata(col) VALUES(LTRIM(RTRIM(SUBSTRING(@data, @prevpos+1, @pos-@prevpos-1))))\n\n else\n\n INSERT INTO @tbldata(col) VALUES(LTRIM(RTRIM(SUBSTRING(@data, @prevpos+1, len(@data)-@prevpos))))\n\n SET @prevpos = @pos \n End\n\n RETURN\n\nEND\n"
},
{
"answer_id": 93258,
"author": "Mike",
"author_id": 1115144,
"author_profile": "https://Stackoverflow.com/users/1115144",
"pm_score": -1,
"selected": false,
"text": "ALTER Procedure GetProductsBySearchString\n@SearchString varchar(1000),\nas\nset nocount on\ndeclare @sqlstring varchar(6000)\nselect @sqlstring = 'set nocount on\nselect a.productid, count(a.productid) as SumOf, sum(a.relevence) as CountOf \n from productkeywords a \n where rtrim(ltrim(a.term)) in (''' + Replace(@SearchString,' ', ''',''') + ''')\n group by a.productid order by SumOf desc, CountOf desc'\n\nexec(@sqlstring)\n"
},
{
"answer_id": 97339,
"author": "Stefan Schweizer",
"author_id": 13559,
"author_profile": "https://Stackoverflow.com/users/13559",
"pm_score": 0,
"selected": false,
"text": "SELECT ID,Column1,Column2 FROM MyTable WHERE ID IN (SELECT VALUE FROM TempTable)\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1862/"
] |
93,105
|
<p>Need a function that takes a character as a parameter and returns true if it is a letter.</p>
|
[
{
"answer_id": 93108,
"author": "raven",
"author_id": 4228,
"author_profile": "https://Stackoverflow.com/users/4228",
"pm_score": 3,
"selected": false,
"text": "Private Function IsLetter(ByVal character As String) As Boolean\n IsLetter = UCase$(character) <> LCase$(character)\nEnd Function\n"
},
{
"answer_id": 93152,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 1,
"selected": false,
"text": "Private Function IsLetter(ByVal ch As String) As Boolean\n IsLetter = (ch >= \"A\" and ch <= \"Z\") or (ch >= \"a\" and ch <= \"z\")\nEnd Function\n"
},
{
"answer_id": 93194,
"author": "seanyboy",
"author_id": 1726,
"author_profile": "https://Stackoverflow.com/users/1726",
"pm_score": -1,
"selected": false,
"text": "public bool IsAlpha(String strToCheck)\n{\n Regex objAlphaPattern=new Regex(\"[^a-zA-Z]\");\n return !objAlphaPattern.IsMatch(strToCheck);\n}\n\npublic bool IsCharAlpha(char chToCheck)\n{\n return ((chToCheck=>'a') and (chToCheck<='z')) or ((chToCheck=>'A') and (chToCheck<='Z'))\n}\n"
},
{
"answer_id": 93299,
"author": "seanyboy",
"author_id": 1726,
"author_profile": "https://Stackoverflow.com/users/1726",
"pm_score": 0,
"selected": false,
"text": "Private Declare Function IsCharAlphaA Lib \"user32\" Alias \"IsCharAlphaA\" (ByVal cChar As Byte) As Long\n"
},
{
"answer_id": 96098,
"author": "Keith Maurino",
"author_id": 1096640,
"author_profile": "https://Stackoverflow.com/users/1096640",
"pm_score": 0,
"selected": false,
"text": "Private Function IsAlpha(ByVal vChar As String) As Boolean\n Const letters$ = \"abcdefghijklmnopqrstuvwxyz\"\n\n If InStr(1, letters, LCase$(vChar)) > 0 Then IsAlpha = True\nEnd Function\n"
},
{
"answer_id": 105474,
"author": "Graham",
"author_id": 1826,
"author_profile": "https://Stackoverflow.com/users/1826",
"pm_score": 2,
"selected": false,
"text": "Private Function IsLetter(Char As String) As Boolean\n IsLetter = UCase(Char) Like \"[ABCDEFGHIJKLMNOPQRSTUVWXYZ]\"\nEnd Function\n"
},
{
"answer_id": 109201,
"author": "rpetrich",
"author_id": 4007,
"author_profile": "https://Stackoverflow.com/users/4007",
"pm_score": 3,
"selected": true,
"text": "IsCharAlphaA"
},
{
"answer_id": 1024618,
"author": "Bob77",
"author_id": 126278,
"author_profile": "https://Stackoverflow.com/users/126278",
"pm_score": 1,
"selected": false,
"text": "Option Explicit\n\nPrivate Declare Function IsCharAlphaW Lib \"unicows\" (ByVal WChar As Integer) As Long\n\nPrivate Function IsLetter(Character As String) As Boolean\n IsLetter = IsCharAlphaW(AscW(Character))\nEnd Function\n\nPrivate Sub Main()\n MsgBox IsLetter(\"^\")\n MsgBox IsLetter(\"A\")\n MsgBox IsLetter(ChrW$(&H34F))\n MsgBox IsLetter(ChrW$(&HFEF0))\n MsgBox IsLetter(ChrW$(&HFEFC))\nEnd Sub\n"
},
{
"answer_id": 22345939,
"author": "Hartmut",
"author_id": 3409673,
"author_profile": "https://Stackoverflow.com/users/3409673",
"pm_score": 0,
"selected": false,
"text": "Function IsLettersOnly(Value As String) As Boolean\n IsLettersOnly = Len(Value) > 0 And Not UCase(Value) Like \"*[!A-Z]*\"\nEnd Function\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4228/"
] |
93,128
|
<p>I'm importing a MySQL dump and getting the following error.</p>
<pre><code>$ mysql foo < foo.sql
ERROR 1153 (08S01) at line 96: Got a packet bigger than 'max_allowed_packet' bytes
</code></pre>
<p>Apparently there are attachments in the database, which makes for very large inserts.</p>
<hr>
<p>This is on my local machine, a Mac with MySQL 5 installed from the MySQL package.</p>
<p>Where do I change <code>max_allowed_packet</code> to be able to import the dump? </p>
<p>Is there anything else I should set? </p>
<p>Just running <code>mysql --max_allowed_packet=32M …</code> resulted in the same error.</p>
|
[
{
"answer_id": 93165,
"author": "GHad",
"author_id": 11705,
"author_profile": "https://Stackoverflow.com/users/11705",
"pm_score": 6,
"selected": false,
"text": "my.ini"
},
{
"answer_id": 93168,
"author": "Tomasz Tybulewicz",
"author_id": 17405,
"author_profile": "https://Stackoverflow.com/users/17405",
"pm_score": 3,
"selected": false,
"text": "max_allowed_packet"
},
{
"answer_id": 104176,
"author": "Michael Pryor",
"author_id": 245,
"author_profile": "https://Stackoverflow.com/users/245",
"pm_score": 10,
"selected": true,
"text": "mysql --max_allowed_packet=100M -u root -p database < dump.sql\n"
},
{
"answer_id": 105334,
"author": "kch",
"author_id": 13989,
"author_profile": "https://Stackoverflow.com/users/13989",
"pm_score": 4,
"selected": false,
"text": "/usr/local/mysql/support-files/my*.cnf"
},
{
"answer_id": 722656,
"author": "Joshua Fox",
"author_id": 39242,
"author_profile": "https://Stackoverflow.com/users/39242",
"pm_score": 7,
"selected": false,
"text": "set global net_buffer_length=1000000; \nset global max_allowed_packet=1000000000; \n"
},
{
"answer_id": 19145731,
"author": "Mike Castro Demaria",
"author_id": 902279,
"author_profile": "https://Stackoverflow.com/users/902279",
"pm_score": 3,
"selected": false,
"text": "[mysqld]\n# added to avoid err \"Got a packet bigger than 'max_allowed_packet' bytes\"\n#\nnet_buffer_length=1000000 \nmax_allowed_packet=1000000000\n#\n"
},
{
"answer_id": 20273704,
"author": "Primoz Rome",
"author_id": 255710,
"author_profile": "https://Stackoverflow.com/users/255710",
"pm_score": 4,
"selected": false,
"text": "# mysql -u admin -p\n\nmysql> set global net_buffer_length=1000000;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> set global max_allowed_packet=1000000000;\nQuery OK, 0 rows affected (0.00 sec)\n"
},
{
"answer_id": 21524811,
"author": "Amirtha Rajan",
"author_id": 3061477,
"author_profile": "https://Stackoverflow.com/users/3061477",
"pm_score": 4,
"selected": false,
"text": "max_allowed_packet=100000000\nnet_buffer_length=1000000 \n"
},
{
"answer_id": 22153978,
"author": "Raj Pawan Gumdal",
"author_id": 260665,
"author_profile": "https://Stackoverflow.com/users/260665",
"pm_score": 1,
"selected": false,
"text": "my.ini"
},
{
"answer_id": 33164481,
"author": "Grzegorz Brzęczyszczykiewicz",
"author_id": 2111633,
"author_profile": "https://Stackoverflow.com/users/2111633",
"pm_score": 2,
"selected": false,
"text": "max_allowed_packet = 16M\n"
},
{
"answer_id": 38580700,
"author": "Shiva",
"author_id": 6160636,
"author_profile": "https://Stackoverflow.com/users/6160636",
"pm_score": 2,
"selected": false,
"text": "max_allowed_packet"
},
{
"answer_id": 54415138,
"author": "Tính Ngô Quang",
"author_id": 2949104,
"author_profile": "https://Stackoverflow.com/users/2949104",
"pm_score": 2,
"selected": false,
"text": "SET GLOBAL max_allowed_packet=1073741824;\nSHOW VARIABLES LIKE 'max_allowed_packet'; \n"
},
{
"answer_id": 70503808,
"author": "Ali Raza Khan",
"author_id": 14214444,
"author_profile": "https://Stackoverflow.com/users/14214444",
"pm_score": 3,
"selected": false,
"text": "SET GLOBAL max_allowed_packet=1073741824;\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13989/"
] |
93,147
|
<p>I'm supposed to create a simple rule engine in C#. Any leads on how I can proceed?. It's a minimalistic rule engine, and would use SQL server as the back end. Do we have any general blueprint or design patterns that generally apply to rule engines? What kind of .Net technologies can I use to design one? Any directions would be helpful.
Thanks.</p>
|
[
{
"answer_id": 28099808,
"author": "Dib",
"author_id": 254215,
"author_profile": "https://Stackoverflow.com/users/254215",
"pm_score": 0,
"selected": false,
"text": "[TestMethod]\npublic void GreaterThanRule_WhenGreater_ResultsTrue()\n{\n // ARRANGE\n int threshold = 5;\n int actual = 10;\n\n // ACT\n var integerRule = new IntegerGreaterThanRule();\n integerRule.Initialize(threshold, actual);\n\n var integerRuleEngine = new RuleEngine<int>();\n integerRuleEngine.Add(integerRule);\n var result = integerRuleEngine.MatchAll();\n\n // ASSERT\n Assert.IsTrue(result);\n}\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
93,150
|
<p>The Query Optimizer is estimating that the results of a join will have only one row, when the actual number of rows is 2000. This is causing later joins on the dataset to have an estimated result of one row, when some of them go as high as 30,000.</p>
<p>With a count of 1, the QO is choosing a loop join/index seek strategy for many of the joins which is much too slow. I worked around the issue by constraining the possible join strategies with a <code>WITH OPTION (HASH JOIN, MERGE JOIN)</code>, which improved overall execution time from 60+ minutes to 12 seconds. However, I think the QO is still generating a less than optimal plan because of the bad rowcounts. I don't want to specify the join order and details manually-- there are too many queries affected by this for it to be worthwhile.</p>
<p>This is in Microsoft SQL Server 2000, a medium query with several table selects joined to the main select.</p>
<p>I think the QO may be overestimating the cardinality of the many side on the join, expecting the joining columns between the tables to have less rows in common.</p>
<p>The estimated row counts from scanning the indexes before the join are accurate, it's only the estimated row count after certain joins that's much too low.</p>
<p>The statistics for all the tables in the DB are up to date and refreshed automatically.</p>
<p>One of the early bad joins is between a generic 'Person' table for information common to all people and a specialized person table that about 5% of all those people belong to. The clustered PK in both tables (and the join column) is an INT. The database is highly normalized.</p>
<p>I believe that the root problem is the bad row count estimate after certain joins, so my main questions are:</p>
<ul>
<li>How can I fix the QO's post join rowcount estimate?</li>
<li>Is there a way that I can hint that a join will have a lot of rows without specifying the entire join order manually?</li>
</ul>
|
[
{
"answer_id": 114811,
"author": "Chris Smith",
"author_id": 9073,
"author_profile": "https://Stackoverflow.com/users/9073",
"pm_score": 3,
"selected": true,
"text": "UPDATE STATISTICS <table> WITH FULLSCAN, ALL\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9073/"
] |
93,153
|
<p>In a .net 2 winforms application, what's a good way to set the culture for the entire application?<br>
Setting CurrentThread.CurrentCulture for every new thread is repetitive and error-prone.<br>
Ideally I'd like to set it when the app starts and forget about it.</p>
|
[
{
"answer_id": 93622,
"author": "Vertigo",
"author_id": 5468,
"author_profile": "https://Stackoverflow.com/users/5468",
"pm_score": 1,
"selected": false,
"text": "static void Main()\n{\n System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo(\"fi-FI\");\n Application.CurrentCulture = cultureInfo;\n Application.EnableVisualStyles();\n Application.SetCompatibleTextRenderingDefault(false);\n Application.Run(new Form1());\n}\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/626/"
] |
93,159
|
<p>In our project we have a standard auto-generated designer.cs file, linked to a DBML file, that contains all our object classes that map onto our database tables.</p>
<p>We want to pass these objects directly through a WCF Service and so they need decorating with the [DataContract] and [DataMember] attributes where appropriate. What is the best approach to doing this so the changes won't get wiped out when the designer.cs file is re-generated upon a change to the database scheme or some other change.</p>
<p>Partial classes are an option, but if the property I want to decorate with the DataMember attribute is already defined in the autogenerated designer.cs file then I can't add the same property definition to the partial class as this means the property will have been defined twice.</p>
|
[
{
"answer_id": 93640,
"author": "Mike Comstock",
"author_id": 16872,
"author_profile": "https://Stackoverflow.com/users/16872",
"pm_score": 0,
"selected": false,
"text": "public partial class MyDataContext : System.Data.Linq.DataContext\n{\n...\n}\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17765/"
] |
93,162
|
<p>Apparently you can easily obtain a client IP address in WCF 3.5 but not in WCF 3.0. Anyone know how?</p>
|
[
{
"answer_id": 93437,
"author": "Paul Mrozowski",
"author_id": 3656,
"author_profile": "https://Stackoverflow.com/users/3656",
"pm_score": 7,
"selected": false,
"text": "using System.ServiceModel;\nusing System.ServiceModel.Channels;\n\nOperationContext context = OperationContext.Current;\nMessageProperties prop = context.IncomingMessageProperties;\nRemoteEndpointMessageProperty endpoint =\n prop[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;\nstring ip = endpoint.Address;\n"
},
{
"answer_id": 188088,
"author": "Gaz",
"author_id": 3856,
"author_profile": "https://Stackoverflow.com/users/3856",
"pm_score": 6,
"selected": true,
"text": " <system.serviceModel>\n <!-- this enables WCF services to access ASP.Net http context -->\n <serviceHostingEnvironment aspNetCompatibilityEnabled=\"true\"/>\n...\n </system.serviceModel>\n"
},
{
"answer_id": 190513,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "OperationContext context = OperationContext.Current;\nMessageProperties prop = context.IncomingMessageProperties;\nRemoteEndpointMessageProperty endpoint = prop[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;\nstring ip = endpoint.Address;\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3856/"
] |
93,171
|
<p>I have a bowling web application that allows pretty detailed frame-by-frame information entry. One thing it allows is tracking which pins were knocked down on each ball. To display this information, I make it look like a rack of pins:</p>
<pre>o o o o
o o o
o o
o</pre>
<p>Images are used to represent the pins. So, for the back row, I have four <em>img</em> tags, then a <em>br</em> tag. It works great... mostly. The problem is in small browsers, such as IEMobile. In this case, where there are may 10 or 11 columns in a table, and there may be a rack of pins in each column, Internet Explorer will try to shrink the column size to fit on the screen, and I end up with something like this:</p>
<pre>o o o
o
o o o
o o
o</pre>
<p>or</p>
<pre>o o
o o
o o
o
o o
o</pre>
<p>The structure is:</p>
<pre><code><tr>
<td>
<!-- some whitespace -->
<div class="..."><img .../><img .../><img .../><img .../><br/>...</div>
<!-- some whitespace -->
</td>
</tr>
</code></pre>
<p>There is no whitespace inside the inner div. If you look at <a href="http://www.bowlsk.com/games/view-series.html?series=13717" rel="nofollow noreferrer">this page</a> in a regular browser, it should display fine. If you look at it in IEMobile, it does not.</p>
<p>Any hints or suggestions? Maybe some sort of &nbsp; that doesn't actually add a space?</p>
<hr/>
<h3>Follow-up/Summary</h3>
<p>I have received and tried several good suggestions, including:</p>
<ul>
<li>Dynamically generate the whole image on the server. It is a good solution, but doesn't really fit my need (hosted on <a href="https://en.wikipedia.org/wiki/Google_App_Engine" rel="nofollow noreferrer">GAE</a>), and a bit more code than I'd like to write. These images could also be cached after the first generation.</li>
<li>Use CSS white-space declaration. It is a good standards-based solution, but it fails miserably in the IEMobile view.</li>
</ul>
<h3>What I ended up doing</h3>
<em>*hangs head and mumbles something*</em>
<p>Yes, that's right, a transparent GIF at the top of the div, sized to the width I need. End code (simplified) looks like:</p>
<pre><code><table class="game">
<tr class="analysis leave">
<!-- ... -->
<td> <div class="smallpins"><img class="spacer" src="http://seasrc.th.net/gif/cleardot.gif" /><br/><img src="/img/pinsmall.gif"/><img src="/img/nopinsmall.gif"/><img src="/img/nopinsmall.gif"/><img src="/img/nopinsmall.gif"/><br/><img src="/img/pinsmall.gif"/><img src="/img/pinsmall.gif"/><img src="/img/nopinsmall.gif"/><br/><img src="/img/nopinsmall.gif"/><img src="/img/nopinsmall.gif"/><br/><img src="/img/nopinsmall.gif"/></div> </td>
<!-- ... -->
</tr>
</table>
</code></pre>
<p>And CSS:</p>
<pre class="lang-css prettyprint-override"><code>div.smallpins {
background: url(/img/lane.gif) repeat;
text-align: center;
padding: 0;
white-space: nowrap;
}
div.smallpins img {
width: 1em;
height: 1em;
}
div.smallpins img.spacer {
width: 4.5em;
height: 0px;
}
table.game tr.leave td{
padding: 0;
margin: 0;
}
table.game tr.leave .smallpins {
min-width: 4em;
white-space: nowrap;
background: none;
}
</code></pre>
<p>P.S.: No, I will not be hotlinking someone else's clear dot in my final solution :)</p>
|
[
{
"answer_id": 93237,
"author": "Chris Serra",
"author_id": 13435,
"author_profile": "https://Stackoverflow.com/users/13435",
"pm_score": 0,
"selected": false,
"text": "<div>"
},
{
"answer_id": 93248,
"author": "scunliffe",
"author_id": 6144,
"author_profile": "https://Stackoverflow.com/users/6144",
"pm_score": -1,
"selected": false,
"text": "<div id=\"container\">\n <div id=\"row1\">\n <img/><img/><img/><img/>\n </div>\n <div id=\"row2\">\n <img/><img/><img/>\n </div>\n <div id=\"row3\">\n <img/><img/>\n </div>\n <div id=\"row4\">\n <img/>\n </div>\n</div>\n"
},
{
"answer_id": 93254,
"author": "Ken Ray",
"author_id": 12253,
"author_profile": "https://Stackoverflow.com/users/12253",
"pm_score": 6,
"selected": true,
"text": "{white-space: nowrap;}\n"
},
{
"answer_id": 93285,
"author": "racurry",
"author_id": 17751,
"author_profile": "https://Stackoverflow.com/users/17751",
"pm_score": 2,
"selected": false,
"text": "<div id=\"pin-images\">\n <img src=\"fivepins.jpg\" />\n <img src=\"fourpins.jpg\" />\n <img src=\"threepins.jpg\" />\n <img src=\"twopins.jpg\" />\n <img src=\"onepin.jpg\" />\n</div>\n"
},
{
"answer_id": 93403,
"author": "Mike Dimmick",
"author_id": 6970,
"author_profile": "https://Stackoverflow.com/users/6970",
"pm_score": 0,
"selected": false,
"text": "⁠"
},
{
"answer_id": 93429,
"author": "Kibbee",
"author_id": 1862,
"author_profile": "https://Stackoverflow.com/users/1862",
"pm_score": 0,
"selected": false,
"text": "<table>\n<tr>\n<td><img src=\"Pin.jpg\"></td>\n<td> </td>\n<td><img src=\"Pin.jpg\"></td>\n<td> ></td>\n<td><img src=\"Pin.jpg\"></td>\n<td> </td>\n<td><img src=\"Pin.jpg\"></td>\n</tr>\n<tr>\n<td> </td>\n<td><img src=\"Pin.jpg\"></td>\n<td> </td>\n<td><img src=\"Pin.jpg\"></td>\n<td> </td>\n<td><img src=\"Pin.jpg\"></td>\n<td> </td>\n</tr>\n<tr>\n<td> </td>\n<td> </td>\n<td><img src=\"Pin.jpg\"></td>\n<td> </td>\n<td><img src=\"Pin.jpg\"></td>\n<td> </td>\n<td> </td>\n</tr>\n<tr>\n<td> </td>\n<td> </td>\n<td> </td>\n<td><img src=\"Pin.jpg\"></td>\n<td> </td>\n<td> </td>\n<td> </td>\n</tr>\n</table>\n"
},
{
"answer_id": 93817,
"author": "Michel",
"author_id": 17316,
"author_profile": "https://Stackoverflow.com/users/17316",
"pm_score": 0,
"selected": false,
"text": "<td width=\"123px\">"
},
{
"answer_id": 94006,
"author": "Michel",
"author_id": 17316,
"author_profile": "https://Stackoverflow.com/users/17316",
"pm_score": 0,
"selected": false,
"text": "<p class=\"...\"><span class=\"pin\"></span><span> </span><span class=\"pin\"></span>...\n<p class=\"...\"><span class=\"pin\"></span><span> </span><span class=\"pin\"></span>...\n<p class=\"...\"><span class=\"pin\"></span><span> </span><span class=\"pin\"></span>...\n<p class=\"...\"><span class=\"pin\"></span><span> </span><span class=\"pin\"></span>...\n"
},
{
"answer_id": 402531,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<meta name=\"MobileOptimized\" content=\"320\">\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93171",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/96/"
] |
93,177
|
<p>Does someone know if it is possible to modify the JVM settings at runtime (e.g. -dname=value)?
I need this little trick to run my Java stored procedure (oracle 10g).</p>
|
[
{
"answer_id": 3813686,
"author": "Saber Chebka",
"author_id": 460705,
"author_profile": "https://Stackoverflow.com/users/460705",
"pm_score": 1,
"selected": false,
"text": " int times = 2;\n OracleRuntime.setMaxRunspaceSize(times *OracleRuntime.getMaxRunspaceSize());\n OracleRuntime.setSessionGCThreshold(times *OracleRuntime.getSessionGCThreshold());\n OracleRuntime.setNewspaceSize(times *OracleRuntime.getNewspaceSize());\n OracleRuntime.setMaxMemorySize(times *OracleRuntime.getMaxMemorySize());\n OracleRuntime.setJavaStackSize(times *OracleRuntime.getJavaStackSize());\n OracleRuntime.setThreadStackSize(times *OracleRuntime.getThreadStackSize());\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93177",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12703/"
] |
93,208
|
<p>I'd like to automatically generate database scripts on a regular basis. Is this possible.</p>
|
[
{
"answer_id": 93282,
"author": "Orion Adrian",
"author_id": 7756,
"author_profile": "https://Stackoverflow.com/users/7756",
"pm_score": 4,
"selected": true,
"text": "exec proc_genscript \n @ServerName = 'Server Name', \n @DBName = 'Database Name', \n @ObjectName = 'Object Name to generate script for', \n @ObjectType = 'Object Type', \n @TableName = 'Parent table name for index and trigger',\n @ScriptFile = 'File name to save the script'\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
93,214
|
<p>Given the code from the <a href="http://railscasts.com/episodes/75" rel="nofollow noreferrer">Complex Form part III</a> how would you go about testing the virtual attribute?</p>
<pre><code> def new_task_attributes=(task_attributes)
task_attributes.each do |attributes|
tasks.build(attributes)
end
end
</code></pre>
<p>I am currently trying to test it like this:</p>
<pre><code> def test_adding_task_to_project
p = Project.new
params = {"new_tasks_attributes" => [{ "name" => "paint fence"}]}
p.new_tasks_attributes=(params)
p.save
assert p.tasks.length == 1
end
</code></pre>
<p>But I am getting the following error:</p>
<blockquote>
<p>NoMethodError: undefined method `stringify_keys!' for "new_tasks_attributes":String</p>
</blockquote>
<p>Any suggestions on improving this test would be greatly appreciated.</p>
|
[
{
"answer_id": 93393,
"author": "Jason Wadsworth",
"author_id": 11078,
"author_profile": "https://Stackoverflow.com/users/11078",
"pm_score": 3,
"selected": true,
"text": "def test_adding_task_to_project\n p = Project.new\n new_tasks_attributes = [{ \"name\" => \"paint fence\"}]\n p.new_tasks_attributes = (new_tasks_attributes)\n p.save\n assert p.tasks.length == 1\nend\n"
},
{
"answer_id": 93440,
"author": "Ben Hamill",
"author_id": 9619,
"author_profile": "https://Stackoverflow.com/users/9619",
"pm_score": 0,
"selected": false,
"text": "[\"new_tasks_attribute\", {\"name\" => \"paint fence\"}]"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1681/"
] |
93,222
|
<p>I recently received an email from my girlfriend that spamassassin marked as spam, mostly because spamassassin detected a tracker ID... except there wasn't one. I'd like to know what triggered it, so that I can report a sensible bug.</p>
|
[
{
"answer_id": 93393,
"author": "Jason Wadsworth",
"author_id": 11078,
"author_profile": "https://Stackoverflow.com/users/11078",
"pm_score": 3,
"selected": true,
"text": "def test_adding_task_to_project\n p = Project.new\n new_tasks_attributes = [{ \"name\" => \"paint fence\"}]\n p.new_tasks_attributes = (new_tasks_attributes)\n p.save\n assert p.tasks.length == 1\nend\n"
},
{
"answer_id": 93440,
"author": "Ben Hamill",
"author_id": 9619,
"author_profile": "https://Stackoverflow.com/users/9619",
"pm_score": 0,
"selected": false,
"text": "[\"new_tasks_attribute\", {\"name\" => \"paint fence\"}]"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15371/"
] |
93,231
|
<p>I'm having a problem debugging an Eclipse Application from Eclipse. When I launch the Debug Configuration, the Eclipse Application starts up and then stops repeatedly. It shows the splash screen and then disappears. This is the farthest it gets before restarting:</p>
<pre><code>MyDebugConfiguration [Eclipse Application]
org.eclipse.equinox.launcher.Main at localhost:2599
Thread [main] (Running)
Daemon Thread [Signal Dispatcher] (Running)
Daemon Thread [State Data Manager] (Running)
Daemon Thread [Framework Event Dispatcher] (Running)
Thread [State Saver] (Running)
Daemon Thread [Start Level Event Dispatcher] (Running)
Thread [Refresh Packages] (Running)
C:\MyApp\eclipse\jdk\jre\bin\javaw.exe (Sep 18, 2008 9:38:19 AM)
</code></pre>
<p>I am using Version 3.4.0 of the Eclipse SDK.</p>
<p>What is causing this?</p>
|
[
{
"answer_id": 93393,
"author": "Jason Wadsworth",
"author_id": 11078,
"author_profile": "https://Stackoverflow.com/users/11078",
"pm_score": 3,
"selected": true,
"text": "def test_adding_task_to_project\n p = Project.new\n new_tasks_attributes = [{ \"name\" => \"paint fence\"}]\n p.new_tasks_attributes = (new_tasks_attributes)\n p.save\n assert p.tasks.length == 1\nend\n"
},
{
"answer_id": 93440,
"author": "Ben Hamill",
"author_id": 9619,
"author_profile": "https://Stackoverflow.com/users/9619",
"pm_score": 0,
"selected": false,
"text": "[\"new_tasks_attribute\", {\"name\" => \"paint fence\"}]"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7648/"
] |
93,260
|
<p>It looks quite easy to find such a tool for Java (<a href="http://checkstyle.sourceforge.net/" rel="noreferrer">Checkstyle</a>, <a href="http://jcsc.sourceforge.net/" rel="noreferrer">JCSC</a>), but I can't seem to find one for C/C++. I am not looking for a lint-like static code analyzer, I only would like to check against coding standards like variable naming, capitalization, spacing, identation, bracket placement, and so on.</p>
|
[
{
"answer_id": 394860,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "universalindentgui"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12291/"
] |
93,264
|
<p>I have created a foreign key (in SQL Server) by:</p>
<pre><code>alter table company add CountryID varchar(3);
alter table company add constraint Company_CountryID_FK foreign key(CountryID)
references Country;
</code></pre>
<p>I then run this query:</p>
<pre><code>alter table company drop column CountryID;
</code></pre>
<p>and I get this error:</p>
<blockquote>
<p><em>Msg 5074, Level 16, State 4, Line 2<br>
The object 'Company_CountryID_FK' is dependent on column 'CountryID'.<br>
Msg 4922, Level 16, State 9, Line 2<br>
ALTER TABLE DROP COLUMN CountryID failed because one or more objects access this column</em></p>
</blockquote>
<p>I have tried this, yet it does not seem to work:</p>
<pre><code>alter table company drop foreign key Company_CountryID_FK;
alter table company drop column CountryID;
</code></pre>
<p>What do I need to do to drop the <code>CountryID</code> column?</p>
<p>Thanks.</p>
|
[
{
"answer_id": 93292,
"author": "Mike",
"author_id": 1115144,
"author_profile": "https://Stackoverflow.com/users/1115144",
"pm_score": 9,
"selected": true,
"text": "alter table company drop constraint Company_CountryID_FK\n\n\nalter table company drop column CountryID\n"
},
{
"answer_id": 93306,
"author": "Dave Costa",
"author_id": 6568,
"author_profile": "https://Stackoverflow.com/users/6568",
"pm_score": 2,
"selected": false,
"text": "alter table company drop **constraint** Company_CountryID_FK;\n"
},
{
"answer_id": 93314,
"author": "boes",
"author_id": 17746,
"author_profile": "https://Stackoverflow.com/users/17746",
"pm_score": 4,
"selected": false,
"text": "alter table company drop constraint Company_CountryID_FK\n"
},
{
"answer_id": 93324,
"author": "Jared",
"author_id": 1980,
"author_profile": "https://Stackoverflow.com/users/1980",
"pm_score": 6,
"selected": false,
"text": "ALTER TABLE [dbo].[company] DROP CONSTRAINT [Company_CountryID_FK]\n"
},
{
"answer_id": 15638387,
"author": "Philip Wade",
"author_id": 1017395,
"author_profile": "https://Stackoverflow.com/users/1017395",
"pm_score": 1,
"selected": false,
"text": "alter table company drop constraint Company_CountryID_FK\n"
},
{
"answer_id": 20857604,
"author": "Samir Savasani",
"author_id": 2868162,
"author_profile": "https://Stackoverflow.com/users/2868162",
"pm_score": 5,
"selected": false,
"text": "DECLARE @ConstraintName nvarchar(200)\nSELECT \n @ConstraintName = KCU.CONSTRAINT_NAME\nFROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC \nINNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU\n ON KCU.CONSTRAINT_CATALOG = RC.CONSTRAINT_CATALOG \n AND KCU.CONSTRAINT_SCHEMA = RC.CONSTRAINT_SCHEMA \n AND KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME\nWHERE\n KCU.TABLE_NAME = 'TABLE_NAME' AND\n KCU.COLUMN_NAME = 'TABLE_COLUMN_NAME'\nIF @ConstraintName IS NOT NULL EXEC('alter table TABLE_NAME drop CONSTRAINT ' + @ConstraintName)\n"
},
{
"answer_id": 24214560,
"author": "Naeem Iqbal",
"author_id": 3411412,
"author_profile": "https://Stackoverflow.com/users/3411412",
"pm_score": 5,
"selected": false,
"text": "if exists (select 1 from sys.objects where name = 'Company_CountryID_FK' and type='F')\nbegin\nalter table company drop constraint Company_CountryID_FK\nend\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1638/"
] |
93,274
|
<p>What is the <em>definitive</em> way to mimic the CSS property min-width in Internet Explorer 6? Is it better not to try?</p>
|
[
{
"answer_id": 93296,
"author": "kch",
"author_id": 13989,
"author_profile": "https://Stackoverflow.com/users/13989",
"pm_score": 4,
"selected": true,
"text": "foo { min-width: 100px } // for everyone\n* html foo { width: 100px } // just for IE\n"
},
{
"answer_id": 93307,
"author": "hugoware",
"author_id": 17091,
"author_profile": "https://Stackoverflow.com/users/17091",
"pm_score": 0,
"selected": false,
"text": "div.container {\n min-width: 760px; \n width:expression(document.body.clientWidth < 760? \"760px\": \"auto\" ); \n}\n"
},
{
"answer_id": 93530,
"author": "Prestaul",
"author_id": 5628,
"author_profile": "https://Stackoverflow.com/users/5628",
"pm_score": 3,
"selected": false,
"text": "<div id=\"container\">\n The \"shim\" div will hold the container div open to at least 500px!\n You should be able to put it anywhere in the container div.\n <div class=\"shim\"> </div>\n</div>\n\n#container .shim {\n width: 500px;\n height: 0;\n line-height: 0;\n}\n"
},
{
"answer_id": 121179,
"author": "mmcglynn",
"author_id": 4241,
"author_profile": "https://Stackoverflow.com/users/4241",
"pm_score": -1,
"selected": false,
"text": "min-width: 660px;\n"
},
{
"answer_id": 1008605,
"author": "Dean Peters",
"author_id": 441512,
"author_profile": "https://Stackoverflow.com/users/441512",
"pm_score": 2,
"selected": false,
"text": " min-width: 193px;\n width:auto !important; \n _width: 193px; /* IE6 hack */\n"
},
{
"answer_id": 3415821,
"author": "Fatih Hayrioğlu",
"author_id": 296373,
"author_profile": "https://Stackoverflow.com/users/296373",
"pm_score": 0,
"selected": false,
"text": "button{\nbackground-color:#069;\nfloat:left;\nmin-width:200px;\nwidth:auto !important;\nwidth:200px;\nwhite-space: nowrap}\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4241/"
] |
93,277
|
<p>I have a rails form with a datetime_select field. When I try to submit the form, I get the following exception:</p>
<pre><code>ActiveRecord::MultiparameterAssignmentErrors in WidgetsController#update
1 error(s) on assignment of multiparameter attributes
</code></pre>
<p>If it's a validation error, why don't I see an error on the page?</p>
<p>This is in Rails 2.0.2</p>
|
[
{
"answer_id": 93327,
"author": "Jason Wadsworth",
"author_id": 11078,
"author_profile": "https://Stackoverflow.com/users/11078",
"pm_score": 5,
"selected": true,
"text": "date_select"
},
{
"answer_id": 2224752,
"author": "Zubin",
"author_id": 258826,
"author_profile": "https://Stackoverflow.com/users/258826",
"pm_score": 0,
"selected": false,
"text": "When I fill in the following:\n | report_from_1i | 2010 |\n | report_from_2i | January |\n | report_from_3i | 1 |\n | report_to_1i | 2010 |\n | report_to_2i | February |\n | report_to_3i | 1 |\n"
},
{
"answer_id": 2246545,
"author": "Lance",
"author_id": 169992,
"author_profile": "https://Stackoverflow.com/users/169992",
"pm_score": 3,
"selected": false,
"text": "date_select"
},
{
"answer_id": 2765839,
"author": "mikezter",
"author_id": 109274,
"author_profile": "https://Stackoverflow.com/users/109274",
"pm_score": 0,
"selected": false,
"text": "alias_method_chain"
},
{
"answer_id": 3952736,
"author": "nutcracker",
"author_id": 19588,
"author_profile": "https://Stackoverflow.com/users/19588",
"pm_score": 1,
"selected": false,
"text": "\"event\"=> {\n \"start_on(2i)\"=>\"October\",\n \"start_on(3i)\"=>\"19\",\n \"start_on(1i)\"=>\"2010\"\n}\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11078/"
] |
93,279
|
<p>For our online game, we have written tons of PHP classes and functions grouped by theme in files and then folders. In the end, we have now all our backend code (logic & DB access layers) in a set of files that we call <strong>libs</strong> and we include our libs in our GUI (web pages, presentation layer) using <em>include_once('pathtolib/file.inc')</em>.</p>
<p>The problem is that we have been lazy with inclusions and most include statements are made inside our libs file resulting that from each webpage, each time we include any libs file, we actually load the entire libs, file by file.</p>
<p>This has a significant impact on the performance. Therefore What would be the best solution ?</p>
<ul>
<li>Remove all include statements from the libs file and only call the necessary one from the web pages ?</li>
<li>Do something else ?</li>
</ul>
<p>Server uses a classic LAMP stack (PHP5).</p>
<p>EDIT: We have a mix of simple functions (legacy reason and the majority of the code) and classes. So autoload will not be enough.</p>
|
[
{
"answer_id": 93397,
"author": "Jonathan Arkell",
"author_id": 11052,
"author_profile": "https://Stackoverflow.com/users/11052",
"pm_score": 2,
"selected": false,
"text": "include"
},
{
"answer_id": 93458,
"author": "Marc Gear",
"author_id": 6563,
"author_profile": "https://Stackoverflow.com/users/6563",
"pm_score": 2,
"selected": false,
"text": "public static function loadClass($class)\n{\n if (class_exists($class, false) ||\n interface_exists($class, false))\n {\n return;\n }\n\n $file = YOUR_LIB_ROOT.str_replace('_', DIRECTORY_SEPARATOR, $class).'.php';\n\n if (file_exists($file))\n {\n include_once $file;\n if (!class_exists($class, false) &&\n !interface_exists($class, false))\n {\n throw new Exception('File '.$file.' was loaded but class '.$class.' was not found');\n }\n }\n}\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11670/"
] |
93,294
|
<p>So I have a nasty stack overflow I have been trying to track down / solve for the past 8 hours or so, and I'm at the point where i think i need advice. </p>
<p>The details:
Interestingly enough this code runs fine when called in the context of our regular winforms application -- but I am tasked with writing a web-based version of our software, and this same exact code causes the stack overflow when called out of an ASPX page running on IIS. The first thing I did was attach and attempt normal .NET debugging through visual studio. At the point of the exception the call stack seemed relatively shallow (about 11 frames deep, of our code), and I could find none of the usual suspects on a stack overflow (bad recursion, self-calling constructors, exception loops).</p>
<p>So I resigned myself to breaking out windbg and S.O.S. -- which i know can be useful for this sort of thing, although I had limited experience with it myself. After hours of monkeying around I think I have some useful data, but I need some help analyzing it.</p>
<p>First up is a !dumpstack I took while broken just before the stack overflow was about to come down.</p>
<pre><code>0:015> !dumpstack
PDB symbol for mscorwks.dll not loaded
OS Thread Id: 0x1110 (15)
Current frame: ntdll!KiFastSystemCallRet
ChildEBP RetAddr Caller,Callee
01d265a8 7c827d0b ntdll!NtWaitForSingleObject+0xc
01d265ac 77e61d1e kernel32!WaitForSingleObjectEx+0x88, calling ntdll!NtWaitForSingleObject
01d2661c 79e789c6 mscorwks!LogHelp_NoGuiOnAssert+0x58ca
01d26660 79e7898f mscorwks!LogHelp_NoGuiOnAssert+0x5893, calling mscorwks!LogHelp_NoGuiOnAssert+0x589b
01d26680 79e734c4 mscorwks!LogHelp_NoGuiOnAssert+0x3c8, calling mscorwks+0x17c0
01d26694 79fc1d6b mscorwks!CorExeMain+0x8724, calling kernel32!InterlockedDecrement
01d26698 79ef3892 mscorwks!GetCLRFunction+0x107de, calling mscorwks+0x17c0
01d266b0 79e78944 mscorwks!LogHelp_NoGuiOnAssert+0x5848, calling mscorwks!LogHelp_NoGuiOnAssert+0x584c
01d266c4 7a14de5d mscorwks!CorLaunchApplication+0x2f243, calling mscorwks!LogHelp_NoGuiOnAssert+0x5831
01d266ec 77e61d1e kernel32!WaitForSingleObjectEx+0x88, calling ntdll!NtWaitForSingleObject
01d266f8 77e61d43 kernel32!WaitForSingleObjectEx+0xad, calling kernel32!GetTickCount+0x73
01d26714 7c8279bb ntdll!NtSetEvent+0xc
01d26718 77e62321 kernel32!SetEvent+0x10, calling ntdll!NtSetEvent
01d26748 7a14df79 mscorwks!CorLaunchApplication+0x2f35f, calling mscorwks!CorLaunchApplication+0x2f17c
01d2675c 7a022dde mscorwks!NGenCreateNGenWorker+0x4516b, calling mscorwks!CorLaunchApplication+0x2f347
01d26770 79fbc685 mscorwks!CorExeMain+0x303e, calling mscorwks+0x1bbe
01d26788 79e734c4 mscorwks!LogHelp_NoGuiOnAssert+0x3c8, calling mscorwks+0x17c0
01d2678c 79e734f2 mscorwks!LogHelp_NoGuiOnAssert+0x3f6, calling mscorwks!LogHelp_NoGuiOnAssert+0x380
01d267a8 7a2d259e mscorwks!CreateHistoryReader+0xafd3
01d267b4 7a2e6292 mscorwks!CreateHistoryReader+0x1ecc7, calling mscorwks!CreateHistoryReader+0xaf9d
01d26814 7a064d52 mscorwks!NGenCreateNGenWorker+0x870df, calling mscorwks!CreateHistoryReader+0x1eb43
01d26854 79f91643 mscorwks!ClrCreateManagedInstance+0x46ff, calling mscorwks!ClrCreateManagedInstance+0x4720
01d2688c 79f915c4 mscorwks!ClrCreateManagedInstance+0x4680
01d268b4 79e734c4 mscorwks!LogHelp_NoGuiOnAssert+0x3c8, calling mscorwks+0x17c0
01d268cc 79f04e98 mscorwks!GetCLRFunction+0x21de4, calling mscorwks!GetCLRFunction+0x21e4b
01d26900 79f0815e mscorwks!GetCLRFunction+0x250aa, calling mscorwks!GetCLRFunction+0x21d35
01d2691c 7c858135 ntdll!RtlIpv4StringToAddressExW+0x167b7, calling ntdll!RtlReleaseResource
01d2692c 79f080a7 mscorwks!GetCLRFunction+0x24ff3, calling mscorwks!GetCLRFunction+0x25052
01d26950 7c828752 ntdll!RtlRaiseStatus+0xe0
01d26974 7c828723 ntdll!RtlRaiseStatus+0xb1, calling ntdll!RtlRaiseStatus+0xba
01d26998 7c8315c2 ntdll!RtlSubtreePredecessor+0x208, calling ntdll!RtlRaiseStatus+0x7e
01d26a1c 7c82855e ntdll!KiUserExceptionDispatcher+0xe, calling ntdll!RtlSubtreePredecessor+0x17c
01d26d20 13380333 (MethodDesc 0x10936710 +0x243 ASI.ParadigmPlus.LoadedWindows.WID904.QuestionChangeLogic(ASI.ParadigmPlus.Question, ASI.ParadigmPlus.Question)) ====> Exception Code 0 cxr@1d26a54 exr@1d26000
01d26bd8 77e64590 kernel32!VirtualAllocEx+0x4b, calling kernel32!GetTickCount+0x73
01d26bec 7c829f59 ntdll!RtlFreeHeap+0x142, calling ntdll!CIpow+0x464
01d26bf0 79e78d11 mscorwks!LogHelp_NoGuiOnAssert+0x5c15, calling ntdll!RtlFreeHeap
01d3e86c 103b4064 (MethodDesc 0xf304c90 +0x174 ASI.ParadigmPlus.Window.TrackQuestionChange(ASI.ParadigmPlus.Question, ASI.ParadigmPlus.Answer))
01d3e88c 103b4064 (MethodDesc 0xf304c90 +0x174 ASI.ParadigmPlus.Window.TrackQuestionChange(ASI.ParadigmPlus.Question, ASI.ParadigmPlus.Answer))
01d3e8b0 103b3e6b (MethodDesc 0xebb4b38 +0x23 ASI.CommonLibrary.ASIArrayList3.get_Item(Int32))
01d3e8d4 103b3d70 (MethodDesc 0xf304e98 +0x1b0 ASI.ParadigmPlus.Window.TrackQuestionChange())
01d3e910 0f90febf (MethodDesc 0xf30d250 +0x190f ASI.ParadigmPlus.Data.RemoteDataAccess.GetWindow(Int32))
01d3ec0c 10a2a572 (MethodDesc 0x10935aa0 +0x1f2 ASI.ParadigmPlus.LoadedWindowSets.WSID904.ApplyLayoutChanges()), calling 02259472
01d3ecec 0f90c880 (MethodDesc 0xebb91f8 +0xe8 ASI.ParadigmPlus.Windowset.ApplyLayoutChangesWrap())
01d3ed0c 0f90c880 (MethodDesc 0xebb91f8 +0xe8 ASI.ParadigmPlus.Windowset.ApplyLayoutChangesWrap())
01d3ed54 0f4d2388 (MethodDesc 0x22261a0 +0x5e8 WebConfigurator.NewDefault.ProductSelectedIndexChange(Int32, Int32))
01d3f264 0f4d1d7f (MethodDesc 0x2226180 +0x47 WebConfigurator.NewDefault.btnGo_Click1(System.Object, System.EventArgs)), calling (MethodDesc 0x22261a0 +0 WebConfigurator.NewDefault.ProductSelectedIndexChange(Int32, Int32))
01d3f284 0e810a05 (MethodDesc 0x22260f8 +0x145 WebConfigurator.NewDefault.Page_Load(System.Object, System.EventArgs)), calling (MethodDesc 0x2226180 +0 WebConfigurator.NewDefault.btnGo_Click1(System.Object, System.EventArgs))
01d3f2a8 793ae896 (MethodDesc 0x79256848 +0x52 System.MulticastDelegate.RemoveImpl(System.Delegate))
01d3f2ac 79e7bee8 mscorwks!LogHelp_TerminateOnAssert+0x2bd0, calling mscorwks!LogHelp_TerminateOnAssert+0x2b60
01d3f2c4 66f12980 (MethodDesc 0x66f1bcd0 +0x10 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr, System.Object, System.Object, System.EventArgs))
01d3f2d0 6628efd2 (MethodDesc 0x66474328 +0x22 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(System.Object, System.EventArgs)), calling (MethodDesc 0x66f1bcd0 +0 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr, System.Object, System.Object, System.EventArgs))
01d3f2e4 6613cb04 (MethodDesc 0x66468a58 +0x64 System.Web.UI.Control.OnLoad(System.EventArgs))
01d3f2f8 6613cb50 (MethodDesc 0x66468a60 +0x30 System.Web.UI.Control.LoadRecursive())
01d3f30c 6614e12d (MethodDesc 0x66467688 +0x59d System.Web.UI.Page.ProcessRequestMain(Boolean, Boolean))
01d3f4e0 6614c717 (MethodDesc 0x66467430 +0x63 System.Web.UI.Page.AddWrappedFileDependencies(System.Object)), calling (MethodDesc 0x66478de8 +0 System.Web.ResponseDependencyList.AddDependencies(System.String[], System.String, Boolean, System.String))
01d3f504 6614d8c3 (MethodDesc 0x66467650 +0x67 System.Web.UI.Page.ProcessRequest(Boolean, Boolean)), calling (MethodDesc 0x66467688 +0 System.Web.UI.Page.ProcessRequestMain(Boolean, Boolean))
01d3f528 79371311 (MethodDesc 0x7925ac80 +0x25 System.Globalization.CultureInfo.get_UserDefaultUICulture()), calling (JitHelp: CORINFO_HELP_GETSHARED_GCSTATIC_BASE)
01d3f53c 6614d80f (MethodDesc 0x66467648 +0x57 System.Web.UI.Page.ProcessRequest()), calling (MethodDesc 0x66467650 +0 System.Web.UI.Page.ProcessRequest(Boolean, Boolean))
01d3f560 6615055c (MethodDesc 0x664676f0 +0x184 System.Web.UI.Page.SetIntrinsics(System.Web.HttpContext, Boolean)), calling (MethodDesc 0x664726b0 +0 System.Web.UI.TemplateControl.HookUpAutomaticHandlers())
01d3f578 6614d72f (MethodDesc 0x66467630 +0x13 System.Web.UI.Page.ProcessRequestWithNoAssert(System.Web.HttpContext)), calling (MethodDesc 0x66467648 +0 System.Web.UI.Page.ProcessRequest())
01d3f580 6614d6c2 (MethodDesc 0x66467620 +0x32 System.Web.UI.Page.ProcessRequest(System.Web.HttpContext)), calling (MethodDesc 0x66467630 +0 System.Web.UI.Page.ProcessRequestWithNoAssert(System.Web.HttpContext))
01d3f594 0e810206 (MethodDesc 0x22265a0 +0x1e ASP.newdefault_aspx.ProcessRequest(System.Web.HttpContext)), calling (MethodDesc 0x66467620 +0 System.Web.UI.Page.ProcessRequest(System.Web.HttpContext))
01d3f5a0 65fe6bfb (MethodDesc 0x66470fc0 +0x167 System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()), calling 01dee5da
01d3f5d4 65fe3f51 (MethodDesc 0x6642f090 +0x41 System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)), calling 01de7d0a
01d3f610 65fe7733 (MethodDesc 0x66470cd0 +0x1b3 System.Web.HttpApplication+ApplicationStepManager.ResumeSteps(System.Exception)), calling (MethodDesc 0x6642f090 +0 System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef))
01d3f64c 7939eef2 (MethodDesc 0x7925eda8 +0x26 System.Runtime.InteropServices.GCHandle.Alloc(System.Object)), calling mscorwks!InstallCustomModule+0x1e8d
01d3f664 65fccbfe (MethodDesc 0x6642ebb0 +0x8e System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(System.Web.HttpContext, System.AsyncCallback, System.Object))
01d3f678 65fd19c5 (MethodDesc 0x6642cde8 +0x1b5 System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest)), calling 01de7cba
01d3f69c 7938111c (MethodDesc 0x79262df0 +0xc System.DateTime.get_UtcNow()), calling mscorwks!GetCLRFunction+0x109f9
01d3f6a4 01c32cbc 01c32cbc, calling 01daa248
01d3f6b4 65fd16b2 (MethodDesc 0x664619e0 +0x62 System.Web.HttpRuntime.ProcessRequestNoDemand(System.Web.HttpWorkerRequest)), calling (MethodDesc 0x6642cde8 +0 System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest))
01d3f6c0 65fcfa6d (MethodDesc 0x6642d4a0 +0xfd System.Web.Hosting.ISAPIRuntime.ProcessRequest(IntPtr, Int32)), calling (MethodDesc 0x664619e0 +0 System.Web.HttpRuntime.ProcessRequestNoDemand(System.Web.HttpWorkerRequest))
01d3f6d8 65fcf9f4 (MethodDesc 0x6642d4a0 +0x84 System.Web.Hosting.ISAPIRuntime.ProcessRequest(IntPtr, Int32)), calling *** ERROR: Symbol file could not be found. Defaulted to export symbols for \\?\C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\webengine.dll -
webengine!GetEcb
01d3f710 79f047fd mscorwks!GetCLRFunction+0x21749
01d3f720 01c32cbc 01c32cbc, calling 01daa248
01d3f730 79f047fd mscorwks!GetCLRFunction+0x21749
01d3f75c 79f01621 mscorwks!GetCLRFunction+0x1e56d, calling mscorwks+0x1b86
01d3f770 79ef98cf mscorwks!GetCLRFunction+0x1681b, calling mscorwks!GetCLRFunction+0x1682f
01d3f7d0 79e74f98 mscorwks!LogHelp_NoGuiOnAssert+0x1e9c, calling mscorwks!LogHelp_NoGuiOnAssert+0x1ec1
01d3f7e8 79f0462c mscorwks!GetCLRFunction+0x21578, calling mscorwks!GetCLRFunction+0x215b0
01d3f7f8 01c32cbc 01c32cbc, calling 01daa248
01d3f844 79f044fa mscorwks!GetCLRFunction+0x21446, calling mscorwks!GetCLRFunction+0x21541
01d3f854 01c32cbc 01c32cbc, calling 01daa248
01d3f898 660167e9 (MethodDesc 0x6646f6b0 +0x5 System.Web.RequestQueue.TimerCompletionCallback(System.Object)), calling (MethodDesc 0x6646f698 +0 System.Web.RequestQueue.ScheduleMoreWorkIfNeeded())
01d3f89c 793af6c6 (MethodDesc 0x792672b0 +0x1a System.Threading._TimerCallback.TimerCallback_Context(System.Object))
01d3f8b4 793af647 (MethodDesc 0x7914fc18 +0x5b System.Threading._TimerCallback.PerformTimerCallback(System.Object)), calling (MethodDesc 0x7914e0d8 +0 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object))
01d3f8b8 793af654 (MethodDesc 0x7914fc18 +0x68 System.Threading._TimerCallback.PerformTimerCallback(System.Object)), calling mscorwks!LogHelp_TerminateOnAssert
01d3f8f8 79e74466 mscorwks!LogHelp_NoGuiOnAssert+0x136a, calling mscorwks+0x1813
01d3f8fc 79e7c709 mscorwks!LogHelp_TerminateOnAssert+0x33f1, calling mscorwks!LogHelp_NoGuiOnAssert+0x1360
01d3f964 7c829f3d ntdll!RtlFreeHeap+0x126, calling ntdll!RtlGetNtGlobalFlags+0x12
01d3f96c 7c829f59 ntdll!RtlFreeHeap+0x142, calling ntdll!CIpow+0x464
01d3f9ac 6a2a9998 webengine!CSharelock::ChangeExclusiveLockToSharedLock+0x2d, calling kernel32!InterlockedCompareExchange
01d3f9b4 6a2ab03b webengine!EcbGetUnicodeServerVariables+0x3d5, calling kernel32!InterlockedIncrement
01d3f9f4 01c32cbc 01c32cbc, calling 01daa248
01d3fa28 01daa295 01daa295, calling mscorwks!GetCLRFunction+0x2119e
01d3fa50 6a2aa63f webengine!CookieAuthConstructTicket+0x232
01d3fa6c 01c32cbc 01c32cbc, calling 01daa248
01d3fa70 6a2aa63f webengine!CookieAuthConstructTicket+0x232
01d3fac8 79e734c4 mscorwks!LogHelp_NoGuiOnAssert+0x3c8, calling mscorwks+0x17c0
01d3facc 79e734f2 mscorwks!LogHelp_NoGuiOnAssert+0x3f6, calling mscorwks!LogHelp_NoGuiOnAssert+0x380
01d3fad8 79f00c03 mscorwks!GetCLRFunction+0x1db4f, calling mscorwks!LogHelp_NoGuiOnAssert+0xf0
01d3fadc 79e71b90 mscorwks+0x1b90, calling mscorwks+0x1813
01d3fae0 79f00c0b mscorwks!GetCLRFunction+0x1db57, calling mscorwks+0x1b86
01d3fb1c 79ef30c3 mscorwks!GetCLRFunction+0x1000f, calling mscorwks!GetCLRFunction+0x10040
01d3fb64 79f00c0b mscorwks!GetCLRFunction+0x1db57, calling mscorwks+0x1b86
01d3fb68 79f02a93 mscorwks!GetCLRFunction+0x1f9df, calling mscorwks!GetCLRFunction+0x1d8e5
01d3fb70 79e71b90 mscorwks+0x1b90, calling mscorwks+0x1813
01d3fb74 79f02aa7 mscorwks!GetCLRFunction+0x1f9f3, calling mscorwks+0x1b86
01d3fb88 79f00e8d mscorwks!GetCLRFunction+0x1ddd9, calling mscorwks+0x18bb
01d3fb8c 79f00f03 mscorwks!GetCLRFunction+0x1de4f, calling mscorwks!GetCLRFunction+0x1dd84
01d3fbc0 79f02978 mscorwks!GetCLRFunction+0x1f8c4, calling mscorwks!GetCLRFunction+0x1de1a
01d3fbfc 79e73220 mscorwks!LogHelp_NoGuiOnAssert+0x124, calling (JitHelp: CORINFO_HELP_GET_THREAD)
01d3fc08 79ef2884 mscorwks!GetCLRFunction+0xf7d0, calling mscorwks!LogHelp_NoGuiOnAssert+0x118
01d3fc0c 79ef28ab mscorwks!GetCLRFunction+0xf7f7, calling mscorwks+0x17c0
01d3fc24 79e7904f mscorwks!LogHelp_NoGuiOnAssert+0x5f53, calling mscorwks+0x1b95
01d3fc38 79ef31ca mscorwks!GetCLRFunction+0x10116, calling mscorwks!LogHelp_NoGuiOnAssert+0x5f3d
01d3fc3c 79e71b90 mscorwks+0x1b90, calling mscorwks+0x1813
01d3fc40 79ef31d9 mscorwks!GetCLRFunction+0x10125, calling mscorwks+0x1b86
01d3fc90 7c829fb5 ntdll!RtlGetNtGlobalFlags+0x38, calling ntdll!ExpInterlockedPopEntrySListEnd+0x11
01d3fc94 7c827d0b ntdll!NtWaitForSingleObject+0xc
01d3fc98 77e61d1e kernel32!WaitForSingleObjectEx+0x88, calling ntdll!NtWaitForSingleObject
01d3fca4 77e61d43 kernel32!WaitForSingleObjectEx+0xad, calling kernel32!GetTickCount+0x73
01d3fdb4 6a2aa748 webengine!CookieAuthConstructTicket+0x33b, calling webengine!CookieAuthConstructTicket+0x11d
01d3fdc4 6a2aa715 webengine!CookieAuthConstructTicket+0x308
01d3fddc 79f024cf mscorwks!GetCLRFunction+0x1f41b
01d3fdf4 79ef3a3f mscorwks!GetCLRFunction+0x1098b, calling mscorwks+0x17c0
01d3fe28 79f0202a mscorwks!GetCLRFunction+0x1ef76
01d3fe3c 79f021a0 mscorwks!GetCLRFunction+0x1f0ec, calling mscorwks!GetCLRFunction+0x1eef9
01d3fe94 79fc9840 mscorwks!CorExeMain+0x101f9
01d3ffa4 79fc982e mscorwks!CorExeMain+0x101e7, calling mscorwks!LogHelp_NoGuiOnAssert+0x61c0
01d3ffb8 77e64829 kernel32!GetModuleHandleA+0xdf
</code></pre>
<p>Lot of stuff there, but nothing that in my (admittedly limited) stack analyzing knowledge indicates looping. I think this next section might have some value however. This is a !dumpstackobjects I got at the same breakpoint:</p>
<pre><code>0:000> ~16e !dumpstackobjects
OS Thread Id: 0x172c (16)
ESP/REG Object Name
01d0ee30 0295ef60 ASI.ParadigmPlus.LoadedWindows.WID904
01d0ef68 0295ef60 ASI.ParadigmPlus.LoadedWindows.WID904
01d0ef6c 0295ef60 ASI.ParadigmPlus.LoadedWindows.WID904
01d0ef74 0295ef60 ASI.ParadigmPlus.LoadedWindows.WID904
01d0f280 0295f810 ASI.ParadigmPlus.Question
01d0f284 0295ef60 ASI.ParadigmPlus.LoadedWindows.WID904
01d26cec 02fdb36c ASI.ParadigmPlus.GrilleApp.GA1000
01d26cf0 0295f674 ASI.ParadigmPlus.QuestionList
01d26cf4 0295ef60 ASI.ParadigmPlus.LoadedWindows.WID904
01d26cf8 02fdb36c ASI.ParadigmPlus.GrilleApp.GA1000
01d26cfc 0295f810 ASI.ParadigmPlus.Question
01d26d00 0295f810 ASI.ParadigmPlus.Question
01d26d08 0295f810 ASI.ParadigmPlus.Question
01d26d30 06c3a958 System.String SP1:SP1
01d26d40 029c232c System.String TNE:TNE
01d26d50 06c3a958 System.String SP1:SP1
01d26d54 029c232c System.String TNE:TNE
01d26d60 029c232c System.String TNE:TNE
01d26d78 06c3a958 System.String SP1:SP1
01d26d7c 06c3a958 System.String SP1:SP1
01d26d84 06c3a958 System.String SP1:SP1
01d26da4 06c357a0 System.String SB1:SB1
01d26da8 06c357a0 System.String SB1:SB1
01d26db0 06c3a958 System.String SP1:SP1
01d26db4 06ba3d08 System.String WHT:WHT
01d26db8 06b987c8 System.String WHT:WHT
01d26dbc 06b8aa10 System.String WF:WF
01d26dc0 029fab00 System.String L:L
01d26dc4 06c3a958 System.String SP1:SP1
01d26dc8 06c4a518 System.String S000:S000
01d26dd4 06c4a518 System.String S000:S000
01d26dd8 0296b404 ASI.ParadigmPlus.Question
01d26ddc 0296a00c ASI.ParadigmPlus.Question
01d26de0 02968a90 ASI.ParadigmPlus.Question
01d26de4 02966af8 ASI.ParadigmPlus.Question
01d26de8 06be6e1c ASI.ParadigmPlus.Answer
01d26dec 06c357a0 System.String SB1:SB1
01d26df0 029fab00 System.String L:L
01d26df4 0295fa54 ASI.ParadigmPlus.QuestionGroup
01d26df8 02963f80 ASI.ParadigmPlus.QuestionGroup
01d26dfc 029662fc ASI.ParadigmPlus.QuestionGroup
01d26e00 02961cb4 ASI.ParadigmPlus.QuestionGroup
01d26e0c 0295f810 ASI.ParadigmPlus.Question
01d26e10 0295ef60 ASI.ParadigmPlus.LoadedWindows.WID904
01d270d4 06c38ddc ASI.ParadigmPlus.Answer
01d270dc 06c4bc0c ASI.ParadigmPlus.Dimension
01d270e0 06c4b99c ASI.ParadigmPlus.DimensionList
01d27104 029607f8 ASI.ParadigmPlus.Question
01d27108 0295fa80 ASI.ParadigmPlus.QuestionList
01d27118 06c38e74 System.String 5:5
01d2711c 02960564 ASI.ParadigmPlus.Question
01d27120 0295fa80 ASI.ParadigmPlus.QuestionList
01d2781c 029fac84 ASI.ParadigmPlus.Answer
01d27820 02960464 ASI.ParadigmPlus.AnswerList
01d27824 029fcbd8 ASI.ParadigmPlus.Answer
01d27828 02960464 ASI.ParadigmPlus.AnswerList
01d2782c 029fca28 ASI.ParadigmPlus.Answer
01d27830 02960464 ASI.ParadigmPlus.AnswerList
01d27844 029faa84 ASI.ParadigmPlus.Answer
01d2784c 06c38e74 System.String 5:5
01d27850 02960564 ASI.ParadigmPlus.Question
01d27854 0295fa80 ASI.ParadigmPlus.QuestionList
01d27860 06c38e74 System.String 5:5
01d27864 02960564 ASI.ParadigmPlus.Question
01d27868 0295fa80 ASI.ParadigmPlus.QuestionList
01d27870 06c38e74 System.String 5:5
01d27874 02960564 ASI.ParadigmPlus.Question
01d27878 0295fa80 ASI.ParadigmPlus.QuestionList
01d2787c 029faa84 ASI.ParadigmPlus.Answer
01d27880 02960464 ASI.ParadigmPlus.AnswerList
01d27884 029fab84 ASI.ParadigmPlus.Answer
01d27888 02960464 ASI.ParadigmPlus.AnswerList
01d27974 02960e80 ASI.ParadigmPlus.Question
01d27978 0295fa80 ASI.ParadigmPlus.QuestionList
01d27bd0 06c3a8dc ASI.ParadigmPlus.Answer
01d27c08 06c3b924 ASI.ParadigmPlus.Answer
01d27c0c 02960f44 ASI.ParadigmPlus.AnswerList
01d27c10 06c3b860 ASI.ParadigmPlus.Answer
01d27c14 02960f44 ASI.ParadigmPlus.AnswerList
01d27c18 06c3ac90 ASI.ParadigmPlus.Answer
01d27c1c 02960f44 ASI.ParadigmPlus.AnswerList
01d27c20 06c3abcc ASI.ParadigmPlus.Answer
01d27c24 02960f44 ASI.ParadigmPlus.AnswerList
01d27c28 06c3ab08 ASI.ParadigmPlus.Answer
01d27c2c 02960f44 ASI.ParadigmPlus.AnswerList
01d27c30 06c3aa44 ASI.ParadigmPlus.Answer
01d27c34 02960f44 ASI.ParadigmPlus.AnswerList
01d27c38 06c3b4dc ASI.ParadigmPlus.Answer
01d27c3c 02960f44 ASI.ParadigmPlus.AnswerList
01d27c40 06c3a990 ASI.ParadigmPlus.Answer
01d27c44 02960f44 ASI.ParadigmPlus.AnswerList
01d27c48 06c3a8dc ASI.ParadigmPlus.Answer
01d27c4c 02960f44 ASI.ParadigmPlus.AnswerList
01d27c6c 02960e80 ASI.ParadigmPlus.Question
01d27c70 0295fa80 ASI.ParadigmPlus.QuestionList
01d27e04 029628d0 ASI.ParadigmPlus.Question
01d27e08 02961ce0 ASI.ParadigmPlus.QuestionList
01d27e28 029628d0 ASI.ParadigmPlus.Question
01d27e2c 02961ce0 ASI.ParadigmPlus.QuestionList
01d27f14 06b89804 ASI.ParadigmPlus.Answer
01d27f18 02962994 ASI.ParadigmPlus.AnswerList
01d27f1c 029628d0 ASI.ParadigmPlus.Question
01d27f20 02961ce0 ASI.ParadigmPlus.QuestionList
01d27f38 06c38e74 System.String 5:5
01d27f3c 02960564 ASI.ParadigmPlus.Question
01d27f40 0295fa80 ASI.ParadigmPlus.QuestionList
01d27f4c 06c38e74 System.String 5:5
01d27f50 02960564 ASI.ParadigmPlus.Question
01d27f54 0295fa80 ASI.ParadigmPlus.QuestionList
01d27f60 06c38e74 System.String 5:5
01d27f64 02960564 ASI.ParadigmPlus.Question
01d27f68 0295fa80 ASI.ParadigmPlus.QuestionList
01d27f88 06b89964 ASI.ParadigmPlus.Answer
01d27f8c 029628d0 ASI.ParadigmPlus.Question
01d27f90 02961ce0 ASI.ParadigmPlus.QuestionList
01d27fa8 06c4b34c System.String FDIA:FDIA
01d27fac 0295fd84 ASI.ParadigmPlus.Question
01d27fb0 0295fa80 ASI.ParadigmPlus.QuestionList
01d27fb4 06b896dc ASI.ParadigmPlus.Answer
01d27fb8 02962994 ASI.ParadigmPlus.AnswerList
01d27fbc 029628d0 ASI.ParadigmPlus.Question
01d27fc0 02961ce0 ASI.ParadigmPlus.QuestionList
01d27fc8 029fab00 System.String L:L
01d27fcc 029603a0 ASI.ParadigmPlus.Question
01d27fd0 0295fa80 ASI.ParadigmPlus.QuestionList
01d27fd4 06b89964 ASI.ParadigmPlus.Answer
01d27fd8 02962994 ASI.ParadigmPlus.AnswerList
01d27fdc 029628d0 ASI.ParadigmPlus.Question
01d27fe0 02961ce0 ASI.ParadigmPlus.QuestionList
01d27fe4 029628d0 ASI.ParadigmPlus.Question
01d27fe8 02961ce0 ASI.ParadigmPlus.QuestionList
01d28610 06b987c8 System.String WHT:WHT
01d28614 02961dd8 ASI.ParadigmPlus.Question
01d28618 02961ce0 ASI.ParadigmPlus.QuestionList
01d2872c 06ba3d08 System.String WHT:WHT
01d28730 029621f0 ASI.ParadigmPlus.Question
01d28734 02961ce0 ASI.ParadigmPlus.QuestionList
01d28778 029f1d94 ASI.ParadigmPlus.Answer
01d2877c 02963c14 ASI.ParadigmPlus.AnswerList
01d28780 06c37884 ASI.ParadigmPlus.Answer
01d28784 02963c14 ASI.ParadigmPlus.AnswerList
01d28788 06c379cc ASI.ParadigmPlus.Answer
01d2878c 02963c14 ASI.ParadigmPlus.AnswerList
01d28790 06c36798 ASI.ParadigmPlus.Answer
01d28794 02963c14 ASI.ParadigmPlus.AnswerList
01d28798 06c36510 ASI.ParadigmPlus.Answer
01d2879c 02963c14 ASI.ParadigmPlus.AnswerList
01d287a0 06c36648 ASI.ParadigmPlus.Answer
01d287a4 02963c14 ASI.ParadigmPlus.AnswerList
01d287ac 06c37a78 System.String Custom Paint
01d287b0 06c379cc ASI.ParadigmPlus.Answer
01d287b8 072eb468 System.Collections.ArrayList+ArrayListEnumeratorSimple
01d287bc 02963c14 ASI.ParadigmPlus.AnswerList
01d289dc 029640b8 ASI.ParadigmPlus.Question
01d289e0 02963fac ASI.ParadigmPlus.QuestionList
01d28a38 029f13f4 System.String Venting Sidelite Locking System
01d28a3c 029f1390 ASI.ParadigmPlus.Answer
01d28a44 072f0568 System.Collections.ArrayList+ArrayListEnumeratorSimple
01d28a48 0296417c ASI.ParadigmPlus.AnswerList
01d28a60 06c356f4 ASI.ParadigmPlus.Answer
01d28a68 06c4a518 System.String S000:S000
01d28a6c 0295ffec ASI.ParadigmPlus.Question
01d28a70 0295fa80 ASI.ParadigmPlus.QuestionList
01d28a7c 06c4a518 System.String S000:S000
01d28a80 0295ffec ASI.ParadigmPlus.Question
01d28a84 0295fa80 ASI.ParadigmPlus.QuestionList
01d28a90 0295f768 System.String CustItemNumber
01d28a98 06c4b34c System.String FDIA:FDIA
01d28a9c 0295fd84 ASI.ParadigmPlus.Question
01d28aa0 0295fa80 ASI.ParadigmPlus.QuestionList
01d28aa4 029ecd64 ASI.ParadigmPlus.Answer
01d28aa8 0296417c ASI.ParadigmPlus.AnswerList
01d28aac 029e95ac ASI.ParadigmPlus.Answer
01d28ab0 0296417c ASI.ParadigmPlus.AnswerList
01d28ab8 029f13f4 System.String Venting Sidelite Locking System
01d28abc 029f1390 ASI.ParadigmPlus.Answer
01d28ac4 072ef574 System.Collections.ArrayList+ArrayListEnumeratorSimple
01d28ac8 0296417c ASI.ParadigmPlus.AnswerList
01d28acc 029f1230 ASI.ParadigmPlus.Answer
01d28ad0 0296417c ASI.ParadigmPlus.AnswerList
01d28f4c 02961798 ASI.ParadigmPlus.Question
01d28f50 0295fa80 ASI.ParadigmPlus.QuestionList
01d2903c 0296466c ASI.ParadigmPlus.Question
01d29040 02963fac ASI.ParadigmPlus.QuestionList
01d290cc 06c07914 System.String C:C
01d290d0 02964268 ASI.ParadigmPlus.Question
01d290d4 02963fac ASI.ParadigmPlus.QuestionList
01d29144 06c30604 ASI.ParadigmPlus.Answer
01d29148 02964730 ASI.ParadigmPlus.AnswerList
01d2914c 0296466c ASI.ParadigmPlus.Question
01d29150 02963fac ASI.ParadigmPlus.QuestionList
01d29154 06c0f9d8 ASI.ParadigmPlus.Answer
01d29158 0296450c ASI.ParadigmPlus.AnswerList
01d2915c 02964448 ASI.ParadigmPlus.Question
01d29160 02963fac ASI.ParadigmPlus.QuestionList
01d29164 02964268 ASI.ParadigmPlus.Question
01d29168 02963fac ASI.ParadigmPlus.QuestionList
01d2991c 029d6c7c System.String 021022
01d29928 029d6c7c System.String 021022
01d29934 029d6c7c System.String 021022
01d29938 029d5700 ASI.ParadigmPlus.Answer
01d2993c 0296450c ASI.ParadigmPlus.AnswerList
01d29940 029d6bdc ASI.ParadigmPlus.Answer
01d29944 0296450c ASI.ParadigmPlus.AnswerList
01d29948 02964448 ASI.ParadigmPlus.Question
01d2994c 02963fac ASI.ParadigmPlus.QuestionList
01d2f908 06c4b34c System.String FDIA:FDIA
01d2f90c 0295fd84 ASI.ParadigmPlus.Question
01d2f910 0295fa80 ASI.ParadigmPlus.QuestionList
01d2ffd0 02964c28 ASI.ParadigmPlus.Question
01d2ffd4 02963fac ASI.ParadigmPlus.QuestionList
01d2ffe4 06c32030 System.String SB:SB
01d2ffe8 02964a54 ASI.ParadigmPlus.Question
01d2ffec 02963fac ASI.ParadigmPlus.QuestionList
01d2fffc 06c3368c ASI.ParadigmPlus.Answer
01d30000 02964b18 ASI.ParadigmPlus.AnswerList
01d30004 02964a54 ASI.ParadigmPlus.Question
01d30008 02963fac ASI.ParadigmPlus.QuestionList
01d3000c 02964a54 ASI.ParadigmPlus.Question
01d30010 02963fac ASI.ParadigmPlus.QuestionList
01d30144 06c32030 System.String SB:SB
01d30148 02964a54 ASI.ParadigmPlus.Question
01d3014c 02963fac ASI.ParadigmPlus.QuestionList
01d30154 06c31f90 ASI.ParadigmPlus.Answer
01d3015c 06c344d8 System.String (COM) Lifetime Brass
01d30160 06c34418 ASI.ParadigmPlus.Answer
01d30168 072f16a0 System.Collections.ArrayList+ArrayListEnumeratorSimple
01d3016c 02964b18 ASI.ParadigmPlus.AnswerList
01d30174 06c31f90 ASI.ParadigmPlus.Answer
01d30178 06c34294 ASI.ParadigmPlus.Answer
01d3017c 02964b18 ASI.ParadigmPlus.AnswerList
01d30180 06c33e48 ASI.ParadigmPlus.Answer
01d30184 02964b18 ASI.ParadigmPlus.AnswerList
01d30188 06c32e6c ASI.ParadigmPlus.Answer
01d3018c 02964b18 ASI.ParadigmPlus.AnswerList
01d30190 06c32b78 ASI.ParadigmPlus.Answer
01d30194 02964b18 ASI.ParadigmPlus.AnswerList
</code></pre>
<p>^^ I had to cut off some of the above to make this post fit, but imagine it keeps going like that ^^</p>
<p>Please ignore the details of our custom code. All this seems excessive to me, but I am no expert at the stack. Most of those stack objects listed above (there are 1500+) are not function paramteters, so I would think they do not belong there. Here is an example of the kind of code that is generating all those items on the stack (tons of code like this is run):</p>
<pre><code>gUnitType.Questions("French Door Style").CommonLogicValue = CommonLogicValues.AlwaysDisplay
gUnitType.Questions("French Door Style").ShowAllAnswers()
If Me.NumberOfUnits > 1 Then
Me.Dimensions("Call Size Height").Answers("6-8 Handicap sill").Visible = False
Me.Dimensions("Call Size Height").Answers("6-10 Handicap Sill").Visible = False
Me.Dimensions("Call Size Height").Answers("7-0 Handicap Sill").Visible = False
Me.Dimensions("Call Size Height").Answers("8-0 Handicap Sill").Visible = False
End If
</code></pre>
<p>I am also no expert on VB (this code is from a different part of our application I do not normally work with), but is it normal for code like this to be filling up the stack with stuff? If anyone has any insight, or could even just point me in the direction of some resources with info about this kind of stuff, it would be greatly appreciated. Thanks for looking!</p>
|
[
{
"answer_id": 93367,
"author": "Mike Dimmick",
"author_id": 6970,
"author_profile": "https://Stackoverflow.com/users/6970",
"pm_score": 1,
"selected": false,
"text": "_NT_SYMBOL_PATH"
},
{
"answer_id": 107682,
"author": "sachaa",
"author_id": 1152057,
"author_profile": "https://Stackoverflow.com/users/1152057",
"pm_score": 0,
"selected": false,
"text": "ASI.ParadigmPlus.LoadedWindows.WID904.QuestionChangeLogic\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93294",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17784/"
] |
93,335
|
<p>Does anyone know of a good tool to generate the WSDL for a service contract written in C# (i.e. set of methods that are tagged as "[OperationContract]" using WCF)? All the tools I've found work the other way around: create code stubs from a WSDL. I don't want to have to hand-jam a WSDL file. I've found tools for php and J2EE, but not C#. Thanks!</p>
|
[
{
"answer_id": 97199,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": true,
"text": "<configuration><services>"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59910/"
] |
93,353
|
<p>I need to make a random list of permutations. The elements can be anything but assume that they are the integers 0 through x-1. I want to make y lists, each containing z elements. The rules are that no list may contain the same element twice and that over all the lists, the number of times each elements is used is the same (or as close as possible). For instance, if my elements are 0,1,2,3, y is 6, and z is 2, then one possible solution is:</p>
<pre>
0,3
1,2
3,0
2,1
0,1
2,3
</pre>
<p>Each row has only unique elements and no element has been used more than 3 times. If y were 7, then 2 elements would be used 4 times, the rest 3.</p>
|
[
{
"answer_id": 95138,
"author": "Terhorst",
"author_id": 8062,
"author_profile": "https://Stackoverflow.com/users/8062",
"pm_score": 3,
"selected": true,
"text": "import math, random\n\n\ndef get_pool(items, y, z):\n slots = y*z\n\n use_each_times = slots/len(items)\n exceptions = slots - use_each_times*len(items)\n\n\n if (use_each_times > y or\n exceptions > 0 and use_each_times+1 > y):\n raise Exception(\"Impossible.\")\n\n\n pool = {}\n for n in items:\n pool[n] = use_each_times\n\n for n in random.sample(items, exceptions):\n pool[n] += 1\n\n return pool\n\ndef rebalance(ret, pool, z):\n max_item = None\n max_times = None\n\n for item, times in pool.items():\n if times > max_times:\n max_item = item\n max_times = times\n\n\n next, times = max_item, max_times\n\n candidates = []\n for i in range(len(ret)):\n item = ret[i]\n\n if next not in item:\n candidates.append( (item, i) )\n\n\n swap, swap_index = random.choice(candidates)\n\n swapi = []\n for i in range(len(swap)):\n if swap[i] not in pool:\n swapi.append( (swap[i], i) )\n\n\n which, i = random.choice(swapi)\n\n pool[next] -= 1\n pool[swap[i]] = 1\n swap[i] = next\n\n ret[swap_index] = swap\n\ndef plist(items, y, z):\n pool = get_pool(items, y, z)\n\n ret = []\n while len(pool.keys()) > 0:\n while len(pool.keys()) < z:\n rebalance(ret, pool, z)\n\n selections = random.sample(pool.keys(), z)\n\n for i in selections:\n pool[i] -= 1\n if pool[i] == 0:\n del pool[i]\n\n ret.append( selections )\n\n return ret\n\n\nprint plist([0,1,2,3], 6, 2)\n"
},
{
"answer_id": 1923768,
"author": "Trevoke",
"author_id": 234025,
"author_profile": "https://Stackoverflow.com/users/234025",
"pm_score": 0,
"selected": false,
"text": "# list is the elements to be permuted\n# y is the number of results desired\n# z is the number of elements per result\n# equalizer keeps track of who got used how many times\ndef constrained_permutations list, y, z\n list.uniq! # Never trust the user. We want no repetitions.\n equalizer = {}\n list.each { |element| equalizer[element] = 0 }\n\n results = []\n # Do this until we get as many results as desired\n while results.size < y\n pool = []\n puts pool\n least_used = equalizer.each_value.min\n # Find how used the least used element was\n while pool.size < z\n # Do this until we have enough elements in this resultset\n element = nil\n while element.nil?\n # If we run out of \"least used elements\", then we need to increment\n # our definition of \"least used\" by 1 and keep going.\n element = list.shuffle.find do |x|\n !pool.include?(x) && equalizer[x] == least_used\n end\n least_used += 1 if element.nil?\n end\n equalizer[element] += 1\n # This element has now been used one more time.\n pool << element\n end\n results << pool\n end\n return results\nend\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4454/"
] |
93,357
|
<p><strong>I want to read the contents of a URL but don't want to "hang" if the URL is unresponsive. I've created a BufferedReader using the URL...</strong></p>
<pre><code>URL theURL = new URL(url);
URLConnection urlConn = theURL.openConnection();
urlConn.setDoOutput(true);
BufferedReader urlReader = new BufferedReader(newInputStreamReader(urlConn.getInputStream()));
</code></pre>
<p><strong>...and then begun the loop to read the contents...</strong></p>
<pre><code>do
{
buf = urlReader.readLine();
if (buf != null)
{
resultBuffer.append(buf);
resultBuffer.append("\n");
}
}
while (buf != null);
</code></pre>
<p><strong>...but if the read hangs then the application hangs.</strong></p>
<p><strong>Is there a way, without grinding the code down to the socket level, to "time out" the read if necessary?</strong></p>
|
[
{
"answer_id": 93589,
"author": "Javaxpert",
"author_id": 15241,
"author_profile": "https://Stackoverflow.com/users/15241",
"pm_score": 2,
"selected": false,
"text": "URLConnection.setConnectTimeout(int timeout)"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13930/"
] |
93,361
|
<p>We're testing our ClickOnce deployed application internally on IIS (Internet Information Services), but we're wondering if we can deploy it to the wider internet using Apache on Linux so we can make use of our existing external website host.</p>
<p>If so, is there anything else I need to consider other than as specifying the correct mime types such as <code>.application</code> and <code>.deploy</code>?</p>
|
[
{
"answer_id": 382083,
"author": "Don Kirkby",
"author_id": 4794,
"author_profile": "https://Stackoverflow.com/users/4794",
"pm_score": 3,
"selected": false,
"text": "AddType application/x-ms-application .application\nAddType application/manifest .manifest\nAddType application/octet-stream .deploy\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5662/"
] |
93,408
|
<p>I saw some code like the following in a JSP</p>
<pre><code><c:if test="<%=request.isUserInRole(RoleEnum.USER.getCode())%>">
<li>user</li>
</c:if>
</code></pre>
<p>My confusion is over the "=" that appears in the value of the <code>test</code> attribute. My understanding was that anything included within <code><%= %></code> is printed to the output, but surely the value assigned to test must be a Boolean, so why does this work?</p>
<p>For bonus points, is there any way to change the attribute value above such that it does not use scriptlet code? Presumably, that means using EL instead.</p>
<p>Cheers,
Don</p>
|
[
{
"answer_id": 93669,
"author": "Mike Spross",
"author_id": 17862,
"author_profile": "https://Stackoverflow.com/users/17862",
"pm_score": 2,
"selected": false,
"text": "<c:if test=\"true\">\n <li>user</li>\n</c:if>\n"
},
{
"answer_id": 93717,
"author": "Michael",
"author_id": 13379,
"author_profile": "https://Stackoverflow.com/users/13379",
"pm_score": 5,
"selected": true,
"text": "test"
},
{
"answer_id": 342552,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "<c:if test=\"${ testObject.testPropert == \"testValue\" }\">...</c:if>\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] |
93,415
|
<p>I use <a href="http://files.emacsblog.org/ryan/elisp/maxframe.el" rel="noreferrer">maxframe.el</a> to maximize my Emacs frames.</p>
<p>It works great on all three major platforms, except on my dual-head Mac setup (Macbook Pro 15-inch laptop with 23-inch monitor). </p>
<p>When maximizing an Emacs frame, the frame expands to fill the width of <em>both</em> monitors and the height of the larger monitor. </p>
<p>Obviously, I would like the frame to maximize to fill only the monitor it's on. How can I detect the resolutions of the two individual monitors using elisp? </p>
<p>Thanks,
Jacob</p>
<p>EDIT: As Denis points out, setting mf-max-width is a reasonable workaround. But (as I should have mentioned) I was hoping for a solution that works on both monitors and with any resolution. Maybe something OSX-specific in the style of the Windows-specific w32-send-sys-command. </p>
|
[
{
"answer_id": 93428,
"author": "EfForEffort",
"author_id": 14113,
"author_profile": "https://Stackoverflow.com/users/14113",
"pm_score": 2,
"selected": false,
"text": "\"*The maximum display width to support. This helps better support the true\nnature of display-pixel-width. Since multiple monitors will result in a\nvery large display pixel width, this value is used to set the stop point for\nmaximizing the frame. This could also be used to set a fixed frame size\nwithout going over the display dimensions.\"\n"
},
{
"answer_id": 102256,
"author": "Greg Mattes",
"author_id": 13940,
"author_profile": "https://Stackoverflow.com/users/13940",
"pm_score": 4,
"selected": true,
"text": "maxframe.el"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13747/"
] |
93,417
|
<p>Suppose you have a collection of a few hundred in-memory objects and you need to query this List to return objects matching some SQL or Criteria like query. For example, you might have a List of Car objects and you want to return all cars made during the 1960s, with a license plate that starts with AZ, ordered by the name of the car model. </p>
<p>I know about <a href="http://josql.sourceforge.net/" rel="noreferrer">JoSQL</a>, has anyone used this, or have any experience with other/homegrown solutions?</p>
|
[
{
"answer_id": 93738,
"author": "Yuval",
"author_id": 2819,
"author_profile": "https://Stackoverflow.com/users/2819",
"pm_score": 0,
"selected": false,
"text": "Comparator"
},
{
"answer_id": 93949,
"author": "joev",
"author_id": 3449,
"author_profile": "https://Stackoverflow.com/users/3449",
"pm_score": 2,
"selected": false,
"text": "Comparator"
},
{
"answer_id": 11712925,
"author": "npgall",
"author_id": 812018,
"author_profile": "https://Stackoverflow.com/users/812018",
"pm_score": 5,
"selected": false,
"text": "Car"
},
{
"answer_id": 22230905,
"author": "Federico Piazza",
"author_id": 710099,
"author_profile": "https://Stackoverflow.com/users/710099",
"pm_score": 3,
"selected": false,
"text": "List<Customer> activeCustomers = new ArrayList<Customer>(); \nfor (Customer customer : customers) { \n if (customer.isActive()) { \n activeCusomers.add(customer); \n } \n} \n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17542/"
] |
93,423
|
<p>I have the following code:</p>
<pre><code> String inputFile = "somefile.txt";
FileInputStream in = new FileInputStream(inputFile);
FileChannel ch = in.getChannel();
ByteBuffer buf = ByteBuffer.allocateDirect(BUFSIZE); // BUFSIZE = 256
/* read the file into a buffer, 256 bytes at a time */
int rd;
while ( (rd = ch.read( buf )) != -1 ) {
buf.rewind();
for ( int i = 0; i < rd/2; i++ ) {
/* print each character */
System.out.print(buf.getChar());
}
buf.clear();
}
</code></pre>
<p>But the characters get displayed at ?'s. Does this have something to do with Java using Unicode characters? How do I correct this?</p>
|
[
{
"answer_id": 93528,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "File inputFile = new File(\"somefile.txt\");\nBufferedReader reader = new BufferedReader(new FileReader(inputFile));\n"
},
{
"answer_id": 93574,
"author": "jjnguy",
"author_id": 2598,
"author_profile": "https://Stackoverflow.com/users/2598",
"pm_score": 2,
"selected": false,
"text": "System.out.print((char)buf.get());\n"
},
{
"answer_id": 93575,
"author": "Craig Day",
"author_id": 5193,
"author_profile": "https://Stackoverflow.com/users/5193",
"pm_score": 2,
"selected": false,
"text": " System.out.print((char) buf.get());\n"
},
{
"answer_id": 93685,
"author": "jliszka",
"author_id": 9767,
"author_profile": "https://Stackoverflow.com/users/9767",
"pm_score": 4,
"selected": true,
"text": "import java.util.*;\nimport java.io.*;\nimport java.nio.*;\nimport java.nio.channels.*;\nimport java.nio.charset.*;\n\npublic class Buffer\n{\n public static void main(String args[]) throws Exception\n {\n String inputFile = \"somefile\";\n FileInputStream in = new FileInputStream(inputFile);\n FileChannel ch = in.getChannel();\n ByteBuffer buf = ByteBuffer.allocateDirect(BUFSIZE); // BUFSIZE = 256\n\n Charset cs = Charset.forName(\"ASCII\"); // Or whatever encoding you want\n\n /* read the file into a buffer, 256 bytes at a time */\n int rd;\n while ( (rd = ch.read( buf )) != -1 ) {\n buf.rewind();\n CharBuffer chbuf = cs.decode(buf);\n for ( int i = 0; i < chbuf.length(); i++ ) {\n /* print each character */\n System.out.print(chbuf.get());\n }\n buf.clear();\n }\n }\n}\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10675/"
] |
93,439
|
<p>Is there any website/service which will enable me to add RSS subscription to any website?</p>
<p>This is for my company I work. We have a website which displays company related news. These news are supplied by an external agency and they gets updated to our database automatically. Our website picks up random/new news and displays them. We are looking at adding a "Subscribe via RSS" button to our website.</p>
|
[
{
"answer_id": 93477,
"author": "ConroyP",
"author_id": 2287,
"author_profile": "https://Stackoverflow.com/users/2287",
"pm_score": 4,
"selected": true,
"text": "<link rel=\"alternate\" title=\"RSS Feed\" \n href=\"http://www.example.com/rss-feed/latest/\" type=\"application/rss+xml\" />\n"
},
{
"answer_id": 160899,
"author": "Kent Brewster",
"author_id": 1151280,
"author_profile": "https://Stackoverflow.com/users/1151280",
"pm_score": 1,
"selected": false,
"text": "<ul id=\"newsfeed\">\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12178/"
] |
93,462
|
<p>when an SQL Server Express DB is 'in recovery', you are unable to connect using SQL Authentication. </p>
<p>Is there a simple way of determining the stat of the DB prior to connecting to it?
(Using .Net)</p>
|
[
{
"answer_id": 93594,
"author": "Andy Irving",
"author_id": 8553,
"author_profile": "https://Stackoverflow.com/users/8553",
"pm_score": 2,
"selected": false,
"text": "SELECT DATABASEPROPERTYEX ('master', 'STATUS') AS 'Status';\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93462",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
93,472
|
<p>Is it possible to use DateTimePicker (Winforms) to pick both date and time (in the dropdown)? How do you change the custom display of the picked value? Also, is it possible to enable the user to type the date/time manually?</p>
|
[
{
"answer_id": 93614,
"author": "itsmatt",
"author_id": 7862,
"author_profile": "https://Stackoverflow.com/users/7862",
"pm_score": 9,
"selected": true,
"text": "dateTimePicker1.Format = DateTimePickerFormat.Custom;\ndateTimePicker1.CustomFormat = \"MM/dd/yyyy hh:mm:ss\"; \n"
},
{
"answer_id": 30259683,
"author": "Vectoria",
"author_id": 3793099,
"author_profile": "https://Stackoverflow.com/users/3793099",
"pm_score": 6,
"selected": false,
"text": " timePortionDateTimePicker.Format = DateTimePickerFormat.Time;\n timePortionDateTimePicker.ShowUpDown = true;\n"
},
{
"answer_id": 41579613,
"author": "Serge Voloshenko",
"author_id": 5771669,
"author_profile": "https://Stackoverflow.com/users/5771669",
"pm_score": 4,
"selected": false,
"text": "Properties"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5363/"
] |
93,511
|
<p>How to get a counter inside xsl:for-each loop that would reflect the number of current element processed.<br>
For example my source XML is</p>
<pre><code><books>
<book>
<title>The Unbearable Lightness of Being </title>
</book>
<book>
<title>Narcissus and Goldmund</title>
</book>
<book>
<title>Choke</title>
</book>
</books>
</code></pre>
<p>What I want to get is:</p>
<pre><code><newBooks>
<newBook>
<countNo>1</countNo>
<title>The Unbearable Lightness of Being </title>
</newBook>
<newBook>
<countNo>2</countNo>
<title>Narcissus and Goldmund</title>
</newBook>
<newBook>
<countNo>3</countNo>
<title>Choke</title>
</newBook>
</newBooks>
</code></pre>
<p>The XSLT to modify:</p>
<pre><code><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<newBooks>
<xsl:for-each select="books/book">
<newBook>
<countNo>???</countNo>
<title>
<xsl:value-of select="title"/>
</title>
</newBook>
</xsl:for-each>
</newBooks>
</xsl:template>
</xsl:stylesheet>
</code></pre>
<p>So the question is what to put in place of ???. Is there any standard keyword or do I simply must declare a variable and increment it inside the loop?</p>
<p>As the question is pretty long I should probably expect one line or one word answer :)</p>
|
[
{
"answer_id": 93553,
"author": "redsquare",
"author_id": 6440,
"author_profile": "https://Stackoverflow.com/users/6440",
"pm_score": 8,
"selected": true,
"text": "position()"
},
{
"answer_id": 93562,
"author": "Santiago Cepas",
"author_id": 6547,
"author_profile": "https://Stackoverflow.com/users/6547",
"pm_score": 3,
"selected": false,
"text": " <xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n <xsl:output method=\"xml\" version=\"1.0\" encoding=\"UTF-8\" indent=\"yes\"/>\n <xsl:template match=\"/\">\n <newBooks>\n <xsl:for-each select=\"books/book\">\n <newBook>\n <countNo><xsl:value-of select=\"position()\"/></countNo>\n <title>\n <xsl:value-of select=\"title\"/>\n </title>\n </newBook>\n </xsl:for-each>\n </newBooks>\n </xsl:template>\n</xsl:stylesheet>\n"
},
{
"answer_id": 93563,
"author": "m_pGladiator",
"author_id": 446104,
"author_profile": "https://Stackoverflow.com/users/446104",
"pm_score": 4,
"selected": false,
"text": "<xsl:number format=\"1. \"/><xsl:value-of select=\".\"/><xsl:text>"
},
{
"answer_id": 93580,
"author": "Luke Bennett",
"author_id": 17602,
"author_profile": "https://Stackoverflow.com/users/17602",
"pm_score": 3,
"selected": false,
"text": "<xsl:value-of select=\"count(preceding-sibling::*) + 1\" />\n"
},
{
"answer_id": 4230670,
"author": "Arun Arangil",
"author_id": 514152,
"author_profile": "https://Stackoverflow.com/users/514152",
"pm_score": 3,
"selected": false,
"text": " <xsl:if test=\"(position( )) = 1\">\n //Show header only once\n </xsl:if>\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3241/"
] |
93,526
|
<p>A Y-combinator is a computer science concept from the “functional” side of things. Most programmers don't know much at all about combinators, if they've even heard about them.</p>
<ul>
<li>What is a Y-combinator?</li>
<li>How do combinators work?</li>
<li>What are they good for?</li>
<li>Are they useful in procedural languages?</li>
</ul>
|
[
{
"answer_id": 93573,
"author": "Zach",
"author_id": 9128,
"author_profile": "https://Stackoverflow.com/users/9128",
"pm_score": 5,
"selected": false,
"text": "var Y = function(f) {\n return (function(g) {\n return g(g);\n })(function(h) {\n return function() {\n return f(h(h)).apply(null, arguments);\n };\n });\n};\n\nvar factorial = Y(function(recurse) {\n return function(x) {\n return x == 0 ? 1 : x * recurse(x-1);\n };\n});\n\nfactorial(5) // -> 120\n"
},
{
"answer_id": 94056,
"author": "Chris Ammerman",
"author_id": 2729,
"author_profile": "https://Stackoverflow.com/users/2729",
"pm_score": 8,
"selected": false,
"text": "// Factorial, if func does the same thing as this bit of code...\nx == 0 ? 1: x * func(x - 1);\n"
},
{
"answer_id": 4536766,
"author": "xgMz",
"author_id": 47551,
"author_profile": "https://Stackoverflow.com/users/47551",
"pm_score": 3,
"selected": false,
"text": "function Y(le) {\n return (function (f) {\n return f(f);\n }(function (f) {\n return le(function (x) {\n return f(f)(x);\n });\n }));\n}\n\nvar factorial = Y(function (fac) {\n return function (n) {\n return n <= 2 ? n : n * fac(n - 1);\n };\n});\n\nvar number120 = factorial(5);\n"
},
{
"answer_id": 6713431,
"author": "btilly",
"author_id": 585411,
"author_profile": "https://Stackoverflow.com/users/585411",
"pm_score": 7,
"selected": false,
"text": "// Here's the function that we want to recurse.\nX = function (recurse, n) {\n if (0 == n)\n return 1;\n else\n return n * recurse(recurse, n - 1);\n};\n\n// This will get X to recurse.\nY = function (builder, n) {\n return builder(builder, n);\n};\n\n// Here it is in action.\nY(\n X,\n 5\n);\n"
},
{
"answer_id": 6714066,
"author": "Wayne",
"author_id": 592746,
"author_profile": "https://Stackoverflow.com/users/592746",
"pm_score": 7,
"selected": false,
"text": "function factorial(n) {\n return n == 0 ? 1 : n * factorial(n - 1);\n}\n"
},
{
"answer_id": 6715144,
"author": "Andrew",
"author_id": 847421,
"author_profile": "https://Stackoverflow.com/users/847421",
"pm_score": 2,
"selected": false,
"text": "function fib( n ){ if( n<=1 ) return n; else return fib(n-1)+fib(n-2) }\n"
},
{
"answer_id": 30692261,
"author": "El Zorko",
"author_id": 58063,
"author_profile": "https://Stackoverflow.com/users/58063",
"pm_score": 5,
"selected": false,
"text": "(λx.f (x x))"
},
{
"answer_id": 38546446,
"author": "zumalifeguard",
"author_id": 75129,
"author_profile": "https://Stackoverflow.com/users/75129",
"pm_score": 1,
"selected": false,
"text": "function factorial(num)\n{\n // If the number is less than 0, reject it.\n if (num < 0) {\n return -1;\n }\n // If the number is 0, its factorial is 1.\n else if (num == 0) {\n return 1;\n }\n // Otherwise, call this recursive procedure again.\n else {\n return (num * factorial(num - 1));\n }\n}\n"
},
{
"answer_id": 43742477,
"author": "Tires",
"author_id": 1053629,
"author_profile": "https://Stackoverflow.com/users/1053629",
"pm_score": 2,
"selected": false,
"text": "var Y = function(f) {\n return (function(g) {\n return g(g);\n })(function(h) {\n return function() {\n return f.apply(h(h), arguments);\n };\n });\n};\n"
},
{
"answer_id": 45036344,
"author": "Dapeng Li",
"author_id": 1215410,
"author_profile": "https://Stackoverflow.com/users/1215410",
"pm_score": 3,
"selected": false,
"text": "almost-factorial"
},
{
"answer_id": 46595580,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": false,
"text": "fix"
},
{
"answer_id": 49424590,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "c"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2729/"
] |
93,539
|
<p>What is the difference between Views and Materialized Views in Oracle?</p>
|
[
{
"answer_id": 93579,
"author": "Jeremiah Peschka",
"author_id": 11780,
"author_profile": "https://Stackoverflow.com/users/11780",
"pm_score": 6,
"selected": false,
"text": "ON COMMIT REFRESH"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1782/"
] |
93,541
|
<p>I have a custom user control with a textbox on it and I'd like to expose the baseline (of the text in the textbox) snapline outside of the custom control. I know that you create a designer (inherited from ControlDesigner) and override SnapLines to get access to the snaplines, but I'm wondering how to get the text baseline of a control that I have exposed by my custom user control.</p>
|
[
{
"answer_id": 95013,
"author": "BenR",
"author_id": 18039,
"author_profile": "https://Stackoverflow.com/users/18039",
"pm_score": 2,
"selected": false,
"text": "Public Overrides ReadOnly Property SnapLines() As System.Collections.IList\n Get\n Dim snapLinesList As ArrayList = TryCast(MyBase.SnapLines, ArrayList)\n\n Dim offset As Integer\n Dim ctrl As MyControl = TryCast(Me.Control, MyControl)\n If ctrl IsNot Nothing AndAlso ctrl.TextBox1 IsNot Nothing Then\n offset = ctrl.TextBox1.Bottom - 5\n End If\n\n snapLinesList.Add(New SnapLine(SnapLineType.Baseline, offset, SnapLinePriority.Medium))\n\n Return snapLinesList\n\n End Get\nEnd Property\n"
},
{
"answer_id": 402419,
"author": "Miral",
"author_id": 43534,
"author_profile": "https://Stackoverflow.com/users/43534",
"pm_score": 6,
"selected": true,
"text": " public override IList SnapLines\n{\n get\n {\n IList snapLines = base.SnapLines;\n\n MyControl control = Control as MyControl;\n if (control == null) { return snapLines; }\n\n IDesigner designer = TypeDescriptor.CreateDesigner(\n control.textBoxValue, typeof(IDesigner));\n if (designer == null) { return snapLines; }\n designer.Initialize(control.textBoxValue);\n\n using (designer)\n {\n ControlDesigner boxDesigner = designer as ControlDesigner;\n if (boxDesigner == null) { return snapLines; }\n\n foreach (SnapLine line in boxDesigner.SnapLines)\n {\n if (line.SnapLineType == SnapLineType.Baseline)\n {\n snapLines.Add(new SnapLine(SnapLineType.Baseline,\n line.Offset + control.textBoxValue.Top,\n line.Filter, line.Priority));\n break;\n }\n }\n }\n\n return snapLines;\n }\n}\n"
},
{
"answer_id": 945486,
"author": "Matthew M.",
"author_id": 27472,
"author_profile": "https://Stackoverflow.com/users/27472",
"pm_score": 5,
"selected": false,
"text": "using System.Windows.Forms.Design;\nusing System.Windows.Forms.Design.Behavior;\nusing System.ComponentModel;\nusing System.ComponentModel.Design;\nusing System.Collections;\n"
},
{
"answer_id": 1744204,
"author": "Jonh Clark",
"author_id": 212320,
"author_profile": "https://Stackoverflow.com/users/212320",
"pm_score": 3,
"selected": false,
"text": "txtDescription"
},
{
"answer_id": 3451311,
"author": "Robert H.",
"author_id": 108958,
"author_profile": "https://Stackoverflow.com/users/108958",
"pm_score": 3,
"selected": false,
"text": "[Designer(typeof(UserControlSnapLineDesigner))]\npublic class UserControlBase : UserControl\n{\n protected virtual Control SnapLineControl { get { return null; } }\n\n private class UserControlSnapLineDesigner : ControlDesigner\n {\n public override IList SnapLines\n {\n get\n {\n IList snapLines = base.SnapLines;\n\n Control targetControl = (this.Control as UserControlBase).SnapLineControl;\n\n if (targetControl == null)\n return snapLines;\n\n using (ControlDesigner controlDesigner = TypeDescriptor.CreateDesigner(targetControl,\n typeof(IDesigner)) as ControlDesigner)\n {\n if (controlDesigner == null)\n return snapLines;\n\n controlDesigner.Initialize(targetControl);\n\n foreach (SnapLine line in controlDesigner.SnapLines)\n {\n if (line.SnapLineType == SnapLineType.Baseline)\n {\n snapLines.Add(new SnapLine(SnapLineType.Baseline, line.Offset + targetControl.Top,\n line.Filter, line.Priority));\n break;\n }\n }\n }\n return snapLines;\n }\n }\n }\n}\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2848/"
] |
93,551
|
<p>Web applications that want to force a resource to be <em>downloaded</em> rather than directly <em>rendered</em> in a Web browser issue a <code>Content-Disposition</code> header in the HTTP response of the form:</p>
<p><code>Content-Disposition: attachment; filename=<em>FILENAME</em></code></p>
<p>The <code>filename</code> parameter can be used to suggest a name for the file into which the resource is downloaded by the browser. <a href="https://www.rfc-editor.org/rfc/rfc2183" rel="noreferrer">RFC 2183</a> (Content-Disposition), however, states in <a href="https://www.rfc-editor.org/rfc/rfc2183#section-2.3" rel="noreferrer">section 2.3</a> (The Filename Parameter) that the file name can only use US-ASCII characters:</p>
<blockquote>
<p>Current [RFC 2045] grammar restricts
parameter values (and hence
Content-Disposition filenames) to
US-ASCII. We recognize the great
desirability of allowing arbitrary
character sets in filenames, but it is
beyond the scope of this document to
define the necessary mechanisms.</p>
</blockquote>
<p>There is empirical evidence, nevertheless, that most popular Web browsers today seem to permit non-US-ASCII characters yet (for the lack of a standard) disagree on the encoding scheme and character set specification of the file name. Question is then, what are the various schemes and encodings employed by the popular browsers if the file name “naïvefile” (without quotes and where the third letter is U+00EF) needed to be encoded into the Content-Disposition header?</p>
<p>For the purpose of this question, <em>popular browsers</em> being:</p>
<ul>
<li>Google Chrome</li>
<li>Safari</li>
<li>Internet Explorer or Edge</li>
<li>Firefox</li>
<li>Opera</li>
</ul>
|
[
{
"answer_id": 216777,
"author": "Kornel",
"author_id": 27009,
"author_profile": "https://Stackoverflow.com/users/27009",
"pm_score": 8,
"selected": false,
"text": "Content-Disposition"
},
{
"answer_id": 3256922,
"author": "Elmer",
"author_id": 173109,
"author_profile": "https://Stackoverflow.com/users/173109",
"pm_score": 3,
"selected": false,
"text": "return File(\n tempFile\n , \"application/octet-stream\"\n , HttpUtility.UrlPathEncode(fileName)\n );\n"
},
{
"answer_id": 6745788,
"author": "Martin Ørding-Thomsen",
"author_id": 346150,
"author_profile": "https://Stackoverflow.com/users/346150",
"pm_score": 9,
"selected": false,
"text": "Content-Disposition: attachment; filename*=UTF-8''Na%C3%AFve%20file.txt\n"
},
{
"answer_id": 10836972,
"author": "Stano",
"author_id": 1422309,
"author_profile": "https://Stackoverflow.com/users/1422309",
"pm_score": 2,
"selected": false,
"text": "$filename = $_GET['file']; //this string from $_GET is already decoded\nif (strstr($_SERVER['HTTP_USER_AGENT'],\"MSIE\"))\n $filename = rawurlencode($filename);\nheader('Content-Disposition: attachment; filename=\"'.$filename.'\"');\n"
},
{
"answer_id": 16103584,
"author": "Vasilen Donchev",
"author_id": 203037,
"author_profile": "https://Stackoverflow.com/users/203037",
"pm_score": 4,
"selected": false,
"text": "if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], \"MSIE\" ) > 0 )\n{\n header ( 'Content-Disposition: attachment; filename=\"' . rawurlencode ( $fileName ) . '\"' );\n}\nelse\n{\n header( 'Content-Disposition: attachment; filename*=UTF-8\\'\\'' . rawurlencode ( $fileName ) );\n}\n"
},
{
"answer_id": 20933751,
"author": "MvG",
"author_id": 1468366,
"author_profile": "https://Stackoverflow.com/users/1468366",
"pm_score": 6,
"selected": false,
"text": "filename*"
},
{
"answer_id": 28169892,
"author": "V G",
"author_id": 504956,
"author_profile": "https://Stackoverflow.com/users/504956",
"pm_score": -1,
"selected": false,
"text": "<input type=\"file\">"
},
{
"answer_id": 29459051,
"author": "apurkrt",
"author_id": 1266880,
"author_profile": "https://Stackoverflow.com/users/1266880",
"pm_score": 2,
"selected": false,
"text": "$il1_filename = utf8_decode($filename);\n$to_underscore = \"\\\"\\\\#*;:|<>/?\";\n$safe_filename = strtr($il1_filename, $to_underscore, str_repeat(\"_\", strlen($to_underscore)));\n\nheader(\"Content-Disposition: attachment; filename=\\\"$safe_filename\\\"\"\n.( $safe_filename === $filename ? \"\" : \"; filename*=UTF-8''\".rawurlencode($filename) ));\n"
},
{
"answer_id": 31044692,
"author": "martinoss",
"author_id": 551698,
"author_profile": "https://Stackoverflow.com/users/551698",
"pm_score": 3,
"selected": false,
"text": "public static class HttpRequestMessageExtensions\n{\n public static HttpResponseMessage CreateFileResponse(this HttpRequestMessage request, byte[] data, string filename, string mediaType)\n {\n HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);\n var stream = new MemoryStream(data);\n stream.Position = 0;\n\n response.Content = new StreamContent(stream);\n\n response.Content.Headers.ContentType = \n new MediaTypeHeaderValue(mediaType);\n\n // URL-Encode filename\n // Fixes behavior in IE, that filenames with non US-ASCII characters\n // stay correct (not \"_utf-8_.......=_=\").\n var encodedFilename = HttpUtility.UrlEncode(filename, Encoding.UTF8);\n\n response.Content.Headers.ContentDisposition =\n new ContentDispositionHeaderValue(\"attachment\") { FileName = encodedFilename };\n return response;\n }\n}\n"
},
{
"answer_id": 31344123,
"author": "Dmitry Kaigorodov",
"author_id": 1711558,
"author_profile": "https://Stackoverflow.com/users/1711558",
"pm_score": 4,
"selected": false,
"text": "Content-Disposition: attachment; filename=\"My Report.doc\"\n"
},
{
"answer_id": 32782542,
"author": "Emanuele Spatola",
"author_id": 2846401,
"author_profile": "https://Stackoverflow.com/users/2846401",
"pm_score": 3,
"selected": false,
"text": "var fileName = 'my file(2).txt';\nvar header = \"Content-Disposition: attachment; filename*=UTF-8''\" \n + encodeRFC5987ValueChars(fileName);\n\nfunction encodeRFC5987ValueChars (str) {\n return encodeURIComponent(str).\n // Note that although RFC3986 reserves \"!\", RFC5987 does not,\n // so we do not need to escape it\n replace(/['()]/g, escape). // i.e., %27 %28 %29\n replace(/\\*/g, '%2A').\n // The following are not required for percent-encoding per RFC5987, \n // so we can allow for a little better readability over the wire: |`^\n replace(/%(?:7C|60|5E)/g, unescape);\n}\n"
},
{
"answer_id": 37347159,
"author": "Gustav",
"author_id": 1741444,
"author_profile": "https://Stackoverflow.com/users/1741444",
"pm_score": 3,
"selected": false,
"text": "header('Content-Disposition: attachment;'\n . 'filename=\"' . addslashes(utf8_decode($filename)) . '\";'\n . 'filename*=utf-8\\'\\'' . rawurlencode($filename));\n"
},
{
"answer_id": 37390834,
"author": "user692942",
"author_id": 692942,
"author_profile": "https://Stackoverflow.com/users/692942",
"pm_score": 0,
"selected": false,
"text": "Filename"
},
{
"answer_id": 57147665,
"author": "luchaninov",
"author_id": 437763,
"author_profile": "https://Stackoverflow.com/users/437763",
"pm_score": 2,
"selected": false,
"text": "$filenameFallback"
},
{
"answer_id": 68587104,
"author": "Bjarke Pjedsted",
"author_id": 4989962,
"author_profile": "https://Stackoverflow.com/users/4989962",
"pm_score": 2,
"selected": false,
"text": "var fileName = \"Naïve file.txt\";\nvar h = new System.Net.Http.Headers.ContentDispositionHeaderValue(\"attachment\");\nh.FileNameStar = fileName;\nh.FileName = \"fallback-ascii-name.txt\";\n\nResponse.Headers.Add(\"Content-Disposition\", h.ToString());\n"
},
{
"answer_id": 68824724,
"author": "laurent",
"author_id": 561309,
"author_profile": "https://Stackoverflow.com/users/561309",
"pm_score": 1,
"selected": false,
"text": "function createContentDispositionHeader(filename:string) {\n const encoded = encodeURIComponent(filename);\n return `attachment; filename*=UTF-8''${encoded}; filename=\"${encoded}\"`;\n}\n"
},
{
"answer_id": 70434241,
"author": "Matoeil",
"author_id": 1412620,
"author_profile": "https://Stackoverflow.com/users/1412620",
"pm_score": -1,
"selected": false,
"text": "$file_name= Unicode::mimeHeaderEncode($file_name);\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6682/"
] |
93,569
|
<p>For example, if I declare a long variable, can I assume it will always be aligned on a "sizeof(long)" boundary? Microsoft Visual C++ online help says so, but is it standard behavior?</p>
<p>some more info:</p>
<p>a. It is possible to explicitely create a misaligned integer (*bar):</p>
<blockquote>
<p>char foo[5]</p>
<p>int * bar = (int *)(&foo[1]);</p>
</blockquote>
<p>b. Apparently, #pragma pack() only affects structures, classes, and unions.</p>
<p>c. MSVC documentation states that POD types are aligned to their respective sizes (but is it always or by default, and is it standard behavior, I don't know)</p>
|
[
{
"answer_id": 93585,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 0,
"selected": false,
"text": "#define ALIGNMENT_OF( t ) offsetof( struct { char x; t test; }, test )\n"
},
{
"answer_id": 93797,
"author": "Torlack",
"author_id": 5243,
"author_profile": "https://Stackoverflow.com/users/5243",
"pm_score": 4,
"selected": true,
"text": "#pragma pack(push)\n#pragma pack(1) \nstruct Example\n{\n short data1; // offset 0\n short padding1; // offset 2\n long data2; // offset 4\n};\n#pragma pack(pop)\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12291/"
] |
93,578
|
<p>I cannot use the Resource File API from within a file system plugin due to a PlatSec issue:</p>
<pre><code>*PlatSec* ERROR - Capability check failed - Can't load filesystemplugin.PXT because it links to bafl.dll which has the following capabilities missing: TCB
</code></pre>
<p>My understanding of the issue is that:</p>
<p>File system plugins are dlls which are executed within the context of the file system process. Therefore all file system plugins must have the <code>TCB</code> PlatSec privilege which in turn means they cannot link against a dll that is not in the <code>TCB</code>.</p>
<p>Is there a way around this (without resorting to a text file or an intermediate server)? I suspect not - but it would be good to get a definitive answer.</p>
|
[
{
"answer_id": 94169,
"author": "MathewI",
"author_id": 17938,
"author_profile": "https://Stackoverflow.com/users/17938",
"pm_score": 3,
"selected": true,
"text": "TCB ProtServ DiskAdmin AllFiles PowerMgmt CommDD\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8565/"
] |
93,583
|
<p>In a asp.net web application, I want to write to a file. This function will first get data from the database, and then write out the flat file.</p>
<p>What can I do to make sure only 1 write occurs, and once the write occurrs, the other threads that maybe want to write to the file don't since the write took place.</p>
<p>I want to have this write done ONLY if it hasn't been done in say 15 minutes.</p>
<p>I know there is a lock keyword, so should I wrap everything in a lock, then check if it has been updated in 15 minutes or more, or visa versa?</p>
<p><b>Update</b></p>
<p>Workflow:</p>
<p>Since this is a web application, the multiple instances will be people viewing a particular web page. I could use the build in cache system, but if asp.net recycles it will be expensive to rebuild the cache so I just want to write it out to a flat file. My other option would be just to create a windows service, but that is more work to manage that I want.</p>
|
[
{
"answer_id": 93597,
"author": "Gishu",
"author_id": 1695,
"author_profile": "https://Stackoverflow.com/users/1695",
"pm_score": 2,
"selected": false,
"text": "lock(this)\n{\n // perform the write.\n}\n"
},
{
"answer_id": 93674,
"author": "Oliver Mellet",
"author_id": 12001,
"author_profile": "https://Stackoverflow.com/users/12001",
"pm_score": 0,
"selected": false,
"text": " // try enter will return false if another thread owns the lock\n if (Monitor.TryEnter(lockObj))\n {\n try\n {\n // check last write time here, return if too soon; otherwise, write\n }\n finally\n {\n Monitor.Exit(lockobj);\n }\n }\n"
},
{
"answer_id": 170571,
"author": "Constantin",
"author_id": 20310,
"author_profile": "https://Stackoverflow.com/users/20310",
"pm_score": 0,
"selected": false,
"text": "FileInfo fi = new FileInfo(path);\nif (fi.Exists\n && (DateTime.UtcNow - fi.LastWriteTimeUtc < TimeSpan.FromMinutes(15)) {\n // file is fresh\n return;\n}\n\nFileStream fs;\ntry {\n fs = new FileStream(\n path, FileMode.Create, FileAccess.Write, FileShare.Read);\n} catch (IOException) {\n // file is locked\n return;\n}\n\nusing (fs) {\n // write to file\n}\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93583",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1368/"
] |
93,590
|
<p>I have a question about using streams in .NET to load files from disk. I am trying to pinpoint a performance problem and want to be sure it's where I think it is.</p>
<pre><code>Dim provider1 As New MD5CryptoServiceProvider
Dim stream1 As FileStream
stream1 = New FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.Read)
provider1.ComputeHash(stream1)
</code></pre>
<p>Q: Are the bytes read from disk when I create the FileStream object, or when the object consuming the stream, in this case an MD5 Hash algorithm, actually reads it?</p>
<p>I see significant performance problems on my web host when using the <code>ComputeHash</code> method, compared to my local test environment. I'm just trying to make sure that the performance problem is in the hashing and not in the disk access.</p>
|
[
{
"answer_id": 93694,
"author": "Chris Wenham",
"author_id": 5548,
"author_profile": "https://Stackoverflow.com/users/5548",
"pm_score": 3,
"selected": true,
"text": "provider1.ComputeHash(stream1.ToArray());\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3059/"
] |
93,625
|
<p>I have a list with two <code><div></code>s in every <code><li></code> and I want to float them one next to the other and I want the <code><li></code> to take the whole availabe space. How do I do it?</p>
<pre><code><html>
<head>
<title></title>
<style type="text/css">
body {
}
ul {
}
li {
}
.a {
}
.b {
}
</style>
</head>
<body>
<ul>
<li>
<div class="a">
content
</div>
<div class="b">
content
</div>
</li>
</ul>
</body>
</html>
</code></pre>
|
[
{
"answer_id": 93646,
"author": "workmad3",
"author_id": 16035,
"author_profile": "https://Stackoverflow.com/users/16035",
"pm_score": -1,
"selected": false,
"text": "li{width:100%;}\n.a{}\n.b{float: left;}\n"
},
{
"answer_id": 93647,
"author": "Jeremiah Peschka",
"author_id": 11780,
"author_profile": "https://Stackoverflow.com/users/11780",
"pm_score": 0,
"selected": false,
"text": "\nLI { width: 100%; }\n.a { float: left; }\n.b { float: right; }\n"
},
{
"answer_id": 93649,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 3,
"selected": true,
"text": " *{ margin: 0; padding: 0;}\n li{ width: 100%: display: block; } \n li:after{ clear: both; } \n div.a{ width: 49%; float: left; }\n div.b{ width: 49%; float: left; } \n"
},
{
"answer_id": 93671,
"author": "AdamB",
"author_id": 2176,
"author_profile": "https://Stackoverflow.com/users/2176",
"pm_score": 2,
"selected": false,
"text": "li\n{\n clear: left;\n}\n.a\n{\n float: left;\n}\n.b\n{\n float: left;\n}\n"
},
{
"answer_id": 93681,
"author": "Mike Becatti",
"author_id": 6617,
"author_profile": "https://Stackoverflow.com/users/6617",
"pm_score": 0,
"selected": false,
"text": "li { width: 100%;}\n.a { float: left;}\n.b { float: left;}\n"
},
{
"answer_id": 94052,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "ul,\nli {\n width: 100%;\n list-style-type: none;\n margin: 0;\n padding: 0;\n}\nli {\n overflow: hidden;\n}\nli div.a,\nli div.b {\n float: left;\n}\n"
},
{
"answer_id": 14507673,
"author": "Labanino",
"author_id": 1839767,
"author_profile": "https://Stackoverflow.com/users/1839767",
"pm_score": 1,
"selected": false,
"text": "<div>A block-level section in a document</div>\n<span>An inline section in a document</span>\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17781/"
] |
93,632
|
<p>I have a CakePHP application that in some moment will show a view with product media (pictures or videos) I want to know if, there is someway to include another view that threats the video or threats the pictures, depending on a flag. I want to use those "small views" to several other purposes, so It should be "like" a cake component, for reutilization.</p>
<p>What you guys suggest to use to be in Cake conventions (and not using a raw <code>include('')</code> command)</p>
|
[
{
"answer_id": 94758,
"author": "Paolo Bergantino",
"author_id": 16417,
"author_profile": "https://Stackoverflow.com/users/16417",
"pm_score": 3,
"selected": false,
"text": "$this->renderElement('display', array('flag' => 'value'));"
},
{
"answer_id": 94811,
"author": "Lucas Oman",
"author_id": 6726,
"author_profile": "https://Stackoverflow.com/users/6726",
"pm_score": 1,
"selected": false,
"text": "requestAction()"
},
{
"answer_id": 145733,
"author": "Chris Hawes",
"author_id": 22776,
"author_profile": "https://Stackoverflow.com/users/22776",
"pm_score": 3,
"selected": false,
"text": "function something() {\n return $this->Post->find('all');\n}\n"
},
{
"answer_id": 17806027,
"author": "LenArt",
"author_id": 2455390,
"author_profile": "https://Stackoverflow.com/users/2455390",
"pm_score": 3,
"selected": false,
"text": "<?php include('/<other_view>.ctp'); ?>\n"
},
{
"answer_id": 31317516,
"author": "Alex Solovyh",
"author_id": 4207270,
"author_profile": "https://Stackoverflow.com/users/4207270",
"pm_score": 0,
"selected": false,
"text": "$this->render('view')\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2274/"
] |
93,638
|
<p>I have a WPF app with many list based controls in a window, which all are bound to different CollectionViews.</p>
<p>At the window level is there a way to get the current selected item for the currently in focus list based control? I know I can do this with some fairly trivial code by looking for the in focus element but does WPF support this as a concept out of the box?</p>
<p>Something like Window.CurrentSelectedDataItem would be great. I am looking into using this as a way to centralize command management for enabling disabling commands based on a current selected data item.</p>
|
[
{
"answer_id": 95031,
"author": "Andy",
"author_id": 3857,
"author_profile": "https://Stackoverflow.com/users/3857",
"pm_score": 1,
"selected": false,
"text": "EventManager.RegisterClassHandler(typeof(ListBox), ListBox.SelectionChanged,\n new SelectionChangedEventHandler(this.OnListBoxSelectionChanged));\n"
},
{
"answer_id": 153784,
"author": "David Schmitt",
"author_id": 4918,
"author_profile": "https://Stackoverflow.com/users/4918",
"pm_score": 0,
"selected": false,
"text": "<MultiBinding Converter=\"{StaticResource coalesce}\">\n <MultiBinding.Bindings>\n <MultiBinding Converter=\"{StaticResource nullIfFalse}\">\n <MultiBinding.Bindings>\n <Binding ElementName=\"List1\" Path=\"HasFocus\" />\n <Binding ElementName=\"List1\" Path=\"SelectedItem\" />\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
93,642
|
<p>We require all requests for downloads to have a valid login (non-http) and we generate transaction tickets for each download. If you were to go to one of the download links and attempt to "replay" the transaction, we use HTTP codes to forward you to get a new transaction ticket. This works fine for a majority of users. There's a small subset, however, that are using Download Accelerators that simply try to replay the transaction ticket several times.</p>
<p>So, in order to determine whether we want to or even <em>can</em> support download accelerators or not, we are trying to understand how they work. </p>
<p>How does having a second, third or even fourth concurrent connection to the web server delivering a static file speed the download process? </p>
<p>What does the accelerator program do?</p>
|
[
{
"answer_id": 71583233,
"author": "Amin Pial",
"author_id": 9258044,
"author_profile": "https://Stackoverflow.com/users/9258044",
"pm_score": 0,
"selected": false,
"text": "partial content download - status code 206"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5581/"
] |
93,650
|
<p>How do you apply stroke (outline around text) to a textblock in xaml in WPF?</p>
|
[
{
"answer_id": 94801,
"author": "SmartyP",
"author_id": 18005,
"author_profile": "https://Stackoverflow.com/users/18005",
"pm_score": 3,
"selected": false,
"text": " <Border BorderBrush=\"Purple\" BorderThickness=\"2\">\n <TextBlock>My fancy TextBlock</TextBlock>\n </Border>\n"
},
{
"answer_id": 97728,
"author": "Kris Erickson",
"author_id": 3798,
"author_profile": "https://Stackoverflow.com/users/3798",
"pm_score": 5,
"selected": false,
"text": "using System;\nusing System.Windows.Media;\nusing System.Globalization;\nusing System.Windows;\nusing System.Windows.Markup;\n\nnamespace CustomXaml\n{\n\npublic class OutlinedText : FrameworkElement, IAddChild\n{\n #region Private Fields\n\n private Geometry _textGeometry;\n\n #endregion\n\n #region Private Methods\n\n /// <summary>\n /// Invoked when a dependency property has changed. Generate a new FormattedText object to display.\n /// </summary>\n /// <param name=\"d\">OutlineText object whose property was updated.</param>\n /// <param name=\"e\">Event arguments for the dependency property.</param>\n private static void OnOutlineTextInvalidated(DependencyObject d, DependencyPropertyChangedEventArgs e)\n {\n ((OutlinedText)d).CreateText();\n }\n\n #endregion\n\n\n #region FrameworkElement Overrides\n\n /// <summary>\n /// OnRender override draws the geometry of the text and optional highlight.\n /// </summary>\n /// <param name=\"drawingContext\">Drawing context of the OutlineText control.</param>\n protected override void OnRender(DrawingContext drawingContext)\n {\n CreateText();\n // Draw the outline based on the properties that are set.\n drawingContext.DrawGeometry(Fill, new Pen(Stroke, StrokeThickness), _textGeometry);\n\n }\n\n /// <summary>\n /// Create the outline geometry based on the formatted text.\n /// </summary>\n public void CreateText()\n {\n FontStyle fontStyle = FontStyles.Normal;\n FontWeight fontWeight = FontWeights.Medium;\n\n if (Bold == true) fontWeight = FontWeights.Bold;\n if (Italic == true) fontStyle = FontStyles.Italic;\n\n // Create the formatted text based on the properties set.\n FormattedText formattedText = new FormattedText(\n Text,\n CultureInfo.GetCultureInfo(\"en-us\"), \n FlowDirection.LeftToRight,\n new Typeface(Font, fontStyle, fontWeight, FontStretches.Normal), \n FontSize,\n Brushes.Black // This brush does not matter since we use the geometry of the text. \n );\n\n // Build the geometry object that represents the text.\n _textGeometry = formattedText.BuildGeometry(new Point(0, 0));\n\n\n\n\n //set the size of the custome control based on the size of the text\n this.MinWidth = formattedText.Width;\n this.MinHeight = formattedText.Height;\n\n }\n\n #endregion\n\n #region DependencyProperties\n\n /// <summary>\n /// Specifies whether the font should display Bold font weight.\n /// </summary>\n public bool Bold\n {\n get\n {\n return (bool)GetValue(BoldProperty);\n }\n\n set\n {\n SetValue(BoldProperty, value);\n }\n }\n\n /// <summary>\n /// Identifies the Bold dependency property.\n /// </summary>\n public static readonly DependencyProperty BoldProperty = DependencyProperty.Register(\n \"Bold\",\n typeof(bool),\n typeof(OutlinedText),\n new FrameworkPropertyMetadata(\n false,\n FrameworkPropertyMetadataOptions.AffectsRender,\n new PropertyChangedCallback(OnOutlineTextInvalidated),\n null\n )\n );\n\n /// <summary>\n /// Specifies the brush to use for the fill of the formatted text.\n /// </summary>\n public Brush Fill\n {\n get\n {\n return (Brush)GetValue(FillProperty);\n }\n\n set\n {\n SetValue(FillProperty, value);\n }\n }\n\n /// <summary>\n /// Identifies the Fill dependency property.\n /// </summary>\n public static readonly DependencyProperty FillProperty = DependencyProperty.Register(\n \"Fill\",\n typeof(Brush),\n typeof(OutlinedText),\n new FrameworkPropertyMetadata(\n new SolidColorBrush(Colors.LightSteelBlue),\n FrameworkPropertyMetadataOptions.AffectsRender,\n new PropertyChangedCallback(OnOutlineTextInvalidated),\n null\n )\n );\n\n /// <summary>\n /// The font to use for the displayed formatted text.\n /// </summary>\n public FontFamily Font\n {\n get\n {\n return (FontFamily)GetValue(FontProperty);\n }\n\n set\n {\n SetValue(FontProperty, value);\n }\n }\n\n /// <summary>\n /// Identifies the Font dependency property.\n /// </summary>\n public static readonly DependencyProperty FontProperty = DependencyProperty.Register(\n \"Font\",\n typeof(FontFamily),\n typeof(OutlinedText),\n new FrameworkPropertyMetadata(\n new FontFamily(\"Arial\"),\n FrameworkPropertyMetadataOptions.AffectsRender,\n new PropertyChangedCallback(OnOutlineTextInvalidated),\n null\n )\n );\n\n /// <summary>\n /// The current font size.\n /// </summary>\n public double FontSize\n {\n get\n {\n return (double)GetValue(FontSizeProperty);\n }\n\n set\n {\n SetValue(FontSizeProperty, value);\n }\n }\n\n /// <summary>\n /// Identifies the FontSize dependency property.\n /// </summary>\n public static readonly DependencyProperty FontSizeProperty = DependencyProperty.Register(\n \"FontSize\",\n typeof(double),\n typeof(OutlinedText),\n new FrameworkPropertyMetadata(\n (double)48.0,\n FrameworkPropertyMetadataOptions.AffectsRender,\n new PropertyChangedCallback(OnOutlineTextInvalidated),\n null\n )\n );\n\n\n /// <summary>\n /// Specifies whether the font should display Italic font style.\n /// </summary>\n public bool Italic\n {\n get\n {\n return (bool)GetValue(ItalicProperty);\n }\n\n set\n {\n SetValue(ItalicProperty, value);\n }\n }\n\n /// <summary>\n /// Identifies the Italic dependency property.\n /// </summary>\n public static readonly DependencyProperty ItalicProperty = DependencyProperty.Register(\n \"Italic\",\n typeof(bool),\n typeof(OutlinedText),\n new FrameworkPropertyMetadata(\n false,\n FrameworkPropertyMetadataOptions.AffectsRender,\n new PropertyChangedCallback(OnOutlineTextInvalidated),\n null\n )\n );\n\n /// <summary>\n /// Specifies the brush to use for the stroke and optional hightlight of the formatted text.\n /// </summary>\n public Brush Stroke\n {\n get\n {\n return (Brush)GetValue(StrokeProperty);\n }\n\n set\n {\n SetValue(StrokeProperty, value);\n }\n }\n\n /// <summary>\n /// Identifies the Stroke dependency property.\n /// </summary>\n public static readonly DependencyProperty StrokeProperty = DependencyProperty.Register(\n \"Stroke\",\n typeof(Brush),\n typeof(OutlinedText),\n new FrameworkPropertyMetadata(\n new SolidColorBrush(Colors.Teal),\n FrameworkPropertyMetadataOptions.AffectsRender,\n new PropertyChangedCallback(OnOutlineTextInvalidated),\n null\n )\n );\n\n /// <summary>\n /// The stroke thickness of the font.\n /// </summary>\n public ushort StrokeThickness\n {\n get\n {\n return (ushort)GetValue(StrokeThicknessProperty);\n }\n\n set\n {\n SetValue(StrokeThicknessProperty, value);\n }\n }\n\n /// <summary>\n /// Identifies the StrokeThickness dependency property.\n /// </summary>\n public static readonly DependencyProperty StrokeThicknessProperty = DependencyProperty.Register(\n \"StrokeThickness\",\n typeof(ushort),\n typeof(OutlinedText),\n new FrameworkPropertyMetadata(\n (ushort)0,\n FrameworkPropertyMetadataOptions.AffectsRender,\n new PropertyChangedCallback(OnOutlineTextInvalidated),\n null\n )\n );\n\n /// <summary>\n /// Specifies the text string to display.\n /// </summary>\n public string Text\n {\n get\n {\n return (string)GetValue(TextProperty);\n }\n\n set\n {\n SetValue(TextProperty, value);\n }\n }\n\n /// <summary>\n /// Identifies the Text dependency property.\n /// </summary>\n public static readonly DependencyProperty TextProperty = DependencyProperty.Register(\n \"Text\",\n typeof(string),\n typeof(OutlinedText),\n new FrameworkPropertyMetadata(\n \"\",\n FrameworkPropertyMetadataOptions.AffectsRender,\n new PropertyChangedCallback(OnOutlineTextInvalidated),\n null\n )\n );\n\n public void AddChild(Object value)\n {\n\n }\n\n public void AddText(string value)\n {\n Text = value;\n }\n\n #endregion\n}\n}\n"
},
{
"answer_id": 4910507,
"author": "JBrooks",
"author_id": 136059,
"author_profile": "https://Stackoverflow.com/users/136059",
"pm_score": 0,
"selected": false,
"text": " <Style x:Key=\"LeftBorderLabel\" TargetType=\"{x:Type Label}\">\n <Setter Property=\"Margin\" Value=\"0\" />\n <Setter Property=\"BorderThickness\" Value=\"1,0,0,0\" />\n <Setter Property=\"BorderBrush\" Value=\"Blue\" />\n </Style>\n"
},
{
"answer_id": 6795547,
"author": "diceguyd30",
"author_id": 464094,
"author_profile": "https://Stackoverflow.com/users/464094",
"pm_score": 0,
"selected": false,
"text": "Imports System\nImports System.Windows.Media\nImports System.Globalization\nImports System.Windows\nImports System.Windows.Markup\n\nNamespace CustomXaml\n\n Public Class OutlinedText\n Inherits FrameworkElement\n Implements IAddChild\n\n Private _textGeometry As Geometry\n\n Private Shared Sub OnOutlineTextInvalidated(d As DependencyObject, e As DependencyPropertyChangedEventArgs)\n DirectCast(d, OutlinedText).CreateText()\n End Sub\n\n Protected Overrides Sub OnRender(drawingContext As System.Windows.Media.DrawingContext)\n CreateText()\n drawingContext.DrawGeometry(Fill, New Pen(Stroke, StrokeThickness), _textGeometry)\n End Sub\n\n Public Sub CreateText()\n Dim fontStyle = FontStyles.Normal\n Dim fontWeight = FontWeights.Medium\n Dim fontDecoration = New TextDecorationCollection()\n\n If Bold Then fontWeight = FontWeights.Bold\n If Italic Then fontStyle = FontStyles.Italic\n If Underline Then fontDecoration.Add(TextDecorations.Underline)\n\n Dim formattedText = New FormattedText( _\n Text, _\n CultureInfo.GetCultureInfo(\"en-us\"), _\n FlowDirection.LeftToRight, _\n New Typeface(Font, fontStyle, fontWeight, FontStretches.Normal), _\n FontSize, _\n Brushes.Black _\n )\n formattedText.SetTextDecorations(fontDecoration)\n\n _textGeometry = formattedText.BuildGeometry(New Point(0, 0))\n\n Me.MinWidth = formattedText.Width\n Me.MinHeight = formattedText.Height\n End Sub\n\n Public Property Bold As Boolean\n Get\n Return CType(GetValue(BoldProperty), Boolean)\n End Get\n Set(value As Boolean)\n SetValue(BoldProperty, value)\n End Set\n End Property\n\n Public Shared ReadOnly BoldProperty As DependencyProperty = DependencyProperty.Register( _\n \"Bold\", _\n GetType(Boolean), _\n GetType(OutlinedText), _\n New FrameworkPropertyMetadata( _\n False, _\n FrameworkPropertyMetadataOptions.AffectsRender, _\n New PropertyChangedCallback(AddressOf OnOutlineTextInvalidated), _\n Nothing _\n ) _\n )\n\n Public Property Underline As Boolean\n Get\n Return CType(GetValue(UnderlineProperty), Boolean)\n End Get\n Set(value As Boolean)\n SetValue(UnderlineProperty, value)\n End Set\n End Property\n\n Public Shared ReadOnly UnderlineProperty As DependencyProperty = DependencyProperty.Register( _\n \"Underline\", _\n GetType(Boolean), _\n GetType(OutlinedText), _\n New FrameworkPropertyMetadata( _\n False, _\n FrameworkPropertyMetadataOptions.AffectsRender, _\n New PropertyChangedCallback(AddressOf OnOutlineTextInvalidated), _\n Nothing _\n ) _\n )\n\n Public Property Fill As Brush\n Get\n Return CType(GetValue(FillProperty), Brush)\n End Get\n Set(value As Brush)\n SetValue(FillProperty, value)\n End Set\n End Property\n\n Public Shared ReadOnly FillProperty As DependencyProperty = DependencyProperty.Register( _\n \"Fill\", _\n GetType(Brush), _\n GetType(OutlinedText), _\n New FrameworkPropertyMetadata( _\n New SolidColorBrush(Colors.LightSteelBlue), _\n FrameworkPropertyMetadataOptions.AffectsRender, _\n New PropertyChangedCallback(AddressOf OnOutlineTextInvalidated), _\n Nothing _\n ) _\n )\n\n Public Property Font As FontFamily\n Get\n Return CType(GetValue(FontProperty), FontFamily)\n End Get\n Set(value As FontFamily)\n SetValue(FontProperty, value)\n End Set\n End Property\n\n Public Shared ReadOnly FontProperty As DependencyProperty = DependencyProperty.Register( _\n \"Font\", _\n GetType(FontFamily), _\n GetType(OutlinedText), _\n New FrameworkPropertyMetadata( _\n New FontFamily(\"Arial\"), _\n FrameworkPropertyMetadataOptions.AffectsRender, _\n New PropertyChangedCallback(AddressOf OnOutlineTextInvalidated), _\n Nothing _\n ) _\n )\n\n Public Property FontSize As Double\n Get\n Return CType(GetValue(FontSizeProperty), Double)\n End Get\n Set(value As Double)\n SetValue(FontSizeProperty, value)\n End Set\n End Property\n\n Public Shared ReadOnly FontSizeProperty As DependencyProperty = DependencyProperty.Register( _\n \"FontSize\", _\n GetType(Double), _\n GetType(OutlinedText), _\n New FrameworkPropertyMetadata( _\n CDbl(48.0), _\n FrameworkPropertyMetadataOptions.AffectsRender, _\n New PropertyChangedCallback(AddressOf OnOutlineTextInvalidated), _\n Nothing _\n ) _\n )\n\n Public Property Italic As Boolean\n Get\n Return CType(GetValue(ItalicProperty), Boolean)\n End Get\n Set(value As Boolean)\n SetValue(ItalicProperty, value)\n End Set\n End Property\n\n Public Shared ReadOnly ItalicProperty As DependencyProperty = DependencyProperty.Register( _\n \"Italic\", _\n GetType(Boolean), _\n GetType(OutlinedText), _\n New FrameworkPropertyMetadata( _\n False, _\n FrameworkPropertyMetadataOptions.AffectsRender, _\n New PropertyChangedCallback(AddressOf OnOutlineTextInvalidated), _\n Nothing _\n ) _\n )\n\n Public Property Stroke As Brush\n Get\n Return CType(GetValue(StrokeProperty), Brush)\n End Get\n Set(value As Brush)\n SetValue(StrokeProperty, value)\n End Set\n End Property\n\n Public Shared ReadOnly StrokeProperty As DependencyProperty = DependencyProperty.Register( _\n \"Stroke\", _\n GetType(Brush), _\n GetType(OutlinedText), _\n New FrameworkPropertyMetadata( _\n New SolidColorBrush(Colors.Teal), _\n FrameworkPropertyMetadataOptions.AffectsRender, _\n New PropertyChangedCallback(AddressOf OnOutlineTextInvalidated), _\n Nothing _\n ) _\n )\n\n Public Property StrokeThickness As Double\n Get\n Return CType(GetValue(StrokeThicknessProperty), Double)\n End Get\n Set(value As Double)\n SetValue(StrokeThicknessProperty, value)\n End Set\n End Property\n\n Public Shared ReadOnly StrokeThicknessProperty As DependencyProperty = DependencyProperty.Register( _\n \"StrokeThickness\", _\n GetType(Double), _\n GetType(OutlinedText), _\n New FrameworkPropertyMetadata( _\n CDbl(0), _\n FrameworkPropertyMetadataOptions.AffectsRender, _\n New PropertyChangedCallback(AddressOf OnOutlineTextInvalidated), _\n Nothing _\n ) _\n )\n\n Public Property Text As String\n Get\n Return CType(GetValue(TextProperty), String)\n End Get\n Set(value As String)\n SetValue(TextProperty, value)\n End Set\n End Property\n\n Public Shared ReadOnly TextProperty As DependencyProperty = DependencyProperty.Register( _\n \"Text\", _\n GetType(String), _\n GetType(OutlinedText), _\n New FrameworkPropertyMetadata( _\n \"\", _\n FrameworkPropertyMetadataOptions.AffectsRender, _\n New PropertyChangedCallback(AddressOf OnOutlineTextInvalidated), _\n Nothing _\n ) _\n )\n\n Public Sub AddChild(value As Object) Implements System.Windows.Markup.IAddChild.AddChild\n\n End Sub\n\n Public Sub AddText(text As String) Implements System.Windows.Markup.IAddChild.AddText\n Me.Text = text\n End Sub\n End Class\nEnd Namespace\n"
},
{
"answer_id": 9887123,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 8,
"selected": true,
"text": "<local:OutlinedTextBlock FontFamily=\"Verdana\" FontSize=\"20pt\" FontWeight=\"ExtraBold\" TextWrapping=\"Wrap\" StrokeThickness=\"1\" Stroke=\"{StaticResource TextStroke}\" Fill=\"{StaticResource TextFill}\">\n Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit\n</local:OutlinedTextBlock>\n"
},
{
"answer_id": 10858323,
"author": "Paul Duffy",
"author_id": 1431737,
"author_profile": "https://Stackoverflow.com/users/1431737",
"pm_score": 1,
"selected": false,
"text": "OnRender()"
},
{
"answer_id": 11547043,
"author": "Chris Klepeis",
"author_id": 71904,
"author_profile": "https://Stackoverflow.com/users/71904",
"pm_score": 0,
"selected": false,
"text": " protected override Size MeasureOverride(Size availableSize)\n {\n this.EnsureFormattedText();\n\n if (this.formattedText == null)\n {\n this.formattedText = new FormattedText(\n (this.Text == null) ? \"\" : this.Text,\n CultureInfo.CurrentUICulture,\n this.FlowDirection,\n new Typeface(this.FontFamily, this.FontStyle, this.FontWeight, FontStretches.Normal),\n this.FontSize,\n Brushes.Black);\n }\n\n // constrain the formatted text according to the available size\n // the Math.Min call is important - without this constraint (which seems arbitrary, but is the maximum allowable text width), things blow up when availableSize is infinite in both directions\n this.formattedText.MaxTextWidth = Math.Min(3579139, availableSize.Width);\n this.formattedText.MaxTextHeight = availableSize.Height;\n\n // return the desired size\n return new Size(this.formattedText.Width, this.formattedText.Height);\n }\n"
},
{
"answer_id": 22998692,
"author": "Steph M",
"author_id": 2453011,
"author_profile": "https://Stackoverflow.com/users/2453011",
"pm_score": 1,
"selected": false,
"text": "<Style x:Key=\"OutlinedTextBlockOuter\" TargetType=\"TextBlock\">\n <Setter Property=\"Foreground\" Value=\"Black\" />\n <Setter Property=\"FontSize\" Value=\"10\"/>\n <Setter Property=\"Effect\">\n <Setter.Value>\n <BlurEffect Radius=\"3.0\"/>\n </Setter.Value>\n </Setter>\n</Style>\n<Style x:Key=\"OutlinedTextBlockInner\" TargetType=\"TextBlock\">\n <Setter Property=\"Foreground\" Value=\"White\" />\n <Setter Property=\"FontSize\" Value=\"10\"/>\n</Style>\n"
},
{
"answer_id": 25739593,
"author": "Eyal Kofman Cagan",
"author_id": 4021994,
"author_profile": "https://Stackoverflow.com/users/4021994",
"pm_score": 2,
"selected": false,
"text": "ContentControl"
},
{
"answer_id": 35261866,
"author": "Javier G.",
"author_id": 4814450,
"author_profile": "https://Stackoverflow.com/users/4814450",
"pm_score": 1,
"selected": false,
"text": "// return the desired size\nreturn new Size(Math.Ceiling(_FormattedText.Width), Math.Ceiling(_FormattedText.Height));\n"
},
{
"answer_id": 35262509,
"author": "Javier G.",
"author_id": 4814450,
"author_profile": "https://Stackoverflow.com/users/4814450",
"pm_score": 6,
"selected": false,
"text": "using System;\nusing System.ComponentModel;\nusing System.Globalization;\nusing System.Windows;\nusing System.Windows.Documents;\nusing System.Windows.Markup;\nusing System.Windows.Media;\n\n[ContentProperty(\"Text\")]\npublic class OutlinedTextBlock : FrameworkElement\n{\n private void UpdatePen() {\n _Pen = new Pen(Stroke, StrokeThickness) {\n DashCap = PenLineCap.Round,\n EndLineCap = PenLineCap.Round,\n LineJoin = PenLineJoin.Round,\n StartLineCap = PenLineCap.Round\n };\n\n InvalidateVisual();\n }\n\n public static readonly DependencyProperty FillProperty = DependencyProperty.Register(\n \"Fill\",\n typeof(Brush),\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(Brushes.Black, FrameworkPropertyMetadataOptions.AffectsRender));\n\n public static readonly DependencyProperty StrokeProperty = DependencyProperty.Register(\n \"Stroke\",\n typeof(Brush),\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(Brushes.Black, FrameworkPropertyMetadataOptions.AffectsRender, StrokePropertyChangedCallback));\n\n private static void StrokePropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) {\n (dependencyObject as OutlinedTextBlock)?.UpdatePen();\n }\n\n public static readonly DependencyProperty StrokeThicknessProperty = DependencyProperty.Register(\n \"StrokeThickness\",\n typeof(double),\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(1d, FrameworkPropertyMetadataOptions.AffectsRender, StrokePropertyChangedCallback));\n\n public static readonly DependencyProperty FontFamilyProperty = TextElement.FontFamilyProperty.AddOwner(\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(OnFormattedTextUpdated));\n\n public static readonly DependencyProperty FontSizeProperty = TextElement.FontSizeProperty.AddOwner(\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(OnFormattedTextUpdated));\n\n public static readonly DependencyProperty FontStretchProperty = TextElement.FontStretchProperty.AddOwner(\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(OnFormattedTextUpdated));\n\n public static readonly DependencyProperty FontStyleProperty = TextElement.FontStyleProperty.AddOwner(\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(OnFormattedTextUpdated));\n\n public static readonly DependencyProperty FontWeightProperty = TextElement.FontWeightProperty.AddOwner(\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(OnFormattedTextUpdated));\n\n public static readonly DependencyProperty TextProperty = DependencyProperty.Register(\n \"Text\",\n typeof(string),\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(OnFormattedTextInvalidated));\n\n public static readonly DependencyProperty TextAlignmentProperty = DependencyProperty.Register(\n \"TextAlignment\",\n typeof(TextAlignment),\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(OnFormattedTextUpdated));\n\n public static readonly DependencyProperty TextDecorationsProperty = DependencyProperty.Register(\n \"TextDecorations\",\n typeof(TextDecorationCollection),\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(OnFormattedTextUpdated));\n\n public static readonly DependencyProperty TextTrimmingProperty = DependencyProperty.Register(\n \"TextTrimming\",\n typeof(TextTrimming),\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(OnFormattedTextUpdated));\n\n public static readonly DependencyProperty TextWrappingProperty = DependencyProperty.Register(\n \"TextWrapping\",\n typeof(TextWrapping),\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(TextWrapping.NoWrap, OnFormattedTextUpdated));\n\n private FormattedText _FormattedText;\n private Geometry _TextGeometry;\n private Pen _Pen;\n\n public Brush Fill\n {\n get { return (Brush)GetValue(FillProperty); }\n set { SetValue(FillProperty, value); }\n }\n\n public FontFamily FontFamily\n {\n get { return (FontFamily)GetValue(FontFamilyProperty); }\n set { SetValue(FontFamilyProperty, value); }\n }\n\n [TypeConverter(typeof(FontSizeConverter))]\n public double FontSize\n {\n get { return (double)GetValue(FontSizeProperty); }\n set { SetValue(FontSizeProperty, value); }\n }\n\n public FontStretch FontStretch\n {\n get { return (FontStretch)GetValue(FontStretchProperty); }\n set { SetValue(FontStretchProperty, value); }\n }\n\n public FontStyle FontStyle\n {\n get { return (FontStyle)GetValue(FontStyleProperty); }\n set { SetValue(FontStyleProperty, value); }\n }\n\n public FontWeight FontWeight\n {\n get { return (FontWeight)GetValue(FontWeightProperty); }\n set { SetValue(FontWeightProperty, value); }\n }\n\n public Brush Stroke\n {\n get { return (Brush)GetValue(StrokeProperty); }\n set { SetValue(StrokeProperty, value); }\n }\n\n public double StrokeThickness\n {\n get { return (double)GetValue(StrokeThicknessProperty); }\n set { SetValue(StrokeThicknessProperty, value); }\n }\n\n public string Text\n {\n get { return (string)GetValue(TextProperty); }\n set { SetValue(TextProperty, value); }\n }\n\n public TextAlignment TextAlignment\n {\n get { return (TextAlignment)GetValue(TextAlignmentProperty); }\n set { SetValue(TextAlignmentProperty, value); }\n }\n\n public TextDecorationCollection TextDecorations\n {\n get { return (TextDecorationCollection)GetValue(TextDecorationsProperty); }\n set { SetValue(TextDecorationsProperty, value); }\n }\n\n public TextTrimming TextTrimming\n {\n get { return (TextTrimming)GetValue(TextTrimmingProperty); }\n set { SetValue(TextTrimmingProperty, value); }\n }\n\n public TextWrapping TextWrapping\n {\n get { return (TextWrapping)GetValue(TextWrappingProperty); }\n set { SetValue(TextWrappingProperty, value); }\n }\n\n public OutlinedTextBlock() {\n UpdatePen();\n TextDecorations = new TextDecorationCollection();\n }\n\n protected override void OnRender(DrawingContext drawingContext) {\n EnsureGeometry();\n\n drawingContext.DrawGeometry(null, _Pen, _TextGeometry);\n drawingContext.DrawGeometry(Fill, null, _TextGeometry);\n }\n\n protected override Size MeasureOverride(Size availableSize) {\n EnsureFormattedText();\n\n // constrain the formatted text according to the available size\n\n double w = availableSize.Width;\n double h = availableSize.Height;\n\n // the Math.Min call is important - without this constraint (which seems arbitrary, but is the maximum allowable text width), things blow up when availableSize is infinite in both directions\n // the Math.Max call is to ensure we don't hit zero, which will cause MaxTextHeight to throw\n _FormattedText.MaxTextWidth = Math.Min(3579139, w);\n _FormattedText.MaxTextHeight = Math.Max(0.0001d, h);\n\n // return the desired size\n return new Size(Math.Ceiling(_FormattedText.Width), Math.Ceiling(_FormattedText.Height));\n }\n\n protected override Size ArrangeOverride(Size finalSize) {\n EnsureFormattedText();\n\n // update the formatted text with the final size\n _FormattedText.MaxTextWidth = finalSize.Width;\n _FormattedText.MaxTextHeight = Math.Max(0.0001d, finalSize.Height);\n\n // need to re-generate the geometry now that the dimensions have changed\n _TextGeometry = null;\n\n return finalSize;\n }\n\n private static void OnFormattedTextInvalidated(DependencyObject dependencyObject,\n DependencyPropertyChangedEventArgs e) {\n var outlinedTextBlock = (OutlinedTextBlock)dependencyObject;\n outlinedTextBlock._FormattedText = null;\n outlinedTextBlock._TextGeometry = null;\n\n outlinedTextBlock.InvalidateMeasure();\n outlinedTextBlock.InvalidateVisual();\n }\n\n private static void OnFormattedTextUpdated(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) {\n var outlinedTextBlock = (OutlinedTextBlock)dependencyObject;\n outlinedTextBlock.UpdateFormattedText();\n outlinedTextBlock._TextGeometry = null;\n\n outlinedTextBlock.InvalidateMeasure();\n outlinedTextBlock.InvalidateVisual();\n }\n\n private void EnsureFormattedText() {\n if (_FormattedText != null) {\n return;\n }\n\n _FormattedText = new FormattedText(\n Text ?? \"\",\n CultureInfo.CurrentUICulture,\n FlowDirection,\n new Typeface(FontFamily, FontStyle, FontWeight, FontStretch),\n FontSize,\n Brushes.Black);\n\n UpdateFormattedText();\n }\n\n private void UpdateFormattedText() {\n if (_FormattedText == null) {\n return;\n }\n\n _FormattedText.MaxLineCount = TextWrapping == TextWrapping.NoWrap ? 1 : int.MaxValue;\n _FormattedText.TextAlignment = TextAlignment;\n _FormattedText.Trimming = TextTrimming;\n\n _FormattedText.SetFontSize(FontSize);\n _FormattedText.SetFontStyle(FontStyle);\n _FormattedText.SetFontWeight(FontWeight);\n _FormattedText.SetFontFamily(FontFamily);\n _FormattedText.SetFontStretch(FontStretch);\n _FormattedText.SetTextDecorations(TextDecorations);\n }\n\n private void EnsureGeometry() {\n if (_TextGeometry != null) {\n return;\n }\n\n EnsureFormattedText();\n _TextGeometry = _FormattedText.BuildGeometry(new Point(0, 0));\n }\n}\n"
},
{
"answer_id": 49636033,
"author": "codeDom",
"author_id": 5306861,
"author_profile": "https://Stackoverflow.com/users/5306861",
"pm_score": 4,
"selected": false,
"text": "using System;\nusing System.ComponentModel;\nusing System.Globalization;\nusing System.Windows;\nusing System.Windows.Documents;\nusing System.Windows.Markup;\nusing System.Windows.Media;\n\nnamespace WpfApp2\n{\n public enum StrokePosition\n {\n Center,\n Outside,\n Inside\n }\n\n [ContentProperty(\"Text\")]\n public class OutlinedTextBlock : FrameworkElement\n {\n private void UpdatePen()\n {\n _Pen = new Pen(Stroke, StrokeThickness)\n {\n DashCap = PenLineCap.Round,\n EndLineCap = PenLineCap.Round,\n LineJoin = PenLineJoin.Round,\n StartLineCap = PenLineCap.Round\n };\n\n if (StrokePosition == StrokePosition.Outside || StrokePosition == StrokePosition.Inside)\n {\n _Pen.Thickness = StrokeThickness * 2;\n }\n\n InvalidateVisual();\n }\n\n public StrokePosition StrokePosition\n {\n get { return (StrokePosition)GetValue(StrokePositionProperty); }\n set { SetValue(StrokePositionProperty, value); }\n }\n\n public static readonly DependencyProperty StrokePositionProperty =\n DependencyProperty.Register(\"StrokePosition\", \n typeof(StrokePosition),\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(StrokePosition.Outside, FrameworkPropertyMetadataOptions.AffectsRender));\n\n public static readonly DependencyProperty FillProperty = DependencyProperty.Register(\n \"Fill\",\n typeof(Brush),\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(Brushes.Black, FrameworkPropertyMetadataOptions.AffectsRender));\n\n public static readonly DependencyProperty StrokeProperty = DependencyProperty.Register(\n \"Stroke\",\n typeof(Brush),\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(Brushes.Black, FrameworkPropertyMetadataOptions.AffectsRender));\n\n public static readonly DependencyProperty StrokeThicknessProperty = DependencyProperty.Register(\n \"StrokeThickness\",\n typeof(double),\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(1d, FrameworkPropertyMetadataOptions.AffectsRender));\n\n public static readonly DependencyProperty FontFamilyProperty = TextElement.FontFamilyProperty.AddOwner(\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(OnFormattedTextUpdated));\n\n public static readonly DependencyProperty FontSizeProperty = TextElement.FontSizeProperty.AddOwner(\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(OnFormattedTextUpdated));\n\n public static readonly DependencyProperty FontStretchProperty = TextElement.FontStretchProperty.AddOwner(\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(OnFormattedTextUpdated));\n\n public static readonly DependencyProperty FontStyleProperty = TextElement.FontStyleProperty.AddOwner(\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(OnFormattedTextUpdated));\n\n public static readonly DependencyProperty FontWeightProperty = TextElement.FontWeightProperty.AddOwner(\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(OnFormattedTextUpdated));\n\n public static readonly DependencyProperty TextProperty = DependencyProperty.Register(\n \"Text\",\n typeof(string),\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(OnFormattedTextInvalidated));\n\n public static readonly DependencyProperty TextAlignmentProperty = DependencyProperty.Register(\n \"TextAlignment\",\n typeof(TextAlignment),\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(OnFormattedTextUpdated));\n\n public static readonly DependencyProperty TextDecorationsProperty = DependencyProperty.Register(\n \"TextDecorations\",\n typeof(TextDecorationCollection),\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(OnFormattedTextUpdated));\n\n public static readonly DependencyProperty TextTrimmingProperty = DependencyProperty.Register(\n \"TextTrimming\",\n typeof(TextTrimming),\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(OnFormattedTextUpdated));\n\n public static readonly DependencyProperty TextWrappingProperty = DependencyProperty.Register(\n \"TextWrapping\",\n typeof(TextWrapping),\n typeof(OutlinedTextBlock),\n new FrameworkPropertyMetadata(TextWrapping.NoWrap, OnFormattedTextUpdated));\n\n private FormattedText _FormattedText;\n private Geometry _TextGeometry;\n private Pen _Pen;\n private PathGeometry _clipGeometry;\n\n public Brush Fill\n {\n get { return (Brush)GetValue(FillProperty); }\n set { SetValue(FillProperty, value); }\n }\n\n public FontFamily FontFamily\n {\n get { return (FontFamily)GetValue(FontFamilyProperty); }\n set { SetValue(FontFamilyProperty, value); }\n }\n\n [TypeConverter(typeof(FontSizeConverter))]\n public double FontSize\n {\n get { return (double)GetValue(FontSizeProperty); }\n set { SetValue(FontSizeProperty, value); }\n }\n\n public FontStretch FontStretch\n {\n get { return (FontStretch)GetValue(FontStretchProperty); }\n set { SetValue(FontStretchProperty, value); }\n }\n\n public FontStyle FontStyle\n {\n get { return (FontStyle)GetValue(FontStyleProperty); }\n set { SetValue(FontStyleProperty, value); }\n }\n\n public FontWeight FontWeight\n {\n get { return (FontWeight)GetValue(FontWeightProperty); }\n set { SetValue(FontWeightProperty, value); }\n }\n\n public Brush Stroke\n {\n get { return (Brush)GetValue(StrokeProperty); }\n set { SetValue(StrokeProperty, value); }\n }\n\n public double StrokeThickness\n {\n get { return (double)GetValue(StrokeThicknessProperty); }\n set { SetValue(StrokeThicknessProperty, value); }\n }\n\n public string Text\n {\n get { return (string)GetValue(TextProperty); }\n set { SetValue(TextProperty, value); }\n }\n\n public TextAlignment TextAlignment\n {\n get { return (TextAlignment)GetValue(TextAlignmentProperty); }\n set { SetValue(TextAlignmentProperty, value); }\n }\n\n public TextDecorationCollection TextDecorations\n {\n get { return (TextDecorationCollection)GetValue(TextDecorationsProperty); }\n set { SetValue(TextDecorationsProperty, value); }\n }\n\n public TextTrimming TextTrimming\n {\n get { return (TextTrimming)GetValue(TextTrimmingProperty); }\n set { SetValue(TextTrimmingProperty, value); }\n }\n\n public TextWrapping TextWrapping\n {\n get { return (TextWrapping)GetValue(TextWrappingProperty); }\n set { SetValue(TextWrappingProperty, value); }\n }\n\n public OutlinedTextBlock()\n {\n UpdatePen();\n TextDecorations = new TextDecorationCollection();\n }\n\n protected override void OnRender(DrawingContext drawingContext)\n {\n EnsureGeometry();\n\n drawingContext.DrawGeometry(Fill, null, _TextGeometry);\n\n if (StrokePosition == StrokePosition.Outside)\n {\n drawingContext.PushClip(_clipGeometry);\n }\n else if (StrokePosition == StrokePosition.Inside)\n {\n drawingContext.PushClip(_TextGeometry);\n }\n\n drawingContext.DrawGeometry(null, _Pen, _TextGeometry);\n\n if (StrokePosition == StrokePosition.Outside || StrokePosition == StrokePosition.Inside)\n {\n drawingContext.Pop();\n }\n }\n\n protected override Size MeasureOverride(Size availableSize)\n {\n EnsureFormattedText();\n\n // constrain the formatted text according to the available size\n\n double w = availableSize.Width;\n double h = availableSize.Height;\n\n // the Math.Min call is important - without this constraint (which seems arbitrary, but is the maximum allowable text width), things blow up when availableSize is infinite in both directions\n // the Math.Max call is to ensure we don't hit zero, which will cause MaxTextHeight to throw\n _FormattedText.MaxTextWidth = Math.Min(3579139, w);\n _FormattedText.MaxTextHeight = Math.Max(0.0001d, h);\n\n // return the desired size\n return new Size(Math.Ceiling(_FormattedText.Width), Math.Ceiling(_FormattedText.Height));\n }\n\n protected override Size ArrangeOverride(Size finalSize)\n {\n EnsureFormattedText();\n\n // update the formatted text with the final size\n _FormattedText.MaxTextWidth = finalSize.Width;\n _FormattedText.MaxTextHeight = Math.Max(0.0001d, finalSize.Height);\n\n // need to re-generate the geometry now that the dimensions have changed\n _TextGeometry = null;\n UpdatePen();\n\n return finalSize;\n }\n\n private static void OnFormattedTextInvalidated(DependencyObject dependencyObject,\n DependencyPropertyChangedEventArgs e)\n {\n var outlinedTextBlock = (OutlinedTextBlock)dependencyObject;\n outlinedTextBlock._FormattedText = null;\n outlinedTextBlock._TextGeometry = null;\n\n outlinedTextBlock.InvalidateMeasure();\n outlinedTextBlock.InvalidateVisual();\n }\n\n private static void OnFormattedTextUpdated(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)\n {\n var outlinedTextBlock = (OutlinedTextBlock)dependencyObject;\n outlinedTextBlock.UpdateFormattedText();\n outlinedTextBlock._TextGeometry = null;\n\n outlinedTextBlock.InvalidateMeasure();\n outlinedTextBlock.InvalidateVisual();\n }\n\n private void EnsureFormattedText()\n {\n if (_FormattedText != null)\n {\n return;\n }\n\n _FormattedText = new FormattedText(\n Text ?? \"\",\n CultureInfo.CurrentUICulture,\n FlowDirection,\n new Typeface(FontFamily, FontStyle, FontWeight, FontStretch),\n FontSize,\n Brushes.Black);\n\n UpdateFormattedText();\n }\n\n private void UpdateFormattedText()\n {\n if (_FormattedText == null)\n {\n return;\n }\n\n _FormattedText.MaxLineCount = TextWrapping == TextWrapping.NoWrap ? 1 : int.MaxValue;\n _FormattedText.TextAlignment = TextAlignment;\n _FormattedText.Trimming = TextTrimming;\n\n _FormattedText.SetFontSize(FontSize);\n _FormattedText.SetFontStyle(FontStyle);\n _FormattedText.SetFontWeight(FontWeight);\n _FormattedText.SetFontFamily(FontFamily);\n _FormattedText.SetFontStretch(FontStretch);\n _FormattedText.SetTextDecorations(TextDecorations);\n }\n\n private void EnsureGeometry()\n {\n if (_TextGeometry != null)\n {\n return;\n }\n\n EnsureFormattedText();\n _TextGeometry = _FormattedText.BuildGeometry(new Point(0, 0));\n\n if (StrokePosition == StrokePosition.Outside)\n {\n var boundsGeo = new RectangleGeometry(new Rect(0, 0, ActualWidth, ActualHeight));\n _clipGeometry = Geometry.Combine(boundsGeo, _TextGeometry, GeometryCombineMode.Exclude, null);\n } \n }\n }\n}\n"
},
{
"answer_id": 51172253,
"author": "user00101010",
"author_id": 10031539,
"author_profile": "https://Stackoverflow.com/users/10031539",
"pm_score": 2,
"selected": false,
"text": "FormattedText t = new FormattedText\n(\n \"abcxyz\",\n CultureInfo.GetCultureInfo(\"en-us\"),\n FlowDirection.LeftToRight,\n new Typeface(\n new FontFamily(\"Arial\"),\n new FontStyle(),\n new FontWeight(),\n new FontStretch()),\n 20,\n Brushes.Transparent\n);\n\nGeometry g = t.BuildGeometry(new System.Windows.Point(0, 0));\n\nPath p = new Path();\np.Fill = Brushes.White;\np.Stroke = Brushes.Black;\np.StrokeThickness = 1;\np.Data = g;\n"
},
{
"answer_id": 56854629,
"author": "bwall",
"author_id": 5617177,
"author_profile": "https://Stackoverflow.com/users/5617177",
"pm_score": 2,
"selected": false,
"text": "<Grid>\n <Grid.Resources>\n <local:EdgeDetectionEffect x:Key=\"OutlineEffect\"\n x:Shared=\"false\"\n EdgeResponse=\".44\"\n ActualHeight=\"{Binding RelativeSource={RelativeSource AncestorType=TextBlock}, Path=ActualHeight}\"\n ActualWidth=\"{Binding RelativeSource={RelativeSource AncestorType=TextBlock}, Path=ActualWidth}\"/>\n </Grid.Resources>\n <TextBlock Text=\"The Crazy Brown Fox Jumped Over the Lazy Dog.\"\n FontWeight=\"Bold\"\n FontSize=\"25\"\n Foreground=\"Yellow\"\n Effect=\"{StaticResource OutlineEffect}\"/>\n</Grid>\n"
},
{
"answer_id": 69330921,
"author": "TRex",
"author_id": 13668671,
"author_profile": "https://Stackoverflow.com/users/13668671",
"pm_score": 0,
"selected": false,
"text": "Geometry"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3798/"
] |
93,653
|
<p>I've got a stored procedure in my database, that looks like this</p>
<pre><code>ALTER PROCEDURE [dbo].[GetCountingAnalysisResults]
@RespondentFilters varchar
AS
BEGIN
@RespondentFilters = '''8ec94bed-fed6-4627-8d45-21619331d82a, 114c61f2-8935-4755-b4e9-4a598a51cc7f'''
DECLARE @SQL nvarchar(600)
SET @SQL =
'SELECT *
FROM Answer
WHERE Answer.RespondentId IN ('+@RespondentFilters+'''))
GROUP BY ChosenOptionId'
exec sp_executesql @SQL
END
</code></pre>
<p>It compiles and executes, but somehow it doesn't give me good results, just like the IN statement wasn't working. Please, if anybody know the solution to this problem, help me.</p>
|
[
{
"answer_id": 93701,
"author": "Jeremiah Peschka",
"author_id": 11780,
"author_profile": "https://Stackoverflow.com/users/11780",
"pm_score": 1,
"selected": false,
"text": "\n-- This would be the input parameter of the stored procedure, if you want to do it that way, or a UDF\ndeclare @string varchar(500)\nset @string = 'ABC,DEF,GHIJK,LMNOPQRS,T,UV,WXY,Z'\n\n\ndeclare @pos int\ndeclare @piece varchar(500)\n\n-- Need to tack a delimiter onto the end of the input string if one doesn't exist\nif right(rtrim(@string),1) ','\n set @string = @string + ','\n\nset @pos = patindex('%,%' , @string)\nwhile @pos 0\nbegin\n set @piece = left(@string, @pos - 1)\n\n -- You have a piece of data, so insert it, print it, do whatever you want to with it.\n print cast(@piece as varchar(500))\n\n set @string = stuff(@string, 1, @pos, '')\n set @pos = patindex('%,%' , @string)\nend\n"
},
{
"answer_id": 93729,
"author": "TrevorD",
"author_id": 12492,
"author_profile": "https://Stackoverflow.com/users/12492",
"pm_score": 1,
"selected": false,
"text": "@RespondentFilters = '''8ec94bed-fed6-4627-8d45-21619331d82a'',''114c61f2-8935-4755-b4e9-4a598a51cc7f'''\n"
},
{
"answer_id": 93734,
"author": "John Sheehan",
"author_id": 1786,
"author_profile": "https://Stackoverflow.com/users/1786",
"pm_score": 2,
"selected": false,
"text": "@RespondentFilters = '''8ec94bed-fed6-4627-8d45-21619331d82a'', ''114c61f2-8935-4755-b4e9-4a598a51cc7f'''\n"
},
{
"answer_id": 93886,
"author": "Brannon",
"author_id": 5745,
"author_profile": "https://Stackoverflow.com/users/5745",
"pm_score": 2,
"selected": false,
"text": "@RespondentFilters = '''''); SELECT * FROM User; /*'\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16003/"
] |
93,654
|
<p>I'd sort of like to use SQLite from within C#.Net, but I can't seem to find an appropriate library. Is there one? An official one? Are there other ways to use SQLite than with a wrapper?</p>
|
[
{
"answer_id": 48971442,
"author": "Simon Mourier",
"author_id": 403671,
"author_profile": "https://Stackoverflow.com/users/403671",
"pm_score": 2,
"selected": false,
"text": "netstandard"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/93438/"
] |
93,655
|
<p>I have an XML file that's the output from a database. I'm using the Java SAX parser to parse the XML and output it in a different format. The XML contains some invalid characters and the parser is throwing errors like 'Invalid Unicode character (0x5)'</p>
<p>Is there a good way to strip all these characters out besides pre-processing the file line-by-line and replacing them? So far I've run into 3 different invalid characters (0x5, 0x6 and 0x7). It's a ~4gb database dump and we're going to be processing it a bunch of times, so having to wait an extra 30 minutes each time we get a new dump to run a pre-processor on it is going to be a pain, and this isn't the first time I've run into this issue.</p>
|
[
{
"answer_id": 7726882,
"author": "ogrisel",
"author_id": 163740,
"author_profile": "https://Stackoverflow.com/users/163740",
"pm_score": 3,
"selected": false,
"text": "Pattern INVALID_XML_CHARS = Pattern.compile(\"[^\\\\u0009\\\\u000A\\\\u000D\\\\u0020-\\\\uD7FF\\\\uE000-\\\\uFFFD\\uD800\\uDC00-\\uDBFF\\uDFFF]\");\n...\nINVALID_XML_CHARS.matcher(stringToCleanup).replaceAll(\"\");\n"
},
{
"answer_id": 8132288,
"author": "jankar",
"author_id": 1046948,
"author_profile": "https://Stackoverflow.com/users/1046948",
"pm_score": 2,
"selected": false,
"text": "BufferedReader reader = null;\n...\nString line = reader.readLine().replaceAll(\"[\\\\x00-\\\\x1F]\", \"\");\n"
},
{
"answer_id": 9635310,
"author": "Bozho",
"author_id": 203907,
"author_profile": "https://Stackoverflow.com/users/203907",
"pm_score": 5,
"selected": false,
"text": "org.apache.xml.utils.XMLChar"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8973/"
] |
93,672
|
<p>Is there a 7-Zip command-line switch that prevents the filenames from echoing to the screen as they are added to the archive?</p>
|
[
{
"answer_id": 93702,
"author": "freespace",
"author_id": 8297,
"author_profile": "https://Stackoverflow.com/users/8297",
"pm_score": 1,
"selected": false,
"text": ">"
},
{
"answer_id": 93714,
"author": "workmad3",
"author_id": 16035,
"author_profile": "https://Stackoverflow.com/users/16035",
"pm_score": 3,
"selected": false,
"text": "<7z command here> 2>&1 NUL\n"
},
{
"answer_id": 93719,
"author": "Dario Solera",
"author_id": 16026,
"author_profile": "https://Stackoverflow.com/users/16026",
"pm_score": 0,
"selected": false,
"text": "7z.exe ... normal parameters > DumpFile.txt\n"
},
{
"answer_id": 5734620,
"author": "Karl Glennon",
"author_id": 23393,
"author_profile": "https://Stackoverflow.com/users/23393",
"pm_score": 2,
"selected": false,
"text": "Out-Null"
},
{
"answer_id": 12208911,
"author": "Bruno Dermario",
"author_id": 1080818,
"author_profile": "https://Stackoverflow.com/users/1080818",
"pm_score": 0,
"selected": false,
"text": "...\\right_path\\7z a output.zip folder_to_be_compressed | findstr /b /r /c:\"\\<Everything is Ok\" /c:\"\\<Scanning\" /c:\"\\<Creating archive\"\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7519/"
] |
93,692
|
<p>I want to embed Javascript in a hobby game engine of mine. Now that we have the 5th generation of Javascript engines out (all blazing fast) I'm curious what engine would you choose to embed in a C++ framework (that includes actual ease of embeding it)? </p>
<p><sup><em>Note: Just to make it clear, I'm not interested in DOM scripting or writing Javascript in a browser.</em></sup></p>
<p>Here's a compilation of links so far and some tips from the thread</p>
<ul>
<li><a href="http://www.mozilla.org/js/spidermonkey/" rel="noreferrer">SpiderMonkey</a></li>
<li><a href="http://wiki.mozilla.org/JavaScript:TraceMonkey" rel="noreferrer">tracemonkey</a> (note:backwards compatible with spidermonkey):</li>
<li><a href="http://code.google.com/p/v8/" rel="noreferrer">V8</a></li>
<li><a href="http://trac.webkit.org/wiki/SquirrelFish" rel="noreferrer">Squirrelfish</a></li>
</ul>
<p>Just for the record, I love Lua and have already embedded it in game engines about 5 times at work.</p>
<p>However now this is a hobby project, and I think that Javascript being known by most web developers and because its ECMA, Flash and Flex developers, a game engine that uses Javascript and XML for scripting would be more user-friendly and cater to a larger user base (and one that so far has not had a chance to use their skills for games) than one with Lua (and there are plenty of those around!).</p>
<p>Also for the record I'll go with V8 on this one, mostly because I like it's C++ style.</p>
|
[
{
"answer_id": 97195,
"author": "Daniel James",
"author_id": 2434,
"author_profile": "https://Stackoverflow.com/users/2434",
"pm_score": 3,
"selected": false,
"text": " * Multiple threads in V8 are allowed, but only one thread at a time\n * is allowed to use V8. The definition of 'using V8' includes\n * accessing handles or holding onto object pointers obtained from V8\n * handles. It is up to the user of V8 to ensure (perhaps with\n * locking) that this constraint is not violated.\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15124/"
] |
93,695
|
<p>My users would like to be able to hit <kbd>Ctrl</kbd>+<kbd>S</kbd> to save a form. Is there a good cross-browser way of capturing the <kbd>Ctrl</kbd>+<kbd>S</kbd> key combination and submit my form?</p>
<p>App is built on Drupal, so jQuery is available.</p>
|
[
{
"answer_id": 93836,
"author": "Jim",
"author_id": 8427,
"author_profile": "https://Stackoverflow.com/users/8427",
"pm_score": 8,
"selected": true,
"text": "$(window).keypress(function(event) {\n if (!(event.which == 115 && event.ctrlKey) && !(event.which == 19)) return true;\n alert(\"Ctrl-S pressed\");\n event.preventDefault();\n return false;\n});\n"
},
{
"answer_id": 93926,
"author": "EndangeredMassa",
"author_id": 106,
"author_profile": "https://Stackoverflow.com/users/106",
"pm_score": 5,
"selected": false,
"text": "shortcut.add(\"Ctrl+S\",function() {\n alert(\"Hi there!\");\n});\n"
},
{
"answer_id": 94742,
"author": "Eevee",
"author_id": 17875,
"author_profile": "https://Stackoverflow.com/users/17875",
"pm_score": 3,
"selected": false,
"text": "accesskey"
},
{
"answer_id": 3366290,
"author": "André",
"author_id": 406103,
"author_profile": "https://Stackoverflow.com/users/406103",
"pm_score": 0,
"selected": false,
"text": "shortcut.add(\"Ctrl+c\",function() {\n alert('Ok...');\n}\n,{\n 'type':'keydown',\n 'propagate':false,\n 'target':document\n});\n"
},
{
"answer_id": 8760097,
"author": "pelms",
"author_id": 388902,
"author_profile": "https://Stackoverflow.com/users/388902",
"pm_score": 0,
"selected": false,
"text": "var ctrl_down = false;\nvar ctrl_key = 17;\nvar s_key = 83;\n\n$(document).keydown(function(e) {\n if (e.keyCode == ctrl_key) ctrl_down = true;\n}).keyup(function(e) {\n if (e.keyCode == ctrl_key) ctrl_down = false;\n});\n\n$(document).keydown(function(e) {\n if (ctrl_down && (e.keyCode == s_key)) {\n alert('Ctrl-s pressed');\n // Your code\n return false;\n }\n}); \n"
},
{
"answer_id": 10273585,
"author": "Eran Medan",
"author_id": 239168,
"author_profile": "https://Stackoverflow.com/users/239168",
"pm_score": 5,
"selected": false,
"text": "event.which"
},
{
"answer_id": 14180949,
"author": "Danny Ruijters",
"author_id": 1584657,
"author_profile": "https://Stackoverflow.com/users/1584657",
"pm_score": 8,
"selected": false,
"text": "$(window).bind('keydown', function(event) {\n if (event.ctrlKey || event.metaKey) {\n switch (String.fromCharCode(event.which).toLowerCase()) {\n case 's':\n event.preventDefault();\n alert('ctrl-s');\n break;\n case 'f':\n event.preventDefault();\n alert('ctrl-f');\n break;\n case 'g':\n event.preventDefault();\n alert('ctrl-g');\n break;\n }\n }\n});\n"
},
{
"answer_id": 14385600,
"author": "Alan Bellows",
"author_id": 1154998,
"author_profile": "https://Stackoverflow.com/users/1154998",
"pm_score": 5,
"selected": false,
"text": "$(document).keydown(function(e) {\n\n var key = undefined;\n var possible = [ e.key, e.keyIdentifier, e.keyCode, e.which ];\n\n while (key === undefined && possible.length > 0)\n {\n key = possible.pop();\n }\n\n if (key && (key == '115' || key == '83' ) && (e.ctrlKey || e.metaKey) && !(e.altKey))\n {\n e.preventDefault();\n alert(\"Ctrl-s pressed\");\n return false;\n }\n return true;\n}); \n"
},
{
"answer_id": 15529207,
"author": "uadrive",
"author_id": 947898,
"author_profile": "https://Stackoverflow.com/users/947898",
"pm_score": 3,
"selected": false,
"text": "// simply disables save event for chrome\n$(window).keypress(function (event) {\n if (!(event.which == 115 && (navigator.platform.match(\"Mac\") ? event.metaKey : event.ctrlKey)) && !(event.which == 19)) return true;\n event.preventDefault();\n return false;\n});\n\n// used to process the cmd+s and ctrl+s events\n$(document).keydown(function (event) {\n if (event.which == 83 && (navigator.platform.match(\"Mac\") ? event.metaKey : event.ctrlKey)) {\n event.preventDefault();\n save(event);\n return false;\n }\n});\n"
},
{
"answer_id": 31150541,
"author": "user2570311",
"author_id": 2570311,
"author_profile": "https://Stackoverflow.com/users/2570311",
"pm_score": 0,
"selected": false,
"text": "alert(\"With a message\")"
},
{
"answer_id": 40395848,
"author": "Jaś Fasola",
"author_id": 5682470,
"author_profile": "https://Stackoverflow.com/users/5682470",
"pm_score": 1,
"selected": false,
"text": "$(document).keydown(function(e) {\nif ((e.which == '115' || e.which == '83' ) && (e.ctrlKey || e.metaKey) && !(e.altKey))\n{\n e.preventDefault();\n alert(\"Ctrl-s pressed\");\n return false;\n}\nreturn true; });\n"
},
{
"answer_id": 43966196,
"author": "Cannicide",
"author_id": 6901876,
"author_profile": "https://Stackoverflow.com/users/6901876",
"pm_score": 3,
"selected": false,
"text": "$(document).keydown(function(e) {\n if ((e.key == 's' || e.key == 'S' ) && (e.ctrlKey || e.metaKey))\n {\n e.preventDefault();\n alert(\"Ctrl-s pressed\");\n return false;\n }\n return true;\n}); "
},
{
"answer_id": 44973660,
"author": "10011101111",
"author_id": 5845598,
"author_profile": "https://Stackoverflow.com/users/5845598",
"pm_score": 0,
"selected": false,
"text": "simulatorControl([17,83], function(){\n console.log('You have pressed Ctrl+Z');\n});\n"
},
{
"answer_id": 49258098,
"author": "R. Salisbury",
"author_id": 4230970,
"author_profile": "https://Stackoverflow.com/users/4230970",
"pm_score": 0,
"selected": false,
"text": "$(window).keydown(function(evt) {\n var key = String.fromCharCode(evt.keyCode).toLowerCase();\n switch(key) {\n case \"s\":\n if(evt.ctrlKey || evt.metaKey) {\n fnToRun();\n evt.preventDefault(true);\n return false;\n }\n break;\n }\n return true;\n});\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1902010/"
] |
93,699
|
<p>I remember seeing a while ago that there is some method in maybe the Reflection namespace that would recursively run <code>ToString()</code> on all of an object's properties and format it nicely for display. </p>
<p>Yes, I know everything I could want will be accessible through the debugger, but I'm wondering if anyone knows that command?</p>
|
[
{
"answer_id": 41033428,
"author": "Tomasz Swider",
"author_id": 1904485,
"author_profile": "https://Stackoverflow.com/users/1904485",
"pm_score": 2,
"selected": false,
"text": "using Newtonsoft.Json;\n\nstatic class Pretty\n{\n public static void Print<T> (T x)\n {\n string json = JsonConvert.SerializeObject(x, Formatting.Indented);\n Console.WriteLine(json);\n }\n}\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] |
93,705
|
<p>I have an application in which users interact with each-other. I want to visualize these interactions so that I can determine whether clusters of users exist (within which interactions are more frequent).</p>
<p>I've assigned a 2D point to each user (where each coordinate is between 0 and 1). My idea is that two users' points move closer together when they interact, an "attractive force", and I just repeatedly go through my interaction logs over and over again.</p>
<p>Of course, I need a "repulsive force" that will push users apart too, otherwise they will all just collapse into a single point.</p>
<p>First I tried monitoring the lowest and highest of each of the XY coordinates, and normalizing their positions, but this didn't work, a few users with a small number of interactions stayed at the edges, and the rest all collapsed into the middle.</p>
<p>Does anyone know what equations I should use to move the points, both for the "attractive" force between users when they interact, and a "repulsive" force to stop them all collapsing into a single point?</p>
<p>Edit: In response to a question, I should point out that I'm dealing with about 1 million users, and about 10 million interactions between users. If anyone can recommend a tool that could do this for me, I'm all ears :-)</p>
|
[
{
"answer_id": 93822,
"author": "Thomas Kammeyer",
"author_id": 4410,
"author_profile": "https://Stackoverflow.com/users/4410",
"pm_score": 1,
"selected": false,
"text": " neato draws undirected graphs using ``spring'' models (see Kamada and\n Kawai, Information Processing Letters 31:1, April 1989). Input files\n must be formatted in the dot attributed graph language. By default,\n the output of neato is the input graph with layout coordinates\n appended.\n\n fdp draws undirected graphs using a ``spring'' model. It relies on a\n force-directed approach in the spirit of Fruchterman and Reingold (cf.\n Software-Practice & Experience 21(11), 1991, pp. 1129-1164).\n"
},
{
"answer_id": 173255,
"author": "Tom",
"author_id": 3715,
"author_profile": "https://Stackoverflow.com/users/3715",
"pm_score": 3,
"selected": true,
"text": "dx = -k*(x-l)"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16050/"
] |
93,708
|
<p>I have an asp.net application that runs exclusively on IE7 (internal web site).</p>
<p>When a user needs to enter data, I pop up a child window with a form. When the form closes, it calls javascript:window.opener.location.reload(true) so that the new data will display on the main page.</p>
<p>The problem is that the browser complains that it must repost the page. Is there any way to turn this feature off?</p>
|
[
{
"answer_id": 93806,
"author": "Jonathan Lonowski",
"author_id": 15031,
"author_profile": "https://Stackoverflow.com/users/15031",
"pm_score": 0,
"selected": false,
"text": "window.opener.location = '#';\n"
},
{
"answer_id": 4342773,
"author": "Anish Joseph",
"author_id": 516962,
"author_profile": "https://Stackoverflow.com/users/516962",
"pm_score": 0,
"selected": false,
"text": "<script>\nif(window.history.forward(1) != null)\n window.history.forward(1);\n</script>\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17870/"
] |
93,710
|
<p>Basically, something similar to System.Xml.XmlWriter - A streaming XML Writer that doesn't incur much of a memory overhead. So that rules out xml.dom and xml.dom.minidom. Suggestions?</p>
|
[
{
"answer_id": 93871,
"author": "AdamKG",
"author_id": 16361,
"author_profile": "https://Stackoverflow.com/users/16361",
"pm_score": -1,
"selected": false,
"text": "lxml.etree"
},
{
"answer_id": 93984,
"author": "Toni Ruža",
"author_id": 6267,
"author_profile": "https://Stackoverflow.com/users/6267",
"pm_score": 0,
"selected": false,
"text": "MarkupWriter"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17865/"
] |
93,716
|
<p>How can I hide the title bar from a Windows Form but still have a Resizing Frame?</p>
|
[
{
"answer_id": 93721,
"author": "Brian Gillespie",
"author_id": 6151,
"author_profile": "https://Stackoverflow.com/users/6151",
"pm_score": 5,
"selected": true,
"text": "ControlBox = false\nText = \"\"\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6151/"
] |
93,720
|
<p><strong>How do I represent an aggregation relation between two classes in UML, such that each class has a link to the other class's interface, not the implementing class?</strong></p>
<p>E.g. I have a class Foo that implements iFoo, and Bar that implements iBar. Foo should have a member variable of type iBar, and Bar should have a member variable of type iFoo.</p>
<p>If I create an aggregation between the two implementing classes, then the member will be of the type of the implementing class, not the superclass. And aggregations between interfaces are invalid in UML (and don't make much sense).</p>
|
[
{
"answer_id": 93721,
"author": "Brian Gillespie",
"author_id": 6151,
"author_profile": "https://Stackoverflow.com/users/6151",
"pm_score": 5,
"selected": true,
"text": "ControlBox = false\nText = \"\"\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16399/"
] |
93,728
|
<p>I want to do the following imports in a class.</p>
<pre><code>import org.eclipse.jdt.core.dom.*;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.Compiler;
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.text.edits.TextEdit;
</code></pre>
<p>How can I import the JDT within Eclipse?
Cheers.</p>
|
[
{
"answer_id": 454386,
"author": "jamesh",
"author_id": 4737,
"author_profile": "https://Stackoverflow.com/users/4737",
"pm_score": 2,
"selected": false,
"text": "internal"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5915/"
] |
93,744
|
<p>For the life of me, I can't remember how to set, delete, toggle or test a bit in a bitfield. Either I'm unsure or I mix them up because I rarely need these. So a "bit-cheat-sheet" would be nice to have.</p>
<p>For example: </p>
<pre><code>flags = flags | FlagsEnum.Bit4; // Set bit 4.
</code></pre>
<p>or</p>
<pre><code>if ((flags & FlagsEnum.Bit4)) == FlagsEnum.Bit4) // Is there a less verbose way?
</code></pre>
<p>Can you give examples of all the other common operations, preferably in C# syntax using a [Flags] enum?</p>
|
[
{
"answer_id": 93785,
"author": "Stephen Deken",
"author_id": 7154,
"author_profile": "https://Stackoverflow.com/users/7154",
"pm_score": 7,
"selected": false,
"text": "flags |= 0x04;\n"
},
{
"answer_id": 93872,
"author": "Anya Shenanigans",
"author_id": 17833,
"author_profile": "https://Stackoverflow.com/users/17833",
"pm_score": 3,
"selected": false,
"text": "flags & (1UL << (bit to test# - 1))\n"
},
{
"answer_id": 93893,
"author": "Nashirak",
"author_id": 15484,
"author_profile": "https://Stackoverflow.com/users/15484",
"pm_score": 2,
"selected": false,
"text": "if((flags & 0x08) == 0x08)"
},
{
"answer_id": 417217,
"author": "hugoware",
"author_id": 17091,
"author_profile": "https://Stackoverflow.com/users/17091",
"pm_score": 8,
"selected": false,
"text": "namespace Enum.Extensions {\n\n public static class EnumerationExtensions {\n\n public static bool Has<T>(this System.Enum type, T value) {\n try {\n return (((int)(object)type & (int)(object)value) == (int)(object)value);\n } \n catch {\n return false;\n }\n }\n\n public static bool Is<T>(this System.Enum type, T value) {\n try {\n return (int)(object)type == (int)(object)value;\n }\n catch {\n return false;\n } \n }\n\n\n public static T Add<T>(this System.Enum type, T value) {\n try {\n return (T)(object)(((int)(object)type | (int)(object)value));\n }\n catch(Exception ex) {\n throw new ArgumentException(\n string.Format(\n \"Could not append value from enumerated type '{0}'.\",\n typeof(T).Name\n ), ex);\n } \n }\n\n\n public static T Remove<T>(this System.Enum type, T value) {\n try {\n return (T)(object)(((int)(object)type & ~(int)(object)value));\n }\n catch (Exception ex) {\n throw new ArgumentException(\n string.Format(\n \"Could not remove value from enumerated type '{0}'.\",\n typeof(T).Name\n ), ex);\n } \n }\n\n }\n}\n"
},
{
"answer_id": 6179308,
"author": "Drew Noakes",
"author_id": 24874,
"author_profile": "https://Stackoverflow.com/users/24874",
"pm_score": 7,
"selected": false,
"text": "flags.HasFlag(FlagsEnum.Bit4)\n"
},
{
"answer_id": 7181407,
"author": "Chuck Dee",
"author_id": 275594,
"author_profile": "https://Stackoverflow.com/users/275594",
"pm_score": 5,
"selected": false,
"text": "[Flags]\npublic enum TestFlags\n{\n One = 1,\n Two = 2,\n Three = 4,\n Four = 8,\n Five = 16,\n Six = 32,\n Seven = 64,\n Eight = 128,\n Nine = 256,\n Ten = 512\n}\n\n\nclass Program\n{\n static void Main(string[] args)\n {\n TestFlags f = TestFlags.Five; /* or any other enum */\n bool result = false;\n\n Stopwatch s = Stopwatch.StartNew();\n for (int i = 0; i < 10000000; i++)\n {\n result |= f.HasFlag(TestFlags.Three);\n }\n s.Stop();\n Console.WriteLine(s.ElapsedMilliseconds); // *4793 ms*\n\n s.Restart();\n for (int i = 0; i < 10000000; i++)\n {\n result |= (f & TestFlags.Three) != 0;\n }\n s.Stop();\n Console.WriteLine(s.ElapsedMilliseconds); // *27 ms* \n\n Console.ReadLine();\n }\n}\n"
},
{
"answer_id": 9641681,
"author": "Tony Tanzillo",
"author_id": 1173769,
"author_profile": "https://Stackoverflow.com/users/1173769",
"pm_score": 2,
"selected": false,
"text": "/// Example of using a Boolean indexed property\n/// to manipulate a [Flags] enum:\n\npublic class BindingFlagsIndexer\n{\n BindingFlags flags = BindingFlags.Default;\n\n public BindingFlagsIndexer()\n {\n }\n\n public BindingFlagsIndexer( BindingFlags value )\n {\n this.flags = value;\n }\n\n public bool this[BindingFlags index]\n {\n get\n {\n return (this.flags & index) == index;\n }\n set( bool value )\n {\n if( value )\n this.flags |= index;\n else\n this.flags &= ~index;\n }\n }\n\n public BindingFlags Value \n {\n get\n { \n return flags;\n } \n set( BindingFlags value ) \n {\n this.flags = value;\n }\n }\n\n public static implicit operator BindingFlags( BindingFlagsIndexer src )\n {\n return src != null ? src.Value : BindingFlags.Default;\n }\n\n public static implicit operator BindingFlagsIndexer( BindingFlags src )\n {\n return new BindingFlagsIndexer( src );\n }\n\n}\n\npublic static class Class1\n{\n public static void Example()\n {\n BindingFlagsIndexer myFlags = new BindingFlagsIndexer();\n\n // Sets the flag(s) passed as the indexer:\n\n myFlags[BindingFlags.ExactBinding] = true;\n\n // Indexer can specify multiple flags at once:\n\n myFlags[BindingFlags.Instance | BindingFlags.Static] = true;\n\n // Get boolean indicating if specified flag(s) are set:\n\n bool flatten = myFlags[BindingFlags.FlattenHierarchy];\n\n // use | to test if multiple flags are set:\n\n bool isProtected = ! myFlags[BindingFlags.Public | BindingFlags.NonPublic];\n\n }\n}\n"
},
{
"answer_id": 44551135,
"author": "TylerBrinkley",
"author_id": 8137269,
"author_profile": "https://Stackoverflow.com/users/8137269",
"pm_score": 4,
"selected": false,
"text": "HasFlag"
},
{
"answer_id": 54973342,
"author": "Mark Bamford",
"author_id": 9004349,
"author_profile": "https://Stackoverflow.com/users/9004349",
"pm_score": 3,
"selected": false,
"text": "using System;\nusing T = MyNamespace.MyFlags;\n\nnamespace MyNamespace\n{\n [Flags]\n public enum MyFlags\n {\n None = 0,\n Flag1 = 1,\n Flag2 = 2\n }\n\n static class MyFlagsEx\n {\n public static bool Has(this T type, T value)\n {\n return (type & value) == value;\n }\n\n public static bool Is(this T type, T value)\n {\n return type == value;\n }\n\n public static T Add(this T type, T value)\n {\n return type | value;\n }\n\n public static T Remove(this T type, T value)\n {\n return type & ~value;\n }\n }\n}\n"
},
{
"answer_id": 68399061,
"author": "Connor Low",
"author_id": 6789816,
"author_profile": "https://Stackoverflow.com/users/6789816",
"pm_score": 2,
"selected": false,
"text": "Flags"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15328/"
] |
93,767
|
<p>I am using the mootools based Rokbox plugin, on one of my sites, and I can't figure out how to close it with javascript.</p>
<p>I triggered the click event on the close button, but that did not work.</p>
<p>I found the code in the rokbox source that is used to add the click listener</p>
<pre><code>this.closeButton.addEvent('click',function(e){new Event(e).stop();self.swtch=false;self.close(e)});
</code></pre>
<p>but since it is minified i cannot find what "this" refers to</p>
|
[
{
"answer_id": 94526,
"author": "Aeon",
"author_id": 13289,
"author_profile": "https://Stackoverflow.com/users/13289",
"pm_score": 1,
"selected": false,
"text": "this"
},
{
"answer_id": 4003178,
"author": "yitwail",
"author_id": 471803,
"author_profile": "https://Stackoverflow.com/users/471803",
"pm_score": 0,
"selected": false,
"text": "window.parent.rokbox.close(null)\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
93,770
|
<p>For deployment reasons, I am trying to use IJW to wrap a C# assembly in C++ instead of using a COM Callable Wrapper. </p>
<p>I've done it on other projects, but on this one, I am getting an EEFileLoadException. Any help would be appreciated!</p>
<p>Managed C++ wrapper code (this is in a DLL):</p>
<pre><code>extern "C" __declspec(dllexport) IMyObject* CreateMyObject(void)
{
//this class references c# in the constructor
return new CMyWrapper( );
}
extern "C" __declspec(dllexport) void DeleteMyObject(IMyObject* pConfigFile)
{
delete pConfigFile;
}
extern "C" __declspec(dllexport) void TestFunction(void)
{
::MessageBox(NULL, _T("My Message Box"), _T("Test"), MB_OK);
}
</code></pre>
<p>Test Code (this is an EXE):</p>
<pre><code>typedef void* (*CreateObjectPtr)();
typedef void (*TestFunctionPtr)();
int _tmain testwrapper(int argc, TCHAR* argv[], TCHAR* envp[])
{
HMODULE hModule = ::LoadLibrary(_T("MyWrapper"));
_ASSERT(hModule != NULL);
PVOID pFunc1 = ::GetProcAddress(hModule, "TestFunction");
_ASSERT(pFunc1 != NULL);
TestFunctionPtr pTest = (TestFunctionPtr)pFunc1;
PVOID pFunc2 = ::GetProcAddress(hModule, "CreateMyObject");
_ASSERT(pFunc2 != NULL);
CreateObjectPtr pCreateObjectFunc = (CreateObjectPtr)pFunc2;
(*pTest)(); //this successfully pops up a message box
(*pCreateObjectFunc)(); //this tosses an EEFileLoadException
return 0;
}
</code></pre>
<p>For what it's worth, the Event Log reports the following:
.NET Runtime version 2.0.50727.143 -
Fatal Execution Engine Error (79F97075) (80131506)</p>
<p>Unfortunately, Microsoft has no information on that error.</p>
|
[
{
"answer_id": 96651,
"author": "Adam Tegen",
"author_id": 4066,
"author_profile": "https://Stackoverflow.com/users/4066",
"pm_score": 6,
"selected": true,
"text": "/// <summary>\n/// Summary for AssemblyResolver\n/// </summary>\npublic ref class AssemblyResolver\n{\npublic:\n\nstatic Assembly^ MyResolveEventHandler( Object^ sender, ResolveEventArgs^ args )\n{\n Console::WriteLine( \"Resolving...\" );\n\n Assembly^ thisAssembly = Assembly::GetExecutingAssembly();\n String^ thisPath = thisAssembly->Location;\n String^ directory = Path::GetDirectoryName(thisPath);\n String^ pathToManagedAssembly = Path::Combine(directory, \"managed.dll\");\n\n Assembly^ newAssembly = Assembly::LoadFile(pathToManagedAssembly);\n return newAssembly;\n}\n\n};\n"
},
{
"answer_id": 17762325,
"author": "Fredrik Ullner",
"author_id": 149813,
"author_profile": "https://Stackoverflow.com/users/149813",
"pm_score": 1,
"selected": false,
"text": "static Assembly^ MyResolveEventHandler( Object^ sender, ResolveEventArgs^ args )\n{\n Console::WriteLine( \"Resolving...\" );\n\n String^ assemblyName = args->Name;\n\n // Strip irrelevant information, such as assembly, version etc.\n // Example: \"Acme.Foobar, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\"\n if( assemblyName->Contains(\",\") ) \n {\n assemblyName = assemblyName->Substring(0, assemblyName->IndexOf(\",\"));\n }\n\n Assembly^ thisAssembly = Assembly::GetExecutingAssembly();\n String^ thisPath = thisAssembly->Location;\n String^ directory = Path::GetDirectoryName(thisPath);\n String^ pathToManagedAssembly = Path::Combine(directory, assemblyName );\n\n Assembly^ newAssembly = Assembly::LoadFile(pathToManagedAssembly);\n return newAssembly;\n}\n"
},
{
"answer_id": 40223503,
"author": "Gareth",
"author_id": 1271626,
"author_profile": "https://Stackoverflow.com/users/1271626",
"pm_score": 1,
"selected": false,
"text": "<runtime>\n<assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\n<dependentAssembly>\n <assemblyIdentity name=\"Microsoft.Owin.Security.OAuth\" publicKeyToken=\"31bf3856ad364e35\" />\n <bindingRedirect oldVersion=\"0.0.0.0-3.0.1.0\" newVersion=\"3.0.1.0\" />\n </dependentAssembly> </assemblyBinding> </runtime>\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4066/"
] |
93,832
|
<p>What is the preferred way to open a URL from a thick client application on Windows using C# and the .NET framework? I want it to use the default browser.</p>
|
[
{
"answer_id": 93866,
"author": "Martin",
"author_id": 770,
"author_profile": "https://Stackoverflow.com/users/770",
"pm_score": 1,
"selected": false,
"text": "private void launchURL_Click(object sender, System.EventArgs e){\n string targetURL = \"http://stackoverflow.com\";\n System.Diagnostics.Process.Start(targetURL);\n}\n"
},
{
"answer_id": 93870,
"author": "Bullines",
"author_id": 27870,
"author_profile": "https://Stackoverflow.com/users/27870",
"pm_score": 0,
"selected": false,
"text": "System.Diagnostics.Process.Start(\"http://www.stackoverflow.com\");\n"
},
{
"answer_id": 93877,
"author": "Dario Solera",
"author_id": 16026,
"author_profile": "https://Stackoverflow.com/users/16026",
"pm_score": 4,
"selected": true,
"text": "Process.Start(\"http://www.yoururl.com/Blah.aspx\");\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17891/"
] |
93,834
|
<p>I was recently working on an application that sent and received messages over Ethernet and Serial. I was then tasked to <strong>add</strong> the monitoring of DIO discretes. I throught, </p>
<blockquote>
<p>"No reason to interrupt the main
thread which is involved in message
processing, I'll just create
<strong><em>another thread</em></strong> that monitors DIO."</p>
</blockquote>
<p>This decision, however, proved to be <strong>poor</strong>. Sometimes the main thread would be interrupted between a Send and a Receive serial message. This interruption would disrupt the timing and alas, messages would be lost (forever). </p>
<p>I found another way to monitor the DIO <em>without using another thread</em> and Ethernet and Serial communication were restored to their correct functionality.</p>
<p>The whole fiasco, however, got me thinking. <strong>Are their any general guidelines about when <em>not</em> to use multiple-threads and/or does anyone have anymore examples of situations when using multiple-threads is not a good idea?</strong></p>
<p>**EDIT:Based on your comments and after scowering the internet for information, I have composed a blog post entitled <a href="http://www.codingwithoutcomments.com/2008/09/21/when-is-multi-threading-not-a-good-idea/" rel="noreferrer">When is multi-threading not a good idea?</a></p>
|
[
{
"answer_id": 94271,
"author": "harningt",
"author_id": 12713,
"author_profile": "https://Stackoverflow.com/users/12713",
"pm_score": 2,
"selected": false,
"text": "Per CPU [*] EVENTLOOP ------ Handles nonblocking I/O using OS/library utilities\n | \\___ Threadpool for various blocking events\n Threadpool for handling the I/O messages that would take long\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25/"
] |
93,839
|
<p>If you have binary strings (literally String objects that contain only 1's and 0's), how would you output them as bits into a file?</p>
<p>This is for a text compressor I was working on; it's still bugging me, and it'd be nice to finally get it working. Thanks!</p>
|
[
{
"answer_id": 93889,
"author": "Tomer Gabel",
"author_id": 11558,
"author_profile": "https://Stackoverflow.com/users/11558",
"pm_score": 4,
"selected": true,
"text": "\nbyte[] buffer = new byte[ ( string.length + 7 ) / 8 ];\nfor ( int i = 0; i < buffer.length; ++i ) {\n byte current = 0;\n for ( int j = 7; j >= 0; --j )\n if ( string[ i * 8 + j ] == '1' )\n current |= 1 << j;\n output( current );\n}\n"
},
{
"answer_id": 93925,
"author": "Dave L.",
"author_id": 3093,
"author_profile": "https://Stackoverflow.com/users/3093",
"pm_score": 1,
"selected": false,
"text": "String s = \"11001010001010101110101001001110\";\nbyte[] data = new byte[s.length() / 8];\nfor (int i = 0; i < data.length; i++) {\n data[i] = (byte) Integer.parseInt(s.substring(i * 8, (i + 1) * 8), 2);\n}\n"
},
{
"answer_id": 93964,
"author": "izb",
"author_id": 974,
"author_profile": "https://Stackoverflow.com/users/974",
"pm_score": 2,
"selected": false,
"text": "public class BitOutputStream extends FilterOutputStream\n{\n private int buffer = 0;\n private int bitCount = 0;\n\n public BitOutputStream(OutputStream out)\n {\n super(out);\n }\n\n public void writeBits(int value, int numBits) throws IOException\n {\n while(numBits>0)\n {\n numBits--;\n int mix = ((value&1)<<bitCount++);\n buffer|=mix;\n value>>=1;\n if(bitCount==8)\n align8();\n }\n }\n\n @Override\n public void close() throws IOException\n {\n align8(); /* Flush any remaining partial bytes */\n super.close();\n }\n\n public void align8() throws IOException\n {\n if(bitCount > 0)\n {\n bitCount=0;\n write(buffer);\n buffer=0;\n }\n }\n}\n"
},
{
"answer_id": 94405,
"author": "finnw",
"author_id": 12048,
"author_profile": "https://Stackoverflow.com/users/12048",
"pm_score": 3,
"selected": false,
"text": "String s = \"11001010001010101110101001001110\";\nbyte[] bytes = (new java.math.BigInteger(s, 2)).toByteArray();\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6833/"
] |
93,853
|
<p>I have seen this problem arise in many different circumstances and would like to get the best practices for fixing / debugging it on StackOverflow.</p>
<p>To use a real world example this occurred to me this morning:</p>
<pre><code>expected announcement.rb to define Announcement
</code></pre>
<p>The class worked fine in development, testing <em>and</em> from a production console, but failed from in a production Mongrel. Here's the class:</p>
<pre><code>class Announcement < ActiveRecord::Base
has_attachment :content_type => 'audio/mp3', :storage => :s3
end
</code></pre>
<p>The issue I would like addressed in the answers is not so much solving this specific problem, but how to properly debug to get Rails to give you a meaningful error as expected x.rb to define X.rb' is often a red herring...</p>
<p><strong>Edit (3 great responses so far, each w/ a partial solution</strong>)</p>
<p><strong>Debugging:</strong></p>
<ol>
<li><p>From Joe Van Dyk: Try accessing the model via a console on the environment / instance that is causing the error (in the case above: script/console production then type in 'Announcement'.</p></li>
<li><p>From Otto: Try setting a minimal plugin set via an initializer, eg: config.plugins = [ :exception_notification, :ssl_requirement, :all ] then re-enable one at a time.</p></li>
</ol>
<p><strong>Specific causes:</strong></p>
<ol>
<li><p>From Ian Terrell: if you're using attachment_fu make sure you have the correct image processor installed. attachment_fu will require it even if you aren't attaching an image.</p></li>
<li><p>From Otto: make sure you didn't name a model that conflicts with a built-in Rails class, eg: Request.</p></li>
<li><p>From Josh Lewis: make sure you don't have duplicated class or module names somewhere in your application (or Gem list).</p></li>
</ol>
|
[
{
"answer_id": 94243,
"author": "Joe Van Dyk",
"author_id": 17076,
"author_profile": "https://Stackoverflow.com/users/17076",
"pm_score": 5,
"selected": true,
"text": "Announcement"
},
{
"answer_id": 94797,
"author": "Ian Terrell",
"author_id": 9269,
"author_profile": "https://Stackoverflow.com/users/9269",
"pm_score": 2,
"selected": false,
"text": "AttachmentFu"
},
{
"answer_id": 96959,
"author": "Otto",
"author_id": 9594,
"author_profile": "https://Stackoverflow.com/users/9594",
"pm_score": 1,
"selected": false,
"text": "environment.rb"
},
{
"answer_id": 1198996,
"author": "Masolino",
"author_id": 464018,
"author_profile": "https://Stackoverflow.com/users/464018",
"pm_score": 1,
"selected": false,
"text": "attachment_fu to"
},
{
"answer_id": 17576347,
"author": "Kevin B.",
"author_id": 2569478,
"author_profile": "https://Stackoverflow.com/users/2569478",
"pm_score": 2,
"selected": false,
"text": "module Foo\n class Bar\n end\nend\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4748/"
] |
93,879
|
<p>The located assembly's manifest definition does not match the assembly reference</p>
<p>getting this when running nunit through ncover. Any idea?</p>
|
[
{
"answer_id": 8375396,
"author": "Björn van den Heuvel",
"author_id": 1080049,
"author_profile": "https://Stackoverflow.com/users/1080049",
"pm_score": 2,
"selected": false,
"text": "CreateObject"
},
{
"answer_id": 14359707,
"author": "Rick Troupin",
"author_id": 1983830,
"author_profile": "https://Stackoverflow.com/users/1983830",
"pm_score": 0,
"selected": false,
"text": "Microsoft.VisualStudio.TemplateWizardInterface"
},
{
"answer_id": 19240240,
"author": "fguigui",
"author_id": 2857274,
"author_profile": "https://Stackoverflow.com/users/2857274",
"pm_score": 3,
"selected": false,
"text": " <runtime>\n <assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\n <dependentAssembly>\n <assemblyIdentity name=\"DotNetOpenAuth.Core\" publicKeyToken=\"2780ccd10d57b246\" />\n <bindingRedirect oldVersion=\"0.0.0.0-4.1.0.0\" newVersion=\"4.1.0.0\" />\n </dependentAssembly>\n.\n.\n.\n <runtime>\n"
},
{
"answer_id": 27378252,
"author": "sandiejat",
"author_id": 3785895,
"author_profile": "https://Stackoverflow.com/users/3785895",
"pm_score": 2,
"selected": false,
"text": "<dependentAssembly>\n <assemblyIdentity name=\"WebGrease\" culture=\"neutral\" publicKeyToken=\"31bf3856ad364e35\" />\n <bindingRedirect oldVersion=\"0.0.0.0-1.6.5135.21930\" newVersion=\"1.6.5135.21930\" />\n</dependentAssembly>\n"
},
{
"answer_id": 28212737,
"author": "Stéphane Gourichon",
"author_id": 1429390,
"author_profile": "https://Stackoverflow.com/users/1429390",
"pm_score": 0,
"selected": false,
"text": "for a in $( egrep '(x86|AnyCPU)' */*.csproj *.sln -l ) ; do echo $a ; sed -i 's/x86/AnyCPU/' $a ; done\n"
},
{
"answer_id": 32293620,
"author": "kyorilys",
"author_id": 1256388,
"author_profile": "https://Stackoverflow.com/users/1256388",
"pm_score": 3,
"selected": false,
"text": "<runtime>\n <assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\n <dependentAssembly>\n <assemblyIdentity name=\"System.Web.Helpers\" publicKeyToken=\"31bf3856ad364e35\"/>\n <bindingRedirect oldVersion=\"1.0.0.0-3.0.0.0\" newVersion=\"3.0.0.0\"/>\n </dependentAssembly>\n <dependentAssembly>\n <assemblyIdentity name=\"System.Web.WebPages\" publicKeyToken=\"31bf3856ad364e35\"/>\n <bindingRedirect oldVersion=\"1.0.0.0-3.0.0.0\" newVersion=\"3.0.0.0\"/>\n </dependentAssembly>\n </assemblyBinding>\n </runtime>\n"
},
{
"answer_id": 48583564,
"author": "Maytham Fahmi",
"author_id": 3088349,
"author_profile": "https://Stackoverflow.com/users/3088349",
"pm_score": 3,
"selected": false,
"text": "\"Error while calling service <ServiceName> Could not load file or assembly 'RestSharp, \nVersion=105.2.3.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. \nThe located assembly's manifest definition does not match the assembly reference.\n(Exception from HRESULT: 0x80131040)\"\n"
},
{
"answer_id": 50151827,
"author": "Hardeep Singh",
"author_id": 4423624,
"author_profile": "https://Stackoverflow.com/users/4423624",
"pm_score": 0,
"selected": false,
"text": "<dependentAssembly>\n <assemblyIdentity name=\"itextsharp\" publicKeyToken=\"8354ae6d2174ddca\" culture=\"neutral\" />\n <bindingRedirect oldVersion=\"0.0.0.0-5.5.13.0\" newVersion=\"5.5.13.0\" />\n </dependentAssembly>\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
93,888
|
<p>By default the session expiry seems to be 20 minutes. </p>
<p>Update: I do not want the session to expire until the browser is closed.</p>
<p>Update2: This is my scenario. User logs into site. Plays around the site. Leaves computer to go for a shower (>20 mins ;)). Comes back to computer and <em>should</em> be able to play around. He closes browser, which deletes session cookie. The next time he comes to the site from a new browser instance, he would need to login again.</p>
<p>In PHP I can set session.cookie_lifetime in php.ini to zero to achieve this. </p>
|
[
{
"answer_id": 93968,
"author": "Toby Mills",
"author_id": 12377,
"author_profile": "https://Stackoverflow.com/users/12377",
"pm_score": 1,
"selected": false,
"text": "Session.Abandon();"
},
{
"answer_id": 94362,
"author": "Simon Forrest",
"author_id": 4733,
"author_profile": "https://Stackoverflow.com/users/4733",
"pm_score": 4,
"selected": true,
"text": "<configuration>\n <system.web>\n <sessionState timeout=\"60\" />\n ... other elements omitted ...\n </system.web>\n ... other elements omitted ....\n</configuration>\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17404/"
] |
93,900
|
<p>I have this workspace downloaded off the web and I try running it on a tomcat server from a fresh installation of Eclipse Ganymede. This particular project came with its own workspace. </p>
<p>When I select Tomcat v6.0 I get a message </p>
<blockquote>
<p>Cannot create a server using the selected type</p>
</blockquote>
<p>Older tomcat versions are available, though. </p>
<p>I guess I have to recreate some configuration setting. The question is which one? This seems to be some odd error as creating a new dynamic web project lets me configure tomcat for both of them</p>
|
[
{
"answer_id": 376748,
"author": "Jim Kiley",
"author_id": 7178,
"author_profile": "https://Stackoverflow.com/users/7178",
"pm_score": 2,
"selected": false,
"text": "<Context>"
},
{
"answer_id": 409958,
"author": "Mantas K.",
"author_id": 51240,
"author_profile": "https://Stackoverflow.com/users/51240",
"pm_score": 0,
"selected": false,
"text": "org.eclipse.core.runtime.CoreException: \nCould not load the Tomcat server configuration at \nC:\\Program Files\\Apache Software Foundation\\apache-tomcat-6.0.14\\conf. \nThe configuration may be corrupt or incomplete.\n"
},
{
"answer_id": 512619,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "sudo ln -s /etc/tomcat6 /usr/share/tomcat6/conf\nsudo ln -s /etc/tomcat6/policy.d/03catalina.policy /usr/share/tomcat6/conf/catalina.policy\nsudo chmod a+r /usr/share/tomcat6/conf/tomcat-users.xml\n"
},
{
"answer_id": 4946179,
"author": "Raymond Chenon",
"author_id": 311420,
"author_profile": "https://Stackoverflow.com/users/311420",
"pm_score": 0,
"selected": false,
"text": "mvn eclipse:eclipse -Dwtpversion=1.5\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10523/"
] |
93,911
|
<p>Part of our java application needs to run javascript that is written by non-developers. These non-developers are using javascript for data formatting. (Simple logic and string concatenation mostly).</p>
<p>My question is how can I setup the execution of these scripts to make sure scripting errors don't have a major negative impact on the rest of the application.</p>
<ul>
<li>Need to guard against infinite loops</li>
<li>Guard against spawning new threads. </li>
<li>Limit access to services and environment
<ul>
<li>File system (Example: If a disgruntled script writer decided to delete files)</li>
<li>Database (Same thing delete database records)</li>
</ul></li>
</ul>
<p>Basically I need to setup the javascript scope to only include exactly what they need and no more.</p>
|
[
{
"answer_id": 754792,
"author": "Thilo",
"author_id": 14955,
"author_profile": "https://Stackoverflow.com/users/14955",
"pm_score": 4,
"selected": false,
"text": " protected void observeInstructionCount(Context cx, int instructionCount)\n {\n MyContext mcx = (MyContext)cx;\n long currentTime = System.currentTimeMillis();\n if (currentTime - mcx.startTime > 10*1000) {\n // More then 10 seconds from Context creation time:\n // it is time to stop the script.\n // Throw Error instance to ensure that script will never\n // get control back through catch or finally.\n throw new Error();\n }\n }\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5569/"
] |
93,932
|
<p>We are getting an error in a VB6 application that sends data back and forth over TCP sockets. We get a runtime error "out of string space". Has anyone seen this or have any thoughts on why this would happen? It seems like we are hitting some VB6 threshhold so any other thoughts would be helpful as well.</p>
|
[
{
"answer_id": 94043,
"author": "Robit",
"author_id": 17026,
"author_profile": "https://Stackoverflow.com/users/17026",
"pm_score": 2,
"selected": false,
"text": "MyString = \"Hello\"\nFor Count = 1 To 100\nMyString = MyString & MyString\nNext Count\n"
},
{
"answer_id": 94179,
"author": "Jack Bolding",
"author_id": 5882,
"author_profile": "https://Stackoverflow.com/users/5882",
"pm_score": 5,
"selected": true,
"text": "Option Explicit\n\nPrivate data As String\nPrivate allocLen As Long\nPrivate currentPos As Long\n\nPublic Function Text() As String\n Text = Left(data, currentPos)\nEnd Function\n\nPublic Function Length() As Long\n Length = currentPos\nEnd Function\n\nPublic Sub Add(s As String)\n\n Dim newLen As Long\n newLen = Len(s)\n If ((currentPos + newLen) > allocLen) Then\n data = data & Space((currentPos + newLen))\n allocLen = Len(data)\n End If\n\n Mid(data, currentPos + 1, newLen) = s\n currentPos = currentPos + newLen\n\nEnd Sub\n\nPrivate Sub Class_Initialize()\n data = Space(10240)\n allocLen = Len(data)\n currentPos = 1\nEnd Sub\n"
},
{
"answer_id": 94201,
"author": "rpetrich",
"author_id": 4007,
"author_profile": "https://Stackoverflow.com/users/4007",
"pm_score": 0,
"selected": false,
"text": "Class_Initialize/Class_Finalize"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] |
93,944
|
<p>You might have a set of properties that is used on the developer machine, which varies from developer to developer, another set for a staging environment, and yet another for the production environment. </p>
<p>In a Spring application you may also have beans that you want to load in a local environment but not in a production environment, and vice versa. </p>
<p>How do you handle this? Do you use separate files, ant/maven resource filtering or other approaches? </p>
|
[
{
"answer_id": 94631,
"author": "enricopulatzo",
"author_id": 9883,
"author_profile": "https://Stackoverflow.com/users/9883",
"pm_score": 2,
"selected": false,
"text": "-Pproduction"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17542/"
] |
93,976
|
<p>How do you check if a one-character String is a letter - including any letters with accents?</p>
<p>I had to work this out recently, so I'll answer it myself, after the recent VB6 question reminded me.</p>
|
[
{
"answer_id": 93979,
"author": "Peter Hilton",
"author_id": 2670,
"author_profile": "https://Stackoverflow.com/users/2670",
"pm_score": 6,
"selected": true,
"text": "string.matches(\"\\\\p{L}\"); // Unicode letter\nstring.matches(\"\\\\p{Lu}\"); // Unicode upper-case letter\n"
},
{
"answer_id": 94004,
"author": "Michael Myers",
"author_id": 13531,
"author_profile": "https://Stackoverflow.com/users/13531",
"pm_score": 5,
"selected": false,
"text": "matches()"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2670/"
] |
93,981
|
<p>Suppose I have a design like this:</p>
<p>Object GUI has two objects: object aManager and object bManager, which don't ever talk to each other.</p>
<p>Both aManager and bManager have object cManager as an attribute (or rather a pointer to cManager). So when aManager modifies its cManager, it's affecting bManager's cManager as well.</p>
<p>My question is what is the correct way to design/implement this?</p>
<p>I was thinking of making cManager as an attribute of GUI, and GUI passes a pointer to cManager when constructing aManager and bManager. But IMHO, GUI has nothing to do with cManager, so why should GUI have it as an attribute?</p>
<p>Is there a specific design pattern I should be using here?</p>
|
[
{
"answer_id": 94202,
"author": "Tim Frey",
"author_id": 1471,
"author_profile": "https://Stackoverflow.com/users/1471",
"pm_score": 1,
"selected": false,
"text": "public GUI(CManager cManager)\n{\n this.aManager = new AManager(cManager);\n this.bManager = new BManager(cManager);\n // don't bother keeping cManager as a field\n}\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17861/"
] |
93,983
|
<p>How can I take the string <code>foo[]=1&foo[]=5&foo[]=2</code> and return a collection with the values <code>1,5,2</code> in that order. I am looking for an answer using regex in C#. Thanks</p>
|
[
{
"answer_id": 94009,
"author": "jjnguy",
"author_id": 2598,
"author_profile": "https://Stackoverflow.com/users/2598",
"pm_score": 1,
"selected": false,
"text": "String[] nums = String.split(yourString, \"&?foo[]\");\n"
},
{
"answer_id": 94038,
"author": "Anya Shenanigans",
"author_id": 17833,
"author_profile": "https://Stackoverflow.com/users/17833",
"pm_score": 0,
"selected": false,
"text": "/=(\\d+)&?/\n"
},
{
"answer_id": 94063,
"author": "Burkhard",
"author_id": 12860,
"author_profile": "https://Stackoverflow.com/users/12860",
"pm_score": 0,
"selected": false,
"text": "using System.Text.RegularExpressions;\n\nRegex.Replace(s, !@\"^[0-9]*$”, \"\");\n"
},
{
"answer_id": 94064,
"author": "Hans Sjunnesson",
"author_id": 8683,
"author_profile": "https://Stackoverflow.com/users/8683",
"pm_score": 0,
"selected": false,
"text": "/=(\\d+)\\&/\n"
},
{
"answer_id": 94078,
"author": "Santiago Palladino",
"author_id": 12791,
"author_profile": "https://Stackoverflow.com/users/12791",
"pm_score": 3,
"selected": true,
"text": " private void RegexTest()\n {\n String input = \"foo[]=1&foo[]=5&foo[]=2\";\n String pattern = @\"foo\\[\\]=(\\d+)\";\n\n Regex regex = new Regex(pattern);\n\n foreach (Match match in regex.Matches(input))\n {\n Console.Out.WriteLine(match.Groups[1]);\n }\n }\n"
},
{
"answer_id": 94096,
"author": "Rory",
"author_id": 8479,
"author_profile": "https://Stackoverflow.com/users/8479",
"pm_score": 1,
"selected": false,
"text": "string[] values = Regex.Split(“foo[]=1&foo[]=5&foo[]=2”, \"&?[^&=]+=\");\n"
},
{
"answer_id": 94109,
"author": "torial",
"author_id": 13990,
"author_profile": "https://Stackoverflow.com/users/13990",
"pm_score": 1,
"selected": false,
"text": "string re = @\"foo\\[\\]=(?<value>\\d+)\";\n"
},
{
"answer_id": 94649,
"author": "Austin Salonen",
"author_id": 4068,
"author_profile": "https://Stackoverflow.com/users/4068",
"pm_score": 0,
"selected": false,
"text": "string x = \"foo[]=1&foo[]=5&foo[]=2\";\nstring[] separator = new string[2] { \"foo[]=\", \"&\" };\nstring[] vals = x.Split(separator, StringSplitOptions.RemoveEmptyEntries);\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17872/"
] |
93,989
|
<p>In .NET, what's the best way to prevent multiple instances of an app from running at the same time? And if there's no "best" technique, what are some of the caveats to consider with each solution?</p>
|
[
{
"answer_id": 94059,
"author": "Thomas Wagner",
"author_id": 13997,
"author_profile": "https://Stackoverflow.com/users/13997",
"pm_score": 5,
"selected": false,
"text": "if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)\n{\n AppLog.Write(\"Application XXXX already running. Only one instance of this application is allowed\", AppLog.LogMessageType.Warn);\n return;\n}\n"
},
{
"answer_id": 94255,
"author": "ImJustPondering",
"author_id": 17940,
"author_profile": "https://Stackoverflow.com/users/17940",
"pm_score": 8,
"selected": true,
"text": "[STAThread]\nstatic void Main() \n{\n using(Mutex mutex = new Mutex(false, \"Global\\\\\" + appGuid))\n {\n if(!mutex.WaitOne(0, false))\n {\n MessageBox.Show(\"Instance already running\");\n return;\n }\n\n Application.Run(new Form1());\n }\n}\n\nprivate static string appGuid = \"c0a76b5a-12ab-45c5-b9d9-d693faa6e7b9\";\n"
},
{
"answer_id": 95304,
"author": "Seibar",
"author_id": 357,
"author_profile": "https://Stackoverflow.com/users/357",
"pm_score": 5,
"selected": false,
"text": "public class Program\n{\n static System.Threading.Mutex singleton = new Mutex(true, \"My App Name\");\n\n static void Main(string[] args)\n {\n if (!singleton.WaitOne(TimeSpan.Zero, true))\n {\n //there is already another instance running!\n Application.Exit();\n }\n }\n}\n"
},
{
"answer_id": 509873,
"author": "Ric Tokyo",
"author_id": 42019,
"author_profile": "https://Stackoverflow.com/users/42019",
"pm_score": 2,
"selected": false,
"text": "[STAThread]\nstatic void Main() // args are OK here, of course\n{\n bool ok;\n m = new System.Threading.Mutex(true, \"YourNameHere\", out ok);\n\n if (! ok)\n {\n MessageBox.Show(\"Another instance is already running.\");\n return;\n }\n\n Application.Run(new Form1()); // or whatever was there\n\n GC.KeepAlive(m); // important!\n}\n"
},
{
"answer_id": 13153090,
"author": "Shruti",
"author_id": 1352967,
"author_profile": "https://Stackoverflow.com/users/1352967",
"pm_score": 2,
"selected": false,
"text": "Private Shared Sub Main()\n Using mutex As New Mutex(False, appGuid)\n If Not mutex.WaitOne(0, False) Then\n MessageBox.Show(\"Instance already running\", \"ERROR\", MessageBoxButtons.OK, MessageBoxIcon.Error)\n Return\n End If\n\n Application.Run(New Form1())\n End Using\nEnd Sub\n"
},
{
"answer_id": 21407828,
"author": "Bitterblue",
"author_id": 1442225,
"author_profile": "https://Stackoverflow.com/users/1442225",
"pm_score": 1,
"selected": false,
"text": "private static Bitmap randomName = new Bitmap(\"my_image.jpg\");\n"
},
{
"answer_id": 21598156,
"author": "HypeZ",
"author_id": 1957622,
"author_profile": "https://Stackoverflow.com/users/1957622",
"pm_score": 3,
"selected": false,
"text": "private static string appGuid = \"WRITE AN UNIQUE GUID HERE\";\nprivate static Mutex mutex;\n"
},
{
"answer_id": 30907248,
"author": "Derek Wade",
"author_id": 2668852,
"author_profile": "https://Stackoverflow.com/users/2668852",
"pm_score": 0,
"selected": false,
"text": "using System.Diagnostics;\n....\n[STAThread]\nstatic void Main()\n{\n...\n int procCount = 0;\n foreach (Process pp in Process.GetProcesses())\n {\n try\n {\n if (String.Compare(pp.MainModule.FileName, Application.ExecutablePath, true) == 0)\n {\n procCount++; \n if(procCount > 1) {\n Application.Exit();\n return;\n }\n }\n }\n catch { }\n }\n Application.Run(new Form1());\n}\n"
},
{
"answer_id": 31827620,
"author": "Kasper Jensen",
"author_id": 2123213,
"author_profile": "https://Stackoverflow.com/users/2123213",
"pm_score": 3,
"selected": false,
"text": "public partial class App : Application \n{ \n private static Mutex _mutex = null; \n\n protected override void OnStartup(StartupEventArgs e) \n { \n const string appName = \"MyAppName\"; \n bool createdNew; \n\n _mutex = new Mutex(true, appName, out createdNew); \n\n if (!createdNew) \n { \n //app is already running! Exiting the application \n Application.Current.Shutdown(); \n } \n\n } \n} \n"
},
{
"answer_id": 32336567,
"author": "user5289350",
"author_id": 5289350,
"author_profile": "https://Stackoverflow.com/users/5289350",
"pm_score": 3,
"selected": false,
"text": "using System.Diagnostics;\n"
},
{
"answer_id": 41597643,
"author": "Divins Mathew",
"author_id": 3201403,
"author_profile": "https://Stackoverflow.com/users/3201403",
"pm_score": 1,
"selected": false,
"text": "StreamWriter"
},
{
"answer_id": 54640621,
"author": "Tono Nam",
"author_id": 637142,
"author_profile": "https://Stackoverflow.com/users/637142",
"pm_score": 0,
"selected": false,
"text": " public static void PreventMultipleInstance(string applicationId)\n {\n // Under Windows this is:\n // C:\\Users\\SomeUser\\AppData\\Local\\Temp\\ \n // Linux this is:\n // /tmp/\n var temporaryDirectory = Path.GetTempPath();\n\n // Application ID (Make sure this guid is different accross your different applications!\n var applicationGuid = applicationId + \".process-lock\";\n\n // file that will serve as our lock\n var fileFulePath = Path.Combine(temporaryDirectory, applicationGuid);\n\n try\n {\n // Prevents other processes from reading from or writing to this file\n var _InstanceLock = new FileStream(fileFulePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);\n _InstanceLock.Lock(0, 0);\n MonoApp.Logger.LogToDisk(LogType.Notification, \"04ZH-EQP0\", \"Aquired Lock\", fileFulePath);\n\n // todo investigate why we need a reference to file stream. Without this GC releases the lock!\n System.Timers.Timer t = new System.Timers.Timer()\n {\n Interval = 500000,\n Enabled = true,\n };\n t.Elapsed += (a, b) =>\n {\n try\n {\n _InstanceLock.Lock(0, 0);\n }\n catch\n {\n MonoApp.Logger.Log(LogType.Error, \"AOI7-QMCT\", \"Unable to lock file\");\n }\n };\n t.Start();\n\n }\n catch\n {\n // Terminate application because another instance with this ID is running\n Environment.Exit(102534); \n }\n } \n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/93989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5682/"
] |
94,011
|
<p>Here is my problem: I've got a dialog with some parameters that the user can change (via a spinner for example). Each time one of these parameters is changed, I launch a thread to update a 3D view according to the new parameter value.
If the user changes another value (or the same value again by clicking many times on the spinner arrow) while the first thread is working, I would like to abort the first thread (and the update of the 3D view) and launch a new one with the latest parameter value.</p>
<p>How can I do something like that?</p>
<p>PS: There is no loop in the <code>run()</code> method of my thread, so checking for a flag is not an option: the thread updating the 3D view basically only calls a single method that is very long to execute. I can't add any flag in this method asking to abort either as I do not have access to its code.</p>
|
[
{
"answer_id": 94031,
"author": "Dave L.",
"author_id": 3093,
"author_profile": "https://Stackoverflow.com/users/3093",
"pm_score": 3,
"selected": false,
"text": "volatile boolean"
},
{
"answer_id": 94068,
"author": "Olvagor",
"author_id": 17473,
"author_profile": "https://Stackoverflow.com/users/17473",
"pm_score": 0,
"selected": false,
"text": " Class Outer\n { \n public static flag=true;\n Outer()\n {\n new Test().start();\n } \n class Test extends Thread\n { \n public void run()\n {\n while(Outer.flag)\n {\n //do your work here\n } \n }\n }\n } \n"
},
{
"answer_id": 94069,
"author": "freespace",
"author_id": 8297,
"author_profile": "https://Stackoverflow.com/users/8297",
"pm_score": 1,
"selected": false,
"text": "shutdown()"
},
{
"answer_id": 94088,
"author": "Rich Adams",
"author_id": 10018,
"author_profile": "https://Stackoverflow.com/users/10018",
"pm_score": 1,
"selected": false,
"text": "run()"
},
{
"answer_id": 94190,
"author": "basszero",
"author_id": 287,
"author_profile": "https://Stackoverflow.com/users/287",
"pm_score": 2,
"selected": false,
"text": "if(oldThread.isRunning())\n{\n oldThread.interrupt();\n // Be careful if you're doing this in response to a user\n // action on the Event Thread\n // Blocking the Event Dispatch Thread in Java is BAD BAD BAD\n oldThread.join();\n}\n\noldThread = new Thread(someRunnable);\noldThread.start();\n"
},
{
"answer_id": 95636,
"author": "skiphoppy",
"author_id": 18103,
"author_profile": "https://Stackoverflow.com/users/18103",
"pm_score": 5,
"selected": true,
"text": "boolean stopFlag = false;\nObject[] latestArgs = null;\n\npublic void run() {\n while (!stopFlag) {\n if (latestArgs != null) {\n Object[] args = latestArgs;\n latestArgs = null;\n perform3dUpdate(args);\n } else {\n Thread.sleep(500);\n }\n }\n}\n\npublic void endThread() {\n stopFlag = true;\n}\n\npublic void updateSettings(Object[] args) {\n latestArgs = args;\n}\n"
},
{
"answer_id": 240729,
"author": "nsayer",
"author_id": 13757,
"author_profile": "https://Stackoverflow.com/users/13757",
"pm_score": 2,
"selected": false,
"text": "public abstract class dispatcher<T> extends Thread {\n\n protected abstract void processItem(T work);\n\n private List<T> workItems = new ArrayList<T>();\n private boolean stopping = false;\n public void submit(T work) {\n synchronized(workItems) {\n workItems.add(work);\n workItems.notify();\n }\n }\n public void exit() {\n stopping = true;\n synchronized(workItems) {\n workItems.notifyAll();\n }\n this.join();\n }\n public void run() {\n while(!stopping) {\n T work;\n synchronized(workItems) {\n if (workItems.empty()) {\n workItems.wait();\n continue;\n }\n work = workItems.remove(0);\n }\n this.processItem(work);\n }\n }\n}\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2612/"
] |
94,023
|
<p>I came across a controller in an older set of code (Rails 1.2.3) that had the following in a controller:</p>
<pre><code>class GenericController > ApplicationController
# filters and such
model :some_model
</code></pre>
<p>Although the name of the model does not match the name of the model, is there any reason to specify this? Or is this something that has disappeared from later versions of Rails?</p>
|
[
{
"answer_id": 94041,
"author": "kch",
"author_id": 13989,
"author_profile": "https://Stackoverflow.com/users/13989",
"pm_score": 3,
"selected": true,
"text": "require"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94023",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13710/"
] |
94,037
|
<p>How can I convert a character to its ASCII code using JavaScript?</p>
<p>For example:</p>
<blockquote>
<p>get 10 from "\n".</p>
</blockquote>
|
[
{
"answer_id": 94049,
"author": "Jim",
"author_id": 8427,
"author_profile": "https://Stackoverflow.com/users/8427",
"pm_score": 12,
"selected": true,
"text": "\"\\n\".charCodeAt(0);\n"
},
{
"answer_id": 9539389,
"author": "Mohsen",
"author_id": 650722,
"author_profile": "https://Stackoverflow.com/users/650722",
"pm_score": 9,
"selected": false,
"text": "String.prototype.charCodeAt()"
},
{
"answer_id": 21861724,
"author": "Marco Altieri",
"author_id": 824846,
"author_profile": "https://Stackoverflow.com/users/824846",
"pm_score": 6,
"selected": false,
"text": "'\\n'.charCodeAt();\n'\\n'.codePointAt();\n"
},
{
"answer_id": 22173154,
"author": "Francisco Presencia",
"author_id": 938236,
"author_profile": "https://Stackoverflow.com/users/938236",
"pm_score": 5,
"selected": false,
"text": "function ascii (a) { return a.charCodeAt(0); }\n"
},
{
"answer_id": 30887763,
"author": "Filip Dupanović",
"author_id": 44041,
"author_profile": "https://Stackoverflow.com/users/44041",
"pm_score": 5,
"selected": false,
"text": "'Foobar'\n .split('')\n .map(char => char.charCodeAt(0))\n .reduce((current, previous) => previous + current)\n"
},
{
"answer_id": 40700617,
"author": "Steven de Salas",
"author_id": 448568,
"author_profile": "https://Stackoverflow.com/users/448568",
"pm_score": 3,
"selected": false,
"text": "UTF-16"
},
{
"answer_id": 44431682,
"author": "Keshav Gera",
"author_id": 5316872,
"author_profile": "https://Stackoverflow.com/users/5316872",
"pm_score": 2,
"selected": false,
"text": "function myFunction(){\n var str=document.getElementById(\"id1\");\n if (str.value==\"\") {\n str.focus();\n return;\n }\n var a=\"ASCII Code is == > \";\ndocument.getElementById(\"demo\").innerHTML =a+str.value.charCodeAt(0);\n}"
},
{
"answer_id": 58568127,
"author": "Ibrahim Lawal",
"author_id": 671568,
"author_profile": "https://Stackoverflow.com/users/671568",
"pm_score": 4,
"selected": false,
"text": "'\\n'.codePointAt(0);\n"
},
{
"answer_id": 62300522,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "str.charCodeAt(index)\n"
},
{
"answer_id": 66281755,
"author": "Roko C. Buljan",
"author_id": 383904,
"author_profile": "https://Stackoverflow.com/users/383904",
"pm_score": 2,
"selected": false,
"text": "const stringToSum = str => [...str||\"A\"].reduce((a, x) => a += x.codePointAt(0), 0);\n\nconsole.log(stringToSum(\"A\")); // 65\nconsole.log(stringToSum(\"Roko\")); // 411\nconsole.log(stringToSum(\"Stack Overflow\")); // 1386"
},
{
"answer_id": 68711802,
"author": "Vladimir Bushma",
"author_id": 7164061,
"author_profile": "https://Stackoverflow.com/users/7164061",
"pm_score": 3,
"selected": false,
"text": "const str_to_arr_of_UTF8 = new TextEncoder().encode(\"Adfgdfs\");\n// [65, 100, 102, 103, 100, 102, 115]\n"
},
{
"answer_id": 69385623,
"author": "menomanabdulla",
"author_id": 7620847,
"author_profile": "https://Stackoverflow.com/users/7620847",
"pm_score": 0,
"selected": false,
"text": "const ASCIIAverage = (str) =>Math.floor(str.split('').map(item => item.charCodeAt(0)).reduce((prev,next) => prev+next)/str.length)\n\nconsole.log(ASCIIAverage('Hello World!'))"
},
{
"answer_id": 69583492,
"author": "simlev",
"author_id": 7659430,
"author_profile": "https://Stackoverflow.com/users/7659430",
"pm_score": 1,
"selected": false,
"text": "'€'.codePointAt(0)"
},
{
"answer_id": 69671681,
"author": "tejas_spy007",
"author_id": 2873677,
"author_profile": "https://Stackoverflow.com/users/2873677",
"pm_score": 0,
"selected": false,
"text": "charCodeAt(0);"
},
{
"answer_id": 72073372,
"author": "claypooj",
"author_id": 13871578,
"author_profile": "https://Stackoverflow.com/users/13871578",
"pm_score": 0,
"selected": false,
"text": "function ascii_code (character) {\n \n // Get the decimal code\n let code = character.charCodeAt(0);\n\n // If the code is 0-127 (which are the ASCII codes,\n if (code < 128) {\n \n // Return the code obtained.\n return code;\n\n // If the code is 128 or greater (which are expanded Unicode characters),\n }else{\n\n // Return -1 so the user knows this isn't an ASCII character.\n return -1;\n };\n};\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4465/"
] |
94,042
|
<p><strong>Here is my current question:</strong></p>
<p>I'm guessing that my problem (described below) is being caused by ASP.NET worker processes being recycled, per the answers below—I'm using InProc sessions storage and don't see much chance of moving away, due to the restriction for other types of storage that all session objects be serializable. However, I can't figure out what would make the worker process be recycled as often as I'm seeing it—there wasn't any changing of the files in the app directory as far as I know, and the options in IIS seem to imply that the process would only be recycled every 1,740 minutes—which is much less frequent than the actual session loss. So, my question is now, what different cases can cause an ASP.NET worker process to be recycled?</p>
<p><strong>Here is my original question:</strong></p>
<p>I have a difficult-to-reproduce problem that occurs in my ASP.NET web application. The application has one main .aspx page that is loaded and initializes a number of session variables. This page uses the ASP.NET Ajax <code>Sys.Net.WebRequest</code> class to repeatedly access another .aspx page, which uses the session variables to make database queries and update the main page (the main page is never re-requested).</p>
<p>Occasionally, after a period of time using the page, causing successful HTTP requests where the session created in the main page properly carries over to the subpage, one of the requests seems to cause a new ASP.NET session to be created—all the session variables are lost (causing an exception to be thrown in my code), and a new session id is reported in the dynamically requested page. That means that suddenly, the main page is disconnected from the server—as far as the server is concerned, the user is no longer logged in.</p>
<p>I'm nearly positive it's not a session timeout—the timeout time is set to something ridiculous, the amount of time it takes to get this to happen is variable but is never long enough to cause the session to time out, <em>and</em> the constant <code>Sys.Net.WebRequests</code> <em>should</em> refresh the session timer.</p>
<p>So, what else could be happening that would cause the HTTP requests to lose contact with the ASP.NET session? I unfortunately haven't been sniffing network traffic when this has happened to me, or I would've checked if the ASP.NET session cookie has stuck around or not.</p>
|
[
{
"answer_id": 112284,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "...\n...\n<system.web>\n...\n...\n <healthMonitoring>\n <rules>\n <add name=\"Application Events\"\n eventName=\"Application Lifetime Events\"\n provider=\"EventLogProvider\"\n profile=\"Default\"\n minInterval=\"00:01:00\" />\n </rules>\n </healthMonitoring>\n...\n...\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5696/"
] |
94,047
|
<p>I'd like to use regular expressions in selecting elements using the match function. I'd prefer not to use an external library (such as saxon) to do this. </p>
|
[
{
"answer_id": 340867,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "CustomDate custDate = new CustomDate() ;\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94047",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
94,053
|
<p>For ASP.Net application deployment what type of information (if any) are you storing in the machine.config? </p>
<p>If you're not using it, how are you managing environment specific configuration settings that may change for each environment?</p>
<p>I'm looking for some "best practices" and the benefits/pitfalls of each. We're about to deploy a brand new application to production in two months and I've got some latitude in these types of decisions. I want to make sure that I'm approaching things in the best way possible and attempting to avoid shooting myself in the foot at a later date. </p>
<p>FYI We're using it (machine.config) currently for just the DB connection information and storing all other variables that might change in a config table in the database.</p>
|
[
{
"answer_id": 94152,
"author": "Jesse C. Slicer",
"author_id": 3312,
"author_profile": "https://Stackoverflow.com/users/3312",
"pm_score": 2,
"selected": false,
"text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<configuration>\n <mscorlib>\n <cryptographySettings>\n <cryptoNameMapping>\n <cryptoClasses>\n <cryptoClass Tiger192=\"Jcs.Tiger.Tiger192, Jcs.Tiger, Culture=neutral, PublicKeyToken=66c61a8173417e64, Version=1.0.0.4\"/>\n <cryptoClass Tiger160=\"Jcs.Tiger.Tiger160, Jcs.Tiger, Culture=neutral, PublicKeyToken=66c61a8173417e64, Version=1.0.0.4\"/>\n <cryptoClass Tiger128=\"Jcs.Tiger.Tiger128, Jcs.Tiger, Culture=neutral, PublicKeyToken=66c61a8173417e64, Version=1.0.0.4\"/>\n </cryptoClasses>\n <nameEntry name=\"Tiger\" class=\"Tiger192\"/>\n <nameEntry name=\"TigerFull\" class=\"Tiger192\"/>\n <nameEntry name=\"Tiger192\" class=\"Tiger192\"/>\n <nameEntry name=\"Tiger160\" class=\"Tiger160\"/>\n <nameEntry name=\"Tiger128\" class=\"Tiger128\"/>\n <nameEntry name=\"System.Security.Cryptography.HashAlgorithm\" class=\"Tiger192\"/>\n </cryptoNameMapping>\n <oidMap>\n <oidEntry OID=\"1.3.6.1.4.1.11591.12.2\" name=\"Jcs.Tiger.Tiger192\"/>\n </oidMap>\n </cryptographySettings>\n </mscorlib>\n</configuration>\n"
},
{
"answer_id": 94167,
"author": "Thomas Jespersen",
"author_id": 8547,
"author_profile": "https://Stackoverflow.com/users/8547",
"pm_score": 4,
"selected": true,
"text": "<appSettings>\n <add key=\"Environment\" value=\"Staging\"/>\n</appSettings>\n"
},
{
"answer_id": 94439,
"author": "sontek",
"author_id": 17176,
"author_profile": "https://Stackoverflow.com/users/17176",
"pm_score": 3,
"selected": false,
"text": "<system.web>\n <deployment retail=\"true\" />\n <healthMonitoring enabled=\"true\" />\n</system.web> \n"
},
{
"answer_id": 95857,
"author": "nathaniel",
"author_id": 11947,
"author_profile": "https://Stackoverflow.com/users/11947",
"pm_score": 3,
"selected": false,
"text": "<machineKey validationKey='A130E240DF1C49E2764EF8A86CEDCBB11274E5298A130CA08B90EED016C0\n14CEAE1D86344C29E67E99DF83347E43820050A2B9C9FC89E0574BF3394B6D0401A9'\ndecryptionKey='2CC37FFA8D14925B9CBCC0E3B1506F35066FEF33FEB4ADC8' validation='SHA1'/>\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
94,074
|
<p>I'm using wget to connect to a secure site like this:</p>
<p><code>wget -nc -i inputFile</code></p>
<p>where inputeFile consists of URLs like this:</p>
<p><code><a href="https://clientWebsite.com/TheirPageName.asp?orderValue=1.00&merchantID=36&programmeID=92&ref=foo&Ofaz=0" rel="nofollow noreferrer">https://clientWebsite.com/TheirPageName.asp?orderValue=1.00&merchantID=36&programmeID=92&ref=foo&Ofaz=0</a></code></p>
<p>This page returns a small gif file. For some reason, this is taking around 2.5 minutes. When I paste the same URL into a browser, I get back a response within seconds. </p>
<p>Does anyone have any idea what could be causing this?</p>
<p>The version of wget, by the way, is "GNU Wget 1.9+cvs-stable (Red Hat modified)"</p>
|
[
{
"answer_id": 94100,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 3,
"selected": false,
"text": "-U \"Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-GB; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1\" \n"
},
{
"answer_id": 70194890,
"author": "Teddy",
"author_id": 10025369,
"author_profile": "https://Stackoverflow.com/users/10025369",
"pm_score": 0,
"selected": false,
"text": "https:\\\\"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
94,103
|
<p>Does anyone know how SQL Server determines the order triggers (of same type, i.e. before triggers) are executed. And is there any way of changing this so that I can specify the order I want. If not, why not.</p>
<p>Thanks.</p>
|
[
{
"answer_id": 94158,
"author": "EvilEddie",
"author_id": 12986,
"author_profile": "https://Stackoverflow.com/users/12986",
"pm_score": 2,
"selected": false,
"text": "sp_Settriggerorder"
},
{
"answer_id": 94162,
"author": "Ben Hoffstein",
"author_id": 4482,
"author_profile": "https://Stackoverflow.com/users/4482",
"pm_score": 1,
"selected": false,
"text": "sp_settriggerorder[@triggername = ] 'triggername', [@order = ] 'value', [@stmttype = ] 'statement_type'\n"
},
{
"answer_id": 94223,
"author": "Frosty",
"author_id": 7476,
"author_profile": "https://Stackoverflow.com/users/7476",
"pm_score": 2,
"selected": false,
"text": "sp_settriggerorder [ @triggername = ] ‘[ triggerschema. ] triggername’\n, [ @order = ] ‘value’\n, [ @stmttype = ] ’statement_type’\n[ , [ @namespace = ] { ‘DATABASE’ | ‘SERVER’ | NULL } ]\n"
},
{
"answer_id": 18658268,
"author": "Ardalan Shahgholi",
"author_id": 2063547,
"author_profile": "https://Stackoverflow.com/users/2063547",
"pm_score": 2,
"selected": false,
"text": "USE AdventureWorks;\nGO\nEXEC sys.sp_settriggerorder @triggername = N'', -- nvarchar(517)\n @order = '', -- varchar(10)\n @stmttype = '', -- varchar(50)\n @namespace = '' -- varchar(10)\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11989/"
] |
94,112
|
<p>My code takes an interface as input but only excercises a couple of the interface's methods (often, just getters).</p>
<p>When testing the code, I'd love to define an anonymous inner class that returns the test data. But what do I do about all the other methods that the interface requires?</p>
<p>I could use my IDE to auto-generate a stub for the interface but that seems fairly code-heavy. </p>
<p>What is the easiest way to stub the two methods I care about and none of the methods I don't?</p>
|
[
{
"answer_id": 94159,
"author": "Burkhard",
"author_id": 12860,
"author_profile": "https://Stackoverflow.com/users/12860",
"pm_score": 0,
"selected": false,
"text": "class MyAdapter extends MyClass {\n public void A() {\n }\n ...\n}\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11766/"
] |
94,123
|
<p>I'm working on a webapp, and every so often we run into situations where pages will load without applying CSS. This problem has shown up in IE6, IE7, Safari 3, and FF3.</p>
<p>A page refresh will always fix the problem.</p>
<p>There are 3 CSS files loaded, all within the same style block using @import:</p>
<pre><code><STYLE type="text/css">
@import url([base css file]);
@import url([skin css file]);
@import url([generated css path]);
</STYLE>
</code></pre>
<p>In any situation when we take the time to examine the html source, nothing is out of the ordinary. Access logs seem normal as well - we're getting HTTP 304 responses for the static CSS files whenever they are requested, and an HTTP 200 response for our generated CSS.</p>
<p>The mimetype is text/css for the css files and the generated css. We're using an iPlanet server, which forwards requests to a Tomcat server.</p>
<p>davebug asked: </p>
<blockquote>
<p>Is it always the same css file not loading, or is the problem with all of them, evenly?</p>
</blockquote>
<p>None of the CSS files load. Any styles defined within the HTML work fine, but nothing in any of the CSS files works when this happens.</p>
|
[
{
"answer_id": 98158,
"author": "da5id",
"author_id": 14979,
"author_profile": "https://Stackoverflow.com/users/14979",
"pm_score": 3,
"selected": true,
"text": "<link rel=\"stylesheet\" href=\"[base css file]\" type=\"text/css\" media=\"screen\" />\n"
},
{
"answer_id": 8058417,
"author": "Ciummo",
"author_id": 1036652,
"author_profile": "https://Stackoverflow.com/users/1036652",
"pm_score": 1,
"selected": false,
"text": "/ActionName"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17887/"
] |
94,141
|
<p>I have the following script, where the first and third <code>document.writeline</code> are static and <strong>the second is generated</strong>:</p>
<pre><code><script language="javascript" type="text/javascript">
document.write("<script language='javascript' type='text/javascript' src='before.js'><\/sc" + "ript>");
document.write("<script language='javascript' type='text/javascript'>alert('during');<\/sc" + "ript>");
document.write("<script language='javascript' type='text/javascript' src='after.js'><\/sc" + "ript>");
</script>
</code></pre>
<p>Firefox and Chrome will display <em>before</em>, <em>during</em> and <em>after</em>, while Internet Explorer first shows <em>during</em> and only then does it show <em>before</em> and <em>after</em>.</p>
<p>I've come across <a href="http://www.elctech.com/blog/nesting-document-write" rel="noreferrer">an article that states</a> that I'm not the first to encounter this, but that hardly makes me feel any better.</p>
<p><strong>Does anyone know how I can set the order to be deterministic in all browsers, or hack IE to work like all the other, sane browsers do?</strong></p>
<p><strong>Caveats</strong>: The code snippet is a very simple repro. It is generated on the server and the second script is the only thing that changes. It's a long script and the reason there are two scripts before and after it are so that the browser will cache them and the dynamic part of the code will be as small as possible. It may also appears many times in the same page with different generated code.</p>
|
[
{
"answer_id": 94328,
"author": "Prestaul",
"author_id": 5628,
"author_profile": "https://Stackoverflow.com/users/5628",
"pm_score": 1,
"selected": false,
"text": "var se1 = document.createElement('script');\nse1.src = 'a.js';\n\nvar se2 = document.createElement('script');\nse2.src = 'b.js';\n\nvar se3 = document.createElement('script');\nse3.src = 'c.js';\n\nvar head = document.getElementsByTagName('head')[0]\nhead.appendChild(se1);\nhead.appendChild(se2);\nhead.appendChild(se3);\n"
},
{
"answer_id": 94503,
"author": "Dustman",
"author_id": 16398,
"author_profile": "https://Stackoverflow.com/users/16398",
"pm_score": 1,
"selected": false,
"text": "// During.js\nduring[fish]();\n"
},
{
"answer_id": 100632,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 0,
"selected": false,
"text": "<script language=\"javascript\" type=\"text/javascript\">\ndocument.write(\"<script language='javascript' type='text/javascript'>function callGeneratedContent() { alert('during'); }<\\x2Fscript>\");\ndocument.write(\"<script language='javascript' type='text/javascript' src='before.js'><\\x2Fscript>\");\ndocument.write(\"<script language='javascript' type='text/javascript' src='after.js'><\\x2Fscript>\");\n</script>\n"
},
{
"answer_id": 120165,
"author": "Omer van Kloeten",
"author_id": 4979,
"author_profile": "https://Stackoverflow.com/users/4979",
"pm_score": 4,
"selected": true,
"text": "<script language=\"javascript\" type=\"text/javascript\">\ndocument.write(\"<script language='javascript' type='text/javascript' src='before.js'><\\/sc\" + \"ript>\");\ndocument.write(\"<script defer language='javascript' type='text/javascript'>alert('during');<\\/sc\" + \"ript>\");\ndocument.write(\"<script defer language='javascript' type='text/javascript' src='after.js'><\\/sc\" + \"ript>\");\n</script>\n"
},
{
"answer_id": 711448,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<script>\ndocument.write(\"<script src='before.js'><\\/script>\");\n</script>\n\n<script >\ndocument.write(\"<script>alert('during');<\\/script>\");\n</script>\n\n<script>\ndocument.write(\"<script src='after.js'><\\/script>\");\n</script>\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4979/"
] |
94,148
|
<p>Working on a project that parses a log of events, and then updates a model based on properties of those events. I've been pretty lazy about "getting it done" and more concerned about upfront optimization, lean code, and proper design patterns. Mostly a self-teaching experiment. I am interested in what patterns more experienced designers think are relevant, or what type of pseudocoded object architecture would be the best, easiest to maintain and so on.</p>
<p>There can be 500,000 events in a single log, and there are about 60 types of events, all of which share about 7 base properties and then have 0 to 15 additional properties depending on the event type. The type of event is the 2nd property in the log file in each line.</p>
<p>So for I've tried a really ugly imperative parser that walks through the log line by line and then processes events line by line. Then I tried a lexical specification that uses a "nextEvent" pattern, which is called in a loop and processed. Then I tried a plain old "parse" method that never returns and just fires events to registered listener callbacks. I've tried both a single callback regardless of event type, and a callback method specific to each event type.</p>
<p>I've tried a base "event" class with a union of all possible properties. I've tried to avoid the "new Event" call (since there can be a huge number of events and the event objects are generally short lived) and having the callback methods per type with primitive property arguments. I've tried having a subclass for each of the 60 event types with an abstract Event parent with the 7 common base properties.</p>
<p>I recently tried taking that further and using a Command pattern to put event handling code per event type. I am not sure I like this and its really similar to the callbacks per type approach, just code is inside an execute function in the type subclasses versus the callback methods per type. </p>
<p>The problem is that alot of the model updating logic is shared, and alot of it is specific to the subclass, and I am just starting to get confused about the whole thing. I am hoping someone can at least point me in a direction to consider!</p>
|
[
{
"answer_id": 220017,
"author": "moffdub",
"author_id": 10759,
"author_profile": "https://Stackoverflow.com/users/10759",
"pm_score": 1,
"selected": false,
"text": "class Event\n{\n // maps property name to property value\n private Map<String, String> properties;\n\n // maps property name to model updater\n private Map<String, ModelUpdater> updaters; \n\n public void update(Model modelToUpdate)\n {\n foreach(String key in this.properties.keys)\n {\n ModelUpdater updater = this.updaters[key];\n String propertyValue = this.properties[key];\n\n updaters.updateModelUsingValue(model, propertyValue);\n }\n }\n\n}\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2204759/"
] |
94,153
|
<p>I am attempting to use the 'tempfile' module for manipulating and creating text files. Once the file is ready I want to save it to disk. I thought it would be as simple as using 'shutil.copy'. However, I get a 'permission denied' IOError:</p>
<pre><code>>>> import tempfile, shutil
>>> f = tempfile.TemporaryFile(mode ='w+t')
>>> f.write('foo')
>>> shutil.copy(f.name, 'bar.txt')
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
shutil.copy(f.name, 'bar.txt')
File "C:\Python25\lib\shutil.py", line 80, in copy
copyfile(src, dst)
File "C:\Python25\lib\shutil.py", line 46, in copyfile
fsrc = open(src, 'rb')
IOError: [Errno 13] Permission denied: 'c:\\docume~1\\me\\locals~1\\temp\\tmpvqq3go'
>>>
</code></pre>
<p>Is this not intended when using the 'tempfile' library? Is there a better way to do this? (Maybe I am overlooking something very trivial)</p>
|
[
{
"answer_id": 94206,
"author": "Hans Sjunnesson",
"author_id": 8683,
"author_profile": "https://Stackoverflow.com/users/8683",
"pm_score": 3,
"selected": false,
"text": "new_file = open('bar.txt', 'rw')\nshutil.copyfileobj(f, new_file)\n"
},
{
"answer_id": 94339,
"author": "dF.",
"author_id": 3002,
"author_profile": "https://Stackoverflow.com/users/3002",
"pm_score": 6,
"selected": true,
"text": "TemporaryFile"
},
{
"answer_id": 109591,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "NamedTemporaryFile"
},
{
"answer_id": 9155528,
"author": "K Z",
"author_id": 853611,
"author_profile": "https://Stackoverflow.com/users/853611",
"pm_score": 5,
"selected": false,
"text": "f.close()"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] |
94,154
|
<p>I'm trying to configure the Quick Launch menu to only display the ancestors and descendant nodes of the currently select node. The menu also needs to display all the childern of the root node. More simply:</p>
<p>Given a site map of:</p>
<p><strong>RootSite</strong></p>
<p>---<strong>SubSite1</strong> = navigation set at "Display the current site, the navigation items below the current site, and the current site's siblings"</p>
<p>-----<strong>Heading1</strong> = navigation set at "Display the same navigation items as the parent site"</p>
<p>-------<strong>Page1</strong> = navigation set at "Display the same navigation items as the parent site"</p>
<p>-------<strong>Page2</strong> = navigation set at "Display the same navigation items as the parent site"</p>
<p>-----<strong>Heading2</strong> = navigation set at "Display the same navigation items as the parent site"</p>
<p>---<strong>SubSite2</strong> = navigation set at "Display the current site, the navigation items below the current site, and the current site's siblings"</p>
<p>-----<strong>Heading1</strong> = navigation set at "Display the same navigation items as the parent site"</p>
<p>SiteMapProvider configuration:</p>
<pre><code><PublishingNavigation:PortalSiteMapDataSource ID="SiteMapDS" Runat="server"
SiteMapProvider="CurrentNavSiteMapProvider" EnableViewState="true"
StartFromCurrentNode="true" ShowStartingNode="false"/>
</code></pre>
<p>The expected and actual behavior of the Quick Launch menu displayed at SubSite1 is:</p>
<p>---SubSite1</p>
<p>-----Heading1</p>
<p>-------Page1</p>
<p>-------Page2</p>
<p>-----Heading2</p>
<p>---SubSite2</p>
<p>The expected behavior of the menu after navigating to Heading1 of SubSite2:</p>
<p>---SubSite1</p>
<p>---SubSite2</p>
<p>-----Heading1</p>
<p>What I actually see after navigating to Heading1 of SubSite2:</p>
<p>---SubSite1</p>
<p>-----Heading1</p>
<p>-------Page1</p>
<p>-------Page2</p>
<p>-----Heading2</p>
<p>---SubSite2</p>
<p>-----Heading1</p>
<p>This does not match what I expect to see if I set the Heading1 navigation to "Display the
same navigation items as the parent site" and SubSite2 is set to "Display the current site, the navigation items below the current site, and the current site's siblings". I expect
Heading1 to inherit the navigation item of SubSite2 with the SubSite1 items collapsed from view. I've also played with the various
Trim... attributes without success. Any help will be greatly appreciated!</p>
|
[
{
"answer_id": 129428,
"author": "Sixto Saez",
"author_id": 9711,
"author_profile": "https://Stackoverflow.com/users/9711",
"pm_score": 3,
"selected": true,
"text": "<%@ Register TagPrefix=\"myCustom\" Namespace=\"YourCompany.CustomWebParts\"\n Assembly=\"YourCompany.CustomWebParts, Version=1.0.0.0, Culture=neutral,\n PublicKeyToken=9f4da00116c38ec5\" %>\n\n...\n\n<myCustom:MossMenu ID=\"CurrentNav\" runat=\"server\" datasourceID=\"SiteMapDS\"\n orientation=\"Vertical\" UseCompactMenus=\"true\" StaticDisplayLevels=\"6\"\n MaximumDynamicDisplayLevels=\"0\" StaticSubMenuIndent=\"5\" ItemWrap=\"false\"\n AccessKey=\"3\" CssClass=\"leftNav\"\n SkipLinkText=\"<%$Resources:cms,masterpages_skiplinktext%>\">\n <LevelMenuItemStyles>\n <asp:MenuItemStyle CssClass=\"Nav\" />\n <asp:MenuItemStyle CssClass=\"SecNav\" />\n </LevelMenuItemStyles>\n <StaticHoverStyle CssClass=\"leftNavHover\"/>\n <StaticSelectedStyle CssClass=\"leftNavSelected\"/>\n <DynamicMenuStyle CssClass=\"leftNavFlyOuts\" />\n <DynamicMenuItemStyle CssClass=\"leftNavFlyOutsItem\"/>\n <DynamicHoverStyle CssClass=\"leftNavFlyOutsHover\"/>\n</myCustom:MossMenu>\n\n<PublishingNavigation:PortalSiteMapDataSource ID=\"SiteMapDS\" Runat=\"server\"\n SiteMapProvider=\"CurrentNavSiteMapProvider\" EnableViewState=\"true\"\n StartFromCurrentNode=\"true\" ShowStartingNode=\"false\"/>\n\n...\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9711/"
] |
94,161
|
<p>I'm working on a project that will be distributed with GNU autoconf/automake, and I have a set of bash scripts which call awk scripts. I would like the bash scripts to end up in the $PATH, but not the awk scripts. How should I insert these into the project? Should they be put in with other binaries?</p>
<p>Also, is there a way to determine the final location of the file after installation? I presume that /usr/local/bin isn't <em>always</em> where the executables end up...</p>
|
[
{
"answer_id": 94259,
"author": "terminus",
"author_id": 9232,
"author_profile": "https://Stackoverflow.com/users/9232",
"pm_score": 3,
"selected": true,
"text": "scriptsdir = $(prefix)/bin\nscripts_DATA = awkscript1 awkscript2\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17925/"
] |
94,171
|
<p>In C#.Net WPF During UserControl.Load -></p>
<p>What is the best way of showing a whirling circle / 'Loading' Indicator on the UserControl until it has finished gathering data and rendering it's contents?</p>
|
[
{
"answer_id": 95143,
"author": "dcstraw",
"author_id": 10391,
"author_profile": "https://Stackoverflow.com/users/10391",
"pm_score": 5,
"selected": true,
"text": "<Grid>\n <Grid x:Name=\"MainContent\" IsEnabled=\"False\">\n ...\n </Grid>\n\n <Grid x:Name=\"LoadingIndicatorPanel\">\n ...\n </Grid>\n</Grid>\n"
},
{
"answer_id": 132966,
"author": "Ian Oakes",
"author_id": 21606,
"author_profile": "https://Stackoverflow.com/users/21606",
"pm_score": 3,
"selected": false,
"text": "<Window \n x:Class=\"WpfApplication2.Window1\"\n xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\n Title=\"Window1\"\n Height=\"300\"\n Width=\"300\"\n >\n <Window.Resources>\n <Color x:Key=\"FilledColor\" A=\"255\" B=\"155\" R=\"155\" G=\"155\"/>\n <Color x:Key=\"UnfilledColor\" A=\"0\" B=\"155\" R=\"155\" G=\"155\"/>\n\n <Storyboard x:Key=\"Animation0\" FillBehavior=\"Stop\" BeginTime=\"00:00:00.0\" RepeatBehavior=\"Forever\">\n <ColorAnimationUsingKeyFrames Storyboard.TargetName=\"_00\" Storyboard.TargetProperty=\"(Shape.Fill).(SolidColorBrush.Color)\">\n <SplineColorKeyFrame KeyTime=\"00:00:00.0\" Value=\"{StaticResource FilledColor}\"/>\n <SplineColorKeyFrame KeyTime=\"00:00:01.6\" Value=\"{StaticResource UnfilledColor}\"/>\n </ColorAnimationUsingKeyFrames>\n </Storyboard>\n\n <Storyboard x:Key=\"Animation1\" BeginTime=\"00:00:00.2\" RepeatBehavior=\"Forever\">\n <ColorAnimationUsingKeyFrames Storyboard.TargetName=\"_01\" Storyboard.TargetProperty=\"(Shape.Fill).(SolidColorBrush.Color)\">\n <SplineColorKeyFrame KeyTime=\"00:00:00.0\" Value=\"{StaticResource FilledColor}\"/>\n <SplineColorKeyFrame KeyTime=\"00:00:01.6\" Value=\"{StaticResource UnfilledColor}\"/>\n </ColorAnimationUsingKeyFrames>\n </Storyboard>\n\n <Storyboard x:Key=\"Animation2\" BeginTime=\"00:00:00.4\" RepeatBehavior=\"Forever\">\n <ColorAnimationUsingKeyFrames Storyboard.TargetName=\"_02\" Storyboard.TargetProperty=\"(Shape.Fill).(SolidColorBrush.Color)\">\n <SplineColorKeyFrame KeyTime=\"00:00:00.0\" Value=\"{StaticResource FilledColor}\"/>\n <SplineColorKeyFrame KeyTime=\"00:00:01.6\" Value=\"{StaticResource UnfilledColor}\"/>\n </ColorAnimationUsingKeyFrames>\n </Storyboard>\n\n <Storyboard x:Key=\"Animation3\" BeginTime=\"00:00:00.6\" RepeatBehavior=\"Forever\">\n <ColorAnimationUsingKeyFrames Storyboard.TargetName=\"_03\" Storyboard.TargetProperty=\"(Shape.Fill).(SolidColorBrush.Color)\">\n <SplineColorKeyFrame KeyTime=\"00:00:00.0\" Value=\"{StaticResource FilledColor}\"/>\n <SplineColorKeyFrame KeyTime=\"00:00:01.6\" Value=\"{StaticResource UnfilledColor}\"/>\n </ColorAnimationUsingKeyFrames>\n </Storyboard>\n\n <Storyboard x:Key=\"Animation4\" BeginTime=\"00:00:00.8\" RepeatBehavior=\"Forever\">\n <ColorAnimationUsingKeyFrames Storyboard.TargetName=\"_04\" Storyboard.TargetProperty=\"(Shape.Fill).(SolidColorBrush.Color)\">\n <SplineColorKeyFrame KeyTime=\"00:00:00.0\" Value=\"{StaticResource FilledColor}\"/>\n <SplineColorKeyFrame KeyTime=\"00:00:01.6\" Value=\"{StaticResource UnfilledColor}\"/>\n </ColorAnimationUsingKeyFrames>\n </Storyboard>\n\n <Storyboard x:Key=\"Animation5\" BeginTime=\"00:00:01.0\" RepeatBehavior=\"Forever\">\n <ColorAnimationUsingKeyFrames Storyboard.TargetName=\"_05\" Storyboard.TargetProperty=\"(Shape.Fill).(SolidColorBrush.Color)\">\n <SplineColorKeyFrame KeyTime=\"00:00:00.0\" Value=\"{StaticResource FilledColor}\"/>\n <SplineColorKeyFrame KeyTime=\"00:00:01.6\" Value=\"{StaticResource UnfilledColor}\"/>\n </ColorAnimationUsingKeyFrames>\n </Storyboard>\n\n <Storyboard x:Key=\"Animation6\" BeginTime=\"00:00:01.2\" RepeatBehavior=\"Forever\">\n <ColorAnimationUsingKeyFrames Storyboard.TargetName=\"_06\" Storyboard.TargetProperty=\"(Shape.Fill).(SolidColorBrush.Color)\">\n <SplineColorKeyFrame KeyTime=\"00:00:00.0\" Value=\"{StaticResource FilledColor}\"/>\n <SplineColorKeyFrame KeyTime=\"00:00:01.6\" Value=\"{StaticResource UnfilledColor}\"/>\n </ColorAnimationUsingKeyFrames>\n </Storyboard>\n\n <Storyboard x:Key=\"Animation7\" BeginTime=\"00:00:01.4\" RepeatBehavior=\"Forever\">\n <ColorAnimationUsingKeyFrames Storyboard.TargetName=\"_07\" Storyboard.TargetProperty=\"(Shape.Fill).(SolidColorBrush.Color)\">\n <SplineColorKeyFrame KeyTime=\"00:00:00.0\" Value=\"{StaticResource FilledColor}\"/>\n <SplineColorKeyFrame KeyTime=\"00:00:01.6\" Value=\"{StaticResource UnfilledColor}\"/>\n </ColorAnimationUsingKeyFrames>\n </Storyboard>\n </Window.Resources>\n\n <Window.Triggers>\n <EventTrigger RoutedEvent=\"FrameworkElement.Loaded\">\n <BeginStoryboard Storyboard=\"{StaticResource Animation0}\"/>\n <BeginStoryboard Storyboard=\"{StaticResource Animation1}\"/>\n <BeginStoryboard Storyboard=\"{StaticResource Animation2}\"/>\n <BeginStoryboard Storyboard=\"{StaticResource Animation3}\"/>\n <BeginStoryboard Storyboard=\"{StaticResource Animation4}\"/>\n <BeginStoryboard Storyboard=\"{StaticResource Animation5}\"/>\n <BeginStoryboard Storyboard=\"{StaticResource Animation6}\"/>\n <BeginStoryboard Storyboard=\"{StaticResource Animation7}\"/>\n </EventTrigger>\n </Window.Triggers>\n\n <Canvas>\n <Canvas Canvas.Left=\"21.75\" Canvas.Top=\"14\" Height=\"81.302\" Width=\"80.197\">\n <Canvas.Resources>\n <Style TargetType=\"Ellipse\">\n <Setter Property=\"Width\" Value=\"15\"/>\n <Setter Property=\"Height\" Value=\"15\" />\n <Setter Property=\"Fill\" Value=\"#FFFFFFFF\" />\n </Style>\n </Canvas.Resources>\n\n <Ellipse x:Name=\"_00\" Canvas.Left=\"24.75\" Canvas.Top=\"50\"/>\n <Ellipse x:Name=\"_01\" Canvas.Top=\"36\" Canvas.Left=\"29.5\"/>\n <Ellipse x:Name=\"_02\" Canvas.Left=\"43.5\" Canvas.Top=\"29.75\"/>\n <Ellipse x:Name=\"_03\" Canvas.Left=\"57.75\" Canvas.Top=\"35.75\"/>\n <Ellipse x:Name=\"_04\" Canvas.Left=\"63.5\" Canvas.Top=\"49.75\" />\n <Ellipse x:Name=\"_05\" Canvas.Left=\"57.75\" Canvas.Top=\"63.5\"/>\n <Ellipse x:Name=\"_06\" Canvas.Left=\"43.75\" Canvas.Top=\"68.75\"/>\n <Ellipse x:Name=\"_07\" Canvas.Top=\"63.25\" Canvas.Left=\"30\" />\n <Ellipse Stroke=\"{x:Null}\" Width=\"39.5\" Height=\"39.5\" Canvas.Left=\"31.75\" Canvas.Top=\"37\" Fill=\"{x:Null}\"/>\n </Canvas>\n </Canvas>\n</Window>\n"
},
{
"answer_id": 3882106,
"author": "VadimB",
"author_id": 454741,
"author_profile": "https://Stackoverflow.com/users/454741",
"pm_score": 1,
"selected": false,
"text": "<WindowsFormsHost>\n <winForms:PictureBox x:Name=\"pictureBoxLoading\" />\n</WindowsFormsHost>\n"
},
{
"answer_id": 14692963,
"author": "Sven Hecht",
"author_id": 1168,
"author_profile": "https://Stackoverflow.com/users/1168",
"pm_score": 3,
"selected": false,
"text": "<UserControl x:Class=\"Mesap.Framework.UI.Controls.BusyIndicator\"\n xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\n xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \n xmlns:d=\"http://schemas.microsoft.com/expression/blend/2008\" \n mc:Ignorable=\"d\" Name=\"Root\" Foreground=\"#9b9b9b\"\n d:DesignHeight=\"100\" d:DesignWidth=\"100\">\n <Grid>\n <Grid.Resources>\n <Storyboard x:Key=\"Animation0\" FillBehavior=\"Stop\" BeginTime=\"00:00:00.0\" RepeatBehavior=\"Forever\">\n <DoubleAnimationUsingKeyFrames Storyboard.TargetName=\"E00\" Storyboard.TargetProperty=\"Opacity\">\n <LinearDoubleKeyFrame KeyTime=\"00:00:00.0\" Value=\"1\"/>\n <LinearDoubleKeyFrame KeyTime=\"00:00:01.6\" Value=\"0\"/>\n </DoubleAnimationUsingKeyFrames>\n </Storyboard>\n\n <Storyboard x:Key=\"Animation1\" BeginTime=\"00:00:00.2\" RepeatBehavior=\"Forever\">\n <DoubleAnimationUsingKeyFrames Storyboard.TargetName=\"E01\" Storyboard.TargetProperty=\"Opacity\">\n <LinearDoubleKeyFrame KeyTime=\"00:00:00.0\" Value=\"1\"/>\n <LinearDoubleKeyFrame KeyTime=\"00:00:01.6\" Value=\"0\"/>\n </DoubleAnimationUsingKeyFrames>\n </Storyboard>\n\n <Storyboard x:Key=\"Animation2\" BeginTime=\"00:00:00.4\" RepeatBehavior=\"Forever\">\n <DoubleAnimationUsingKeyFrames Storyboard.TargetName=\"E02\" Storyboard.TargetProperty=\"Opacity\">\n <LinearDoubleKeyFrame KeyTime=\"00:00:00.0\" Value=\"1\"/>\n <LinearDoubleKeyFrame KeyTime=\"00:00:01.6\" Value=\"0\"/>\n </DoubleAnimationUsingKeyFrames>\n </Storyboard>\n\n <Storyboard x:Key=\"Animation3\" BeginTime=\"00:00:00.6\" RepeatBehavior=\"Forever\">\n <DoubleAnimationUsingKeyFrames Storyboard.TargetName=\"E03\" Storyboard.TargetProperty=\"Opacity\">\n <LinearDoubleKeyFrame KeyTime=\"00:00:00.0\" Value=\"1\"/>\n <LinearDoubleKeyFrame KeyTime=\"00:00:01.6\" Value=\"0\"/>\n </DoubleAnimationUsingKeyFrames>\n </Storyboard>\n\n <Storyboard x:Key=\"Animation4\" BeginTime=\"00:00:00.8\" RepeatBehavior=\"Forever\">\n <DoubleAnimationUsingKeyFrames Storyboard.TargetName=\"E04\" Storyboard.TargetProperty=\"Opacity\">\n <LinearDoubleKeyFrame KeyTime=\"00:00:00.0\" Value=\"1\"/>\n <LinearDoubleKeyFrame KeyTime=\"00:00:01.6\" Value=\"0\"/>\n </DoubleAnimationUsingKeyFrames>\n </Storyboard>\n\n <Storyboard x:Key=\"Animation5\" BeginTime=\"00:00:01.0\" RepeatBehavior=\"Forever\">\n <DoubleAnimationUsingKeyFrames Storyboard.TargetName=\"E05\" Storyboard.TargetProperty=\"Opacity\">\n <LinearDoubleKeyFrame KeyTime=\"00:00:00.0\" Value=\"1\"/>\n <LinearDoubleKeyFrame KeyTime=\"00:00:01.6\" Value=\"0\"/>\n </DoubleAnimationUsingKeyFrames>\n </Storyboard>\n\n <Storyboard x:Key=\"Animation6\" BeginTime=\"00:00:01.2\" RepeatBehavior=\"Forever\">\n <DoubleAnimationUsingKeyFrames Storyboard.TargetName=\"E06\" Storyboard.TargetProperty=\"Opacity\">\n <LinearDoubleKeyFrame KeyTime=\"00:00:00.0\" Value=\"1\"/>\n <LinearDoubleKeyFrame KeyTime=\"00:00:01.6\" Value=\"0\"/>\n </DoubleAnimationUsingKeyFrames>\n </Storyboard>\n\n <Storyboard x:Key=\"Animation7\" BeginTime=\"00:00:01.4\" RepeatBehavior=\"Forever\">\n <DoubleAnimationUsingKeyFrames Storyboard.TargetName=\"E07\" Storyboard.TargetProperty=\"Opacity\">\n <LinearDoubleKeyFrame KeyTime=\"00:00:00.0\" Value=\"1\"/>\n <LinearDoubleKeyFrame KeyTime=\"00:00:01.6\" Value=\"0\"/>\n </DoubleAnimationUsingKeyFrames>\n </Storyboard>\n\n <Style TargetType=\"Ellipse\">\n <Setter Property=\"Fill\" Value=\"{Binding ElementName=Root, Path=Foreground}\"/>\n\n </Style>\n </Grid.Resources>\n <Grid.Triggers>\n <EventTrigger RoutedEvent=\"FrameworkElement.Loaded\">\n <BeginStoryboard Storyboard=\"{StaticResource Animation0}\"/>\n <BeginStoryboard Storyboard=\"{StaticResource Animation1}\"/>\n <BeginStoryboard Storyboard=\"{StaticResource Animation2}\"/>\n <BeginStoryboard Storyboard=\"{StaticResource Animation3}\"/>\n <BeginStoryboard Storyboard=\"{StaticResource Animation4}\"/>\n <BeginStoryboard Storyboard=\"{StaticResource Animation5}\"/>\n <BeginStoryboard Storyboard=\"{StaticResource Animation6}\"/>\n <BeginStoryboard Storyboard=\"{StaticResource Animation7}\"/>\n </EventTrigger>\n </Grid.Triggers>\n\n <Grid.ColumnDefinitions>\n <ColumnDefinition/>\n <ColumnDefinition/>\n <ColumnDefinition/>\n <ColumnDefinition/>\n <ColumnDefinition/>\n <ColumnDefinition/>\n <ColumnDefinition/>\n <ColumnDefinition/>\n <ColumnDefinition/>\n <ColumnDefinition/>\n <ColumnDefinition/>\n </Grid.ColumnDefinitions>\n <Grid.RowDefinitions>\n <RowDefinition/>\n <RowDefinition/>\n <RowDefinition/>\n <RowDefinition/>\n <RowDefinition/>\n <RowDefinition/>\n <RowDefinition/>\n <RowDefinition/>\n <RowDefinition/>\n <RowDefinition/>\n <RowDefinition/>\n </Grid.RowDefinitions>\n\n <Ellipse x:Name=\"E00\" Grid.Row=\"4\" Grid.Column=\"0\" Grid.RowSpan=\"3\" Grid.ColumnSpan=\"3\" Width=\"Auto\" Height=\"Auto\" Opacity=\"0\"/>\n <Ellipse x:Name=\"E01\" Grid.Row=\"1\" Grid.Column=\"1\" Grid.RowSpan=\"3\" Grid.ColumnSpan=\"3\" Width=\"Auto\" Height=\"Auto\" Opacity=\"0\" />\n <Ellipse x:Name=\"E02\" Grid.Row=\"0\" Grid.Column=\"4\" Grid.RowSpan=\"3\" Grid.ColumnSpan=\"3\" Width=\"Auto\" Height=\"Auto\" Opacity=\"0\" />\n <Ellipse x:Name=\"E03\" Grid.Row=\"1\" Grid.Column=\"7\" Grid.RowSpan=\"3\" Grid.ColumnSpan=\"3\" Width=\"Auto\" Height=\"Auto\" Opacity=\"0\" />\n <Ellipse x:Name=\"E04\" Grid.Row=\"4\" Grid.Column=\"8\" Grid.RowSpan=\"3\" Grid.ColumnSpan=\"3\" Width=\"Auto\" Height=\"Auto\" Opacity=\"0\" />\n <Ellipse x:Name=\"E05\" Grid.Row=\"7\" Grid.Column=\"7\" Grid.RowSpan=\"3\" Grid.ColumnSpan=\"3\" Width=\"Auto\" Height=\"Auto\" Opacity=\"0\" />\n <Ellipse x:Name=\"E06\" Grid.Row=\"8\" Grid.Column=\"4\" Grid.RowSpan=\"3\" Grid.ColumnSpan=\"3\" Width=\"Auto\" Height=\"Auto\" Opacity=\"0\" />\n <Ellipse x:Name=\"E07\" Grid.Row=\"7\" Grid.Column=\"1\" Grid.RowSpan=\"3\" Grid.ColumnSpan=\"3\" Width=\"Auto\" Height=\"Auto\" Opacity=\"0\" />\n </Grid>\n</UserControl>\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94171",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/352728/"
] |
94,177
|
<p>I have the following XAML: </p>
<pre><code><TextBlock Text="{Binding ElementName=EditListBox, Path=SelectedItems.Count}" Margin="0,0,5,0"/>
<TextBlock Text="items selected">
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=EditListBox, Path=SelectedItems.Count}" Value="1">
<Setter Property="TextBlock.Text" Value="item selected"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</code></pre>
<p>The first text block happily changes with SelectedItems.Count, showing 0,1,2, etc. The datatrigger on the second block never seems to fire to change the text.</p>
<p>Any thoughts?</p>
|
[
{
"answer_id": 94690,
"author": "Alan Le",
"author_id": 1133,
"author_profile": "https://Stackoverflow.com/users/1133",
"pm_score": 5,
"selected": true,
"text": "public class CountToSelectedTextConverter : IValueConverter\n{\n #region IValueConverter Members\n\n public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)\n {\n if ((int)value == 1)\n return \"item selected\";\n else\n return \"items selected\";\n }\n\n public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)\n {\n throw new NotImplementedException();\n }\n\n #endregion\n}\n"
},
{
"answer_id": 105592,
"author": "Robert Macnee",
"author_id": 19273,
"author_profile": "https://Stackoverflow.com/users/19273",
"pm_score": 5,
"selected": false,
"text": "<TextBlock Margin=\"0,0,5,0\" Text=\"{Binding ElementName=EditListBox, Path=SelectedItems.Count}\"/>\n<TextBlock>\n <TextBlock.Style>\n <Style TargetType=\"{x:Type TextBlock}\">\n <Setter Property=\"Text\" Value=\"items selected\"/>\n <Style.Triggers>\n <DataTrigger Binding=\"{Binding ElementName=EditListBox, Path=SelectedItems.Count}\" Value=\"1\">\n <Setter Property=\"Text\" Value=\"item selected\"/>\n </DataTrigger>\n </Style.Triggers>\n </Style>\n </TextBlock.Style>\n</TextBlock>\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94177",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2284/"
] |
94,204
|
<p>What is the best way to have synchronized a collection of objects between various threads in .Net?</p>
<p>I need to have a List or Dictionary accessed from different threads in a thread safe mode. With Adds, Removes, Foreachs, etc.</p>
|
[
{
"answer_id": 94276,
"author": "Thomee",
"author_id": 12825,
"author_profile": "https://Stackoverflow.com/users/12825",
"pm_score": 0,
"selected": false,
"text": "\n Collections::Queue ^unsafe_queue = gcnew Collections::Queue();\n Collections::Queue ^safe_queue = Collections::Queue::Synchronized(unsafe_queue);\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16613/"
] |
94,226
|
<p>I have 4 versions of file A.txt in my subversion repository, say: A.txt.r1, A.txt.r2, A.txt.r3 and A.txt.r4. My working copy of the file is r4 and I want to switch back to r2. I don't want to use "<em>svn update -r 2 A.txt</em>" because this will delete all the revisions after r2, namely r3 and r4. </p>
<p>So is there any way that I update my working copy to r2 and still having the option to switch to r3 and r4 later? Put it another way, I want to still be able to see all 4 revisions by using "<em>svn log A.txt</em>" after doing the update.</p>
|
[
{
"answer_id": 94258,
"author": "kch",
"author_id": 13989,
"author_profile": "https://Stackoverflow.com/users/13989",
"pm_score": 2,
"selected": false,
"text": "svn up -r2 file"
},
{
"answer_id": 94351,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 3,
"selected": false,
"text": "svn up -r 4"
},
{
"answer_id": 94392,
"author": "Bruno De Fraine",
"author_id": 6918,
"author_profile": "https://Stackoverflow.com/users/6918",
"pm_score": 5,
"selected": false,
"text": "svn up -r HEAD\nsvn merge -r HEAD:2 A.txt\nsvn commit\n"
},
{
"answer_id": 94442,
"author": "jgindin",
"author_id": 17941,
"author_profile": "https://Stackoverflow.com/users/17941",
"pm_score": 2,
"selected": false,
"text": "svn update -r 2 A.txt\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8203/"
] |
94,227
|
<p>C++ is all about memory ownership - aka <strong>ownership semantics</strong>.</p>
<p>It is the responsibility of the owner of a chunk of dynamically allocated memory to release that memory. So the question really becomes who owns the memory.</p>
<p>In C++ ownership is documented by the type a <em>raw</em> pointer is wrapped inside thus in a good (IMO) C++ program it is very rare (<em>rare</em>, not <em>never</em>) to see raw pointers passed around (as raw pointers have no inferred ownership thus we can not tell who owns the memory and thus without careful reading of the documentation you can't tell who is responsible for ownership).</p>
<p>Conversely, it is rare to see raw pointers stored in a class each raw pointer is stored within its own smart pointer wrapper. (<strong>N.B.:</strong> If you don't own an object you should not be storing it because you can not know when it will go out of scope and be destroyed.)</p>
<p>So the question:</p>
<ul>
<li>What type of ownership semantic have people come across?</li>
<li>What standard classes are used to implement those semantics?</li>
<li>In what situations do you find them useful?</li>
</ul>
<p>Lets keep 1 type of semantic ownership per answer so they can be voted up and down individually.</p>
<h2>Summary:</h2>
<p>Conceptually, smart pointers are simple and a naive implementation is easy. I have seen many attempted implementations, but invariably they are broken in some way that is not obvious to casual use and examples. Thus I recommend always using well tested smart pointers from a library rather than rolling your own. <code>std::auto_ptr</code> or one of the Boost smart pointers seem to cover all my needs.</p>
<h3><code>std::auto_ptr<T></code>:</h3>
<p>Single person owns the object. Transfer of ownership is allowed.</p>
<p>Usage: This allows you to define interfaces that show the explicit transfer of ownership.</p>
<h3><code>boost::scoped_ptr<T></code></h3>
<p>Single person owns the object. Transfer of ownership is NOT allowed.</p>
<p>Usage: Used to show explicit ownership. Object will be destroyed by destructor or when explicitly reset.</p>
<h3><code>boost::shared_ptr<T></code> (<code>std::tr1::shared_ptr<T></code>)</h3>
<p>Multiple ownership. This is a simple reference counted pointer. When the reference count reaches zero, the object is destroyed.</p>
<p>Usage: When an object can have multiple owers with a lifetime that can not be determined at compile time.</p>
<h3><code>boost::weak_ptr<T></code>:</h3>
<p>Used with <code>shared_ptr<T></code> in situations where a cycle of pointers may happen.</p>
<p>Usage: Used to stop cycles from retaining objects when only the cycle is maintaining a shared refcount.</p>
|
[
{
"answer_id": 94262,
"author": "Matt Cruikshank",
"author_id": 8643,
"author_profile": "https://Stackoverflow.com/users/8643",
"pm_score": 2,
"selected": false,
"text": "std::tr1::shared_ptr<Blah>"
},
{
"answer_id": 94512,
"author": "Fabio Ceconello",
"author_id": 8999,
"author_profile": "https://Stackoverflow.com/users/8999",
"pm_score": 5,
"selected": true,
"text": "shared_ptr"
},
{
"answer_id": 384127,
"author": "Hernán",
"author_id": 48026,
"author_profile": "https://Stackoverflow.com/users/48026",
"pm_score": 1,
"selected": false,
"text": "* small (contained in single header)\n* simple (nothing fancy in the code, easy to understand)\n* maximum compatibility (drop in replacement for dumb pointers)\n"
},
{
"answer_id": 384398,
"author": "Daniel Earwicker",
"author_id": 27423,
"author_profile": "https://Stackoverflow.com/users/27423",
"pm_score": 1,
"selected": false,
"text": "auto_ptr"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14065/"
] |
94,241
|
<p>in "CSS: The missing manual" the author says that font-size: medium (or other size keywords) sets the font relative to the <em>browser's</em> base font size.</p>
<p>But what I'm seeing in FF2 and IE6 is that it sets the font size to what I specified in the .CSS HTML or BODY style (which is much preferred).</p>
<p>If it works the latter way, this is very handy if you have nested styles and you know you want some text to be the body font-size (i.e., "normal sized text").</p>
|
[
{
"answer_id": 94330,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "body {\n font: normal 100% \"Arial\",\"Helvetica\",sans-serif;\n}\np, li, td {\n font-size: .85em;\n}\nli p, td p {\n font-size: 1em;\n}\n"
},
{
"answer_id": 38996809,
"author": "Aides",
"author_id": 4068027,
"author_profile": "https://Stackoverflow.com/users/4068027",
"pm_score": 1,
"selected": false,
"text": "medium"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4906/"
] |
94,274
|
<p>This has been a problem that I haven't been able to figure out for sometime. Preventing the second instance is trivial and has many methods, however, bringing back the already running process isn't. I would like to:</p>
<ul>
<li>Minimized: Undo the minimize and bring the running instance to the front.</li>
<li>Behind other windows: Bring the application to the front.</li>
</ul>
<p>The language I am using this in is VB.NET and C#.</p>
|
[
{
"answer_id": 64445715,
"author": "user4565320",
"author_id": 4565320,
"author_profile": "https://Stackoverflow.com/users/4565320",
"pm_score": 1,
"selected": false,
"text": " If App.PrevInstance = True Then\n MsgBox \"Already running....\"\n Unload Me\n Exit Sub\n End If\n"
},
{
"answer_id": 71707681,
"author": "Jason Geiger",
"author_id": 517690,
"author_profile": "https://Stackoverflow.com/users/517690",
"pm_score": 0,
"selected": false,
"text": "public static void StopProgramOnSecondRun()\n{\n string\n //Get the full filename and path\n FullEXEPath = System.Reflection.Assembly.GetEntryAssembly().Location,\n //Isolate just the filename with no extension\n FilenameWithNoExtension = System.IO.Path.GetFileNameWithoutExtension(FullEXEPath);\n\n //Retrieve a list of processes that have the same name as this one wich is FilenameWithNoExtension\n Process[] processes = System.Diagnostics.Process.GetProcessesByName(FilenameWithNoExtension);\n\n //There should always be at least one process returned. If the number is greater than one. Than this is the clone and we must kill it.\n if (processes.Length > 1)\n System.Diagnostics.Process.GetCurrentProcess().Kill();\n}\n"
},
{
"answer_id": 73957796,
"author": "sixin",
"author_id": 1592795,
"author_profile": "https://Stackoverflow.com/users/1592795",
"pm_score": 0,
"selected": false,
"text": "if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)\n {\n File.Create(\"AlreadyRunning.log\").Dispose();\n return;\n }\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8505/"
] |
94,305
|
<p>Lets say I have the option of identifying a code path to take on the basis of a string comparison or else iffing the type:</p>
<p>Which is quicker and why?</p>
<pre><code>switch(childNode.Name)
{
case "Bob":
break;
case "Jill":
break;
case "Marko":
break;
}
if(childNode is Bob)
{
}
elseif(childNode is Jill)
{
}
else if(childNode is Marko)
{
}
</code></pre>
<p><strong>Update:</strong> The main reason I ask this is because the switch statement is perculiar about what counts as a case. For example it wont allow you to use variables, only constants which get moved to the main assembly. I assumed it had this restriction due to some funky stuff it was doing. If it is only translating to elseifs (as one poster commented) then why are we not allowed variables in case statements?</p>
<p><strong>Caveat:</strong> I am post-optimising. This method is called <em>many</em> times in a slow part of the app.</p>
|
[
{
"answer_id": 94408,
"author": "Aeon",
"author_id": 13289,
"author_profile": "https://Stackoverflow.com/users/13289",
"pm_score": -1,
"selected": false,
"text": "switch(childNode.Type)\n{\ncase Bob:\n break;\ncase Jill:\n break;\ncase Marko:\n break;\n}\n"
},
{
"answer_id": 94615,
"author": "SaguiItay",
"author_id": 6980,
"author_profile": "https://Stackoverflow.com/users/6980",
"pm_score": 2,
"selected": false,
"text": "switch(childNode.Name)\n{\n case \"Bob\":\n break;\n case \"Jill\":\n break;\n case \"Marko\":\n break;\n}\n\nif(childNode.Name == \"Bob\")\n{}\nelse if(childNode.Name == \"Jill\")\n{}\nelse if(childNode.Name == \"Marko\")\n{}\n"
},
{
"answer_id": 94710,
"author": "Ted Elliott",
"author_id": 16501,
"author_profile": "https://Stackoverflow.com/users/16501",
"pm_score": 2,
"selected": false,
"text": "Dictionary<Type, HandlerDelegate> handlers = new Dictionary<Type, HandlerDelegate>();\nhandlers[typeof(Bob)] = this.HandleBob;\nhandlers[typeof(Jill)] = this.HandleJill;\nhandlers[typeof(Marko)] = this.HandleMarko;\n\nhandlers[childNode.GetType()](childNode);\n/// ...\n\nprivate void HandleBob(Node childNode) {\n // code to handle Bob\n}\n"
},
{
"answer_id": 95012,
"author": "Greg",
"author_id": 12601,
"author_profile": "https://Stackoverflow.com/users/12601",
"pm_score": 4,
"selected": false,
"text": "class Program\n{\n static void Main( string[] args )\n {\n Bob bob = new Bob();\n Jill jill = new Jill();\n Marko marko = new Marko();\n\n for( int i = 0; i < 1000000; i++ )\n {\n Test( bob );\n Test( jill );\n Test( marko );\n }\n }\n\n public static void Test( ChildNode childNode )\n { \n TestSwitch( childNode );\n TestIfElse( childNode );\n }\n\n private static void TestIfElse( ChildNode childNode )\n {\n if( childNode is Bob ){}\n else if( childNode is Jill ){}\n else if( childNode is Marko ){}\n }\n\n private static void TestSwitch( ChildNode childNode )\n {\n switch( childNode.Name )\n {\n case \"Bob\":\n break;\n case \"Jill\":\n break;\n case \"Marko\":\n break;\n }\n }\n}\n\nclass ChildNode { public string Name { get; set; } }\n\nclass Bob : ChildNode { public Bob(){ this.Name = \"Bob\"; }}\n\nclass Jill : ChildNode{public Jill(){this.Name = \"Jill\";}}\n\nclass Marko : ChildNode{public Marko(){this.Name = \"Marko\";}}\n"
},
{
"answer_id": 95118,
"author": "ilitirit",
"author_id": 9825,
"author_profile": "https://Stackoverflow.com/users/9825",
"pm_score": 4,
"selected": false,
"text": "class Node\n{\n public virtual void Action()\n {\n // Perform default action\n }\n}\n\nclass Bob : Node\n{\n public override void Action()\n {\n // Perform action for Bill\n }\n}\n\nclass Jill : Node\n{\n public override void Action()\n {\n // Perform action for Jill\n }\n}\n"
},
{
"answer_id": 126507,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 8,
"selected": true,
"text": "int value = 25124;\nif(value == 0) ...\nelse if (value == 1) ...\nelse if (value == 2) ...\n...\nelse if (value == 25124) ... \n"
},
{
"answer_id": 14132144,
"author": "nawfal",
"author_id": 661933,
"author_profile": "https://Stackoverflow.com/users/661933",
"pm_score": 2,
"selected": false,
"text": "interface INode\n{\n void Action;\n}\n\nclass Bob : INode\n{\n public void Action\n {\n\n }\n}\n\nclass Jill : INode\n{\n public void Action\n {\n\n }\n}\n\nclass Marko : INode\n{\n public void Action\n {\n\n }\n}\n\n//Your function:\nvoid Do(INode childNode)\n{\n childNode.Action();\n}\n"
},
{
"answer_id": 48439960,
"author": "Walter Verhoeven",
"author_id": 8000382,
"author_profile": "https://Stackoverflow.com/users/8000382",
"pm_score": 0,
"selected": false,
"text": "//somewhere in your code\nstatic long _bob = \"Bob\".GetUniqueHashCode();\nstatic long _jill = \"Jill\".GetUniqueHashCode();\nstatic long _marko = \"Marko\".GeUniquetHashCode();\n\nvoid MyMethod()\n{\n ...\n if(childNode.Tag==0)\n childNode.Tag= childNode.Name.GetUniquetHashCode()\n\n switch(childNode.Tag)\n {\n case _bob :\n break;\n case _jill :\n break;\n case _marko :\n break;\n }\n}\n"
},
{
"answer_id": 48475161,
"author": "Walter Verhoeven",
"author_id": 8000382,
"author_profile": "https://Stackoverflow.com/users/8000382",
"pm_score": 2,
"selected": false,
"text": " public static class StringExtention\n {\n public static long ToUniqueHash(this string text)\n {\n long value = 0;\n var array = text.ToCharArray();\n unchecked\n {\n for (int i = 0; i < array.Length; i++)\n {\n value = (value * 397) ^ array[i].GetHashCode();\n value = (value * 397) ^ i;\n }\n return value;\n }\n }\n }\n\n public class AccountTypes\n {\n\n static void Main()\n {\n var sb = new StringBuilder();\n\n sb.AppendLine($\"const long ACCOUNT_TYPE = {\"AccountType\".ToUniqueHash()};\");\n sb.AppendLine($\"const long NET_LIQUIDATION = {\"NetLiquidation\".ToUniqueHash()};\");\n sb.AppendLine($\"const long TOTAL_CASH_VALUE = {\"TotalCashValue\".ToUniqueHash()};\");\n sb.AppendLine($\"const long SETTLED_CASH = {\"SettledCash\".ToUniqueHash()};\");\n sb.AppendLine($\"const long ACCRUED_CASH = {\"AccruedCash\".ToUniqueHash()};\");\n sb.AppendLine($\"const long BUYING_POWER = {\"BuyingPower\".ToUniqueHash()};\");\n sb.AppendLine($\"const long EQUITY_WITH_LOAN_VALUE = {\"EquityWithLoanValue\".ToUniqueHash()};\");\n sb.AppendLine($\"const long PREVIOUS_EQUITY_WITH_LOAN_VALUE = {\"PreviousEquityWithLoanValue\".ToUniqueHash()};\");\n sb.AppendLine($\"const long GROSS_POSITION_VALUE ={ \"GrossPositionValue\".ToUniqueHash()};\");\n sb.AppendLine($\"const long REQT_EQUITY = {\"ReqTEquity\".ToUniqueHash()};\");\n sb.AppendLine($\"const long REQT_MARGIN = {\"ReqTMargin\".ToUniqueHash()};\");\n sb.AppendLine($\"const long SPECIAL_MEMORANDUM_ACCOUNT = {\"SMA\".ToUniqueHash()};\");\n sb.AppendLine($\"const long INIT_MARGIN_REQ = { \"InitMarginReq\".ToUniqueHash()};\");\n sb.AppendLine($\"const long MAINT_MARGIN_REQ = {\"MaintMarginReq\".ToUniqueHash()};\");\n sb.AppendLine($\"const long AVAILABLE_FUNDS = {\"AvailableFunds\".ToUniqueHash()};\");\n sb.AppendLine($\"const long EXCESS_LIQUIDITY = {\"ExcessLiquidity\".ToUniqueHash()};\");\n sb.AppendLine($\"const long CUSHION = {\"Cushion\".ToUniqueHash()};\");\n sb.AppendLine($\"const long FULL_INIT_MARGIN_REQ = {\"FullInitMarginReq\".ToUniqueHash()};\");\n sb.AppendLine($\"const long FULL_MAINTMARGIN_REQ ={ \"FullMaintMarginReq\".ToUniqueHash()};\");\n sb.AppendLine($\"const long FULL_AVAILABLE_FUNDS = {\"FullAvailableFunds\".ToUniqueHash()};\");\n sb.AppendLine($\"const long FULL_EXCESS_LIQUIDITY ={ \"FullExcessLiquidity\".ToUniqueHash()};\");\n sb.AppendLine($\"const long LOOK_AHEAD_INIT_MARGIN_REQ = {\"LookAheadInitMarginReq\".ToUniqueHash()};\");\n sb.AppendLine($\"const long LOOK_AHEAD_MAINT_MARGIN_REQ = {\"LookAheadMaintMarginReq\".ToUniqueHash()};\");\n sb.AppendLine($\"const long LOOK_AHEAD_AVAILABLE_FUNDS = {\"LookAheadAvailableFunds\".ToUniqueHash()};\");\n sb.AppendLine($\"const long LOOK_AHEAD_EXCESS_LIQUIDITY = {\"LookAheadExcessLiquidity\".ToUniqueHash()};\");\n sb.AppendLine($\"const long HIGHEST_SEVERITY = {\"HighestSeverity\".ToUniqueHash()};\");\n sb.AppendLine($\"const long DAY_TRADES_REMAINING = {\"DayTradesRemaining\".ToUniqueHash()};\");\n sb.AppendLine($\"const long LEVERAGE = {\"Leverage\".ToUniqueHash()};\");\n Console.WriteLine(sb.ToString());\n\n Test(); \n } \n\n public static void Test()\n {\n //generated constant values\n const long ACCOUNT_TYPE = -3012481629590703298;\n const long NET_LIQUIDATION = 5886477638280951639;\n const long TOTAL_CASH_VALUE = 2715174589598334721;\n const long SETTLED_CASH = 9013818865418133625;\n const long ACCRUED_CASH = -1095823472425902515;\n const long BUYING_POWER = -4447052054809609098;\n const long EQUITY_WITH_LOAN_VALUE = -4088154623329785565;\n const long PREVIOUS_EQUITY_WITH_LOAN_VALUE = 6224054330592996694;\n const long GROSS_POSITION_VALUE = -7316842993788269735;\n const long REQT_EQUITY = -7457439202928979430;\n const long REQT_MARGIN = -7525806483981945115;\n const long SPECIAL_MEMORANDUM_ACCOUNT = -1696406879233404584;\n const long INIT_MARGIN_REQ = 4495254338330797326;\n const long MAINT_MARGIN_REQ = 3923858659879350034;\n const long AVAILABLE_FUNDS = 2736927433442081110;\n const long EXCESS_LIQUIDITY = 5975045739561521360;\n const long CUSHION = 5079153439662500166;\n const long FULL_INIT_MARGIN_REQ = -6446443340724968443;\n const long FULL_MAINTMARGIN_REQ = -8084126626285123011;\n const long FULL_AVAILABLE_FUNDS = 1594040062751632873;\n const long FULL_EXCESS_LIQUIDITY = -2360941491690082189;\n const long LOOK_AHEAD_INIT_MARGIN_REQ = 5230305572167766821;\n const long LOOK_AHEAD_MAINT_MARGIN_REQ = 4895875570930256738;\n const long LOOK_AHEAD_AVAILABLE_FUNDS = -7687608210548571554;\n const long LOOK_AHEAD_EXCESS_LIQUIDITY = -4299898188451362207;\n const long HIGHEST_SEVERITY = 5831097798646393988;\n const long DAY_TRADES_REMAINING = 3899479916235857560;\n const long LEVERAGE = 1018053116254258495;\n\n bool found = false;\n var sValues = new string[] {\n \"AccountType\"\n ,\"NetLiquidation\"\n ,\"TotalCashValue\"\n ,\"SettledCash\"\n ,\"AccruedCash\"\n ,\"BuyingPower\"\n ,\"EquityWithLoanValue\"\n ,\"PreviousEquityWithLoanValue\"\n ,\"GrossPositionValue\"\n ,\"ReqTEquity\"\n ,\"ReqTMargin\"\n ,\"SMA\"\n ,\"InitMarginReq\"\n ,\"MaintMarginReq\"\n ,\"AvailableFunds\"\n ,\"ExcessLiquidity\"\n ,\"Cushion\"\n ,\"FullInitMarginReq\"\n ,\"FullMaintMarginReq\"\n ,\"FullAvailableFunds\"\n ,\"FullExcessLiquidity\"\n ,\"LookAheadInitMarginReq\"\n ,\"LookAheadMaintMarginReq\"\n ,\"LookAheadAvailableFunds\"\n ,\"LookAheadExcessLiquidity\"\n ,\"HighestSeverity\"\n ,\"DayTradesRemaining\"\n ,\"Leverage\"\n };\n\n long t1, t2;\n var sw = System.Diagnostics.Stopwatch.StartNew();\n foreach (var name in sValues)\n {\n switch (name)\n {\n case \"AccountType\": found = true; break;\n case \"NetLiquidation\": found = true; break;\n case \"TotalCashValue\": found = true; break;\n case \"SettledCash\": found = true; break;\n case \"AccruedCash\": found = true; break;\n case \"BuyingPower\": found = true; break;\n case \"EquityWithLoanValue\": found = true; break;\n case \"PreviousEquityWithLoanValue\": found = true; break;\n case \"GrossPositionValue\": found = true; break;\n case \"ReqTEquity\": found = true; break;\n case \"ReqTMargin\": found = true; break;\n case \"SMA\": found = true; break;\n case \"InitMarginReq\": found = true; break;\n case \"MaintMarginReq\": found = true; break;\n case \"AvailableFunds\": found = true; break;\n case \"ExcessLiquidity\": found = true; break;\n case \"Cushion\": found = true; break;\n case \"FullInitMarginReq\": found = true; break;\n case \"FullMaintMarginReq\": found = true; break;\n case \"FullAvailableFunds\": found = true; break;\n case \"FullExcessLiquidity\": found = true; break;\n case \"LookAheadInitMarginReq\": found = true; break;\n case \"LookAheadMaintMarginReq\": found = true; break;\n case \"LookAheadAvailableFunds\": found = true; break;\n case \"LookAheadExcessLiquidity\": found = true; break;\n case \"HighestSeverity\": found = true; break;\n case \"DayTradesRemaining\": found = true; break;\n case \"Leverage\": found = true; break;\n default: found = false; break;\n }\n\n if (!found)\n throw new NotImplementedException();\n }\n t1 = sw.ElapsedTicks;\n sw.Restart();\n foreach (var name in sValues)\n {\n switch (name.ToUniqueHash())\n {\n case ACCOUNT_TYPE:\n found = true;\n break;\n case NET_LIQUIDATION:\n found = true;\n break;\n case TOTAL_CASH_VALUE:\n found = true;\n break;\n case SETTLED_CASH:\n found = true;\n break;\n case ACCRUED_CASH:\n found = true;\n break;\n case BUYING_POWER:\n found = true;\n break;\n case EQUITY_WITH_LOAN_VALUE:\n found = true;\n break;\n case PREVIOUS_EQUITY_WITH_LOAN_VALUE:\n found = true;\n break;\n case GROSS_POSITION_VALUE:\n found = true;\n break;\n case REQT_EQUITY:\n found = true;\n break;\n case REQT_MARGIN:\n found = true;\n break;\n case SPECIAL_MEMORANDUM_ACCOUNT:\n found = true;\n break;\n case INIT_MARGIN_REQ:\n found = true;\n break;\n case MAINT_MARGIN_REQ:\n found = true;\n break;\n case AVAILABLE_FUNDS:\n found = true;\n break;\n case EXCESS_LIQUIDITY:\n found = true;\n break;\n case CUSHION:\n found = true;\n break;\n case FULL_INIT_MARGIN_REQ:\n found = true;\n break;\n case FULL_MAINTMARGIN_REQ:\n found = true;\n break;\n case FULL_AVAILABLE_FUNDS:\n found = true;\n break;\n case FULL_EXCESS_LIQUIDITY:\n found = true;\n break;\n case LOOK_AHEAD_INIT_MARGIN_REQ:\n found = true;\n break;\n case LOOK_AHEAD_MAINT_MARGIN_REQ:\n found = true;\n break;\n case LOOK_AHEAD_AVAILABLE_FUNDS:\n found = true;\n break;\n case LOOK_AHEAD_EXCESS_LIQUIDITY:\n found = true;\n break;\n case HIGHEST_SEVERITY:\n found = true;\n break;\n case DAY_TRADES_REMAINING:\n found = true;\n break;\n case LEVERAGE:\n found = true;\n break;\n default:\n found = false;\n break;\n }\n\n if (!found)\n throw new NotImplementedException();\n }\n t2 = sw.ElapsedTicks;\n sw.Stop();\n Console.WriteLine($\"String switch:{t1:N0} long switch:{t2:N0}\");\n var faster = (t1 > t2) ? \"Slower\" : \"faster\";\n Console.WriteLine($\"String switch: is {faster} than long switch: by {Math.Abs(t1-t2)} Ticks\");\n Console.ReadLine();\n\n }\n"
},
{
"answer_id": 48697861,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "switch"
},
{
"answer_id": 71854518,
"author": "user889030",
"author_id": 889030,
"author_profile": "https://Stackoverflow.com/users/889030",
"pm_score": 1,
"selected": false,
"text": "if / else if"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94305",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1143/"
] |
94,316
|
<p>I want to change the Text of the browse button in the FileUpload Control (System.Web.UI.WebControls), instead of the [Browse...] text I want to use [...]</p>
|
[
{
"answer_id": 10112832,
"author": "BonDini",
"author_id": 1200259,
"author_profile": "https://Stackoverflow.com/users/1200259",
"pm_score": 4,
"selected": false,
"text": "asp:FileUpload"
},
{
"answer_id": 26941653,
"author": "Dr. Aaron Dishno",
"author_id": 4219973,
"author_profile": "https://Stackoverflow.com/users/4219973",
"pm_score": 2,
"selected": false,
"text": "<asp:Button ID=\"bUploadPicture\" runat=\"server\" Text=\"Upload Picture\"\n OnClientClick=\"document.getElementById('<%=tFileUpload1.ClientID%>')\n .click();return (false);\" />\n\n<div style=\"display:none;visibility:hidden;\">\n <asp:AsyncFileUpload ID=\"tFileUpload1\" runat=\"server\" \n OnUploadedComplete=\"tFileUpload1_UploadedComplete\" />\n</div>\n"
}
] |
2008/09/18
|
[
"https://Stackoverflow.com/questions/94316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.