qid
int64 4
19.1M
| question
stringlengths 18
48.3k
| answers
list | date
stringlengths 10
10
| metadata
list |
|---|---|---|---|---|
178,751
|
<p>Here is the sample:</p>
<pre><code> Dim TestString As String = "Hello," & Chr(0) & "World"
MsgBox(TestString, , "TestString.Length=" & TestString.Length.ToString)
</code></pre>
<p>Result - Messagebox shows "Hello," with title says TestString.Length=12 </p>
<p>I guess the chr(0) is treated as the end of zero terminated string, but it's not what i want. </p>
<p>What the right method to operate with Chr(0) ?</p>
<hr>
<p>I've also tried this in asp.net with no avail. I'm sending the string over a socket. My problem is that when I'm debugging it the whole string doesn't add up. I need to send them a rather large string for it. What comes up really on the message window doesn't bother me. I used the above as an example. I just need when putting the multiple variables that it adds correctly to the string. Another example of it would be </p>
<pre><code>"SCORE".ToString.PadRight(8, chr(0)) & "3.0".ToString.PadRight(10, chr(0)) & "0".ToString.PadRight(1, "0")
</code></pre>
<p>the expected value would score3.00</p>
<p>What I get though is score3.0</p>
|
[
{
"answer_id": 178784,
"author": "Ryan",
"author_id": 17917,
"author_profile": "https://Stackoverflow.com/users/17917",
"pm_score": 1,
"selected": false,
"text": "TestString.Replace(chr(0), \" \")"
},
{
"answer_id": 67020757,
"author": "UnhandledException-InvalidChar",
"author_id": 11975130,
"author_profile": "https://Stackoverflow.com/users/11975130",
"pm_score": 0,
"selected": false,
"text": "<DllImport(\"my.dll\", ... )> _\nSub modifyStr(<MarshalAs(UnmanagedType.BStr)> ByRef stringContainingNullChars as String) \n\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12369/"
] |
178,762
|
<p>Sorry, I couldn't figure out a good way to phrase my real question.</p>
<p>I run a high-traffic ASP.NET site on a 64-bit machine. I have IIS running in 32-bit mode, however, due to some legacy components of the app. I am running this particular web app inside an application pool that has the web garden option on (running 6 processes inside an 8 core machine).</p>
<p>Once or twice a week one of the processes will skyrocket into 100% CPU utilization, causing a giant slowdown for the site, so my plan was to wait until that happens, memory dump the offending process, then poke around WinDbg to zero in on the thread that's spiking to see where the code is spinning its wheels.</p>
<p>I've debugged using WinDbg before to figure out what was causing a deadlock on the site, but that was several months ago and I can't remember how I got it working. (As a side note, this is a lesson to document everything you do.)</p>
<p>I'm running WinDbg on the Windows 2003 server that's running the site, so as to prevent any DLL version problems. Here have been my steps so far, please let me know where I'm going wrong to get the error message that I'm getting.</p>
<ol>
<li><p>I first memory dump the spiking process using UserDump, with the following command, where 3389 is the ID of the process:</p>
<p><code>userdump -k 3389</code></p></li>
<li><p>I load the dump into the x86 edition of WinDbg.</p></li>
<li><p>Since I'm running 32-bit on a 64-bit machine, I first load the memory dump and then:</p>
<p><code>.load wow64exts</code></p>
<p><code>.effmach x86</code></p></li>
<li><p>I make sure that my symbol path includes the directory that contains my apps PDB files:</p>
<p><code>.sympath+ c:\inetpub\myapp\bin</code></p></li>
<li><p>Running just `.load SOS' fails with an error of "The system cannot find the file specified", so I go the fully qualified route of the following, which works:</p>
<p><code>.load c:\windows\microsoft.net\framework\v2.0.50727\sos</code></p></li>
</ol>
<p>From here, I'm lost. I try any of the SOS commands, like <code>!threads</code>, only to get this error:</p>
<pre><code>Failed to load data access DLL, 0x80004005
</code></pre>
<p>That error is also accompanied by the numbered list of items that I should be verifying.
I have verified that I am running the most current version of the debugger, mscordacwks.dll is in fact in the same directory as the mscorwks.dll file, and I'm debugging on the same architecture as the dump file. </p>
<p>I've also run the magical "<code>.cordll -ve -u -l</code>" command, but that doesn't solve anything. I'm always greeted with "<code>CLR DLL status: No load attempts</code>" when I execute that. Then I try "<code>.reload</code>", which yields a handful of warnings like "<code>WARNING: wldap32 overlaps dnsapi</code>". I <em>wish</em> it said something like "<code>CLRDLL: Loaded DLL C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscordacwks.dll</code>". But it doesn't.</p>
|
[
{
"answer_id": 250065,
"author": "Pure.Krome",
"author_id": 30674,
"author_profile": "https://Stackoverflow.com/users/30674",
"pm_score": 1,
"selected": false,
"text": "0:027 !runaway\nUser Mode Time\nThread Time\n18:704 0 days 0:00:17.843 <-- Thread #18\n19:9f4 0 days 0:00:13.328 <-- Thread #19\n16:1948 0 days 0:00:10.718\n26:a7c 0 days 0:00:01.375\n24:114 0 days 0:00:01.093\n27:d54 0 days 0:00:00.390\n28:1b70 0 days 0:00:00.328\n0:b7c 0 days 0:00:00.171\n25:3f8 0 days 0:00:00.000\n23:1968 0 days 0:00:00.000\n"
},
{
"answer_id": 1236207,
"author": "Chris Ostler",
"author_id": 91472,
"author_profile": "https://Stackoverflow.com/users/91472",
"pm_score": 1,
"selected": false,
"text": "!sym noisy !dumpstack SYMSRV: http://msdl.microsoft.com/download/symbols/mscorwks.dll/492B82C1590000/mscorwks.dll not found .reload lm v m mscorwks"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22299/"
] |
178,809
|
<p>I am trying to fix some bugs in a product I inherited, and I have this snippet of javascript that is supposed to hilight a couple of boxes and pop up a confirm box. What currently happens is I see the boxes change color and there is a 5 or so second delay, then it's as if the missing confirm just accepts itself. Does anyone smarter than I see anything amiss in this code?</p>
<pre><code>function lastCheckInv() {
document.getElementById("ctl00$ContentPlaceHolderMain$INDet$txtInvNumber").style.background = "yellow";
document.getElementById("ctl00$ContentPlaceHolderMain$INDet$txtInvNumber").focus();
document.getElementById("ctl00_ContentPlaceHolderMain_INDet_AddCharges").style.background = "yellow";
document.getElementById("ctl00_ContentPlaceHolderMain_INDet_lblFreight").style.background = "yellow";
bRetVal = confirm("Are you sure the information associated with this invoice is correct?");
return bRetVal;
}
</code></pre>
|
[
{
"answer_id": 178825,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 1,
"selected": false,
"text": ".focus() .style.background .focus()"
},
{
"answer_id": 178832,
"author": "Gordon Bell",
"author_id": 16473,
"author_profile": "https://Stackoverflow.com/users/16473",
"pm_score": 3,
"selected": false,
"text": "document.getElementById(<%= txtInvNumber.ClientID %>).style.background = \"yellow\"\n"
},
{
"answer_id": 178981,
"author": "Soldarnal",
"author_id": 3420,
"author_profile": "https://Stackoverflow.com/users/3420",
"pm_score": 2,
"selected": false,
"text": "<script language=\"javascript\">\nfunction lastCheckInv() {\n\n document.getElementById(\"test1\").style.background = \"yellow\";\n document.getElementById(\"test1\").focus();\n document.getElementById(\"test2\").style.background = \"yellow\";\n document.getElementById(\"test3\").style.background = \"yellow\";\n bRetVal = confirm(\"Are you sure?\");\n\n return bRetVal;\n\n}\n</script>\n\n<form method=\"get\" onsubmit=\"return lastCheckInv();\">\n <input id=\"test1\" name=\"test1\" value=\"Hello\">\n <input id=\"test2\" name=\"test2\" value=\"Hi\">\n <input id=\"test3\" name=\"test3\" value=\"Bye\">\n <input type=\"submit\" name=\"Save\" value=\"Save\">\n</form>\n"
},
{
"answer_id": 179135,
"author": "David Basarab",
"author_id": 2469,
"author_profile": "https://Stackoverflow.com/users/2469",
"pm_score": 0,
"selected": false,
"text": "document.getElementById(\"ctl00_ContentPlaceHolderMain_INDet_lblFreight\").style.background = \"yellow\"; \n var obj = document.getElementById(\"ctl00_ContentPlaceHolderMain_INDet_lblFreight\");\n\nif(obj)\n{\n obj.style.background = \"yellow\";\n}\n"
},
{
"answer_id": 179359,
"author": "Odilon Redo",
"author_id": 21166,
"author_profile": "https://Stackoverflow.com/users/21166",
"pm_score": 0,
"selected": false,
"text": "function lastCheckInv() {\n\n var myObjs,bRetVal;\n\n myObjs=[\n \"ctl00_ContentPlaceHolderMain_INDet_AddCharges\",\n \"ctl00_ContentPlaceHolderMain_INDet_lblFreight\",\n \"ctl00$ContentPlaceHolderMain$INDet$txtInvNumber\"\n ];\n\n\n bRetVal = confirm(\"Are you sure the information associated with this invoice is correct?\");\n\n for (var i=0, j=myObjs.length, myElement; i<j; i++){\n\n myElement=document.getElementById(myObjs[i]);\n\n if (!myElement){\n // this element is missing\n continue;\n }\n\n else {\n\n // apply colour\n myElement.style.background = \"yellow\";\n\n // focus the last object in the array\n\n if (i == (j-1) ){\n myObj.focus();\n }\n\n\n }\n\n }\n\n\n return bRetVal;\n\n}\n"
},
{
"answer_id": 240641,
"author": "Georg",
"author_id": 30776,
"author_profile": "https://Stackoverflow.com/users/30776",
"pm_score": 0,
"selected": false,
"text": "function lastCheckInv()\n\n{ \n document.getElementById(\"ctl00_ContentPlaceHolderMain_INDet_txtInvNumber\").style.background = \"yellow\"; \n document.getElementById(\"ctl00_ContentPlaceHolderMain_INDet_txtInvNumber\").focus(); \n document.getElementById(\"ctl00_ContentPlaceHolderMain_INDet_AddCharges\").style.background = \"yellow\"; \n document.getElementById(\"ctl00_ContentPlaceHolderMain_INDet_lblFreight\").style.background = \"yellow\"; \n return confirm(\"Are you sure the information associated with this invoice is correct?\"); \n}\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13593/"
] |
178,821
|
<p>I have seen arguments for using explicit interfaces as a method of locking a classes usage to that interface. The argument seems to be that by forcing others to program to the interface you can ensure better decoupling of the classes and allow easier testing.</p>
<p>Example:</p>
<pre><code>public interface ICut
{
void Cut();
}
public class Knife : ICut
{
void ICut.Cut()
{
//Cut Something
}
}
</code></pre>
<p>And to use the Knife object:</p>
<pre><code>ICut obj = new Knife();
obj.Cut();
</code></pre>
<p>Would you recommend this method of interface implementation? Why or why not?</p>
<p>EDIT:
Also, given that I am using an explicit interface the following would NOT work.</p>
<pre><code>Knife obj = new Knife();
obj.Cut();
</code></pre>
|
[
{
"answer_id": 178830,
"author": "skaffman",
"author_id": 21234,
"author_profile": "https://Stackoverflow.com/users/21234",
"pm_score": 0,
"selected": false,
"text": "Cut() ICut"
},
{
"answer_id": 178843,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 2,
"selected": false,
"text": "public class Sword: ICut\n{ \n void ICut.Cut() \n { \n //Cut Something \n }\n}\n ICut obj = SharpImplementFactory();\n\nobj.Cut();\n"
},
{
"answer_id": 178996,
"author": "ilitirit",
"author_id": 9825,
"author_profile": "https://Stackoverflow.com/users/9825",
"pm_score": 2,
"selected": false,
"text": "public interface IWriter\n{\n void Write(string message);\n}\n\npublic interface IReader\n{\n string Read();\n}\n\npublic class MessageLog : IReader, IWriter\n{\n public string Read()\n {\n // Implementation\n\n return \"\";\n }\n\n void IWriter.Write(string message)\n {\n // Implementation\n }\n}\n\npublic class Foo\n{\n readonly MessageLog _messageLog;\n IWriter _messageWriter;\n\n public Foo()\n {\n _messageLog = new MessageLog();\n _messageWriter = _messageLog;\n }\n\n public IReader Messages\n {\n get { return _messageLog; }\n }\n}\n"
},
{
"answer_id": 987796,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "public class Knife : ICut\n{\n public void Slice()\n {\n // slice something\n }\n\n void ICut.Cut()\n {\n Slice();\n }\n}\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23855/"
] |
178,837
|
<p>I am looking for a regex that will find repeating letters. So any letter twice or more, for example:</p>
<pre><code>booooooot or abbott
</code></pre>
<p>I won't know the letter I am looking for ahead of time. </p>
<p>This is a question I was asked in interviews and then asked in interviews. Not so many people get it correct.</p>
|
[
{
"answer_id": 178851,
"author": "Jonathan Lonowski",
"author_id": 15031,
"author_profile": "https://Stackoverflow.com/users/15031",
"pm_score": 3,
"selected": false,
"text": "/(\\w)\\1+/g\n"
},
{
"answer_id": 178854,
"author": "Joseph Pecoraro",
"author_id": 792,
"author_profile": "https://Stackoverflow.com/users/792",
"pm_score": 0,
"selected": false,
"text": "(\\w)\\1+\n"
},
{
"answer_id": 178856,
"author": "hasseg",
"author_id": 4111,
"author_profile": "https://Stackoverflow.com/users/4111",
"pm_score": 3,
"selected": false,
"text": "(\\w)\\1+\n \\w [a-zA-Z_0-9] [a-zA-Z] [[:alpha:]]"
},
{
"answer_id": 178861,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 7,
"selected": true,
"text": "\\1 $1 my $str = \"Foooooobar\";\n\n$str =~ /(\\w)(\\1+)/;\n\nprint $1;\n# prints 'o'\nprint $1 . $2;\n# prints 'oooooo'\n"
},
{
"answer_id": 178879,
"author": "Keng",
"author_id": 730,
"author_profile": "https://Stackoverflow.com/users/730",
"pm_score": 4,
"selected": false,
"text": "([a-zA-Z])\\1+\n ([[:alpha:]])\\1+\n"
},
{
"answer_id": 179166,
"author": "dland",
"author_id": 18625,
"author_profile": "https://Stackoverflow.com/users/18625",
"pm_score": 2,
"selected": false,
"text": "/[^\\D3]/ #! /usr/local/bin/perl\n\nuse strict;\nuse warnings;\n\n# uncomment the following three lines:\n# use locale;\n# use POSIX;\n# setlocale(LC_CTYPE, 'fr_FR.ISO8859-1');\n\nwhile (<DATA>) {\n chomp;\n if (/([^\\W_0-9])\\1+/) {\n print \"$_: dup [$1]\\n\";\n }\n else {\n print \"$_: nope\\n\";\n }\n}\n\n__DATA__\n100\nfood\ncréé\na::b\n"
},
{
"answer_id": 179679,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "my $str = \"SSSannnkaaarsss\";\n\nprint $str =~ /(\\w)\\1+/g;\n"
},
{
"answer_id": 179959,
"author": "b w",
"author_id": 4126,
"author_profile": "https://Stackoverflow.com/users/4126",
"pm_score": 1,
"selected": false,
"text": "([[:alpha:]])(\\1+)"
},
{
"answer_id": 181288,
"author": "ysth",
"author_id": 17389,
"author_profile": "https://Stackoverflow.com/users/17389",
"pm_score": 2,
"selected": false,
"text": "if ( ($str ^ substr($str,1) ) =~ /\\0+/ ) {\n print \"found \", substr($str, $-[0], $+[0]-$-[0]+1), \" at offset \", $-[0];\n}\n"
},
{
"answer_id": 6989255,
"author": "karakays",
"author_id": 877668,
"author_profile": "https://Stackoverflow.com/users/877668",
"pm_score": 0,
"selected": false,
"text": "((\\w)(?=\\2))+\\2"
},
{
"answer_id": 10728308,
"author": "Abdullah",
"author_id": 605399,
"author_profile": "https://Stackoverflow.com/users/605399",
"pm_score": 0,
"selected": false,
"text": "/(.)\\\\1{2,}+/u\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3208/"
] |
178,838
|
<p>Structs seem like a useful way to parse a binary blob of data (ie a file or network packet). This is fine and dandy until you have variable size arrays in the blob. For instance:</p>
<pre><code>struct nodeheader{
int flags;
int data_size;
char data[];
};
</code></pre>
<p>This allows me to find the last data character:</p>
<pre><code>nodeheader b;
cout << b.data[b.data_size-1];
</code></pre>
<p>Problem being, I want to have multiple variable length arrays:</p>
<pre><code>struct nodeheader{
int friend_size;
int data_size;
char data[];
char friend[];
};
</code></pre>
<p>I'm not manually allocating these structures. I have a file like so:</p>
<pre><code>char file_data[1024];
nodeheader* node = &(file_data[10]);
</code></pre>
<p>As I'm trying to parse a binary file (more specifically a class file). I've written an implementation in Java (which was my class assignment), no I'm doing a personal version in C++ and was hoping to get away without having to write 100 lines of code. Any ideas?</p>
<p>Thanks,
Stefan</p>
|
[
{
"answer_id": 178896,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 2,
"selected": false,
"text": "nodeheader *nh = (nodeheader *)malloc(sizeof(nodeheader) + max_data_size);\n struct nodeheader\n{\n char *data;\n size_t data_size;\n char *friend;\n size_t friend_size;\n};\n\nnodeheader AllocNodeHeader(size_t data_size, size_t friend_size)\n{\n nodeheader nh;\n nh.data = (char *)malloc(data_size); // check for NULL return\n nh.data_size = data_size;\n nh.friend = (char *)malloc(friend_size); // check for NULL return\n nh.friend_size = friend_size;\n\n return nh;\n}\n\nvoid FreeNodeHeader(nodeheader *nh)\n{\n free(nh->data);\n nh->data = NULL;\n free(nh->friend);\n nh->friend = NULL;\n}\n"
},
{
"answer_id": 178917,
"author": "fizzer",
"author_id": 18167,
"author_profile": "https://Stackoverflow.com/users/18167",
"pm_score": -1,
"selected": false,
"text": "struct nodeheader {\n std::vector<unsigned char> data;\n std::vector<unsigned char> friend_buf; // 'friend' is a keyword!\n // etc...\n};\n\nnodeheader file_data;\n char file_data[1024];\nnodeheader* node = &(file_data[10]);\n struct biggestnodeheader {\n int flags;\n int data_size;\n char data[ENOUGH_SPACE_FOR_LARGEST_HEADER_I_EVER_NEED];\n};\n\nbiggestnodeheader file_data;\n// etc...\n"
},
{
"answer_id": 186263,
"author": "Jim Buck",
"author_id": 2666,
"author_profile": "https://Stackoverflow.com/users/2666",
"pm_score": 1,
"selected": false,
"text": "struct nodeheader\n{\n int friend_size;\n int data_size;\n};\n\nstruct nodefile\n{\n nodeheader *header;\n char *data;\n char *friend;\n};\n\nchar file_data[1024];\n\n// .. file in file_data ..\n\nnodefile file;\nfile.header = (nodeheader *)&file_data[0];\nfile.data = (char *)&file.header[1];\nfile.friend = &file.data[file->header.data_size];\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13257/"
] |
178,845
|
<p>Is there some simple way to calculate a Weeknumber value from a date value stored in XML?</p>
<p>It needs to be pure XSLT solution. I cannot use any code :(</p>
|
[
{
"answer_id": 178885,
"author": "Mark",
"author_id": 5904,
"author_profile": "https://Stackoverflow.com/users/5904",
"pm_score": -1,
"selected": false,
"text": "Dim SomeDate As Date = ReadDateFromXML()\nDim YearStart As New Date(Year(SomeDate), 1, 1)\nDim WeekNumber As Integer = DateDiff(DateInterval.WeekOfYear, YearStart, SomeDate)\n"
},
{
"answer_id": 178932,
"author": "Todd",
"author_id": 2572,
"author_profile": "https://Stackoverflow.com/users/2572",
"pm_score": -1,
"selected": false,
"text": "DateTime date = DateTime.Now;\nint week = date.DayOfYear / 7;\nConsole.WriteLine(week);\n"
},
{
"answer_id": 183084,
"author": "NotMe",
"author_id": 2424,
"author_profile": "https://Stackoverflow.com/users/2424",
"pm_score": 0,
"selected": false,
"text": "<xsl:function name=\"chkbk:calculate-week-number\" as=\"xs:integer\">\n <xsl:param name=\"date\" as=\"xs:date\" />\n <xsl:sequence select=\"xs:integer(format-date($date,'[W]'))\" />\n</xsl:function>\n"
},
{
"answer_id": 294089,
"author": "Dimitre Novatchev",
"author_id": 36305,
"author_profile": "https://Stackoverflow.com/users/36305",
"pm_score": 1,
"selected": false,
"text": "datetime_lib.xsl datetime_lib.xsl"
},
{
"answer_id": 73047717,
"author": "P. Rabotas",
"author_id": 7096387,
"author_profile": "https://Stackoverflow.com/users/7096387",
"pm_score": -1,
"selected": false,
"text": "Public Function WeekNum_ISO8601(ByVal d As Date) As Integer ' WW e.g. 29\n Dim WN As Integer\n Dim YN As Integer = d.Year\n Dim TempDate As Date\n Dim FirstThursday As Date\n Dim MondayOfFirstWeekOfTheYear As Date\n Dim SundayOfFirstWeekOfTheYear As Date\n '\n TempDate = DateAndTime.DateSerial(YN, 1, 0)\n '\n Do\n TempDate = DateAndTime.DateSerial(YN, 1, TempDate.Day + 1)\n Loop Until TempDate.DayOfWeek = DayOfWeek.Thursday\n FirstThursday = TempDate\n '\n SundayOfFirstWeekOfTheYear = DateAndTime.DateSerial(YN, 1, FirstThursday.Day + 3)\n MondayOfFirstWeekOfTheYear = DateAndTime.DateSerial(YN, 1, FirstThursday.Day - 3)\n '\n If d < MondayOfFirstWeekOfTheYear Then\n TempDate = DateAndTime.DateSerial(YN - 1, 12, 31)\n WN = WeekNum_ISO8601(TempDate)\n End If\n '\n If d >= MondayOfFirstWeekOfTheYear And d <= SundayOfFirstWeekOfTheYear Then\n WN = 1\n End If\n '\n If d > SundayOfFirstWeekOfTheYear Then\n WN = CInt((d.DayOfYear - TempDate.Day) / 7) + 1\n End If\n '\n Return WN\nEnd Function\nPublic Function YearWeek(ByVal d As Date) As String ' YYYY-WW, e.g. 2022-29\n Dim tmpDate As Date\n tmpDate = d\n\n If (d.Month = 1) And (d.Day < DayOfWeek.Thursday) And d.Day < 7 Then\n tmpDate = DateAndTime.DateSerial(d.Year - 1, 12, 31)\n Return tmpDate.Year.ToString & \"-\" & Format(WeekNum_ISO8601(tmpDate), \"00\")\n Else\n Return (d.Year.ToString & \"-\" & Format(WeekNum_ISO8601(d), \"00\"))\n End If\n\nEnd Function\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15626/"
] |
178,846
|
<p>I installed the ReSharper evaluation version and uninstalled it. Afterwards Visual Studio's Intellisense stopped working. I have restarted computer but I still have this problem. </p>
<p>Can anyone please help me here?</p>
<p>I am using Visual Studio 2005. Thanks.</p>
|
[
{
"answer_id": 178893,
"author": "Gordon Bell",
"author_id": 16473,
"author_profile": "https://Stackoverflow.com/users/16473",
"pm_score": 6,
"selected": true,
"text": "devenv.exe /ResetSettings\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20933/"
] |
178,857
|
<p>Is it possible to get the text of an <code>OleDbCommand</code> with all parameters replaced with their values? E.g. in the code below I'm looking for a way to get the query text </p>
<pre><code>SELECT * FROM my_table WHERE c1 = 'hello' and c2 = 'world'
</code></pre>
<p>after I finished assigning the parameters.</p>
<pre><code>var query = "SELECT * FROM my_table WHERE c1 = ? and c2 = ?";
var cmd = new OleDbCommand(query, connection);
cmd.Parameters.Add("@p1", OleDbType.WChar).Value = "hello";
cmd.Parameters.Add("@p2", OleDbType.WChar).Value = "world";
</code></pre>
|
[
{
"answer_id": 178883,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 4,
"selected": true,
"text": "? @parametername .ComposeSQL()"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11387/"
] |
178,860
|
<p>I'm trying to use a Microsoft Access database for a demo project that I'm thinking of doing in either CodeIgniter or CakePHP. Ignoring the possible folly of using Microsoft Access, I haven't been able to figure out precisely how the connection string corresponds to the frameworks' database settings. In straight PHP, I can use this code to connect to an Access database:</p>
<pre><code>$db_connection = odbc_connect(
"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\\path\\to\\db.mdb",
"ADODB.Connection", "", "SQL_CUR_USE_ODBC"
);
</code></pre>
<p>How do those strings correspond to the Code Igniter db settings? This doesn't seem to be quite working:</p>
<pre><code>$db['access']['hostname'] = "{Microsoft Access Driver (*.mdb)}";
$db['access']['username'] = "ADODB.Connection";
$db['access']['password'] = "";
$db['access']['database'] = "\\path\\to\\db.mdb";
$db['access']['dbdriver'] = "odbc";
$db['access']['dbprefix'] = "";
$db['access']['pconnect'] = TRUE;
$db['access']['db_debug'] = TRUE;
$db['access']['cache_on'] = FALSE;
$db['access']['cachedir'] = "";
$db['access']['char_set'] = "utf8";
$db['access']['dbcollat'] = "utf8_general_ci";
</code></pre>
|
[
{
"answer_id": 260567,
"author": "JayTee",
"author_id": 20153,
"author_profile": "https://Stackoverflow.com/users/20153",
"pm_score": 3,
"selected": true,
"text": "$db['access']['hostname'] = \"<dsn name>\";\n$db['access']['username'] = \"\";\n$db['access']['password'] = \"\";\n$db['access']['database'] = \"<dsn name>\";\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24197/"
] |
178,863
|
<p>I am building a product that we are eventually going to white-label. Right now I am trying to figure out the best way to facilitate these requirements programmatically so the user can update the basic design of the site (ie header color, etc) via their profile/settings form. </p>
<p>Requirements: </p>
<ol>
<li>User can update the logo (this is complete)</li>
<li>User can update basic design elements (based on CSS), ie header color, footer color, sidebar color - all basic CSS overrides</li>
</ol>
<p>We don't want to use ASP.Net Themes/Skins because that requires storing static themes in the local file system. We would like to use CSS to override the base style and store this in the database.</p>
<p>Our initial plan is to store the CSS in a simple varchar field in the database and write that CSS out to the Master Page on Pre-Init event using "!" to override the base styles. Is this the best solution? If not, what have you done to accomplish this functionality/</p>
|
[
{
"answer_id": 178891,
"author": "y0mbo",
"author_id": 417,
"author_profile": "https://Stackoverflow.com/users/417",
"pm_score": -1,
"selected": false,
"text": "<style>"
},
{
"answer_id": 179001,
"author": "Mr. Shiny and New 安宇",
"author_id": 7867,
"author_profile": "https://Stackoverflow.com/users/7867",
"pm_score": 2,
"selected": false,
"text": ".header_area {\n border: 1px solid <%=headerBorderColor%>;\n background-color: <%=headerBGColor%>;\n foreground-color: <%=headerFGColor%>;\n}\n <link rel=\"stylesheet\" href=\"default_styles.css\">\n<link rel=\"stylesheet\" href=\"white_label_css.asp\">\n"
},
{
"answer_id": 179216,
"author": "Andy Brudtkuhl",
"author_id": 12442,
"author_profile": "https://Stackoverflow.com/users/12442",
"pm_score": 1,
"selected": false,
"text": "<link rel=\"stylesheet\" href=\"style.ashx\" />\n <!--WebHandler Language=\"C#\" Class=\"StyleSheetHandler\"-->\n public class StyleSheetHandler : IHttpHandler {\n public void ProcessRequest (HttpContext context)\n { \n context.Response.ContentType = \"text/css\";\n context.Response.ContentEncoding = System.Text.Encoding.UTF8;\n\n string css = BuildCSSString(); //not showing this function\n\n context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(600));\n context.Response.Cache.SetCacheability(HttpCacheability.Public);\n context.Response.Write( css );\n }\n\n public bool IsReusable\n {\n get { return true; }\n }\n\n}\n"
},
{
"answer_id": 180696,
"author": "lbz",
"author_id": 11530,
"author_profile": "https://Stackoverflow.com/users/11530",
"pm_score": 3,
"selected": false,
"text": "<link rel=\"stylesheet\" href=\"standard.css\" />\n<link rel=\"stylesheet\" href=\"<%= customer_code %>/custom_style.css\" />\n...\n<img scr=\"<%= customer_code %>/logo.png\" />\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12442/"
] |
178,876
|
<p>In this asp.net I'm cleaning up it's possible for deadlocks to occur. I want to make sure that the code deals with them properly, so I'm trying to write NUnit tests which trigger a deadlock.....</p>
<p>The DAO is split by entity. Each entity has a set of tests which are surrounded by Startup() and Teardown() methods which create a transactionscope and then roll it back after the tests are complete. This works great for everything else, but is completely useless for deadlocks.</p>
<p>How can I setup and run a "deadlock" test using TransactionScope and SQL2000 (ie MSDTC is involved) that can be reliably reproduced?
More detail: I know there is a situation whereby if two users call two functions with different, specific, data values then a deadlock <em>can</em> result. How can I simulate this within NUNIT - and make the deadlock <em>always</em> happen?</p>
<p>And yes, I did start with the "Why don't you stop the deadlocks happening in the first place" plan of action, but I have no control over the code where the deadlocks can occur - I just call the functions and they can deadlock.</p>
|
[
{
"answer_id": 185025,
"author": "Josh Kodroff",
"author_id": 549,
"author_profile": "https://Stackoverflow.com/users/549",
"pm_score": 3,
"selected": true,
"text": "MockObject mo = MockManager.MockObject(typeof(MyDeadlockException));\nmock.ExpectAndThrow(\"MyMethod\", (MyDeadlockException)mo.Object); \n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6969/"
] |
178,887
|
<p>Is it is possible, with <a href="http://en.wikipedia.org/wiki/Windows_Forms" rel="nofollow noreferrer">Windows Forms</a> in .NET, to change the opacity of a form without it automatically changing the opacity of the controls within the form?</p>
<p>I have a form that is running maximized, that contains a flowlayoutpanel in the centre of the form with controls inside it. I would like to lower the opacity of the form so that the "spare" part around the flowlayoutpanel is partly transparent, but the flowlayoutpanel itself remains solid (im aiming for a <a href="http://www.huddletogether.com/projects/lightbox/" rel="nofollow noreferrer">lightbox</a> style effect).</p>
|
[
{
"answer_id": 179022,
"author": "Jeff Yates",
"author_id": 23234,
"author_profile": "https://Stackoverflow.com/users/23234",
"pm_score": 0,
"selected": false,
"text": "Opacity Form Control"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6165/"
] |
178,888
|
<p>This is a minor bug (one I'm willing to live with in the interest of go-live, frankly), but I'm wondering if anyone else has ideas to fix it.</p>
<p>I have a C# WinForms application. When the app is launched via the executable (not via the debugger), the first thing the user sees is a console window, followed by the main window (after pre-loading is complete.)</p>
<p>I'd like to not display the console window. (Like I said, it's a minor bug.)</p>
<p>The project output is already set to Windows Application.</p>
<p>Here's (most of) the code for the Main() method. I've snipped out various proprietary/security related stuff, replacing it with comments where appropriate.</p>
<pre><code>[STAThread]
static void Main()
{
try
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
// SNIP: Get username from Windows, associate with DB user
if (user == null || user.UID == 0 || (user.Active.HasValue && !(user.Active.Value)))
{
MessageBox.Show(ErrorStrings.UnknownUser, ErrorStrings.TitleBar, MessageBoxButtons.OK,
MessageBoxIcon.Error);
Application.Exit();
return;
}
// SNIP: Associate user with employee object
Application.Run(new MainForm());
}
catch (Exception ex)
{
if (ExceptionPolicy.HandleException(ex, UiStrings.ExceptionPolicy))
{
string message = ErrorStrings.UnhandledPreface + ex.ToString();
MessageBox.Show(message, ErrorStrings.TitleBar, MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
}
}
</code></pre>
<p>Anyone have any ideas?</p>
|
[
{
"answer_id": 178955,
"author": "Stephen Deken",
"author_id": 7154,
"author_profile": "https://Stackoverflow.com/users/7154",
"pm_score": 1,
"selected": false,
"text": "AllocConsole() UseShellExecute=false; CreateNoWindow=true;"
},
{
"answer_id": 179084,
"author": "John Rudy",
"author_id": 14048,
"author_profile": "https://Stackoverflow.com/users/14048",
"pm_score": 2,
"selected": false,
"text": "<csc output=\"${build.outputPath}\\[myapp].exe\" target=\"winexe\" debug=\"Full\" rebuild=\"true\">\n <!-- lots of references, sources and resources -->\n</csc>\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14048/"
] |
178,898
|
<p>I have a program that uses the built in webbrowser control. At some point during the usage of this, I'm not sure at what point, but it appears to be random, I get the following error:</p>
<pre><code>System.AccessViolationException
FullText = System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
</code></pre>
<p>Does anyone have any clues as to why I would get this and how to prevent it?</p>
|
[
{
"answer_id": 1920554,
"author": "Darkmage",
"author_id": 173728,
"author_profile": "https://Stackoverflow.com/users/173728",
"pm_score": 0,
"selected": false,
"text": "\"bcdedit.exe /set {current} nx AlwaysOff\"\n"
},
{
"answer_id": 5223166,
"author": "Filip Navara",
"author_id": 156063,
"author_profile": "https://Stackoverflow.com/users/156063",
"pm_score": 3,
"selected": false,
"text": "mshtml!CRootTracker::CollectGarbageInternal+0xd\nmshtml!CDoc::ReduceMemoryPressureTask+0x29\nmshtml!CStackPtrAry<unsigned long,12>::GetStackSize+0xb6\nmshtml!GlobalWndProc+0x183\nUSER32!InternalCallWinProc+0x23\nUSER32!UserCallWinProcCheckWow+0x109\nUSER32!DispatchMessageWorker+0x3bc\nUSER32!DispatchMessageW+0xf\n C:\\Windows\\System32\\regsvr32.exe C:\\Windows\\System32\\jscript.dll\nC:\\Windows\\SysWOW64\\regsvr32.exe C:\\Windows\\SysWOW64\\jscript.dll\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12969/"
] |
178,899
|
<p>I have a collection of classes that I want to serialize out to an XML file. It looks something like this:</p>
<pre><code>public class Foo
{
public List<Bar> BarList { get; set; }
}
</code></pre>
<p>Where a bar is just a wrapper for a collection of properties, like this:</p>
<pre><code>public class Bar
{
public string Property1 { get; set; }
public string Property2 { get; set; }
}
</code></pre>
<p>I want to mark this up so that it outputs to an XML file - this will be used for both persistence, and also to render the settings via an XSLT to a nice human-readable form. </p>
<p>I want to get a nice XML representation like this:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<Foo>
<BarList>
<Bar>
<Property1>Value</Property1>
<Property2>Value</Property2>
</Bar>
<Bar>
<Property1>Value</Property1>
<Property2>Value</Property2>
</Bar>
</Barlist>
</Foo>
</code></pre>
<p>where are all of the Bars in the Barlist are written out with all of their properties. I'm fairly sure that I'll need some markup on the class definition to make it work, but I can't seem to find the right combination.</p>
<p>I've marked Foo with the attribute </p>
<pre><code>[XmlRoot("Foo")]
</code></pre>
<p>and the <code>list<Bar></code> with the attribute</p>
<pre><code>[XmlArray("BarList"), XmlArrayItem(typeof(Bar), ElementName="Bar")]
</code></pre>
<p>in an attempt to tell the Serializer what I want to happen. This doesn't seem to work however and I just get an empty tag, looking like this:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<Foo>
<Barlist />
</Foo>
</code></pre>
<p>I'm not sure if the fact I'm using Automatic Properties should have any effect, or if the use of generics requires any special treatment. I've gotten this to work with simpler types like a list of strings, but a list of classes so far eludes me.</p>
|
[
{
"answer_id": 178931,
"author": "Carl",
"author_id": 951280,
"author_profile": "https://Stackoverflow.com/users/951280",
"pm_score": 6,
"selected": true,
"text": "public partial class Form1 : Form\n{\n public Form1()\n {\n InitializeComponent();\n }\n\n private void button1_Click(object sender, EventArgs e)\n {\n\n Foo f = new Foo();\n\n f.BarList = new List<Bar>();\n\n f.BarList.Add(new Bar { Property1 = \"abc\", Property2 = \"def\" });\n\n XmlSerializer ser = new XmlSerializer(typeof(Foo));\n\n using (FileStream fs = new FileStream(@\"c:\\sertest.xml\", FileMode.Create))\n {\n ser.Serialize(fs, f);\n }\n }\n}\n\npublic class Foo\n{\n [XmlArray(\"BarList\"), XmlArrayItem(typeof(Bar), ElementName = \"Bar\")]\n public List<Bar> BarList { get; set; }\n}\n\n[XmlRoot(\"Foo\")]\npublic class Bar\n{\n public string Property1 { get; set; }\n public string Property2 { get; set; }\n}\n <?xml version=\"1.0\"?>\n<Foo xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n <BarList>\n <Bar>\n <Property1>abc</Property1>\n <Property2>def</Property2>\n </Bar>\n </BarList>\n</Foo>\n"
},
{
"answer_id": 178994,
"author": "FryHard",
"author_id": 231,
"author_profile": "https://Stackoverflow.com/users/231",
"pm_score": 2,
"selected": false,
"text": "[Serializable]\n[XmlRoot(\"Foo\")]\npublic class Foo\n{\n [XmlArray(\"BarList\"), XmlArrayItem(typeof(Bar), ElementName = \"Bar\")]\n public List<Bar> BarList { get; set; }\n}\n [Serializable]\npublic class Bar\n{\n public string Property1 { get; set; }\n public string Property2 { get; set; }\n}\n Foo f = new Foo();\nf.BarList = new List<Bar>();\nf.BarList.Add(new Bar() { Property1 = \"s\", Property2 = \"2\" });\nf.BarList.Add(new Bar() { Property1 = \"s\", Property2 = \"2\" });\n\nFileStream fs = new FileStream(\"c:\\\\test.xml\", FileMode.OpenOrCreate);\nSystem.Xml.Serialization.XmlSerializer s = new System.Xml.Serialization.XmlSerializer(typeof(Foo));\ns.Serialize(fs, f);\n <?xml version=\"1.0\" ?> \n<Foo xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n <BarList>\n <Bar>\n <Property1>s</Property1> \n <Property2>2</Property2> \n </Bar>\n <Bar>\n <Property1>s</Property1> \n <Property2>2</Property2> \n </Bar>\n </BarList>\n</Foo>\n"
},
{
"answer_id": 17980727,
"author": "Peter Klein",
"author_id": 1679936,
"author_profile": "https://Stackoverflow.com/users/1679936",
"pm_score": 1,
"selected": false,
"text": "<Serializable> Public Class MyClass\n Public Property Children as List(of ChildCLass)\n <XmlAttribute> Public Property MyFirstProperty as string\n <XmlAttribute> Public Property MySecondProperty as string\nEnd Class\n\n<Serializable> Public Class ChildClass\n <XmlAttribute> Public Property MyFirstProperty as string\n <XmlAttribute> Public Property MySecondProperty as string\nEnd Class\n <MyClass> MyFirstProperty=\"\" MySecondProperty=\"\"\n <Children>\n <ChildClass> MyFirstProperty=\"\" MySecondProperty=\"\"\n </ChildClass>\n </Children>\n</MyClass>\n <XmlElement>"
},
{
"answer_id": 47215920,
"author": "Lê Quý Đôn",
"author_id": 8891788,
"author_profile": "https://Stackoverflow.com/users/8891788",
"pm_score": 2,
"selected": false,
"text": "var xmlfromLINQ = new XElement(\"BarList\",\n from c in BarList \n select new XElement(\"Bar\",\n new XElement(\"Property1\", c.Property1),\n new XElement(\"Property2\", c.Property2)\n ));\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4019/"
] |
178,904
|
<pre><code>var something = {
wtf: null,
omg: null
};
</code></pre>
<p>My JavaScript knowledge is still horribly patchy since I last programmed with it, but I think I've relearned most of it now. Except for this. I don't recall ever seeing this before. What is it? And where can I learn more about it?</p>
|
[
{
"answer_id": 178916,
"author": "Aaron Maenpaa",
"author_id": 2603,
"author_profile": "https://Stackoverflow.com/users/2603",
"pm_score": 4,
"selected": false,
"text": "var something = new Object();\nsomething.wtf = null;\nsomething.omg = null;\n"
},
{
"answer_id": 178918,
"author": "StingyJack",
"author_id": 16391,
"author_profile": "https://Stackoverflow.com/users/16391",
"pm_score": 2,
"selected": false,
"text": "something.wtf = \"myMessage\";\nalert(something.wtf);\n"
},
{
"answer_id": 178924,
"author": "Stephen Deken",
"author_id": 7154,
"author_profile": "https://Stackoverflow.com/users/7154",
"pm_score": 2,
"selected": false,
"text": "var something = new Object();\nsomething[\"wtf\"] = null;\nsomething[\"omg\"] = null;\n"
},
{
"answer_id": 178925,
"author": "Jonathan Lonowski",
"author_id": 15031,
"author_profile": "https://Stackoverflow.com/users/15031",
"pm_score": 3,
"selected": false,
"text": "var o = new Object();\no.wtf = null;\no.omg = null;\n"
},
{
"answer_id": 178956,
"author": "chroder",
"author_id": 18802,
"author_profile": "https://Stackoverflow.com/users/18802",
"pm_score": 5,
"selected": true,
"text": "var myobj = {\n name: 'SO',\n hello: function() {\n alert(this.name);\n }\n};\n for (i in myobj) {\n // myobj[i]\n // Using the brackets (myobj['name']) is the same as using a dot (myobj.name)\n}\n"
},
{
"answer_id": 178966,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 3,
"selected": false,
"text": "var normalArray = [];\n normalArray[1] = 'This is an enumerated array';\n\n alert(normalArray[1]); // outputs: This is an enumerated array\n\nvar associativeArray = [];\n associativeArray['person'] = 'John Smith';\n\n alert(associativeArray['person']); // outputs: John Smith \n var associativeArray = [];\nassociativeArray[\"one\"] = \"First\";\nassociativeArray[\"two\"] = \"Second\";\nassociativeArray[\"three\"] = \"Third\";\nfor (i in associativeArray) { \n document.writeln(i+':'+associativeArray[i]+', '); \n // outputs: one:First, two:Second, three:Third\n};\n"
},
{
"answer_id": 179286,
"author": "Odilon Redo",
"author_id": 21166,
"author_profile": "https://Stackoverflow.com/users/21166",
"pm_score": 1,
"selected": false,
"text": "var something = {wtf:null}\n var something={};\nsomething.wtf=null;\n var something=new Object();\nsomething.wtf=null;\n something[\"wtf\"]=null;\n var myName=\"wtf\";\nsomething[myName]=null;\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19825/"
] |
178,909
|
<p>I have a C# form into which I've placed a left-docked <code>MenuStrip</code>. This <code>MenuStrip</code> contains some menu items which contain submenus, and some menu items which are effectively buttons (clicking on them results in an action taking place; n.b., I realize this is not a good design).</p>
<p>I would like to have the menu items which have menus associated with them draw the right-pointing arrow on the menu item, the same way a contextual menu does. I've subclassed <code>ToolStripProfessionalRenderer</code> and can call <code>OnRenderArrow()</code> at the appropriate time (e.g., within <code>OnRenderItemText()</code> or similar), but I don't seem to have a way to determine the correct location of the arrow.</p>
<p>So, two interrelated questions here:</p>
<ol>
<li>Is there a way to force the arrows to be drawn on top-level menu items?</li>
<li>If not, is there a way to determine the proper location of the arrow on the menu item so that <code>OnRenderArrow()</code> can be called manually?</li>
</ol>
<p>Thanks!</p>
|
[
{
"answer_id": 179087,
"author": "Stephen Deken",
"author_id": 7154,
"author_profile": "https://Stackoverflow.com/users/7154",
"pm_score": 0,
"selected": false,
"text": "protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)\n{\n base.OnRenderItemText(e);\n if (e.Item.GetType() == typeof(ToolStripMenuItem))\n {\n ToolStripMenuItem tsmi = (ToolStripMenuItem)e.Item;\n if (tsmi.HasDropDownItems && tsmi.OwnerItem == null)\n {\n Rectangle bounds = tsmi.Bounds;\n bounds.X = bounds.Right - 25;\n bounds.Width = 25;\n bounds.Y = 0;\n ToolStripArrowRenderEventArgs tsarea = new ToolStripArrowRenderEventArgs(\n e.Graphics,\n e.Item,\n bounds,\n e.TextColor,\n ArrowDirection.Right);\n OnRenderArrow(tsarea);\n }\n }\n}\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7154/"
] |
178,913
|
<p>Here's the jist of the problem: Given a list of sets, such as:</p>
<pre><code>[ (1,2,3), (5,2,6), (7,8,9), (6,12,13), (21,8,34), (19,20) ]
</code></pre>
<p>Return a list of groups of the sets, such that sets that have a shared element are in the same group.</p>
<pre><code>[ [ (1,2,3), (5,2,6), (6,12,13) ], [ (7,8,9), (21,8,34) ], [ (19,20) ] ]
</code></pre>
<p>Note the stickeyness - the set (6,12,13) doesn't have a shared element with (1,2,3), but they get put in the same group because of (5,2,6).</p>
<p>To complicate matters, I should mention that I don't really have these neat sets, but rather a DB table with several million rows that looks like:</p>
<pre><code>element | set_id
----------------
1 | 1
2 | 1
3 | 1
5 | 2
2 | 2
6 | 2
</code></pre>
<p>and so on. So I would love a way to do it in SQL, but I would be happy with a general direction for the solution.</p>
<p><strong>EDIT</strong>: Changed the table column names to (element, set_id) instead of (key, group_id), to make the terms more consistent. Note that Kev's answer uses the old column names.</p>
|
[
{
"answer_id": 178940,
"author": "Matt Price",
"author_id": 852,
"author_profile": "https://Stackoverflow.com/users/852",
"pm_score": 1,
"selected": false,
"text": "nodes = [ [1,2,3], [2,4,5], [6,7,8], [10,11,12], [7,10,13], [12], [] ]\nlinks = [ set() for x in nodes ]\n\n#first find the links\nfor n in range(len(nodes)):\n for item in nodes[n]:\n for m in range(n+1, len(nodes)):\n if (item in nodes[m]):\n links[n].add(m)\n links[m].add(n)\n\nsets = []\nnodes_not_in_a_set = range(len(nodes))\n\nwhile len(nodes_not_in_a_set) > 0:\n nodes_to_explore = [nodes_not_in_a_set.pop()]\n current_set = set()\n while len(nodes_to_explore) > 0:\n current_node = nodes_to_explore.pop()\n current_set.add(current_node)\n if current_node in nodes_not_in_a_set:\n nodes_not_in_a_set.remove(current_node)\n for l in links[current_node]:\n if l not in current_set and l not in nodes_to_explore:\n nodes_to_explore.append(l)\n if len(current_set) > 0:\n sets.append(current_set)\n\nfor s in sets:\n print [nodes[n] for n in s]\n [[]]\n[[6, 7, 8], [10, 11, 12], [7, 10, 13], [12]]\n[[1, 2, 3], [2, 4, 5]]\n"
},
{
"answer_id": 179183,
"author": "itsadok",
"author_id": 7581,
"author_profile": "https://Stackoverflow.com/users/7581",
"pm_score": 0,
"selected": false,
"text": "groups (group_id, set_id) sets element set_id groups group_id set_id groups set_id groups groups"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7581/"
] |
178,915
|
<p>What do I need to do to save an image my program has generated (possibly from the camera, possibly not) to the system photo library on the iPhone?</p>
|
[
{
"answer_id": 179066,
"author": "Martin Gordon",
"author_id": 2481,
"author_profile": "https://Stackoverflow.com/users/2481",
"pm_score": 10,
"selected": true,
"text": "UIImageWriteToSavedPhotosAlbum(UIImage *image, \n id completionTarget, \n SEL completionSelector, \n void *contextInfo);\n UIImage nil UIImageWriteToSavedPhotosAlbum()"
},
{
"answer_id": 2542467,
"author": "mrburns05",
"author_id": 199367,
"author_profile": "https://Stackoverflow.com/users/199367",
"pm_score": 3,
"selected": false,
"text": "-(void) saveMePlease {\n\n//Loop through the array here\nfor (int i=0:i<[arrayOfPhotos count]:i++){\n NSString *file = [arrayOfPhotos objectAtIndex:i];\n NSString *path = [get the path of the image like you would in DOCS FOLDER or whatever];\n NSString *imagePath = [path stringByAppendingString:file];\n UIImage *image = [[[UIImage alloc] initWithContentsOfFile:imagePath]autorelease];\n\n //Now it will do this for each photo in the array\n UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);\n }\n}\n"
},
{
"answer_id": 2870518,
"author": "mrburns05",
"author_id": 199367,
"author_profile": "https://Stackoverflow.com/users/199367",
"pm_score": 1,
"selected": false,
"text": " //in the .h file put:\n\nNSMutableArray *myPhotoArray;\n\n\n///then in the .m\n\n- (void) viewDidLoad {\n\n myPhotoArray = [[NSMutableArray alloc]init];\n\n\n\n}\n\n//However Your getting images\n\n- (void) someOtherMethod { \n\n UIImage *someImage = [your prefered method of using this];\n[myPhotoArray addObject:someImage];\n\n}\n\n-(void) saveMePlease {\n\n//Loop through the array here\nfor (int i=0:i<[myPhotoArray count]:i++){\n NSString *file = [myPhotoArray objectAtIndex:i];\n NSString *path = [get the path of the image like you would in DOCS FOLDER or whatever];\n NSString *imagePath = [path stringByAppendingString:file];\n UIImage *image = [[[UIImage alloc] initWithContentsOfFile:imagePath]autorelease];\n\n //Now it will do this for each photo in the array\n UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);\n }\n}\n"
},
{
"answer_id": 3760992,
"author": "Dzianis Fileyeu",
"author_id": 453987,
"author_profile": "https://Stackoverflow.com/users/453987",
"pm_score": 6,
"selected": false,
"text": " ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];\n\n [library writeImageToSavedPhotosAlbum:[image CGImage] orientation:(ALAssetOrientation)[image imageOrientation] completionBlock:^(NSURL *assetURL, NSError *error){\n if (error) {\n // TODO: error handling\n } else {\n // TODO: success handling\n }\n}];\n[library release];\n"
},
{
"answer_id": 5272479,
"author": "Hello",
"author_id": 655276,
"author_profile": "https://Stackoverflow.com/users/655276",
"pm_score": 1,
"selected": false,
"text": "homeDirectoryPath = NSHomeDirectory();\nunexpandedPath = [homeDirectoryPath stringByAppendingString:@\"/Pictures/\"];\n\nfolderPath = [NSString pathWithComponents:[NSArray arrayWithObjects:[NSString stringWithString:[unexpandedPath stringByExpandingTildeInPath]], nil]];\n\nunexpandedImagePath = [folderPath stringByAppendingString:@\"/image.png\"];\n\nimagePath = [NSString pathWithComponents:[NSArray arrayWithObjects:[NSString stringWithString:[unexpandedImagePath stringByExpandingTildeInPath]], nil]];\n\nif (![[NSFileManager defaultManager] fileExistsAtPath:folderPath isDirectory:NULL]) {\n [[NSFileManager defaultManager] createDirectoryAtPath:folderPath attributes:nil];\n}\n"
},
{
"answer_id": 15755630,
"author": "Jeff C.",
"author_id": 881448,
"author_profile": "https://Stackoverflow.com/users/881448",
"pm_score": 4,
"selected": false,
"text": "- (void) image: (UIImage *) image didFinishSavingWithError: (NSError *) error contextInfo: (void *) contextInfo;\n [NSInvocation setArgument:atIndex:]: index (2) out of bounds [-1, 1]"
},
{
"answer_id": 18220664,
"author": "SamChen",
"author_id": 927208,
"author_profile": "https://Stackoverflow.com/users/927208",
"pm_score": 2,
"selected": false,
"text": "-(void)saveToAlbum{\n [self performSelectorInBackground:@selector(startSavingToAlbum) withObject:nil];\n}\n-(void)startSavingToAlbum{\n currentSavingIndex = 0;\n UIImage* img = arrayOfPhoto[currentSavingIndex];//get your image\n UIImageWriteToSavedPhotosAlbum(img, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);\n}\n- (void)image: (UIImage *) image didFinishSavingWithError: (NSError *) error contextInfo: (void *) contextInfo{ //can also handle error message as well\n currentSavingIndex ++;\n if (currentSavingIndex >= arrayOfPhoto.count) {\n return; //notify the user it's done.\n }\n else\n {\n UIImage* img = arrayOfPhoto[currentSavingIndex];\n UIImageWriteToSavedPhotosAlbum(img, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);\n }\n}\n"
},
{
"answer_id": 20756849,
"author": "Mutawe",
"author_id": 1091539,
"author_profile": "https://Stackoverflow.com/users/1091539",
"pm_score": 5,
"selected": false,
"text": "UIImageWriteToSavedPhotosAlbum(myUIImage, nil, nil, nil);\n Swift"
},
{
"answer_id": 21281534,
"author": "Pratik Somaiya",
"author_id": 1235566,
"author_profile": "https://Stackoverflow.com/users/1235566",
"pm_score": 0,
"selected": false,
"text": "dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{\n UIImageWriteToSavedPhotosAlbum(img.image, nil, nil, nil);\n});\n"
},
{
"answer_id": 29133115,
"author": "King-Wizard",
"author_id": 1110914,
"author_profile": "https://Stackoverflow.com/users/1110914",
"pm_score": 2,
"selected": false,
"text": " // Save it to the camera roll / saved photo album\n // UIImageWriteToSavedPhotosAlbum(self.myUIImageView.image, nil, nil, nil) or \n UIImageWriteToSavedPhotosAlbum(self.myUIImageView.image, self, \"image:didFinishSavingWithError:contextInfo:\", nil)\n\n func image(image: UIImage!, didFinishSavingWithError error: NSError!, contextInfo: AnyObject!) {\n if (error != nil) {\n // Something wrong happened.\n } else {\n // Everything is alright.\n }\n }\n"
},
{
"answer_id": 31512044,
"author": "HugglesNL",
"author_id": 3075874,
"author_profile": "https://Stackoverflow.com/users/3075874",
"pm_score": 1,
"selected": false,
"text": "@interface UIImageView (SaveImage) <UIActionSheetDelegate>\n- (void)addHoldToSave;\n@end\n @implementation UIImageView (SaveImage)\n- (void)addHoldToSave{\n UILongPressGestureRecognizer* longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];\n longPress.minimumPressDuration = 1.0f;\n [self addGestureRecognizer:longPress];\n}\n\n- (void)handleLongPress:(UILongPressGestureRecognizer*)sender {\n if (sender.state == UIGestureRecognizerStateEnded) {\n\n UIActionSheet* _attachmentMenuSheet = [[UIActionSheet alloc] initWithTitle:nil\n delegate:self\n cancelButtonTitle:@\"Cancel\"\n destructiveButtonTitle:nil\n otherButtonTitles:@\"Save Image\", nil];\n [_attachmentMenuSheet showInView:[[UIView alloc] initWithFrame:self.frame]];\n }\n else if (sender.state == UIGestureRecognizerStateBegan){\n //Do nothing\n }\n}\n-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{\n if (buttonIndex == 0) {\n UIImageWriteToSavedPhotosAlbum(self.image, nil,nil, nil);\n }\n}\n\n\n@end\n [self.imageView addHoldToSave];\n"
},
{
"answer_id": 32962031,
"author": "iDevAmit",
"author_id": 1872233,
"author_profile": "https://Stackoverflow.com/users/1872233",
"pm_score": 2,
"selected": false,
"text": "-(void)savePhotoToAlbum:(UIImage*)imageToSave {\n\n CGImageRef imageRef = imageToSave.CGImage;\n NSDictionary *metadata = [NSDictionary new]; // you can add\n ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];\n\n [library writeImageToSavedPhotosAlbum:imageRef metadata:metadata completionBlock:^(NSURL *assetURL,NSError *error){\n if(error) {\n NSLog(@\"Image save eror\");\n }\n }];\n}\n"
},
{
"answer_id": 36819428,
"author": "jarora",
"author_id": 1869954,
"author_profile": "https://Stackoverflow.com/users/1869954",
"pm_score": 1,
"selected": false,
"text": "UIImageWriteToSavedPhotosAlbum(image: UIImage, _ completionTarget: AnyObject?, _ completionSelector: Selector, _ contextInfo: UnsafeMutablePointer<Void>)\n UIImageWriteToSavedPhotosAlbum(image, self, #selector(self.imageSaved(_:didFinishSavingWithError:contextInfo:)), nil)\n\nfunc imageSaved(image: UIImage!, didFinishSavingWithError error: NSError?, contextInfo: AnyObject?) {\n if (error != nil) {\n // Something wrong happened.\n } else {\n // Everything is alright.\n }\n }\n"
},
{
"answer_id": 54250312,
"author": "luhuiya",
"author_id": 932672,
"author_profile": "https://Stackoverflow.com/users/932672",
"pm_score": 2,
"selected": false,
"text": "func writeImage(image: UIImage) {\n UIImageWriteToSavedPhotosAlbum(image, self, #selector(self.finishWriteImage), nil)\n}\n\n@objc private func finishWriteImage(_ image: UIImage, didFinishSavingWithError error: NSError?, contextInfo: UnsafeRawPointer) {\n if (error != nil) {\n // Something wrong happened.\n print(\"error occurred: \\(String(describing: error))\")\n } else {\n // Everything is alright.\n print(\"saved success!\")\n }\n}\n"
},
{
"answer_id": 64046706,
"author": "Hope",
"author_id": 2692027,
"author_profile": "https://Stackoverflow.com/users/2692027",
"pm_score": 0,
"selected": false,
"text": "var saveToPhotoAlbumCounter = 0\n\n\n\nfunc startSavingPhotoAlbume(){\n saveToPhotoAlbumCounter = 0\n saveToPhotoAlbume()\n}\n\nfunc saveToPhotoAlbume(){ \n let image = loadImageFile(fileName: imagefileList[saveToPhotoAlbumCounter], folderName: folderName)\n UIImageWriteToSavedPhotosAlbum(image!, self, #selector(image(_:didFinishSavingWithError:contextInfo:)), nil)\n}\n\n@objc func image(_ image: UIImage, didFinishSavingWithError error: NSError?, contextInfo: UnsafeRawPointer) {\n if (error != nil) {\n print(\"ptoto albume savin error for \\(imageFileList[saveToPhotoAlbumCounter])\")\n } else {\n \n if saveToPhotoAlbumCounter < imageFileList.count - 1 {\n saveToPhotoAlbumCounter += 1\n saveToPhotoAlbume()\n } else {\n print(\"saveToPhotoAlbume is finished with \\(saveToPhotoAlbumCounter) files\")\n }\n }\n}\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20626/"
] |
178,921
|
<p>I have the following code in my file to load a div with HTML from an AJAX call:</p>
<pre><code>$('#searchButton').click( function() {
$('#inquiry').load('/search.php?pid=' + $('#searchValue').val());
});
</code></pre>
<p>This works fine in Firefox and Google Chrome, but whenever I do the search in IE I get redirected back to index.php. I grabbed the URL from Firebug and pasted that into IE and no redirection happens, I just get the output that should be returned.</p>
<p>I also tried changing it to a $.get() request and a full $.ajax() request but still the same redirection.</p>
|
[
{
"answer_id": 178942,
"author": "Steve g",
"author_id": 12092,
"author_profile": "https://Stackoverflow.com/users/12092",
"pm_score": 2,
"selected": false,
"text": "$('#searchButton').click( function(e) {\n $('#inquiry').load('/search.php?pid=' + $('#searchValue').val());\n e.preventDefault();\n});\n"
},
{
"answer_id": 179043,
"author": "dragonmantank",
"author_id": 204,
"author_profile": "https://Stackoverflow.com/users/204",
"pm_score": 2,
"selected": true,
"text": "<form onSubmit=\"return false;\">\n[HTML]\n</form>\n"
},
{
"answer_id": 23929433,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "var searchbutton = $('#searchButton');\nvar inquirysearchvalue = $('#inquiry').load('/search.php?pid=' + $('#searchValue');\n\nsearchbutton.click( function(e) {\n inquirysearchvalue.val());\n e.preventDefault();\n});\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/204/"
] |
178,934
|
<p>In the STL library some containers have iterators and it is commonly held that they are a superior way of iterating through these containers rather than simple for loops e.g.</p>
<pre><code>for ( int i=0; i < vecVector.size(); i++ )
{
..
}
</code></pre>
<p>Can anyone tell me why and in what cases I should use iterators and in what cases the code snippet above please?</p>
|
[
{
"answer_id": 178989,
"author": "Dave Van den Eynde",
"author_id": 455874,
"author_profile": "https://Stackoverflow.com/users/455874",
"pm_score": 1,
"selected": false,
"text": "#include <algorithm>\n\nvoid printvalue(double s)\n{\n // Do something with s\n}\n\nint _tmain(int argc, _TCHAR* argv[])\n{\n double s[20] = {0};\n\n std::for_each(s, s+20, printvalue);\n\n return 0;\n}\n"
},
{
"answer_id": 178992,
"author": "paercebal",
"author_id": 14089,
"author_profile": "https://Stackoverflow.com/users/14089",
"pm_score": 6,
"selected": true,
"text": "typedef std::vector<int> Container ;\n\nvoid doSomething(Container & p_aC)\n{\n for(Container::iterator it = p_aC.begin(), itEnd = p_aC.end(); it != itEnd; ++it)\n {\n int & i = *it ; // i is now a reference to the value iterated\n // do something with \"i\"\n }\n}\n"
},
{
"answer_id": 179348,
"author": "Jamie Eisenhart",
"author_id": 19533,
"author_profile": "https://Stackoverflow.com/users/19533",
"pm_score": 2,
"selected": false,
"text": "#include <iostream>\n#include <vector>\n#include <algorithm>\n\nusing namespace std;\n\ntemplate <typename InputIterator, typename OutputIterator>\nvoid AddOne(InputIterator begin, InputIterator end, OutputIterator dest)\n{\n while (begin != end)\n {\n *dest = *begin + 1;\n ++dest;\n ++begin;\n }\n}\n\nint _tmain(int argc, _TCHAR* argv[])\n{\n vector<int> data;\n data.push_back(1);\n data.push_back(2);\n data.push_back(3);\n\n // Compute intermediate results vector and dump to console\n vector<int> results;\n AddOne(data.begin(), data.end(), back_inserter(results));\n copy(results.begin(), results.end(), ostream_iterator<int>(cout, \" \"));\n cout << endl;\n\n // Compute results and send directly to console, no intermediate vector required\n AddOne(data.begin(), data.end(), ostream_iterator<int>(cout, \" \"));\n cout << endl;\n\n return 0;\n}\n"
},
{
"answer_id": 181824,
"author": "Johann Gerell",
"author_id": 6345,
"author_profile": "https://Stackoverflow.com/users/6345",
"pm_score": 1,
"selected": false,
"text": "std::vector<> std::set<> std::map<> for"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18664/"
] |
178,936
|
<p>I am working on a build system. The build system posts the results as a zip file in a directory. Unfortunately I have no easy way to know the name of the zip file, because it is timestamped. For the next operation, I must decompress this zip file to some specific location and then do some more file operations.</p>
<p>I guess I could change the build system so I specify the name of the result zip file from the command line, however, I though it might be easiest just to find out which one is the newest file and unzip it (if the previous process is successful). </p>
<p>How can I issue an unzip command that will only take effect on the newest zip file in the directory, ignoring all others?</p>
<p>EDIT: I decided to use the capabilities in ANT for this task instead. However, it is still a neat trick to have up the sleve... Thanks for the answer!</p>
|
[
{
"answer_id": 179016,
"author": "David Webb",
"author_id": 3171,
"author_profile": "https://Stackoverflow.com/users/3171",
"pm_score": 5,
"selected": true,
"text": "FOR /F usebackq %%i IN (`DIR /B /O-D *.ZIP`) DO UNZIP %%i && GOTO DONE || GOTO DONE\n:DONE\n DIR /B /O-D *.ZIP FOR /F usebackq && GOTO DONE || GOTO DONE UNZIP && || UNZIP %%i FOR /F \"tokens=*\" %%i IN ('DIR /B /O-D *.ZIP') DO UNZIP \"%%i\" && GOTO DONE || GOTO DONE\n:DONE\n"
},
{
"answer_id": 179035,
"author": "John Nilsson",
"author_id": 24243,
"author_profile": "https://Stackoverflow.com/users/24243",
"pm_score": 2,
"selected": false,
"text": "unzip \"$(ls -tr *zip | tail -n1)\"\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178936",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2309/"
] |
178,948
|
<p>I have a repeater that outputs divs like the following for every item returned from some method.</p>
<pre><code><div class="editor-area">
<div class="title">the title</div>
<div>the description</div>
<div class="bottom-bar">
<a href="link">Modify</a>
<a href="link2">Delete</a>
</div>
</div>
</code></pre>
<p>I need to have a textbox on the page that allows the user to filter the list based on what's in the title field. I would like it to happen as the user types.</p>
<p>I could get this done without asking for help, but I want to do it right. I'm using ASP.Net 2.0 WebForms (unfortunately), and I can use jQuery if it would be useful for this (i have very little experience with it). </p>
<p>Any tips or samples would be appreciated. </p>
<p>If the filter operation takes a couple of seconds, how do you keep it from locking up the screen? What event should I do the filter on? Is there anything in jQuery that would make the javascript a little cleaner?</p>
|
[
{
"answer_id": 179021,
"author": "Craig Stuntz",
"author_id": 7714,
"author_profile": "https://Stackoverflow.com/users/7714",
"pm_score": 4,
"selected": true,
"text": "$(\"div.title\").hide();\n $(\"div.title:contains(searchText)\").show();\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3226/"
] |
178,952
|
<p>In the code below I use <code>mpf_add</code> to add the string representation of two floating values. What I don't understand at this point is why <code>2.2 + 3.2 = 5.39999999999999999999999999999999999999</code>. I would have thought that <code>gmp</code> was smart enough to give <code>5.4</code>. </p>
<p>What am I not comprehending about how gmp does floats?</p>
<p>(BTW, when I first wrote this I wasn't sure how to insert a decimal point, thus the plus/minus digit stuff at the end)</p>
<pre><code>BSTR __stdcall FBIGSUM(BSTR p1, BSTR p2 ) {
USES_CONVERSION;
F(n1);
F(n2);
F(res);
LPSTR sNum1 = W2A( p1 );
LPSTR sNum2 = W2A( p2 );
mpf_set_str( n1, sNum1, 10 );
mpf_set_str( n2, sNum2, 10 );
mpf_add( res, n1, n2 );
char * buff = (char *) _alloca( 1024 );
char expBuffer[ 20 ];
mp_exp_t exp;
mpf_get_str(buff, &exp, 10, 0, res);
char * temp = ltoa( (long) exp, expBuffer, 10 );
if (exp >= 0) {
strcat(buff, "+" );
}
strcat(buff, expBuffer );
BSTR bResult = _com_util::ConvertStringToBSTR( buff );
return bResult;
}
</code></pre>
|
[
{
"answer_id": 184167,
"author": "bugmagnet",
"author_id": 426,
"author_profile": "https://Stackoverflow.com/users/426",
"pm_score": 1,
"selected": false,
"text": "2.1 3.457 2.100 mpz_add 2100 3457 5557 5.557 function fadd( n1, n2 )\n dim s1, s2, max, mul, res\n normalise3 n1, n2, s1, s2, max\n s1 = replace( s1, \".\", \"\" )\n s2 = replace( s2, \".\", \"\" )\n mul = clng(s1) + clng(s2)\n res = left( mul, len(mul) - max ) & \".\" & mid( mul, len( mul ) - max + 1 )\n fadd = res\nend function\n\nsub normalise3( byval n1, byval n2, byref s1, byref s2, byref numOfDigits )\n dim a1, a2\n dim max\n if instr( n1, \".\" ) = 0 then n1 = n1 & \".\"\n if instr( n2, \".\" ) = 0 then n2 = n2 & \".\"\n a1 = split( n1, \".\" )\n a2 = split( n2, \".\" )\n max = len( a1(1) )\n if len( a2(1) ) > max then max = len( a2( 1 ) )\n s1 = a1(0) & \".\" & a1(1) & string( max - len( a1( 1 )), \"0\" )\n s2 = a2(0) & \".\" & a2(1) & string( max - len( a2( 1 )), \"0\" )\n numOfDigits = max\nend sub\n #define Z(x) mpz_t x; mpz_init( x );\n\nBSTR __stdcall FADD( BSTR p1, BSTR p2 ) {\n USES_CONVERSION;\n\n LPSTR sP1 = W2A( p1 );\n LPSTR sP2 = W2A( p2 );\n\n char LeftOf1[ 1024 ];\n char RightOf1[ 1024 ];\n char LeftOf2[ 1024 ];\n char RightOf2[ 1024 ];\n char * dotPos;\n long numOfDigits;\n int i;\n int amtOfZeroes;\n\n dotPos = strstr( sP1, \".\" );\n if ( dotPos == NULL ) {\n strcpy( LeftOf1, sP1 );\n *RightOf1 = '\\0';\n } else {\n *dotPos = '\\0';\n strcpy( LeftOf1, sP1 );\n strcpy( RightOf1, (dotPos + 1) );\n }\n\n dotPos = strstr( sP2, \".\" );\n if ( dotPos == NULL ) {\n strcpy( LeftOf2, sP2 );\n *RightOf2 = '\\0';\n } else {\n *dotPos = '\\0';\n strcpy( LeftOf2, sP2 );\n strcpy( RightOf2, (dotPos + 1) );\n }\n\n numOfDigits = strlen( RightOf1 ) > strlen( RightOf2 ) ? strlen( RightOf1 ) : strlen( RightOf2 );\n\n strcpy( sP1, LeftOf1 );\n strcat( sP1, RightOf1 );\n amtOfZeroes = numOfDigits - strlen( RightOf1 );\n for ( i = 0; i < amtOfZeroes; i++ ) {\n strcat( sP1, \"0\" );\n }\n strcpy( sP2, LeftOf2 );\n strcat( sP2, RightOf2 );\n amtOfZeroes = numOfDigits - strlen( RightOf2 );\n for ( i = 0; i < amtOfZeroes; i++ ) {\n strcat( sP2, \"0\" );\n }\n\n\n Z(n1);\n Z(n2);\n Z(res);\n\n mpz_set_str( n1, sP1, 10 );\n mpz_set_str( n2, sP2, 10 );\n mpz_add( res, n1, n2 );\n\n char * buff = (char *) _alloca( mpz_sizeinbase( res, 10 ) + 2 + 1 );\n\n mpz_get_str(buff, 10, res);\n\n char * here = buff + strlen(buff) - numOfDigits; \n\n memmove( here + 1, here, strlen(buff)); // plus trailing null\n *(here) = '.';\n\n BSTR bResult = _com_util::ConvertStringToBSTR( buff );\n return bResult;\n}\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/426/"
] |
178,963
|
<p>I have this working definition:</p>
<pre><code>IDENTIFIER [a-zA-Z][a-zA-Z0-9]*
</code></pre>
<p>I don't want to keep repeating the [a-zA-Z] and [0-9], so I made two new definitions</p>
<pre><code>DIGIT [0-9]
VALID [a-zA-Z]
</code></pre>
<p>How can I rewrite the IDENTIFIER rule to use the DIGIT and VALID definitions?</p>
<p>I don't know how to do the "second" match, I'm stuck here:</p>
<pre><code>IDENTIFIER {VALID}[{VALID}{DIGIT}]* // This syntax is incorrect
</code></pre>
<p>Thanks.</p>
<p>Edit: The entire test program that I'm using: <a href="http://pastebin.com/f5b64183f" rel="nofollow noreferrer">http://pastebin.com/f5b64183f</a>.</p>
|
[
{
"answer_id": 178987,
"author": "Keng",
"author_id": 730,
"author_profile": "https://Stackoverflow.com/users/730",
"pm_score": -1,
"selected": false,
"text": "(?:[a-zA-Z])+(?:[0-9])+\n"
},
{
"answer_id": 179058,
"author": "Ben Doom",
"author_id": 12267,
"author_profile": "https://Stackoverflow.com/users/12267",
"pm_score": 3,
"selected": true,
"text": "IDENTIFIER {VALID}({VALID}|{DIGIT})*\n [{VALID}{DIGIT}] [[A-Za-z][0-9]]"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18403/"
] |
178,964
|
<p><a href="https://stackoverflow.com/q/133925">JavaScript post request like a form submit</a> shows you how to submit a form that you create via POST in JavaScript. Below is my modified code.</p>
<pre><code>var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", "test.jsp");
var hiddenField = document.createElement("input");
hiddenField.setAttribute("name", "id");
hiddenField.setAttribute("value", "bob");
form.appendChild(hiddenField);
document.body.appendChild(form); // Not entirely sure if this is necessary
form.submit();
</code></pre>
<p>What I would like to do is open the results in a new window. I am currently using something like this to open a page in a new window:</p>
<pre><code>onclick = window.open(test.html, '', 'scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,status=no');
</code></pre>
|
[
{
"answer_id": 179015,
"author": "liggett78",
"author_id": 19762,
"author_profile": "https://Stackoverflow.com/users/19762",
"pm_score": 9,
"selected": true,
"text": "<form target=\"_blank\" ...></form>\n form.setAttribute(\"target\", \"_blank\");\n"
},
{
"answer_id": 180999,
"author": "Marko Dumic",
"author_id": 5817,
"author_profile": "https://Stackoverflow.com/users/5817",
"pm_score": 7,
"selected": false,
"text": "var form = document.createElement(\"form\");\nform.setAttribute(\"method\", \"post\");\nform.setAttribute(\"action\", \"test.jsp\");\n\n// setting form target to a window named 'formresult'\nform.setAttribute(\"target\", \"formresult\");\n\nvar hiddenField = document.createElement(\"input\"); \nhiddenField.setAttribute(\"name\", \"id\");\nhiddenField.setAttribute(\"value\", \"bob\");\nform.appendChild(hiddenField);\ndocument.body.appendChild(form);\n\n// creating the 'formresult' window with custom features prior to submitting the form\nwindow.open('test.html', 'formresult', 'scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,status=no');\n\nform.submit();\n"
},
{
"answer_id": 2390990,
"author": "Edu Carrega",
"author_id": 287546,
"author_profile": "https://Stackoverflow.com/users/287546",
"pm_score": 1,
"selected": false,
"text": "<input type=”image” src=”submit.png”> (in any place)\n <form name=”print”>\n<input type=”hidden” name=”a” value=”<?= $a ?>”>\n<input type=”hidden” name=”b” value=”<?= $b ?>”>\n<input type=”hidden” name=”c” value=”<?= $c ?>”>\n</form>\n <script>\n$(‘#submit’).click(function(){\n open(”,”results”);\n with(document.print)\n {\n method = “POST”;\n action = “results.php”;\n target = “results”;\n submit();\n }\n});\n</script>\n"
},
{
"answer_id": 12572772,
"author": "luchaninov",
"author_id": 437763,
"author_profile": "https://Stackoverflow.com/users/437763",
"pm_score": 3,
"selected": false,
"text": "var urlAction = 'whatever.php';\nvar data = {param1:'value1'};\n\nvar $form = $('<form target=\"_blank\" method=\"POST\" action=\"' + urlAction + '\">');\n$.each(data, function(k,v){\n $form.append('<input type=\"hidden\" name=\"' + k + '\" value=\"' + v + '\">');\n});\n$form.submit();\n"
},
{
"answer_id": 41526344,
"author": "Grigory Kislin",
"author_id": 548473,
"author_profile": "https://Stackoverflow.com/users/548473",
"pm_score": 2,
"selected": false,
"text": "<form action='...' method=post target=\"result\" onsubmit=\"window.open('','result','width=800,height=400');\">\n <input name=\"..\">\n ....\n</form>\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
178,973
|
<p>I'm a big fan of <a href="http://logging.apache.org/log4net" rel="noreferrer">log4net</a>, but recently, some (in my department) have questioned its inclusion in our projects because of the seemingly heaviness of each logging method. I would argue that there are better techniques than others, but that's another question.</p>
<p>I'm curious to know, what is the typical impact of a log4net DebugFormat-type call on your applications. I'm going to leave out variables like number of log statements per lines of code, etc, because I'm just looking for anything that you've seen in the real world.</p>
<p>And, I am aware of the simple technique of adding a guard clause to long evaluation statements eg:</p>
<pre><code>if (log.IsDebug)
{
log.DebugFormat(...);
}
</code></pre>
<p>So, let's exclude that from consideration for now.</p>
|
[
{
"answer_id": 179120,
"author": "Will Hartung",
"author_id": 13663,
"author_profile": "https://Stackoverflow.com/users/13663",
"pm_score": 5,
"selected": true,
"text": "log.debug(\"Runtime error. Order #\" + order.getOrderNo() + \" is not posted.\");\n log.debug(\"Something wrong with this list: \" + longListOfData);\n if (log.isDebug()) {\n log.debug(...);\n}\n log.debug(\"Runtime error. Order # {0} is not posted.\", order.getOrderNo());\n"
},
{
"answer_id": 10606949,
"author": "keisar",
"author_id": 1344070,
"author_profile": "https://Stackoverflow.com/users/1344070",
"pm_score": 2,
"selected": false,
"text": "if (IsDebugEnabled)\n{\n Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);\n}\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5619/"
] |
178,976
|
<p>I am wondering what everyone thinks the best method of handling results from your own database is. Other teams may be involved and there is always the chance the procedure/data could be altered and erroneous results would occur. My question is this. Is it better to let and exception occur, catch and log it or try to handle all contingencies and hide the error? Say, something like below.</p>
<pre><code>if (dr.Table.Columns.Contains("column") && !dr["column"].Equals(DBNull.Value))
{
this.value = (type)dr["column"];
}
else
{
this.value= null;
}
</code></pre>
|
[
{
"answer_id": 182550,
"author": "AJ.",
"author_id": 7211,
"author_profile": "https://Stackoverflow.com/users/7211",
"pm_score": 0,
"selected": false,
"text": "try // wrap everything in a try/catch to handle things I haven't thought of\n{\n\n if ( !dr.Table.Columns.Contains(\"column\") )\n {\n throw new SomeSortOfException(\"cloumn: \" + column + \" is missing\" );\n }\n else // strictly don't need the else but it makes the code easier to follow\n {\n if (dr[\"column\"].Equals(DBNull.Value))\n {\n this.value= null;\n }\n else\n {\n this.value = (type) dr[\"column\"];\n }\n }\n}\ncatch( SomeSortOfException ex )\n{\n throw;\n}\ncatch( Exception ex )\n{\n // handle or throw impossible exceptions here\n}\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8873/"
] |
178,977
|
<p>In the Ajax toolkit you can use a Tab Container and add TabPanels to this. </p>
<p>I have some controls that I want to be able to use across all tabs and the tailor the tabs with other controls as neccessary. </p>
<p>My question is how do I reuse a panel on multiple tabs?
Essentially I after something like this</p>
<pre><code><TabContainer>
<tabPanel1>
<contentTemplate>
<pnl1></pnl1>
//other controls here
</contentTemplate>
</tabPanel1>
<tabPanel2>
<contentTemplate>
<pnl1></pnl1>
//other controls here
</contentTemplate>
<tabPanel2>
</tabContainer>
<pnl1>
//some controls here
</pnl1>
</code></pre>
|
[
{
"answer_id": 179246,
"author": "Andy Brudtkuhl",
"author_id": 12442,
"author_profile": "https://Stackoverflow.com/users/12442",
"pm_score": 2,
"selected": true,
"text": "<TabContainer>\n <tabPanel1>\n <contentTemplate>\n <uc1:MyControl id=\"myControl\" runat=\"server\" />\n </contentTemplate>\n </tablPanel1>\n\n <tabPanel2>\n <contentTemplate>\n <uc1:MyControl id=\"myControl2\" runat=\"server\" />\n </contentTemplate>\n </tablPanel2>\n</TabContainer>\n\n<uc1:MyControl id=\"myControl3\" runat=\"server\" />\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/178977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11802/"
] |
179,004
|
<p>Every time I make a project I develop several generic routines/modules/libraries that I expect I'll be using with other projects.</p>
<p>Due to the speed of development I don't spend a lot of time making these modules perfect - just good enough for this project, and well enough documented and isolatable that I can easily add them to another project.</p>
<p>So far so good.</p>
<p>Now when I use them in another project inevitably I improve them - either adding new features/functions, fixing bugs, making them more general, etc.</p>
<p>At that point I have several problems:</p>
<ul>
<li>I need to maintain the changes in the module for the code I'm working on</li>
<li>I need to maintain those same changes in a central "module" repository</li>
<li>I need to make sure that the updated modules are available for, but not automatically used in older projects, or sometimes even existing projects I'm already working on.</li>
</ul>
<p>How do you manage this? How are these problems different when you have teams working on various modules in different projects?</p>
<p>-Adam</p>
|
[
{
"answer_id": 179116,
"author": "ephemient",
"author_id": 20713,
"author_profile": "https://Stackoverflow.com/users/20713",
"pm_score": 5,
"selected": true,
"text": "svn:externals svn://svn/shared svn:externals shared shared shared svn:externals shared svn:externals"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2915/"
] |
179,014
|
<p>I am using PHP with Apache on Linux, with Sendmail. I use the PHP <a href="http://php.net/manual/en/function.mail.php" rel="noreferrer"><code>mail</code></a> function. The email is sent, but the envelope has the <code>Apache_user@localhostname</code> in <code>MAIL FROM</code> (example nobody@conniptin.internal) and some remote mail servers reject this because the domain doesn't exist (obviously). Using <code>mail</code>, can I force it to change the envelope <code>MAIL FROM</code>?</p>
<p>EDIT: If I add a header in the fourth field of the <code>mail</code>() function, that changes the <code>From</code> field in the headers of the body of the message, and DOES NOT change the envelope <code>MAIL FROM</code>.</p>
<p>I can force it by spawning sendmail with <code>sendmail -t -odb -oi -frealname@realhost</code> and piping the email contents to it. Is this a better approach?</p>
<p>Is there a better, simpler, more PHP appropriate way of doing this?</p>
<p>EDIT: The bottom line is I should have RTM. Thanks for the answers folks, the fifth parameter works and all is well.</p>
|
[
{
"answer_id": 179061,
"author": "Lucas Oman",
"author_id": 6726,
"author_profile": "https://Stackoverflow.com/users/6726",
"pm_score": 7,
"selected": true,
"text": "mail('to@blah.com','subject!','body!','From: from@blah.com','-f from@blah.com');\n"
},
{
"answer_id": 179069,
"author": "Joe Scylla",
"author_id": 25771,
"author_profile": "https://Stackoverflow.com/users/25771",
"pm_score": 1,
"selected": false,
"text": "ini_set(\"sendmail_from\", yourmail@example.com);\nmail(...);\nini_restore(\"sendmail_from\");\n"
},
{
"answer_id": 5433481,
"author": "mr-euro",
"author_id": 111600,
"author_profile": "https://Stackoverflow.com/users/111600",
"pm_score": -1,
"selected": false,
"text": "system/exec"
},
{
"answer_id": 47109353,
"author": "Vladimir Kornea",
"author_id": 2407309,
"author_profile": "https://Stackoverflow.com/users/2407309",
"pm_score": 2,
"selected": false,
"text": "bool mail ( string $to , string $subject , string $message [, string\n $additional_headers [, string $additional_parameters ]] ) sendmail_path -f escapeshellcmd() escapeshellcmd() escapeshellcmd() X-Warning -f /etc/mail/trusted-users"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13667/"
] |
179,026
|
<p>In Gmail, I have a bunch of labeled messages.</p>
<p>I'd like to use an IMAP client to get those messages, but I'm not sure what the search incantation is.</p>
<pre><code>c = imaplib.IMAP4_SSL('imap.gmail.com')
c.list()
('OK', [..., '(\\HasNoChildren) "/" "GM"', ...])
c.search(???)
</code></pre>
<p>I'm not finding many examples for this sort of thing.</p>
|
[
{
"answer_id": 421752,
"author": "cdleary",
"author_id": 3594,
"author_profile": "https://Stackoverflow.com/users/3594",
"pm_score": 5,
"selected": true,
"text": "imaplib SELECT IMAP4.list imaplib r'(\\HasNoChildren) \"/\"' /"
},
{
"answer_id": 3101260,
"author": "Avadhesh",
"author_id": 365148,
"author_profile": "https://Stackoverflow.com/users/365148",
"pm_score": 3,
"selected": false,
"text": "import imaplib \nobj = imaplib.IMAP4_SSL('imap.gmail.com', 993)\nobj.login('username', 'password')\nobj.select('**label name**') # <-- the label in which u want to search message\nobj.search(None, 'FROM', '\"LDJ\"')\n"
},
{
"answer_id": 36875058,
"author": "Plínio César",
"author_id": 1284485,
"author_profile": "https://Stackoverflow.com/users/1284485",
"pm_score": 2,
"selected": false,
"text": "X-GM-RAW c = imaplib.IMAP4_SSL('imap.gmail.com', 993)\nemail = 'eggs@spam'\npassword = 'spamspamspam'\nc.login(email, password)\n c.select(\"INBOX\")\n c.list() gmail_search = \"has:attachment eggs OR spam\"\nstatus, data = c.search(None, 'X-GM-RAW', gmail_search)\n gmail_search for id in data[0].split():\n status, data = gmail.fetch(id, '(BODY[TEXT])')\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17732/"
] |
179,054
|
<p>I'm writing an app which for various reasons involves Internet Explorer (IE7, for the record), ActiveX controls, and a heroic amount of JavaScript, which is spread across multiple .js includes. </p>
<p>One of our remote testers is experiencing an error message and IE's error message says something to the effect of:</p>
<pre><code>Line: 719
Char: 5
Error: Unspecified Error
Code: 0
URL: (the URL of the machine)
</code></pre>
<p>There's only one JavaScript file which has over 719 lines and line 719 is a blank line (in this case).</p>
<p>None of the HTML or other files involved in the project have 719 or more lines, but the resulting HTML (it's sort of a server-side-include thing), at least as IE shows from "View Source" does have 719 or more lines - but line 719 (in this case) is a closing table row tag (no JavaScript, in other words).</p>
<p>The results of "View Generated Source" is only 310 lines in this case.</p>
<p>I would imagine that it could possibly be that the entire page, with the contents of the JavaScript files represented inline with the rest of the HTML could be where the error is referring to but I don't know any good way to view what that would be,</p>
<p>So, given a JavaScript error from Internet Explorer <strong>where the line number is the only hint</strong> but the page is actually spread across multiple files?</p>
<p><strong>UPDATE:</strong> The issue is exacerbated by the fact that the user experiencing this is remote and for various network reasons, debugging it using something like Visual Studio 2008 (which has awesome JavaScript debugging, by the way) is impossible. I'm limited to having one of us look at the source to try and figure out what line of code it's crapping out on.</p>
<p><strong>UPDATE 2:</strong> The real answer (as accepted below) seems to be "no, not really". For what it's worth though, Robert J. Walker's bit about it being off by one did get me pointed in the right direction as I think it was the offending line. But since that's not really what I'd call good or reliable (IE's fault, not Robert J. Walker's fault) I'm going to accept the "no, not really" answer. I'm not sure if this is proper SO etiquette. Please let me know if it's not via the comments.</p>
|
[
{
"answer_id": 179101,
"author": "EndangeredMassa",
"author_id": 106,
"author_profile": "https://Stackoverflow.com/users/106",
"pm_score": 2,
"selected": false,
"text": "View > Source > Dom (Page)\n"
},
{
"answer_id": 179115,
"author": "dlamblin",
"author_id": 459,
"author_profile": "https://Stackoverflow.com/users/459",
"pm_score": 2,
"selected": false,
"text": "<script type='text/javascript' \n src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'>\n</script>\n firebug.d.console.log(\"stuff and things\")\nfirebug.d.console.dir( {returnedObject:[\"404\", \"Object Not Found\"]} )\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179054",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2577/"
] |
179,063
|
<p>How can dynamic Key-value pairs of objects be stored in app.config in using the application settings api, at runtime?</p>
<p>I've been trying to get my head around, and I can't find any meaningful example or documentation.</p>
<p>I seems that .Net dictionary classes can't be serialized in XML to store them in app.config</p>
<p>Is the only way to do it by using custom XML serialized classes, or are there any other ways? </p>
|
[
{
"answer_id": 179136,
"author": "Nick",
"author_id": 22407,
"author_profile": "https://Stackoverflow.com/users/22407",
"pm_score": 2,
"selected": false,
"text": "// Open App.Config of executable\nSystem.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);\n\n// Add an Application Setting with a name Key and a Value stored in variable called Value\nconfig.AppSettings.Settings.Add(\"Key\", Value );\n\n// Save the changes in App.config file.\nconfig.Save(ConfigurationSaveMode.Modified);\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4685/"
] |
179,085
|
<p>What is the difference between creating one index across multiple columns versus creating multiple indexes, one <em>per</em> column?</p>
<p>Are there reasons why one should be used over the other?</p>
<p>For example:</p>
<pre><code>Create NonClustered Index IX_IndexName On TableName
(Column1 Asc, Column2 Asc, Column3 Asc)
</code></pre>
<p>Versus:</p>
<pre><code>Create NonClustered Index IX_IndexName1 On TableName
(Column1 Asc)
Create NonClustered Index IX_IndexName2 On TableName
(Column2 Asc)
Create NonClustered Index IX_IndexName3 On TableName
(Column3 Asc)
</code></pre>
|
[
{
"answer_id": 179133,
"author": "MobyDX",
"author_id": 3923,
"author_profile": "https://Stackoverflow.com/users/3923",
"pm_score": 6,
"selected": false,
"text": "SELECT *\nFROM TableName\nWHERE Column1=1 AND Column2=2 AND Column3=3\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383/"
] |
179,102
|
<p>I want to get a <code>System.Type</code> given only the type name in a <code>string</code>.</p>
<p>For instance, if I have an object:</p>
<pre><code>MyClass abc = new MyClass();
</code></pre>
<p>I can then say:</p>
<pre><code>System.Type type = abc.GetType();
</code></pre>
<p>But what if all I have is:</p>
<pre><code>string className = "MyClass";
</code></pre>
|
[
{
"answer_id": 179110,
"author": "Chris Marasti-Georg",
"author_id": 96,
"author_profile": "https://Stackoverflow.com/users/96",
"pm_score": 5,
"selected": false,
"text": "Type type = Type.GetType(\"foo.bar.MyClass, foo.bar\");\n"
},
{
"answer_id": 179111,
"author": "jalbert",
"author_id": 1360388,
"author_profile": "https://Stackoverflow.com/users/1360388",
"pm_score": 1,
"selected": false,
"text": "Type type = Type.GetType(\"MyClass\");\n"
},
{
"answer_id": 179397,
"author": "Seibar",
"author_id": 357,
"author_profile": "https://Stackoverflow.com/users/357",
"pm_score": 2,
"selected": false,
"text": "Type type = Type.GetType(\"foo.bar.MyClass, foo.bar\");\nobject instanceObject = System.Reflection.Activator.CreateInstance(type);\ntype.InvokeMember(method, BindingFlags.InvokeMethod, null, instanceObject, new object[0]);\n"
},
{
"answer_id": 7286512,
"author": "dmihailescu",
"author_id": 925434,
"author_profile": "https://Stackoverflow.com/users/925434",
"pm_score": 0,
"selected": false,
"text": "Type.GetType(...) typeof"
},
{
"answer_id": 14625254,
"author": "Chris W",
"author_id": 890258,
"author_profile": "https://Stackoverflow.com/users/890258",
"pm_score": 1,
"selected": false,
"text": "public static Type GetType(string fullName)\n{\n if (string.IsNullOrEmpty(fullName))\n return null;\n Type type = Type.GetType(fullName);\n if (type == null)\n {\n string targetAssembly = fullName;\n while (type == null && targetAssembly.Length > 0)\n {\n try\n {\n int dotInd = targetAssembly.LastIndexOf('.');\n targetAssembly = dotInd >= 0 ? targetAssembly.Substring(0, dotInd) : \"\";\n if (targetAssembly.Length > 0)\n type = Type.GetType(fullName + \", \" + targetAssembly);\n }\n catch { }\n }\n }\n return type;\n}\n"
},
{
"answer_id": 18997449,
"author": "shadow",
"author_id": 1393087,
"author_profile": "https://Stackoverflow.com/users/1393087",
"pm_score": 0,
"selected": false,
"text": " // Creates and initializes a new object from its name and parameters\n public Object CreateObjectByName(string name, params Object[] args)\n {\n string s = \"<prefix>\" + name; // case sensitive; Type.FullName\n Type type = Type.GetType(s);\n Object o = System.Activator.CreateInstance(type, args);\n return o;\n }\n string z = (new NewClass(args)).GetType().FullName;\n"
},
{
"answer_id": 20407903,
"author": "nawfal",
"author_id": 661933,
"author_profile": "https://Stackoverflow.com/users/661933",
"pm_score": 5,
"selected": false,
"text": "mscorlib Type type = Type.GetType(\"namespace.class\");\n Assembly assembly = typeof(SomeKnownTypeInAssembly).Assembly;\nType type = assembly.GetType(\"namespace.class\");\n\n//or\n\nType type = Type.GetType(\"namespace.class, assembly\");\n //if class is in same assembly\nvar namespace = typeof(SomeKnownTypeInNamespace).Namespace;\nType type = Type.GetType(namespace + \".\" + \"MyClass\");\n\n\n//or for cases of referenced classes\nvar assembly = typeof(SomeKnownTypeInAssembly).Assembly;\nvar namespace = typeof(SomeKnownTypeInNamespace).Namespace;\nType type = assembly.GetType(namespace + \".\" + \"MyClass\");\n//or\nType type = Type.GetType(namespace + \".\" + \"MyClass\" + \", \" + assembly.GetName().Name);\n Type type = AppDomain.CurrentDomain.GetAssemblies()\n .SelectMany(x => x.GetTypes())\n .FirstOrDefault(x => x.Name == \"MyClass\");\n Type type = AppDomain.CurrentDomain.GetAssemblies()\n .Select(a => new { a, a.GetTypes().First().Namespace })\n .Select(x => x.a.GetType(x.Namespace + \".\" + \"MyClass\"))\n .FirstOrDefault(x => x != null);\n Assembly.Load Assembly.LoadFrom"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10722/"
] |
179,105
|
<p>I recall reading somewhere that using references to smart pointers can cause memory corruption. Is this simply because of using the reference of the smart pointer after its been destroyed? Or does the reference counting get messed up?</p>
<p>Thanks for clarifying</p>
|
[
{
"answer_id": 19118453,
"author": "John Morrison",
"author_id": 2835233,
"author_profile": "https://Stackoverflow.com/users/2835233",
"pm_score": 0,
"selected": false,
"text": "const smart_ptr<T>&\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16496/"
] |
179,112
|
<p>I'm using Exchange Web Services to Find, Create, Update, and Delete appointments from the calendars for one or more people. The application would be used by a manager to view employees' vacation time, as well as assign appointments based on availability.</p>
<p>In order for this to all work, an authenticated user's credentials must be sent to the web service. So far, the two methods that I have found that would allow for this are 1) passing in the username and password of each user and 2) impersonating a user to use DefaultCredentials. The DefaultCredentials option doesn't work for us because we do not allow impersonating users. </p>
<p>Does anyone know another way?</p>
|
[
{
"answer_id": 6224082,
"author": "Pooli",
"author_id": 288967,
"author_profile": "https://Stackoverflow.com/users/288967",
"pm_score": 1,
"selected": false,
"text": "public static ExchangeService GetService()\n{\n var webCredentials = new WebCredentials(CredentialCache.DefaultNetworkCredentials);\n\n var service = new ExchangeService(ExchangeVersion);\n service.AutodiscoverUrl(Properties.Settings.Default.SmptAccountName);\n service.Credentials = credentials;\n\n return service; \n}\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3018/"
] |
179,113
|
<p>Say I've got two scheduled processes: A and B.</p>
<p>Given that B should not run until A has completed, how might I gracefully enforce this dependency?</p>
<p>Approaches that have been considered:</p>
<ol>
<li><p>Have A schedule B upon completion. This has the downside of B never being scheduled if for some reason A failed.</p></li>
<li><p>When B runs, have it ping A to see if the latter has completed. How this might be accomplished (network, file, database record, message queue) could be messy and problematic introducing a third dependency.</p></li>
<li><p>Combine A and B into a single process. This has the downside of tightly binding the two, making it harder to re-run one or the other in isolation if need be.</p></li>
</ol>
<p>Thoughts?</p>
|
[
{
"answer_id": 179118,
"author": "warren",
"author_id": 4418,
"author_profile": "https://Stackoverflow.com/users/4418",
"pm_score": 3,
"selected": true,
"text": "A && B\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4061/"
] |
179,119
|
<p>I am learning and using Emacs. What I found annoying is that Ctrl-Space input will be stolen by Windows XP to switch the language bar instead of setting the mark in Emacs. The "language bar" is the native input languages selection such as Chinese keyboard other than English keyboard. Is there a way to temporarily prevent XP from stealing it? I have disabled the language bar from "Regional and language options" from Control Panel but the problem still exists. It doesn't happen on my Windows 2000 desktop at office but it happens on my work Windows XP laptop. Thank you very much.</p>
|
[
{
"answer_id": 12675127,
"author": "Kache",
"author_id": 234593,
"author_profile": "https://Stackoverflow.com/users/234593",
"pm_score": 3,
"selected": false,
"text": "Start regedit HKEY_CURRENT_USER/Control Panel/Input Method/Hot Keys 00000070 Chinese (Traditional) IME - Ime/NonIme Toggle 00000010 Chinese (Simplified) IME - Ime/NonIme Toggle 02c00000 20000000 Key Modifiers 02 00 Virtual Key 20 FF Hot keys for input languages Control Panel > Region and Language > Keyboards and Languages > Change keyboards... > Advanced Key Settings > Hot keys for input languages"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24020/"
] |
179,123
|
<p>I wrote the wrong thing in a commit message.</p>
<p>How can I change the message? The commit has not been pushed yet.</p>
|
[
{
"answer_id": 179147,
"author": "EfForEffort",
"author_id": 14113,
"author_profile": "https://Stackoverflow.com/users/14113",
"pm_score": 15,
"selected": true,
"text": "git commit --amend\n git commit --amend -m \"New commit message\"\n git push <remote> <branch> --force\n# Or\ngit push <remote> <branch> -f\n // n is the number of commits up to the last commit you want to be able to edit\ngit rebase -i HEAD~n\n e/r git rebase -i HEAD~n git rerere"
},
{
"answer_id": 180085,
"author": "Aristotle Pagaltzis",
"author_id": 9410,
"author_profile": "https://Stackoverflow.com/users/9410",
"pm_score": 11,
"selected": false,
"text": "git rebase --interactive $parent_of_flawed_commit pick reword edit git commit --amend git rebase --continue git rebase --interactive"
},
{
"answer_id": 2219560,
"author": "lfx_cool",
"author_id": 268413,
"author_profile": "https://Stackoverflow.com/users/268413",
"pm_score": 11,
"selected": false,
"text": "git commit --amend -m \"your new message\"\n"
},
{
"answer_id": 6258114,
"author": "John",
"author_id": 768136,
"author_profile": "https://Stackoverflow.com/users/768136",
"pm_score": 9,
"selected": false,
"text": "git commit --amend git commit -a --amend -m \"My new commit message\"\n"
},
{
"answer_id": 7070976,
"author": "Fatih Acet",
"author_id": 480949,
"author_profile": "https://Stackoverflow.com/users/480949",
"pm_score": 10,
"selected": false,
"text": "git commit --amend\n git commit --amend -C HEAD\n git reset --hard HEAD^\n git rebase -i HEAD~commit_count git commit --amend\ngit rebase --continue\n git commit --amend"
},
{
"answer_id": 12231177,
"author": "Mark",
"author_id": 710388,
"author_profile": "https://Stackoverflow.com/users/710388",
"pm_score": 9,
"selected": false,
"text": "git filter-branch git filter-branch -f --msg-filter \"sed 's/errror/error/'\" $flawed_commit..HEAD\n git commit --amend HEAD msg-filter"
},
{
"answer_id": 13010393,
"author": "Heena Hussain",
"author_id": 1369257,
"author_profile": "https://Stackoverflow.com/users/1369257",
"pm_score": 8,
"selected": false,
"text": "git commit --amend\n HEAD~3 git rebase -i git rebase -i HEAD~3\n"
},
{
"answer_id": 13282142,
"author": "Akhilraj N S",
"author_id": 1556933,
"author_profile": "https://Stackoverflow.com/users/1556933",
"pm_score": 8,
"selected": false,
"text": "git commit -a --amend -m \"My new commit message\"\n"
},
{
"answer_id": 13394598,
"author": "sebers",
"author_id": 1812509,
"author_profile": "https://Stackoverflow.com/users/1812509",
"pm_score": 8,
"selected": false,
"text": "git filter-branch -f --msg-filter \\\n'sed \"s/<old message>/<new message>/g\"' -- --all\n refs/original/ -f refs/original -- --all old_master git checkout -b old_master refs/original/refs/heads/master\n"
},
{
"answer_id": 13656530,
"author": "gulchrider",
"author_id": 289447,
"author_profile": "https://Stackoverflow.com/users/289447",
"pm_score": 8,
"selected": false,
"text": "Commit/Amend Last Commit\n"
},
{
"answer_id": 14260056,
"author": "krevedko",
"author_id": 1785348,
"author_profile": "https://Stackoverflow.com/users/1785348",
"pm_score": 8,
"selected": false,
"text": "git commit --amend -c <commit ID>\n"
},
{
"answer_id": 14391252,
"author": "wallerjake",
"author_id": 1876427,
"author_profile": "https://Stackoverflow.com/users/1876427",
"pm_score": 8,
"selected": false,
"text": "git commit --amend\n git rebase -i [branched_from] [hash before commit]\n git commit --amend git reflog git commit"
},
{
"answer_id": 14464406,
"author": "Shoaib Ud-Din",
"author_id": 1613679,
"author_profile": "https://Stackoverflow.com/users/1613679",
"pm_score": 8,
"selected": false,
"text": "$ git rebase bbc643cd^ --interactive\n $ git add <filepattern>\n $ git commit --amend\n $ git rebase --continue\n"
},
{
"answer_id": 15669052,
"author": "skin",
"author_id": 563746,
"author_profile": "https://Stackoverflow.com/users/563746",
"pm_score": 8,
"selected": false,
"text": "git commit --amend\n git commit --amend"
},
{
"answer_id": 18048546,
"author": "Havard Graff",
"author_id": 1856278,
"author_profile": "https://Stackoverflow.com/users/1856278",
"pm_score": 7,
"selected": false,
"text": "git rebase -i origin/master"
},
{
"answer_id": 20338254,
"author": "Radu Murzea",
"author_id": 995822,
"author_profile": "https://Stackoverflow.com/users/995822",
"pm_score": 7,
"selected": false,
"text": "git reset --soft HEAD~1\ngit commit -m 'New and corrected commit message'\n --soft --hard"
},
{
"answer_id": 20945012,
"author": "Chu-Siang Lai",
"author_id": 686105,
"author_profile": "https://Stackoverflow.com/users/686105",
"pm_score": 6,
"selected": false,
"text": "reci recm recommit (amend) git recm git recm -m $ vim ~/.gitconfig\n\n[alias]\n\n ......\n cm = commit\n reci = commit --amend\n recm = commit --amend\n ......\n"
},
{
"answer_id": 20960146,
"author": "Shubham Chaudhary",
"author_id": 2670370,
"author_profile": "https://Stackoverflow.com/users/2670370",
"pm_score": 7,
"selected": false,
"text": "git commit --amend\n git commit --amend -m 'one line message'\n git rebase -i <hash of one commit before the wrong commit>\n edit/e git commit --amend\n git rebase --continue\n"
},
{
"answer_id": 21278288,
"author": "przbadu",
"author_id": 2553311,
"author_profile": "https://Stackoverflow.com/users/2553311",
"pm_score": 7,
"selected": false,
"text": "git commit --amend -m \"your new commit message\"\n # You can reset your head to n number of commit\n# NOT a good idea for changing last commit message,\n# but you can get an idea to split commit into multiple commits\ngit reset --soft HEAD^\n\n# It will reset you last commit. Now, you\n# can re-commit it with new commit message.\n git reset # Reset your head. I am resetting to last commits:\ngit reset --soft HEAD^\n# (You can reset multiple commit by doing HEAD~2(no. of commits)\n\n# Now, reset your head for splitting it to multiple commits\ngit reset HEAD\n\n# Add and commit your files separately to make multiple commits: e.g\ngit add app/\ngit commit -m \"add all files in app directory\"\n\ngit add config/\ngit commit -m \"add all files in config directory\"\n"
},
{
"answer_id": 23824606,
"author": "David Ongaro",
"author_id": 2727750,
"author_profile": "https://Stackoverflow.com/users/2727750",
"pm_score": 7,
"selected": false,
"text": "--only -o commit --amend git commit --amend -o -m \"New commit message\"\n $EDITOR -m"
},
{
"answer_id": 24843054,
"author": "neoneye",
"author_id": 78336,
"author_profile": "https://Stackoverflow.com/users/78336",
"pm_score": 6,
"selected": false,
"text": "git commit --amend -m \"T-1000, advanced prototype\"\ngit push --force\n"
},
{
"answer_id": 25178676,
"author": "Marijn",
"author_id": 3510188,
"author_profile": "https://Stackoverflow.com/users/3510188",
"pm_score": 7,
"selected": false,
"text": "git rebase -i HEAD~5\n pick <commit hash> commit message\n pick reword i reword pick : wq :wq git push --force git push --force"
},
{
"answer_id": 25720830,
"author": "Kedar Adhikari",
"author_id": 3600772,
"author_profile": "https://Stackoverflow.com/users/3600772",
"pm_score": 6,
"selected": false,
"text": "git status git add --all git commit -am \"message goes here about the change\" git pull <origin master> git push <origin master>"
},
{
"answer_id": 26782560,
"author": "Steve Chambers",
"author_id": 1063716,
"author_profile": "https://Stackoverflow.com/users/1063716",
"pm_score": 7,
"selected": false,
"text": "Unable to create 'project_path/.git/index.lock': File exists. git push origin <branch> -f"
},
{
"answer_id": 27916548,
"author": "Prabhakar Undurthi",
"author_id": 2200417,
"author_profile": "https://Stackoverflow.com/users/2200417",
"pm_score": 6,
"selected": false,
"text": " git commit --amend -m \"Your new message\"\n git commit --amend -m \"BRANCH-NAME: new message\"\n git commit --amend -m \"BRANCH-NAME : your new message\"\n\ngit push -f origin BRANCH-NAME # Not a best practice. Read below why?\n git commit --amend -m \"BRANCH-NAME : your new message\"\n git pull origin BRANCH-NAME\n git push -f origin BRANCH-NAME\n"
},
{
"answer_id": 28421811,
"author": "Zaz",
"author_id": 405550,
"author_profile": "https://Stackoverflow.com/users/405550",
"pm_score": 8,
"selected": false,
"text": "git commit --amend -o -m \"New commit message\"\n -o --only git rebase -i @~9 # Show the last 9 commits in a text editor\n pick r reword 3j cw r ZZ vimtutor h j k l 3j i c u r dd dw dl cc cw cl dd i yy yw yl p P :w :q! :wq ZZ $ git reset @~3 # Go back three commits\n$ git reflog\nc4f708b HEAD@{0}: reset: moving to @~3\n2c52489 HEAD@{1}: commit: more changes\n4a5246d HEAD@{2}: commit: make important changes\ne8571e4 HEAD@{3}: commit: make some changes\n... earlier commits ...\n$ git reset 2c52489\n... and you're back where you started\n --hard --force"
},
{
"answer_id": 28645738,
"author": "albfan",
"author_id": 848072,
"author_profile": "https://Stackoverflow.com/users/848072",
"pm_score": 6,
"selected": false,
"text": "commit --amend $ git rebase-reword <commit-or-refname>\n $ git rebase-reword b68f560\n$ git rebase-reword HEAD^\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7473/"
] |
179,128
|
<p>I'm starting a project which requires reading outlook msg files in c#. I have the specs for compound documents but am having trouble reading them in c#. Any pointers would be greatly appreciated.</p>
<p>Thanks.</p>
|
[
{
"answer_id": 179323,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 5,
"selected": true,
"text": "namespace cs_console_app\n{\n using System;\n using System.Runtime.InteropServices;\n using System.Runtime.InteropServices.ComTypes;\n\n [ComImport]\n [Guid(\"0000000d-0000-0000-C000-000000000046\")]\n [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]\n public interface IEnumSTATSTG\n {\n // The user needs to allocate an STATSTG array whose size is celt.\n [PreserveSig]\n uint Next(\n uint celt,\n [MarshalAs(UnmanagedType.LPArray), Out]\n System.Runtime.InteropServices.ComTypes.STATSTG[] rgelt,\n out uint pceltFetched\n );\n\n void Skip(uint celt);\n\n void Reset();\n\n [return: MarshalAs(UnmanagedType.Interface)]\n IEnumSTATSTG Clone();\n }\n\n [ComImport]\n [Guid(\"0000000b-0000-0000-C000-000000000046\")]\n [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]\n interface IStorage\n {\n void CreateStream(\n /* [string][in] */ string pwcsName,\n /* [in] */ uint grfMode,\n /* [in] */ uint reserved1,\n /* [in] */ uint reserved2,\n /* [out] */ out IStream ppstm);\n\n void OpenStream(\n /* [string][in] */ string pwcsName,\n /* [unique][in] */ IntPtr reserved1,\n /* [in] */ uint grfMode,\n /* [in] */ uint reserved2,\n /* [out] */ out IStream ppstm);\n\n void CreateStorage(\n /* [string][in] */ string pwcsName,\n /* [in] */ uint grfMode,\n /* [in] */ uint reserved1,\n /* [in] */ uint reserved2,\n /* [out] */ out IStorage ppstg);\n\n void OpenStorage(\n /* [string][unique][in] */ string pwcsName,\n /* [unique][in] */ IStorage pstgPriority,\n /* [in] */ uint grfMode,\n /* [unique][in] */ IntPtr snbExclude,\n /* [in] */ uint reserved,\n /* [out] */ out IStorage ppstg);\n\n void CopyTo(\n /* [in] */ uint ciidExclude,\n /* [size_is][unique][in] */ Guid rgiidExclude, // should this be an array?\n /* [unique][in] */ IntPtr snbExclude,\n /* [unique][in] */ IStorage pstgDest);\n\n void MoveElementTo(\n /* [string][in] */ string pwcsName,\n /* [unique][in] */ IStorage pstgDest,\n /* [string][in] */ string pwcsNewName,\n /* [in] */ uint grfFlags);\n\n void Commit(\n /* [in] */ uint grfCommitFlags);\n\n void Revert();\n\n void EnumElements(\n /* [in] */ uint reserved1,\n /* [size_is][unique][in] */ IntPtr reserved2,\n /* [in] */ uint reserved3,\n /* [out] */ out IEnumSTATSTG ppenum);\n\n void DestroyElement(\n /* [string][in] */ string pwcsName);\n\n void RenameElement(\n /* [string][in] */ string pwcsOldName,\n /* [string][in] */ string pwcsNewName);\n\n void SetElementTimes(\n /* [string][unique][in] */ string pwcsName,\n /* [unique][in] */ System.Runtime.InteropServices.ComTypes.FILETIME pctime,\n /* [unique][in] */ System.Runtime.InteropServices.ComTypes.FILETIME patime,\n /* [unique][in] */ System.Runtime.InteropServices.ComTypes.FILETIME pmtime);\n\n void SetClass(\n /* [in] */ Guid clsid);\n\n void SetStateBits(\n /* [in] */ uint grfStateBits,\n /* [in] */ uint grfMask);\n\n void Stat(\n /* [out] */ out System.Runtime.InteropServices.ComTypes.STATSTG pstatstg,\n /* [in] */ uint grfStatFlag);\n\n }\n\n [Flags]\n public enum STGM : int\n {\n DIRECT = 0x00000000,\n TRANSACTED = 0x00010000,\n SIMPLE = 0x08000000,\n READ = 0x00000000,\n WRITE = 0x00000001,\n READWRITE = 0x00000002,\n SHARE_DENY_NONE = 0x00000040,\n SHARE_DENY_READ = 0x00000030,\n SHARE_DENY_WRITE = 0x00000020,\n SHARE_EXCLUSIVE = 0x00000010,\n PRIORITY = 0x00040000,\n DELETEONRELEASE = 0x04000000,\n NOSCRATCH = 0x00100000,\n CREATE = 0x00001000,\n CONVERT = 0x00020000,\n FAILIFTHERE = 0x00000000,\n NOSNAPSHOT = 0x00200000,\n DIRECT_SWMR = 0x00400000,\n }\n\n public enum STATFLAG : uint\n {\n STATFLAG_DEFAULT = 0,\n STATFLAG_NONAME = 1,\n STATFLAG_NOOPEN = 2\n }\n\n public enum STGTY : int\n {\n STGTY_STORAGE = 1,\n STGTY_STREAM = 2,\n STGTY_LOCKBYTES = 3,\n STGTY_PROPERTY = 4\n }\n\n class Program\n {\n [DllImport(\"ole32.dll\")]\n private static extern int StgIsStorageFile(\n [MarshalAs(UnmanagedType.LPWStr)] string pwcsName);\n\n [DllImport(\"ole32.dll\")]\n static extern int StgOpenStorage(\n [MarshalAs(UnmanagedType.LPWStr)] string pwcsName,\n IStorage pstgPriority,\n STGM grfMode,\n IntPtr snbExclude,\n uint reserved,\n out IStorage ppstgOpen);\n\n static void Main(string[] args)\n {\n string filename = @\"f:\\temp\\treta2.msg\";\n if (StgIsStorageFile(filename) == 0)\n {\n IStorage storage = null;\n if (StgOpenStorage(\n filename,\n null,\n STGM.DIRECT | STGM.READ | STGM.SHARE_EXCLUSIVE,\n IntPtr.Zero,\n 0,\n out storage) == 0)\n {\n System.Runtime.InteropServices.ComTypes.STATSTG statstg;\n storage.Stat(out statstg, (uint) STATFLAG.STATFLAG_DEFAULT);\n\n IEnumSTATSTG pIEnumStatStg = null;\n storage.EnumElements(0, IntPtr.Zero, 0, out pIEnumStatStg);\n\n System.Runtime.InteropServices.ComTypes.STATSTG[] regelt = { statstg };\n uint fetched = 0;\n uint res = pIEnumStatStg.Next(1, regelt, out fetched);\n\n if (res == 0)\n {\n while (res != 1)\n {\n string strNode = statstg.pwcsName;\n bool bNodeFound = false;\n\n Console.WriteLine(strNode);\n\n if (strNode == \"__substg1.0_0E04001E\"\n || strNode == \"__substg1.0_0E1D001E\"\n || strNode == \"__substg1.0_1000001E\"\n || strNode == \"__substg1.0_1013001E\")\n {\n bNodeFound = true;\n }\n\n if (bNodeFound)\n {\n switch (statstg.type)\n {\n case (int) STGTY.STGTY_STORAGE:\n {\n IStorage pIChildStorage;\n storage.OpenStorage(statstg.pwcsName,\n null,\n (uint) (STGM.READ | STGM.SHARE_EXCLUSIVE),\n IntPtr.Zero,\n 0,\n out pIChildStorage);\n }\n break;\n case (int) STGTY.STGTY_STREAM:\n {\n IStream pIStream;\n storage.OpenStream(statstg.pwcsName,\n IntPtr.Zero,\n (uint)(STGM.READ | STGM.SHARE_EXCLUSIVE),\n 0,\n out pIStream);\n\n byte[] data = new byte[255];\n\n pIStream.Read(data, 255, IntPtr.Zero);\n }\n break;\n }\n }\n\n if ((res = pIEnumStatStg.Next(1, regelt, out fetched)) != 1)\n {\n statstg = regelt[0];\n }\n }\n }\n }\n }\n\n Console.ReadLine();\n }\n }\n}\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16834/"
] |
179,173
|
<p>I have an XmlDocument that already exists and is read from a file. </p>
<p>I would like to add a chunk of Xml to a node in the document. Is there a good way to create and add all the nodes without cluttering my code with many .CreateNote and .AppendChild calls?</p>
<p>I would like some way of making a string or stringBuilder of a valid Xml section and just appending that to an XmlNode.</p>
<p>ex:
Original XmlDoc:</p>
<pre><code><MyXml>
<Employee>
</Employee>
</MyXml>
</code></pre>
<p>and, I would like to add a Demographic (with several children) tag to Employee:</p>
<pre><code><MyXml>
<Employee>
<Demographic>
<Age/>
<DOB/>
</Demographic>
</Employee>
</MyXml>
</code></pre>
|
[
{
"answer_id": 179191,
"author": "user7116",
"author_id": 7116,
"author_profile": "https://Stackoverflow.com/users/7116",
"pm_score": 8,
"selected": true,
"text": "XmlDocument xdoc = new XmlDocument();\nxdoc.LoadXml(@\"<MyXml><Employee></Employee></MyXml>\");\n\nXmlDocumentFragment xfrag = xdoc.CreateDocumentFragment();\nxfrag.InnerXml = @\"<Demographic><Age/><DOB/></Demographic>\";\n\nxdoc.DocumentElement.FirstChild.AppendChild(xfrag);\n"
},
{
"answer_id": 179198,
"author": "Panos",
"author_id": 8049,
"author_profile": "https://Stackoverflow.com/users/8049",
"pm_score": 4,
"selected": false,
"text": "employeeNode.InnerXml = \"<Demographic><Age/><DOB/></Demographic>\";\n employeeNode.AppendChild(employeeNode.OwnerDocument.ImportNode(otherXmlDocument.DocumentElement, true));\n"
},
{
"answer_id": 179309,
"author": "Echostorm",
"author_id": 12862,
"author_profile": "https://Stackoverflow.com/users/12862",
"pm_score": 3,
"selected": false,
"text": " XDocument doc = XDocument.Load(@\"c:\\temp\\test.xml\");\n XElement demoNode = new XElement(\"Demographic\");\n demoNode.Add(new XElement(\"Age\"));\n demoNode.Add(new XElement(\"DOB\"));\n doc.Descendants(\"Employee\").Single().Add(demoNode);\n doc.Save(@\"c:\\temp\\test2.xml\");\n"
},
{
"answer_id": 514370,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "myDataset.ReadXML(path and file name) myDataset.WriteXML(path and file name)"
},
{
"answer_id": 39797079,
"author": "Peter Gruppelaar",
"author_id": 3790025,
"author_profile": "https://Stackoverflow.com/users/3790025",
"pm_score": 0,
"selected": false,
"text": "string Path = Directory.GetCurrentDirectory() + \"/2016\";\n string pathFile = Path + \"/klanten.xml\";\n StreamReader sr = new StreamReader(pathFile);\n txt.Text = sr.ReadToEnd();\n sr.Close();\n string name = Globals.s_Name;\n string klanten = txt.Text;\n string s = klanten;\n XmlDocument xdoc = new XmlDocument();\n\n string klant = \"<voornaam>\" + naamBox1.Text + \"</voornaam>\";\n xdoc.LoadXml(s);\n XmlDocumentFragment xfrag = xdoc.CreateDocumentFragment();\n xfrag.InnerXml = klant;\n xdoc.DocumentElement.FirstChild.AppendChild(xfrag);\n xdoc.Save(name + \"/klanten.xml\");\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2871/"
] |
179,213
|
<p>This is a multiple question for the same pre-processing instruction.</p>
<h2>1 - <> or "" ?</h2>
<p>Apart from the info found in the MSDN:</p>
<p><a href="https://msdn.microsoft.com/en-us/library/36k2cdd4.aspx" rel="noreferrer" title="#include Directive (C-C++)">#include Directive (C-C++)</a></p>
<p>1.a: What are the differences between the two notations?<br>
1.b: Do all compilers implement them the same way?<br>
1.c: When would you use the <>, and when would you use the "" (i.e. what are the criteria you would use to use one or the other for a header include)?<br></p>
<h2>2 - #include {TheProject/TheHeader.hpp} or {TheHeader.hpp} ?</h2>
<p>I've seen at least two ways of writing includes of one's project headers.
Considering that you have at least 4 types of headers, that is:</p>
<ul>
<li>private headers of your project?</li>
<li>headers of your project, but which are exporting symbols (and thus, "public")</li>
<li>headers of another project your module links with</li>
<li>headers of a compiler or standard library</li>
</ul>
<p>For each kind of headers:</p>
<p>2.a: Would you use <> or "" ?<br>
2.b: Would you include with {TheProject/TheHeader.hpp}, or with {TheHeader.hpp} only?<br></p>
<h2>3 - Bonus</h2>
<p>3.a: Do you work on project with sources and/or headers within a tree-like organisation (i.e., directories inside directories, as opposed to "every file in one directory") and what are the pros/cons?</p>
|
[
{
"answer_id": 179248,
"author": "Evan Teran",
"author_id": 13430,
"author_profile": "https://Stackoverflow.com/users/13430",
"pm_score": 3,
"selected": false,
"text": "#include <SDL/whatever.h>\n #include <sys/io.h>\n#include <linux/limits.h>\n"
},
{
"answer_id": 179261,
"author": "coppro",
"author_id": 16855,
"author_profile": "https://Stackoverflow.com/users/16855",
"pm_score": 1,
"selected": false,
"text": "<> \"\" #include <bla\"file.cpp> \"bla>file.cpp\" \"\" <> #include \"iostream\" #include <iostream> \"\" <> <> \"\" <> <boost/preprocessor.hpp> <wx/window.h> <Magic++.h> -I #include \"public_header.hpp\" \"src/private_header.hpp\" \"module\\_text\\_processor.hpp\" \"module/text\\_processor.hpp\""
},
{
"answer_id": 179262,
"author": "Trent",
"author_id": 9083,
"author_profile": "https://Stackoverflow.com/users/9083",
"pm_score": 2,
"selected": false,
"text": "<project/libHeader.h> \"myHeader.h\" <project/libHeader.h> <libHeader.h>"
},
{
"answer_id": 179436,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 3,
"selected": false,
"text": "# include \"q-char-sequence\" new-line # include <h-char-sequence> new-line #include \"whatever\" #include <whatever> #include <> #include \"\""
},
{
"answer_id": 179786,
"author": "John Dibling",
"author_id": 241536,
"author_profile": "https://Stackoverflow.com/users/241536",
"pm_score": 1,
"selected": false,
"text": "#include \"c:\\utils\\mylib\\mylibrary.h\"\n\nint main()\n{\n return 0;\n}\n #ifndef MYLIB_H\n#define MYLIB_H\n\n#include <speech.h>\n\nnamespace mylib\n{\n void Speak(SpeechType speechType); \n};\n\n#endif\n #ifndef SPEECH_H\n#define SPEECH_H\n\nnamespace mylib\n{\n enum SpeechType {Bark, Growl};\n};\n\n#endif\n #include <speech.h> mylibrary.h #include \"x:\\utils\\mylib.h\" #include \"c:\\utils_1.0\\mylib.h\""
},
{
"answer_id": 1251308,
"author": "paercebal",
"author_id": 14089,
"author_profile": "https://Stackoverflow.com/users/14089",
"pm_score": 5,
"selected": false,
"text": "#include <namespace/header.hpp>\n #include <h-char-sequence> new-line\n #include \"q-char-sequence\" new-line\n #include <h-char-sequence> new-line\n <...> \"...\" <file> <MyFile.hpp> #include <MyLocalProject/Header.hpp>\n #include <GlobalInclude/Header.hpp>\n #include \"Header.hpp\"\n #include <Header.hpp>\n #include <cstdlib>\n#include <vector>\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179213",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14089/"
] |
179,223
|
<p>I want to add my own member to the StringBuilder class, but when I go to create it IntelliSense doesn't bring it up.</p>
<pre><code>public class myStringBuilder()
Inherits System.Text.[StringBuilder should be here]
....
end class
</code></pre>
<p>Is it even possible? thanks</p>
|
[
{
"answer_id": 179240,
"author": "Jeff Yates",
"author_id": 23234,
"author_profile": "https://Stackoverflow.com/users/23234",
"pm_score": 5,
"selected": true,
"text": "StringBuilder NotInheritable sealed StringBuilder"
},
{
"answer_id": 179406,
"author": "Jeff B",
"author_id": 25879,
"author_profile": "https://Stackoverflow.com/users/25879",
"pm_score": 1,
"selected": false,
"text": "myStringBuilder.MyExtensionMethod(etc...); StringBuilderExtensions.MyExtensionMethod(myStringBuilder, etc...);"
},
{
"answer_id": 179728,
"author": "Anders",
"author_id": 25515,
"author_profile": "https://Stackoverflow.com/users/25515",
"pm_score": 2,
"selected": false,
"text": "Imports System.Runtime.CompilerServices\nModule sbExtension\n <Extension()> _\n Public Sub AppendFormattedLine(ByVal oStr As System.Text.StringBuilder, _\n ByVal format As String, _\n ByVal arg0 As Object)\n oStr.AppendFormat(\"{0}{1}\", String.Format(format, arg0), ControlChars.NewLine)\n End Sub\n <Extension()> _\n Public Sub AppendFormattedLine(ByVal oStr As System.Text.StringBuilder, _\n ByVal format As String, ByVal arg0 As Object, _\n ByVal arg1 As Object)\n oStr.AppendFormat(\"{0}{1}\", String.Format(format, arg0, arg1), ControlChars.NewLine)\n End Sub\n <Extension()> _\n Public Sub AppendFormattedLine(ByVal oStr As System.Text.StringBuilder, _\n ByVal format As String, _\n ByVal arg0 As Object, _\n ByVal arg1 As Object, _\n ByVal arg2 As Object)\n oStr.AppendFormat(\"{0}{1}\", String.Format(format, arg0, arg1, arg2), ControlChars.NewLine)\n End Sub\n <Extension()> _\n Public Sub AppendFormattedLine(ByVal oStr As System.Text.StringBuilder, _\n ByVal format As String, _\n ByVal ParamArray args() As Object)\n oStr.AppendFormat(\"{0}{1}\", String.Format(format, args), ControlChars.NewLine)\n End Sub\nEnd Module\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25515/"
] |
179,254
|
<p>Has anyone got this working in a web application? </p>
<p>No matter what I do it seems that my appSettings section (redirected from web.config using appSettings file=".\Site\site.config") does not get reloaded. </p>
<p>Am I doomed to the case of having to just restart the application? I was hoping this method would lead me to a more performant solution.</p>
<p>Update:</p>
<p>By 'reloading' I mean refreshing ConfigurationManager.AppSettings without having to completely restart my ASP.NET application and having to incur the usual startup latency.</p>
|
[
{
"answer_id": 494972,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": -1,
"selected": false,
"text": "Dim config As System.Configuration.Configuration = WebConfigurationManager.OpenWebConfiguration(\"~\")\n Return config.AppSettings.Settings(\"TheKeyYouWantTheValue\").Value\n Protected Shared Function AddOrUpdateAppSetting( _\n ByVal Config As System.Configuration.Configuration _\n , ByVal TheKey As String _\n , ByVal TheValue As String _\n ) As Boolean</p>\n\n Dim retval As Boolean = True\n\n Dim Itm As System.Configuration.KeyValueConfigurationElement = _\n Config.AppSettings.Settings.Item(TheKey)\n If Itm Is Nothing Then\n If Config.AppSettings.Settings.IsReadOnly Then\n retval = False\n Else\n Config.AppSettings.Settings.Add(TheKey, TheValue)\n End If\n\n\n Else\n ' config.AppSettings.Settings(thekey).Value = thevalue\n If Itm.IsReadOnly Then\n retval = False\n Else\n Itm.Value = TheValue\n End If\n\n\n End If\n If retval Then\n Try\n Config.Save(ConfigurationSaveMode.Modified)\n\n Catch ex As Exception\n retval = False\n End Try\n\n End If\n\n Return retval\n\nEnd Function\n"
},
{
"answer_id": 1592129,
"author": "G-Wiz",
"author_id": 29805,
"author_profile": "https://Stackoverflow.com/users/29805",
"pm_score": 7,
"selected": true,
"text": "ConfigurationManager.RefreshSection(\"appSettings\");\n"
},
{
"answer_id": 2595281,
"author": "Vince",
"author_id": 291719,
"author_profile": "https://Stackoverflow.com/users/291719",
"pm_score": -1,
"selected": false,
"text": "<appSettings configSource=\"appSettings.config\"></appSettings>\n <?xml version=\"1.0\"?>\n<appSettings>\n <add key=\"SomeKey\" value=\"SomeValue\" />\n</appSettings>\n"
},
{
"answer_id": 8481926,
"author": "Martin Meixger",
"author_id": 64466,
"author_profile": "https://Stackoverflow.com/users/64466",
"pm_score": 2,
"selected": false,
"text": "ConfigSection restartOnExternalChanges=\"false\" ConfigurationManager.GetSection(\"yourSection\")"
},
{
"answer_id": 15218973,
"author": "Willem van Ketwich",
"author_id": 512965,
"author_profile": "https://Stackoverflow.com/users/512965",
"pm_score": 3,
"selected": false,
"text": "ConfigurationManager.RefreshSection(\"appSettings\") ExeConfigurationFileMap configMap = new ExeConfigurationFileMap();\nUri uriAssemblyFolder = new Uri(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase));\nstring appPath = uriAssemblyFolder.LocalPath;\nconfigMap.ExeConfigFilename = appPath + @\"\\..\\\" + \"Web.config\";\nConfiguration config = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None); \n string webConfigVariable = config.AppSettings.Settings[\"webConfigVariable\"].Value;\n"
},
{
"answer_id": 41505562,
"author": "Allie",
"author_id": 1986822,
"author_profile": "https://Stackoverflow.com/users/1986822",
"pm_score": 2,
"selected": false,
"text": "ConfigurationManager.AppSettings.Set(key, value)\n string configFile=\"path to your config file\";\nXmlDocument xml = new XmlDocument();\nxml.Load(configFile);\n\nforeach (XmlNode node in xml.SelectNodes(\"/appSettings/add\"))\n{\n string key = node.Attributes[\"key\"].Value;\n string value= node.Attributes[\"value\"].Value;\n ConfigurationManager.AppSettings.Set(key, value);\n}\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5777/"
] |
179,255
|
<p>If I have an Address object which implements IEditableObject, I might have EndEdit implementation like this:</p>
<pre><code>public void EndEdit()
{
// BeginEdit would set _editInProgress and update *Editing fields;
if (_editInProgress)
{
_line1 = _line1Editing;
_line2 = _line2Editing;
_city = _cityEditing;
_state = _stateEditing;
_postalCode = _postalCodeEditing;
_editInProgress = false;
}
}
</code></pre>
<p>If there is an exception updating <strong><em>_state</em></strong>, for example, then all 5 properties should reset. This atomic update issue probably isn't limited to EndEdit.</p>
|
[
{
"answer_id": 179458,
"author": "akmad",
"author_id": 1314,
"author_profile": "https://Stackoverflow.com/users/1314",
"pm_score": 1,
"selected": false,
"text": "try {\n //do stuff\n}\ncatch (Exception ex) {\n //reset\n\n //rethrow exception\n throw;\n}\n"
},
{
"answer_id": 3260716,
"author": "Jonathan Allen",
"author_id": 5274,
"author_profile": "https://Stackoverflow.com/users/5274",
"pm_score": 0,
"selected": false,
"text": "Friend Sub BeginEdit()\n m_Backup = New Dictionary(Of String, Object)(m_DataPoints, StringComparer.OrdinalIgnoreCase)\nEnd Sub\n\nFriend Sub CancelEdit()\n If m_Backup IsNot Nothing Then m_DataPoints = m_Backup\nEnd Sub\n\nFriend Sub EndEdit()\n m_Backup = Nothing\nEnd Sub\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25856/"
] |
179,259
|
<p>In my app I have these Hibernate-mapped types (general case):</p>
<pre><code>class RoleRule {
private Role role;
private PermissionAwareEntity entity; // hibernate-mapped entity for which permission is granted
private PermissionType permissionType; // enum
@ManyToOne
@JoinColumn(name = "ROLE_ID")
public Role getRole() {
return role;
}
public void setRole(Role role) {
this.role = role;
}
}
class Role {
private Set<RoleRule> rules = new HashSet<RoleRule>(0);
@OneToMany(cascade=CascadeType.ALL)
@JoinColumn(name="ROLE_ID")
public Set<RoleRule> getRules() {
return rules;
}
public void setRules(Set<RoleRule> rules) {
this.rules = rules;
}
}
</code></pre>
<p>All classes have <code>equals() & hashCode()</code> overrides.</p>
<p>My application allows tweaking of roles (by sysadmins only, don't worry), and among other fields, allows creation of new role rules. When a new rule is created I try to create a new <code>RoleRule</code> object and insert it into the role's field <code>rules</code>. I call <code>session.update(role)</code> to apply the changes to the database.</p>
<p>Now comes the ugly part... Hibernate decides to do the following when closing the transaction and flushing:</p>
<ol>
<li>Insert the new rule into the database. Excellent.</li>
<li>Update the other role fields (not collections). So far so good.</li>
<li>Update the existing rules, even if nothing has changed in them. I can live with this.</li>
<li>Update the existing rules <em>again</em>. Here's a paste from the log, including the automatic comment:<br></li>
</ol>
<pre>/* delete one-to-many row Role.rules */
update ROLE_RULE set ROLE_ID=null where ROLE_ID=? and ROLE_RULE_ID=?</pre>
<p>Of course, all fields are not-null, and this operation fails spectacularly.</p>
<p>Can anyone try to explain why Hibernate would do this??? And even more important, how the frak do I get around this???</p>
<p><strong>EDIT</strong>: I was so sure it was something to do with the mapping, and then my boss, on a whim, deleted the <code>equals()</code> and <code>hashCode()</code> in both classes, recreated them using Eclipse, and mysteriously this solved the problem.</p>
<p>I'm still very curious about my question though. Can anyone suggest why Hibernate would do this?</p>
|
[
{
"answer_id": 179324,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 2,
"selected": false,
"text": "@OneToMany(mappedBy = \"role\")\n @Entity\n@org.hibernate.annotations.Entity(\n dynamicInsert = true, dynamicUpdate = true\n)\n"
},
{
"answer_id": 179524,
"author": "Brian Deterling",
"author_id": 14619,
"author_profile": "https://Stackoverflow.com/users/14619",
"pm_score": 3,
"selected": false,
"text": "copy the list of existing records to a list_to_delete\nfor each record from the form\n remove it from the list_to_delete\n if the record exists (based on equals()? key?)\n change each field that the user can enter\n else if the record doesn't exist\n add it to the collection\nend for\nfor each list_to_delete\n remove it\nend for\nsave\n"
},
{
"answer_id": 49102915,
"author": "Jeya Balaji",
"author_id": 5338935,
"author_profile": "https://Stackoverflow.com/users/5338935",
"pm_score": -1,
"selected": false,
"text": "// snFile and task share many to many relationship\n\n@PersistenceContext\nprivate EntityManager em;\n\npublic SnFile merge(SnFile snFile) {\n log.debug(\"Request to merge SnFile : {}\", snFile);\n\n Set<Task> tasks = taskService.findBySnFilesId(snFile.getId());\n if(snFile.getTasks() != null) {\n snFile.getTasks().clear();\n }\n em.merge(snFile);\n em.flush();\n if(tasks != null) {\n if(snFile.getTasks() != null)\n snFile.getTasks().addAll(tasks);\n else\n snFile.setTasks(tasks);\n }\n\n return em.merge(snFile);\n }\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2819/"
] |
179,264
|
<p>I have an ASP.Net 3.5 platform and windows 2003 server with all the updates. </p>
<p>There is a limit with .Net that it cannot handle more than <a href="http://forums.iis.net/p/1105360/1689855.aspx" rel="noreferrer">260 characters</a>. Moreover if you look it up on web, you will find that IE 6 fails to work if it is not patched at above 100 charcters. </p>
<p>I want to have the rewrite path module to be supported on maximum number of browsers, so I am looking for an acceptable limit to which I can create verbose URL's.</p>
|
[
{
"answer_id": 179283,
"author": "Adam Davis",
"author_id": 2915,
"author_profile": "https://Stackoverflow.com/users/2915",
"pm_score": 2,
"selected": false,
"text": " Note: Servers ought to be cautious about depending on URI\n lengths above 255 bytes, because some older client or proxy\n implementations might not properly support these lengths.\n"
},
{
"answer_id": 180183,
"author": "Robert Paulson",
"author_id": 14033,
"author_profile": "https://Stackoverflow.com/users/14033",
"pm_score": 4,
"selected": true,
"text": "http://somewhere.com/directory/filename.aspx?id=1234\n ^^^^^^^- querystring\n ^^^^^^^^^^^^^^^^^^^^^^^^ -------- path\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9498/"
] |
179,287
|
<p>Let's say I have an existing trivial XML file named 'MyData.xml' that contains the following:</p>
<pre><code><?xml version="1.0" encoding="utf-8" ?>
<myElement>foo</myElement>
</code></pre>
<p>I want to change the text value of 'foo' to 'bar' resulting in the following:</p>
<pre><code><?xml version="1.0" encoding="utf-8" ?>
<myElement>bar</myElement>
</code></pre>
<p>Once I am done, I want to save the changes. </p>
<p>What is the easiest and simplest way to accomplish all this?</p>
|
[
{
"answer_id": 179305,
"author": "Javier",
"author_id": 11649,
"author_profile": "https://Stackoverflow.com/users/11649",
"pm_score": 2,
"selected": false,
"text": "import p4x\ndoc = p4x.P4X (open(file).read)\ndoc.myElement = 'bar'\n"
},
{
"answer_id": 180433,
"author": "Ray",
"author_id": 4872,
"author_profile": "https://Stackoverflow.com/users/4872",
"pm_score": 2,
"selected": false,
"text": "from xml.dom.minidom import parse\nimport os\n\n# create a backup of original file\nnew_file_name = 'MyData.xml'\nold_file_name = new_file_name + \"~\"\nos.rename(new_file_name, old_file_name)\n\n# change text value of element\ndoc = parse(old_file_name)\nnode = doc.getElementsByTagName('myElement')\nnode[0].firstChild.nodeValue = 'bar'\n\n# persist changes to new file\nxml_file = open(new_file_name, \"w\")\ndoc.writexml(xml_file, encoding=\"utf-8\")\nxml_file.close()\n"
},
{
"answer_id": 180564,
"author": "machineghost",
"author_id": 5921,
"author_profile": "https://Stackoverflow.com/users/5921",
"pm_score": 1,
"selected": false,
"text": "record = doc.xml_create_element(u'Record')\n\nnameElem = doc.xml_create_element(u'Name', content=unicode(name))\n\nrecord.xml_append(nameElem)\n\nvalueElem = doc.xml_create_element(u'Value', content=unicode(value))\n\nrecord.xml_append(valueElem\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179287",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] |
179,288
|
<p>Say I have 3 frames in a frameset arranged in 3 rows. Frames 1 and 3 are from my site and frame 2 (the central one) is from an external website. Is there a cunning way to force the browser to centre align the data in frame 2?</p>
<p>I've found a small work-around which uses a frameset within a frameset which has 2 blank columns either side of the data but that means the scrollbars from frames 2 and 3 are out of alignment.</p>
<p>Any ideas?</p>
<p>Edit : The code I have currently is : </p>
<pre>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server" />
<frameset rows="10%,65%,25%" border=0 frameborder="no">
<frame name="nav" noresize scrolling="no" src='NavigationBar.aspx?NAVIGATION=<%=sDisplayNavigation %>'>
<frameset cols="1*,1010px,1*">
<frame name="lspace" scrolling="no" src="border.htm">
<frame name= "main" scrolling="auto" src='<%=sMainTextURL%>#highlight'>
<frame name="rspace" scrolling="no" src="border.htm">
</frameset>
<frame name="suggest" scrolling="yes" noresize src='<%=sSuggestURL%>'>
</frameset>
</html>
</pre>
|
[
{
"answer_id": 73977121,
"author": "Christopher M",
"author_id": 20177451,
"author_profile": "https://Stackoverflow.com/users/20177451",
"pm_score": 1,
"selected": false,
"text": "<frameset rows=\"10%,65,25%\" border=0 frameborder=\"no\">\n <frameset rows=\"10%,65px,25%\" border=0 frameborder=\"no\">\n <frameset rows=\"36px,80%,36px\" frameborder=1 border=3> \n <frame src=\"frame1.html\" target=\"frame2.html\" noresize>\n\n <frame name=frame2 src=\"index.html\"> \n \n <frame src=\"frame3.html\" target=\"frame2.html\" noresize> \n</frameset> \n \"frame1.html\" target=\"frame2.html\" <a title=\"To Homepage\" href=\"index.html\" target=\"frame2\" >Homepage</a> \n <frameset cols=\"140px,100%\" frameborder=1 border=1> \n <frame src=\"frame1.html\" target=\"frame2.html\" noresize>\n <frame name=frame2 src=\"index.html\"> \n</frameset> \n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21299/"
] |
179,291
|
<p>I'm looking to call a subprocess with a file descriptor opened to a given pipe such that the open() call does not hang waiting for the other side of the pipe to receive a connection.</p>
<p>To demonstrate:</p>
<pre><code>$ mkfifo /tmp/foobar.pipe
$ some_program --command-fd=5 5</tmp/foobar.pipe
</code></pre>
<p>In this case, <code>some_program</code> is not run until some process has <code>/tmp/foobar.pipe</code> open for write; however, <code>some_program</code> has useful effects even when it isn't receiving commands, so desired behavior is for <code>some_program</code> to be immediately executed.</p>
<p>Mechanisms to do this by exec'ing through an alternate scripting language (python, perl, etc) or a C wrapper which open <code>/tmp/foobar.pipe</code> with the <code>O_NONBLOCK</code> flag are obvious; I'm looking for a pure-bash solution, should one be possible.</p>
|
[
{
"answer_id": 179345,
"author": "Sec",
"author_id": 20555,
"author_profile": "https://Stackoverflow.com/users/20555",
"pm_score": 2,
"selected": false,
"text": "mkfifo /tmp/foobar.in\nmkfifo /tmp/foobar.out\n( cat </tmp/foobar.in ) >/tmp/foobar.out &\nsome_program --command-fd=5 5</tmp/foobar.out\n"
},
{
"answer_id": 179469,
"author": "Charles Duffy",
"author_id": 14122,
"author_profile": "https://Stackoverflow.com/users/14122",
"pm_score": 4,
"selected": true,
"text": "$ mkfifo /tmp/foobar.pipe\n$ some_program --command-fd=5 5<>/tmp/foobar.pipe\n 5<>/tmp/foobar.pipe 5</tmp/foobar.pipe O_NONBLOCK"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14122/"
] |
179,295
|
<p>I'm implementing a class that wraps around an xml document with a very strictly defined schema. I don't control the schema. </p>
<p>One of the properties in the class is for an element value that the schema indicates must match a certain regular expression. In the setter for the property, if a string doesn't match the expression I'm throwing an exception.</p>
<p>My question is, how can I better communicate to users of my class the requirements for this field? Is there an attribute I can use? Xml comments (so it shows up in intellisense)? Should I do something other than thrown an exception? What other options do I have?</p>
|
[
{
"answer_id": 179312,
"author": "Chris Cudmore",
"author_id": 18907,
"author_profile": "https://Stackoverflow.com/users/18907",
"pm_score": 0,
"selected": false,
"text": "Element <elementname> must match /regex/\n"
},
{
"answer_id": 183090,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 0,
"selected": false,
"text": "Public Class MatchedString\n Public Enum InvalidValueBehaviors\n SetToEmpty\n AllowSetToInvalidValue\n DoNothing\n End Enum\n\n Public Sub New(ByVal Expression As String)\n Me.expression = Expression\n exp = New Regex(Me.expression)\n End Sub\n\n Public Sub New(ByVal Description As String, ByVal Expression As String)\n Me.expression = Expression\n exp = New Regex(Me.expression)\n _expressiondescription = Description\n End Sub\n\n Public Sub New(ByVal Expression As String, ByVal ThrowOnInvalidValue As Boolean, ByVal InvalidValueBehavior As InvalidValueBehaviors)\n Me.expression = Expression\n exp = New Regex(Me.expression)\n Me.ThrowOnInvalidValue = ThrowOnInvalidValue\n Me.InvalidValueBehavior = InvalidValueBehavior\n End Sub\n\n Public Sub New(ByVal Description As String, ByVal Expression As String, ByVal ThrowOnInvalidValue As Boolean, ByVal InvalidValueBehavior As InvalidValueBehaviors)\n Me.expression = Expression\n exp = New Regex(Me.expression)\n _expressiondescription = Description\n Me.ThrowOnInvalidValue = ThrowOnInvalidValue\n Me.InvalidValueBehavior = InvalidValueBehavior\n End Sub\n\n Private exp As Regex\n Private expression As String\n\n Public ReadOnly Property MatchExpression() As String\n Get\n Return expression\n End Get\n End Property\n\n Public ReadOnly Property ExpressionDescription() As String\n Get\n Return _expressiondescription\n End Get\n End Property\n Private _expressiondescription As String\n\n Public Function CheckIsMatch(ByVal s As String)\n Return exp.IsMatch(s)\n End Function\n\n Public Property ThrowOnInvalidValue() As Boolean\n Get\n Return _thrownoninvalidvalue\n End Get\n Set(ByVal value As Boolean)\n _thrownoninvalidvalue = value\n End Set\n End Property\n Private _thrownoninvalidvalue = True\n\n Public Property InvalidValueBehavior() As InvalidValueBehaviors\n Get\n Return _invalidvaluebehavior\n End Get\n Set(ByVal value As InvalidValueBehaviors)\n _invalidvaluebehavior = value\n End Set\n End Property\n Private _invalidvaluebehavior As InvalidValueBehaviors = InvalidValueBehaviors.DoNothing\n\n Public Property Value() As String\n Get\n Return _value\n End Get\n Set(ByVal value As String)\n If value Is Nothing Then value = \"\" 'Never set to Nothing\n\n If CheckIsMatch(value) Then\n _value = value\n Else\n Select Case InvalidValueBehavior\n Case InvalidValueBehaviors.AllowSetToInvalidValue\n _value = value\n Case InvalidValueBehaviors.SetToEmpty\n _value = \"\"\n End Select\n\n If ThrowOnInvalidValue Then\n Throw New ArgumentOutOfRangeException(String.Format(\"String: {0} does not match expression: {1}\", value, MatchExpression))\n End If\n End If\n End Set\n End Property\n Private _value As String = \"\"\n\n Public Overrides Function ToString() As String\n Return _value\n End Function\nEnd Class\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179295",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3043/"
] |
179,337
|
<p>In c#</p>
<pre><code>double tmp = 3.0 * 0.05;
</code></pre>
<p>tmp = 0.15000000000000002</p>
<p>This has to do with money. The value is really $0.15, but the system wants to round it up to $0.16. 0.151 should probably be rounded up to 0.16, but not 0.15000000000000002</p>
<p>What are some ways I can get the correct numbers (ie 0.15, or 0.16 if the decimal is high enough).</p>
|
[
{
"answer_id": 179392,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "decimal float double"
},
{
"answer_id": 179435,
"author": "spoulson",
"author_id": 3347,
"author_profile": "https://Stackoverflow.com/users/3347",
"pm_score": 0,
"selected": false,
"text": "decimal decimal float Int32 0x00018000"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3800/"
] |
179,355
|
<p>How do you delete all the cookies for the current domain using JavaScript?</p>
|
[
{
"answer_id": 179386,
"author": "ConroyP",
"author_id": 2287,
"author_profile": "https://Stackoverflow.com/users/2287",
"pm_score": 4,
"selected": false,
"text": "var mydate = new Date();\nmydate.setTime(mydate.getTime() - 1);\ndocument.cookie = \"username=; expires=\" + mydate.toGMTString(); \n"
},
{
"answer_id": 179514,
"author": "Robert J. Walker",
"author_id": 4287,
"author_profile": "https://Stackoverflow.com/users/4287",
"pm_score": 10,
"selected": true,
"text": "function deleteAllCookies() {\n var cookies = document.cookie.split(\";\");\n\n for (var i = 0; i < cookies.length; i++) {\n var cookie = cookies[i];\n var eqPos = cookie.indexOf(\"=\");\n var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;\n document.cookie = name + \"=;expires=Thu, 01 Jan 1970 00:00:00 GMT\";\n }\n}\n HttpOnly HttpOnly Path document.cookie Path"
},
{
"answer_id": 5886746,
"author": "AnthonyVO",
"author_id": 438458,
"author_profile": "https://Stackoverflow.com/users/438458",
"pm_score": 6,
"selected": false,
"text": "function eraseCookieFromAllPaths(name) {\n // This function will attempt to remove a cookie from all paths.\n var pathBits = location.pathname.split('/');\n var pathCurrent = ' path=';\n\n // do a simple pathless delete first.\n document.cookie = name + '=; expires=Thu, 01-Jan-1970 00:00:01 GMT;';\n\n for (var i = 0; i < pathBits.length; i++) {\n pathCurrent += ((pathCurrent.substr(-1) != '/') ? '/' : '') + pathBits[i];\n document.cookie = name + '=; expires=Thu, 01-Jan-1970 00:00:01 GMT;' + pathCurrent + ';';\n }\n}\n"
},
{
"answer_id": 17819341,
"author": "Zach Shallbetter",
"author_id": 520520,
"author_profile": "https://Stackoverflow.com/users/520520",
"pm_score": 2,
"selected": false,
"text": "var cookie = document.cookie.split(';');\n\nfor (var i = 0; i < cookie.length; i++) {\n\n var chip = cookie[i],\n entry = chip.split(\"=\"),\n name = entry[0];\n\n document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';\n}\n"
},
{
"answer_id": 20115529,
"author": "Dinesh",
"author_id": 1921517,
"author_profile": "https://Stackoverflow.com/users/1921517",
"pm_score": 3,
"selected": false,
"text": "function deleteAllCookies() {\n var c = document.cookie.split(\"; \");\n for (i in c) \n document.cookie =/^[^=]+/.exec(c[i])[0]+\"=;expires=Thu, 01 Jan 1970 00:00:00 GMT\"; \n}\n"
},
{
"answer_id": 20946944,
"author": "jichi",
"author_id": 970086,
"author_profile": "https://Stackoverflow.com/users/970086",
"pm_score": 4,
"selected": false,
"text": "for (var it in $.cookie()) $.removeCookie(it);\n"
},
{
"answer_id": 27374365,
"author": "Craig Smedley",
"author_id": 2818475,
"author_profile": "https://Stackoverflow.com/users/2818475",
"pm_score": 8,
"selected": false,
"text": "document.cookie.split(\";\").forEach(function(c) { document.cookie = c.replace(/^ +/, \"\").replace(/=.*/, \"=;expires=\" + new Date().toUTCString() + \";path=/\"); });\n javascript:(function(){document.cookie.split(\";\").forEach(function(c) { document.cookie = c.replace(/^ +/, \"\").replace(/=.*/, \"=;expires=\" + new Date().toUTCString() + \";path=/\"); }); })();\n"
},
{
"answer_id": 31985035,
"author": "Roman",
"author_id": 4791116,
"author_profile": "https://Stackoverflow.com/users/4791116",
"pm_score": 1,
"selected": false,
"text": "//Delete all cookies\nfunction deleteAllCookies() {\n var cookies = document.cookie.split(\";\");\n for (var i = 0; i < cookies.length; i++) {\n var cookie = cookies[i];\n var eqPos = cookie.indexOf(\"=\");\n var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;\n document.cookie = name + '=;' +\n 'expires=Thu, 01-Jan-1970 00:00:01 GMT;' +\n 'path=' + '/;' +\n 'domain=' + window.location.host + ';' +\n 'secure=;';\n }\n}\n"
},
{
"answer_id": 33366171,
"author": "Jan",
"author_id": 78639,
"author_profile": "https://Stackoverflow.com/users/78639",
"pm_score": 7,
"selected": false,
"text": "www.mydomain.example mydomain.example (function () {\n var cookies = document.cookie.split(\"; \");\n for (var c = 0; c < cookies.length; c++) {\n var d = window.location.hostname.split(\".\");\n while (d.length > 0) {\n var cookieBase = encodeURIComponent(cookies[c].split(\";\")[0].split(\"=\")[0]) + '=; expires=Thu, 01-Jan-1970 00:00:01 GMT; domain=' + d.join('.') + ' ;path=';\n var p = location.pathname.split('/');\n document.cookie = cookieBase + '/';\n while (p.length > 0) {\n document.cookie = cookieBase + p.join('/');\n p.pop();\n };\n d.shift();\n }\n }\n})();\n"
},
{
"answer_id": 35680201,
"author": "Derek Wade",
"author_id": 2668852,
"author_profile": "https://Stackoverflow.com/users/2668852",
"pm_score": -1,
"selected": false,
"text": "document.cookie \"; path=/;\""
},
{
"answer_id": 38184148,
"author": "Shubham Kumar",
"author_id": 4722288,
"author_profile": "https://Stackoverflow.com/users/4722288",
"pm_score": 2,
"selected": false,
"text": "function deleteAllCookies(){\n var cookies = document.cookie.split(\";\");\n for (var i = 0; i < cookies.length; i++)\n deleteCookie(cookies[i].split(\"=\")[0]);\n}\n\nfunction setCookie(name, value, expirydays) {\n var d = new Date();\n d.setTime(d.getTime() + (expirydays*24*60*60*1000));\n var expires = \"expires=\"+ d.toUTCString();\n document.cookie = name + \"=\" + value + \"; \" + expires;\n}\n\nfunction deleteCookie(name){\n setCookie(name,\"\",-1);\n}\n deleteAllCookies()"
},
{
"answer_id": 38244351,
"author": "Stefano Saitta",
"author_id": 4420152,
"author_profile": "https://Stackoverflow.com/users/4420152",
"pm_score": 1,
"selected": false,
"text": "const cookieCleaner = () => {\n return document.cookie.split(\";\").reduce(function (acc, cookie) {\n const eqPos = cookie.indexOf(\"=\");\n const cleanCookie = `${cookie.substr(0, eqPos)}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;`;\n return `${acc}${cleanCookie}`;\n }, \"\");\n}\n"
},
{
"answer_id": 41641134,
"author": "SpYk3HH",
"author_id": 900807,
"author_profile": "https://Stackoverflow.com/users/900807",
"pm_score": 0,
"selected": false,
"text": "/ ;(function() {\n if (!window['deleteAllCookies'] && document['cookie']) {\n window.deleteAllCookies = function(showLog) {\n var arrCookies = document.cookie.split(';'),\n arrPaths = location.pathname.replace(/^\\//, '').split('/'), // remove leading '/' and split any existing paths\n arrTemplate = [ 'expires=Thu, 01-Jan-1970 00:00:01 GMT', 'path={path}', 'domain=' + window.location.host, 'secure=' ]; // array of cookie settings in order tested and found most useful in establishing a \"delete\"\n for (var i in arrCookies) {\n var strCookie = arrCookies[i];\n if (typeof strCookie == 'string' && strCookie.indexOf('=') >= 0) {\n var strName = strCookie.split('=')[0]; // the cookie name\n for (var j=1;j<=arrTemplate.length;j++) {\n if (document.cookie.indexOf(strName) < 0) break; // if this is true, then the cookie no longer exist\n else {\n var strValue = strName + '=; ' + arrTemplate.slice(0, j).join('; ') + ';'; // made using the temp array of settings, putting it together piece by piece as loop rolls on\n if (j == 1) document.cookie = strValue;\n else {\n for (var k=0;k<=arrPaths.length;k++) {\n if (document.cookie.indexOf(strName) < 0) break; // if this is true, then the cookie no longer exist\n else {\n var strPath = arrPaths.slice(0, k).join('/') + '/'; // builds path line \n strValue = strValue.replace('{path}', strPath);\n document.cookie = strValue;\n }\n }\n }\n }\n }\n }\n }\n showLog && window['console'] && console.info && console.info(\"\\n\\tCookies Have Been Deleted!\\n\\tdocument.cookie = \\\"\" + document.cookie + \"\\\"\\n\");\n return document.cookie;\n }\n }\n})();\n"
},
{
"answer_id": 44164390,
"author": "Jacob David C. Cunningham",
"author_id": 2710227,
"author_profile": "https://Stackoverflow.com/users/2710227",
"pm_score": 4,
"selected": false,
"text": "document.cookie.split(';').forEach(function(c) {\n document.cookie = c.trim().split('=')[0] + '=;' + 'expires=Thu, 01 Jan 1970 00:00:00 UTC;';\n});\n"
},
{
"answer_id": 44945595,
"author": "sureshvignesh",
"author_id": 6856761,
"author_profile": "https://Stackoverflow.com/users/6856761",
"pm_score": 0,
"selected": false,
"text": "var cookies = $.cookie();\nfor(var cookie in cookies) {\n$.removeCookie(cookie);\n}\n function clearListCookies()\n{ \n var cookies = document.cookie.split(\";\");\n for (var i = 0; i < cookies.length; i++)\n { \n var spcook = cookies[i].split(\"=\");\n deleteCookie(spcook[0]);\n }\n function deleteCookie(cookiename)\n {\n var d = new Date();\n d.setDate(d.getDate() - 1);\n var expires = \";expires=\"+d;\n var name=cookiename;\n //alert(name);\n var value=\"\";\n document.cookie = name + \"=\" + value + expires + \"; path=/acc/html\"; \n}\nwindow.location = \"\"; // TO REFRESH THE PAGE\n}\n"
},
{
"answer_id": 50291342,
"author": "Mashiro",
"author_id": 8083009,
"author_profile": "https://Stackoverflow.com/users/8083009",
"pm_score": 3,
"selected": false,
"text": "var cookie_version_control = '---2018/5/11';\n\nfunction setCookie(name,value,days) {\n var expires = \"\";\n if (days) {\n var date = new Date();\n date.setTime(date.getTime() + (days*24*60*60*1000));\n expires = \"; expires=\" + date.toUTCString();\n }\n document.cookie = name+cookie_version_control + \"=\" + (value || \"\") + expires + \"; path=/\";\n}\n\nfunction getCookie(name) {\n var nameEQ = name+cookie_version_control + \"=\";\n var ca = document.cookie.split(';');\n for(var i=0;i < ca.length;i++) {\n var c = ca[i];\n while (c.charAt(0)==' ') c = c.substring(1,c.length);\n if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);\n }\n return null;\n}\n\nfunction removeCookie(name) { \n document.cookie = name+cookie_version_control+'=; Max-Age=-99999999;'; \n}\n"
},
{
"answer_id": 54947499,
"author": "B. Bohdan",
"author_id": 8097218,
"author_profile": "https://Stackoverflow.com/users/8097218",
"pm_score": 2,
"selected": false,
"text": "deleteAll deleteAll path=/ path Cookie import {Setter} from './Setter';\n\nexport class Cookie {\n /**\n * @param {string} key\n * @return {string|undefined}\n */\n static get(key) {\n key = key.replace(/([\\.$?*|{}\\(\\)\\[\\]\\\\\\/\\+^])/g, '\\\\$1');\n\n const regExp = new RegExp('(?:^|; )' + key + '=([^;]*)');\n const matches = document.cookie.match(regExp);\n\n return matches\n ? decodeURIComponent(matches[1])\n : undefined;\n }\n\n /**\n * @param {string} name\n */\n static delete(name) {\n this.set(name, '', { expires: -1 });\n }\n\n static deleteAll() {\n const cookies = document.cookie.split('; ');\n\n for (let cookie of cookies) {\n const index = cookie.indexOf('=');\n\n const name = ~index\n ? cookie.substr(0, index)\n : cookie;\n\n document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/';\n }\n }\n\n /**\n * @param {string} name\n * @param {string|boolean} value\n * @param {{expires?:Date|string|number,path?:string,domain?:string,secure?:boolean}} opts\n */\n static set(name, value, opts = {}) {\n Setter.set(name, value, opts);\n }\n}\n Cookie.set export class Setter {\n /**\n * @param {string} name\n * @param {string|boolean} value\n * @param {{expires?:Date|string|number,path?:string,domain?:string,secure?:boolean}} opts\n */\n static set(name, value, opts = {}) {\n value = Setter.prepareValue(value);\n opts = Setter.prepareOpts(opts);\n\n let updatedCookie = name + '=' + value;\n\n for (let i in opts) {\n if (!opts.hasOwnProperty(i)) continue;\n\n updatedCookie += '; ' + i;\n\n const value = opts[i];\n\n if (value !== true)\n updatedCookie += '=' + value;\n }\n\n document.cookie = updatedCookie;\n }\n\n /**\n * @param {string} value\n * @return {string}\n * @private\n */\n static prepareValue(value) {\n return encodeURIComponent(value);\n }\n\n /**\n * @param {{expires?:Date|string|number,path?:string,domain?:string,secure?:boolean}} opts\n * @private\n */\n static prepareOpts(opts = {}) {\n opts = Object.assign({}, opts);\n\n let {expires} = opts;\n\n if (typeof expires == 'number' && expires) {\n const date = new Date();\n\n date.setTime(date.getTime() + expires * 1000);\n\n expires = opts.expires = date;\n }\n\n if (expires && expires.toUTCString)\n opts.expires = expires.toUTCString();\n\n return opts;\n }\n}\n"
},
{
"answer_id": 66412149,
"author": "Luis Lobo",
"author_id": 11212275,
"author_profile": "https://Stackoverflow.com/users/11212275",
"pm_score": 1,
"selected": false,
"text": "let mainURL = getMainURL().toLowerCase().replace('www.', '').replace('.com.br', '.com'); // i am a brazilian guy\nlet cookies = $.cookie();\nfor(key in cookies){\n // default remove\n $.removeCookie(key, {\n path:'/'\n });\n // remove without www\n $.removeCookie(key, {\n domain: mainURL,\n path: '/'\n });\n // remove with www\n $.removeCookie(key, {\n domain: 'www.' + mainURL,\n path: '/'\n });\n};\n\n// get-main-url.js v1\nfunction getMainURL(url = window.location.href){\n url = url.replace(/.+?\\/\\//, ''); // remove protocol\n url = url.replace(/(\\#|\\?|\\/)(.+)?/, ''); // remove parameters and paths\n // remove subdomain\n if( url.split('.').length === 3 ){\n url = url.split('.');\n url.shift();\n url = url.join('.');\n };\n return url;\n};\n"
},
{
"answer_id": 66422055,
"author": "sampath",
"author_id": 10229940,
"author_profile": "https://Stackoverflow.com/users/10229940",
"pm_score": 3,
"selected": false,
"text": "document.cookie.split(\";\").forEach(function(c) { \n document.cookie = c.replace(/^ +/, \"\").replace(/=.*/, \"=;expires=\" + new Date().toUTCString() + \";path=/\"); \n});\n//clearing local storage\nlocalStorage.clear();\n"
},
{
"answer_id": 66612049,
"author": "Tesla",
"author_id": 13158114,
"author_profile": "https://Stackoverflow.com/users/13158114",
"pm_score": 4,
"selected": false,
"text": "cookieStore.getAll().then(cookies => cookies.forEach(cookie => {\n console.log('Cookie deleted:', cookie);\n cookieStore.delete(cookie.name);\n}));\n"
},
{
"answer_id": 66698063,
"author": "Slavik Meltser",
"author_id": 1291121,
"author_profile": "https://Stackoverflow.com/users/1291121",
"pm_score": 4,
"selected": false,
"text": "www.some.sub.domain.example .some.sub.domain.example .sub.domain.example cookie.split() document.cookie.replace(/(?<=^|;).+?(?=\\=|;|$)/g, name => location.hostname.split('.').reverse().reduce(domain => (domain=domain.replace(/^\\.?[^.]+/, ''),document.cookie=`${name}=;max-age=0;path=/;domain=${domain}`,domain), location.hostname));\n document.cookie.replace(\n /(?<=^|;).+?(?=\\=|;|$)/g,\n name => location.hostname\n .split(/\\.(?=[^\\.]+\\.)/)\n .reduceRight((acc, val, i, arr) => i ? arr[i]='.'+val+acc : (arr[i]='', arr), '')\n .map(domain => document.cookie=`${name}=;max-age=0;path=/;domain=${domain}`)\n);\n"
},
{
"answer_id": 68085116,
"author": "Nemesarial",
"author_id": 2186159,
"author_profile": "https://Stackoverflow.com/users/2186159",
"pm_score": 1,
"selected": false,
"text": "\\ function clearCookies( wildcardDomain=false, primaryDomain=true, path=null ){\n pathSegment = path ? '; path=' + path : ''\n expSegment = \"=;expires=Thu, 01 Jan 1970 00:00:00 GMT\"\n document.cookie.split(';').forEach(\n function(c) { \n primaryDomain && (document.cookie = c.replace(/^ +/, \"\").replace(/=.*/, expSegment + pathSegment))\n wildcardDomain && (document.cookie = c.replace(/^ +/, \"\").replace(/=.*/, expSegment + pathSegment + '; domain=' + document.domain))\n }\n )\n} \n"
},
{
"answer_id": 70360538,
"author": "Anton Starcev",
"author_id": 4579414,
"author_profile": "https://Stackoverflow.com/users/4579414",
"pm_score": 0,
"selected": false,
"text": "js-cookie import cookie from 'js-cookie'\n\nexport const removeAllCookiesByName = (cookieName: string) => {\n const hostParts = location.host.split('.')\n const domains = hostParts.reduce(\n (acc: string[], current, index) => [\n ...acc,\n hostParts.slice(index).join('.'),\n ],\n []\n )\n domains.forEach((domain) => cookie.remove(cookieName, { domain }))\n}\n\n"
},
{
"answer_id": 73315500,
"author": "PYK",
"author_id": 3233722,
"author_profile": "https://Stackoverflow.com/users/3233722",
"pm_score": 0,
"selected": false,
"text": "deleteAllCookies=()=>\n {\n let c=document.cookie.split(';')\n for(const k of c)\n {\n let s=k.split('=')\n document.cookie=s[0].trim()+'=;expires=Fri, 20 Aug 2021 00:00:00 UTC'\n }\n }\n deleteAllCookies()\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3636/"
] |
179,365
|
<p>I am trying this:</p>
<pre><code>Provider=MSDASQL.1;Persist Security Info=False;User ID=sys;Password=pwd;Initial Catalog=DATABASE;Data Source=OdbcDataSource;DBA Privilege=SYSDBA
</code></pre>
<p>But I get the error:</p>
<pre><code>[Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
</code></pre>
<p>I'm using Delphi, but answers in any language are welcome.</p>
<p><strong><em>Clarification:
I am able to connect as a normal user. I run into trouble when I try to connect AS SYSDBA.</em></strong></p>
|
[
{
"answer_id": 179416,
"author": "David Basarab",
"author_id": 2469,
"author_profile": "https://Stackoverflow.com/users/2469",
"pm_score": 0,
"selected": false,
"text": "Data Source=oracl;User Id=userID;Password=password;Integrated Security=no\n"
},
{
"answer_id": 61949624,
"author": "ListenToBob",
"author_id": 13575047,
"author_profile": "https://Stackoverflow.com/users/13575047",
"pm_score": 1,
"selected": false,
"text": "Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = ORCL))); User ID=sys; Password=syspassword; DBA PRIVILEGE=SYSDBA\n"
},
{
"answer_id": 71669169,
"author": "M.Hassan",
"author_id": 3142139,
"author_profile": "https://Stackoverflow.com/users/3142139",
"pm_score": 1,
"selected": false,
"text": "Data Source=myOracleDB;User Id=SYS;Password=SYS;DBA Privilege=SYSDBA;\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/672/"
] |
179,369
|
<p>I have a simple Python script that I want to stop executing if a condition is met.</p>
<p>For example:</p>
<pre><code>done = True
if done:
# quit/stop/exit
else:
# do other stuff
</code></pre>
<p>Essentially, I am looking for something that behaves equivalently to the 'return' keyword in the body of a function which allows the flow of the code to exit the function and not execute the remaining code.</p>
|
[
{
"answer_id": 179387,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackoverflow.com/users/6491",
"pm_score": 4,
"selected": false,
"text": "import sys\nsys.exit()\n"
},
{
"answer_id": 179516,
"author": "David Locke",
"author_id": 1447,
"author_profile": "https://Stackoverflow.com/users/1447",
"pm_score": 4,
"selected": false,
"text": "def main():\n done = True\n if done:\n return\n # quit/stop/exit\n else:\n # do other stuff\n\nif __name__ == \"__main__\":\n #Run as main program\n main()\n"
},
{
"answer_id": 179608,
"author": "ryan_s",
"author_id": 13728,
"author_profile": "https://Stackoverflow.com/users/13728",
"pm_score": 9,
"selected": true,
"text": "import sys\nsys.exit()\n import sys\nsys.exit(0)\n import sys\nsys.exit(\"aa! errors!\")\n"
},
{
"answer_id": 179689,
"author": "efotinis",
"author_id": 12320,
"author_profile": "https://Stackoverflow.com/users/12320",
"pm_score": 4,
"selected": false,
"text": "import sys\nsys.exit(...)\n raise SystemExit(...)\n"
},
{
"answer_id": 2139017,
"author": "GabrieleV",
"author_id": 188694,
"author_profile": "https://Stackoverflow.com/users/188694",
"pm_score": 3,
"selected": false,
"text": "sys.exit(\"message\")\n die(\"message\")\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] |
179,405
|
<p>Can anyone explain what this mod_rewrite rule is doing?</p>
<p>I'm trying to comment the file, but the code seems to state the opposite of what I think it's doing</p>
<pre><code># Enable rewriting of URLs
RewriteEngine on
# Allow specified file types to be accessed
# Thing to test = URL
# Condition = not starting with
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt)
# RewriteRule will only be performed if the preceeding RewriteCond is fulfilled
# Remove index.php from all URLs
# Pattern = anything (0 or more of any character)
# Substitution = index.php + the rest of the URL
RewriteRule ^(.*)$ /index.php/$1 [L]
</code></pre>
|
[
{
"answer_id": 179419,
"author": "Roel",
"author_id": 11449,
"author_profile": "https://Stackoverflow.com/users/11449",
"pm_score": 3,
"selected": true,
"text": "^ = begin of line\n( = begin group\n.* = any character, any number of times\n) = end group\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4196/"
] |
179,415
|
<p>Assuming we always use a Sun JVM (say, 1.5+), is it always safe to cast a Graphics reference to Graphics2D? </p>
<p>I haven't seen it cause any problems yet and, to my understanding, the Graphics class is legacy code but the Java designers didn't want to change the interfaces for Swing and AWT classes in order to preserver backwards compatibility.</p>
|
[
{
"answer_id": 179431,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 6,
"selected": true,
"text": "Graphics Graphics2D"
},
{
"answer_id": 180237,
"author": "Roland Schneider",
"author_id": 16515,
"author_profile": "https://Stackoverflow.com/users/16515",
"pm_score": 4,
"selected": false,
"text": "Graphics2D DebugGraphics Graphics2D"
},
{
"answer_id": 1364460,
"author": "MathiasKegelmann",
"author_id": 48731,
"author_profile": "https://Stackoverflow.com/users/48731",
"pm_score": 3,
"selected": false,
"text": "public void paint (Graphics g) {\n Graphics2D g2 = (Graphics2D) g;\n ...\n}\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1471/"
] |
179,427
|
<p>Seems like the subtraction is triggering some kind of issue and the resulting value is wrong.</p>
<pre><code>double tempCommission = targetPremium.doubleValue()*rate.doubleValue()/100d;
</code></pre>
<p>78.75 = 787.5 * 10.0/100d</p>
<pre><code>double netToCompany = targetPremium.doubleValue() - tempCommission;
</code></pre>
<p>708.75 = 787.5 - 78.75</p>
<pre><code>double dCommission = request.getPremium().doubleValue() - netToCompany;
</code></pre>
<p>877.8499999999999 = 1586.6 - 708.75</p>
<p>The resulting expected value would be 877.85.</p>
<p>What should be done to ensure the correct calculation?</p>
|
[
{
"answer_id": 179453,
"author": "Eric Weilnau",
"author_id": 13342,
"author_profile": "https://Stackoverflow.com/users/13342",
"pm_score": 8,
"selected": true,
"text": "import java.math.BigDecimal;\n\nBigDecimal premium = BigDecimal.valueOf(\"1586.6\");\nBigDecimal netToCompany = BigDecimal.valueOf(\"708.75\");\nBigDecimal commission = premium.subtract(netToCompany);\nSystem.out.println(commission + \" = \" + premium + \" - \" + netToCompany);\n 877.85 = 1586.6 - 708.75\n"
},
{
"answer_id": 179474,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 3,
"selected": false,
"text": "double d = 0;\nfor (int i = 1; i <= 10; i++) {\n d += 0.1;\n}\nSystem.out.println(d); // prints 0.9999999999999999 not 1.0\n"
},
{
"answer_id": 179487,
"author": "Johann Zacharee",
"author_id": 24290,
"author_profile": "https://Stackoverflow.com/users/24290",
"pm_score": 6,
"selected": false,
"text": "java.math.BigDecimal BigDecimal BigDecimal BigDecimal(double) BigDecimal.valueOf(double) double BigDecimal String BigDecimal BigDecimal"
},
{
"answer_id": 808959,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "import java.math.BigDecimal;\n\nBigDecimal premium = new BigDecimal(\"1586.6\");\nBigDecimal netToCompany = new BigDecimal(\"708.75\");\nBigDecimal commission = premium.subtract(netToCompany);\nSystem.out.println(commission + \" = \" + premium + \" - \" + netToCompany);\n import java.math.BigDecimal;\n\nBigDecimal premium = BigDecimal.valueOf(158660, 2);\nBigDecimal netToCompany = BigDecimal.valueOf(70875, 2);\nBigDecimal commission = premium.subtract(netToCompany);\nSystem.out.println(commission + \" = \" + premium + \" - \" + netToCompany);\n"
},
{
"answer_id": 1018367,
"author": "Roman Kagan",
"author_id": 117802,
"author_profile": "https://Stackoverflow.com/users/117802",
"pm_score": 2,
"selected": false,
"text": "double newNum = Math.floor(num * 100 + 0.5) / 100;\n"
},
{
"answer_id": 1629282,
"author": "Denis",
"author_id": 197133,
"author_profile": "https://Stackoverflow.com/users/197133",
"pm_score": 1,
"selected": false,
"text": "double rounded = Math.rint(toround * 100) / 100;\n"
},
{
"answer_id": 8326785,
"author": "Timon",
"author_id": 1073447,
"author_profile": "https://Stackoverflow.com/users/1073447",
"pm_score": -1,
"selected": false,
"text": "public static int round(Double i) {\n return (int) Math.round(i + ((i > 0.0) ? 0.00000001 : -0.00000001));\n}\n Double foo = 0.0;\n for (int i = 1; i <= 150; i++) {\n foo += 0.00010;\n }\n System.out.println(foo);\n System.out.println(Math.round(foo * 100.0) / 100.0);\n System.out.println(round(foo*100.0) / 100.0);\n 0.014999999999999965\n0.01\n0.02\n"
},
{
"answer_id": 9656080,
"author": "Mike Stratton",
"author_id": 1262427,
"author_profile": "https://Stackoverflow.com/users/1262427",
"pm_score": -1,
"selected": false,
"text": "int a = 877.8499999999999;\nSystem.out.printf(\"Formatted Output is: %.2f\", a);\n"
},
{
"answer_id": 10028960,
"author": "Doug",
"author_id": 381448,
"author_profile": "https://Stackoverflow.com/users/381448",
"pm_score": 2,
"selected": false,
"text": "System.out.println(round((1515476.0) * 0.00001) / 0.00001);\n 1499999.9999999998 System.out.println(BigDecimal.valueOf(1515476.0).setScale(-5, RoundingMode.HALF_UP).doubleValue());\n"
},
{
"answer_id": 16248507,
"author": "Tomasz",
"author_id": 10523,
"author_profile": "https://Stackoverflow.com/users/10523",
"pm_score": 2,
"selected": false,
"text": "double dCommission = 1586.6 - 708.75;\nSystem.out.println(dCommission);\n> 877.8499999999999\n\nReal dCommissionR = Real.valueOf(1586.6 - 708.75);\nSystem.out.println(dCommissionR);\n> 877.850000000000\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25881/"
] |
179,439
|
<p>I checked out a project from SVN and did not specify the project type, so it checked out as a "default" project. What is the easiest way to quickly convert this into a "Java" project?</p>
<p>I'm using Eclipse version 3.3.2.</p>
|
[
{
"answer_id": 179450,
"author": "Chris Marasti-Georg",
"author_id": 96,
"author_profile": "https://Stackoverflow.com/users/96",
"pm_score": 8,
"selected": true,
"text": "<projectDescription>\n <buildSpec>\n <buildCommand>\n <name>org.eclipse.jdt.core.javabuilder</name>\n <arguments>\n </arguments>\n </buildCommand>\n </buildSpec>\n <natures>\n <nature>org.eclipse.jdt.core.javanature</nature>\n </natures>\n</projectDescription>\n <classpath>\n <classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n</classpath>\n"
},
{
"answer_id": 13750958,
"author": "drumherum",
"author_id": 33343,
"author_profile": "https://Stackoverflow.com/users/33343",
"pm_score": 3,
"selected": false,
"text": ".project natures nature org.eclipse.jdt.core.javanature .classpath classpath classpathentry kind con path org.eclipse.jdt.launching.JRE_CONTAINER .project .classpath result name"
},
{
"answer_id": 31965240,
"author": "Premraj",
"author_id": 1697099,
"author_profile": "https://Stackoverflow.com/users/1697099",
"pm_score": 4,
"selected": false,
"text": "properties project facets Convert to faceted form..."
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5917/"
] |
179,441
|
<p>I'm modifying a mature CGI application written in Perl and the question of content encoding has come up. The browser reports that the content is iso-8859-1 encoded and the application is declaring iso-8859-1 as the charset in the HTTP headers but doesn't ever seem to <em>actually do</em> the encoding. None of the various encoding techniques described in the perldoc tutorials (<a href="http://perldoc.perl.org/Encode.html" rel="nofollow noreferrer">Encode</a>, <a href="http://perldoc.perl.org/encoding.html" rel="nofollow noreferrer">Encoding</a>, <a href="http://perldoc.perl.org/open.html" rel="nofollow noreferrer">Open</a>) are used in the code so I'm a little confused as to how the document is actually being encoded. </p>
<p>As mentioned, the application is quite mature and likely predates many of the current encoding methods. Does anyone know of any legacy or deprecated techniques I should be looking for? To what encoding does Perl assume/default to when no direction is provided by the developer?</p>
<p>Thanks</p>
|
[
{
"answer_id": 179490,
"author": "moritz",
"author_id": 14132,
"author_profile": "https://Stackoverflow.com/users/14132",
"pm_score": 4,
"selected": true,
"text": "uc lc"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20790/"
] |
179,460
|
<p>If I have a class that needs to implement an interface but one or more of the methods on that interface don't make sense in the context of this particular class, what should I do?</p>
<p>For example, lets say I'm implementing an adapter pattern where I want to create a wrapper class that implements <a href="http://java.sun.com/javase/6/docs/api/java/util/Map.html" rel="nofollow noreferrer">java.util.Map</a> by wrapping some immutable object and exposing it's data as key/value pairs. In this case the methods put and putAll don't make sense as I have no way to modify the underlying object. So the question is what should those methods do?</p>
|
[
{
"answer_id": 179465,
"author": "Chris Marasti-Georg",
"author_id": 96,
"author_profile": "https://Stackoverflow.com/users/96",
"pm_score": 3,
"selected": false,
"text": "UnsupportedOperationException NotImplementedException"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1247/"
] |
179,466
|
<p>I'm creating a self updating app where I have the majority of the code in a seperate DLL. It's command line and will eventually be run on Mono. I'm just trying to get this code to work in C# on windows at the command line.</p>
<p>How can I create a c# application that I can delete a supporting dll while its running?</p>
<pre><code>AppDomain domain = AppDomain.CreateDomain("MyDomain");
ObjectHandle instance = domain.CreateInstance( "VersionUpdater.Core", "VersionUpdater.Core.VersionInfo");
object unwrap = instance.Unwrap();
Console.WriteLine(((ICommand)unwrap).Run());
AppDomain.Unload(domain);
Console.ReadLine();
</code></pre>
<p>at the ReadLine the VersionUpdater.Core.dll is still locked from deletion</p>
<p>The ICommand interface is in VersionUpdater.Common.dll which is referenced by both the Commandline app and VersionUpdater.Core.dll</p>
|
[
{
"answer_id": 924702,
"author": "RandomNickName42",
"author_id": 67819,
"author_profile": "https://Stackoverflow.com/users/67819",
"pm_score": 1,
"selected": false,
"text": "MOVEFILE_DELAY_UNTIL_REBOOT MOVEFILE_COPY_ALLOWED MOVEFILE_DELAY_UNTIL_REBOOT"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/253/"
] |
179,468
|
<p>What I want to do is set the focus to a specific control (specifically a <code>TextBox</code>) on a tab page when that tab page is selected.</p>
<p>I've tried to call <code>Focus</code> during the Selected event of the containing tab control, but that isn't working. After that I tried to call focus during the <code>VisibleChanged</code> event of the control itself (with a check so that I'm not focusing on an invisible control), but that isn't working either.</p>
<p>Searching this site, I've come across this <a href="https://stackoverflow.com/questions/48680/winforms-c-set-focus-to-first-child-control-of-tab-page">question</a> but that isn't working either. Although after that, I did notice that calling the <code>Focus</code> of the control does make it the <code>ActiveControl</code>.</p>
|
[
{
"answer_id": 179499,
"author": "itsmatt",
"author_id": 7862,
"author_profile": "https://Stackoverflow.com/users/7862",
"pm_score": 4,
"selected": true,
"text": "SelectedIndexChanged tabControl tabControl1.SelectedIndex textBox.Focus(); private void tabControl1_selectedIndexChanged(object sender, EventArgs e)\n{\n if (tabControl1.SelectedIndex == 1)\n {\n textBox1.Focus();\n }\n}\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1440933/"
] |
179,472
|
<p>I need to export a SL DataGrid to HTML so my users can then print it. Can someone put me in the right direction?</p>
<p>Upate: After reading Rob's answer I am changing my question. Instead of Silverlight Grid to HTML, I now just want to export it to PDF. Has anyone used any 3rd party PDF generators with Silverlight?</p>
|
[
{
"answer_id": 179499,
"author": "itsmatt",
"author_id": 7862,
"author_profile": "https://Stackoverflow.com/users/7862",
"pm_score": 4,
"selected": true,
"text": "SelectedIndexChanged tabControl tabControl1.SelectedIndex textBox.Focus(); private void tabControl1_selectedIndexChanged(object sender, EventArgs e)\n{\n if (tabControl1.SelectedIndex == 1)\n {\n textBox1.Focus();\n }\n}\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23663/"
] |
179,480
|
<p>Provided I have admin access, I need a way to manage (Create, modify, remove) local accounts in a remote machine from an ASP.NET client.</p>
<p>I'm clueless in how to approach this. Is WMI a possibility (System.Management namespace)?
Any pointers?</p>
|
[
{
"answer_id": 180678,
"author": "Matt Hanson",
"author_id": 5473,
"author_profile": "https://Stackoverflow.com/users/5473",
"pm_score": 3,
"selected": true,
"text": "DirectoryEntry directoryEntry = new DirectoryEntry(\"WinNT://ComputerName\" & \",computer\", \"AdminUN\", \"AdminPW\");\nDirectoryEntry user = directoryEntry.Children.Add(\"username\", \"user\");\nuser.Invoke(\"SetPassword\", new object[] { \"password\"});\nser.CommitChanges();\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25885/"
] |
179,488
|
<p>Is there a list somewhere on common Attributes which are used in objects like <code>Serializable</code>?</p>
<p>Thanks</p>
<p>Edit ~ The reason I asked is that I came across an StoredProcedure attribute in ntiers ORMS.</p>
|
[
{
"answer_id": 179496,
"author": "StingyJack",
"author_id": 16391,
"author_profile": "https://Stackoverflow.com/users/16391",
"pm_score": 5,
"selected": true,
"text": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Reflection;\n\nnamespace ConsoleApp1\n{\n class Program\n {\n static void Main(string[] args)\n {\n var process = new Process();\n //your path may vary\n process.StartInfo.FileName = @\"C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.1 Tools\\gacutil.exe\";\n process.StartInfo.RedirectStandardOutput = true;\n process.StartInfo.UseShellExecute = false;\n process.StartInfo.Arguments = \"/l\";\n process.Start();\n\n var consoleOutput = process.StandardOutput;\n\n\n var assemblyList = new List<string>();\n var startAdding = false;\n while (consoleOutput.EndOfStream == false)\n {\n var line = consoleOutput.ReadLine();\n if (line.IndexOf(\"The Global Assembly Cache contains the following assemblies\", StringComparison.OrdinalIgnoreCase) >= 0)\n {\n startAdding = true;\n continue;\n }\n\n if (startAdding == false)\n {\n continue;\n }\n\n //add any other filter conditions (framework version, etc)\n if (line.IndexOf(\"System.\", StringComparison.OrdinalIgnoreCase) < 0)\n {\n continue;\n }\n\n assemblyList.Add(line.Trim());\n }\n\n var collectedRecords = new List<string>();\n var failedToLoad = new List<string>();\n\n Console.WriteLine($\"Found {assemblyList.Count} assemblies\");\n var currentItem = 1;\n\n\n foreach (var gacAssemblyInfo in assemblyList)\n {\n Console.SetCursorPosition(0, 2);\n Console.WriteLine($\"On {currentItem} of {assemblyList.Count} \");\n Console.SetCursorPosition(0, 3);\n Console.WriteLine($\"Loading {gacAssemblyInfo}\");\n currentItem++;\n\n try\n {\n var asm = Assembly.Load(gacAssemblyInfo);\n\n foreach (Type t in asm.GetTypes())\n {\n if (t.Name.EndsWith(\"Attribute\", StringComparison.OrdinalIgnoreCase))\n {\n collectedRecords.Add($\"{t.FullName} - {t.Assembly.FullName}\");\n }\n }\n\n }\n catch (Exception ex)\n {\n failedToLoad.Add($\"FAILED to load {gacAssemblyInfo} - {ex}\");\n Console.SetCursorPosition(1, 9);\n Console.WriteLine($\"Failure to load count: {failedToLoad.Count}\");\n Console.SetCursorPosition(4, 10);\n Console.WriteLine($\"Last Fail: {gacAssemblyInfo}\");\n }\n }\n\n var fileBase = System.IO.Path.GetRandomFileName();\n var goodFile = $\"{fileBase}_good.txt\";\n var failFile = $\"{fileBase}_failedToLoad.txt\";\n System.IO.File.WriteAllLines(goodFile, collectedRecords);\n System.IO.File.WriteAllLines(failFile, failedToLoad);\n Console.SetCursorPosition(0, 15);\n Console.WriteLine($\"Matching types: {goodFile}\");\n Console.WriteLine($\"Failures: {failFile}\");\n Console.WriteLine(\"Press ENTER to exit\");\n Console.ReadLine();\n }\n }\n}\n"
},
{
"answer_id": 179615,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 1,
"selected": false,
"text": "mscorlib System.Attribute"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23667/"
] |
179,492
|
<p>F# is derived from OCaml, but what major items are missing or added? Specifically I'm curious as to whether the resources available for learning OCaml are also useful to someone who wants to learn F#.</p>
|
[
{
"answer_id": 2485277,
"author": "Tomas Petricek",
"author_id": 33518,
"author_profile": "https://Stackoverflow.com/users/33518",
"pm_score": 7,
"selected": false,
"text": "+"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179492",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16942/"
] |
179,500
|
<p>I've seen a lot of questions around that use improperly the expression "C/C++".
The reasons in my opinion are: </p>
<ul>
<li>Newbie C and C++ programmers probably don't understand the difference between the two languages.</li>
<li>People don't really care about it since they want a generic, quick and "dirty" answer</li>
</ul>
<p>While C/C++ could sometimes be interpreted as "either C or C++", I think it's a big error. C and C++ offer different approaches to programming, and even if C code can be easily implemented into C++ programs I think that referring to two separate languages with that single expression ( C/C++ ) is wrong.<br /></p>
<p>It's true that some questions can be considered either as C or C++ ones, anyway.
What do you think about it?</p>
|
[
{
"answer_id": 179949,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 1,
"selected": false,
"text": "sprintf"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23890/"
] |
179,510
|
<p>Is there a way to get rid of the selection rectangle when clicking a link which does not refresh the current page entirely?</p>
|
[
{
"answer_id": 179525,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 3,
"selected": false,
"text": "onclick=\"this.blur()\"\n"
},
{
"answer_id": 179532,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 7,
"selected": true,
"text": ":focus {\n outline: 0;\n}\n a:focus"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179510",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16440/"
] |
179,539
|
<p>If I have $var defined in Page1.php and in Page2.php I have</p>
<pre>
//Page2.php
include('Page1.php');
echo $var;
</pre>
<p>For what reasons will it not print the value of $var to the screen? The files are in the same directory so paths shouldn't be the issue. I've checked the php.ini file and nothing really jumps out at me. Any ideas?</p>
|
[
{
"answer_id": 179552,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 2,
"selected": false,
"text": "$var $var"
},
{
"answer_id": 179572,
"author": "andyuk",
"author_id": 2108,
"author_profile": "https://Stackoverflow.com/users/2108",
"pm_score": 0,
"selected": false,
"text": "<?php\n$foo = \"bar\"\n?>\n <?php\ninclude('page1.php');\necho $foo;\n?>\n"
},
{
"answer_id": 179578,
"author": "Mnebuerquo",
"author_id": 5114,
"author_profile": "https://Stackoverflow.com/users/5114",
"pm_score": 1,
"selected": true,
"text": "echo getcwd();\n global $var;\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24059/"
] |
179,543
|
<p>for a FILE* stream, if I read as much data as possible, feof(stream) returns me non-zero. Then, If I fclose stream, it feof(stream) will continue to returns me a non-zero value?
Is it GUARANTEED?</p>
|
[
{
"answer_id": 180193,
"author": "Dan Lenski",
"author_id": 20789,
"author_profile": "https://Stackoverflow.com/users/20789",
"pm_score": 2,
"selected": false,
"text": "feof() comp.lang.c"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25888/"
] |
179,556
|
<p>Like the title says, If I place an <code>app_offline.htm</code> in the application root, will it cut off currently running requests, or just new ones?</p>
|
[
{
"answer_id": 179686,
"author": "Gabe Sumner",
"author_id": 12689,
"author_profile": "https://Stackoverflow.com/users/12689",
"pm_score": 6,
"selected": true,
"text": "protected void Page_Load(object sender, EventArgs e)\n{\n Response.BufferOutput = false;\n Response.Write(\"Step 1<br />\");\n System.Threading.Thread.Sleep(10000);\n Response.Write(\"Step 2<br />\");\n System.Threading.Thread.Sleep(10000);\n Response.Write(\"Step 3<br />\");\n}\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16172/"
] |
179,565
|
<p>If yes, on which operating system, shell or whatever?</p>
<p>Consider the following java program (I'm using java just as an example, any language would be good for this question, which is more about operation systems):</p>
<pre><code>public class ExitCode {
public static void main(String args[]) {
System.exit(Integer.parseInt(args[0]));
}
}
</code></pre>
<p>Running it on Linux and bash, it returns always values less equal 255, e.g. (<code>echo $?</code> prints the exit code of the previous executed command)</p>
<pre><code>> java ExitCode 2; echo $?
2
> java ExitCode 128; echo $?
128
> java ExitCode 255; echo $?
255
> java ExitCode 256; echo $?
0
> java ExitCode 65536; echo $?
0
</code></pre>
<hr>
<p>EDITED: the (only, so far) answer below fully explain what happens on UNIXes. I'm still wondering about other OSes.</p>
|
[
{
"answer_id": 179652,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 6,
"selected": true,
"text": "wait() waitpid() wait() waitpid() sigaction() SA_SIGINFO sigaction() <signal.h> exit() #include <errno.h>\n#include <signal.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <sys/wait.h>\n#include <time.h>\n#include <unistd.h>\n\nstatic siginfo_t sig_info = { 0 };\nstatic volatile sig_atomic_t sig_num = 0;\nstatic void *sig_ctxt = 0;\n\nstatic void catcher(int signum, siginfo_t *info, void *vp)\n{\n sig_num = signum;\n sig_info = *info;\n sig_ctxt = vp;\n}\n\nstatic void set_handler(int signum)\n{\n struct sigaction sa;\n sa.sa_flags = SA_SIGINFO;\n sa.sa_sigaction = catcher;\n sigemptyset(&sa.sa_mask);\n\n if (sigaction(signum, &sa, 0) != 0)\n {\n int errnum = errno;\n fprintf(stderr, \"Failed to set signal handler (%d: %s)\\n\", errnum, strerror(errnum));\n exit(1);\n }\n}\n\nstatic void prt_interrupt(FILE *fp)\n{\n if (sig_num != 0)\n {\n fprintf(fp, \"Signal %d from PID %d (status 0x%.8X; UID %d)\\n\",\n sig_info.si_signo, (int)sig_info.si_pid, sig_info.si_status,\n (int)sig_info.si_uid);\n sig_num = 0;\n }\n}\n\nstatic void five_kids(void)\n{\n const int base = 0xCC00FF40;\n for (int i = 0; i < 5; i++)\n {\n pid_t pid = fork();\n if (pid < 0)\n break;\n else if (pid == 0)\n {\n printf(\"PID %d - exiting with status %d (0x%.8X)\\n\",\n (int)getpid(), base + i, base + i);\n exit(base + i);\n }\n else\n {\n int status = 0;\n pid_t corpse = wait(&status);\n if (corpse != -1)\n printf(\"Child: %d; Corpse: %d; Status = 0x%.4X - waited\\n\", pid, corpse, (status & 0xFFFF));\n struct timespec nap = { .tv_sec = 0, .tv_nsec = 1000000 }; // 1 millisecond\n nanosleep(&nap, 0);\n prt_interrupt(stdout);\n fflush(0);\n }\n }\n}\n\nint main(void)\n{\n set_handler(SIGCHLD);\n five_kids();\n}\n sigexit73 sigexit73.c $ sigexit73\nPID 26599 - exiting with status -872349888 (0xCC00FF40)\nSignal 20 from PID 26599 (status 0xCC00FF40; UID 501)\nChild: 26600; Corpse: 26599; Status = 0x4000 - waited\nPID 26600 - exiting with status -872349887 (0xCC00FF41)\nSignal 20 from PID 26600 (status 0xCC00FF41; UID 501)\nChild: 26601; Corpse: 26600; Status = 0x4100 - waited\nPID 26601 - exiting with status -872349886 (0xCC00FF42)\nSignal 20 from PID 26601 (status 0xCC00FF42; UID 501)\nChild: 26602; Corpse: 26601; Status = 0x4200 - waited\nPID 26602 - exiting with status -872349885 (0xCC00FF43)\nSignal 20 from PID 26602 (status 0xCC00FF43; UID 501)\nChild: 26603; Corpse: 26602; Status = 0x4300 - waited\nPID 26603 - exiting with status -872349884 (0xCC00FF44)\nSignal 20 from PID 26603 (status 0xCC00FF44; UID 501)\n$\n nanosleep() $ sigexit73\nsigexit23\nPID 26621 - exiting with status -872349888 (0xCC00FF40)\nSignal 20 from PID 26621 (status 0xCC00FF40; UID 501)\nChild: 26622; Corpse: 26621; Status = 0x4000 - waited\nPID 26622 - exiting with status -872349887 (0xCC00FF41)\nPID 26623 - exiting with status -872349886 (0xCC00FF42)\nSignal 20 from PID 26622 (status 0xCC00FF41; UID 501)\nChild: 26624; Corpse: 26623; Status = 0x4200 - waited\nSignal 20 from PID 26623 (status 0xCC00FF42; UID 501)\nChild: 26625; Corpse: 26622; Status = 0x4100 - waited\nPID 26624 - exiting with status -872349885 (0xCC00FF43)\nPID 26625 - exiting with status -872349884 (0xCC00FF44)\n$\n Signal waited SIGCHLD exit() sigaction() SIGCHLD SA_SIGINFO sigexit73.c"
},
{
"answer_id": 328423,
"author": "Michael Ratanapintha",
"author_id": 1879,
"author_profile": "https://Stackoverflow.com/users/1879",
"pm_score": 4,
"selected": false,
"text": "CMD.EXE CMD.EXE > java ExitCode 2\n> echo %errorlevel%\n2\n\n> java ExitCode 128\n> echo %errorlevel%\n128\n\n> java ExitCode 255\n> echo %errorlevel%\n255\n\n> java ExitCode 256\n> echo %errorlevel%\n256\n\n> java ExitCode 65536\n> echo %errorlevel%\n65536\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25891/"
] |
179,582
|
<p>I'm primarily interested in pgsql for this, but I was wondering if there is a way in any RDBMS to do an insert operation, <em>without</em> disabling and re-enabling any FOREIGN KEY or NOT NULL constraints, on two tables that refer to each other. (You might think of this as a chicken that was somehow born from its own egg.)</p>
<p>For a practical example, if you had a multiple-choice quiz system, with tables "question" and "answer", where question.correct_answer refers to answer.id, and answer.question refers to question.id, is it possible to add a question and its answers simultaneously?</p>
<p>(For the record, I'm aware that you can do the disabling and re-enabling in a transaction block, and that another solution is to not have a correct_answer column but instead have answer.correct as a boolean and have a check constraint making sure there's exactly one correct answer per question. But I'm not curious about alternative solutions here.)</p>
|
[
{
"answer_id": 179651,
"author": "Neall",
"author_id": 619,
"author_profile": "https://Stackoverflow.com/users/619",
"pm_score": 3,
"selected": true,
"text": "BEGIN;\n SET CONSTRAINTS ALL DEFERRED;\nINSERT INTO questions (questionid, answerid, question)\n VALUES (1, 100, 'How long are Abraham Lincoln\\'s legs?');\nINSERT INTO answers (answerid, questionid, answer)\n VALUES (100, 1, 'Long enough to reach the ground.');\nCOMMIT;\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16777/"
] |
179,619
|
<p>Why is it that there are two kinds of references in xaml.</p>
<p>One looks like this:</p>
<pre><code>xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
</code></pre>
<p>But mine look like this:</p>
<pre><code>xmlns:WPFToolKit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
</code></pre>
<p>Why can't I do this:</p>
<pre><code>xmlns:local="http://myschema.mydomain.com/MyControlNamespace
</code></pre>
<p>Thanks to <a href="https://stackoverflow.com/users/7116/sixlettervariables">ixlettervariables</a> for the answer. Here's a detailed explanation <a href="http://codingcontext.wordpress.com/2008/10/09/consolidating-xaml-namespaces/" rel="nofollow noreferrer">here</a></p>
|
[
{
"answer_id": 179632,
"author": "user7116",
"author_id": 7116,
"author_profile": "https://Stackoverflow.com/users/7116",
"pm_score": 4,
"selected": true,
"text": "[assembly:XmlnsDefinition(\"http://myschema.mydomain.com/MyControlNamespace\", \"My.Control.Namespace\")]\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17744/"
] |
179,625
|
<p>In SQL Server 2017, you can use this syntax, but not in earlier versions:</p>
<pre><code>SELECT Name = TRIM(Name) FROM dbo.Customer;
</code></pre>
|
[
{
"answer_id": 179630,
"author": "Ben Hoffstein",
"author_id": 4482,
"author_profile": "https://Stackoverflow.com/users/4482",
"pm_score": 9,
"selected": true,
"text": "SELECT LTRIM(RTRIM(Names)) AS Names FROM Customer\n"
},
{
"answer_id": 179637,
"author": "Kibbee",
"author_id": 1862,
"author_profile": "https://Stackoverflow.com/users/1862",
"pm_score": 6,
"selected": false,
"text": "SELECT RTRIM(Names) FROM Customer\n SELECT LTRIM(Names) FROM Customer\n SELECT LTRIM(RTRIM(Names)) FROM Customer\n"
},
{
"answer_id": 182047,
"author": "onedaywhen",
"author_id": 15354,
"author_profile": "https://Stackoverflow.com/users/15354",
"pm_score": 3,
"selected": false,
"text": "ALTER TABLE Customer ADD\n CONSTRAINT customer_names__whitespace\n CHECK (\n Names NOT LIKE ' %'\n AND Names NOT LIKE '% '\n AND Names NOT LIKE '% %'\n );\n family_name first_name"
},
{
"answer_id": 6420947,
"author": "rahularyansharma",
"author_id": 779158,
"author_profile": "https://Stackoverflow.com/users/779158",
"pm_score": 1,
"selected": false,
"text": "TRIM(\" New York \") .The return result is \"New York\".\n"
},
{
"answer_id": 24605674,
"author": "razon",
"author_id": 908936,
"author_profile": "https://Stackoverflow.com/users/908936",
"pm_score": 3,
"selected": false,
"text": "SELECT LTRIM(RTRIM(Replace(Replace(Replace(name,' ',' '),CHAR(13), ' '),char(10), ' ')))\nfrom author\n"
},
{
"answer_id": 54250546,
"author": "Kai-Ove Böhnisch",
"author_id": 10932439,
"author_profile": "https://Stackoverflow.com/users/10932439",
"pm_score": 2,
"selected": false,
"text": "REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RTRIM(LTRIM(REPLACE(\"Put in your Field name\", ' ',' '))),'''',''), CHAR(9), ''), CHAR(10), ''), CHAR(13), ''), CHAR(160), '') [CorrValue]\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6522/"
] |
179,653
|
<p>I want to take the value stored in a 32 bit unsigned int, put it into four chars and then store the integer value of each of these chars in a string.</p>
<p>I think the first part goes like this:</p>
<pre><code>char a = orig << 8;
char b = orig << 8;
char c = orig << 8;
char d = orig << 8;
</code></pre>
|
[
{
"answer_id": 179666,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 1,
"selected": false,
"text": "char a = orig & 0xff;\norig >>= 8;\nchar b = orig & 0xff;\norig >>= 8;\nchar c = orig & 0xff;\norig >>= 8;\nchar d = orig & 0xff;\n 0x10111213 \"16 17 18 19\""
},
{
"answer_id": 179669,
"author": "Ates Goral",
"author_id": 23501,
"author_profile": "https://Stackoverflow.com/users/23501",
"pm_score": 0,
"selected": false,
"text": "sprintf(buffer, \"%lX\", orig);\n sprintf(buffer, \"%ld\", orig);\n snprintf"
},
{
"answer_id": 179675,
"author": "Vivek",
"author_id": 7418,
"author_profile": "https://Stackoverflow.com/users/7418",
"pm_score": 2,
"selected": false,
"text": "union #include <<iostream>>\n #include <<stdio.h>>\n using namespace std;\n\n union myunion\n {\n struct chars \n { \n unsigned char d, c, b, a;\n } mychars;\n\n unsigned int myint; \n };\n\n int main(void) \n {\n myunion u;\n\n u.myint = 0x41424344;\n\n cout << \"a = \" << u.mychars.a << endl;\n cout << \"b = \" << u.mychars.b << endl;\n cout << \"c = \" << u.mychars.c << endl;\n cout << \"d = \" << u.mychars.d << endl;\n }\n"
},
{
"answer_id": 179682,
"author": "friol",
"author_id": 23034,
"author_profile": "https://Stackoverflow.com/users/23034",
"pm_score": 3,
"selected": false,
"text": "unsigned char byte1=orig&0xff;\nunsigned char byte2=(orig>>8)&0xff;\nunsigned char byte3=(orig>>16)&0xff;\nunsigned char byte4=(orig>>24)&0xff;\n\nchar myString[256];\nsprintf(myString,\"%x %x %x %x\",byte1,byte2,byte3,byte4);\n"
},
{
"answer_id": 179694,
"author": "Ates Goral",
"author_id": 23501,
"author_profile": "https://Stackoverflow.com/users/23501",
"pm_score": 4,
"selected": true,
"text": "unsigned char a = orig & 0xff;\nunsigned char b = (orig >> 8) & 0xff;\nunsigned char c = (orig >> 16) & 0xff;\nunsigned char d = (orig >> 24) & 0xff;\n unsigned char *chars = (unsigned char *)(&orig);\nunsigned char a = chars[0];\nunsigned char b = chars[1];\nunsigned char c = chars[2];\nunsigned char d = chars[3];\n union charSplitter {\n struct {\n unsigned char a, b, c, d;\n } charValues;\n\n unsigned int intValue;\n};\n\ncharSplitter splitter;\nsplitter.intValue = orig;\n// splitter.charValues.a will give you first byte etc.\n a b c d"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1449/"
] |
179,665
|
<p>I have an array <code>NSMutableArray</code> with happy objects. These objects viciously turn on (leak) me whenever I try to clear the array of all the objects and repopulate it.</p>
<p>It's allocated in the init function like so</p>
<pre><code>self.list = [NSMutableArray array];
</code></pre>
<p>The different methods I have used to clear it out include:</p>
<pre><code>self.list = nil;
self.list = [NSMutableArray array];
</code></pre>
<p>and</p>
<pre><code>[self.eventList removeAllObjects];
</code></pre>
<p>Explicitly allocating and releasing the array doesn't work either. The leak ONLY occurs when I try to reset the list.</p>
<p>Am I missing a step when resetting or is this a different problem?</p>
|
[
{
"answer_id": 179695,
"author": "Elfred",
"author_id": 12636,
"author_profile": "https://Stackoverflow.com/users/12636",
"pm_score": 2,
"selected": false,
"text": "@property @property(retain) (EXC\\_BAD\\_ACCESS)"
},
{
"answer_id": 179892,
"author": "Nathan Kinsinger",
"author_id": 20045,
"author_profile": "https://Stackoverflow.com/users/20045",
"pm_score": 3,
"selected": false,
"text": "MyEvent *event = [[MyEvent alloc] initWithEventInfo:info];\n[self.eventList addObject:event];\n[event release];\n\nMyEvent *otherEvent = [[[MyEvent alloc] initWithEventInfo:otherInfo] autorelease];\n[self.eventList addObject:otherEvent];\n"
},
{
"answer_id": 180024,
"author": "Colin Wheeler",
"author_id": 2750,
"author_profile": "https://Stackoverflow.com/users/2750",
"pm_score": 0,
"selected": false,
"text": "NSMutableArray @property"
},
{
"answer_id": 190099,
"author": "mmalc",
"author_id": 23233,
"author_profile": "https://Stackoverflow.com/users/23233",
"pm_score": 4,
"selected": true,
"text": "- (void)addObjectsToArray {\n\n [list addObject:[[MyClass alloc] init];\n\n OtherClass *anotherObject = [[OtherClass alloc] init];\n [list addObject:anotherObject];\n}\n - (void)addObjectsToArray {\n\n MyClass *myObject = [[MyClass alloc] init];\n [list addObject:myObject];\n [myObject release];\n\n OtherClass *anotherObject = [[OtherClass alloc] init];\n [list addObject:anotherObject];\n [anotherObject release];\n}\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25004/"
] |
179,668
|
<p>I tried doing this:</p>
<pre><code>root.addEventListener("click",
function ()
{
navigateToURL(ClickURLRequest,"_self");
});
</code></pre>
<p>And it does add the event listener. I like using closures because they work well in this situation,</p>
<p>however, removing the event listener requires a reference to the original function, and since I used an anonymous closure, it does not work, I tried:</p>
<pre><code> root.removeEventListener("click",
function ()
{
navigateToURL(ClickURLRequest,"_self");
});
</code></pre>
<p>as well as:</p>
<pre><code> root.removeEventListener("click", function () {} );
</code></pre>
<p>The only way I found it would work was to ditch the anonymous closure and point the event listeners at a pre-existing function:</p>
<pre><code> function OnClick (e:Event)
{
navigateToURL(ClickURLRequest,"_self");
}
root.addEventListener("click", OnClick);
root.removeEventListener("click", OnClick);
</code></pre>
<p>Does anyone know a way to use anonymous closures for event handlers while still retaining the ability to remove them?</p>
|
[
{
"answer_id": 179842,
"author": "JustLogic",
"author_id": 21664,
"author_profile": "https://Stackoverflow.com/users/21664",
"pm_score": 0,
"selected": false,
"text": "root.removeEventListener(\"click\", arguments.callee );\n"
},
{
"answer_id": 179905,
"author": "BefittingTheorem",
"author_id": 16744,
"author_profile": "https://Stackoverflow.com/users/16744",
"pm_score": 5,
"selected": false,
"text": "\naddEventListener\n(\n Event.ACTIVATE, \n function(event:Event):void\n {\n (event.target as EventDispatcher).removeEventListener(event.type, arguments.callee) \n }\n)\n"
},
{
"answer_id": 213890,
"author": "Simon",
"author_id": 24727,
"author_profile": "https://Stackoverflow.com/users/24727",
"pm_score": -1,
"selected": false,
"text": "return"
},
{
"answer_id": 948547,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "addSelfDestructiveEventListener('roomRenderer', 'complete', trackAction, 'floorChanged');\n\nprivate function addSelfDestructiveEventListener(listenee:*, event:String, functionToCall:Function, StringArgs:String):void\n{\n this[listenee].addEventListener(event, function(event:Event):void\n {\n (event.target as EventDispatcher).removeEventListener(event.type, arguments.callee);\n functionToCall(StringArgs);\n })\n}\n"
},
{
"answer_id": 3195329,
"author": "Emerson Cardoso",
"author_id": 385590,
"author_profile": "https://Stackoverflow.com/users/385590",
"pm_score": 2,
"selected": false,
"text": "var closure:Function = null;\nroot.addEventListener(\"click\", \n closure = function () \n { \n navigateToURL(ClickURLRequest,\"_self\"); \n });\n\nroot.removeEventListener(\"click\", closure);\n"
},
{
"answer_id": 3894712,
"author": "Marcus Stade",
"author_id": 68909,
"author_profile": "https://Stackoverflow.com/users/68909",
"pm_score": 3,
"selected": false,
"text": "myDispatcher.addEventListener(\"click\", function(event:Event):void\n{\n IEventDispatcher(event.target).removeEventListener(event.type, arguments.callee);\n\n // Whatever else needs doing goes here\n});\n myLoader.addEventListener(\"complete\", function(event:Event):void\n{\n /* Even though the load is asynchronous, having the callback code inline\n * like this instead of scattered around makes it easier to understand,\n * in my opinion. */\n});\n var closure:Function;\n\nmyDispatcher.addEventListener(\"click\", function(event:Event):void\n{\n closure = arguments.callee;\n\n // Whatever else needs doing goes here\n});\n myDispatcher.removeEventListener(\"click\", closure);\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] |
179,676
|
<p>What is the best way to get a file (in this case, a .PDF, but any file will do) from a WebResponse and put it into a MemoryStream? Using .GetResponseStream() from WebResponse gets a Stream object, but if you want to convert that Stream to a specific type of stream, what do you do?</p>
|
[
{
"answer_id": 179990,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "//---------- Start HttpResponse\nif(objHttpWebResponse.StatusCode == HttpStatusCode.OK)\n {\n //Get response stream\n objResponseStream = objHttpWebResponse.GetResponseStream();\n\n //Load response stream into XMLReader\n objXMLReader = new XmlTextReader(objResponseStream);\n\n //Declare XMLDocument\n XmlDocument xmldoc = new XmlDocument();\n xmldoc.Load(objXMLReader);\n\n //Set XMLResponse object returned from XMLReader\n XMLResponse = xmldoc;\n\n //Close XMLReader\n objXMLReader.Close();\n }\n\n //Close HttpWebResponse\n objHttpWebResponse.Close();\n}\n"
},
{
"answer_id": 180505,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": -1,
"selected": false,
"text": " Dim request As WebRequest\n Dim response As WebResponse = Nothing\n Dim s As Stream = Nothing\n Dim fs As FileStream = Nothing\n Dim file As MemoryStream = Nothing\n\n Dim uri As New Uri(String.Format(\"http://forums.microsoft.com/forums/ShowPost.aspx?PostID=2992978&SiteID=1\"))\n request = WebRequest.Create(uri)\n request.Timeout = 10000\n response = request.GetResponse\n s = response.GetResponseStream\n\n '2 - Receive file as memorystream\n Dim read(256) As Byte\n Dim count As Int32 = s.Read(read, 0, read.Length)\n File = New MemoryStream\n Do While (count > 0)\n File.Write(read, 0, count)\n count = s.Read(read, 0, read.Length)\n Loop\n File.Position = 0\n 'Close responsestream\n s.Close()\n response.Close()\n\n '3 - Save file\n fs = New FileStream(\"c:\\test.html\", FileMode.CreateNew)\n count = file.Read(read, 0, read.Length)\n Do While (count > 0)\n fs.Write(read, 0, count)\n count = file.Read(read, 0, read.Length)\n Loop\n fs.Close()\n File.Close()\n"
},
{
"answer_id": 4924357,
"author": "Redwood",
"author_id": 1512,
"author_profile": "https://Stackoverflow.com/users/1512",
"pm_score": 5,
"selected": false,
"text": "FtpWebRequest MemoryStream Peek() Read() MemoryStream memStream;\nusing (Stream response = request.GetResponseStream()) {\n memStream = new MemoryStream();\n\n byte[] buffer = new byte[1024];\n int byteCount;\n do {\n byteCount = stream.Read(buffer, 0, buffer.Length);\n memStream.Write(buffer, 0, byteCount);\n } while (byteCount > 0);\n}\n\n// If you're going to be reading from the stream afterwords you're going to want to seek back to the beginning.\nmemStream.Seek(0, SeekOrigin.Begin);\n\n// Use memStream as required\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
179,700
|
<p>Is there a way to take a class name and convert it to a string in C#? </p>
<p>As part of the Entity Framework, the .Include method takes in a dot-delimited list of strings to join on when performing a query. I have the class model of what I want to join, and for reasons of refactoring and future code maintenance, I want to be able to have compile-time safety when referencing this class.</p>
<p>Thus, is there a way that I could do this:</p>
<pre><code>class Foo
{
}
tblBar.Include ( Foo.GetType().ToString() );
</code></pre>
<p>I don't think I can do GetType() without an instance. Any ideas?</p>
|
[
{
"answer_id": 179711,
"author": "Max Schmeling",
"author_id": 3226,
"author_profile": "https://Stackoverflow.com/users/3226",
"pm_score": 7,
"selected": false,
"text": ".GetType() GetType typeof(Foo).Name\n typeof(Foo).AssemblyQualifiedName\n"
},
{
"answer_id": 179715,
"author": "Brian",
"author_id": 19299,
"author_profile": "https://Stackoverflow.com/users/19299",
"pm_score": 2,
"selected": false,
"text": "typeof(Foo).ToString()\n"
},
{
"answer_id": 6711989,
"author": "Albino",
"author_id": 843267,
"author_profile": "https://Stackoverflow.com/users/843267",
"pm_score": 0,
"selected": false,
"text": "DbSet<contact> ObjectSet<contact> tblBar.Include(a => a.foo)"
},
{
"answer_id": 12692128,
"author": "Glade Mellor",
"author_id": 448675,
"author_profile": "https://Stackoverflow.com/users/448675",
"pm_score": 3,
"selected": false,
"text": "Type CLASS = typeof(MyClass);\n string CLASS_NAME = CLASS.Name;\n string NAMESPACE = CLASS.Namespace;\n"
},
{
"answer_id": 20080124,
"author": "Gustavo Mori",
"author_id": 556595,
"author_profile": "https://Stackoverflow.com/users/556595",
"pm_score": 0,
"selected": false,
"text": "class Foo\n{\n public static string ClassName\n {\n get\n {\n return MethodBase.GetCurrentMethod().DeclaringType.Name;\n }\n }\n}\n tblBar.Include(Foo.ClassName);\n tblBar.Include(\"Foo\");\n"
},
{
"answer_id": 71128769,
"author": "Francesco Puglisi",
"author_id": 579717,
"author_profile": "https://Stackoverflow.com/users/579717",
"pm_score": 2,
"selected": false,
"text": "typeof(Foo).ToString() nameof(Foo)\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24841/"
] |
179,706
|
<p>I am writing a site that uses strongly typed datasets. </p>
<p>The DBA who created the table made gave a column a value that represents a negative. The column is 'Do_Not_Estimate_Flag' where the column can contain 'T' or 'F'. I can't change the underlying table or the logic that fills it. What I want to do is to add a 'ESTIMATION_ALLOWED' column to the DataRow of my strongly typed DataSet. I have done this using the partial class that I can modify. (There is the autogenerated partial class and the non autogenerated partial class that I can safely modify.) The logic is in a property in the partial class. The trouble is that when the value is loaded ala </p>
<pre><code><%#DataBinder.Eval(Container.DataItem, "ESTIMATION_ALLOWED")%>
</code></pre>
<p>it goes straight to the underlying DataRow ignoring my property. How can I best achieve the desired result?</p>
<p>here is my code:</p>
<p>partial class MyFunkyDataTable
{</p>
<pre><code> private System.Data.DataColumn columnESTIMATION_ALLOWED;
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
public System.Data.DataColumn ESTIMATION_ALLOWEDColumn
{
get
{
return columnESTIMATION_ALLOWED;
}
}
public override void EndInit()
{
//init class
columnESTIMATION_ALLOWED = new System.Data.DataColumn("ESTIMATION_ALLOWED", typeof(string), null, global::System.Data.MappingType.Element);
Columns.Add(columnESTIMATION_ALLOWED);
columnESTIMATION_ALLOWED.ReadOnly = true;
//init Vars
columnESTIMATION_ALLOWED = Columns["ESTIMATION_ALLOWED"];
base.EndInit();
}
}
partial class MyFunkyRow
{
public string ESTIMATION_ALLOWED
{
get
{
if(DO_NOT_EST_FLAG == "N")
{
return "Yes";
}
return "No";
}
}
}
</code></pre>
|
[
{
"answer_id": 179820,
"author": "Joe",
"author_id": 13087,
"author_profile": "https://Stackoverflow.com/users/13087",
"pm_score": 2,
"selected": true,
"text": "<%#FormatFlag(DataBinder.Eval(Container.DataItem, \"Do_Not_Estimate_Flag\" ))%>\n protected string FormatFlag(object doNotEstimateFlag)\n{\n if (doNotEstimateFlag.ToString() == \"N\") return \"Yes\";\n return \"No\";\n} \n SELECT\n ...\n CASE WHEN Do_Not_Estimate_Flag = 'N' THEN 'Yes' ELSE 'No' END ESTIMATE_ALLOWED,\n ...\nFROM\n ...\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4491/"
] |
179,708
|
<p>Can anybody recommend a good method for determining the Rect of some wrapped text on an iPhone? I've tried all the built-in methods for NSString in the 2.1 SDK to no avail. The size methods never return sizes that allow me to completely fit wrapped text in my custom view.</p>
<p>I'm drawing some user customizable text that should always be as big as possible within the limits of my custom view. If I can determine the rect needed to completely enclose wrapped text for a given max width and font size, I can raise or lower the font size until the text is just big enough to completely fill the custom view without being clipped.</p>
<p>Any help is much appreciated!</p>
|
[
{
"answer_id": 179963,
"author": "Mike McMaster",
"author_id": 544,
"author_profile": "https://Stackoverflow.com/users/544",
"pm_score": 2,
"selected": false,
"text": "CGSize sizeForText = [theText sizeWithFont:theFont constrainedToSize:CGSizeMake(myMaxWidth, 9999)];\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
179,713
|
<p>How can you change the <code>href</code> attribute (link target) for a hyperlink using jQuery?</p>
|
[
{
"answer_id": 179717,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 12,
"selected": true,
"text": "$(\"a\").attr(\"href\", \"http://www.google.com/\")\n <a name=\"MyLinks\"></a>\n<a href=\"http://www.codeproject.com/\">The CodeProject</a>\n href <a> href $(\"a[href]\") //...\n href $(\"a[href='http://www.google.com/']\").attr('href', 'http://www.live.com/')\n href http://www.google.com/ href $(\"a[href^='http://stackoverflow.com']\")\n .each(function()\n { \n this.href = this.href.replace(/^http:\\/\\/beta\\.stackoverflow\\.com/, \n \"http://stackoverflow.com\");\n });\n http://stackoverflow.com"
},
{
"answer_id": 179719,
"author": "Peter Shinners",
"author_id": 17209,
"author_profile": "https://Stackoverflow.com/users/17209",
"pm_score": 6,
"selected": false,
"text": "attr $(\"a.mylink\").attr(\"href\", \"http://cupcream.com\");\n"
},
{
"answer_id": 213166,
"author": "flamingLogos",
"author_id": 8161,
"author_profile": "https://Stackoverflow.com/users/8161",
"pm_score": 6,
"selected": false,
"text": "<a href=\"http://www.google.com\">\n\n$(\"a[href='http://www.google.com/']\").attr('href', \n'http://maps.google.com/');\n <div class=\"content\">\n <p>...link to <a href=\"http://www.google.com/\">Google</a>\n in the content...</p>\n</div>\n\n<div class=\"footer\">\n Links: <a href=\"http://www.google.com/\">Google</a>\n</div>\n\n$(\".content a[href='http://www.google.com/']\").attr('href', \n'http://maps.google.com/');\n <div class=\"content\">\n <p>...link to <a href=\"http://www.google.com/\">Google</a>\n in the content...</p>\n <p>...second link to <a href=\"http://www.google.com/\" \n id=\"changeme\">Google</a>\n in the content...</p>\n</div>\n\n<div class=\"footer\">\n Links: <a href=\"http://www.google.com/\">Google</a>\n</div>\n\n$(\"a#changeme\").attr('href', \n'http://maps.google.com/');\n"
},
{
"answer_id": 4406279,
"author": "crafter",
"author_id": 475178,
"author_profile": "https://Stackoverflow.com/users/475178",
"pm_score": 4,
"selected": false,
"text": "<a rel='1' class=\"menu_link\" href=\"option1.html\">Option 1</a>\n<a rel='2' class=\"menu_link\" href=\"option2.html\">Option 2</a>\n\n$('.menu_link').live('click', function() {\n var thelink = $(this);\n alert ( thelink.html() );\n alert ( thelink.attr('href') );\n alert ( thelink.attr('rel') );\n\n return false;\n});\n"
},
{
"answer_id": 6348239,
"author": "Jerome",
"author_id": 798281,
"author_profile": "https://Stackoverflow.com/users/798281",
"pm_score": 8,
"selected": false,
"text": "$(\"a\").prop(\"href\", \"http://www.jakcms.com\")\n prop attr attr prop"
},
{
"answer_id": 28016553,
"author": "Josh Crozier",
"author_id": 2680216,
"author_profile": "https://Stackoverflow.com/users/2680216",
"pm_score": 6,
"selected": false,
"text": "href <a> var anchors = document.querySelectorAll('a');\nArray.prototype.forEach.call(anchors, function (element, index) {\n element.href = \"http://stackoverflow.com\";\n});\n href <a> href [href] a[href] var anchors = document.querySelectorAll('a[href]');\nArray.prototype.forEach.call(anchors, function (element, index) {\n element.href = \"http://stackoverflow.com\";\n});\n href <a> google.com a[href*=\"google.com\"] var anchors = document.querySelectorAll('a[href*=\"google.com\"]');\nArray.prototype.forEach.call(anchors, function (element, index) {\n element.href = \"http://stackoverflow.com\";\n});\n a[href$=\".png\"] <a> href .png a[href^=\"https://\"] <a> href https:// href <a> var anchors = document.querySelectorAll('a[href^=\"https://\"], a[href$=\".png\"]');\nArray.prototype.forEach.call(anchors, function (element, index) {\n element.href = \"http://stackoverflow.com\";\n});\n"
},
{
"answer_id": 31382408,
"author": "Anup",
"author_id": 2047151,
"author_profile": "https://Stackoverflow.com/users/2047151",
"pm_score": 3,
"selected": false,
"text": " $(\"a[href^='http://stackoverflow.com']\")\n .each(function()\n { \n this.href = this.href.replace(/^http:\\/\\/beta\\.stackoverflow\\.com/, \n \"http://stackoverflow.com\");\n });\n"
},
{
"answer_id": 39276418,
"author": "Pawel",
"author_id": 696535,
"author_profile": "https://Stackoverflow.com/users/696535",
"pm_score": 4,
"selected": false,
"text": "document.querySelector('#the-link').setAttribute('href', 'http://google.com');\n"
},
{
"answer_id": 43006005,
"author": "Cooper",
"author_id": 7215091,
"author_profile": "https://Stackoverflow.com/users/7215091",
"pm_score": 2,
"selected": false,
"text": "?><script type=\"text/javascript\">\njQuery(document).ready(function() {\njQuery(\"div.fusion-logo a\").attr(\"href\",\"tel:303-985-9850\");\n});\n</script>\n [myjavascript]\n"
},
{
"answer_id": 49568546,
"author": "Aman Chhabra",
"author_id": 1262248,
"author_profile": "https://Stackoverflow.com/users/1262248",
"pm_score": 4,
"selected": false,
"text": "$(\"a\").attr(\"href\", \"https://stackoverflow.com/\") \n $(\"a\").prop(\"href\", \"https://stackoverflow.com/\")\n $(\"a\") $(\"a:eq(0)\") active $(\"a.active\") profileLink $(\"a#proileLink\") $(\"a:first\") $(\"[href]\") $(\"a[href='www.stackoverflow.com']\") $(\"a[href!='www.stackoverflow.com']\") $(\"a[href*='www.stackoverflow.com']\") $(\"a[href^='www.stackoverflow.com']\") $(\"a[href$='www.stackoverflow.com']\") $(\"a[href^='http://www.google.com']\")\n .each(function()\n { \n this.href = this.href.replace(/http:\\/\\/www.google.com\\//gi, function (x) {\n return \"http://proxywebsite.com/?query=\"+encodeURIComponent(x);\n });\n });\n"
},
{
"answer_id": 54263304,
"author": "Alireza",
"author_id": 5423108,
"author_profile": "https://Stackoverflow.com/users/5423108",
"pm_score": 3,
"selected": false,
"text": "href href <a id=\"ali\" alt=\"Ali\" href=\"http://dezfoolian.com.au\">Alireza Dezfoolian</a>\n document.getElementById(\"ali\").setAttribute(\"href\", \"https://stackoverflow.com\");\n $(\"#ali\").attr(\"href\", \"https://stackoverflow.com\");\n $(\"#ali\").prop(\"href\", \"https://stackoverflow.com\");\n JS"
},
{
"answer_id": 62503176,
"author": "Kamil Kiełczewski",
"author_id": 860099,
"author_profile": "https://Stackoverflow.com/users/860099",
"pm_score": 2,
"selected": false,
"text": "link.href = 'https://...'\n link.href = 'https://stackoverflow.com' <a id=\"link\" href=\"#\">Click me</a>"
},
{
"answer_id": 70064573,
"author": "CooleKikker2",
"author_id": 16966832,
"author_profile": "https://Stackoverflow.com/users/16966832",
"pm_score": 4,
"selected": false,
"text": "$(\"#link\").attr(\"href\", \"https://coenvink.com/\")\n $(\"#link\")\n .attr(\"href\", \"https://coenvink.com/\")\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3747/"
] |
179,716
|
<p>I have a series of datetime objects and would like to calculate the average delta between them.</p>
<p>For example, if the input was <code>(2008-10-01 12:15:00, 2008-10-01 12:25:00, 2008-10-01 12:35:00)</code>, then the average delta would be exactly 00:10:00, or 10 minutes.</p>
<p>Any suggestions on how to calculate this using Python?</p>
|
[
{
"answer_id": 179738,
"author": "Randy",
"author_id": 9361,
"author_profile": "https://Stackoverflow.com/users/9361",
"pm_score": 4,
"selected": false,
"text": "mx = max(a)\nmn = min(a)\navg = (mx-mn)/(len(a)-1)\n"
},
{
"answer_id": 181239,
"author": "Claudiu",
"author_id": 15055,
"author_profile": "https://Stackoverflow.com/users/15055",
"pm_score": 2,
"selected": false,
"text": "a sumdeltas = timedelta(seconds=0)\ni = 1\nwhile i < len(a):\n sumdeltas += a[i-1] - a[i]\n i = i + 1\n\navg_delta = sumdeltas / (len(a) - 1)\n"
},
{
"answer_id": 1571406,
"author": "sergey",
"author_id": 190490,
"author_profile": "https://Stackoverflow.com/users/190490",
"pm_score": 0,
"selected": false,
"text": "from datetime import timedelta\n\ndef avg(a):\n numdeltas = len(a) - 1\n sumdeltas = timedelta(seconds=0)\n\n i = 1\n while i < len(a):\n delta = abs(a[i] - a[i-1])\n try:\n sumdeltas += delta\n except:\n raise\n i += 1\n avg = sumdeltas / numdeltas\n return avg\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1155/"
] |
179,720
|
<p>On Windows NTFS there is a nice but mostly unused feature called
"Alternate Data Streams" (ADS) which I recently used in a hobby-dev project.</p>
<p>On Mac HFS+ there is also a similarly nice but mostly unused feature called "named forks".</p>
<p>I am thinking of porting this project to Linux, but I do not know if any Filesystem on linux has such a feature?</p>
|
[
{
"answer_id": 179734,
"author": "Peter Shinners",
"author_id": 17209,
"author_profile": "https://Stackoverflow.com/users/17209",
"pm_score": 0,
"selected": false,
"text": "extended attributes xattr xattrs"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23264/"
] |
179,723
|
<p>By that I mean, what do I need to do to have useful assertions in my code?</p>
<p>MFC is quite easy, i just use ASSERT(something).</p>
<p>What's the non-MFC way?</p>
<p><strong>Edit:</strong> Is it possible to stop assert breaking in assert.c rather than than my file which called assert()?</p>
<p><strong>Edit:</strong> What's the difference between <code><assert.h></code> & <code><cassert></code>?</p>
<p><strong>Accepted Answer:</strong> Loads of great answers in this post, I wish I could accept more than one answer (or someone would combine them all). So answer gets awarded to Ferruccio (for first answer).</p>
|
[
{
"answer_id": 179733,
"author": "Ferruccio",
"author_id": 4086,
"author_profile": "https://Stackoverflow.com/users/4086",
"pm_score": 6,
"selected": true,
"text": "#include <cassert>\n\nassert(something);\n #include <boost/static_assert.hpp>\n\nBOOST_STATIC_ASSERT(sizeof(int) == 4); // compile fails if ints aren't 32-bit\n"
},
{
"answer_id": 179778,
"author": "Ates Goral",
"author_id": 23501,
"author_profile": "https://Stackoverflow.com/users/23501",
"pm_score": 3,
"selected": false,
"text": "__debugbreak #define MYASSERT(EXPR, MSG) if (!(EXPR)) throw MSG;\n #define MYASSERT(EXPR) if (!(EXPR)) __debugbreak();\n"
},
{
"answer_id": 179848,
"author": "Dustin Getz",
"author_id": 20003,
"author_profile": "https://Stackoverflow.com/users/20003",
"pm_score": 1,
"selected": false,
"text": "// cassert standard header\n#include <yvals.h>\n#include <assert.h>\n <cxxx>"
},
{
"answer_id": 179876,
"author": "Miquella",
"author_id": 16313,
"author_profile": "https://Stackoverflow.com/users/16313",
"pm_score": 4,
"selected": false,
"text": "#error assert() <cassert> NDEBUG ASSERT() static_assert static_assert assert() ASSERT()"
},
{
"answer_id": 179883,
"author": "Michael Labbé",
"author_id": 22244,
"author_profile": "https://Stackoverflow.com/users/22244",
"pm_score": 3,
"selected": false,
"text": "#include <cassert>\n\n/* Some code later */\nassert( true );\n switch ( someVal ):\n{\ncase 0:\ncase 1:\n break;\ndefault:\n assert( false ); /* should never happen */\n}\n assert( !\"This assert will always hit.\" );\n"
},
{
"answer_id": 180109,
"author": "Constantin",
"author_id": 20310,
"author_profile": "https://Stackoverflow.com/users/20310",
"pm_score": 3,
"selected": false,
"text": "#include <crtdbg.h>\n#include <sstream>\n...\n// displays nondescript message box when x <= 42\n_ASSERT(x > 42);\n// displays message box with \"x > 42\" message when x <= 42\n_ASSERTE(x > 42);\n// displays message box with computed message \"x is ...!\" when x <= 42\n_ASSERT_EXPR(\n x > 42, (std::stringstream() << L\"x is \" << x << L\"!\").str().c_str());\n"
},
{
"answer_id": 180493,
"author": "paercebal",
"author_id": 14089,
"author_profile": "https://Stackoverflow.com/users/14089",
"pm_score": 3,
"selected": false,
"text": "bool doSomething(MyObject * p)\n{\n // If p is NULL, then the app will abort/exit\n XXX_ASSERT((p != NULL), \"Hey ! p is NULL !\") ;\n \n // etc.\n}\n bool doSomething(MyObject * p)\n{\n if(p == NULL)\n {\n // First, XXX_RAISE_ERROR will alert the user as configured in the INI file\n // perhaps even offering to open a debug session\n XXX_RAISE_ERROR(\"Hey ! p is NULL !\") ;\n // here, you can handle the error as you wish\n // Than means allocating p, or throwing an exception, or\n // returning false, etc.\n // Whereas the XXX_ASSERT could simply crash.\n }\n \n // etc.\n}\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/986/"
] |
179,742
|
<p>VB 2008.</p>
<p>I have several text boxes on a form and I want each of them to use the same event handler. I know how to manually wire each one up to the handler, but I'm looking for a more generic way so if I add more text boxes they will automatically be hooked up to the event handler.</p>
<p>Ideas?</p>
<p>EDIT: Using the C# sample from MusiGenesis (and with the help of the comment left by nick), I wrote this VB code:</p>
<pre><code>Private Sub AssociateTextboxEventHandler()
For Each c As Control In Me.Controls
If TypeOf c Is TextBox Then
AddHandler c.TextChanged, AddressOf tb_TextChanged
End If
Next
End Sub
</code></pre>
<p>Thanks a lot! SO is great.</p>
|
[
{
"answer_id": 179824,
"author": "MusiGenesis",
"author_id": 14606,
"author_profile": "https://Stackoverflow.com/users/14606",
"pm_score": 4,
"selected": true,
"text": "private void Form1_Load(object sender, EventArgs e)\n{\n foreach (Control ctrl in this.Controls)\n {\n if (ctrl is TextBox)\n {\n TextBox tb = (TextBox)ctrl;\n tb.TextChanged += new EventHandler(tb_TextChanged);\n }\n }\n\n}\n\nvoid tb_TextChanged(object sender, EventArgs e)\n{\n TextBox tb = (TextBox)sender;\n tb.Tag = \"CHANGED\"; // or whatever\n}\n"
},
{
"answer_id": 179923,
"author": "osp70",
"author_id": 2357,
"author_profile": "https://Stackoverflow.com/users/2357",
"pm_score": 0,
"selected": false,
"text": "Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load\n UpdateControls(Me)\nEnd Sub\n\nPrivate Sub UpdateControls(ByVal myControlIN As Control)\n Dim myControl\n\n For Each myControl In myControlIN.Controls\n UpdateControls(myControl)\n Dim myTextbox As TextBox\n\n If TypeOf myControl Is TextBox Then\n myTextbox = myControl\n AddHandler myTextbox.TextChanged, AddressOf TextBox_TextChanged\n End If\n Next\n\nEnd Sub\n\nPrivate Sub TextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)\n MsgBox(\"text changed in \" & CType(sender, TextBox).Name)\nEnd Sub\n"
},
{
"answer_id": 20282205,
"author": "Sergio",
"author_id": 1622364,
"author_profile": "https://Stackoverflow.com/users/1622364",
"pm_score": 2,
"selected": false,
"text": "For Each c As TextBox In Controls.OfType(Of TextBox)()\n AddHandler c.TextChanged, AddressOf tb_TextChanged\nNext\n"
},
{
"answer_id": 34000103,
"author": "hirnwunde",
"author_id": 3382612,
"author_profile": "https://Stackoverflow.com/users/3382612",
"pm_score": 0,
"selected": false,
"text": "' cycle through TabPages ...\nFor Each page As TabPage In Me.TabControl1.Controls.OfType(Of TabPage)()\n ' in every TabPage cycle through Groupboxes ...\n For Each gbox As GroupBox In page.Controls.OfType(Of GroupBox)()\n ' and in every TextBox inside the actual GroupBox\n For Each tbox As TextBox In gbox.Controls.OfType(Of TextBox)()\n AddHandler tbox.TextChanged, AddressOf _TextChanged\n Next\n Next\nNext\n\nPrivate Sub _TextChanged(sender As System.Object, e As System.EventArgs)\n somethingWasChanged = True\nEnd Sub\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2441/"
] |
179,745
|
<p>This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together:</p>
<ul>
<li><p><strong>Firstly</strong>: Given an established Java project, what are some decent ways to speed it up beyond just plain in-code optimization?</p></li>
<li><p><strong>Secondly</strong>: When writing a program from scratch in Java, what are some good ways to greatly improve performance?</p></li>
</ul>
<p><strong>Please stay away from general optimization techniques unless they are <em>Java specific</em>.</strong></p>
<p>I asked this about <a href="https://stackoverflow.com/questions/172720/speeding-up-python">Python</a> and <a href="https://stackoverflow.com/questions/177122/speeding-up-perl">Perl</a> earlier. For Java I'm wondering what good tips/tricks are out there to improve performance and if there are any particularly good Java profilers.</p>
|
[
{
"answer_id": 179841,
"author": "Vinnie",
"author_id": 2890,
"author_profile": "https://Stackoverflow.com/users/2890",
"pm_score": 1,
"selected": false,
"text": "-xmx -xms"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/145/"
] |
179,752
|
<p>Lets say on my page I have this function:</p>
<pre><code> function ReturnFoo(bar)
{
return bar.toString() + "foo";
}
</code></pre>
<p>Now, I would like to have this called from ASP .NET, hopefully with the ASP .NET AJAX framework, as I am already using it in this codebase (I have already spent the 100k, might as well use it).</p>
<p>Also, I would like to get back the output that is returned from this function and then assign it to a variable created on the server side. And this is restricted to ASP .NET 2.0</p>
|
[
{
"answer_id": 233007,
"author": "Timothy Khouri",
"author_id": 11917,
"author_profile": "https://Stackoverflow.com/users/11917",
"pm_score": 0,
"selected": false,
"text": "private void Page_Load()\n{\n string someValue = EXECUTE_JS_ON_CLIENT_AND_GET_RESULT();\n\n // do some stuff here while still on the server...\n}\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7952/"
] |
179,768
|
<p>A few questions on MS Access databases -</p>
<p>Size: Are there limits to the size of an access database? The reason i ask is that we have an access database that has a few simple tables. The size of the db is about 1GB. When I do a query on it, i see it taking over 10 minutes to run. </p>
<p>With proper indexing, should MS Access be able to handle this or are there fundamental limitations to the technology.</p>
<p>This is MS Access XP. </p>
<p>Also, does MS Access support db transactions, commit and rollback?</p>
|
[
{
"answer_id": 183775,
"author": "David-W-Fenton",
"author_id": 9787,
"author_profile": "https://Stackoverflow.com/users/9787",
"pm_score": 0,
"selected": false,
"text": "WHERE Year([MyTable].[MyDate]) = 2002\n WHERE MyTable.MyDate Between #1/1/2002# And #12/31/2002#\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] |
179,779
|
<p>I am writing code for a search results page that needs to highlight search terms. The terms happen to occur within table cells (the app is iterating through GridView Row Cells), and these table cells may have HTML.</p>
<p>Currently, my code looks like this (relevant hunks shown below):</p>
<pre><code>const string highlightPattern = @"<span class=""Highlight"">$0</span>";
DataBoundLiteralControl litCustomerComments = (DataBoundLiteralControl)e.Row.Cells[CUSTOMERCOMMENTS_COLUMN].Controls[0];
// Turn "term1 term2" into "(term1|term2)"
string spaceDelimited = txtTextFilter.Text.Trim();
string pipeDelimited = string.Join("|", spaceDelimited.Split(new[] {" "}, StringSplitOptions.RemoveEmptyEntries));
string searchPattern = "(" + pipeDelimited + ")";
// Highlight search terms in Customer - Comments column
e.Row.Cells[CUSTOMERCOMMENTS_COLUMN].Text = Regex.Replace(litCustomerComments.Text, searchPattern, highlightPattern, RegexOptions.IgnoreCase);
</code></pre>
<p>Amazingly it works. BUT, sometimes the text I am matching on is HTML that looks like this:</p>
<pre><code><span class="CustomerName">Fred</span> was a classy individual.
</code></pre>
<p>And if you search for "class" I want the highlight code to wrap the "class" in "classy" but of course not the HTML attribute "class" that happens to be in there! If you search for "Fred", that should be highlighted.</p>
<p>So what's a good regex that will make sure matches happen only OUTSIDE the html tags? It doesn't have to be super hardcore. Simply making sure the match is not between < and > would work fine, I think.</p>
|
[
{
"answer_id": 181882,
"author": "Julien Hoarau",
"author_id": 12248,
"author_profile": "https://Stackoverflow.com/users/12248",
"pm_score": 5,
"selected": true,
"text": "(?<!<[^>]*)(regex you want to check: Fred|span) <[^>]* const string notInsideBracketsRegex = @\"(?<!<[^>]*)\";\nconst string highlightPattern = @\"<span class=\"\"Highlight\"\">$0</span>\";\nDataBoundLiteralControl litCustomerComments = (DataBoundLiteralControl)e.Row.Cells[CUSTOMERCOMMENTS_COLUMN].Controls[0];\n\n// Turn \"term1 term2\" into \"(term1|term2)\"\nstring spaceDelimited = txtTextFilter.Text.Trim();\nstring pipeDelimited = string.Join(\"|\", spaceDelimited.Split(new[] {\" \"}, StringSplitOptions.RemoveEmptyEntries));\nstring searchPattern = \"(\" + pipeDelimited + \")\";\nsearchPattern = notInsideBracketsRegex + searchPattern;\n\n// Highlight search terms in Customer - Comments column\ne.Row.Cells[CUSTOMERCOMMENTS_COLUMN].Text = Regex.Replace(litCustomerComments.Text, searchPattern, highlightPattern, RegexOptions.IgnoreCase);\n"
},
{
"answer_id": 181902,
"author": "MSalters",
"author_id": 15416,
"author_profile": "https://Stackoverflow.com/users/15416",
"pm_score": 0,
"selected": false,
"text": "\"<span class=\"CustomerName>Fred.</span> is a good customer (<![CDATA[ >10000$ ]]> )\" CDATA <![CDATA ]]> CDATA <![CDATA"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13700/"
] |
179,796
|
<p>In a VS2008 web site project, I have a page open in split view. I try to drag an Infragistics web control onto the page's design surface. Nothing happens. I try to drag same onto the htmlz. Dialog box with </p>
<blockquote>
<p>The operation could not be completed. Invalid formatetc structure. </p>
</blockquote>
<p>Subsequently the dragged control does not appear in the design surface or html.</p>
<p>Project compiles fine, runs fine. The error is just at at design-time. </p>
<p>Tried resetting the toolbox and re-adding the Infragistics controls. Cleaned project and rebuilt solution.</p>
<p>Help?</p>
<p>Further info: this is not an error specific to Infragistics (eg <a href="http://www.google.com/search?q=the+operation+could+not+be+completed.+invalid+formatetc+structure&ie=utf-8&oe=utf-8&aq=t" rel="nofollow noreferrer">http://www.google.com/search?q=the+operation+could+not+be+completed.+invalid+formatetc+structure&ie=utf-8&oe=utf-8&aq=t</a>). There are various voodoo solutions for this on other boards, but I'm never happy with a vague "I reinstalled VS and then wiped my hd and then performed a unicorn sacrifice on my keyboard then it works!" Specifics please--what type of unicorn exactly?</p>
<p>Further configuration info: Straight-laced VS2008 w/no SP1 or installed products. Does have hotfixes, but last ones installed a couple months ago (repro steps done many times since w/no problem).</p>
|
[
{
"answer_id": 6169841,
"author": "Gabriel Oliva",
"author_id": 775410,
"author_profile": "https://Stackoverflow.com/users/775410",
"pm_score": 1,
"selected": false,
"text": "<system.web>\n <!-- \n Set compilation debug=\"true\" to insert debugging \n symbols into the compiled page. Because this \n affects performance, set this value to true only \n during development.\n -->\n <compilation debug=\"true\">\n <assemblies>\n <add assembly=\"System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089\"/>\n <add assembly=\"System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35\"/>\n <add assembly=\"System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089\"/>\n <add assembly=\"System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089\"/>\n <add assembly=\"DevExpress.Web.v9.2, Version=9.2.9.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A\"/>\n <add assembly=\"System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A\"/>\n <add assembly=\"DevExpress.Data.v9.2, Version=9.2.9.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A\"/>\n <add assembly=\"System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089\"/></assemblies>\n </compilation>\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2637/"
] |
179,799
|
<p>Yesterday I tried to get started with Java RMI. I found this sun tutorial (<a href="http://java.sun.com/docs/books/tutorial/rmi/index.html" rel="nofollow noreferrer">http://java.sun.com/docs/books/tutorial/rmi/index.html</a>) and started with the server implemantation. But everytime I start the pogram (the rmiregistry is running) I get an AccessControlException with the following StackTrace:</p>
<pre><code>LoginImpl exception:
java.security.AccessControlException: access denied (java.io.FilePermission \\\C\ProjX\server\serverProj\bin\usermanager read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
at java.security.AccessController.checkPermission(AccessController.java:427)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkRead(SecurityManager.java:871)
at java.io.File.exists(File.java:700)
at sun.net.www.protocol.file.Handler.openConnection(Handler.java:80)
at sun.net.www.protocol.file.Handler.openConnection(Handler.java:55)
at java.net.URL.openConnection(URL.java:943)
at sun.rmi.server.LoaderHandler.addPermissionsForURLs(LoaderHandler.java:1020)
at sun.rmi.server.LoaderHandler.access$300(LoaderHandler.java:52)
at sun.rmi.server.LoaderHandler$Loader.<init>(LoaderHandler.java:1108)
at sun.rmi.server.LoaderHandler$Loader.<init>(LoaderHandler.java:1089)
at sun.rmi.server.LoaderHandler$1.run(LoaderHandler.java:861)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.server.LoaderHandler.lookupLoader(LoaderHandler.java:858)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:541)
at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:628)
at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:294)
at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:238)
at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1494)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1457)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1693)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:375)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:240)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:595)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at startserver.StartServer.main(StartServer.java:22)
</code></pre>
<p>My <code>server.policy</code> file looks like this:</p>
<pre><code>grant {
permission java.security.AllPermission;
};
</code></pre>
<p>But I have also tried this one:</p>
<pre><code>grant {
permission java.security.AllPermission;
permission java.io.FilePermission "file://C:/ProjX/server/serverProj/bin/usermanager", "read";
};
</code></pre>
<p>... and this one (and several others :-():</p>
<pre><code>grant codeBase "file:///-" {
permission java.security.AllPermission;
};
</code></pre>
<p>But in every case the result is the same. And yes, the policy file is in path (I see a Parse Exception, when I write wrong statments into the policy-file). I tried out several other "/" and "" constellations but it has no effect.</p>
<p>I use Eclipse and my VM-Parameters are like this:</p>
<pre><code>-cp C:\ProjX\server\serverProj\bin\usermanager\
-Djava.rmi.server.codebase=file://C:/ProjX/server/serverProj/bin/usermanager/
-Djava.rmi.server.hostname=XYZ (anonymized)
-Djava.security.policy=server.policy
</code></pre>
<p>The compiled Remote-Interface and the interface-implementation class (LoginImpl) classes are in this path: "C:/ProjX/server/serverProj/bin/usermanager/". The main method, where I instanciate and rebind the stub to the registry is in another package and looks like this:</p>
<pre><code>public static void main(String[] args) {
if (System.getSecurityManager() == null) {
System.setSecurityManager(new SecurityManager());
}
try {
String name = "Login";
Login login = new LoginImpl();
Login stub = (Login) UnicastRemoteObject.exportObject(login, 0);
Registry registry = LocateRegistry.getRegistry();
registry.rebind(name, stub);
System.out.println("LoginImpl bound");
} catch (Exception e) {
System.err.println("LoginImpl exception:");
e.printStackTrace();
}
}
</code></pre>
<p>Does anybody have an advice for me?</p>
<hr />
<p>So the question is the same (the <code>java.rmi.UnmarshalException</code> shows that changing the codebase is not the solution of my AccessControlException). And no: I don't want to buy a plugin "G B".</p>
|
[
{
"answer_id": 180176,
"author": "Tom Hawtin - tackline",
"author_id": 4725,
"author_profile": "https://Stackoverflow.com/users/4725",
"pm_score": 3,
"selected": false,
"text": "-Djava.rmi.server.codebase=file://C:/ProjX/server/serverProj/bin/usermanager/\n \"file:///C:/...\" \"file:/C:/...\" \"http://C:/...\" C"
},
{
"answer_id": 201917,
"author": "bhavanki",
"author_id": 24184,
"author_profile": "https://Stackoverflow.com/users/24184",
"pm_score": 0,
"selected": false,
"text": "-J-Djava.security.policy=all.policy"
},
{
"answer_id": 202213,
"author": "user25913",
"author_id": 25913,
"author_profile": "https://Stackoverflow.com/users/25913",
"pm_score": 3,
"selected": false,
"text": "-cp C:\\ProjX\\server\\serverProj\\bin\\usermanager\\\n-Djava.rmi.server.codebase=file://C:/ProjX/server/serverProj/bin/usermanager/\n-Djava.rmi.server.hostname=XYZ (anonymized)\n-Djava.security.policy=server.policy\n -Djava.rmi.server.codebase=file:/C:/ProjX/server/serverProj/bin/\n-Djava.rmi.server.hostname=XYZ (anonymized)\n-Djava.security.policy=server.policy\n"
},
{
"answer_id": 284827,
"author": "Piotr Kochański",
"author_id": 34102,
"author_profile": "https://Stackoverflow.com/users/34102",
"pm_score": 2,
"selected": false,
"text": "Hello h = null;\nProperties props = System.getProperties();\nSystem.setProperty(\"java.rmi.server.codebase\", \"file:/C:/PROJECTX/bin/\");\ntry {\n h = new HelloImpl();\n Naming.bind(\"//localhost:1099/HelloService\", h);\n System.out.println(\"Serwis gotów...\");\n} catch (RemoteException e) {\n e.printStackTrace();\n} catch (MalformedURLException e) {\n e.printStackTrace();\n} catch (AlreadyBoundException e) {\n e.printStackTrace();\n}\n Hello"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179799",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25913/"
] |
179,826
|
<p>Does anyone know of crossbrowser equivalent of explicitOriginalTarget event parameter? This parameter is Mozilla specific and it gives me the element that caused the blur. Let's say i have a text input and a link on my page. Text input has the focus. If I click on the link, text input's blur event gives me the link element in Firefox via explicitOriginalTarget parameter.</p>
<p>I am extending Autocompleter.Base's onBlur method to not hide the search results when search field loses focus to given elements. By default, onBlur method hides if search-field loses focus to any element.</p>
<pre><code>Autocompleter.Base.prototype.onBlur = Autocompleter.Base.prototype.onBlur.wrap(
function(origfunc, ev) {
var newTargetElement = (ev.explicitOriginalTarget.nodeType == 3 ? ev.explicitOriginalTarget.parentNode: ev.explicitOriginalTarget); // FIX: This works only in firefox because of event's explicitOriginalTarget property
var callOriginalFunction = true;
for (i = 0; i < obj.options.validEventElements.length; i++) {
if ($(obj.options.validEventElements[i])) {
if (newTargetElement.descendantOf($(obj.options.validEventElements[i])) == true || newTargetElement == $(obj.options.validEventElements[i])) {
callOriginalFunction = false;
break;
}
}
}
if (callOriginalFunction) {
return origFunc(ev);
}
}
);
new Ajax.Autocompleter("search-field", "search-results", 'getresults.php', { validEventElements: ['search-field','result-count'] });
</code></pre>
<p>Thanks.</p>
|
[
{
"answer_id": 9607278,
"author": "Kotei",
"author_id": 1255475,
"author_profile": "https://Stackoverflow.com/users/1255475",
"pm_score": 0,
"selected": false,
"text": "srcElement if( !selectTag.explicitOriginalTarget )\n selectTag.explicitOriginalTarget = selectTag.srcElement;\n"
},
{
"answer_id": 10457820,
"author": "Allan Rofer",
"author_id": 1376136,
"author_profile": "https://Stackoverflow.com/users/1376136",
"pm_score": 2,
"selected": false,
"text": "srcElement explicitOriginalTarget onClick onChange srcElement explicitOriginalTarget event.x event.y explicitOriginalTarget onChange mousemove mouseout onChange"
},
{
"answer_id": 73765924,
"author": "balping",
"author_id": 898783,
"author_profile": "https://Stackoverflow.com/users/898783",
"pm_score": 0,
"selected": false,
"text": "submitter let form = document.querySelector(\"form\");\nform.addEventListener(\"submit\", (event) => {\n let submitter = event.submitter; //either a form input or a submit button\n});\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25768/"
] |
179,834
|
<p>I have a multi-timezone web application that stores all of the datetime values in UTC in the database, when actions happen on the server, I can easily convert the time into UTC.</p>
<p>However, when a client enters a time or time span, what is the best way to detect and store it?</p>
<p>I am currently doing the following:</p>
<ol>
<li>Get the value of Date.getTimezoneOffset() (javascript) </li>
<li>Post that to the server-side code via the ICallbackEventHandler on Page.</li>
<li>Store that value in the session </li>
<li>On any subsequent request, calculate the output/input datetime value using the client's timezone.</li>
</ol>
<p>Regardless of the actual implementation, this seems like an in-elegant solution. Does anyone have a better method?</p>
|
[
{
"answer_id": 179866,
"author": "Mnebuerquo",
"author_id": 5114,
"author_profile": "https://Stackoverflow.com/users/5114",
"pm_score": 3,
"selected": true,
"text": "each()"
},
{
"answer_id": 179873,
"author": "Hermooz",
"author_id": 25912,
"author_profile": "https://Stackoverflow.com/users/25912",
"pm_score": 2,
"selected": false,
"text": "If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8360/"
] |
179,839
|
<p>Basically, I'm trying to selectively copy a table from one database to another. I have two different [Oracle] databases (e.g., running on different hosts) with the same schema. I'm interested in a efficient way to load Table A in DB1 with the result of running a select on Table A in DB2. I'm using JDBC, if that's relevant.</p>
|
[
{
"answer_id": 179870,
"author": "CaptainPicard",
"author_id": 15203,
"author_profile": "https://Stackoverflow.com/users/15203",
"pm_score": 4,
"selected": true,
"text": "create database link other_db connect to remote_user identified by remote_passwd using remote_tnsname;\n\ncreate table a as select * from a@other_db;\n"
}
] |
2008/10/07
|
[
"https://Stackoverflow.com/questions/179839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25915/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.