qid
int64 4
19.1M
| question
stringlengths 18
48.3k
| answers
list | date
stringlengths 10
10
| metadata
sequence |
---|---|---|---|---|
4,418 | <p>The firewall I'm behind is running Microsoft ISA server in NTLM-only mode. Hash anyone have success getting their Ruby gems to install/update via Ruby SSPI gem or other method?</p>
<p>... or am I just being lazy?</p>
<p>Note: rubysspi-1.2.4 does not work.</p>
<p>This also works for "igem", part of the IronRuby project</p>
| [
{
"answer_id": 4420,
"author": "Jarin Udom",
"author_id": 574,
"author_profile": "https://Stackoverflow.com/users/574",
"pm_score": 3,
"selected": false,
"text": "PARENT_PROXY PARENT_PROXY_PORT cd aps097; python main.py gem install—http-proxy http://localhost:5865/ library"
},
{
"answer_id": 4431,
"author": "Mike Minutillo",
"author_id": 358,
"author_profile": "https://Stackoverflow.com/users/358",
"pm_score": 9,
"selected": true,
"text": "HTTP_PROXY SET HTTP_PROXY=http://%USER%:%PASSWORD%@%SERVER%:%PORT%\n SET HTTP_PROXY=http://wolfbyte:secret@pigsy:8080\n"
},
{
"answer_id": 4187271,
"author": "Peter Moresi",
"author_id": 426602,
"author_profile": "https://Stackoverflow.com/users/426602",
"pm_score": 8,
"selected": false,
"text": "$ gem install --http-proxy http://localhost:8888 $gem_name\n"
},
{
"answer_id": 7315150,
"author": "Christian F",
"author_id": 722711,
"author_profile": "https://Stackoverflow.com/users/722711",
"pm_score": 3,
"selected": false,
"text": "tsocks gem install ...\n tsocks bundle install\n"
},
{
"answer_id": 9382152,
"author": "Benjamin Wootton",
"author_id": 247573,
"author_profile": "https://Stackoverflow.com/users/247573",
"pm_score": 4,
"selected": false,
"text": "set HTTP_PROXY=some.proxy.com\nset HTTP_PROXY_USER=user\nset HTTP_PROXY_PASS=password\n user:password@"
},
{
"answer_id": 9866308,
"author": "SethRocker",
"author_id": 439133,
"author_profile": "https://Stackoverflow.com/users/439133",
"pm_score": 7,
"selected": false,
"text": "gem install --http-proxy http://COMPANY.PROXY.ADDRESS $gem_name\n"
},
{
"answer_id": 11769049,
"author": "kfox",
"author_id": 575027,
"author_profile": "https://Stackoverflow.com/users/575027",
"pm_score": 5,
"selected": false,
"text": "gem install -p http://proxy_ip:proxy_port rails\n -p"
},
{
"answer_id": 13563827,
"author": "Zander",
"author_id": 91359,
"author_profile": "https://Stackoverflow.com/users/91359",
"pm_score": 2,
"selected": false,
"text": "sudo gem install [path/to/downloaded/gem/file]"
},
{
"answer_id": 19596410,
"author": "Saikrishna Rao",
"author_id": 1128212,
"author_profile": "https://Stackoverflow.com/users/1128212",
"pm_score": 2,
"selected": false,
"text": "export http_proxy=http://${proxy.host}:${port}\nexport https_proxy=http://${proxy.host}:${port}\n gem install ${gem_name}\n"
},
{
"answer_id": 22957276,
"author": "HomTom",
"author_id": 2931433,
"author_profile": "https://Stackoverflow.com/users/2931433",
"pm_score": 4,
"selected": false,
"text": "gem install -p http://proxy_ip:proxy_port compass\n gem install -p http://[username]:[password]@proxy_ip:proxy_port compass\n"
},
{
"answer_id": 23693898,
"author": "testworks",
"author_id": 3509508,
"author_profile": "https://Stackoverflow.com/users/3509508",
"pm_score": 1,
"selected": false,
"text": "HTTP_PROXY HTTP_PROXY HTTP_PROXY http://proxy-server-name\n http://username:password@proxy-server-name:port-number\n"
},
{
"answer_id": 25244434,
"author": "ArNumb",
"author_id": 2818659,
"author_profile": "https://Stackoverflow.com/users/2818659",
"pm_score": 1,
"selected": false,
"text": "pushd [directory] pushd D:\\Setups gem install [update name] --local gem install rubygems-update --local ruby -v"
},
{
"answer_id": 27921249,
"author": "Pedro García Vigil",
"author_id": 4449057,
"author_profile": "https://Stackoverflow.com/users/4449057",
"pm_score": 2,
"selected": false,
"text": "set HTTP_PROXY=http://server:port\nset HTTP_PROXY_USER=username\nset HTTP_PROXY_PASS=userparssword\nset HTTPS_PROXY=http://server:port\nset HTTPS_PROXY_USER=username\nset HTTPS_PROXY_PASS=userpassword\n HTTPS_PROXY"
},
{
"answer_id": 34412185,
"author": "lukapiske",
"author_id": 511366,
"author_profile": "https://Stackoverflow.com/users/511366",
"pm_score": 4,
"selected": false,
"text": "http_proxy: http://proxy:3128\n gem install"
},
{
"answer_id": 56637216,
"author": "Shantonu",
"author_id": 1564801,
"author_profile": "https://Stackoverflow.com/users/1564801",
"pm_score": 3,
"selected": false,
"text": "gem install --http-proxy http://host:port/ package_name\n\ngem update --http-proxy http://host:port/ package_name\n"
},
{
"answer_id": 61013775,
"author": "Mike Campbell",
"author_id": 1520714,
"author_profile": "https://Stackoverflow.com/users/1520714",
"pm_score": 0,
"selected": false,
"text": "gem socksify gem install socksify cp $(command which gem) /usr/local/bin/proxy_gem\n require 'socksify'\n\nif ENV['SOCKS_PROXY']\n require 'socksify'\n host, port = ENV['SOCKS_PROXY'].split(':')\n TCPSocket.socks_server = host || 'localhost'\n TCPSocket.socks_port = port.to_i || 1080\nend\n ssh -D 8123 -f -C -q -N user@proxy\n SOCKS_PROXY=localhost:8123 proxy_gem push mygem\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4418",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/307/"
] |
4,430 | <p>Is there available any tool for PHP which can be used to generate code for consuming a <a href="http://en.wikipedia.org/wiki/Web_service" rel="noreferrer">web service</a> based on its <a href="http://en.wikipedia.org/wiki/Web_Services_Description_Language" rel="noreferrer">WSDL</a>? Something comparable to clicking "Add Web Reference" in Visual Studio or the Eclipse plugin which does the same thing for Java.</p>
| [
{
"answer_id": 24490,
"author": "davidmytton",
"author_id": 2183,
"author_profile": "https://Stackoverflow.com/users/2183",
"pm_score": 6,
"selected": false,
"text": "$client = new SoapClient(\"some.wsdl\");\n $result = $client->getTime();\n"
},
{
"answer_id": 32475441,
"author": "Mashudu Muleya",
"author_id": 5316309,
"author_profile": "https://Stackoverflow.com/users/5316309",
"pm_score": 1,
"selected": false,
"text": "Add <?php\n $client = new SoapClient(\"http://localhost/csharp/web_service.asmx?wsdl\");\n\n print_r( $client->Add(array(\"a\" => \"5\", \"b\" =>\"2\")));\n?>\n"
},
{
"answer_id": 37068486,
"author": "Luke Wenke",
"author_id": 785309,
"author_profile": "https://Stackoverflow.com/users/785309",
"pm_score": 2,
"selected": false,
"text": "<x:Envelope xmlns:x=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:int=\"http://thesite.com/\">\n <x:Header/>\n <x:Body>\n <int:authenticateLogin>\n <int:LoginId>12345</int:LoginId>\n </int:authenticateLogin>\n </x:Body>\n</x:Envelope>\n <s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n <authenticateLoginResponse xmlns=\"http://thesite.com/\">\n <authenticateLoginResult>\n <RequestStatus>true</RequestStatus>\n <UserName>003p0000006XKX3AAO</UserName>\n <BearerToken>Abcdef1234567890</BearerToken>\n </authenticateLoginResult>\n </authenticateLoginResponse>\n </s:Body>\n</s:Envelope>\n $client = new SoapClient('http://thesite.com/PortalIntegratorService.svc?wsdl');\n$result = $client->authenticateLogin(array('LoginId' => 12345));\nif (!empty($result->authenticateLoginResult->RequestStatus)\n && !empty($result->authenticateLoginResult->UserName)) {\n echo 'The username is: '.$result->authenticateLoginResult->UserName;\n}\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/349/"
] |
4,432 | <p>Typical way of creating a <a href="http://en.wikipedia.org/wiki/Comma-separated_values" rel="noreferrer">CSV</a> string (pseudocode):</p>
<ol>
<li>Create a CSV container object (like a StringBuilder in C#).</li>
<li>Loop through the strings you want to add appending a comma after each one.</li>
<li>After the loop, remove that last superfluous comma.</li>
</ol>
<p>Code sample:</p>
<pre><code>public string ReturnAsCSV(ContactList contactList)
{
StringBuilder sb = new StringBuilder();
foreach (Contact c in contactList)
{
sb.Append(c.Name + ",");
}
sb.Remove(sb.Length - 1, 1);
//sb.Replace(",", "", sb.Length - 1, 1)
return sb.ToString();
}
</code></pre>
<p>I like the idea of adding the comma by checking if the container is empty, but doesn't that mean more processing as it needs to check the length of the string on each occurrence?</p>
<p>I feel that there should be an easier/cleaner/more efficient way of removing that last comma. Any ideas?</p>
| [
{
"answer_id": 4437,
"author": "Chris Farmer",
"author_id": 404,
"author_profile": "https://Stackoverflow.com/users/404",
"pm_score": 2,
"selected": false,
"text": "if (sb.Length > 0) sb.Append(\",\");"
},
{
"answer_id": 4438,
"author": "Yaakov Ellis",
"author_id": 51,
"author_profile": "https://Stackoverflow.com/users/51",
"pm_score": 0,
"selected": false,
"text": "public string ReturnAsCSV(ContactList contactList)\n{\n StringBuilder sb = new StringBuilder();\n bool isFirst = true;\n\n foreach (Contact c in contactList) {\n if (!isFirst) { \n // Only add comma before item if it is not the first item\n sb.Append(\",\"); \n } else {\n isFirst = false;\n }\n\n sb.Append(c.Name);\n }\n\n return sb.ToString();\n}\n"
},
{
"answer_id": 4441,
"author": "David Wengier",
"author_id": 489,
"author_profile": "https://Stackoverflow.com/users/489",
"pm_score": 5,
"selected": true,
"text": "string [] strings = contactList.Select(c => c.Name).ToArray();\nstring csv = string.Join(\",\", strings);\n"
},
{
"answer_id": 4502,
"author": "Ishmaeel",
"author_id": 227,
"author_profile": "https://Stackoverflow.com/users/227",
"pm_score": 2,
"selected": false,
"text": "public string ReturnAsCSV(ContactList contactList)\n{\n List<String> tmpList = new List<string>();\n\n foreach (Contact c in contactList)\n {\n tmpList.Add(c.Name);\n }\n\n return String.Join(\",\", tmpList.ToArray());\n}\n return String.Join(\n System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator,\n tmpList.ToArray());\n"
},
{
"answer_id": 4518,
"author": "GateKiller",
"author_id": 383,
"author_profile": "https://Stackoverflow.com/users/383",
"pm_score": 0,
"selected": false,
"text": "public string ReturnAsCSV(ContactList contactList)\n{\n StringBuilder sb = new StringBuilder();\n\n foreach (Contact c in contactList)\n {\n sb.Append(c.Name + \",\");\n }\n\n return sb.ToString().Trim(',');\n}\n"
},
{
"answer_id": 4611,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 3,
"selected": false,
"text": "public string ReturnAsCSV(ContactList contactList)\n{\n if (contactList == null || contactList.Count == 0)\n return string.Empty;\n\n StringBuilder sb = new StringBuilder(contactList[0].Name);\n\n for (int i = 1; i < contactList.Count; i++)\n {\n sb.Append(\",\");\n sb.Append(contactList[i].Name);\n }\n\n return sb.ToString();\n}\n"
},
{
"answer_id": 6724,
"author": "dbkk",
"author_id": 838,
"author_profile": "https://Stackoverflow.com/users/838",
"pm_score": 3,
"selected": false,
"text": "public static String EncodeCsvLine(params String[] fields)\n{\n StringBuilder line = new StringBuilder();\n\n for (int i = 0; i < fields.Length; i++)\n {\n if (i > 0)\n {\n line.Append(DelimiterChar);\n }\n\n String csvField = EncodeCsvField(fields[i]);\n line.Append(csvField);\n }\n\n return line.ToString();\n}\n\nstatic String EncodeCsvField(String field)\n{\n StringBuilder sb = new StringBuilder();\n sb.Append(field);\n\n // Some fields with special characters must be embedded in double quotes\n bool embedInQuotes = false;\n\n // Embed in quotes to preserve leading/tralining whitespace\n if (sb.Length > 0 && \n (sb[0] == ' ' || \n sb[0] == '\\t' ||\n sb[sb.Length-1] == ' ' || \n sb[sb.Length-1] == '\\t' ))\n {\n embedInQuotes = true;\n }\n\n for (int i = 0; i < sb.Length; i++)\n {\n // Embed in quotes to preserve: commas, line-breaks etc.\n if (sb[i] == DelimiterChar || \n sb[i]=='\\r' || \n sb[i]=='\\n' || \n sb[i] == '\"') \n { \n embedInQuotes = true;\n break;\n }\n }\n\n // If the field itself has quotes, they must each be represented \n // by a pair of consecutive quotes.\n sb.Replace(\"\\\"\", \"\\\"\\\"\");\n\n String rv = sb.ToString();\n\n if (embedInQuotes)\n {\n rv = \"\\\"\" + rv + \"\\\"\";\n }\n\n return rv;\n}\n"
},
{
"answer_id": 17305,
"author": "Autodidact",
"author_id": 2051,
"author_profile": "https://Stackoverflow.com/users/2051",
"pm_score": 1,
"selected": false,
"text": "public string ReturnAsCSV(ContactList contactList)\n{\n StringBuilder sb = new StringBuilder();\n\n foreach (Contact c in contactList) \n { \n sb.Append(c.Name + \",\"); \n }\n\n if (sb.Length > 0) \n sb.Length -= 1;\n\n return sb.ToString(); \n}\n"
},
{
"answer_id": 11214712,
"author": "jocull",
"author_id": 97964,
"author_profile": "https://Stackoverflow.com/users/97964",
"pm_score": 1,
"selected": false,
"text": "public class clsCSVBuilder\n{\n protected int _CurrentIndex = -1;\n protected List<string> _Headers = new List<string>();\n protected List<List<string>> _Records = new List<List<string>>();\n protected const string SEPERATOR = \",\";\n\n public clsCSVBuilder() { }\n\n public void CreateRow()\n {\n _Records.Add(new List<string>());\n _CurrentIndex++;\n }\n\n protected string _EscapeString(string str)\n {\n return string.Format(\"\\\"{0}\\\"\", str.Replace(\"\\\"\", \"\\\"\\\"\")\n .Replace(\"\\r\\n\", \" \")\n .Replace(\"\\n\", \" \")\n .Replace(\"\\r\", \" \"));\n }\n\n protected void _AddRawString(string item)\n {\n _Records[_CurrentIndex].Add(item);\n }\n\n public void AddHeader(string name)\n {\n _Headers.Add(_EscapeString(name));\n }\n\n public void AddRowItem(string item)\n {\n _AddRawString(_EscapeString(item));\n }\n\n public void AddRowItem(int item)\n {\n _AddRawString(item.ToString());\n }\n\n public void AddRowItem(double item)\n {\n _AddRawString(item.ToString());\n }\n\n public void AddRowItem(DateTime date)\n {\n AddRowItem(date.ToShortDateString());\n }\n\n public static string GenerateTempCSVPath()\n {\n return Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString().ToLower().Replace(\"-\", \"\") + \".csv\");\n }\n\n protected string _GenerateCSV()\n {\n StringBuilder sb = new StringBuilder();\n\n if (_Headers.Count > 0)\n {\n sb.AppendLine(string.Join(SEPERATOR, _Headers.ToArray()));\n }\n\n foreach (List<string> row in _Records)\n {\n sb.AppendLine(string.Join(SEPERATOR, row.ToArray()));\n }\n\n return sb.ToString();\n }\n\n public void SaveAs(string path)\n {\n using (StreamWriter sw = new StreamWriter(path))\n {\n sw.Write(_GenerateCSV());\n }\n }\n}\n"
},
{
"answer_id": 11215149,
"author": "Ed Power",
"author_id": 150058,
"author_profile": "https://Stackoverflow.com/users/150058",
"pm_score": 0,
"selected": false,
"text": "public string ReturnAsCSV(ContactList contactList)\n{\n StringBuilder sb = new StringBuilder();\n using (StringWriter stringWriter = new StringWriter(sb))\n {\n using (var csvWriter = new CsvHelper.CsvWriter(stringWriter))\n {\n csvWriter.Configuration.HasHeaderRecord = false;\n foreach (Contact c in contactList)\n {\n csvWriter.WriteField(c.Name);\n }\n }\n }\n return sb.ToString();\n}\n csvWriter.WriteRecords<ContactList>(contactList);"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/202/"
] |
4,508 | <p>Using MAPI functions from within managed code is officially unsupported. Apparently, MAPI uses its own memory management and it crashes and burns within managed code (see <a href="http://blogs.msdn.com/pcreehan/archive/2007/05/04/what-does-unsupported-mean.aspx" rel="noreferrer">here</a> and <a href="http://blogs.msdn.com/mstehle/archive/2007/10/03/fyi-why-are-mapi-and-cdo-1-21-not-supported-in-managed-net-code.aspx" rel="noreferrer">here</a>)</p>
<p><strong>All I want to do is launch the default e-mail client</strong> with subject, body, <strong>AND one or more attachments</strong>. </p>
<p>So I've been looking into <a href="http://pinvoke.net/default.aspx/mapi32.MAPISendDocuments" rel="noreferrer">MAPISendDocuments</a> and it seems to work. But I haven't been able to gather courage to actually use the function in production code.</p>
<p>Has anybody used this function a lot? Do you have any horror stories?</p>
<p><em>PS. No, I won't shellExecute Outlook.exe with command line arguments for attachments.</em></p>
<p><em>PPS. Attachment support is a</em> requirement <em>, so Mailto: solutions do not cut it for me.</em></p>
| [
{
"answer_id": 4590,
"author": "John",
"author_id": 33,
"author_profile": "https://Stackoverflow.com/users/33",
"pm_score": 2,
"selected": false,
"text": "Process.Start(\"mailto:[email protected]?subject=TestCode&Body=Test Text\");\n"
},
{
"answer_id": 4408605,
"author": "Roman Starkov",
"author_id": 33080,
"author_profile": "https://Stackoverflow.com/users/33080",
"pm_score": 0,
"selected": false,
"text": "using Microsoft.Office;\nusing Microsoft.Office.Core;\n\n...\n\nOutlook.Application outlook = new Outlook.Application();\nOutlook.MailItem mail = (Outlook.MailItem) outlook.CreateItem(Outlook.OlItemType.olMailItem);\n\nmail.BodyFormat = Outlook.OlBodyFormat.olFormatRichText;\nmail.HTMLBody = \"stuff\";\nmail.Subject = \"more stuff\";\nstring file = File.ReadAllBytes(...);\nmail.Attachments.Add(file, Outlook.OlAttachmentType.olByValue, 1, file)\n\nmail.Display(false);\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/227/"
] |
4,519 | <p>I have the Xming X Window Server installed on a laptop running Windows XP to connect to some UNIX development servers. </p>
<p>It works fine when I connect directly to the company network in the office. However, it does not work when I connect to the network remotely over a VPN.</p>
<p>When I start Xming when connected remotely none of my terminal Windows are displayed.</p>
<p>I think it may have something to do with the DISPLAY environment variable not being set correctly to the IP address of the laptop when it is connected.</p>
<p>I've noticed that when I do an ipconfig whilst connected remotely that my laptop has two IP addresses, the one assigned to it from the company network and the local IP address I've set up for it on my "local network" from my modem/router.</p>
<p>Are there some configuration changes I need to make in Xming to support its use through the VPN?</p>
| [
{
"answer_id": 4683,
"author": "grom",
"author_id": 486,
"author_profile": "https://Stackoverflow.com/users/486",
"pm_score": 1,
"selected": false,
"text": "$ x11vnc -display :0\n"
},
{
"answer_id": 27852421,
"author": "Jack Kidwell",
"author_id": 4435124,
"author_profile": "https://Stackoverflow.com/users/4435124",
"pm_score": 2,
"selected": false,
"text": "Connection > SSH > X11 > X display location localhost:0.0 VPNIP:0.0 VPNIP VPN statistics client address information VPN client Statistics... X11Forwarding yes\nX11DisplayOffset 10\nX11UseLocalhost yes\nAddressFamily inet\n"
},
{
"answer_id": 45979044,
"author": "Ersel Er",
"author_id": 4681316,
"author_profile": "https://Stackoverflow.com/users/4681316",
"pm_score": 2,
"selected": false,
"text": "Connections > SSH > X11 -A INPUT -m state --state NEW -m tcp -p tcp -m multiport --dports 5901:5903,6000:6003 -j ACCEPT Connections > SSH > Tunnels Source Port=6000 Destination=127.0.0.1:6000 Remote Add export DISPLAY=127.0.0.1:0.0 DISPLAY 127.0.0.1:1.0"
},
{
"answer_id": 53330378,
"author": "Alan Xie",
"author_id": 10660573,
"author_profile": "https://Stackoverflow.com/users/10660573",
"pm_score": 0,
"selected": false,
"text": "LinuxBox.mydomain.com\nLinuxBox\n192.168.1.25\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/381/"
] |
4,533 | <p>How do I generate an ETag HTTP header for a resource file?</p>
| [
{
"answer_id": 4540,
"author": "Mark Harrison",
"author_id": 116,
"author_profile": "https://Stackoverflow.com/users/116",
"pm_score": 5,
"selected": true,
"text": " server client\n \n <------------- request file foo\n \n file foo etag: \"xyz\" -------->\n \n <------------- request file foo\n etag: \"xyz\" (what the server just sent)\n \n (the etag is the same, so the server can send a 304)\n char *mketag(char *s, struct stat *sb)\n{\n sprintf(s, \"%d-%d-%d\", sb->st_mtime, sb->st_size, sb->st_ino);\n return s;\n}\n"
},
{
"answer_id": 7308209,
"author": "lolesque",
"author_id": 787216,
"author_profile": "https://Stackoverflow.com/users/787216",
"pm_score": 2,
"selected": false,
"text": "for file in *; do printf \"%x-%x-%x\\t$file\\n\" `stat -c%i $file` `stat -c%s $file` $((`stat -c%Y $file`*1000000)) ; done\n"
},
{
"answer_id": 14057468,
"author": "peawormsworth",
"author_id": 1880288,
"author_profile": "https://Stackoverflow.com/users/1880288",
"pm_score": 1,
"selected": false,
"text": " shortlink = str(hex(zlib.adler32(link)+(2**32-1)/2))[2:-1]\n"
},
{
"answer_id": 63104602,
"author": "Sergey Ponomarev",
"author_id": 1049542,
"author_profile": "https://Stackoverflow.com/users/1049542",
"pm_score": 0,
"selected": false,
"text": "inode inode \n<inttypes.h>\n \n \nchar *mketag(char *s, struct stat *sb)\n{\n sprintf(s, \"\\\"%\" PRIx64 \"-%\" PRIx64 \"\\\"\", sb->st_mtime, sb->st_size);\n return s;\n}\n \n etag = '\"' + Long.toHexString(lastModified) + '-' +\n Long.toHexString(contentLength) + '\"';\n // Generate ETag from file's size and last modification time as unix timestamp in seconds from 1970\npublic static string MakeEtag(long lastMod, long size)\n{\n string etag = '\"' + lastMod.ToString(\"x\") + '-' + size.ToString(\"x\") + '\"';\n return etag;\n}\n\npublic static void Main(string[] args)\n{\n long lastMod = 1578315296;\n long size = 1047;\n string etag = MakeEtag(lastMod, size);\n Console.WriteLine(\"ETag: \" + etag);\n //=> ETag: \"5e132e20-417\"\n}\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192/"
] |
4,544 | <p>I'm trying to create a bookmarklet for posting del.icio.us bookmarks to a separate account.</p>
<p>I tested it from the command line like:</p>
<pre><code>wget -O - --no-check-certificate \
"https://seconduser:[email protected]/v1/posts/add?url=http://seet.dk&description=test"
</code></pre>
<p>This works great.</p>
<p>I then wanted to create a bookmarklet in my firefox. I googled and found bits and pieces and ended up with:</p>
<pre><code>javascript:void(
open('https://seconduser:[email protected]/v1/posts/add?url='
+encodeURIComponent(location.href)
+'&description='+encodeURIComponent(document.title),
'delicious','toolbar=no,width=500,height=250'
)
);
</code></pre>
<p>But all that happens is that I get this from del.icio.us:</p>
<pre><code><?xml version="1.0" standalone="yes"?>
<result code="access denied" />
<!-- fe04.api.del.ac4.yahoo.net uncompressed/chunked Thu Aug 7 02:02:54 PDT 2008 -->
</code></pre>
<p>If I then go to the address bar and press enter, it changes to:</p>
<pre><code><?xml version='1.0' standalone='yes'?>
<result code="done" />
<!-- fe02.api.del.ac4.yahoo.net uncompressed/chunked Thu Aug 7 02:07:45 PDT 2008 -->
</code></pre>
<p>Any ideas how to get it to work directly from the bookmarks?</p>
| [
{
"answer_id": 12453,
"author": "travis",
"author_id": 1414,
"author_profile": "https://Stackoverflow.com/users/1414",
"pm_score": 1,
"selected": false,
"text": "VERSION BUILD=6000814 RECORDER=FX\nTAB T=1\nURL GOTO=http://10.20.2.4/login\nTAG POS=1 TYPE=INPUT:TEXT FORM=NAME:introduce ATTR=NAME:initials CONTENT=username-goes-here\nSET !ENCRYPTION NO\nTAG POS=1 TYPE=INPUT:PASSWORD FORM=NAME:introduce ATTR=NAME:password CONTENT=password-goes-here\nTAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:introduce ATTR=NAME:Submit&&VALUE:Go\nURL GOTO=http://10.20.2.4/timecard\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/86/"
] |
4,545 | <p>Does anyone remember the <code>XMP</code> tag?</p>
<p>What was it used for and why was it deprecated?</p>
| [
{
"answer_id": 4549,
"author": "graham.reeds",
"author_id": 342,
"author_profile": "https://Stackoverflow.com/users/342",
"pm_score": 6,
"selected": true,
"text": "XMP XMP PRE"
},
{
"answer_id": 5252111,
"author": "mplungjan",
"author_id": 295783,
"author_profile": "https://Stackoverflow.com/users/295783",
"pm_score": 1,
"selected": false,
"text": "var stuff='<xmp'+'>this is shown as is<br/>hello</xmp>';\ndocument.getElementById(\"x\").innerHTML=stuff; <div id=\"x\"></div>"
},
{
"answer_id": 8981120,
"author": "Adam F",
"author_id": 855567,
"author_profile": "https://Stackoverflow.com/users/855567",
"pm_score": 2,
"selected": false,
"text": "xmp var_dump(); pre textarea readonly"
},
{
"answer_id": 11249786,
"author": "dadinck",
"author_id": 1475519,
"author_profile": "https://Stackoverflow.com/users/1475519",
"pm_score": 6,
"selected": false,
"text": "XMP PRE PRE < > & PRE XMP XMP XMP </XMP> XMP"
},
{
"answer_id": 37593882,
"author": "Phil Busby",
"author_id": 6415119,
"author_profile": "https://Stackoverflow.com/users/6415119",
"pm_score": 2,
"selected": false,
"text": "<textarea> <textarea><b>boldtext</b><textarea>"
},
{
"answer_id": 45902139,
"author": "noobninja",
"author_id": 3788772,
"author_profile": "https://Stackoverflow.com/users/3788772",
"pm_score": 3,
"selected": false,
"text": "<xmp> <!DOCTYPE html>\n<html>\n <title>Example</title>\n <xmp theme=\"united\">\n## Example\n\n - note one\n - note two\n - note three\n </xmp>\n <script src=\"http://strapdownjs.com/v/0.2/strapdown.js\"></script>\n</html>\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383/"
] |
4,610 | <p>How is it possible to make prototype methods in C#.Net?</p>
<p>In JavaScript, I can do the following to create a trim method for the string object:</p>
<pre><code>String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,"");
}
</code></pre>
<p>How can I go about doing this in C#.Net?</p>
| [
{
"answer_id": 4614,
"author": "David Wengier",
"author_id": 489,
"author_profile": "https://Stackoverflow.com/users/489",
"pm_score": 0,
"selected": false,
"text": "public static string MyMethod(this string input)\n{\n // do things\n}\n \"asdfas\".MyMethod();\n"
},
{
"answer_id": 4615,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 6,
"selected": true,
"text": "public static class StringExtensions\n{\n public static String trim(this String s)\n {\n return s.Trim();\n }\n}\n String s = \" Test \";\ns = s.trim();\n String s = \" Test \";\ns = StringExtensions.trim(s);\n"
},
{
"answer_id": 4616,
"author": "Andrew Peters",
"author_id": 608,
"author_profile": "https://Stackoverflow.com/users/608",
"pm_score": 0,
"selected": false,
"text": "public static void Trim(this string s)\n{\n // implementation\n}\n namespace System.Runtime.CompilerServices\n{\n [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly)]\n public sealed class ExtensionAttribute : Attribute\n {\n }\n}\n"
},
{
"answer_id": 4619,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 3,
"selected": false,
"text": "public static class MyStringEtensions\n{\n public static bool ContainsMabster(this string s)\n {\n return s.Contains(\"Mabster\");\n }\n}\n if (\"Why hello there, Mabster!\".ContainsMabster()) { /* ... */ }\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383/"
] |
4,612 | <p>Is <em>CompileAssemblyFromDom</em> faster than <em>CompileAssemblyFromSource</em>?</p>
<p>It <em>should</em> be as it presumably bypasses the compiler front-end.</p>
| [
{
"answer_id": 29283,
"author": "Jacob Krall",
"author_id": 3140,
"author_profile": "https://Stackoverflow.com/users/3140",
"pm_score": 4,
"selected": true,
"text": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing Microsoft.CSharp;\nusing System.CodeDom;\nusing System.IO;\nusing System.CodeDom.Compiler;\nusing System.Reflection;\n\nnamespace CodeDomQuestion\n{\n class Program\n {\n\n private static void Main(string[] args)\n {\n Program p = new Program();\n p.dotest(\"C:\\\\fs.exe\");\n }\n\n public void dotest(string outputname)\n {\n CSharpCodeProvider cscProvider = new CSharpCodeProvider();\n CompilerParameters cp = new CompilerParameters();\n cp.MainClass = null;\n cp.GenerateExecutable = true;\n cp.OutputAssembly = outputname;\n \n CodeNamespace ns = new CodeNamespace(\"StackOverflowd\");\n\n CodeTypeDeclaration type = new CodeTypeDeclaration();\n type.IsClass = true;\n type.Name = \"MainClass\";\n type.TypeAttributes = TypeAttributes.Public;\n \n ns.Types.Add(type);\n\n CodeMemberMethod cmm = new CodeMemberMethod();\n cmm.Attributes = MemberAttributes.Static;\n cmm.Name = \"Main\";\n cmm.Statements.Add(new CodeSnippetExpression(\"System.Console.WriteLine('f'zxcvv)\"));\n type.Members.Add(cmm);\n\n CodeCompileUnit ccu = new CodeCompileUnit();\n ccu.Namespaces.Add(ns);\n\n CompilerResults results = cscProvider.CompileAssemblyFromDom(cp, ccu);\n\n foreach (CompilerError err in results.Errors)\n Console.WriteLine(err.ErrorText + \" - \" + err.FileName + \":\" + err.Line);\n\n Console.WriteLine();\n }\n }\n}\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/608/"
] |
4,617 | <p>We've got two developers on the same closed (ugh, stupid gov) network, Another developer a couple minutes drive down the road, and a fourth developer half-way across the country. E-Mail, ftp, and removal media are all possible methods of transfer for the people not on the same network.</p>
<p>I am one of the two closed network developers, consider us the "master" location.</p>
<p>What is the best Mercurial setup/pattern for group? What is the best way to trasmit changes to/from the remote developers? As I am in charge, I figured that I would have to keep at least one master repo with another local repo in which I can develop. Each other person should just need a clone of the master. Is this right? I guess this also makes me responsible for the merging? </p>
<p>As you can see, I'm still trying to wrap my head around distributed version control. I don't think there is any other way to do this with the connectivity situation.</p>
| [
{
"answer_id": 900172,
"author": "Martin Geisler",
"author_id": 110204,
"author_profile": "https://Stackoverflow.com/users/110204",
"pm_score": 2,
"selected": false,
"text": "hg push upstream devel devel upstream % hg outgoing ../upstream\n % hg bundle changes.hg ../upstream\n % hg incoming changes.hg\n % hg pull changes.hg\n upstream hg bundle --base hg help bundle"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/287/"
] |
4,622 | <p>What is the <strong>complete</strong> and correct syntax for the SQL Case expression?</p>
| [
{
"answer_id": 4626,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 7,
"selected": true,
"text": "CASE case-expression\n WHEN when-expression-1 THEN value-1\n [ WHEN when-expression-n THEN value-n ... ]\n [ ELSE else-value ]\nEND\n CASE\n WHEN boolean-when-expression-1 THEN value-1\n [ WHEN boolean-when-expression-n THEN value-n ... ]\n [ ELSE else-value ]\nEND\n case-expression - something that produces a value\nwhen-expression-x - something that is compared against the case-expression\nvalue-1 - the result of the CASE statement if:\n the when-expression == case-expression\n OR the boolean-when-expression == TRUE\nboolean-when-exp.. - something that produces a TRUE/FALSE answer\n"
},
{
"answer_id": 4634,
"author": "Neall",
"author_id": 619,
"author_profile": "https://Stackoverflow.com/users/619",
"pm_score": 4,
"selected": false,
"text": "CASE SELECT a,\n CASE WHEN a=1 THEN 'one'\n WHEN a=2 THEN 'two'\n ELSE 'other'\n END\nFROM test;\n SELECT a,\n CASE a WHEN 1 THEN 'one'\n WHEN 2 THEN 'two'\n ELSE 'other'\n END\nFROM test;\n"
},
{
"answer_id": 223167,
"author": "Leigh Riffel",
"author_id": 27010,
"author_profile": "https://Stackoverflow.com/users/27010",
"pm_score": 2,
"selected": false,
"text": "CASE { simple_case_expression | searched_case_expression }\n [ else_clause ]\n END\n expr { WHEN comparison_expr THEN return_expr }...\n { WHEN condition THEN return_expr }...\n ELSE else_expr\n"
},
{
"answer_id": 224770,
"author": "onedaywhen",
"author_id": 15354,
"author_profile": "https://Stackoverflow.com/users/15354",
"pm_score": 4,
"selected": false,
"text": "<case expression> ::=\n <case abbreviation>\n | <case specification>\n\n<case abbreviation> ::=\n NULLIF <left paren> <value expression> <comma>\n <value expression> <right paren>\n | COALESCE <left paren> <value expression>\n { <comma> <value expression> }... <right paren>\n\n<case specification> ::=\n <simple case>\n | <searched case>\n\n<simple case> ::=\n CASE <case operand>\n <simple when clause>...\n [ <else clause> ]\n END\n\n<searched case> ::=\n CASE\n <searched when clause>...\n [ <else clause> ]\n END\n\n<simple when clause> ::= WHEN <when operand> THEN <result>\n\n<searched when clause> ::= WHEN <search condition> THEN <result>\n\n<else clause> ::= ELSE <result>\n\n<case operand> ::= <value expression>\n\n<when operand> ::= <value expression>\n\n<result> ::= <result expression> | NULL\n\n<result expression> ::= <value expression>\n 1) NULLIF (V1, V2) is equivalent to the following <case specification>:\n\n CASE WHEN V1=V2 THEN NULL ELSE V1 END\n\n2) COALESCE (V1, V2) is equivalent to the following <case specification>:\n\n CASE WHEN V1 IS NOT NULL THEN V1 ELSE V2 END\n\n3) COALESCE (V1, V2, . . . ,n ), for n >= 3, is equivalent to the\n following <case specification>:\n\n CASE WHEN V1 IS NOT NULL THEN V1 ELSE COALESCE (V2, . . . ,n )\n END\n\n4) If a <case specification> specifies a <simple case>, then let CO\n be the <case operand>:\n\n a) The data type of each <when operand> WO shall be comparable\n with the data type of the <case operand>.\n\n b) The <case specification> is equivalent to a <searched case>\n in which each <searched when clause> specifies a <search\n condition> of the form \"CO=WO\".\n\n5) At least one <result> in a <case specification> shall specify a\n <result expression>.\n\n6) If an <else clause> is not specified, then ELSE NULL is im-\n plicit.\n\n7) The data type of a <case specification> is determined by ap-\n plying Subclause 9.3, \"Set operation result data types\", to the\n data types of all <result expression>s in the <case specifica-\n tion>.\n\nAccess Rules\n\n None.\n\nGeneral Rules\n\n1) Case:\n\n a) If a <result> specifies NULL, then its value is the null\n value.\n\n b) If a <result> specifies a <value expression>, then its value\n is the value of that <value expression>.\n\n2) Case:\n\n a) If the <search condition> of some <searched when clause> in\n a <case specification> is true, then the value of the <case\n specification> is the value of the <result> of the first\n (leftmost) <searched when clause> whose <search condition> is\n true, cast as the data type of the <case specification>.\n\n b) If no <search condition> in a <case specification> is true,\n then the value of the <case expression> is the value of the\n <result> of the explicit or implicit <else clause>, cast as\n the data type of the <case specification>.\n"
},
{
"answer_id": 687137,
"author": "Eric Johnson",
"author_id": 58089,
"author_profile": "https://Stackoverflow.com/users/58089",
"pm_score": 3,
"selected": false,
"text": "case \n when search_condition then expression \n [when search_condition then expression]...\n [else expression]\nend\n case expression\n when expression then expression \n [when expression then expression]...\n [else expression]\nend\n select disaster, \n case\n when disaster = \"earthquake\" \n then \"stand in doorway\"\n when disaster = \"nuclear apocalypse\" \n then \"hide in basement\"\n when monster = \"zombie apocalypse\" \n then \"hide with Chuck Norris\"\n else\n then \"ask mom\"\n end \n from endoftheworld\n"
},
{
"answer_id": 14558826,
"author": "user2001117",
"author_id": 2001117,
"author_profile": "https://Stackoverflow.com/users/2001117",
"pm_score": -1,
"selected": false,
"text": "CASE column\n WHEN value1 THEN 1\n WHEN value3 THEN 2\n WHEN value3 THEN 3\n WHEN value1 THEN 4\n ELSE ''\nEND\n CASE \n WHEN column=value1 THEN 1\n WHEN column=value3 THEN 2\n WHEN column=value3 THEN 3\n WHEN column=value1 THEN 4\n ELSE ''\nEND\n"
},
{
"answer_id": 65185982,
"author": "Aruna Karunarathna",
"author_id": 760445,
"author_profile": "https://Stackoverflow.com/users/760445",
"pm_score": -1,
"selected": false,
"text": "CASE\n WHEN some_condition THEN return_some_value\n ELSE return_some_other_value\nEND\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383/"
] |
4,629 | <p>I can do an <code>eval("something()");</code> to execute the code dynamically in JavaScript. Is there a way for me to do the same thing in C#?</p>
<p>An example of what I am trying to do is: I have an integer variable (say <code>i</code>) and I have multiple properties by the names: "Property1", "Property2", "Property3", etc.
Now, I want to perform some operations on the " Property<em>i</em> " property depending on the value of <code>i</code>. </p>
<p>This is really simple with Javascript. Is there any way to do this with C#?</p>
| [
{
"answer_id": 4633,
"author": "David Wengier",
"author_id": 489,
"author_profile": "https://Stackoverflow.com/users/489",
"pm_score": 2,
"selected": false,
"text": "object result = theObject.GetType().GetProperty(\"Property\" + i).GetValue(theObject, null);\n"
},
{
"answer_id": 4635,
"author": "GateKiller",
"author_id": 383,
"author_profile": "https://Stackoverflow.com/users/383",
"pm_score": 0,
"selected": false,
"text": "void something(int i, string P1) {\n something(i, P1, String.Empty);\n}\n\nvoid something(int i, string P1, string P2) {\n something(i, P1, P2, String.Empty);\n}\n\nvoid something(int i, string P1, string P2, string P3) {\n something(i, P1, P2, P3, String.Empty);\n}\n"
},
{
"answer_id": 4636,
"author": "Karl Seguin",
"author_id": 34,
"author_profile": "https://Stackoverflow.com/users/34",
"pm_score": 4,
"selected": false,
"text": "protected static void SetField(object o, string fieldName, object value)\n{\n FieldInfo field = o.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic);\n field.SetValue(o, value);\n}\n"
},
{
"answer_id": 4637,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 7,
"selected": true,
"text": "Microsoft.CodeAnalysis.CSharp.Scripting String propName = \"Text\";\nPropertyInfo pi = someObject.GetType().GetProperty(propName);\npi.SetValue(someObject, \"New Value\", new Object[0]);\n"
},
{
"answer_id": 4657,
"author": "MojoFilter",
"author_id": 93,
"author_profile": "https://Stackoverflow.com/users/93",
"pm_score": 3,
"selected": false,
"text": "class MyClass {\n public Point point1, point2, point3;\n\n private Point[] points;\n\n public MyClass() {\n //...\n this.points = new Point[] {point1, point2, point3};\n }\n\n public void DoSomethingWith(int i) {\n Point target = this.points[i+1];\n // do stuff to target\n }\n}\n"
},
{
"answer_id": 3841433,
"author": "Xodem",
"author_id": 464085,
"author_profile": "https://Stackoverflow.com/users/464085",
"pm_score": 1,
"selected": false,
"text": "document.InvokeScript"
},
{
"answer_id": 6457416,
"author": "Largo",
"author_id": 487303,
"author_profile": "https://Stackoverflow.com/users/487303",
"pm_score": 4,
"selected": false,
"text": "public static object Eval(string sCSCode) {\n\n CSharpCodeProvider c = new CSharpCodeProvider();\n ICodeCompiler icc = c.CreateCompiler();\n CompilerParameters cp = new CompilerParameters();\n\n cp.ReferencedAssemblies.Add(\"system.dll\");\n cp.ReferencedAssemblies.Add(\"system.xml.dll\");\n cp.ReferencedAssemblies.Add(\"system.data.dll\");\n cp.ReferencedAssemblies.Add(\"system.windows.forms.dll\");\n cp.ReferencedAssemblies.Add(\"system.drawing.dll\");\n\n cp.CompilerOptions = \"/t:library\";\n cp.GenerateInMemory = true;\n\n StringBuilder sb = new StringBuilder(\"\");\n sb.Append(\"using System;\\n\" );\n sb.Append(\"using System.Xml;\\n\");\n sb.Append(\"using System.Data;\\n\");\n sb.Append(\"using System.Data.SqlClient;\\n\");\n sb.Append(\"using System.Windows.Forms;\\n\");\n sb.Append(\"using System.Drawing;\\n\");\n\n sb.Append(\"namespace CSCodeEvaler{ \\n\");\n sb.Append(\"public class CSCodeEvaler{ \\n\");\n sb.Append(\"public object EvalCode(){\\n\");\n sb.Append(\"return \"+sCSCode+\"; \\n\");\n sb.Append(\"} \\n\");\n sb.Append(\"} \\n\");\n sb.Append(\"}\\n\");\n\n CompilerResults cr = icc.CompileAssemblyFromSource(cp, sb.ToString());\n if( cr.Errors.Count > 0 ){\n MessageBox.Show(\"ERROR: \" + cr.Errors[0].ErrorText, \n \"Error evaluating cs code\", MessageBoxButtons.OK, \n MessageBoxIcon.Error );\n return null;\n }\n\n System.Reflection.Assembly a = cr.CompiledAssembly;\n object o = a.CreateInstance(\"CSCodeEvaler.CSCodeEvaler\");\n\n Type t = o.GetType();\n MethodInfo mi = t.GetMethod(\"EvalCode\");\n\n object s = mi.Invoke(o, null);\n return s;\n\n}\n"
},
{
"answer_id": 7204715,
"author": "roft",
"author_id": 914071,
"author_profile": "https://Stackoverflow.com/users/914071",
"pm_score": -1,
"selected": false,
"text": "TypeOf(Evaluate)\n{\n\"1+1\":2;\n\"1+2\":3;\n\"1+3\":5;\n....\n\"2-5\":-3;\n\"0+0\":1\n} \n List<string> results = new List<string>();\nfor() results.Add(result);\n"
},
{
"answer_id": 14671114,
"author": "Davide Icardi",
"author_id": 209727,
"author_profile": "https://Stackoverflow.com/users/209727",
"pm_score": 4,
"selected": false,
"text": "var interpreter = new Interpreter();\nvar result = interpreter.Eval(\"8 / 2 + 2\");\n var interpreter = new Interpreter()\n .SetVariable(\"service\", new ServiceExample());\n\nstring expression = \"x > 4 ? service.SomeMethod() : service.AnotherMethod()\";\n\nLambda parsedExpression = interpreter.Parse(expression, \n new Parameter(\"x\", typeof(int)));\n\nparsedExpression.Invoke(5);\n"
},
{
"answer_id": 37983894,
"author": "Eli Arbel",
"author_id": 276083,
"author_profile": "https://Stackoverflow.com/users/276083",
"pm_score": 6,
"selected": false,
"text": "// add NuGet package 'Microsoft.CodeAnalysis.Scripting'\nusing Microsoft.CodeAnalysis.CSharp.Scripting;\n\nawait CSharpScript.EvaluateAsync(\"System.Math.Pow(2, 4)\") // returns 16\n var script = await CSharpScript.RunAsync(@\"\n class MyClass\n { \n public void Print() => System.Console.WriteLine(1);\n }\")\n await script.ContinueWithAsync(\"new MyClass().Print();\");\n"
},
{
"answer_id": 45673529,
"author": "Iucounu",
"author_id": 2346932,
"author_profile": "https://Stackoverflow.com/users/2346932",
"pm_score": 1,
"selected": false,
"text": "someObject.Evaluate<int>(\"6 / {{{0}}}\", 3))\n someObject.Evaluate(\"this.ToString()\"))\n someObject.Execute(@\n\"Console.WriteLine(\"\"Hello, world!\"\");\nConsole.WriteLine(\"\"This demonstrates running a simple script\"\");\n\");\n IExecutable executable = ExecutableFactory.Default.GetExecutable(executableType, sourceCode, parameterNames, addedNamespaces);\n"
},
{
"answer_id": 50136420,
"author": "Ilya Dan",
"author_id": 7379207,
"author_profile": "https://Stackoverflow.com/users/7379207",
"pm_score": 0,
"selected": false,
"text": "public static object GetPropertyValue(object instance, string memberName)\n{\n return instance.GetType().GetField(memberName).GetValue(instance);\n}\n"
},
{
"answer_id": 51322656,
"author": "Hennadii",
"author_id": 9329578,
"author_profile": "https://Stackoverflow.com/users/9329578",
"pm_score": 0,
"selected": false,
"text": "var success = Reflector.Set(instance, null, $\"Property{i}\", value);\n var setter = Reflector.CreateSetter<object, object>($\"Property{i}\", typeof(type which contains \"Property\"+i));\nsetter(instance, value);\n Action<object, object>"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/384/"
] |
4,630 | <p>Example: I have two shared objects (same should apply to .dlls). The first shared object is from a third-party library, we'll call it libA.so. I have wrapped some of this with JNI and created my own library, libB.so. Now libB depends on libA.</p>
<p>When webstarting, both libraries are places in some webstart working area. My java code attempts to load libB. At this point the system loader will attempt to load libA which is not in the system library path (java.library.path won't help this). The end result is that libB has an unsatisfied link and cannot be used. </p>
<p>I have tried loading libA before libB, but that still does not work. Seems the OS wants to do that loading for me. Is there any way I can make this work other than statically compiling?</p>
| [
{
"answer_id": 80551,
"author": "Adam Mitz",
"author_id": 2574,
"author_profile": "https://Stackoverflow.com/users/2574",
"pm_score": 1,
"selected": false,
"text": "<nativelib ...> \n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/287/"
] |
4,638 | <p>How do you create your own custom moniker (or URL Protocol) on Windows systems?</p>
<p>Examples:</p>
<ul>
<li>http:</li>
<li>mailto:</li>
<li>service:</li>
</ul>
| [
{
"answer_id": 4662,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 2,
"selected": false,
"text": "procedure InstallIntoRegistry;\nvar\n Reg: TRegistry;\nbegin\n Reg := TRegistry.Create;\n try\n Reg.RootKey := HKEY_CLASSES_ROOT;\n if Reg.OpenKey('moniker', True) then\n begin\n Reg.WriteString('', 'URL:Name of moniker');\n Reg.WriteString('URL Protocol', '');\n Reg.WriteString('Source Filter', '{E436EBB6-524F-11CE-9F53-0020AF0BA770}');\n Reg.WriteInteger('EditFlags', 2);\n\n if Reg.OpenKey('shell\\open\\command', True) then\n begin\n Reg.WriteString('', '\"' + ParamStr(0) + '\" \"%1\"');\n end;\n end else begin\n MessageBox(0, 'You do not have the necessary access rights to complete this installation!' + Chr(13) +\n 'Please make sure you are logged in with a user account with administrative rights!', 'Access denied', 0);\n Exit;\n end;\n finally\n FreeAndNil(Reg);\n end;\n\n MessageBox(0, 'Application WebStart has been installed successfully!', 'Installed', 0);\nend;\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/307/"
] |
4,661 | <p>I have more than one OpenID as I have tried out numerous. As people take up OpenID different suppliers are going to emerge I may want to switch provinders. As all IDs are me, and all are authenticated against the same email address, shouldn't I be able to log into stack overflow with any of them and be able to hit the same account?</p>
| [
{
"answer_id": 4777,
"author": "Otto",
"author_id": 519,
"author_profile": "https://Stackoverflow.com/users/519",
"pm_score": 6,
"selected": true,
"text": "<HEAD></HEAD>"
},
{
"answer_id": 112662,
"author": "Troels Thomsen",
"author_id": 20138,
"author_profile": "https://Stackoverflow.com/users/20138",
"pm_score": 3,
"selected": false,
"text": "<link rel=\"openid2.provider\" href=\"http://www.loginbuzz.com/provider.axd\" />\n<link rel=\"openid2.local_id\" href=\"http://example.loginbuzz.com/\" />\n<link rel=\"openid.server\" href=\"http://www.loginbuzz.com/provider.axd\" />\n<link rel=\"openid.delegate\" href=\"http://example.loginbuzz.com/\" />\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/274/"
] |
4,664 | <p>Should the folders in a solution match the namespace?</p>
<p>In one of my teams projects, we have a class library that has many sub-folders in the project.</p>
<p>Project Name and Namespace: <code>MyCompany.Project.Section</code>.</p>
<p>Within this project, there are several folders that match the namespace section:</p>
<ul>
<li>Folder <code>Vehicles</code> has classes in the <code>MyCompany.Project.Section.Vehicles</code> namespace</li>
<li>Folder <code>Clothing</code> has classes in the<code>MyCompany.Project.Section.Clothing</code> namespace</li>
<li>etc.</li>
</ul>
<p>Inside this same project, is another rogue folder</p>
<ul>
<li>Folder <code>BusinessObjects</code> has classes in the <code>MyCompany.Project.Section</code> namespace</li>
</ul>
<p>There are a few cases like this where folders are made for "organizational convenience".</p>
<p>My question is: What's the standard? In class libraries do the folders usually match the namespace structure or is it a mixed bag?</p>
| [
{
"answer_id": 55781,
"author": "Jay Bazuzi",
"author_id": 5314,
"author_profile": "https://Stackoverflow.com/users/5314",
"pm_score": 5,
"selected": false,
"text": "// ----- Foo.cs\npartial class Foo\n{\n // Foo implementation here\n}\n // ----- Foo.Bar.cs\npartial class Foo\n{\n class Bar\n {\n // Foo.Bar implementation here\n }\n}\n"
},
{
"answer_id": 29255554,
"author": "Weyland Yutani",
"author_id": 2086856,
"author_profile": "https://Stackoverflow.com/users/2086856",
"pm_score": 6,
"selected": false,
"text": "var rectangle = new Project1.Window.Rectangle();\n using Rectangle = Project1.Window.Rectangle;\n using Project1.General; \nusing Project1.Image; \nusing Project1.Window; \nusing Project1.Window.Controls; \nusing Project1.Shapes; \nusing Project1.Input; \nusing Project1.Data; \n using Project1;\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
4,677 | <p>The singleton pattern is a design pattern that is used to restrict instantiation of a class to one object instance. Although I know how to code the singleton pattern in C++ and Java, I was wondering if anyone know how to implement it in Ruby?</p>
| [
{
"answer_id": 4686,
"author": "cynicalman",
"author_id": 410,
"author_profile": "https://Stackoverflow.com/users/410",
"pm_score": 3,
"selected": false,
"text": "class Clazz\n include Singleton\nend\n"
},
{
"answer_id": 5453,
"author": "CodingWithoutComments",
"author_id": 25,
"author_profile": "https://Stackoverflow.com/users/25",
"pm_score": 4,
"selected": true,
"text": "require 'singleton'\n\nclass Example\n include Singleton\nend\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25/"
] |
4,689 | <p>What fonts do you use for programming, and for what language/IDE? I use <a href="http://www.microsoft.com/downloads/details.aspx?familyid=22e69ae4-7e40-4807-8a86-b3d36fab68d3&displaylang=en" rel="nofollow noreferrer" title="Consolas">Consolas</a> for all my Visual Studio work, any other recommendations?</p>
| [
{
"answer_id": 4704,
"author": "deadprogrammer",
"author_id": 556,
"author_profile": "https://Stackoverflow.com/users/556",
"pm_score": 9,
"selected": true,
"text": "Illegal1 = O0"
},
{
"answer_id": 23050,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 1,
"selected": false,
"text": "nomacatsui"
},
{
"answer_id": 1303742,
"author": "deceze",
"author_id": 476,
"author_profile": "https://Stackoverflow.com/users/476",
"pm_score": 0,
"selected": false,
"text": "ForMateKonaVe"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/637/"
] |
4,724 | <p>I really feel that I should learn <a href="http://en.wikipedia.org/wiki/Lisp_(programming_language)" rel="noreferrer">Lisp</a> and there are plenty of good resources out there to help me do it.</p>
<p>I'm not put off by the complicated syntax, but where in "traditional commercial programming" would I find places it would make sense to use it instead of a procedural language.</p>
<p>Is there a commercial killer-app out there that's been written in Lisp ?</p>
| [
{
"answer_id": 8789,
"author": "John with waffle",
"author_id": 279,
"author_profile": "https://Stackoverflow.com/users/279",
"pm_score": 3,
"selected": false,
"text": "(defun quicksort (lis) \n (if (null lis) \n nil\n (let* ((x (car lis)) \n (r (cdr lis)) \n (fn (lambda (a) \n (< a x))))\n (append (quicksort (remove-if-not fn \n r)) \n (list x)\n (quicksort (remove-if fn \n r))))))\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/381/"
] |
4,738 | <p>I'm developing a data access component that will be used in a website that contains a mix of classic ASP and ASP.NET pages, and need a good way to manage its configuration settings.</p>
<p>I'd like to use a custom <code>ConfigurationSection</code>, and for the ASP.NET pages this works great. But when the component is called via COM interop from a classic ASP page, the component isn't running in the context of an ASP.NET request and therefore has no knowledge of web.config.</p>
<p>Is there a way to tell the <code>ConfigurationManager</code> to just load the configuration from an arbitrary path (e.g. <code>..\web.config</code> if my assembly is in the <code>/bin</code> folder)? If there is then I'm thinking my component can fall back to that if the default <code>ConfigurationManager.GetSection</code> returns <code>null</code> for my custom section.</p>
<p>Any other approaches to this would be welcome!</p>
| [
{
"answer_id": 4746,
"author": "Ishmaeel",
"author_id": 227,
"author_profile": "https://Stackoverflow.com/users/227",
"pm_score": 8,
"selected": true,
"text": "System.Configuration.ConfigurationFileMap fileMap = new ConfigurationFileMap(strConfigPath); //Path to your config file\nSystem.Configuration.Configuration configuration = System.Configuration.ConfigurationManager.OpenMappedMachineConfiguration(fileMap);\n"
},
{
"answer_id": 5965,
"author": "Joseph Daigle",
"author_id": 507,
"author_profile": "https://Stackoverflow.com/users/507",
"pm_score": 3,
"selected": false,
"text": "OpenMappedMachineConfiguration() Configuration HasFile"
},
{
"answer_id": 3818417,
"author": "Gavin",
"author_id": 78216,
"author_profile": "https://Stackoverflow.com/users/78216",
"pm_score": 5,
"selected": false,
"text": "OpenMappedMachineConfiguration ConfigurationFileMap fileMap = new ConfigurationFileMap(strConfigPath);\nConfiguration configuration = ConfigurationManager.OpenMappedMachineConfiguration(fileMap);\nMailSettingsSectionGroup thisMail = configuration.GetSectionGroup(\"system.net/mailSettings\") as MailSettingsSectionGroup; // returns null\n configuration.SectionGroups <sectionGroup name=\"system.net\" type=\"System.Net.Configuration.NetSectionGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\">\n <sectionGroup name=\"mailSettings\" type=\"System.Net.Configuration.MailSettingsSectionGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\">\n <section name=\"smtp\" type=\"System.Net.Configuration.SmtpSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" />\n </sectionGroup>\n</sectionGroup>\n ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap() { ExeConfigFilename = strConfigPath };\nConfiguration configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);\nMailSettingsSectionGroup thisMail = configuration.GetSectionGroup(\"system.net/mailSettings\") as MailSettingsSectionGroup; // returns valid object!\n"
},
{
"answer_id": 4157995,
"author": "Iftikhar Ali",
"author_id": 504911,
"author_profile": "https://Stackoverflow.com/users/504911",
"pm_score": 2,
"selected": false,
"text": "string sMsg = System.Configuration.ConfigurationManager.AppSettings[\"WSURL\"];\n"
},
{
"answer_id": 14246260,
"author": "Roi Shabtai",
"author_id": 739558,
"author_profile": "https://Stackoverflow.com/users/739558",
"pm_score": 6,
"selected": false,
"text": "AppDomain.CurrentDomain.SetData(\"APP_CONFIG_FILE\", <Full_Path_To_The_Configuration_File>);\n AppDomain.CurrentDomain.SetData(\"APP_CONFIG_FILE\", @\"C:\\Shared\\app.config\");\n IDisposable using(AppConfig.Change(tempFileName))\n{\n // tempFileName is used for the app config during this context\n}\n"
},
{
"answer_id": 24745637,
"author": "Javier Cañon",
"author_id": 3838468,
"author_profile": "https://Stackoverflow.com/users/3838468",
"pm_score": 1,
"selected": false,
"text": "var config = WebConfigurationManager.OpenWebConfiguration(\"~/Sites/\" + requestDomain + \"/\");\n(..)\nconfig.AppSettings.Settings[\"xxxx\"].Value;\n"
},
{
"answer_id": 35280447,
"author": "JoelFan",
"author_id": 16012,
"author_profile": "https://Stackoverflow.com/users/16012",
"pm_score": 0,
"selected": false,
"text": "var appPath = AppDomain.CurrentDomain.BaseDirectory;\nvar configPath = Path.Combine(appPath, baseFileName);;\nvar root = XElement.Load(configPath);\n\n// can call root.Elements(...)\n"
},
{
"answer_id": 51765082,
"author": "gatsby",
"author_id": 5775048,
"author_profile": "https://Stackoverflow.com/users/5775048",
"pm_score": 1,
"selected": false,
"text": "AppDomain.CurrentDomain.SetData(\"APP_CONFIG_FILE\", \"newAppConfig.config);\n"
},
{
"answer_id": 55241920,
"author": "Jacob",
"author_id": 665783,
"author_profile": "https://Stackoverflow.com/users/665783",
"pm_score": 4,
"selected": false,
"text": "System.Configuration.ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();\nfileMap.ExeConfigFilename = \"YourFilePath\";\nSystem.Configuration.Configuration configuration = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/205/"
] |
4,752 | <p>We've been having some issues with a SharePoint instance in a test
environment. Thankfully this is not production ;) The problems started
when the disk with the SQL Server databases and search index ran out
of space. Following this, the search service would not run and search
settings in the SSP were not accessible. Reclaiming the disk space did
not resolve the issue. So rather than restoring the VM, we decided to
try to fix the issue.</p>
<p>We created a new SSP and changed the association of all services to
the new SSP. The old SSP and it's databases were then deleted. Search
results for PDF files are no longer appearing, but the search works
fine otherwise. MySites also works OK.</p>
<p>Following the implementation of this change, these problems occur:</p>
<blockquote>
<p>1) An audit failure message started appearing in the application event log, for 'DOMAIN\SPMOSSSvc' which is the MOSS farm account.</p>
</blockquote>
<pre><code>Event Type: Failure Audit
Event Source: MSSQLSERVER
Event Category: (4)
Event ID: 18456
Date: 8/5/2008
Time: 3:55:19 PM
User: DOMAIN\SPMOSSSvc
Computer: dastest01
Description:
Login failed for user 'DOMAIN\SPMOSSSvc'. [CLIENT: <local machine>]
</code></pre>
<blockquote>
<p>2) SQL Server profiler is showing queries from SharePoint that reference the old
(deleted) SSP database.</p>
</blockquote>
<p>So...</p>
<ul>
<li>Where would these references to DOMAIN\SPMOSSSvc and the old SSP
database exist?</li>
<li>Is there a way to 'completely' remove the SSP from the server, and
re-create? The option to delete was not available (greyed out) when a
single SSP is in place.</li>
</ul>
| [
{
"answer_id": 5475,
"author": "Daniel O",
"author_id": 697,
"author_profile": "https://Stackoverflow.com/users/697",
"pm_score": 1,
"selected": false,
"text": "stsadm.exe -o deletessp -title <sspname> [-deletedatabases]\n deletedatbases"
},
{
"answer_id": 7109,
"author": "Daniel McPherson",
"author_id": 897,
"author_profile": "https://Stackoverflow.com/users/897",
"pm_score": 2,
"selected": false,
"text": "<database name>_job_deleteExpiredSessions"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/636/"
] |
4,782 | <p>How much database performance overhead is involved with using C# and LINQ compared to custom optimized queries loaded with mostly low-level C, both with a SQL Server 2008 backend?</p>
<p>I'm specifically thinking here of a case where you have a fairly data-intensive program and will be doing a data refresh or update at least once per screen and will have 50-100 simultaneous users.</p>
| [
{
"answer_id": 5475,
"author": "Daniel O",
"author_id": 697,
"author_profile": "https://Stackoverflow.com/users/697",
"pm_score": 1,
"selected": false,
"text": "stsadm.exe -o deletessp -title <sspname> [-deletedatabases]\n deletedatbases"
},
{
"answer_id": 7109,
"author": "Daniel McPherson",
"author_id": 897,
"author_profile": "https://Stackoverflow.com/users/897",
"pm_score": 2,
"selected": false,
"text": "<database name>_job_deleteExpiredSessions"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/177/"
] |
4,816 | <p>How do you resolve a domain name to an IP address with .NET/C#?</p>
| [
{
"answer_id": 4821,
"author": "lubos hasko",
"author_id": 275,
"author_profile": "https://Stackoverflow.com/users/275",
"pm_score": 5,
"selected": true,
"text": "using System.Net;\n\nforeach (IPAddress address in Dns.GetHostAddresses(\"www.google.com\"))\n{\n Console.WriteLine(address.ToString());\n}\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/390/"
] |
4,824 | <p>Is there a C library function that will return the index of a character in a string?</p>
<p>So far, all I've found are functions like strstr that will return the found char *, not it's location in the original string.</p>
| [
{
"answer_id": 4832,
"author": "Bill",
"author_id": 102,
"author_profile": "https://Stackoverflow.com/users/102",
"pm_score": 5,
"selected": false,
"text": "strstr char * source = \"test string\"; /* assume source address is */\n /* 0x10 for example */\nchar * found = strstr( source, \"in\" ); /* should return 0x18 */\nif (found != NULL) /* strstr returns NULL if item not found */\n{\n int index = found - source; /* index is 8 */\n /* source[8] gets you \"i\" */\n}\n"
},
{
"answer_id": 4833,
"author": "Michal Sznajder",
"author_id": 501,
"author_profile": "https://Stackoverflow.com/users/501",
"pm_score": 4,
"selected": false,
"text": "char *pos = strchr (myString, '#');\nint pos = pos ? pos - myString : -1;\n"
},
{
"answer_id": 4834,
"author": "Kyle Cronin",
"author_id": 658,
"author_profile": "https://Stackoverflow.com/users/658",
"pm_score": 2,
"selected": false,
"text": "char *a = \"Hello World!\";\nchar *b = strstr(a, \"World\");\n\nint position = b - a;\n\nprintf(\"the offset is %i\\n\", position);\n the offset is 6\n"
},
{
"answer_id": 4838,
"author": "Jonathan Works",
"author_id": 309844,
"author_profile": "https://Stackoverflow.com/users/309844",
"pm_score": 5,
"selected": true,
"text": "/* strcspn example */\n#include <stdio.h>\n#include <string.h>\n\nint main ()\n{\n char str[] = \"fcba73\";\n char keys[] = \"1234567890\";\n int i;\n i = strcspn (str,keys);\n printf (\"The first number in str is at position %d.\\n\",i+1);\n return 0;\n}\n"
},
{
"answer_id": 35494788,
"author": "fnisi",
"author_id": 1884351,
"author_profile": "https://Stackoverflow.com/users/1884351",
"pm_score": 0,
"selected": false,
"text": "int zstring_search_chr(char *token,char s){\n if (!token || s=='\\0')\n return 0;\n\n for (;*token; token++)\n if (*token == s)\n return 1;\n\n return 0;\n}\n"
},
{
"answer_id": 48264846,
"author": "snack0verflow",
"author_id": 9004745,
"author_profile": "https://Stackoverflow.com/users/9004745",
"pm_score": 0,
"selected": false,
"text": "s=\"bvbrburbhlkvp\";\nint index=strstr(&s,\"h\")-&s;\n 'h'"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/75/"
] |
4,839 | <p>My dream IDE does full code hints, explains and completes PHP, Javascript, HTML and CSS. I know it exists!</p>
<p>so far, <a href="http://www.zend.com/en/products/studio/features" rel="noreferrer">Zend studio 6</a>, under the Eclipse IDE does a great job at hinting PHP, some Javascript and HTML, any way I can expand this?</p>
<p>edit: a bit more information: right now, using zend-6 under eclipse, i type in</p>
<pre><code><?php
p //(a single letter "p")
</code></pre>
<p>and I get a hint tooltip with all the available php functions that begin with "p" (phpinfo(), parse_ini_file(), parse_str(), etc...), each with its own explanation: phpinfo()->"outputs lots of PHP information", the same applies for regular HTML (no explanations however).</p>
<p>However, I get nothing when I do:</p>
<pre><code><style>
b /* (a single letter "b") */
</code></pre>
<p>I'd love it if I could get, from that "b" suggestions for "border", "bottom", etc. The same applies for Javascript.</p>
<p>Any ideas?</p>
| [
{
"answer_id": 4852,
"author": "Jonathan Works",
"author_id": 309844,
"author_profile": "https://Stackoverflow.com/users/309844",
"pm_score": 0,
"selected": false,
"text": "function test(){\n\n}\n\nte<CTRL+SPACE>\n var test = function(){\n\n};\n\n\nte<CTRL+SPACE>\n"
},
{
"answer_id": 4877,
"author": "Jonathan Works",
"author_id": 309844,
"author_profile": "https://Stackoverflow.com/users/309844",
"pm_score": 3,
"selected": true,
"text": "border"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/547/"
] |
4,850 | <p>I am new to C# and am doing some work in an existing application. I have a DirectX viewport that has components in it that I want to be able to position using arrow keys.</p>
<p>Currently I am overriding ProcessCmdKey and catching arrow input and send an OnKeyPress event. This works, but I want to be able to use modifiers(<strong><kbd>ALT</kbd>+<kbd>CTRL</kbd>+<kbd>SHIFT</kbd></strong>). As soon as I am holding a modifier and press an arrow no events are triggered that I am listening to.</p>
<p>Does anyone have any ideas or suggestions on where I should go with this?</p>
| [
{
"answer_id": 5026,
"author": "Tokabi",
"author_id": 315,
"author_profile": "https://Stackoverflow.com/users/315",
"pm_score": 5,
"selected": true,
"text": "protected override bool ProcessCmdKey(ref Message msg, Keys keyData)\n{\n bool shiftPressed = (keyData & Keys.Shift) != 0;\n Keys unmodifiedKey = (keyData & Keys.KeyCode);\n\n // rest of code goes here\n}\n"
},
{
"answer_id": 2033811,
"author": "cdiggins",
"author_id": 184528,
"author_profile": "https://Stackoverflow.com/users/184528",
"pm_score": 3,
"selected": false,
"text": " public Keys UnmodifiedKey(Keys key)\n {\n return key & Keys.KeyCode;\n }\n\n public bool KeyPressed(Keys key, Keys test)\n {\n return UnmodifiedKey(key) == test;\n }\n\n public bool ModifierKeyPressed(Keys key, Keys test)\n {\n return (key & test) == test;\n }\n\n public bool ControlPressed(Keys key)\n {\n return ModifierKeyPressed(key, Keys.Control);\n }\n\n public bool AltPressed(Keys key)\n {\n return ModifierKeyPressed(key, Keys.Alt);\n }\n\n public bool ShiftPressed(Keys key)\n {\n return ModifierKeyPressed(key, Keys.Shift);\n }\n\n protected override bool ProcessCmdKey(ref Message msg, Keys keyData)\n {\n if (KeyPressed(keyData, Keys.Left) && AltPressed(keyData))\n {\n int n = code.Text.IndexOfPrev('<', code.SelectionStart);\n if (n < 0) return false;\n if (ShiftPressed(keyData))\n {\n code.ExpandSelectionLeftTo(n);\n }\n else\n {\n code.SelectionStart = n;\n code.SelectionLength = 0;\n }\n return true;\n }\n else if (KeyPressed(keyData, Keys.Right) && AltPressed(keyData))\n {\n if (ShiftPressed(keyData))\n {\n int n = code.Text.IndexOf('>', code.SelectionEnd() + 1);\n if (n < 0) return false;\n code.ExpandSelectionRightTo(n + 1);\n }\n else\n {\n int n = code.Text.IndexOf('<', code.SelectionStart + 1);\n if (n < 0) return false;\n code.SelectionStart = n;\n code.SelectionLength = 0;\n }\n return true;\n }\n return base.ProcessCmdKey(ref msg, keyData);\n }\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41/"
] |
4,860 | <p>We have a question with regards to XML-sig and need detail about the optional elements as well as some of the canonicalization and transform stuff. We're writing a spec for a very small XML-syntax payload that will go into the metadata of media files and it needs to by cryptographically signed. Rather than re-invent the wheel, We thought we should use the XML-sig spec but I think most of it is overkill for what we need, and so we like to have more information/dialogue with people who know the details.</p>
<p>Specifically, do we need to care about either transforms or canonicalization if the XML is very basic with no tabs for formatting and is specific to our needs?</p>
| [
{
"answer_id": 5026,
"author": "Tokabi",
"author_id": 315,
"author_profile": "https://Stackoverflow.com/users/315",
"pm_score": 5,
"selected": true,
"text": "protected override bool ProcessCmdKey(ref Message msg, Keys keyData)\n{\n bool shiftPressed = (keyData & Keys.Shift) != 0;\n Keys unmodifiedKey = (keyData & Keys.KeyCode);\n\n // rest of code goes here\n}\n"
},
{
"answer_id": 2033811,
"author": "cdiggins",
"author_id": 184528,
"author_profile": "https://Stackoverflow.com/users/184528",
"pm_score": 3,
"selected": false,
"text": " public Keys UnmodifiedKey(Keys key)\n {\n return key & Keys.KeyCode;\n }\n\n public bool KeyPressed(Keys key, Keys test)\n {\n return UnmodifiedKey(key) == test;\n }\n\n public bool ModifierKeyPressed(Keys key, Keys test)\n {\n return (key & test) == test;\n }\n\n public bool ControlPressed(Keys key)\n {\n return ModifierKeyPressed(key, Keys.Control);\n }\n\n public bool AltPressed(Keys key)\n {\n return ModifierKeyPressed(key, Keys.Alt);\n }\n\n public bool ShiftPressed(Keys key)\n {\n return ModifierKeyPressed(key, Keys.Shift);\n }\n\n protected override bool ProcessCmdKey(ref Message msg, Keys keyData)\n {\n if (KeyPressed(keyData, Keys.Left) && AltPressed(keyData))\n {\n int n = code.Text.IndexOfPrev('<', code.SelectionStart);\n if (n < 0) return false;\n if (ShiftPressed(keyData))\n {\n code.ExpandSelectionLeftTo(n);\n }\n else\n {\n code.SelectionStart = n;\n code.SelectionLength = 0;\n }\n return true;\n }\n else if (KeyPressed(keyData, Keys.Right) && AltPressed(keyData))\n {\n if (ShiftPressed(keyData))\n {\n int n = code.Text.IndexOf('>', code.SelectionEnd() + 1);\n if (n < 0) return false;\n code.ExpandSelectionRightTo(n + 1);\n }\n else\n {\n int n = code.Text.IndexOf('<', code.SelectionStart + 1);\n if (n < 0) return false;\n code.SelectionStart = n;\n code.SelectionLength = 0;\n }\n return true;\n }\n return base.ProcessCmdKey(ref msg, keyData);\n }\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/661/"
] |
4,870 | <p>I'm writing a Telnet client of sorts in C# and part of what I have to parse are ANSI/VT100 escape sequences, specifically, just those used for colour and formatting (detailed <a href="http://www.termsys.demon.co.uk/vtansi.htm#colors" rel="noreferrer">here</a>).</p>
<p>One method I have is one to find all the codes and remove them, so I can render the text without any formatting if needed:</p>
<pre><code>
public static string StripStringFormating(string formattedString)
{
if (rTest.IsMatch(formattedString))
return rTest.Replace(formattedString, string.Empty);
else
return formattedString;
}
</code></pre>
<p>I'm new to regular expressions and I was suggested to use this:</p>
<pre><code>static Regex rText = new Regex(@"\e\[[\d;]+m", RegexOptions.Compiled);</code></pre>
<p>However, this failed if the escape code was incomplete due to an error on the server. So then this was suggested, but my friend warned it might be slower (this one also matches another condition (z) that I might come across later):</p>
<pre><code>static Regex rTest =
new Regex(@"(\e(\[([\d;]*[mz]?))?)?", RegexOptions.Compiled);</code></pre>
<p>This not only worked, but was in fact faster to and reduced the impact on my text rendering. Can someone explain to a regexp newbie, why? :)</p>
| [
{
"answer_id": 4915,
"author": "Jonathan Works",
"author_id": 309844,
"author_profile": "https://Stackoverflow.com/users/309844",
"pm_score": 2,
"selected": false,
"text": "\"(\\e\\[(\\d{1,2};)*?[mz]?)?\"\n"
},
{
"answer_id": 52980,
"author": "Oskar",
"author_id": 5472,
"author_profile": "https://Stackoverflow.com/users/5472",
"pm_score": 2,
"selected": false,
"text": "public static string StripStringFormating(string formattedString)\n{ \n return rTest.Replace(formattedString, string.Empty);\n}\n"
},
{
"answer_id": 84532,
"author": "Doug Moore",
"author_id": 13179,
"author_profile": "https://Stackoverflow.com/users/13179",
"pm_score": 1,
"selected": false,
"text": "(?s)(?:\\e\\[(?:(\\d+);?)*([A-Za-z])(.*?))(?=\\e\\[|\\z)\n <ESC>[1;32mThis is bright green.<ESC>[0m This is the default color.\n [ [1, 32], m, This is bright green.]\n[0, m, This is the default color.]\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/483/"
] |
4,884 | <p>I have a custom built ajax [div] based dynamic dropdown. </p>
<p>I have an [input] box which; <code>onkeyup</code>, runs an Ajax search which returns results in <code>div</code>s and are drawn back in using <code>innerHTML</code>. These <code>div</code>s all have highlights <code>onmouseover</code> so, a typical successful search yields the following structure (pardon the semi-code):</p>
<pre><code>[input]
[div id=results] //this gets overwritten contantly by my AJAX function
[div id=result1 onmouseover=highlight onclick=input.value=result1]
[div id=result2 onmouseover=highlight onclick=input.value=result2]
[div id=result2 onmouseover=highlight onclick=input.value=result2]
[/div]
</code></pre>
<p>It works.</p>
<p>However, I'm missing the important functions behind regular HTML elements. I can't keyboard down or up between "options".</p>
<p>I know javascript handles keyboard events but; I haven't been able to find a good guide. (Of course, the follow-up question will end up being: can I use <code><ENTER></code> to trigger that <code>onclick</code> event?)</p>
| [
{
"answer_id": 4897,
"author": "Tom",
"author_id": 20,
"author_profile": "https://Stackoverflow.com/users/20",
"pm_score": 1,
"selected": false,
"text": "keyup keydown innerHTML createTextNode() createElement() appendChild()"
},
{
"answer_id": 13918,
"author": "Walter Rumsby",
"author_id": 1654,
"author_profile": "https://Stackoverflow.com/users/1654",
"pm_score": 4,
"selected": true,
"text": "div id=\"results\" onkeyup onkeydown div onkeyup"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/547/"
] |
4,911 | <p>So in my simple learning website, I use the built in ASP.NET authentication system. </p>
<p>I am adding now a user table to save stuff like his zip, DOB etc. My question is:</p>
<ol>
<li>In the new table, should the key be the user name (the string) or the user ID which is that GUID looking number they use in the <code>asp_ tables</code>. </li>
<li>If the best practice is to use that ugly guid, does anyone know how to get it? it seems to not be accessible as easily as the name (<code>System.Web.HttpContext.Current.User.Identity.Name</code>)</li>
<li>If you suggest I use neither (not the guid nor the userName fields provided by ASP.NET authentication) then how do I do it with ASP.NET authentication? One option I like is to use the email address of the user as login, but how to I make ASP.NET authentication system use an email address instead of a user name? (or there is nothing to do there, it is just me deciding I "know" userName is actually an email address?</li>
</ol>
<p>Please note:</p>
<ul>
<li>I am not asking on how get a GUID in .NET, I am just referring to the userID column in the <code>asp_ tables</code> as guid.</li>
<li>The user name is unique in ASP.NET authentication.</li>
</ul>
| [
{
"answer_id": 4936,
"author": "Dillie-O",
"author_id": 71,
"author_profile": "https://Stackoverflow.com/users/71",
"pm_score": 0,
"selected": false,
"text": "Dim guidProduct As Guid = Guid.NewGuid()\n Guid guidProduct = Guid.NewGuid();\n"
},
{
"answer_id": 5053,
"author": "palmsey",
"author_id": 521,
"author_profile": "https://Stackoverflow.com/users/521",
"pm_score": 5,
"selected": false,
"text": "Guid UserID = new Guid(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString());\n"
},
{
"answer_id": 828512,
"author": "Schprit",
"author_id": 102064,
"author_profile": "https://Stackoverflow.com/users/102064",
"pm_score": 2,
"selected": false,
"text": "Guid UserID = new Guid(Membership.GetUser(User.Identity.Name)).ProviderUserKey.ToString());\n Guid UserID = new Guid(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString());\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/350/"
] |
4,913 | <p>Using VS2008, C#, .Net 2 and Winforms how can I make a regular Button look "pressed"?
Imagine this button is an on/off switch.
<code>ToolStripButton</code> has the Checked property, but the regular Button does not.</p>
| [
{
"answer_id": 197561,
"author": "Chris Hughes",
"author_id": 27405,
"author_profile": "https://Stackoverflow.com/users/27405",
"pm_score": 0,
"selected": false,
"text": "ToggleButton"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/626/"
] |
4,922 | <p>I saw this in <a href="https://stackoverflow.com/a/4384/697449">an answer to another question</a>, in reference to shortcomings of the Java spec:</p>
<blockquote>
<p>There are more shortcomings and this is a subtle topic. Check <a href="http://kiranthakkar.blogspot.com/2007/05/method-overloading-with-new-features-of.html" rel="noreferrer">this</a> out:</p>
<pre><code>public class methodOverloading{
public static void hello(Integer x){
System.out.println("Integer");
}
public static void hello(long x){
System.out.println("long");
}
public static void main(String[] args){
int i = 5;
hello(i);
}
}
</code></pre>
<p>Here "long" would be printed (haven't checked it myself), because the compiler chooses widening over auto-boxing. Be careful when using auto-boxing or don't use it at all!</p>
</blockquote>
<p><em>Are we sure that this is actually an example of widening instead of autoboxing, or is it something else entirely?</em></p>
<p>On my initial scanning, I would agree with the statement that the output would be "long" on the basis of <code>i</code> being declared as a primitive and not an object. However, if you changed</p>
<pre><code>hello(long x)
</code></pre>
<p>to</p>
<pre><code>hello(Long x)
</code></pre>
<p>the output would print "Integer"</p>
<p>What's really going on here? I know nothing about the compilers/bytecode interpreters for java...</p>
| [
{
"answer_id": 5091,
"author": "Camilo Díaz Repka",
"author_id": 861,
"author_profile": "https://Stackoverflow.com/users/861",
"pm_score": 5,
"selected": true,
"text": "public static void main(java.lang.String[]);\n Code:\n 0: iconst_ 5\n 1: istore_ 1\n 2: iload_ 1\n 3: i2l\n 4: invokestatic #6; //Method hello:(J)V\n 7: return\n\n}\n public static void main(java.lang.String[]);\n Code:\n 0: iconst_ 5\n 1: istore_ 1\n 2: iload_ 1\n 3: invokestatic #6; //Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 6: invokestatic #7; //Method hello:(Ljava/lang/Integer;)V\n 9: return\n\n}\n"
},
{
"answer_id": 5164,
"author": "dlinsin",
"author_id": 198,
"author_profile": "https://Stackoverflow.com/users/198",
"pm_score": 2,
"selected": false,
"text": "public static void hello(Collection x){\n System.out.println(\"Collection\");\n}\n\npublic static void hello(List x){\n System.out.println(\"List\");\n}\n\npublic static void main(String[] args){\n Collection col = new ArrayList();\n hello(col);\n}\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/670/"
] |
4,923 | <p>I'm using <code>ColdFusion</code> to populate a template that includes HTML unordered lists (<code><ul></code>s).</p>
<p>Most of these aren't that long, but a few have ridiculously long lengths and could really stand to be in 2-3 columns.</p>
<p>Is there an HTML, ColdFusion or perhaps JavaScript (I'm accepting jQuery solutions) way to do this easily? It's not worth some over-complicated heavyweight solution to save some scrolling.</p>
| [
{
"answer_id": 4963,
"author": "Chris Marasti-Georg",
"author_id": 96,
"author_profile": "https://Stackoverflow.com/users/96",
"pm_score": 4,
"selected": false,
"text": "if list length > 150, split into 3 columns, else if > 70, split into 2 columns, else 1 clear: left clear: both .column {\n float: left;\n width: 50%;\n}\n.clear {\n clear: both;\n} <ul class=\"column\">\n <li>Item 1</li>\n <li>Item 2</li>\n <!-- ... -->\n <li>Item 49</li>\n <li>Item 50</li>\n</ul>\n<ul class=\"column\">\n <li>Item 51</li>\n <li>Item 52</li>\n <!-- ... -->\n <li>Item 99</li>\n <li>Item 100</li>\n</ul>\n<div class=\"clear\">"
},
{
"answer_id": 6285,
"author": "doekman",
"author_id": 56,
"author_profile": "https://Stackoverflow.com/users/56",
"pm_score": 4,
"selected": false,
"text": "ul {\n -webkit-column-count: 3;\n -moz-column-count: 3;\n column-count: 3;\n -webkit-column-gap: 2em;\n -moz-column-gap: 2em;\n column-gap: 2em;\n}\n"
},
{
"answer_id": 64089,
"author": "Dan Roberts",
"author_id": 8345,
"author_profile": "https://Stackoverflow.com/users/8345",
"pm_score": 2,
"selected": false,
"text": "<cfset list=\"1,2,3,4,5,6,7,8,9,10,11,12,13,14\">\n<cfset numberOfColumns = \"3\">\n\n<cfoutput>\n<cfloop from=\"1\" to=\"#numberOfColumns#\" index=\"col\">\n <ul>\n <cfloop from=\"#col#\" to=\"#listLen(list)#\" index=\"i\" step=\"#numberOfColumns#\">\n <li>#listGetAt(list,i)#</li>\n </cfloop>\n </ul>\n</cfloop>\n</cfoutput>\n"
},
{
"answer_id": 65451,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "function columns(x,num) {\n num || (num = 2);\n x.normalize();\n\n var cols, i, j, col, used, left, len, islist;\n used = left = 0;\n cols = <div class={'columns cols'+num}></div>;\n\n if((left = x.length())==1)\n left = x.children().length();\n else\n islist = true;\n\n for(i=0; i<num; i++) {\n len = Math.ceil(left/(num-i));\n col = islist ? new XMLList\n : <{x.name()}></{x.name()}>;\n\n if(!islist && x['@class'].toString())\n col['@class'] = x['@class'];\n\n for(j=used; j<len+used; j++)\n islist ? (col += x[j].copy()) \n : (col.appendChild(x.child(j).copy()));\n\n used += len;\n left -= len;\n cols.appendChild(<div class={'column'+(i==(num-1) ? 'collast' : '')}>{col}</div>);\n }\n return cols;\n}\n columns(listNode,2) <ul class=\"foo\">\n <li>a</li>\n <li>b</li>\n <li>c</li>\n</ul>\n <div class=\"columns cols2\">\n <div class=\"column\">\n <ul class=\"foo\">\n <li>a</li>\n <li>b</li>\n </ul>\n </div>\n <div class=\"column collast\">\n <ul class=\"foo\">\n <li>c</li>\n </ul>\n </div>\n</div>\n div.columns {\n overflow: hidden;\n _zoom: 1;\n}\n\ndiv.columns div.column {\n float: left;\n}\n\ndiv.cols2 div.column {\n width: 47.2%;\n padding: 0 5% 0 0;\n}\n\ndiv.cols3 div.column {\n width: 29.8%;\n padding: 0 5% 0 0;\n}\n\ndiv.cols4 div.column {\n width: 21.1%;\n padding: 0 5% 0 0;\n}\n\ndiv.cols5 div.column {\n width: 15.9%;\n padding: 0 5% 0 0;\n}\n\ndiv.columns div.collast {\n padding: 0;\n}\n"
},
{
"answer_id": 76747,
"author": "ScottyDont",
"author_id": 13718,
"author_profile": "https://Stackoverflow.com/users/13718",
"pm_score": 3,
"selected": false,
"text": "$(\"ul#listname\").clone().attr(\"id\",\"listname2\").after()\n $(\"ul#listname li:even\").remove();\n$(\"ul#listname2 li:odd\").remove();\n .slice(begin,end) :nth-child .slice(8,14) ul :gt(8)"
},
{
"answer_id": 76788,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "<li/> ul ul <cfset thelist = \"1,2,3,4,5,6,7,8,9,10,11,12,13\"> \n<cfset container = []> \n<cfset container[1] = []> \n<cfset container[2] = []> \n<cfset container[3] = []> \n\n<cfloop list=\"#thelist#\" index=\"i\"> \n <cfif i mod 3 eq 0> \n <cfset arrayappend(container[3], i)> \n <cfelseif i mod 2 eq 0> \n <cfset arrayappend(container[2], i)> \n <cfelse> \n <cfset arrayappend(container[1], i)> \n </cfif> \n</cfloop> \n\n<style type=\"text/css\"> \n ul li { float: left; } \n ul li ul li { clear: left; } \n</style> \n\n<cfoutput> \n<ul> \n <cfloop from=\"1\" to=\"3\" index=\"a\"> \n <li> \n <ul> \n <cfloop array=\"#container[a]#\" index=\"i\"> \n <li>#i#</li> \n </cfloop> \n </ul> \n </li> \n </cfloop> \n</ul> \n</cfoutput>\n"
},
{
"answer_id": 110355,
"author": "jonah",
"author_id": 19861,
"author_profile": "https://Stackoverflow.com/users/19861",
"pm_score": 2,
"selected": false,
"text": "</ul><ul> <cfset numberOfColumns = 3 />\n<cfset numberOfEntries = 34 />\n<ul style=\"float:left;\">\n <cfloop from=\"1\" to=\"#numberOfEntries#\" index=\"i\">\n <li>#i#</li>\n <cfif NOT i MOD ceiling(numberOfEntries / numberOfColumns)>\n </ul>\n <ul style=\"float:left;\">\n </cfif>\n </cfloop>\n</ul>\n ceiling() round()"
},
{
"answer_id": 1941883,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "var $cat_list = $('ul#catList'); // UL with all list items.\nvar $cat_flow = $('div#catFlow'); // Target div.\nvar $cat_list_clone = $cat_list.clone(); // Clone the list.\n$('li:odd', $cat_list).remove(); // Remove odd list items.\n$('li:even', $cat_list_clone).remove(); // Remove even list items.\n$cat_flow.append($cat_list_clone); // Append the duplicate to the target div.\n"
},
{
"answer_id": 14593214,
"author": "bradleygriffith",
"author_id": 827441,
"author_profile": "https://Stackoverflow.com/users/827441",
"pm_score": 2,
"selected": false,
"text": "1. 4. 7. 10.\n2. 5. 8. 11.\n3. 6. 9. 12.\n $(document).ready(function(){\n Array.prototype.chunk = function(chunk_size){\n var array = this,\n new_array = [],\n chunk_size = chunk_size,\n i,\n length;\n\n for(i = 0, length = array.length; i < length; i += chunk_size){\n new_array.push(array.slice(i, i + chunk_size));\n }\n return new_array;\n }\n\n function buildColumns(list, row_limit) {\n var list_items = $(list).find('li').map(function(){return this;}).get(),\n row_limit = row_limit,\n columnized_list_items = list_items.chunk(row_limit);\n\n $(columnized_list_items).each(function(i){\n if (i != 0){\n var item_width = $(this).outerWidth(),\n item_height = $(this).outerHeight(),\n top_margin = -((item_height * row_limit) + (parseInt($(this).css('margin-top')) * row_limit)),\n left_margin = (item_width * i) + (parseInt($(this).css('margin-left')) * (i + 1));\n\n $(this[0]).css('margin-top', top_margin);\n $(this).css('margin-left', left_margin);\n }\n });\n }\n\n buildColumns('ul#some_list', 5);\n});\n"
},
{
"answer_id": 17410790,
"author": "Tim Vermaelen",
"author_id": 1114530,
"author_profile": "https://Stackoverflow.com/users/1114530",
"pm_score": 2,
"selected": false,
"text": "while splice slice // @param (list): a jquery ul object\n// @param (cols): amount of requested columns\nfunction multiColumn (list, cols) {\n var children = list.children(),\n target = list.parent(),\n liCount = children.length,\n newUl = $(\"<ul />\").addClass(list.prop(\"class\")),\n newItems,\n avg = Math.floor(liCount / cols),\n rest = liCount % cols,\n take,\n stack = [];\n\n while (cols--) {\n take = rest > cols ? (avg + 1) : avg;\n liCount -= take;\n\n newItems = children.splice(liCount, take);\n stack.push(newUl.clone().append(newItems));\n }\n\n target.append(stack.reverse());\n list.remove();\n}\n"
},
{
"answer_id": 32249448,
"author": "Ajay Gupta",
"author_id": 2663073,
"author_profile": "https://Stackoverflow.com/users/2663073",
"pm_score": 2,
"selected": false,
"text": "ul.col {\n width:50%;\n float:left;\n}\n\ndiv.clr {\n clear:both;\n}\n <ul class=\"col\">\n <li>Number 1</li>\n <li>Number 2</li>\n\n <li>Number 19</li>\n <li>Number 20</li>\n</ul>\n<ul class=\"col\">\n <li>Number 21</li>\n <li>Number 22</li>\n\n <li>Number 39</li>\n <li>Number 40</li>\n</ul>\n"
},
{
"answer_id": 32295899,
"author": "Danield",
"author_id": 703717,
"author_profile": "https://Stackoverflow.com/users/703717",
"pm_score": 2,
"selected": false,
"text": "flex-direction row column ol {\n display: flex;\n flex-flow: column wrap; /* flex-direction: column */\n height: 100px; /* need to specify height :-( */\n}\nol ~ ol {\n flex-flow: row wrap; /* flex-direction: row */\n max-height: auto; /* override max-height of the column direction */\n}\nli {\n width: 150px;\n}\na {\n display: inline-block;\n padding-right: 35px;\n} <p>items in column direction</p>\n<ol>\n <li><a href=\"#\">Aloe</a>\n </li>\n <li><a href=\"#\">Bergamot</a>\n </li>\n <li><a href=\"#\">Calendula</a>\n </li>\n <li><a href=\"#\">Damiana</a>\n </li>\n <li><a href=\"#\">Elderflower</a>\n </li>\n <li><a href=\"#\">Feverfew</a>\n </li>\n <li><a href=\"#\">Ginger</a>\n </li>\n <li><a href=\"#\">Hops</a>\n </li>\n <li><a href=\"#\">Iris</a>\n </li>\n <li><a href=\"#\">Juniper</a>\n </li>\n <li><a href=\"#\">Kava kava</a>\n </li>\n <li><a href=\"#\">Lavender</a>\n </li>\n <li><a href=\"#\">Marjoram</a>\n </li>\n <li><a href=\"#\">Nutmeg</a>\n </li>\n <li><a href=\"#\">Oregano</a>\n </li>\n <li><a href=\"#\">Pennyroyal</a>\n </li>\n</ol>\n<hr/>\n<p>items in row direction</p>\n<ol>\n <li><a href=\"#\">Aloe</a>\n </li>\n <li><a href=\"#\">Bergamot</a>\n </li>\n <li><a href=\"#\">Calendula</a>\n </li>\n <li><a href=\"#\">Damiana</a>\n </li>\n <li><a href=\"#\">Elderflower</a>\n </li>\n <li><a href=\"#\">Feverfew</a>\n </li>\n <li><a href=\"#\">Ginger</a>\n </li>\n <li><a href=\"#\">Hops</a>\n </li>\n <li><a href=\"#\">Iris</a>\n </li>\n <li><a href=\"#\">Juniper</a>\n </li>\n <li><a href=\"#\">Kava kava</a>\n </li>\n <li><a href=\"#\">Lavender</a>\n </li>\n <li><a href=\"#\">Marjoram</a>\n </li>\n <li><a href=\"#\">Nutmeg</a>\n </li>\n <li><a href=\"#\">Oregano</a>\n </li>\n <li><a href=\"#\">Pennyroyal</a>\n </li>\n</ol>"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/666/"
] |
4,954 | <p>I have worked for 5 years mainly in java desktop applications accessing Oracle databases and I have never used regular expressions. Now I enter Stack Overflow and I see a lot of questions about them; I feel like I missed something. </p>
<p>For what do you use regular expressions?</p>
<p>P.S. sorry for my bad english</p>
| [
{
"answer_id": 4959,
"author": "Matt MacLean",
"author_id": 22,
"author_profile": "https://Stackoverflow.com/users/22",
"pm_score": 0,
"selected": false,
"text": "*.txt .*\\.txt$"
},
{
"answer_id": 4962,
"author": "Teifion",
"author_id": 1384652,
"author_profile": "https://Stackoverflow.com/users/1384652",
"pm_score": 3,
"selected": false,
"text": "/(bb|[^b]{2})/i\n"
},
{
"answer_id": 4972,
"author": "Mike Stone",
"author_id": 122,
"author_profile": "https://Stackoverflow.com/users/122",
"pm_score": 4,
"selected": true,
"text": "puts \"Matched!\" unless /\\d{3}-\\d{4}/.match(\"555-1234\").nil?\nputs \"Didn't match!\" if /\\d{3}-\\d{4}/.match(\"Not phone number\").nil?\n match = /([^@]*)@(.*)/.match(\"[email protected]\")\nname = match[1]\ndomain = match[2]\n"
},
{
"answer_id": 25850,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 3,
"selected": false,
"text": "/^1?$|^(11+?)\\1+$/\n 1 1 def is_prime(n)\n str = \"1\" * n\n return str !~ /^1?$|^(11+?)\\1+$/ \nend\n"
},
{
"answer_id": 1437610,
"author": "Philippe Leybaert",
"author_id": 113570,
"author_profile": "https://Stackoverflow.com/users/113570",
"pm_score": 0,
"selected": false,
"text": "^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])[a-zA-Z0-9]{5,10}$\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/518/"
] |
4,973 | <p>I am trying to lay out a table-like page with two columns. I want the rightmost column to dock to the right of the page, and this column should have a distinct background color. The content in the right side is almost always going to be smaller than that on the left. I would like the div on the right to always be tall enough to reach the separator for the row below it. How can I make my background color fill that space?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.rightfloat {
color: red;
background-color: #BBBBBB;
float: right;
width: 200px;
}
.left {
font-size: 20pt;
}
.separator {
clear: both;
width: 100%;
border-top: 1px solid black;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="separator">
<div class="rightfloat">
Some really short content.
</div>
<div class="left">
Some really really really really really really
really really really really big content
</div>
</div>
<div class="separator">
<div class="rightfloat">
Some more short content.
</div>
<div class="left">
Some really really really really really really
really really really really big content
</div>
</div></code></pre>
</div>
</div>
</p>
<hr>
<p>Edit: I agree that this example is very table-like and an actual table would be a fine choice. But my "real" page will eventually be less table-like, and I'd just like to first master this task!</p>
<p>Also, for some reason, when I create/edit my posts in IE7, the code shows up correctly in the preview view, but when I actually post the message, the formatting gets removed. Editing my post in Firefox 2 seems to have worked, FWIW.</p>
<hr>
<p>Another edit: Yeah, I unaccepted GateKiller's answer. It does indeed work nicely on my simple page, but not in my actual heavier page. I'll investigate some of the links y'all have pointed me to.</p>
| [
{
"answer_id": 4979,
"author": "Teifion",
"author_id": 1384652,
"author_profile": "https://Stackoverflow.com/users/1384652",
"pm_score": 2,
"selected": false,
"text": "body\n -> header (big blue banner)\n -> headerNav (green bar at the top)\n -> breadcrumbs (invisible at the moment)\n -> page\n -> navigation (floats to the right)\n -> content (main content)\n -> clear (the quote at the bottom)\n -> footerNav (the green bar at the bottom)\n -> clear (empty but still does something)\n -> footer (blue thing at the bottom)\n"
},
{
"answer_id": 4983,
"author": "Adam Haile",
"author_id": 194,
"author_profile": "https://Stackoverflow.com/users/194",
"pm_score": 0,
"selected": false,
"text": "<html>\n <body>\n <style type=\"text/css\">\n .rightfloat {\n color: red;\n background-color: #BBBBBB;\n float: right;\n width: 200px;\n }\n\n .left {\n font-size: 20pt;\n }\n\n .separator {\n clear: both;\n width: 100%;\n border-top: 1px solid black;\n }\n </style>\n"
},
{
"answer_id": 5019,
"author": "GateKiller",
"author_id": 383,
"author_profile": "https://Stackoverflow.com/users/383",
"pm_score": 3,
"selected": false,
"text": "html, body,\n#left, #right {\n height: 100%\n}\n\n#left {\n float: left;\n width: 25%;\n}\n#right {\n width: 75%;\n} <html>\n <body>\n <div id=\"left\">\n Content\n </div>\n <div id=\"right\">\n Content\n </div>\n </body>\n</html>"
},
{
"answer_id": 5103,
"author": "Polsonby",
"author_id": 137,
"author_profile": "https://Stackoverflow.com/users/137",
"pm_score": 6,
"selected": true,
"text": "div"
},
{
"answer_id": 5617,
"author": "Ricky",
"author_id": 653,
"author_profile": "https://Stackoverflow.com/users/653",
"pm_score": 0,
"selected": false,
"text": "background-color <div/> <div class=\"separator\"/> repeat-y"
},
{
"answer_id": 1029876,
"author": "mxmissile",
"author_id": 9604,
"author_profile": "https://Stackoverflow.com/users/9604",
"pm_score": 3,
"selected": false,
"text": "var leftcol = $(\"#leftcolumn\");\nvar rightcol = $(\"#rightcolumn\");\nvar leftcol_height = leftcol.height();\nvar rightcol_height = rightcol.height();\n\nif (leftcol_height > rightcol_height)\n rightcol.height(leftcol_height);\nelse\n leftcol.height(rightcol_height);\n"
},
{
"answer_id": 1030017,
"author": "georgebrock",
"author_id": 5168,
"author_profile": "https://Stackoverflow.com/users/5168",
"pm_score": 3,
"selected": false,
"text": "display: table-* overflow: hidden zoom: 1 hasLayout <div id=\"foo\"></div> #foo html, body {\n height: 100%;\n}\n\n.row {\n zoom: 1; /* Clear internal floats in IE */\n overflow: hidden; /* Clear internal floats */\n}\n\n.right-column,\n.left-column {\n padding-bottom: 1000em; /* Balance the heights of the columns */\n margin-bottom: -1000em; /* */\n}\n\n.right-column {\n width: 20%;\n float: right;\n}\n\n.left-column {\n width: 79%;\n float: left;\n} <div class=\"row\">\n <div class=\"right-column\">Right column content</div>\n <div class=\"left-column\">Left column content</div>\n</div>\n<div class=\"row\">\n <div class=\"right-column\">Right column content</div>\n <div class=\"left-column\">Left column content</div>\n</div>"
},
{
"answer_id": 15599857,
"author": "user2194160",
"author_id": 2194160,
"author_profile": "https://Stackoverflow.com/users/2194160",
"pm_score": 0,
"selected": false,
"text": "width <style type=\"text/css\">;\n td {\n width:25%;\n height:100%;\n float:left;\n }\n</style>\n"
},
{
"answer_id": 18505213,
"author": "Palm Int Srv",
"author_id": 2086668,
"author_profile": "https://Stackoverflow.com/users/2086668",
"pm_score": 0,
"selected": false,
"text": "html body div html {\n height: 100%;\n}\n\nbody {\n height: 100%;\n}\ndiv {\n height: 100%; /* Set Div Height */\n} \n"
},
{
"answer_id": 44718603,
"author": "pragadeesh mahendran",
"author_id": 8203775,
"author_profile": "https://Stackoverflow.com/users/8203775",
"pm_score": 1,
"selected": false,
"text": "<link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css\">\n\n<div class=\"row\">\n <div class=\"col-md-6\">Content</div>\n <div class=\"col-md-6\">Content</div>\n</div>"
},
{
"answer_id": 56416085,
"author": "aspirew",
"author_id": 11590170,
"author_profile": "https://Stackoverflow.com/users/11590170",
"pm_score": 0,
"selected": false,
"text": ".rightfloat {\n color: red;\n background-color: #BBBBBB;\n float: right;\n width: 200px;\n}\n\n.left {\n font-size: 20pt;\n}\n\n.separator {\n clear: both;\n width: 100%;\n border-top: 1px solid black;\n} <div class=\"separator\">\n <div class=\"rightfloat\">\n Some really short content.\n </div>\n <div class=\"left\"> \n Some really really really really really really\n really really really really big content\n </div>\n</div>\n<div class=\"separator\">\n <div class=\"rightfloat\">\n Some more short content.\n </div>\n <div class=\"left\"> \n Some really really really really really really\n really really really really big content\n </div>\n</div>"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/404/"
] |
4,994 | <p>I am currently creating a master ddl for our database. Historically we have used backup/restore to version our database, and not maintained any ddl scripts. The schema is quite large.</p>
<p>My current thinking:</p>
<ul>
<li><p>Break script into parts (possibly in separate scripts):</p>
<ol>
<li>table creation</li>
<li>add indexes</li>
<li>add triggers</li>
<li>add constraints</li>
</ol></li>
<li><p>Each script would get called by the master script.</p></li>
<li>I might need a script to drop constraints temporarily for testing</li>
<li>There may be orphaned tables in the schema, I plan to identify suspect tables.</li>
</ul>
<p>Any other advice?</p>
<p>Edit: Also if anyone knows good tools to automate part of the process, we're using MS SQL 2000 (old, I know).</p>
| [
{
"answer_id": 5008,
"author": "Stu",
"author_id": 414,
"author_profile": "https://Stackoverflow.com/users/414",
"pm_score": 1,
"selected": false,
"text": "Select * From Information_Schema.Table_Constraints \n\nSelect * From Information_Schema.Referential_Constraints\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/4994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/92/"
] |
5,017 | <p>I have written an AIR Application that downloads videos and documents from a server. The videos play inside of the application, but I would like the user to be able to open the documents in their native applications.</p>
<p>I am looking for a way to prompt the user to Open / Save As on a local file stored in the Application Storage Directory. I have tried using the FileReference + URLRequest classes but this throws an exception that it needs a remote url.</p>
<p>My last resort is just copying the file to their desktop : \</p>
| [
{
"answer_id": 5266,
"author": "Shawn",
"author_id": 26,
"author_profile": "https://Stackoverflow.com/users/26",
"pm_score": 3,
"selected": true,
"text": "navigateToURL(new URLRequest(File.applicationStorageDirectory.nativePath + \"/courses/\" + fileName));\n"
},
{
"answer_id": 3233338,
"author": "Chris",
"author_id": 389993,
"author_profile": "https://Stackoverflow.com/users/389993",
"pm_score": 4,
"selected": false,
"text": "openWithDefaultApplication(); var file:File = File.desktopDirectory.resolvePath(fileLocation);\nfile.openWithDefaultApplication();\n"
},
{
"answer_id": 32225417,
"author": "1.21 gigawatts",
"author_id": 441016,
"author_profile": "https://Stackoverflow.com/users/441016",
"pm_score": 0,
"selected": false,
"text": "var request:URLRequest = new URLRequest();\nrequest.url = file.url;\nnavigateToURL(request, \"_blank\");\n navigateToURL(file.nativePath) navigateToURL()"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26/"
] |
5,071 | <p>I've played with CVS a little bit and am not the most familiar with all of its capabilities, but a huge annoyance for me is trying to add new directories that contain more directories in them. Running "<code>cvs add</code>" only adds the contents of the current directory, and using "<code>cvs import</code>" didn't look like the right thing either since it's still all code I'm producing (this howto claimed import is for <a href="http://www.thathost.com/wincvs-howto/cvsdoc/cvs_16.html#SEC136" rel="noreferrer">3rd party sources</a>)</p>
<p>Do you guys know any way to recursively add everything in a given directory to the current CVS project (or if SVN or git makes this notably easier)?</p>
| [
{
"answer_id": 5106,
"author": "Mark Harrison",
"author_id": 116,
"author_profile": "https://Stackoverflow.com/users/116",
"pm_score": 1,
"selected": false,
"text": "find . -type f | xargs cvs add\n"
},
{
"answer_id": 5262,
"author": "Mark Harrison",
"author_id": 116,
"author_profile": "https://Stackoverflow.com/users/116",
"pm_score": 5,
"selected": true,
"text": "find . -type f -print0| xargs -0 cvs add\n"
},
{
"answer_id": 5330,
"author": "Chris Bunch",
"author_id": 422,
"author_profile": "https://Stackoverflow.com/users/422",
"pm_score": 0,
"selected": false,
"text": "find . -type f -exec cvs add {} \\;\n"
},
{
"answer_id": 34893,
"author": "John Meagher",
"author_id": 3535,
"author_profile": "https://Stackoverflow.com/users/3535",
"pm_score": 1,
"selected": false,
"text": "find . -type d -print0| xargs -0 cvs add\n find . -type f -print0| xargs -0 cvs add\n"
},
{
"answer_id": 35344,
"author": "Alexander L. Belikoff",
"author_id": 3514,
"author_profile": "https://Stackoverflow.com/users/3514",
"pm_score": 2,
"selected": false,
"text": "cvs import"
},
{
"answer_id": 268246,
"author": "Oliver Giesen",
"author_id": 9784,
"author_profile": "https://Stackoverflow.com/users/9784",
"pm_score": 2,
"selected": false,
"text": "cvs add cvs add cvs import cvs import -nC -n -C"
},
{
"answer_id": 1979749,
"author": "doj",
"author_id": 240829,
"author_profile": "https://Stackoverflow.com/users/240829",
"pm_score": 1,
"selected": false,
"text": "/usr/bin/cvsadd chmod +x /usr/bin/cvsadd"
},
{
"answer_id": 3862101,
"author": "phoneynk",
"author_id": 466601,
"author_profile": "https://Stackoverflow.com/users/466601",
"pm_score": 3,
"selected": false,
"text": "find . -type d -print0| xargs -0 cvs add\n find . -type f | grep -v CVS | xargs cvs add\n"
},
{
"answer_id": 5158092,
"author": "Tom",
"author_id": 639814,
"author_profile": "https://Stackoverflow.com/users/639814",
"pm_score": 6,
"selected": false,
"text": "find . -type d \\! -name CVS -exec cvs add '{}' \\;\n find . \\( -type d -name CVS -prune \\) -o \\( -type f -exec cvs add '{}' \\; \\)\n"
},
{
"answer_id": 17720754,
"author": "borrel",
"author_id": 423777,
"author_profile": "https://Stackoverflow.com/users/423777",
"pm_score": 0,
"selected": false,
"text": "cvs status 2>/dev/null | awk '{if ($1==\"?\")system(\"cvs add \"$2)}'\n"
},
{
"answer_id": 24548144,
"author": "Broomerr",
"author_id": 2075608,
"author_profile": "https://Stackoverflow.com/users/2075608",
"pm_score": 1,
"selected": false,
"text": "cvs up -0 -print0 -zZ --no-run-if-empty CVS_PATTERN=/tmp/cvs_pattern\ncvs -z3 -q up | egrep '^\\?.*' | sed -e 's/^? //' > $CVS_PATTERN\nfind . -type d \\! -name CVS -print0 | grep -zZf $CVS_PATTERN | xargs -0 --no-run-if-empty cvs add\nfind . \\( -type d -name CVS -prune \\) -o \\( -type f -print0 \\) | grep -zZf $CVS_PATTERN | xargs -0 --no-run-if-empty cvs add\ncvs commit -m 'commiting tree recursively'\n cvs add: cannot add special file `.'; skipping\ncvs [add aborted]: there is a version in ./dirname1 already\n cvs add: `./dirname2/filename' already exists, with version number 1.1.1.1\n"
},
{
"answer_id": 24798342,
"author": "manufosela",
"author_id": 1833198,
"author_profile": "https://Stackoverflow.com/users/1833198",
"pm_score": 4,
"selected": false,
"text": "$> find . -type d \\! -name CVS -exec cvs add '{}' \\;"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/422/"
] |
5,075 | <p>Char's are great because they are fixed size and thus make for a faster table. They are however limited to 255 characters. I want to hold 500 characters but a blob is variable length and that's not what I want.</p>
<p>Is there some way to have a fixed length field of 500 characters in MySQL or am I going to have to use 2 char fields?</p>
| [
{
"answer_id": 44064,
"author": "Jeff Cuscutis",
"author_id": 2277,
"author_profile": "https://Stackoverflow.com/users/2277",
"pm_score": 0,
"selected": false,
"text": "VARCHAR(500)"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] |
5,078 | <p>I'd like to set up a cheap Linux box as a web server to host a variety of web technologies (PHP & Java EE come to mind, but I'd like to experiment with Ruby or Python in the future as well). </p>
<p>I'm fairly versed in setting up Tomcat to run on Linux for serving up Java EE applications, but I'd like to be able to open this server up, even just so I can create some tools I can use while I am working in the office. All the experience I've had with configuring Java EE sites has all been for intranet applications where we were told not to focus on securing the pages for external users. </p>
<p>What is your advice on setting up a personal Linux web server in a secure enough way to open it up for external traffic?</p>
| [
{
"answer_id": 5110,
"author": "saint_groceon",
"author_id": 59,
"author_profile": "https://Stackoverflow.com/users/59",
"pm_score": 1,
"selected": false,
"text": "su sudo"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/318/"
] |
5,102 | <p>I tried to follow a couple of googled up tutorials on setting up mod_python, but failed every time. Do you have a good, step-by step, rock-solid howto?</p>
<p>My dev box is OS X, production - Centos.</p>
| [
{
"answer_id": 5165,
"author": "Mark Harrison",
"author_id": 116,
"author_profile": "https://Stackoverflow.com/users/116",
"pm_score": 3,
"selected": false,
"text": "LoadModule python_module modules/mod_python.so\n\n<Directory \"/serverbase/htdocs/myapp\">\n AddHandler mod_python .py\n PythonHandler myapp\n PythonDebug On\n $ /serverbase/htdocs/myapp$ ls -l\ntotal 16\n-r-xr-xr-x 1 root sys 6484 May 21 15:54 myapp.py\n"
},
{
"answer_id": 14791003,
"author": "tsbertalan",
"author_id": 1224886,
"author_profile": "https://Stackoverflow.com/users/1224886",
"pm_score": 0,
"selected": false,
"text": "if __name__=='__main__' index() otherFunction() testScript/otherFunction testScript.py"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/556/"
] |
5,118 | <p>I'm working on a website that will switch to a new style on a set date. The site's built-in semantic HTML and CSS, so the change should just require a CSS reference change. I'm working with a designer who will need to be able to see how it's looking, as well as a client who will need to be able to review content updates in the current look as well as design progress on the new look.</p>
<p>I'm planning to use a magic querystring value and/or a javascript link in the footer which writes out a cookie to select the new CSS page. We're working in ASP.NET 3.5. Any recommendations?</p>
<p>I should mention that we're using IE Conditional Comments for IE8, 7, and 6 support. I may create a function that does a replacement:</p>
<pre><code><link href="Style/<% GetCssRoot() %>.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 8]>
<link type="text/css" href="Style/<% GetCssRoot() %>-ie8.css" rel="stylesheet" />
<![endif]-->
<!--[if lte IE 7]>
<link type="text/css" href="Style/<% GetCssRoot() %>-ie7.css" rel="stylesheet" />
<![endif]-->
<!--[if lte IE 6]>
<link type="text/css" href="Style/<% GetCssRoot() %>-ie6.css" rel="stylesheet" />
<![endif]-->
</code></pre>
| [
{
"answer_id": 5151,
"author": "palmsey",
"author_id": 521,
"author_profile": "https://Stackoverflow.com/users/521",
"pm_score": 2,
"selected": false,
"text": "if (!String.IsNullOrEmpty(Request.QueryString[\"css\"]))\n Session.Add(\"CSS\",Request.QueryString[\"css\"]);\n"
},
{
"answer_id": 5160,
"author": "Yaakov Ellis",
"author_id": 51,
"author_profile": "https://Stackoverflow.com/users/51",
"pm_score": 6,
"selected": true,
"text": "<head>\n <link id=\"linkStyles\" rel=\"stylesheet\" type=\"text/css\" runat=\"server\" />\n</head>\n protected void Page_Load(object sender, EventArgs e) {\n string stylesheetAddress = // logic to determine stylesheet\n linkStyles.Href = stylesheetAddress;\n}\n"
},
{
"answer_id": 5161,
"author": "Shawn",
"author_id": 26,
"author_profile": "https://Stackoverflow.com/users/26",
"pm_score": 3,
"selected": false,
"text": "ASP.NET"
},
{
"answer_id": 5162,
"author": "GateKiller",
"author_id": 383,
"author_profile": "https://Stackoverflow.com/users/383",
"pm_score": -1,
"selected": false,
"text": "if (Request.Querystring[\"stylesheet\"] != null) {\n Response.Cookies[\"stylesheet\"].Value = Request.QueryString[\"stylesheet\"];\n Response.Redirect(<Current Page>);\n}\n if (Request.Cookies[\"stylesheet\"] != null) {\n // New Stylesheet\n} else {\n // Default\n}\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5/"
] |
5,134 | <p>What is the best approach to write <strong>hooks</strong> for <strong>Subversion</strong> in <strong>Windows</strong>? As far as I know, only executable files can be used. So what is the best choice? </p>
<ul>
<li>Plain batch files (very limited but perhaps OK for very simple solutions)</li>
<li>Dedicated compiled executable applications (sledgehammer to crack a nutshell?)</li>
<li>Some other hybrid choice (like a batch file running a Powershell script)</li>
</ul>
| [
{
"answer_id": 1198468,
"author": "Troy Hunt",
"author_id": 73948,
"author_profile": "https://Stackoverflow.com/users/73948",
"pm_score": 4,
"selected": true,
"text": "public void Main(string[] args)\n{\n string repositories = args[0];\n string transaction = args[1];\n\n var processStartInfo = new ProcessStartInfo\n {\n FileName = \"svnlook.exe\",\n UseShellExecute = false,\n CreateNoWindow = true,\n RedirectStandardOutput = true,\n RedirectStandardError = true,\n Arguments = String.Format(\"log -t \\\"{0}\\\" \\\"{1}\\\"\", transaction, repositories)\n };\n\n var p = Process.Start(processStartInfo);\n var s = p.StandardOutput.ReadToEnd();\n p.WaitForExit();\n\n if (s == string.Empty)\n {\n Console.Error.WriteLine(\"Message must be provided\");\n Environment.Exit(1);\n }\n\n Environment.Exit(0);\n}\n [path]\\PreCommit.exe %1 %2\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/563/"
] |
5,142 | <p>I created a view on a machine using the <em>substring</em> function from Firebird, and it worked. When I copied the database to a different machine, the view was broken. This is the way I used it:</p>
<pre><code>SELECT SUBSTRING(field FROM 5 FOR 15) FROM table;
</code></pre>
<p>And this is the output on the machine that does not accept the function:</p>
<pre><code>token unknown: FROM
</code></pre>
<p>Both computers have this configuration:</p>
<ul>
<li><em>IB Expert</em> version 2.5.0.42 to run the queries and deal with the database.</li>
<li><em>Firebird</em> version 1.5 as server to database.</li>
<li><em>BDE Administration</em> version 5.01 installed, with <em>Interbase</em> 4.0 drivers.</li>
</ul>
<p>Any ideas about why it's behaving differently on these machines?</p>
| [
{
"answer_id": 5148,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 0,
"selected": false,
"text": "SELECT SUBSTRING(field FROM 5 FOR 15) AS x FROM table;\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/431/"
] |
5,179 | <p>ASP.NET server-side controls postback to their own page. This makes cases where you want to redirect a user to an external page, but need to post to that page for some reason (for authentication, for instance) a pain.</p>
<p>An <code>HttpWebRequest</code> works great if you don't want to redirect, and JavaScript is fine in some cases, but can get tricky if you really do need the server-side code to get the data together for the post.</p>
<p>So how do you both post to an external URL and redirect the user to the result from your ASP.NET codebehind code?</p>
| [
{
"answer_id": 5219,
"author": "saalon",
"author_id": 111,
"author_profile": "https://Stackoverflow.com/users/111",
"pm_score": 5,
"selected": true,
"text": "HttpContext.Current.Response.Write() <body onload=\"\"> public static void PassthroughAuthentication()\n{\n\n System.Web.HttpContext.Current.Response.Write(\"<body \n onload=document.forms[0].submit();window.location=\\\"Home.aspx\\\";>\");\n\n System.Web.HttpContext.Current.Response.Write(\"<form name=\\\"Form\\\" \n target=_blank method=post \n action=\\\"https://external-url.com/security.asp\\\">\");\n\n System.Web.HttpContext.Current.Response.Write(string.Format(\"<input \n type=hidden name=\\\"cFName\\\" value=\\\"{0}\\\">\", \"Username\"));\n\n System.Web.HttpContext.Current.Response.Write(\"</form>\");\n System.Web.HttpContext.Current.Response.Write(\"</body>\");\n}\n"
},
{
"answer_id": 18473342,
"author": "Jenn",
"author_id": 818004,
"author_profile": "https://Stackoverflow.com/users/818004",
"pm_score": 2,
"selected": false,
"text": "Private Sub ExternalRedirector(ByVal externalUrl As String)\n Dim clientRedirectName As String = \"ClientExternalRedirect\"\n Dim externalRedirectJS As New StringBuilder()\n\n If Not String.IsNullOrEmpty(externalUrl) Then\n If Not Page.ClientScript.IsStartupScriptRegistered(clientRedirectName) Then\n externalRedirectJS.Append(\"function CheckWindow() {\")\n externalRedirectJS.Append(\" if (window.top != window) {\")\n externalRedirectJS.Append(\" window.top.location = '\")\n externalRedirectJS.Append(externalUrl)\n externalRedirectJS.Append(\"';\")\n externalRedirectJS.Append(\" return false;\")\n externalRedirectJS.Append(\" }\")\n externalRedirectJS.Append(\" else {\")\n externalRedirectJS.Append(\" window.location = '\")\n externalRedirectJS.Append(externalUrl)\n externalRedirectJS.Append(\"';\")\n externalRedirectJS.Append(\" }\")\n externalRedirectJS.Append(\"}\")\n externalRedirectJS.Append(\"CheckWindow();\")\n\n Page.ClientScript.RegisterStartupScript(Page.GetType(), clientRedirectName, externalRedirectJS.ToString(), True)\n End If\n End If\nEnd Sub\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/111/"
] |
5,194 | <p>I am prototyping some C# 3 collection filters and came across this.
I have a collection of products:</p>
<pre><code>public class MyProduct
{
public string Name { get; set; }
public Double Price { get; set; }
public string Description { get; set; }
}
var MyProducts = new List<MyProduct>
{
new MyProduct
{
Name = "Surfboard",
Price = 144.99,
Description = "Most important thing you will ever own."
},
new MyProduct
{
Name = "Leash",
Price = 29.28,
Description = "Keep important things close to you."
}
,
new MyProduct
{
Name = "Sun Screen",
Price = 15.88,
Description = "1000 SPF! Who Could ask for more?"
}
};
</code></pre>
<p>Now if I use LINQ to filter it works as expected:</p>
<pre><code>var d = (from mp in MyProducts
where mp.Price < 50d
select mp);
</code></pre>
<p>And if I use the Where extension method combined with a Lambda the filter works as well:</p>
<pre><code>var f = MyProducts.Where(mp => mp.Price < 50d).ToList();
</code></pre>
<p><strong>Question:</strong> What is the difference, and why use one over the other?</p>
| [
{
"answer_id": 7741,
"author": "Keith",
"author_id": 905,
"author_profile": "https://Stackoverflow.com/users/905",
"pm_score": 2,
"selected": false,
"text": "IEnumerable<MyProduct> List<MyProduct> var d = \n from mp in MyProducts\n where mp.Price < 50d\n select mp;\n var d = \n MyProducts.\n Where<MyProduct>( mp => mp.Price < 50d ).\n Select<MyProduct>( mp => mp ); \n //note that this last select is optimised out if it makes no change\n .Method().Method.Method()"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/439/"
] |
5,222 | <p>What is the Java equivalent of PHP's <code>$_POST</code>? After searching the web for an hour, I'm still nowhere closer.</p>
| [
{
"answer_id": 5224,
"author": "Ryan Ahearn",
"author_id": 75,
"author_profile": "https://Stackoverflow.com/users/75",
"pm_score": 7,
"selected": true,
"text": "HttpServletRequest getParameter(String paramName)"
},
{
"answer_id": 11042,
"author": "ScArcher2",
"author_id": 1310,
"author_profile": "https://Stackoverflow.com/users/1310",
"pm_score": 6,
"selected": false,
"text": "<html>\n<body>\n<form method=\"post\" action=\"/myServlet\">\n<input type=\"text\" name=\"username\" />\n<input type=\"password\" name=\"password\" />\n<input type=\"submit\" />\n</form>\n</body>\n</html>\n import java.io.*;\nimport javax.servlet.*;\nimport javax.servlet.http.*;\n\npublic class MyServlet extends HttpServlet {\n public void doPost(HttpServletRequest request,\n HttpServletResponse response)\n throws ServletException, IOException {\n\n String userName = request.getParameter(\"username\");\n String password = request.getParameter(\"password\");\n ....\n ....\n }\n}\n"
},
{
"answer_id": 40784913,
"author": "hgc2002",
"author_id": 1460240,
"author_profile": "https://Stackoverflow.com/users/1460240",
"pm_score": 2,
"selected": false,
"text": "\n <input type=\"text\" id=\"username\" /> <!-- won't work -->\n <input type=\"text\" name=\"username\" /> <!-- will work -->\n <input type=\"text\" name=\"username\" id=\"username\" /> <!-- will work too -->\n"
},
{
"answer_id": 49922035,
"author": "Siddappa Walake",
"author_id": 6188955,
"author_profile": "https://Stackoverflow.com/users/6188955",
"pm_score": 1,
"selected": false,
"text": "Map params = servReq.getParameterMap();\n String userId=servReq.getParameter(\"user_id\");\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/429/"
] |
5,223 | <p>I have a JavaScript object. Is there a built-in or accepted best practice way to get the length of this object?</p>
<pre><code>const myObject = new Object();
myObject["firstname"] = "Gareth";
myObject["lastname"] = "Simpson";
myObject["age"] = 21;
</code></pre>
| [
{
"answer_id": 5232,
"author": "jj33",
"author_id": 430,
"author_profile": "https://Stackoverflow.com/users/430",
"pm_score": 5,
"selected": false,
"text": "var element_count = 0;\nfor (e in myArray) { if (myArray.hasOwnProperty(e)) element_count++; }\n"
},
{
"answer_id": 6280,
"author": "doekman",
"author_id": 56,
"author_profile": "https://Stackoverflow.com/users/56",
"pm_score": 5,
"selected": false,
"text": "var element_count = 0;\nfor(var e in myArray)\n if(myArray.hasOwnProperty(e))\n element_count++;\n"
},
{
"answer_id": 6444,
"author": "Polsonby",
"author_id": 137,
"author_profile": "https://Stackoverflow.com/users/137",
"pm_score": 4,
"selected": false,
"text": "<script type=\"text/javascript\">\nObject.prototype.size = function () {\n var len = this.length ? --this.length : -1;\n for (var k in this)\n len++;\n return len;\n}\nObject.prototype.size2 = function () {\n var len = this.length ? --this.length : -1;\n for (var k in this)\n len++;\n return len;\n}\nvar myArray = new Object();\nmyArray[\"firstname\"] = \"Gareth\";\nmyArray[\"lastname\"] = \"Simpson\";\nmyArray[\"age\"] = 21;\nalert(\"age is \" + myArray[\"age\"]);\nalert(\"length is \" + myArray.size());\n</script>\n"
},
{
"answer_id": 6700,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 13,
"selected": true,
"text": "Object.keys() var size = Object.keys(myObj).length;\n Object.keys() Object.keys Object.getOwnPropertyNames Object.getOwnPropertySymbols var person = {\n [Symbol('name')]: 'John Doe',\n [Symbol('age')]: 33,\n \"occupation\": \"Programmer\"\n};\n\nconst propOwn = Object.getOwnPropertyNames(person);\nconsole.log(propOwn.length); // 1\n\nlet propSymb = Object.getOwnPropertySymbols(person);\nconsole.log(propSymb.length); // 2 Object.size = function(obj) {\n var size = 0,\n key;\n for (key in obj) {\n if (obj.hasOwnProperty(key)) size++;\n }\n return size;\n};\n\n// Get the size of an object\nconst myObj = {}\nvar size = Object.size(myObj);"
},
{
"answer_id": 5527037,
"author": "aeosynth",
"author_id": 131023,
"author_profile": "https://Stackoverflow.com/users/131023",
"pm_score": 11,
"selected": false,
"text": "hasOwnProperty Object.keys(myArray).length\n"
},
{
"answer_id": 6316862,
"author": "DanMan",
"author_id": 428241,
"author_profile": "https://Stackoverflow.com/users/428241",
"pm_score": 5,
"selected": false,
"text": "function Hash(){\n var length=0;\n this.add = function(key, val){\n if(this[key] == undefined)\n {\n length++;\n }\n this[key]=val;\n }; \n this.length = function(){\n return length;\n };\n}\n\nmyArray = new Hash();\nmyArray.add(\"lastname\", \"Simpson\");\nmyArray.add(\"age\", 21);\nalert(myArray.length()); // will alert 2\n"
},
{
"answer_id": 7177140,
"author": "Jerry",
"author_id": 909828,
"author_profile": "https://Stackoverflow.com/users/909828",
"pm_score": 4,
"selected": false,
"text": "function keyValuePairs() {\n this.length = 0;\n function add(key, value) { this[key] = value; this.length++; }\n function remove(key) { if (this.hasOwnProperty(key)) { delete this[key]; this.length--; }}\n}\n"
},
{
"answer_id": 8186938,
"author": "wade harrell",
"author_id": 1054363,
"author_profile": "https://Stackoverflow.com/users/1054363",
"pm_score": 3,
"selected": false,
"text": "var objLength = function(obj){ \n var key,len=0;\n for(key in obj){\n len += Number( obj.hasOwnProperty(key) );\n }\n return len;\n};\n"
},
{
"answer_id": 11346637,
"author": "ripper234",
"author_id": 11236,
"author_profile": "https://Stackoverflow.com/users/11236",
"pm_score": 8,
"selected": false,
"text": "_.size({one : 1, two : 2, three : 3});\n=> 3\n $.assocArraySize = function(obj) {\n // http://stackoverflow.com/a/6700/11236\n var size = 0, key;\n for (key in obj) {\n if (obj.hasOwnProperty(key)) size++;\n }\n return size;\n};\n"
},
{
"answer_id": 15207568,
"author": "Eric Anderson",
"author_id": 120067,
"author_profile": "https://Stackoverflow.com/users/120067",
"pm_score": 2,
"selected": false,
"text": "Object.size = (obj) ->\n size = 0\n size++ for own key of obj\n size\n"
},
{
"answer_id": 17332295,
"author": "Sherzod",
"author_id": 928001,
"author_profile": "https://Stackoverflow.com/users/928001",
"pm_score": 3,
"selected": false,
"text": "Object.prototype.size = function () {\n var size = 0,\n key;\n for (key in this) {\n if (this.hasOwnProperty(key)) size++;\n }\n return size;\n};\n\nvar x = {\n one: 1,\n two: 2,\n three: 3\n};\n\nx.size() === 3;\n"
},
{
"answer_id": 18012581,
"author": "Ally",
"author_id": 837649,
"author_profile": "https://Stackoverflow.com/users/837649",
"pm_score": 5,
"selected": false,
"text": "/**\n * @constructor\n */\nAssociativeArray = function () {};\n\n// Make the length property work\nObject.defineProperty(AssociativeArray.prototype, \"length\", {\n get: function () {\n var count = 0;\n for (var key in this) {\n if (this.hasOwnProperty(key))\n count++;\n }\n return count;\n }\n});\n var a1 = new AssociativeArray();\na1[\"prop1\"] = \"test\";\na1[\"prop2\"] = 1234;\na1[\"prop3\"] = \"something else\";\nalert(\"Length of array is \" + a1.length);\n"
},
{
"answer_id": 18560314,
"author": "Joon",
"author_id": 692528,
"author_profile": "https://Stackoverflow.com/users/692528",
"pm_score": 6,
"selected": false,
"text": "if (!Object.keys) {\n Object.keys = function (obj) {\n var arr = [],\n key;\n for (key in obj) {\n if (obj.hasOwnProperty(key)) {\n arr.push(key);\n }\n }\n return arr;\n };\n}\n\nObject.keys(obj).length;\n"
},
{
"answer_id": 23571866,
"author": "Ron Sims II",
"author_id": 1341417,
"author_profile": "https://Stackoverflow.com/users/1341417",
"pm_score": 2,
"selected": false,
"text": "function uberject(obj){\n this._count = 0;\n for(var param in obj){\n this[param] = obj[param];\n this._count++;\n }\n}\n\nuberject.prototype.getLength = function(){\n return this._count;\n};\n\nvar foo = new uberject({bar:123,baz:456});\nalert(foo.getLength());\n"
},
{
"answer_id": 24510557,
"author": "venkat7668",
"author_id": 2165104,
"author_profile": "https://Stackoverflow.com/users/2165104",
"pm_score": 5,
"selected": false,
"text": "Object.getOwnPropertyNames({\"hi\":\"Hi\",\"msg\":\"Message\"}).length; // => 2\n"
},
{
"answer_id": 27805509,
"author": "Eduardo Cuomo",
"author_id": 717267,
"author_profile": "https://Stackoverflow.com/users/717267",
"pm_score": 2,
"selected": false,
"text": "Object.defineProperty(Object.prototype, 'length', {\n get: function () {\n var size = 0, key;\n for (key in this)\n if (this.hasOwnProperty(key))\n size++;\n return size;\n }\n});\n var o = {a: 1, b: 2, c: 3};\nalert(o.length); // <-- 3\no['foo'] = 123;\nalert(o.length); // <-- 4\n"
},
{
"answer_id": 29579046,
"author": "stylesenberg",
"author_id": 4132915,
"author_profile": "https://Stackoverflow.com/users/4132915",
"pm_score": 1,
"selected": false,
"text": " var myObject = {}; // ... your object goes here.\n\n var length = 0;\n\n for (var property in myObject) {\n if (myObject.hasOwnProperty(property)){\n length += 1;\n }\n };\n\n console.log(length); // logs 0 in my example.\n"
},
{
"answer_id": 32593870,
"author": "pcnate",
"author_id": 3851647,
"author_profile": "https://Stackoverflow.com/users/3851647",
"pm_score": 4,
"selected": false,
"text": "// Count the elements in an object\napp.filter('lengthOfObject', function() {\n return function( obj ) {\n var size = 0, key;\n for (key in obj) {\n if (obj.hasOwnProperty(key)) size++;\n }\n return size;\n }\n})\n $scope.filterResult = $filter('lengthOfObject')($scope.object)\n <any ng-expression=\"object | lengthOfObject\"></any>\n"
},
{
"answer_id": 34734220,
"author": "Pian0_M4n",
"author_id": 2156913,
"author_profile": "https://Stackoverflow.com/users/2156913",
"pm_score": 3,
"selected": false,
"text": "Object.getOwnPropertyNames(myObject).length [].length"
},
{
"answer_id": 35844733,
"author": "John Slegers",
"author_id": 1946501,
"author_profile": "https://Stackoverflow.com/users/1946501",
"pm_score": 3,
"selected": false,
"text": "Object.keys() Object.getOwnPropertyNames() .length function size(obj, enumerablesOnly) {\n return enumerablesOnly === false ?\n Object.getOwnPropertyNames(obj).length :\n Object.keys(obj).length;\n}\n var myObj = Object.create({}, {\n getFoo: {},\n setFoo: {}\n});\nmyObj.Foo = 12;\n\nvar myArr = [1,2,5,4,8,15];\n\nconsole.log(size(myObj)); // Output : 1\nconsole.log(size(myObj, true)); // Output : 1\nconsole.log(size(myObj, false)); // Output : 3\nconsole.log(size(myArr)); // Output : 6\nconsole.log(size(myArr, true)); // Output : 6\nconsole.log(size(myArr, false)); // Output : 7\n"
},
{
"answer_id": 37307278,
"author": "Oriol",
"author_id": 1529630,
"author_profile": "https://Stackoverflow.com/users/1529630",
"pm_score": 4,
"selected": false,
"text": "const myMap = new Map();\n\nmyMap.set(\"firstname\", \"Gareth\");\nmyMap.set(\"lastname\", \"Simpson\");\nmyMap.set(\"age\", 21);\n\nconsole.log(myMap.size); // 3"
},
{
"answer_id": 37537045,
"author": "Mahendra Kulkarni",
"author_id": 6011619,
"author_profile": "https://Stackoverflow.com/users/6011619",
"pm_score": 4,
"selected": false,
"text": "var myArray = new Object();\nmyArray[\"firstname\"] = \"Gareth\";\nmyArray[\"lastname\"] = \"Simpson\";\nmyArray[\"age\"] = 21;\nobj = Object.keys(myArray).length;\nconsole.log(obj)"
},
{
"answer_id": 38816218,
"author": "christian Nguyen",
"author_id": 4225143,
"author_profile": "https://Stackoverflow.com/users/4225143",
"pm_score": 0,
"selected": false,
"text": "var getTotal = function(collection) {\n\n var length = collection['length'];\n var isArrayObject = typeof length == 'number' && length >= 0 && length <= Math.pow(2,53) - 1; // Number.MAX_SAFE_INTEGER\n\n if(isArrayObject) {\n return collection['length'];\n }\n\n i= 0;\n for(var key in collection) {\n if (collection.hasOwnProperty(key)) {\n i++;\n }\n }\n\n return i;\n};\n // case 1\nvar a = new Object();\na[\"firstname\"] = \"Gareth\";\na[\"lastname\"] = \"Simpson\";\na[\"age\"] = 21;\n\n//case 2\nvar b = [1,2,3];\n\n// case 3\nvar c = {};\nc[0] = 1;\nc.two = 2;\n getLength(a); // 3\ngetLength(b); // 3\ngetLength(c); // 2\n"
},
{
"answer_id": 39542137,
"author": "Mystical",
"author_id": 6368005,
"author_profile": "https://Stackoverflow.com/users/6368005",
"pm_score": 3,
"selected": false,
"text": "Object.keys(obj).length function objLength(obj)\n{\n return Object.keys(obj).length;\n}\n\nconsole.log(objLength({a:1, b:\"summit\", c:\"nonsense\"}));\n\n// Works perfectly fine\nvar obj = new Object();\nobj['fish'] = 30;\nobj['nullified content'] = null;\nconsole.log(objLength(obj));\n\n// It also works your way, which is creating it using the Object constructor\nObject.prototype.getLength = function() {\n return Object.keys(this).length;\n}\nconsole.log(obj.getLength());\n\n// You can also write it as a method, which is more efficient as done so above\n\nObject.defineProperty(Object.prototype, \"length\", {get:function(){\n return Object.keys(this).length;\n}});\nconsole.log(obj.length);\n\n// probably the most effictive approach is done so and demonstrated above which sets a getter property called \"length\" for objects which returns the equivalent value of getLength(this) or this.getLength()"
},
{
"answer_id": 44114476,
"author": "solanki...",
"author_id": 6390817,
"author_profile": "https://Stackoverflow.com/users/6390817",
"pm_score": 5,
"selected": false,
"text": "const myObject = {};\nconsole.log(Object.values(myObject).length);"
},
{
"answer_id": 44909574,
"author": "MacroMan",
"author_id": 1171032,
"author_profile": "https://Stackoverflow.com/users/1171032",
"pm_score": 2,
"selected": false,
"text": "Object.defineProperty(Object.prototype, \"length\", {\n get: function () {\n return Object.keys(this).length;\n }\n});\n var myObj = { 'key': 'value' };\nmyObj.length;\n 1"
},
{
"answer_id": 48319070,
"author": "saurabhgoyal795",
"author_id": 7539786,
"author_profile": "https://Stackoverflow.com/users/7539786",
"pm_score": 5,
"selected": false,
"text": "length Object.keys(myObject).length\n"
},
{
"answer_id": 49683151,
"author": "tdjprog",
"author_id": 4935426,
"author_profile": "https://Stackoverflow.com/users/4935426",
"pm_score": 4,
"selected": false,
"text": "var myObject = new Object();\nmyObject[\"firstname\"] = \"Gareth\";\nmyObject[\"lastname\"] = \"Simpson\";\nmyObject[\"age\"] = 21;\n"
},
{
"answer_id": 49730723,
"author": "njmwas",
"author_id": 2529302,
"author_profile": "https://Stackoverflow.com/users/2529302",
"pm_score": -1,
"selected": false,
"text": "var myObject = new Object();\nmyObject[\"firstname\"] = \"Gareth\";\nmyObject[\"lastname\"] = \"Simpson\";\nmyObject[\"age\"] = 21;\n\nvar size = JSON.stringify(myObject).length;\n\ndocument.write(size); JSON.stringify(myObject)"
},
{
"answer_id": 50608738,
"author": "Mithu A Quayium",
"author_id": 2079914,
"author_profile": "https://Stackoverflow.com/users/2079914",
"pm_score": 4,
"selected": false,
"text": "Object.keys(myobject).length\n"
},
{
"answer_id": 50713932,
"author": "PythonProgrammi",
"author_id": 6464947,
"author_profile": "https://Stackoverflow.com/users/6464947",
"pm_score": 4,
"selected": false,
"text": "<script>\nmyObj = {\"key1\" : \"Hello\", \"key2\" : \"Goodbye\"};\nvar size = Object.keys(myObj).length;\nconsole.log(size);\n</script>\n\n<p id=\"myObj\">The number of <b>keys</b> in <b>myObj</b> are: <script>document.write(size)</script></p> var size = Object.keys(myObj).length;\n"
},
{
"answer_id": 54662407,
"author": "Kamil Kiełczewski",
"author_id": 860099,
"author_profile": "https://Stackoverflow.com/users/860099",
"pm_score": 0,
"selected": false,
"text": "Object.keys for-in var objLength = (o,i=0) => { for(p in o) i++; return i }\n var myObject = new Object();\nmyObject[\"firstname\"] = \"Gareth\";\nmyObject[\"lastname\"] = \"Simpson\";\nmyObject[\"age\"] = 21;\n\nvar child = Object.create(myObject);\nchild[\"sex\"] = \"male\";\n\nvar objLength = (o,i=0) => { for(p in o) i++; return i }\n\nconsole.log(\"Object.keys(myObject):\", Object.keys(myObject).length, \"(OK)\");\nconsole.log(\"Object.keys(child) :\", Object.keys(child).length, \"(wrong)\");\nconsole.log(\"objLength(child) :\", objLength(child), \"(OK)\");"
},
{
"answer_id": 57525980,
"author": "Paul",
"author_id": 5939653,
"author_profile": "https://Stackoverflow.com/users/5939653",
"pm_score": -1,
"selected": false,
"text": "websocket.on('message', data => {\n dataPerSecond += JSON.stringify(data).length;\n}\n"
},
{
"answer_id": 57839252,
"author": "shaheb",
"author_id": 2786194,
"author_profile": "https://Stackoverflow.com/users/2786194",
"pm_score": 4,
"selected": false,
"text": "Object.keys(myObject).length var myObject = new Object();\nmyObject[\"firstname\"] = \"Gareth\";\nmyObject[\"lastname\"] = \"Simpson\";\nmyObject[\"age\"] = 21;\n\nconsole.log(Object.keys(myObject).length); //3"
},
{
"answer_id": 59694573,
"author": "Soura Ghosh",
"author_id": 9229338,
"author_profile": "https://Stackoverflow.com/users/9229338",
"pm_score": 3,
"selected": false,
"text": "const myObject = new Object();\nmyObject[\"firstname\"] = \"Gareth\";\nmyObject[\"lastname\"] = \"Simpson\";\nmyObject[\"age\"] = 21;\n\nconsole.log(Object.keys(myObject).length)\n\n// o/p 3\n"
},
{
"answer_id": 60540719,
"author": "Sheelpriy",
"author_id": 2542562,
"author_profile": "https://Stackoverflow.com/users/2542562",
"pm_score": 2,
"selected": false,
"text": "Reflect.ownKeys(targetObject).length\n Reflect.ownKeys(target)\n function Person(name, age){\n this.name = name;\n this.age = age;\n}\n\nPerson.prototype.getIntro= function() {\n return `${this.name} is ${this.age} years old!!`\n}\n\nlet student = new Person('Anuj', 11);\n\nconsole.log(Reflect.ownKeys(student).length) // 2\nconsole.log(student.getIntro()) // Anuj is 11 years old!!\n"
},
{
"answer_id": 64231717,
"author": "Shashwat Gupta",
"author_id": 7765900,
"author_profile": "https://Stackoverflow.com/users/7765900",
"pm_score": 2,
"selected": false,
"text": "console.log(Object.values({id:\"1\",age:23,role_number:90}).length);"
},
{
"answer_id": 67136236,
"author": "Rashed Rahat",
"author_id": 10427807,
"author_profile": "https://Stackoverflow.com/users/10427807",
"pm_score": 2,
"selected": false,
"text": "Object.values(theObject).length const myObject = new Object();\nmyObject[\"firstname\"] = \"Gareth\";\nmyObject[\"lastname\"] = \"Simpson\";\nmyObject[\"age\"] = 21;\nconsole.log(Object.values(myObject).length);"
},
{
"answer_id": 69669301,
"author": "Coni",
"author_id": 16932102,
"author_profile": "https://Stackoverflow.com/users/16932102",
"pm_score": -1,
"selected": false,
"text": " vendor = {1: \"\", 2: \"\"}\n const keysArray = Object.keys(vendor)\n const objectLength = keysArray.length\n console.log(objectLength)\n Result 2\n"
},
{
"answer_id": 70413307,
"author": "dazzafact",
"author_id": 1163485,
"author_profile": "https://Stackoverflow.com/users/1163485",
"pm_score": 1,
"selected": false,
"text": "function length2(obj){\n if (typeof obj==='object' && obj!== null){return Object.keys(obj).length;}\n //if (Array.isArray){return obj.length;}\n return obj.length;\n\n}\n"
},
{
"answer_id": 71957503,
"author": "Ran Turner",
"author_id": 7494218,
"author_profile": "https://Stackoverflow.com/users/7494218",
"pm_score": 3,
"selected": false,
"text": "Object.entries const objectLength = obj => Object.entries(obj).length;\n\nconst person = {\n id: 1,\n name: 'John',\n age: 30\n}\n \nconst car = {\n type: 2,\n color: 'red',\n}\n\nconsole.log(objectLength(person)); // 3\nconsole.log(objectLength(car)); // 2"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/147/"
] |
5,226 | <p>I am currently in the process of creating my own blog and I have got to marking up the comments, but what is the best way to mark it up?</p>
<p>The information I need to present is:</p>
<ol>
<li>Persons Name</li>
<li>Gravatar Icon</li>
<li>Comment Date</li>
<li>The Comment</li>
</ol>
<p><em>PS: I'm only interested in semantic HTML markup.</em></p>
| [
{
"answer_id": 5235,
"author": "Rich Reuter",
"author_id": 283,
"author_profile": "https://Stackoverflow.com/users/283",
"pm_score": 2,
"selected": false,
"text": ".comment {\n width: 400px;\n}\n\n.comment_img {\n float: left;\n}\n\n.comment_text,\n.comment_meta {\n margin-left: 40px;\n}\n\n.comment_meta {\n clear: both;\n} <div class='comment' id='comment_(comment id #)'>\n <div class='comment_img'>\n <img src='https://placehold.it/100' alt='(Commenter Name)' />\n </div>\n <div class='comment_text'>\n <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed mauris. Morbi quis tellus sit amet eros ullamcorper ultrices. Proin a tortor. Praesent et odio. Duis mi odio, consequat ut, euismod sed, commodo vitae, nulla. Suspendisse potenti. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Etiam pede.</p>\n <p>Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas rhoncus accumsan velit. Donec varius magna a est. </p>\n </div>\n <p class='comment_meta'>\n By <a href='#'>Name</a> on <span class='comment_date'>2008-08-21 11:32 AM</span>\n </p>\n</div>"
},
{
"answer_id": 5248,
"author": "Rich Reuter",
"author_id": 283,
"author_profile": "https://Stackoverflow.com/users/283",
"pm_score": 1,
"selected": false,
"text": "<dl>\n <dt>By [Name] at 2008-01-01<dt>\n <dd><img src='...' alt=''/></dd>\n <dd><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed mauris. Morbi quis tellus sit amet eros ullamcorper ultrices. Proin a tortor. Praesent et odio. Duis mi odio, consequat ut, euismod sed, commodo vitae, nulla. Suspendisse potenti. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Etiam pede.</p>\n\n <p>Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas rhoncus accumsan velit. Donec varius magna a est. </p>\n </dd>\n</dl>\n"
},
{
"answer_id": 5256,
"author": "GateKiller",
"author_id": 383,
"author_profile": "https://Stackoverflow.com/users/383",
"pm_score": 2,
"selected": false,
"text": "<ol class=\"comments\">\n <li>\n <a href=\"\">\n <img src=\"\" alt=\"\" />\n </a>\n <cite>Name<br />Date</cite>\n <blockquote>Comment</blockquote>\n </li>\n</ol>\n"
},
{
"answer_id": 5392,
"author": "helloandre",
"author_id": 50,
"author_profile": "https://Stackoverflow.com/users/50",
"pm_score": 1,
"selected": false,
"text": "<blockquote \n cite=\"http://yoursite/comments/feederscript.php?id=commentid\" \n title=\"<?php echo Name . \" - \" . Date ?>\" >\n <?php echo Comment ?>\n</blockquote>\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383/"
] |
5,260 | <p>I have a situation where I want to add hours to a date and have the new date wrap around the work-day. I cobbled up a function to determine this new date, but want to make sure that I'm not forgetting anything.</p>
<p>The hours to be added is called "delay". It could easily be a parameter to the function instead.</p>
<p>Please post any suggestions. [VB.NET Warning]</p>
<pre><code>Private Function GetDateRequired() As Date
''// A decimal representation of the current hour
Dim hours As Decimal = Decimal.Parse(Date.Now.Hour) + (Decimal.Parse(Date.Now.Minute) / 60.0)
Dim delay As Decimal = 3.0 ''// delay in hours
Dim endOfDay As Decimal = 12.0 + 5.0 ''// end of day, in hours
Dim startOfDay As Decimal = 8.0 ''// start of day, in hours
Dim newHour As Integer
Dim newMinute As Integer
Dim dateRequired As Date = Now
Dim delta As Decimal = hours + delay
''// Wrap around to the next day, if necessary
If delta > endOfDay Then
delta = delta - endOfDay
dateRequired = dateRequired.AddDays(1)
newHour = Integer.Parse(Decimal.Truncate(delta))
newMinute = Integer.Parse(Decimal.Truncate((delta - newHour) * 60))
newHour = startOfDay + newHour
Else
newHour = Integer.Parse(Decimal.Truncate(delta))
newMinute = Integer.Parse(Decimal.Truncate((delta - newHour) * 60))
End If
dateRequired = New Date(dateRequired.Year, dateRequired.Month, dateRequired.Day, newHour, newMinute, 0)
Return dateRequired
End Sub
</code></pre>
<p><strong>Note</strong>: This will probably not work if delay is more than 9 hours long. It should never change from 3, through.</p>
<p>EDIT:
The goal is find the date and time that you get as a result of adding several hours to the current time. This is used to determine a default value for a due date of a submission. I want to add 3 hours to the current time to get the due date time. However, I don't want due dates that go beyond 5pm on the current day. So, I tried to have the hours split between (today, up to 5pm) and (tomorrow, from 8am on), such that adding 3 hours to 4pm would give you 19am, because 1 hour is added to the end of today and 2 hours are added to the beginning of tomorrow.</p>
| [
{
"answer_id": 5334,
"author": "Stu",
"author_id": 414,
"author_profile": "https://Stackoverflow.com/users/414",
"pm_score": 2,
"selected": false,
"text": "Module Module1\n\n Public Function IsInBusinessHours(ByVal d As Date) As Boolean\n Return Not (d.Hour < 8 OrElse d.Hour > 17 OrElse d.DayOfWeek = DayOfWeek.Saturday OrElse d.DayOfWeek = DayOfWeek.Sunday)\n End Function\n\n\n Public Function AddInBusinessHours(ByVal fromDate As Date, ByVal hours As Integer) As Date\n Dim work As Date = fromDate.AddHours(hours)\n While Not IsInBusinessHours(work)\n work = work.AddHours(1)\n End While\n Return work\n End Function\n\n\n Public Function LoopInBusinessHours(ByVal fromDate As Date, ByVal hours As Integer) As Date\n Dim work As Date = fromDate\n While hours > 0\n While hours > 0 AndAlso IsInBusinessHours(work)\n work = work.AddHours(1)\n hours -= 1\n End While\n While Not IsInBusinessHours(work)\n work = work.AddHours(1)\n End While\n End While\n Return work\n End Function\n\n Sub Main()\n Dim test As Date = New Date(2008, 8, 8, 15, 0, 0)\n Dim hours As Integer = 5\n Console.WriteLine(\"Date: \" + test.ToString() + \", \" + hours.ToString())\n Console.WriteLine(\"Just skipping: \" + AddInBusinessHours(test, hours))\n Console.WriteLine(\"Looping: \" + LoopInBusinessHours(test, hours))\n Console.ReadLine()\n End Sub\n\nEnd Module\n"
},
{
"answer_id": 5588,
"author": "Mike Minutillo",
"author_id": 358,
"author_profile": "https://Stackoverflow.com/users/358",
"pm_score": 1,
"selected": false,
"text": "now <- number of minutes since the work day started\ndelay <- number of minutes in the delay\nday <- length of a work day in minutes\n\nx <- (now + delay) / day {integer division}\ny <- (now + delay) % day {modulo remainder}\n\nreturn startoftoday + x {in days} + y {in minutes}\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/106/"
] |
5,263 | <p>I have a self-referential Role table that represents a tree structure </p>
<pre><code>ID [INT] AUTO INCREMENT
Name [VARCHAR]
ParentID [INT]
</code></pre>
<p>I am using an ADO.NET DataTable and DataAdapter to load and save values to this table. This works if I only create children of existing rows. If I make a child row, then make a child of that child, then Update, the temporary ID value generated by the DataTable is going into the ParentID column. I have the following data relation set:</p>
<pre><code>dataset.Relations.Add(New DataRelation("RoleToRole",RoleTable.Columns("ID"), RoleTable.Columns("ParentID")))
</code></pre>
<p>And when I make new child rows in the DataTable I call the SetParentRow method</p>
<pre><code>newRow.SetParentRow(parentRow)
</code></pre>
<p>Is there something special I have to do to get the ID generation to propagate recursively when I call Update on the DataAdapter?</p>
| [
{
"answer_id": 5497,
"author": "lomaxx",
"author_id": 493,
"author_profile": "https://Stackoverflow.com/users/493",
"pm_score": 0,
"selected": false,
"text": "newRow.SetParentRow(parentRow, RoleTable.Relations(\"RoleToRole\"))\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/173/"
] |
5,269 | <p>In C#, (and feel free to answer for other languages), what order does the runtime evaluate a logic statement?</p>
<p>Example:</p>
<pre><code>DataTable myDt = new DataTable();
if (myDt != null && myDt.Rows.Count > 0)
{
//do some stuff with myDt
}
</code></pre>
<p>Which statement does the runtime evaluate first - </p>
<pre><code>myDt != null
</code></pre>
<p>or:</p>
<pre><code>myDt.Rows.Count > 0
</code></pre>
<p>?</p>
<p>Is there a time when the compiler would ever evaluate the statement backwards? Perhaps when an "OR" operator is involved?</p>
<hr>
<blockquote>
<p>& is known as a logical bitwise operator and will always evaluate all the sub-expressions</p>
</blockquote>
<p>What is a good example of when to use the bitwise operator instead of the "short-circuited boolean"?</p>
| [
{
"answer_id": 5278,
"author": "csmba",
"author_id": 350,
"author_profile": "https://Stackoverflow.com/users/350",
"pm_score": 3,
"selected": false,
"text": "if( x isNot Nothing AndAlso x.go()) then\n if ( x.init() And y.init()) then\n x.process(y)\nend \ny.doDance()\n"
},
{
"answer_id": 5279,
"author": "shsteimer",
"author_id": 292,
"author_profile": "https://Stackoverflow.com/users/292",
"pm_score": 2,
"selected": false,
"text": "if( A && B){\n // do something\n}\n if(A || B){\n //do something\n}\n"
},
{
"answer_id": 5292,
"author": "Brad Tutterow",
"author_id": 308,
"author_profile": "https://Stackoverflow.com/users/308",
"pm_score": 2,
"selected": false,
"text": "if (amHungry & whiteCastleIsNearby)\n{\n // The code will check if White Castle is nearby\n // even when I am not hungry\n}\n\nif (amHungry && whiteCastleIsNearby)\n{\n // The code will only check if White Castle is nearby\n // when I am hungry\n}\n"
},
{
"answer_id": 5295,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 2,
"selected": false,
"text": "if (a() && b())\n if (a() & b())\n"
},
{
"answer_id": 5301,
"author": "Mike Stone",
"author_id": 122,
"author_profile": "https://Stackoverflow.com/users/122",
"pm_score": 2,
"selected": false,
"text": "puts message unless message.nil?\n unless message.nil?\n puts message\nend\n"
},
{
"answer_id": 5372,
"author": "Bruce Alderman",
"author_id": 311,
"author_profile": "https://Stackoverflow.com/users/311",
"pm_score": 1,
"selected": false,
"text": "READ 0100 \nWRITE 0010 \nEXEC 0001\n flags = READ & EXEC; // value of flags is 0101\n"
},
{
"answer_id": 5378,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 3,
"selected": false,
"text": "a = new Log(); // Log class overloads the + operator\na + \"some string\"; // Call the overloaded method - otherwise this wouldn't work because you can't normally add strings to objects.\n a() || b() // be never runs if a is true\n"
},
{
"answer_id": 5384,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 1,
"selected": false,
"text": "a = Foo( 5, GetSummary( \"Orion\", GetAddress(\"Orion\") ) );\n GetAddress \"Orion\" GetSummary \"Orion\" GetAddress Foo 5 GetSummary a"
},
{
"answer_id": 5432,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 1,
"selected": false,
"text": "a = Foo(5, GetSummary(\"Orion\", GetAddress(\"Orion\")),\n GetSummary(\"Chris\", GetAddress(\"Chris\")));\n GetAddress(\"Orion\") GetSummary(\"Orion\", ...) GetAddress(\"Chris\") GetSummary(\"Chris\", ...) Foo(...) a && || foo() && bar() foo() & bar() && foo() bar() && & bar() foo()"
},
{
"answer_id": 17521,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 0,
"selected": false,
"text": "if ( x.init() And y.init()) then\n x.process(y)\nend \ny.doDance()\n And And & Dim x As Formatting = Formatting.Bold Or Formatting.Italic\nIf (x And Formatting.Italic) = Formatting.Italic Then\n MsgBox(\"The text will be set in italic.\")\nEnd If\n"
},
{
"answer_id": 2641585,
"author": "BCS",
"author_id": 1343,
"author_profile": "https://Stackoverflow.com/users/1343",
"pm_score": 0,
"selected": false,
"text": "&&"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/357/"
] |
5,323 | <p>It seems like every time I try to create a pure CSS layout it takes me much longer than if I'd use a table or two. Getting three columns to be equal lengths with different amounts of data seems to require particular fancy hacks, especially when dealing with cross-browser issues.</p>
<p>My Question:</p>
<p>Who are these few tables going to hurt? </p>
<p>Tables seem to work particularly well on tabular data — why are they so reviled in this day and age?</p>
<p>Google.com has a table in its source code, so do many other sites (<em>stackoverflow.com does not by the way</em>).</p>
| [
{
"answer_id": 5331,
"author": "Seibar",
"author_id": 357,
"author_profile": "https://Stackoverflow.com/users/357",
"pm_score": 3,
"selected": false,
"text": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n .someClass {\n background-color:black; /*this is for most browsers*/\n _background-color:white; /*this is for IE6 only - all others will ignore it*/\n}\n"
},
{
"answer_id": 5423,
"author": "Dillie-O",
"author_id": 71,
"author_profile": "https://Stackoverflow.com/users/71",
"pm_score": 3,
"selected": false,
"text": "<link rel=\"stylesheet\" type=\"text/css\" media=\"print\" href=\"PrintStyle.css\" />\n"
},
{
"answer_id": 75488,
"author": "Carl Camera",
"author_id": 12804,
"author_profile": "https://Stackoverflow.com/users/12804",
"pm_score": 5,
"selected": false,
"text": "class car {\n int wheels = 4;\n string engine;\n}\n\ncar mybike = new car();\nmybike.wheels = 2;\nmybike.engine = null;\n <table> <table> <table>"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/556/"
] |
5,328 | <p>So, in Java, the first line of your constructor HAS to be a call to super... be it implicitly calling super(), or explicitly calling another constructor. What I want to know is, why can't I put a try block around that?</p>
<p>My specific case is that I have a mock class for a test. There is no default constructor, but I want one to make the tests simpler to read. I also want to wrap the exceptions thrown from the constructor into a RuntimeException.</p>
<p>So, what I want to do is effectively this:</p>
<pre><code>public class MyClassMock extends MyClass {
public MyClassMock() {
try {
super(0);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
// Mocked methods
}
</code></pre>
<p>But Java complains that super isn't the first statement.</p>
<p>My workaround:</p>
<pre><code>public class MyClassMock extends MyClass {
public static MyClassMock construct() {
try {
return new MyClassMock();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public MyClassMock() throws Exception {
super(0);
}
// Mocked methods
}
</code></pre>
<p>Is this the best workaround? Why doesn't Java let me do the former?</p>
<hr>
<p>My best guess as to the "why" is that Java doesn't want to let me have a constructed object in a potentially inconsistent state... however, in doing a mock, I don't care about that. It seems I should be able to do the above... or at least I know that the above is safe for my case... or seems as though it should be anyways.</p>
<p>I am overriding any methods I use from the tested class, so there is no risk that I am using uninitialized variables.</p>
| [
{
"answer_id": 5351,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 5,
"selected": true,
"text": "public ClassName(...) : base(...)\n"
},
{
"answer_id": 5357,
"author": "Telcontar",
"author_id": 518,
"author_profile": "https://Stackoverflow.com/users/518",
"pm_score": 1,
"selected": false,
"text": "toString() equals()"
},
{
"answer_id": 76957,
"author": "Joshua",
"author_id": 14768,
"author_profile": "https://Stackoverflow.com/users/14768",
"pm_score": 3,
"selected": false,
"text": "SecurityManager public class Evil : SecurityManager {\n Evil()\n {\n try {\n super();\n } catch { Throwable t }\n {\n }\n }\n}\n"
},
{
"answer_id": 10261194,
"author": "Edwin Dalorzo",
"author_id": 697630,
"author_profile": "https://Stackoverflow.com/users/697630",
"pm_score": 3,
"selected": false,
"text": "class A {\n private String a = \"A\";\n\n public A() throws Exception {\n throw new Exception();\n }\n}\n try...catch A a = null;\ntry{\n a = new A();\n}catch(Exception e) {\n //...\n}\nSystem.out.println(a);\n null A name A class A {\n private final int a;\n public A() throws Exception { \n a = 10;\n }\n}\n\nclass B extends A {\n private final int b;\n public B() throws Exception {\n methodThatThrowsException(); \n b = 20;\n }\n}\n\nclass C extends B {\n public C() throws Exception { super(); }\n}\n C B int b"
},
{
"answer_id": 22721701,
"author": "aliteralmind",
"author_id": 2736496,
"author_profile": "https://Stackoverflow.com/users/2736496",
"pm_score": -1,
"selected": false,
"text": "public class Test {\n public Test() {\n this(Test.getObjectThatMightThrowException());\n }\n public Test(Object o) {\n //...\n }\n private static final Object getObjectThatMightThrowException() {\n try {\n return new ObjectThatMightThrowAnException();\n } catch(RuntimeException rtx) {\n throw new RuntimeException(\"It threw an exception!!!\", rtx);\n }\n }\n}\n"
},
{
"answer_id": 43454831,
"author": "Kröw",
"author_id": 5921170,
"author_profile": "https://Stackoverflow.com/users/5921170",
"pm_score": 0,
"selected": false,
"text": "super() try catch super() try {\n super();\n ...\n} catch (Exception e) {\n super(); //This line will throw the same error...\n ...\n}\n super() try catch super super() super()"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/122/"
] |
5,329 | <p>I'm currently evaluating the <code>MSF for CMMI</code> process template under <strong>TFS</strong> for use on my development team, and I'm having trouble understanding the need for separate bug and change request work item types.</p>
<p>I understand that it is beneficial to be able to differentiate between bugs (errors) and change requests (changing requirements) when generating reports.</p>
<p>In our current system, however, we only have a single type of change request and just use a field to indicate whether it is a bug, requirement change, etc (this field can be used to build report queries).</p>
<p>What are the benefits of having a separate workflow for bugs?</p>
<p>I'm also confused by the fact that developers can submit work against a bug <strong>or</strong> a change request, I thought the intended workflow was for bugs to generate change requests which are what the developer references when making changes.</p>
| [
{
"answer_id": 57878222,
"author": "superarts.org",
"author_id": 772295,
"author_profile": "https://Stackoverflow.com/users/772295",
"pm_score": 0,
"selected": false,
"text": "a := a + 1"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/327/"
] |
5,374 | <p>I would have thought this would be an easy one to Google, but I've been unsucessful.</p>
<p>I want to assign a variable the value out of an attribute (easy so far) then use that variable to select another node based on the value of that attribute.</p>
<p>Example:</p>
<pre><code><xsl:variable name="myId" select="@id" />
<xsl value-of select="//Root/Some/Other/Path/Where[@id='{@myId}']/@Name />
</code></pre>
<p>That does not work. If I replace the {@myId} with the value that is in the variable then it does find the right node, but doign it this way produces nothing. I'm sure I'm missing something, or perhaps there is a different way to do it.</p>
<p>The context is that there is related data under different top-level nodes that share the same id value so I need to get the related nodes in my template.</p>
| [
{
"answer_id": 5469,
"author": "palehorse",
"author_id": 312,
"author_profile": "https://Stackoverflow.com/users/312",
"pm_score": 5,
"selected": true,
"text": "<xsl:variable name=\"myId\" select=\"@id\" />\n<xsl value-of select=\"//Root/Some/Other/Path/Where[@id=$myId]/@Name\" />\n"
},
{
"answer_id": 16386,
"author": "samjudson",
"author_id": 1908,
"author_profile": "https://Stackoverflow.com/users/1908",
"pm_score": 3,
"selected": false,
"text": "<newElement Id=\"{@Id}\"/>\n <newElement Id=\"{$myId}\"/>\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/312/"
] |
5,415 | <p>I have a binary file that I have to parse and I'm using Python. Is there a way to take 4 bytes and convert it to a single precision floating point number?</p>
| [
{
"answer_id": 73281,
"author": "tzot",
"author_id": 6899,
"author_profile": "https://Stackoverflow.com/users/6899",
"pm_score": 8,
"selected": true,
"text": ">>> import struct\n>>> struct.pack('f', 3.141592654)\nb'\\xdb\\x0fI@'\n>>> struct.unpack('f', b'\\xdb\\x0fI@')\n(3.1415927410125732,)\n>>> struct.pack('4f', 1.0, 2.0, 3.0, 4.0)\n'\\x00\\x00\\x80?\\x00\\x00\\x00@\\x00\\x00@@\\x00\\x00\\x80@'\n"
},
{
"answer_id": 54168810,
"author": "NDM",
"author_id": 6585198,
"author_profile": "https://Stackoverflow.com/users/6585198",
"pm_score": 4,
"selected": false,
"text": ">>> import struct\n>>> [x] = struct.unpack('f', b'\\xdb\\x0fI@')\n>>> x\n3.1415927410125732\n >>> import struct\n>>> [x,y] = struct.unpack('ff', b'\\xdb\\x0fI@\\x0b\\x01I4')\n>>> x\n3.1415927410125732\n>>> y\n1.8719963179592014e-07\n>>> \n"
},
{
"answer_id": 73420517,
"author": "Chance Cuddeback",
"author_id": 13674247,
"author_profile": "https://Stackoverflow.com/users/13674247",
"pm_score": 2,
"selected": false,
"text": "struct.unpack('Xf', ...)\n struct.unpack('Xd', ...)\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/680/"
] |
5,419 | <p>When I try to print a Unicode string in a Windows console, I get an error .</p>
<p><code>UnicodeEncodeError: 'charmap' codec can't encode character ....</code></p>
<p>I assume this is because the Windows console does not accept Unicode-only characters. What's the best way around this?
Is there any way I can make Python automatically print a <code>?</code> instead of failing in this situation?</p>
<p><strong>Edit:</strong> I'm using Python 2.5.</p>
<hr />
<p><strong>Note:</strong> @LasseV.Karlsen answer with the checkmark is sort of outdated (from 2008). Please use the solutions/answers/suggestions below with care!!</p>
<p><a href="https://stackoverflow.com/a/32176732/610569">@JFSebastian answer</a> is more relevant as of today (6 Jan 2016).</p>
| [
{
"answer_id": 5430,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 6,
"selected": true,
"text": "$ python -c 'import sys, codecs, locale; print sys.stdout.encoding; \\\n sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout); \\\n line = u\"\\u0411\\n\"; print type(line), len(line); \\\n sys.stdout.write(line); print line'\n UTF-8\n <type 'unicode'> 2\n Б\n Б\n\n $ python -c 'import sys, codecs, locale; print sys.stdout.encoding; \\\n sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout); \\\n line = u\"\\u0411\\n\"; print type(line), len(line); \\\n sys.stdout.write(line); print line' | cat\n None\n <type 'unicode'> 2\n Б\n Б\n"
},
{
"answer_id": 8020,
"author": "Bartosz Radaczyński",
"author_id": 985,
"author_profile": "https://Stackoverflow.com/users/985",
"pm_score": 1,
"selected": false,
"text": "import sys\nsys.getdefaultencoding()\n import sys\nsys.setdefaultencoding('utf-8')\n # -*- coding: UTF-8 -*-\nimport sys,time\n"
},
{
"answer_id": 2013263,
"author": "sorin",
"author_id": 99834,
"author_profile": "https://Stackoverflow.com/users/99834",
"pm_score": 3,
"selected": false,
"text": "\n#!/usr/bin/python\n# -*- coding: UTF-8 -*-\n\nimport codecs, sys\n\nreload(sys)\nsys.setdefaultencoding('utf-8')\n\nprint sys.getdefaultencoding()\n\nif sys.platform == 'win32':\n try:\n import win32console \n except:\n print \"Python Win32 Extensions module is required.\\n You can download it from https://sourceforge.net/projects/pywin32/ (x86 and x64 builds are available)\\n\"\n exit(-1)\n # win32console implementation of SetConsoleCP does not return a value\n # CP_UTF8 = 65001\n win32console.SetConsoleCP(65001)\n if (win32console.GetConsoleCP() != 65001):\n raise Exception (\"Cannot set console codepage to 65001 (UTF-8)\")\n win32console.SetConsoleOutputCP(65001)\n if (win32console.GetConsoleOutputCP() != 65001):\n raise Exception (\"Cannot set console output codepage to 65001 (UTF-8)\")\n\n#import sys, codecs\nsys.stdout = codecs.getwriter('utf8')(sys.stdout)\nsys.stderr = codecs.getwriter('utf8')(sys.stderr)\n\nprint \"This is an Е乂αmp١ȅ testing Unicode support using Arabic, Latin, Cyrillic, Greek, Hebrew and CJK code points.\\n\"\n"
},
{
"answer_id": 4637795,
"author": "Daira Hopwood",
"author_id": 393146,
"author_profile": "https://Stackoverflow.com/users/393146",
"pm_score": 5,
"selected": false,
"text": "sys.setdefaultencoding"
},
{
"answer_id": 10667978,
"author": "Giampaolo Rodolà",
"author_id": 376587,
"author_profile": "https://Stackoverflow.com/users/376587",
"pm_score": 4,
"selected": false,
"text": "from __future__ import print_function\nimport sys\n\ndef safeprint(s):\n try:\n print(s)\n except UnicodeEncodeError:\n if sys.version_info >= (3,):\n print(s.encode('utf8').decode(sys.stdout.encoding))\n else:\n print(s.encode('utf8'))\n\nsafeprint(u\"\\N{EM DASH}\")\n"
},
{
"answer_id": 32176732,
"author": "jfs",
"author_id": 4279,
"author_profile": "https://Stackoverflow.com/users/4279",
"pm_score": 6,
"selected": false,
"text": "win-unicode-console print(unicode_string) UnicodeEncodeError: 'charmap' codec can't encode character... chcp cp437 WriteConsoleW() win-unicode-console T:\\> py -m pip install win-unicode-console\nT:\\> py -m run your_script.py\n ? ? PYTHONIOENCODING T:\\> set PYTHONIOENCODING=:replace\nT:\\> python3 -c \"print(u'[\\N{EURO SIGN}]')\"\n[?]\n PYTHONIOENCODING PYTHONLEGACYWINDOWSIOENCODING"
},
{
"answer_id": 34306583,
"author": "Kinjal Dixit",
"author_id": 6629,
"author_profile": "https://Stackoverflow.com/users/6629",
"pm_score": 2,
"selected": false,
"text": ">set PYTHONIOENCODING=UTF-8\n"
},
{
"answer_id": 35903736,
"author": "mike rodent",
"author_id": 595305,
"author_profile": "https://Stackoverflow.com/users/595305",
"pm_score": 3,
"selected": false,
"text": "def pr(s):\n try:\n print(s)\n except UnicodeEncodeError:\n for c in s:\n try:\n print( c, end='')\n except UnicodeEncodeError:\n print( '?', end='')\n"
},
{
"answer_id": 37229972,
"author": "CODE-REaD",
"author_id": 5025060,
"author_profile": "https://Stackoverflow.com/users/5025060",
"pm_score": -1,
"selected": false,
"text": "print() UnicodeEncodeError print(text) print(str(text).encode('utf-8')) str() encode()"
},
{
"answer_id": 43924648,
"author": "J. Does",
"author_id": 7227370,
"author_profile": "https://Stackoverflow.com/users/7227370",
"pm_score": 1,
"selected": false,
"text": "OSError: [winError 87] The paraneter is incorrect \nException ignored in: (_io-TextIOwrapper name='(stdout)' mode='w' ' encoding='utf8') \nOSError: [WinError 87] The parameter is incorrect \n font"
},
{
"answer_id": 45868162,
"author": "shubaly",
"author_id": 7269358,
"author_profile": "https://Stackoverflow.com/users/7269358",
"pm_score": 2,
"selected": false,
"text": "print unicode(string, 'unicode-escape')\n import os\nstring = \"002 Could've Would've Should've\"\nos.system('echo ' + string)\n pip install win-unicode-console\npy -mrun your_script.py\n"
},
{
"answer_id": 51124805,
"author": "Matthew Estock",
"author_id": 2133918,
"author_profile": "https://Stackoverflow.com/users/2133918",
"pm_score": 2,
"selected": false,
"text": "print(yourstring.encode('ascii','replace').decode('ascii'))\n msg = s.recv(1024).decode(\"utf-8\")\n print(msg.encode('ascii','replace').decode('ascii'))\n UnicodeEncodeError: 'charmap' ?"
},
{
"answer_id": 52617143,
"author": "c97",
"author_id": 397961,
"author_profile": "https://Stackoverflow.com/users/397961",
"pm_score": 3,
"selected": false,
"text": "chcp 65001 & set PYTHONIOENCODING=utf-8\n"
},
{
"answer_id": 68507839,
"author": "Itachi",
"author_id": 1831784,
"author_profile": "https://Stackoverflow.com/users/1831784",
"pm_score": -1,
"selected": false,
"text": "import locale \nlocale.getpreferredencoding()\n import os\nif os.name == \"nt\":\n import _locale\n _locale._gdl_bak = _locale._getdefaultlocale\n _locale._getdefaultlocale = (lambda *args: (_locale._gdl_bak()[0], 'utf8'))\n"
},
{
"answer_id": 74509356,
"author": "Wok",
"author_id": 376454,
"author_profile": "https://Stackoverflow.com/users/376454",
"pm_score": 0,
"selected": false,
"text": "scratch_1.py s = \"∞\"\n\nprint(s)\n python scratch_1.py\n ∞\n python scratch_1.py > temp.txt\n Traceback (most recent call last):\n File \"C:\\Users\\Wok\\AppData\\Roaming\\JetBrains\\PyCharmCE2022.2\\scratches\\scratch_1.py\", line 3, in <module>\n print(s)\n File \"C:\\Users\\Wok\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\encodings\\cp1252.py\", line 19, in encode\n return codecs.charmap_encode(input,self.errors,encoding_table)[0]\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nUnicodeEncodeError: 'charmap' codec can't encode character '\\u221e' in position 0: character maps to <undefined>\n ? s = \"∞\"\n\ntry:\n print(s)\nexcept UnicodeEncodeError:\n output_str = s.encode(\"ascii\", errors=\"replace\").decode(\"ascii\")\n\n print(output_str)\n decode() str bytes \"ascii\""
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/207/"
] |
5,425 | <p>I have a page that is generated which inserts an HTML comment near the top of the page. Inside the comment is a *nix-style command.</p>
<pre><code><!-- command --option value --option2 value2 --option3 -->
</code></pre>
<p>This comment breaks the page completely. What is wrong with the comment to cause this to happen, and why is this the case?</p>
| [
{
"answer_id": 5596,
"author": "Lance Fisher",
"author_id": 571,
"author_profile": "https://Stackoverflow.com/users/571",
"pm_score": 2,
"selected": false,
"text": "<div style=\"display:none\">command --option value --option2 value2 --option3 </div>\n <div class=\"comment\">command --option value --option2 value2 --option3 </div>\n .comment {display:none;}\n"
},
{
"answer_id": 5632,
"author": "Darren Kopp",
"author_id": 77,
"author_profile": "https://Stackoverflow.com/users/77",
"pm_score": 1,
"selected": false,
"text": "<html>"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/219/"
] |
5,428 | <p>Is it worth learning the convention or is it a bane to readability and maintainability?</p>
| [
{
"answer_id": 5439,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 7,
"selected": true,
"text": "int vBox = aBottom * lVerticalSide;\n int aBottom = lSide1;\n int iLength;\nint iVolume;\nint iArea;\n"
},
{
"answer_id": 5440,
"author": "Steve Willard",
"author_id": 402,
"author_profile": "https://Stackoverflow.com/users/402",
"pm_score": 0,
"selected": false,
"text": "thisMethodIsPrettyCool()\nthis_method_is_pretty_cool()\n"
},
{
"answer_id": 5445,
"author": "Justin Standard",
"author_id": 92,
"author_profile": "https://Stackoverflow.com/users/92",
"pm_score": 3,
"selected": false,
"text": "sValue iCount dAmount fAmount bFlag"
},
{
"answer_id": 5451,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 4,
"selected": false,
"text": "int vBox = aBottom * lVerticalSide;\n int boxVolume = bottomArea * verticalHeight;\n"
},
{
"answer_id": 10099,
"author": "ColinYounger",
"author_id": 1223,
"author_profile": "https://Stackoverflow.com/users/1223",
"pm_score": 1,
"selected": false,
"text": "int Box = iBottom * nVerticleSide\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/659/"
] |
5,459 | <p>This is how I wanted to do it which would work in PHP 5.3.0+</p>
<pre><code><?php
class MyClass
{
const CONSTANT = 'Const var';
}
$classname = 'MyClass';
echo $classname::CONSTANT; // As of PHP 5.3.0
?>
</code></pre>
<p>But I'm restricted to using PHP 5.2.6. Can anyone think of a simple way to simulate this behavior without instantiating the class?</p>
| [
{
"answer_id": 5472,
"author": "Juan",
"author_id": 550,
"author_profile": "https://Stackoverflow.com/users/550",
"pm_score": -1,
"selected": false,
"text": "<?php\nclass MyClass\n{\n const CONSTANT = 'Const var';\n}\n\n$classname = 'MyClass';\necho eval( 'return '.$classname.'::CONSTANT;' );\n?>\n"
},
{
"answer_id": 19601,
"author": "AdamTheHutt",
"author_id": 1103,
"author_profile": "https://Stackoverflow.com/users/1103",
"pm_score": 4,
"selected": true,
"text": "eval constant <?php\n\nclass MyClass\n{\n const CONSTANT = 'Const var';\n}\n\n$classname = 'MyClass';\necho constant(\"$classname::CONSTANT\");\n\n?>\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/117/"
] |
5,473 | <p>Is it possible to undo the changes caused by the following command? If so, how?</p>
<pre><code>git reset --hard HEAD~1
</code></pre>
| [
{
"answer_id": 6636,
"author": "Pat Notz",
"author_id": 825,
"author_profile": "https://Stackoverflow.com/users/825",
"pm_score": 9,
"selected": false,
"text": "git reflog git reset --hard <sha1 of desired commit>\n"
},
{
"answer_id": 21778,
"author": "Brian Riehman",
"author_id": 2063,
"author_profile": "https://Stackoverflow.com/users/2063",
"pm_score": 12,
"selected": true,
"text": "$ git init\nInitialized empty Git repository in .git/\n\n$ echo \"testing reset\" > file1\n$ git add file1\n$ git commit -m 'added file1'\nCreated initial commit 1a75c1d: added file1\n 1 files changed, 1 insertions(+), 0 deletions(-)\n create mode 100644 file1\n\n$ echo \"added new file\" > file2\n$ git add file2\n$ git commit -m 'added file2'\nCreated commit f6e5064: added file2\n 1 files changed, 1 insertions(+), 0 deletions(-)\n create mode 100644 file2\n\n$ git reset --hard HEAD^\nHEAD is now at 1a75c1d... added file1\n\n$ cat file2\ncat: file2: No such file or directory\n\n$ git reflog\n1a75c1d... HEAD@{0}: reset --hard HEAD^: updating HEAD\nf6e5064... HEAD@{1}: commit: added file2\n\n$ git reset --hard f6e5064\nHEAD is now at f6e5064... added file2\n\n$ cat file2\nadded new file\n"
},
{
"answer_id": 21873,
"author": "sverrejoh",
"author_id": 473,
"author_profile": "https://Stackoverflow.com/users/473",
"pm_score": 7,
"selected": false,
"text": "fsck $ git fsck --lost-found\ndangling commit b72e67a9bb3f1fc1b64528bcce031af4f0d6fcbf\n $ git rebase b72e67a9bb3f1fc1b64528bcce031af4f0d6fcbf\n"
},
{
"answer_id": 29469,
"author": "Jörg W Mittag",
"author_id": 2988,
"author_profile": "https://Stackoverflow.com/users/2988",
"pm_score": 5,
"selected": false,
"text": "git repack -d git gc git fsck --lost-found git checkout git reset @ ~ git reset HEAD@{1} git init\ngit commit --allow-empty -mOne\ngit commit --allow-empty -mTwo\ngit checkout -b anotherbranch\ngit commit --allow-empty -mThree\ngit checkout master # This changes the HEAD, but not the repository contents\ngit show HEAD~1 # => One\ngit show HEAD@{1} # => Three\ngit reflog\n HEAD~1 HEAD@{1}"
},
{
"answer_id": 5127681,
"author": "markmc",
"author_id": 627058,
"author_profile": "https://Stackoverflow.com/users/627058",
"pm_score": 8,
"selected": false,
"text": "$> git reset --hard HEAD@{1}\n"
},
{
"answer_id": 11965255,
"author": "Stian Høiland",
"author_id": 659310,
"author_profile": "https://Stackoverflow.com/users/659310",
"pm_score": 5,
"selected": false,
"text": "$ git fsck --lost-found Checking object directories: 100% (256/256), done.\nChecking objects: 100% (3/3), done.\ndangling blob 025cab9725ccc00fbd7202da543f556c146cb119\ndangling blob 84e9af799c2f5f08fb50874e5be7fb5cb7aa7c1b\ndangling blob 85f4d1a289e094012819d9732f017c7805ee85b4\ndangling blob 8f654d1cd425da7389d12c17dd2d88d318496d98\ndangling blob 9183b84bbd292dcc238ca546dab896e073432933\ndangling blob 1448ee51d0ea16f259371b32a557b60f908d15ee\ndangling blob 95372cef6148d980ab1d7539ee6fbb44f5e87e22\ndangling blob 9b3bf9fb1ee82c6d6d5ec9149e38fe53d4151fbd\ndangling blob 2b21002ca449a9e30dbb87e535fbd4e65bac18f7\ndangling blob 2fff2f8e4ea6408ac84a8560477aa00583002e66\ndangling blob 333e76340b59a944456b4befd0e007c2e23ab37b\ndangling blob b87163c8def315d40721e592f15c2192a33816bb\ndangling blob c22aafb90358f6bf22577d1ae077ad89d9eea0a7\ndangling blob c6ef78dd64c886e9c9895e2fc4556e69e4fbb133\ndangling blob 4a71f9ff8262701171d42559a283c751fea6a201\ndangling blob 6b762d368f44ddd441e5b8eae6a7b611335b49a2\ndangling blob 724d23914b48443b19eada79c3eb1813c3c67fed\ndangling blob 749ffc9a412e7584245af5106e78167b9480a27b\ndangling commit f6ce1a403399772d4146d306d5763f3f5715cb5a <- it's this one\n $ git show f6ce1a403399772d4146d306d5763f3f5715cb5a commit f6ce1a403399772d4146d306d5763f3f5715cb5a\nAuthor: Stian Gudmundsen Høiland <[email protected]>\nDate: Wed Aug 15 08:41:30 2012 +0200\n\n *MY COMMIT MESSAGE IS DISPLAYED HERE*\n\ndiff --git a/Some.file b/Some.file\nnew file mode 100644\nindex 0000000..15baeba\n--- /dev/null\n+++ b/Some.file\n*THE WHOLE COMMIT IS DISPLAYED HERE*\n $ git rebase f6ce1a403399772d4146d306d5763f3f5715cb5a First, rewinding head to replay your work on top of it...\nFast-forwarded master to f6ce1a403399772d4146d306d5763f3f5715cb5a.\n"
},
{
"answer_id": 21227533,
"author": "martin",
"author_id": 1725579,
"author_profile": "https://Stackoverflow.com/users/1725579",
"pm_score": 4,
"selected": false,
"text": "git init \necho hello >> test.txt \ngit add test.txt \n git reset --hard \ngit fsck \n git show ce01362 \n gitk --all $(git log -g --pretty=format:%h) \n"
},
{
"answer_id": 22319764,
"author": "neuron",
"author_id": 461421,
"author_profile": "https://Stackoverflow.com/users/461421",
"pm_score": 3,
"selected": false,
"text": "git fsck --lost-found | grep commit | cut -d ' ' -f 3 | xargs -i git show \\{\\} | egrep '^commit |Date:'"
},
{
"answer_id": 27990599,
"author": "Ajedi32",
"author_id": 1157054,
"author_profile": "https://Stackoverflow.com/users/1157054",
"pm_score": 6,
"selected": false,
"text": "git reset --hard git reset git reset --hard HEAD~ git reset git reset --hard @{1}\n git reflog <branchname> 7c169bd master@{0}: reset: moving to HEAD~\n3ae5027 master@{1}: commit: Changed file2\n7c169bd master@{2}: commit: Some change\n5eb37ca master@{3}: commit (initial): Initial commit\n master@{1} 3ae5027 git reset --hard <commit> git add git fsck git add git reset <commit>"
},
{
"answer_id": 29408886,
"author": "suhailvs",
"author_id": 2351696,
"author_profile": "https://Stackoverflow.com/users/2351696",
"pm_score": 7,
"selected": false,
"text": "--hard discarded commit $ git reflog\n b0d059c HEAD@{0}: reset: moving to HEAD~1\n4bac331 HEAD@{1}: commit: added level introduction....\n....\n 4bac331 discarded commit $ git reset --hard 4bac331\n"
},
{
"answer_id": 49957891,
"author": "CodeWizard",
"author_id": 1755598,
"author_profile": "https://Stackoverflow.com/users/1755598",
"pm_score": 4,
"selected": false,
"text": "HEAD First of all what is HEAD? HEAD HEAD git worktree HEAD .git/HEAD detached HEAD HEAD detached HEAD HEAD git checkout git checkout <commit_id>\ngit checkout -b <new branch> <commit_id>\ngit checkout HEAD~X // x is the number of commits t go back\n # Checkout a given commit. \n# Doing so will result in a `detached HEAD` which mean that the `HEAD`\n# is not pointing to the latest so you will need to checkout branch\n# in order to be able to update the code.\ngit checkout <commit-id>\n\n# create a new branch forked to the given commit\ngit checkout -b <branch name>\n git reflog reflog git reflog HEAD HEAD reflog git reflog\ngit checkout HEAD@{...}\n git reset HEAD --hard <commit_id> # This will destroy any local modifications.\n# Don't do it if you have uncommitted work you want to keep.\ngit reset --hard 0d1d7fc32\n\n# Alternatively, if there's work to keep:\ngit stash\ngit reset --hard 0d1d7fc32\ngit stash pop\n# This saves the modifications, then reapplies that patch after resetting.\n# You could get merge conflicts, if you've modified things which were\n# changed since the commit you reset to.\n git rebase --no-autostash git revert <sha-1> # add new commit with the undo of the original one.\n# the <sha-1> can be any commit(s) or commit range\ngit revert <sha-1>\n reset && checkout HEAD"
},
{
"answer_id": 57491027,
"author": "ScottyBlades",
"author_id": 3833666,
"author_profile": "https://Stackoverflow.com/users/3833666",
"pm_score": 5,
"selected": false,
"text": "git reflog git cherry-pick <the sha>"
},
{
"answer_id": 60669149,
"author": "flyingpluto7",
"author_id": 6343586,
"author_profile": "https://Stackoverflow.com/users/6343586",
"pm_score": 2,
"selected": false,
"text": "git reset --hard ctrl-z cmd-shift-z"
},
{
"answer_id": 60767938,
"author": "tuan.dinh",
"author_id": 4963534,
"author_profile": "https://Stackoverflow.com/users/4963534",
"pm_score": 2,
"selected": false,
"text": "https://medium.com/@CarrieGuss/how-to-recover-from-a-git-hard-reset-b830b5e3f60c for blob in $(git fsck --lost-found | awk ‘$2 == “blob” { print $3 }’); do git cat-file -p $blob > $blob.txt; done\n git reset --hard"
},
{
"answer_id": 63639989,
"author": "NATALIAGJ",
"author_id": 12296962,
"author_profile": "https://Stackoverflow.com/users/12296962",
"pm_score": 2,
"selected": false,
"text": "git reflog"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5473",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/85/"
] |
5,482 | <p>The ASP.NET AJAX <strong>ModalPopupExtender</strong> has <code>OnCancelScript</code> and <code>OnOkScript</code> properties, but it doesn't seem to have an <code>OnShowScript</code> property. I'd like to specify a javascript function to run each time the popup is shown.</p>
<p>In past situations, I set the <code>TargetControlID</code> to a dummy control and provide my own control that first does some JS code and then uses the JS methods to show the popup. But in this case, I am showing the popup from both client and server side code.</p>
<p>Anyone know of a way to do this?</p>
<p>BTW, I needed this because I have a textbox in the modal that I want to make a TinyMCE editor. But the TinyMCE init script doesn't work on invisible textboxes, so I had to find a way to run it at the time the modal was shown</p>
| [
{
"answer_id": 5500,
"author": "lomaxx",
"author_id": 493,
"author_profile": "https://Stackoverflow.com/users/493",
"pm_score": 6,
"selected": true,
"text": "function pageLoad()\n{\n var popup = $find('ModalPopupClientID');\n popup.add_shown(SetFocus);\n}\n\nfunction SetFocus()\n{\n $get('TriggerClientId').focus();\n}\n"
},
{
"answer_id": 2365547,
"author": "Mircea Dunka",
"author_id": 284646,
"author_profile": "https://Stackoverflow.com/users/284646",
"pm_score": 4,
"selected": false,
"text": "mpeBID function pageLoad() {\n $find('mpeBID').add_shown(HideMediaPlayer);\n}\n\nfunction HideMediaPlayer() {\n var divMovie = $get('<%=divMovie.ClientID%>');\n divMovie.style.display = \"none\";\n}\n"
},
{
"answer_id": 9529512,
"author": "John Ward",
"author_id": 1244536,
"author_profile": "https://Stackoverflow.com/users/1244536",
"pm_score": 4,
"selected": false,
"text": "<ajaxToolkit:ModalPopupExtender \n ID=\"ModalPopupExtender2\" runat=\"server\" \n TargetControlID=\"lnk_OpenGame\" \n PopupControlID=\"Panel1\" \n BehaviorID=\"SilverPracticeBehaviorID\" >\n <Animations>\n <OnShown>\n <ScriptAction Script=\"InitializeGame();\" /> \n </OnShown>\n </Animations> \n</ajaxToolkit:ModalPopupExtender>\n"
},
{
"answer_id": 15915119,
"author": "Mormon SUD",
"author_id": 2241412,
"author_profile": "https://Stackoverflow.com/users/2241412",
"pm_score": 2,
"selected": false,
"text": "var launch = false;\n\nfunction launchModal() {\n launch = true;\n}\n\nfunction pageLoad() {\n if (launch) {\n var ModalPedimento = $find('ModalPopupExtender_Pedimento');\n ModalPedimento.show();\n ModalPedimento.add_shown(SetFocus);\n }\n}\n\nfunction SetFocus() {\n $get('TriggerClientId').focus();\n}\n"
},
{
"answer_id": 15932547,
"author": "Mormon SUD",
"author_id": 2241412,
"author_profile": "https://Stackoverflow.com/users/2241412",
"pm_score": 2,
"selected": false,
"text": "var launch = false;\nvar NameObject = '';\n\nfunction launchModal(ModalPopupExtender) {\n launch = true;\n NameObject = ModalPopupExtender;\n}\n\nfunction pageLoad() {\n if (launch) {\n var ModalObject = $find(NameObject);\n ModalObject.show();\n ModalObject.add_shown(SetFocus);\n }\n} \n\nfunction SetFocus() {\n $get('TriggerClientId').focus();\n}\n protected void btnNuevo_Click(object sender, EventArgs e)\n{\n //Para recuperar el formulario modal desde el lado del sercidor\n ScriptManager.RegisterStartupScript(Page, Page.GetType(), \"key\", \"<script>launchModal('\" + ModalPopupExtender_Factura.ID.ToString() + \"');</script>\", false);\n}\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/698/"
] |
5,494 | <p>I'm using IIS in Windows 2003 Server for a SharePoint intranet. <br />External incoming requests will be using the host header <code>portal.mycompany.com</code> and be forced to use SSL.</p>
<p>I was wondering if there's a way to set up an alternate host header such as <br /><code>http://internalportal/</code> <br />which only accepts requests from the internal network, but doesn't force the users to use SSL.</p>
<p>Any recommendations for how to set this up?</p>
| [
{
"answer_id": 5585,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 1,
"selected": false,
"text": "172.16.3.1:443:portal.mycompany.com\n172.16.3.2:80:internalportal\n"
}
] | 2008/08/07 | [
"https://Stackoverflow.com/questions/5494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/697/"
] |
5,507 | <p>Does it make sense, having all of the C#-managed-bliss, to go back to Petzold's Programming Windows and try to produce code w/ pure WinAPI?</p>
<p>What can be learn from it? Isn't it just too outdated to be useful?</p>
| [
{
"answer_id": 104394,
"author": "paercebal",
"author_id": 14089,
"author_profile": "https://Stackoverflow.com/users/14089",
"pm_score": 5,
"selected": false,
"text": "fopen CreateFile CreateWindow void * delete this ; const"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/861/"
] |
5,509 | <p>So my company uses a delightfully buggy program called Rational Purify (as a plugin to Microsoft Visual Developer Studio) to manage memory leaks. The program is deigned to let you click on a memory leak after you have encountered it, and then jump to the line that the leak occurs on.</p>
<p>Unfortunately Purify is malfunctioning and Purify will not jump to the place that the leak occurred it only mentions the class and method that the leak occurs in. Unfortunately, sometimes this is about as useful as hiring a guide to help you hunt bears and having him point to the forest and tell you there are bears there.</p>
<p>Does anyone with Purify experience have any idea how I might fix this problem or have a good manual to look though?</p>
| [
{
"answer_id": 714325,
"author": "RichieHindle",
"author_id": 21886,
"author_profile": "https://Stackoverflow.com/users/21886",
"pm_score": 2,
"selected": false,
"text": ".sln"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/159/"
] |
5,511 | <p>How are you handling the entry of numeric values in WPF applications?</p>
<p>Without a NumericUpDown control, I've been using a TextBox and handling its PreviewKeyDown event with the code below, but it's pretty ugly.</p>
<p>Has anyone found a more graceful way to get numeric data from the user without relying on a third-party control?</p>
<pre><code>private void NumericEditPreviewKeyDown(object sender, KeyEventArgs e)
{
bool isNumPadNumeric = (e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9) || e.Key == Key.Decimal;
bool isNumeric = (e.Key >= Key.D0 && e.Key <= Key.D9) || e.Key == Key.OemPeriod;
if ((isNumeric || isNumPadNumeric) && Keyboard.Modifiers != ModifierKeys.None)
{
e.Handled = true;
return;
}
bool isControl = ((Keyboard.Modifiers != ModifierKeys.None && Keyboard.Modifiers != ModifierKeys.Shift)
|| e.Key == Key.Back || e.Key == Key.Delete || e.Key == Key.Insert
|| e.Key == Key.Down || e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Up
|| e.Key == Key.Tab
|| e.Key == Key.PageDown || e.Key == Key.PageUp
|| e.Key == Key.Enter || e.Key == Key.Return || e.Key == Key.Escape
|| e.Key == Key.Home || e.Key == Key.End);
e.Handled = !isControl && !isNumeric && !isNumPadNumeric;
}
</code></pre>
| [
{
"answer_id": 7794,
"author": "Arcturus",
"author_id": 900,
"author_profile": "https://Stackoverflow.com/users/900",
"pm_score": 7,
"selected": true,
"text": "protected override void OnPreviewTextInput(System.Windows.Input.TextCompositionEventArgs e)\n{\n e.Handled = !AreAllValidNumericChars(e.Text);\n base.OnPreviewTextInput(e);\n}\n\nprivate bool AreAllValidNumericChars(string str)\n{\n foreach(char c in str)\n {\n if(!Char.IsNumber(c)) return false;\n }\n\n return true;\n}\n"
},
{
"answer_id": 28001,
"author": "user3035",
"author_id": 3035,
"author_profile": "https://Stackoverflow.com/users/3035",
"pm_score": 4,
"selected": false,
"text": "<TextBox local:TextBoxNumbers.SingleDelta=\"1\">100</TextBox>\n Up Down Shift + Up Shift + Down Page Up Page Down Converter Code behind using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Windows;\nusing System.Windows.Controls;\nusing System.Windows.Data;\nusing System.Windows.Input;\n\nnamespace Helpers\n{\n public class TextBoxNumbers\n { \n public static Decimal GetSingleDelta(DependencyObject obj)\n {\n return (Decimal)obj.GetValue(SingleDeltaProperty);\n }\n\n public static void SetSingleDelta(DependencyObject obj, Decimal value)\n {\n obj.SetValue(SingleDeltaProperty, value);\n }\n\n // Using a DependencyProperty as the backing store for SingleValue. This enables animation, styling, binding, etc...\n public static readonly DependencyProperty SingleDeltaProperty =\n DependencyProperty.RegisterAttached(\"SingleDelta\", typeof(Decimal), typeof(TextBoxNumbers), new UIPropertyMetadata(0.0m, new PropertyChangedCallback(f)));\n\n public static void f(DependencyObject o, DependencyPropertyChangedEventArgs e)\n {\n TextBox t = o as TextBox;\n\n if (t == null)\n return;\n\n t.PreviewKeyDown += new System.Windows.Input.KeyEventHandler(t_PreviewKeyDown);\n }\n\n private static Decimal GetSingleValue(DependencyObject obj)\n {\n return GetSingleDelta(obj);\n }\n\n private static Decimal GetDoubleValue(DependencyObject obj)\n {\n return GetSingleValue(obj) * 10;\n }\n\n private static Decimal GetTripleValue(DependencyObject obj)\n {\n return GetSingleValue(obj) * 100;\n }\n\n static void t_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)\n {\n TextBox t = sender as TextBox;\n Decimal i;\n\n if (t == null)\n return;\n\n if (!Decimal.TryParse(t.Text, out i))\n return;\n\n switch (e.Key)\n {\n case System.Windows.Input.Key.Up:\n if (Keyboard.Modifiers == ModifierKeys.Shift)\n i += GetDoubleValue(t);\n else\n i += GetSingleValue(t);\n break;\n\n case System.Windows.Input.Key.Down:\n if (Keyboard.Modifiers == ModifierKeys.Shift)\n i -= GetDoubleValue(t);\n else\n i -= GetSingleValue(t);\n break;\n\n case System.Windows.Input.Key.PageUp:\n i += GetTripleValue(t);\n break;\n\n case System.Windows.Input.Key.PageDown:\n i -= GetTripleValue(t);\n break;\n\n default:\n return;\n }\n\n if (BindingOperations.IsDataBound(t, TextBox.TextProperty))\n {\n try\n {\n Binding binding = BindingOperations.GetBinding(t, TextBox.TextProperty);\n t.Text = (string)binding.Converter.Convert(i, null, binding.ConverterParameter, binding.ConverterCulture);\n }\n catch\n {\n t.Text = i.ToString();\n }\n }\n else\n t.Text = i.ToString();\n }\n }\n}\n"
},
{
"answer_id": 57784,
"author": "Mark Allen",
"author_id": 5948,
"author_profile": "https://Stackoverflow.com/users/5948",
"pm_score": 1,
"selected": false,
"text": "int numericValue = 0;\n\nif (false == int.TryParse(yourInput, out numericValue))\n{\n // handle non-numeric input\n}\n"
},
{
"answer_id": 561577,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "private void txtNumericValue_PreviewKeyDown(object sender, KeyEventArgs e)\n{\n KeyConverter converter = new KeyConverter();\n\n string key = converter.ConvertToString(e.Key);\n\n if (key != null && key.Length == 1)\n {\n e.Handled = Char.IsDigit(key[0]) == false;\n }\n}\n"
},
{
"answer_id": 1923737,
"author": "Eric",
"author_id": 218177,
"author_profile": "https://Stackoverflow.com/users/218177",
"pm_score": 4,
"selected": false,
"text": "Regex NumEx = new Regex(@\"^-?\\d*\\.?\\d*$\");\n\nprivate void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)\n{\n if (sender is TextBox)\n {\n string text = (sender as TextBox).Text + e.Text;\n e.Handled = !NumEx.IsMatch(text);\n }\n else\n throw new NotImplementedException(\"TextBox_PreviewTextInput Can only Handle TextBoxes\");\n}\n <TextBox Text=\"{Binding Number, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}\"/>\n"
},
{
"answer_id": 2122964,
"author": "Ritz",
"author_id": 257370,
"author_profile": "https://Stackoverflow.com/users/257370",
"pm_score": 1,
"selected": false,
"text": "Private Sub Value1TextBox_PreviewTextInput(ByVal sender As Object, ByVal e As TextCompositionEventArgs) Handles Value1TextBox.PreviewTextInput\n Try\n If Not IsNumeric(e.Text) Then\n e.Handled = True\n End If\n Catch ex As Exception\n End Try\nEnd Sub\n"
},
{
"answer_id": 2165796,
"author": "bcd",
"author_id": 262212,
"author_profile": "https://Stackoverflow.com/users/262212",
"pm_score": 1,
"selected": false,
"text": "void PreviewTextInputHandler(object sender, TextCompositionEventArgs e)\n{\n string sVal = e.Text;\n int val = 0;\n\n if (sVal != null && sVal.Length > 0)\n {\n if (int.TryParse(sVal, out val))\n {\n e.Handled = false;\n }\n else\n {\n e.Handled = true;\n }\n }\n}\n"
},
{
"answer_id": 2673131,
"author": "juanagui",
"author_id": 168435,
"author_profile": "https://Stackoverflow.com/users/168435",
"pm_score": 2,
"selected": false,
"text": "public class NumericTextBox : TextBox\n{\n public NumericTextBox()\n : base()\n {\n DataObject.AddPastingHandler(this, new DataObjectPastingEventHandler(CheckPasteFormat));\n }\n\n private Boolean CheckFormat(string text)\n {\n short val;\n return Int16.TryParse(text, out val);\n }\n\n private void CheckPasteFormat(object sender, DataObjectPastingEventArgs e)\n {\n var isText = e.SourceDataObject.GetDataPresent(System.Windows.DataFormats.Text, true);\n\n if (isText)\n {\n var text = e.SourceDataObject.GetData(DataFormats.Text) as string;\n if (CheckFormat(text))\n {\n return;\n }\n }\n\n e.CancelCommand();\n }\n\n protected override void OnPreviewTextInput(System.Windows.Input.TextCompositionEventArgs e)\n {\n if (!CheckFormat(e.Text))\n {\n e.Handled = true;\n }\n else\n {\n base.OnPreviewTextInput(e);\n }\n }\n}\n"
},
{
"answer_id": 2764514,
"author": "BrownBot",
"author_id": 332246,
"author_profile": "https://Stackoverflow.com/users/332246",
"pm_score": 2,
"selected": false,
"text": "protected override void OnPreviewKeyUp(System.Windows.Input.KeyEventArgs e)\n{\n base.OnPreviewKeyUp(e);\n\n if (BindingOperations.IsDataBound(this, TextBox.TextProperty))\n {\n if (this.Text.Length == 0)\n {\n this.SetValue(TextBox.TextProperty, \"0\");\n this.SelectAll();\n }\n }\n}\n"
},
{
"answer_id": 2824205,
"author": "erodewald",
"author_id": 24399,
"author_profile": "https://Stackoverflow.com/users/24399",
"pm_score": 4,
"selected": false,
"text": "e.Handled = !e.Text.All(Char.IsNumber);\nbase.OnPreviewTextInput(e);\n"
},
{
"answer_id": 4889675,
"author": "Dead.Rabit",
"author_id": 424963,
"author_profile": "https://Stackoverflow.com/users/424963",
"pm_score": 2,
"selected": false,
"text": "protected override void OnPreviewTextInput( System.Windows.Input.TextCompositionEventArgs e )\n{\n try\n {\n if ( String.IsNullOrEmpty( SelectedText ) )\n {\n Convert.ToDecimal( this.Text.Insert( this.CaretIndex, e.Text ) );\n }\n else\n {\n Convert.ToDecimal( this.Text.Remove( this.SelectionStart, this.SelectionLength ).Insert( this.SelectionStart, e.Text ) );\n }\n }\n catch\n {\n // mark as handled if cannot convert string to decimal\n e.Handled = true;\n }\n\n base.OnPreviewTextInput( e );\n}\n"
},
{
"answer_id": 5546415,
"author": "Jroonk",
"author_id": 692098,
"author_profile": "https://Stackoverflow.com/users/692098",
"pm_score": 2,
"selected": false,
"text": "private void NumericKeyDown(object sender, System.Windows.Input.KeyEventArgs e)\n{\n bool isNumPadNumeric = (e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9);\n bool isNumeric =((e.Key >= Key.D0 && e.Key <= Key.D9) && (e.KeyboardDevice.Modifiers == ModifierKeys.None));\n bool isDecimal = ((e.Key == Key.OemPeriod || e.Key == Key.Decimal) && (((TextBox)sender).Text.IndexOf('.') < 0));\n e.Handled = !(isNumPadNumeric || isNumeric || isDecimal);\n}\n"
},
{
"answer_id": 8998307,
"author": "Jonny Ots",
"author_id": 712714,
"author_profile": "https://Stackoverflow.com/users/712714",
"pm_score": 2,
"selected": false,
"text": "ValidationRule public class DoubleValidation : ValidationRule\n{\n public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)\n {\n if (value is string)\n {\n double number;\n if (!Double.TryParse((value as string), out number))\n return new ValidationResult(false, \"Please enter a valid number\");\n }\n\n return ValidationResult.ValidResult;\n }\n TextBox Binding.ValidationRules TextBox.Text <TextBox>\n <TextBox.Text>\n <Binding Path=\"MyNumericProperty\" UpdateSourceTrigger=\"PropertyChanged\">\n <Binding.ValidationRules>\n <local:DoubleValidation/>\n </Binding.ValidationRules>\n </Binding>\n </TextBox.Text>\n</TextBox>\n"
},
{
"answer_id": 11858030,
"author": "Varun",
"author_id": 1583635,
"author_profile": "https://Stackoverflow.com/users/1583635",
"pm_score": 1,
"selected": false,
"text": "public class IntegerFormatConverter : IValueConverter\n{\n public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)\n {\n int result;\n int.TryParse(value.ToString(), out result);\n return result;\n }\n\n public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)\n {\n int result;\n int.TryParse(value.ToString(), out result);\n return result;\n }\n}\n"
},
{
"answer_id": 16807485,
"author": "Brian Hinchey",
"author_id": 62278,
"author_profile": "https://Stackoverflow.com/users/62278",
"pm_score": 2,
"selected": false,
"text": "public class NumericTextBox : TextBox\n{\n public NumericTextBox()\n {\n DataObject.AddPastingHandler(this, OnPaste);\n }\n\n private void OnPaste(object sender, DataObjectPastingEventArgs dataObjectPastingEventArgs)\n {\n var isText = dataObjectPastingEventArgs.SourceDataObject.GetDataPresent(System.Windows.DataFormats.Text, true);\n\n if (isText)\n {\n var text = dataObjectPastingEventArgs.SourceDataObject.GetData(DataFormats.Text) as string;\n if (IsTextValid(text))\n {\n return;\n }\n }\n\n dataObjectPastingEventArgs.CancelCommand();\n }\n\n private bool IsTextValid(string enteredText)\n {\n if (!enteredText.All(c => Char.IsNumber(c) || c == '.' || c == '-'))\n {\n return false;\n }\n\n //We only validation against unselected text since the selected text will be replaced by the entered text\n var unselectedText = this.Text.Remove(SelectionStart, SelectionLength);\n\n if (enteredText == \".\" && unselectedText.Contains(\".\"))\n {\n return false;\n }\n\n if (enteredText == \"-\" && unselectedText.Length > 0)\n {\n return false;\n }\n\n return true;\n }\n\n protected override void OnPreviewTextInput(System.Windows.Input.TextCompositionEventArgs e)\n {\n e.Handled = !IsTextValid(e.Text);\n base.OnPreviewTextInput(e);\n }\n}\n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/615/"
] |
5,611 | <p>I know that just using <code>rand()</code> is predictable, if you know what you're doing, and have access to the server.</p>
<p>I have a project that is <strong>highly</strong> dependent upon choosing a random number that is as unpredictable as possible. So I'm looking for suggestions, either other built-in functions or user functions, that can generate a <em>better</em> random number.</p>
<p>I used this to do a little test:</p>
<pre><code>$i = 0;
while($i < 10000){
$rand = rand(0, 100);
if(!isset($array[$rand])){
$array[$rand] = 1;
} else {
$array[$rand]++;
}
sort($array);
$i++;
}
</code></pre>
<p>I found the results to be evenly distributed, and there is an odd pattern to the number of times each number is generated.</p>
| [
{
"answer_id": 18867906,
"author": "Aaron Gong",
"author_id": 2215486,
"author_profile": "https://Stackoverflow.com/users/2215486",
"pm_score": 2,
"selected": false,
"text": "openssl_random_pseudo_bytes(...)\n"
},
{
"answer_id": 31444887,
"author": "Salvador Dali",
"author_id": 1090562,
"author_profile": "https://Stackoverflow.com/users/1090562",
"pm_score": 1,
"selected": false,
"text": "int random_int ( int $min , int $max )\n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/115/"
] |
5,628 | <p>I want some links to include a fragment identifier. Like some of the URLs on this site:</p>
<p><a href="https://stackoverflow.com/questions/5619/ie6-ssl-ajax-post-form-404-error">Debugging: IE6 + SSL + AJAX + post form = 404 error</a><strong>#5626</strong></p>
<p>Is there a way to do this with any of the built-in methods in MVC? Or would I have to roll my own HTML helpers?</p>
| [
{
"answer_id": 7151,
"author": "Dominic Cooney",
"author_id": 878,
"author_profile": "https://Stackoverflow.com/users/878",
"pm_score": 1,
"selected": false,
"text": "routes.MapRoute(\"WithTarget\", \"{controller}/{action}/{id}#{target}\");\n...\n<%= Html.ActionLink(\"Home\", \"Index\", new { target = \"foo\" })%>\n"
},
{
"answer_id": 30614,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 2,
"selected": false,
"text": "<%= Html.ActionLink(\"Home\", \"Index\") %>\n <a href='<%= Url.Action(\"Index\") %>#2345'>Home</a>\n"
},
{
"answer_id": 1241929,
"author": "LorenzCK",
"author_id": 3118,
"author_profile": "https://Stackoverflow.com/users/3118",
"pm_score": 4,
"selected": false,
"text": "public class RedirectToRouteResultEx : RedirectToRouteResult {\n\n public RedirectToRouteResultEx(RouteValueDictionary values)\n : base(values) {\n }\n\n public RedirectToRouteResultEx(string routeName, RouteValueDictionary values)\n : base(routeName, values) {\n }\n\n public override void ExecuteResult(ControllerContext context) {\n var destination = new StringBuilder();\n\n var helper = new UrlHelper(context.RequestContext);\n destination.Append(helper.RouteUrl(RouteName, RouteValues));\n\n //Add href fragment if set\n if (!string.IsNullOrEmpty(Fragment)) {\n destination.AppendFormat(\"#{0}\", Fragment);\n }\n\n context.HttpContext.Response.Redirect(destination.ToString(), false);\n }\n\n public string Fragment { get; set; }\n}\n\npublic static class RedirectToRouteResultExtensions {\n public static RedirectToRouteResultEx AddFragment(this RedirectToRouteResult result, string fragment) {\n return new RedirectToRouteResultEx(result.RouteName, result.RouteValues) {\n Fragment = fragment\n };\n }\n}\n return RedirectToAction(\"MyAction\", \"MyController\")\n .AddFragment(\"fragment-name\");\n"
},
{
"answer_id": 6768970,
"author": "voam",
"author_id": 177395,
"author_profile": "https://Stackoverflow.com/users/177395",
"pm_score": 0,
"selected": false,
"text": "<script language=\"javascript\" type=\"text/javascript\">\n $(function () {\n $('div.imageHolder > a').each(function () {\n $(this).attr('href', $(this).attr('href') + '#tab-works');\n });\n });\n</script>\n"
},
{
"answer_id": 7193912,
"author": "Joel",
"author_id": 236167,
"author_profile": "https://Stackoverflow.com/users/236167",
"pm_score": 2,
"selected": false,
"text": "public static string Action(this UrlHelper url, string actionName, string controllerName, string fragment, object routeValues)\n{\n return UrlHelper.GenerateUrl(\n routeName: null,\n actionName: actionName,\n controllerName: controllerName,\n routeValues: new System.Web.Routing.RouteValueDictionary(routeValues),\n fragment: fragment,\n protocol: null,\n hostName: null,\n routeCollection: url.RouteCollection,\n requestContext: url.RequestContext,\n includeImplicitMvcValues: true /*helps fill in the nulls above*/\n );\n}\n"
},
{
"answer_id": 30172386,
"author": "Theophilus",
"author_id": 2615878,
"author_profile": "https://Stackoverflow.com/users/2615878",
"pm_score": 0,
"selected": false,
"text": "ActionLink"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/653/"
] |
5,629 | <p></p>
<p>It is supposed to be backwards compatible with HTML4 and XHTML. <a href="http://ejohn.org/blog/html5-doctype/" rel="nofollow noreferrer">John Resig posted about some of the benefits</a>.</p>
<p>As long as we don't use any of the new and not supported yet features, would there be any downside to start building sites with this doctype?</p>
| [
{
"answer_id": 7030883,
"author": "Faraz Kelhini",
"author_id": 530659,
"author_profile": "https://Stackoverflow.com/users/530659",
"pm_score": 0,
"selected": false,
"text": "http://hsivonen.iki.fi/doctype/"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/653/"
] |
5,649 | <p>Does anyone know of any good tools (I'm looking for IDEs) to write assembly on the Mac. Xcode is a little cumbersome to me.</p>
<p>Also, on the Intel Macs, can I use generic x86 asm? Or is there a modified instruction set? Any information about post Intel.</p>
<p>Also: I know that on windows, asm can run in an emulated environment created by the OS to let the code think it's running on its own dedicated machine. Does OS X provide the same thing?</p>
| [
{
"answer_id": 357113,
"author": "David DeHaven",
"author_id": 45095,
"author_profile": "https://Stackoverflow.com/users/45095",
"pm_score": 5,
"selected": false,
"text": "__dyld_misaligned_stack_error ; File: hello.asm\n; Build: nasm -f macho hello.asm && gcc -o hello hello.o\n\nSECTION .rodata\nhello.msg db 'Hello, World!',0x0a,0x00\n\nSECTION .text\n\nextern _printf ; could also use _puts...\nGLOBAL _main\n\n; aligns esp to 16 bytes in preparation for calling a C library function\n; arg is number of bytes to pad for function arguments, this should be a multiple of 16\n; unless you are using push/pop to load args\n%macro clib_prolog 1\n mov ebx, esp ; remember current esp\n and esp, 0xFFFFFFF0 ; align to next 16 byte boundary (could be zero offset!)\n sub esp, 12 ; skip ahead 12 so we can store original esp\n push ebx ; store esp (16 bytes aligned again)\n sub esp, %1 ; pad for arguments (make conditional?)\n%endmacro\n\n; arg must match most recent call to clib_prolog\n%macro clib_epilog 1\n add esp, %1 ; remove arg padding\n pop ebx ; get original esp\n mov esp, ebx ; restore\n%endmacro\n\n_main:\n ; set up stack frame\n push ebp\n mov ebp, esp\n push ebx\n\n clib_prolog 16\n mov dword [esp], hello.msg\n call _printf\n ; can make more clib calls here...\n clib_epilog 16\n\n ; tear down stack frame\n pop ebx\n mov esp, ebp\n pop ebp\n mov eax, 0 ; set return code\n ret\n"
},
{
"answer_id": 17800896,
"author": "Jared Burrows",
"author_id": 950427,
"author_profile": "https://Stackoverflow.com/users/950427",
"pm_score": 3,
"selected": false,
"text": "-o hello.tmp - outfile\n-f macho - specify format\nLinux - elf or elf64\nMac OSX - macho\n -arch i386 - specify architecture (32 bit assembly)\n-macosx_version_min 10.6 (Mac OSX - complains about default specification)\n-no_pie (Mac OSX - removes ld warning)\n-e main - specify main symbol name (Mac OSX - default is start)\n-o hello.o - outfile\n ./hello.o - execution\n nasm -o hello.tmp -f macho hello.s && ld -arch i386 -macosx_version_min 10.6 -no_pie -e _main -o hello.o hello.tmp && ./hello.o\n"
},
{
"answer_id": 48446402,
"author": "Akhzar Nazir",
"author_id": 8080276,
"author_profile": "https://Stackoverflow.com/users/8080276",
"pm_score": 3,
"selected": false,
"text": "brew install nasm nasm -f macho64 myFile.asm ld -macosx_version_min 10.7.0 -lSystem -o OutPutFile myFile.o && ./64 global start\nsection .text\n\nstart:\n mov rax, 0x2000004 ; write\n mov rdi, 1 ; stdout\n mov rsi, msg\n mov rdx, msg.len\n syscall\n\n mov rax, 0x2000001 ; exit\n mov rdi, 0\n syscall\n\nsection .data\n\nmsg: db \"Assalam O Alaikum Dear\", 10\n.len: equ $ - msg\n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/703/"
] |
5,667 | <p>What's the best way to do the semantic equivalent of the traditional sleep() system call from within an Informix SPL routine? In other words, simply "pause" for N seconds (or milliseconds or whatever, but seconds are fine). I'm looking for a solution that does <em>not</em> involve linking some new (perhaps written by me) C code or other library into the Informix server. This has to be something I can do purely from SPL. A solution for IDS 10 or 11 would be fine.</p>
<p>@RET - The "obvious" answer wasn't obvious to me! I didn't know about the SYSTEM command. Thank you! (And yes, I'm the guy you think I am.)</p>
<hr>
<p>Yes, it's for debugging purposes only. Unfortunately, CURRENT within an SPL will always return the same value, set at the entry to the call:</p>
<blockquote><p><i>"any call to CURRENT from inside the SPL function that an EXECUTE FUNCTION (or EXECUTE PROCEDURE) statement invokes returns the value of the system clock when the SPL function starts."</i></p>
—<a href="http://publib.boulder.ibm.com/infocenter/idshelp/v10/topic/com.ibm.sqls.doc/sqls1011.htm" rel="nofollow noreferrer">IBM Informix Guide to SQL</a></p></blockquote>
<p>Wrapping CURRENT in its own subroutine does not help. You do get a different answer on the first call to your wrapper (provided you're using YEAR TO FRACTION(5) or some other type with high enough resolution to show the the difference) but then you get that same value back on every single subsequent call, which ensures that any sort of loop will never terminate.</p>
| [
{
"answer_id": 80353,
"author": "RET",
"author_id": 14750,
"author_profile": "https://Stackoverflow.com/users/14750",
"pm_score": 3,
"selected": true,
"text": "SYSTEM \"sleep 5\""
},
{
"answer_id": 51524006,
"author": "robsosno",
"author_id": 229860,
"author_profile": "https://Stackoverflow.com/users/229860",
"pm_score": 1,
"selected": false,
"text": "integer sysadmin:yieldn( integer nseconds )\n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/164/"
] |
5,682 | <p>I'm not sure if it's my system, although I haven't done anything unusual with it, but I've started noticing incorrectly rendered characters popping up in web pages, text-files, <a href="http://ejohn.org/blog/html5-doctype/" rel="nofollow noreferrer">like this</a>:</p>
<p><a href="http://www.kbssource.com/strange-characters.gif" rel="nofollow noreferrer">http://www.kbssource.com/strange-characters.gif</a></p>
<p>I have a hunch it's a related to the fairly recent trend to use unicode for everything, which is a good thing I think, combined with fonts that don't support all possible characters.</p>
<p>So, does anyone know what's causing these blips (am I right?), and how do I stop this showing up in my own content?</p>
| [
{
"answer_id": 5720,
"author": "Mark Harrison",
"author_id": 116,
"author_profile": "https://Stackoverflow.com/users/116",
"pm_score": 0,
"selected": false,
"text": "____\n#include <stdio.h>\n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/117/"
] |
5,694 | <p>I got this error today when trying to open a Visual Studio 2008 <strong>project</strong> in Visual Studio 2005:</p>
<blockquote>
<p>The imported project "C:\Microsoft.CSharp.targets" was not found.</p>
</blockquote>
| [
{
"answer_id": 5695,
"author": "lomaxx",
"author_id": 493,
"author_profile": "https://Stackoverflow.com/users/493",
"pm_score": 8,
"selected": true,
"text": "<Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\n <Import Project=\"$(MSBuildBinPath)\\Microsoft.CSharp.targets\" />\n"
},
{
"answer_id": 7239367,
"author": "stack247",
"author_id": 661900,
"author_profile": "https://Stackoverflow.com/users/661900",
"pm_score": 2,
"selected": false,
"text": "Microsoft.WebApplications.targets Microsoft.WebApplication.targets"
},
{
"answer_id": 13995747,
"author": "appenthused",
"author_id": 1017156,
"author_profile": "https://Stackoverflow.com/users/1017156",
"pm_score": 3,
"selected": false,
"text": "<Import Project=\"$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v10.0\\WebApplications\\Microsoft.WebApplication.targets\" />\n"
},
{
"answer_id": 18078170,
"author": "Greg Gum",
"author_id": 425823,
"author_profile": "https://Stackoverflow.com/users/425823",
"pm_score": 1,
"selected": false,
"text": "<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>\n"
},
{
"answer_id": 38782270,
"author": "Alf Moh",
"author_id": 5138921,
"author_profile": "https://Stackoverflow.com/users/5138921",
"pm_score": 3,
"selected": false,
"text": "Microsoft.CSharp.Core.targets not found Projects/(working project name)/packages/Microsoft.Net.Compilers.1.3.2/tools/ Microsoft.CSharp.Core.targets tools folder Tools > NuGetPackage Manager > Manage NuGet Packages For Solution tools folder Manage NuGet Packages For Solution"
},
{
"answer_id": 42238377,
"author": "Gichamba",
"author_id": 487030,
"author_profile": "https://Stackoverflow.com/users/487030",
"pm_score": 2,
"selected": false,
"text": "<Import Project=\"..\\packages\\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\\build\\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props\" Condition=\"Exists('..\\packages\\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\\build\\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')\" />\n<Import Project=\"..\\packages\\Microsoft.Net.Compilers.1.0.0\\build\\Microsoft.Net.Compilers.props\" Condition=\"Exists('..\\packages\\Microsoft.Net.Compilers.1.0.0\\build\\Microsoft.Net.Compilers.props')\" />\n<Import Project=\"..\\packages\\Microsoft.Net.Compilers.1.3.2\\build\\Microsoft.Net.Compilers.props\" Condition=\"Exists('..\\packages\\Microsoft.Net.Compilers.1.3.2\\build\\Microsoft.Net.Compilers.props')\" />\n"
},
{
"answer_id": 47452127,
"author": "Vojta",
"author_id": 2524260,
"author_profile": "https://Stackoverflow.com/users/2524260",
"pm_score": 4,
"selected": false,
"text": "Microsoft.Net.Compilers.1.3.2 packages"
},
{
"answer_id": 49113817,
"author": "WholeLifeLearner",
"author_id": 1528883,
"author_profile": "https://Stackoverflow.com/users/1528883",
"pm_score": 0,
"selected": false,
"text": "[...]\\VisualStudio\\v12.0\\WebApplications\\Microsoft.WebApplication.targets\"\n [...]\\VisualStudio\\v$(VisualStudioVersion)\\WebApplications\\Microsoft.WebApplication.targets\"\n"
},
{
"answer_id": 66758114,
"author": "Andreas",
"author_id": 6344387,
"author_profile": "https://Stackoverflow.com/users/6344387",
"pm_score": 0,
"selected": false,
"text": "\"Sample%20-%205\" \"Sample - 5\""
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/493/"
] |
5,724 | <p>Is there a better windows command line shell other than <code>cmd</code> which has better copy paste between Windows' windows and console windows?</p>
| [
{
"answer_id": 9288730,
"author": "Zombo",
"author_id": 1002260,
"author_profile": "https://Stackoverflow.com/users/1002260",
"pm_score": 0,
"selected": false,
"text": "~/.profile"
},
{
"answer_id": 12438973,
"author": "Erik Kaplun",
"author_id": 247623,
"author_profile": "https://Stackoverflow.com/users/247623",
"pm_score": 0,
"selected": false,
"text": "cmd.exe cmd.exe mintty"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/108465/"
] |
5,727 | <p>Why are pointers such a leading factor of confusion for many new, and even old, college level students in C or C++? Are there any tools or thought processes that helped you understand how pointers work at the variable, function, and beyond level?</p>
<p>What are some good practice things that can be done to bring somebody to the level of, "Ah-hah, I got it," without getting them bogged down in the overall concept? Basically, drill like scenarios.</p>
| [
{
"answer_id": 5728,
"author": "Josh",
"author_id": 257,
"author_profile": "https://Stackoverflow.com/users/257",
"pm_score": 5,
"selected": false,
"text": "struct {\nchar a;\nchar b;\nchar c;\nchar d;\n} mystruct;\nmystruct.a = 'r';\nmystruct.b = 's';\nmystruct.c = 't';\nmystruct.d = 'u';\n\nchar* my_pointer;\nmy_pointer = &mystruct.b;\ncout << 'Start: my_pointer = ' << *my_pointer << endl;\nmy_pointer++;\ncout << 'After: my_pointer = ' << *my_pointer << endl;\nmy_pointer = &mystruct.a;\ncout << 'Then: my_pointer = ' << *my_pointer << endl;\nmy_pointer = my_pointer + 3;\ncout << 'End: my_pointer = ' << *my_pointer << endl;\n // Same example as above, except in C:\nstruct {\n char a;\n char b;\n char c;\n char d;\n} mystruct;\n\nmystruct.a = 'r';\nmystruct.b = 's';\nmystruct.c = 't';\nmystruct.d = 'u';\n\nchar* my_pointer;\nmy_pointer = &mystruct.b;\n\nprintf(\"Start: my_pointer = %c\\n\", *my_pointer);\nmy_pointer++;\nprintf(\"After: my_pointer = %c\\n\", *my_pointer);\nmy_pointer = &mystruct.a;\nprintf(\"Then: my_pointer = %c\\n\", *my_pointer);\nmy_pointer = my_pointer + 3;\nprintf(\"End: my_pointer = %c\\n\", *my_pointer);\n Start: my_pointer = s\nAfter: my_pointer = t\nThen: my_pointer = r\nEnd: my_pointer = u\n"
},
{
"answer_id": 5735,
"author": "grom",
"author_id": 486,
"author_profile": "https://Stackoverflow.com/users/486",
"pm_score": 0,
"selected": false,
"text": "int* my_int_pointer;\n"
},
{
"answer_id": 5754,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 11,
"selected": true,
"text": "type\n THouse = class\n private\n FName : array[0..9] of Char;\n public\n constructor Create(name: PChar);\n end;\n THouse.Create('My house');\n var\n h: THouse;\nbegin\n h := THouse.Create('My house');\n ...\n var\n h1, h2: THouse;\nbegin\n h1 := THouse.Create('My house');\n h2 := h1; // copies the address, not the house\n ...\n var\n h: THouse;\nbegin\n h := THouse.Create('My house');\n ...\n h.Free;\n h := nil;\n var\n h: THouse;\nbegin\n h := THouse.Create('My house');\n ...\n h.Free;\n ... // forgot to clear h here\n h.OpenFrontDoor; // will most likely fail\n h .Free var\n h: THouse;\nbegin\n h := THouse.Create('My house');\n h := THouse.Create('My house'); // uh-oh, what happened to our first house?\n ...\n h.Free;\n h := nil;\n h procedure OpenTheFrontDoorOfANewHouse;\nvar\n h: THouse;\nbegin\n h := THouse.Create('My house');\n h.OpenFrontDoor;\n // uh-oh, no .Free here, where does the address go?\nend;\n var\n h1, h2: THouse;\nbegin\n h1 := THouse.Create('My house');\n h2 := h1; // copies the address, not the house\n ...\n h1.Free;\n h1 := nil;\n h2.OpenFrontDoor; // uh-oh, what happened to our house?\n h1 h1 h2 var\n h1, h2: THouse;\nbegin\n h1 := THouse.Create('My house');\n h2 := THouse.Create('My other house somewhere');\n ^-----------------------^\n longer than 10 characters\n 0123456789 <-- 10 characters\n var\n h1, h2: THouse;\nbegin\n h1 := THouse.Create('Home');\n h2 := THouse.Create('Cabin');\n h1.NextHouse := h2;\n NextHouse var\n h1, h2: THouse;\n h: THouse;\nbegin\n h1 := THouse.Create('Home');\n h2 := THouse.Create('Cabin');\n h1.NextHouse := h2;\n ...\n h := h1;\n while h <> nil do\n begin\n h.LockAllDoors;\n h.CloseAllWindows;\n h := h.NextHouse;\n end;\n"
},
{
"answer_id": 6416,
"author": "Tryke",
"author_id": 773,
"author_profile": "https://Stackoverflow.com/users/773",
"pm_score": 7,
"selected": false,
"text": "int john; int *sally = &john; int *bill = sally; int sam; bill = &sam;"
},
{
"answer_id": 7271,
"author": "Derek Park",
"author_id": 872,
"author_profile": "https://Stackoverflow.com/users/872",
"pm_score": 4,
"selected": false,
"text": "widget->wazzle.fizzle = fazzle.foozle->wazzle;\n"
},
{
"answer_id": 758499,
"author": "Breton",
"author_id": 51101,
"author_profile": "https://Stackoverflow.com/users/51101",
"pm_score": 3,
"selected": false,
"text": "int doIt(char *buffer )\n//*buffer is a pointer to the buffer\n doIt(mybuffer) doIt(*myBuffer) doIt(&mybuffer) doIt(mybuffer) doIt(*mybuffer) doIt(&mybuffer) doIt(&&mybuffer) doIt(&&&mybuffer)"
},
{
"answer_id": 761227,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "int *mypointer;\n * int* mypointer;\n"
},
{
"answer_id": 2057116,
"author": "Ryan Lundy",
"author_id": 5486,
"author_profile": "https://Stackoverflow.com/users/5486",
"pm_score": 5,
"selected": false,
"text": "int puts(const char *s);\n const. puts() puts(strA);"
},
{
"answer_id": 15842434,
"author": "Mike",
"author_id": 1348709,
"author_profile": "https://Stackoverflow.com/users/1348709",
"pm_score": 3,
"selected": false,
"text": "-------------------\n| | | |\n| 1 | 2 | 3 |\n| | | |\n parking_lot[3] = {0} 1 2 3\n-------------------\n| o=o | o=o | o=o |\n| |B| | |R| | |G| |\n| o-o | o-o | o-o |\n int blue red green enum int *finger = parking_lot int **finger_two = &finger 1 2 3\n-------------------\n| o=o | | o=o |\n| |B| | | |G| |\n| o-o | | o-o |\n 1 2 3\n-------------------\n| o=o | o=o | o=o |\n| |B| | |O| | |G| |\n| o-o | o-o | o-o |\n finger+1 *(finger+1)"
},
{
"answer_id": 16694780,
"author": "sashoalm",
"author_id": 492336,
"author_profile": "https://Stackoverflow.com/users/492336",
"pm_score": 2,
"selected": false,
"text": "unsigned char RAM[10] = { 10, 14, 4, 3, 2, 1, 20, 19, 50, 9 };\n unsigned char index = 2 RAM[RAM[index]]"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/568/"
] |
5,759 | <p>I just moved over to the Visual Basic team here at work.</p>
<p>What is the equivalent keyword to <code>break</code> in Visual Basic, that is, to exit a loop early but not the method?</p>
| [
{
"answer_id": 5761,
"author": "John",
"author_id": 33,
"author_profile": "https://Stackoverflow.com/users/33",
"pm_score": 9,
"selected": true,
"text": "Exit For Wend Exit Do"
},
{
"answer_id": 5782,
"author": "Eric Haskins",
"author_id": 100,
"author_profile": "https://Stackoverflow.com/users/100",
"pm_score": 2,
"selected": false,
"text": "Exit"
},
{
"answer_id": 16022965,
"author": "Ayman El Temsahi",
"author_id": 2205080,
"author_profile": "https://Stackoverflow.com/users/2205080",
"pm_score": 3,
"selected": false,
"text": "Exit Sub\n Exit Function \n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/713/"
] |
5,787 | <p>I'm just in the process of parsing some text and can't remember what the escape character is for a tab in C#?</p>
| [
{
"answer_id": 35949455,
"author": "andrew.fox",
"author_id": 257470,
"author_profile": "https://Stackoverflow.com/users/257470",
"pm_score": 3,
"selected": false,
"text": "string Environment.Newline"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383/"
] |
5,791 | <p>Does anyone here use VB.NET and have a strong preference for or against using <code>IsNothing</code> as opposed to <code>Is Nothing</code> (for example, <code>If IsNothing(anObject)</code> or <code>If anObject Is Nothing...</code>)? If so, why?</p>
<p>EDIT: If you think they're both equally acceptable, do you think it's best to pick one and stick with it, or is it OK to mix them?</p>
| [
{
"answer_id": 5889,
"author": "proudgeekdad",
"author_id": 702,
"author_profile": "https://Stackoverflow.com/users/702",
"pm_score": 5,
"selected": false,
"text": "If printDialog IsNot Nothing Then\n 'blah\nEnd If\n If Not obj Is Nothing Then\n 'blah\nEnd If\n"
},
{
"answer_id": 24494417,
"author": "KyleMit",
"author_id": 1366033,
"author_profile": "https://Stackoverflow.com/users/1366033",
"pm_score": 5,
"selected": false,
"text": "IsNothing() IsNothing(object) Nothing Dim i As Integer\n If IsNothing(i) Then\n ' Do something \n End If\n Dim i As Integer\n If i Is Nothing Then\n ' Do something \n End If\n IsNothing(object) Microsoft.VisualBasic.dll IsNothing() x If a IsNot Nothing If Not IsNothing(a)"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/133/"
] |
5,802 | <p>Is there any way to use inheritance in database (Specifically in SQL Server 2005)?</p>
<p>Suppose I have few field like <strong>CreatedOn</strong>, <strong>CreatedBy</strong> which I want to add on all of my entities. I looking for an alternative way instead of adding these fields to every table.</p>
| [
{
"answer_id": 5807,
"author": "Neall",
"author_id": 619,
"author_profile": "https://Stackoverflow.com/users/619",
"pm_score": 2,
"selected": false,
"text": "INHERITS FROM (tablename[, othertable...])\n"
},
{
"answer_id": 69658,
"author": "decibel",
"author_id": 11116,
"author_profile": "https://Stackoverflow.com/users/11116",
"pm_score": 0,
"selected": false,
"text": "CREATE TABLE blah (\n blah_id serial PRIMARY KEY\n , something text NOT NULL\n , LIKE template_table INCLUDING DEFALUTS\n);\n"
},
{
"answer_id": 86900,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 0,
"selected": false,
"text": "create table Object (\n Id int NOT NULL --primary key, auto-increment\n Name varchar(32)\n)\ncreate table SubObject (\n Id int NOT NULL --primary key and also foreign key to Object\n Description varchar(32)\n)\n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/191/"
] |
5,821 | <p>How do I escape the underscore character?</p>
<p>I am writing something like the following where clause and want to be able to find actual entries with _d at the end.</p>
<pre><code>Where Username Like '%_d'
</code></pre>
| [
{
"answer_id": 5822,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 10,
"selected": true,
"text": "... LIKE '%[_]d'\n"
},
{
"answer_id": 10415670,
"author": "Gerardo Lima",
"author_id": 394042,
"author_profile": "https://Stackoverflow.com/users/394042",
"pm_score": 8,
"selected": false,
"text": "LIKE WHERE username LIKE '%[_]d'; -- @Lasse solution\nWHERE username LIKE '%$_d' ESCAPE '$';\nWHERE username LIKE '%^_d' ESCAPE '^';\n"
},
{
"answer_id": 50650186,
"author": "Tek Mailer",
"author_id": 5697368,
"author_profile": "https://Stackoverflow.com/users/5697368",
"pm_score": 3,
"selected": false,
"text": "select *\nfrom information_schema.columns \nwhere replace(table_name,'_','!') not like '%!%'\norder by table_name\n"
},
{
"answer_id": 52702908,
"author": "Arnór Barkarson",
"author_id": 7436253,
"author_profile": "https://Stackoverflow.com/users/7436253",
"pm_score": 2,
"selected": false,
"text": "'%\\_%'"
},
{
"answer_id": 56812000,
"author": "wolverine87",
"author_id": 7885982,
"author_profile": "https://Stackoverflow.com/users/7885982",
"pm_score": 1,
"selected": false,
"text": "WHERE CHARINDEX('_', thingyoursearching) < 1 WHERE CHARINDEX('_', thingyoursearching) > 0"
},
{
"answer_id": 64153299,
"author": "Freddy Madsen",
"author_id": 12632795,
"author_profile": "https://Stackoverflow.com/users/12632795",
"pm_score": 3,
"selected": false,
"text": "'%_%' '%\\_%' \\ '%\\\\_%' \\\\ \\"
},
{
"answer_id": 66069453,
"author": "Alex C.",
"author_id": 2349128,
"author_profile": "https://Stackoverflow.com/users/2349128",
"pm_score": 3,
"selected": false,
"text": "[ ] like '%[\\\\_]%'\n"
},
{
"answer_id": 71712662,
"author": "Zosoled",
"author_id": 12221876,
"author_profile": "https://Stackoverflow.com/users/12221876",
"pm_score": 0,
"selected": false,
"text": "SELECT * FROM table WHERE email LIKE '%@%\\_%' ESCAPE '\\'\n SELECT * FROM table WHERE email LIKE '%@%!_%' ESCAPE '!'\n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383/"
] |
5,831 | <p>Does anyone have, or know of, a binary patch generation algorithm implementation in C#?</p>
<p>Basically, compare two files (designated <em>old</em> and <em>new</em>), and produce a patch file that can be used to upgrade the <em>old</em> file to have the same contents as the <em>new</em> file.</p>
<p>The implementation would have to be relatively fast, and work with huge files. It should exhibit O(n) or O(logn) runtimes.</p>
<p>My own algorithms tend to either be lousy (fast but produce huge patches) or slow (produce small patches but have O(n^2) runtime).</p>
<p>Any advice, or pointers for implementation would be nice.</p>
<p>Specifically, the implementation will be used to keep servers in sync for various large datafiles that we have one master server for. When the master server datafiles change, we need to update several off-site servers as well.</p>
<p>The most naive algorithm I have made, which only works for files that can be kept in memory, is as follows:</p>
<ol>
<li>Grab the first four bytes from the <em>old</em> file, call this the <em>key</em></li>
<li>Add those bytes to a dictionary, where <em>key -> position</em>, where <em>position</em> is the position where I grabbed those 4 bytes, 0 to begin with</li>
<li>Skip the first of these four bytes, grab another 4 (3 overlap, 1 one), and add to the dictionary the same way</li>
<li>Repeat steps 1-3 for all 4-byte blocks in the <em>old</em> file</li>
<li>From the start of the <em>new</em> file, grab 4 bytes, and attempt to look it up in the dictionary</li>
<li>If found, find the longest match if there are several, by comparing bytes from the two files</li>
<li>Encode a reference to that location in the <em>old</em> file, and skip the matched block in the <em>new</em> file</li>
<li>If not found, encode 1 byte from the <em>new</em> file, and skip it</li>
<li>Repeat steps 5-8 for the rest of the <em>new</em> file</li>
</ol>
<p>This is somewhat like compression, without windowing, so it will use a lot of memory. It is, however, fairly fast, and produces quite small patches, as long as I try to make the codes output minimal.</p>
<p>A more memory-efficient algorithm uses windowing, but produces much bigger patch files.</p>
<p>There are more nuances to the above algorithm that I skipped in this post, but I can post more details if necessary. I do, however, feel that I need a different algorithm altogether, so improving on the above algorithm is probably not going to get me far enough.</p>
<hr>
<p><strong>Edit #1</strong>: Here is a more detailed description of the above algorithm.</p>
<p>First, combine the two files, so that you have one big file. Remember the cut-point between the two files.</p>
<p>Secondly, do that <em>grab 4 bytes and add their position to the dictionary</em> step for everything in the whole file.</p>
<p>Thirdly, from where the <em>new</em> file starts, do the loop with attempting to locate an existing combination of 4 bytes, and find the longest match. Make sure we only consider positions from the old file, or from <em>earlier in the new file than we're currently at</em>. This ensures that we can reuse material in both the old and the new file during patch application.</p>
<hr>
<p><strong>Edit #2</strong>: <a href="http://code.google.com/p/lvknet/source/browse/trunk/LVK/IO/Patching/Binary/BinaryPatch.cs" rel="noreferrer">Source code to the above algorithm</a></p>
<p>You might get a warning about the certificate having some problems. I don't know how to resolve that so for the time being just accept the certificate.</p>
<p>The source uses lots of other types from the rest of my library so that file isn't all it takes, but that's the algorithm implementation.</p>
<hr>
<p>@lomaxx, I have tried to find a good documentation for the algorithm used in subversion, called xdelta, but unless you already know how the algorithm works, the documents I've found fail to tell me what I need to know.</p>
<p>Or perhaps I'm just dense... :)</p>
<p>I took a quick peek on the algorithm from that site you gave, and it is unfortunately not usable. A comment from the binary diff file says:</p>
<blockquote>
<p>Finding an optimal set of differences requires quadratic time relative to the input size, so it becomes unusable very quickly.</p>
</blockquote>
<p>My needs aren't optimal though, so I'm looking for a more practical solution.</p>
<p>Thanks for the answer though, added a bookmark to his utilities if I ever need them.</p>
<p><strong>Edit #1</strong>: Note, I will look at his code to see if I can find some ideas, and I'll also send him an email later with questions, but I've read that book he references and though the solution is good for finding optimal solutions, it is impractical in use due to the time requirements.</p>
<p><strong>Edit #2</strong>: I'll definitely hunt down the python xdelta implementation.</p>
| [
{
"answer_id": 4558990,
"author": "Bradley Grainger",
"author_id": 23633,
"author_profile": "https://Stackoverflow.com/users/23633",
"pm_score": 2,
"selected": false,
"text": "max(17*n,9*n+m)+O(1) O((n+m) log n) n m"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/267/"
] |
5,846 | <p>How do I turn the following 2 queries into 1 query</p>
<pre><code>$sql = "SELECT level FROM skills WHERE id = $id LIMIT 1;";
$result = $db->sql_query($sql);
$level = (int) $db->sql_fetchfield('level');
$db->sql_freeresult($result);
++$level;
$sql = "UPDATE skills SET level = $level WHERE id = $id;";
$result = $db->sql_query($sql);
$db->sql_freeresult($result);
</code></pre>
<p>I'm using it in a phpBB mod but the gist is that I grab the level, add one to it then update, it seems that it'd be much easier and faster if I could do it as one query.</p>
<p>Edit: <code>$id</code> has already been forced to be an integer, thus no escaping is needed this time.</p>
| [
{
"answer_id": 5848,
"author": "Josh",
"author_id": 257,
"author_profile": "https://Stackoverflow.com/users/257",
"pm_score": 6,
"selected": true,
"text": "$sql = \"UPDATE skills SET level = level+1 WHERE id = $id\";\n$result = $db->sql_query($sql);\n$db->sql_freeresult($result);\n $sql = \"UPDATE skills SET level = COALESCE(level,0)+1 WHERE id = $id\";\n level INT DEFAULT '0' NOT NULL\n"
},
{
"answer_id": 5849,
"author": "Mat",
"author_id": 48,
"author_profile": "https://Stackoverflow.com/users/48",
"pm_score": 2,
"selected": false,
"text": "$sql = \"UPDATE skills SET level = level + 1 WHERE id = $id\";\n $id"
},
{
"answer_id": 5850,
"author": "Karl Seguin",
"author_id": 34,
"author_profile": "https://Stackoverflow.com/users/34",
"pm_score": 2,
"selected": false,
"text": "UPDATE skills SET level = level + 1 WHERE id = $id\n"
},
{
"answer_id": 5851,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 4,
"selected": false,
"text": "UPDATE skills\nSET level = level + 1\nWHERE id = $id\n"
},
{
"answer_id": 5852,
"author": "Sean Carpenter",
"author_id": 729,
"author_profile": "https://Stackoverflow.com/users/729",
"pm_score": 1,
"selected": false,
"text": "UPDATE skills SET level = level + 1 WHERE id = $id;\n"
},
{
"answer_id": 5861,
"author": "Josh",
"author_id": 257,
"author_profile": "https://Stackoverflow.com/users/257",
"pm_score": -1,
"selected": false,
"text": "mysql_escape_string()"
},
{
"answer_id": 25535,
"author": "Imran",
"author_id": 1897,
"author_profile": "https://Stackoverflow.com/users/1897",
"pm_score": 3,
"selected": false,
"text": "$query = $db->prepare(\"UPDATE skills SET level = level + 1 WHERE id = :id\")\n$query->bindValue(\":id\", $id);\n$result = $query->execute();\n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] |
5,857 | <p>I have a page upon which a user can choose up to many different paragraphs. When the link is clicked (or button), an email will open up and put all those paragraphs into the body of the email, address it, and fill in the subject. However, the text can be too long for a mailto link.</p>
<p>Any way around this?</p>
<hr>
<p>We were thinking about having an SP from the SQL Server do it but the user needs a nice way of 'seeing' the email before they blast 50 executive level employees with items that shouldn't be sent...and of course there's the whole thing about doing IT for IT rather than doing software programming. 80(</p>
<p>When you build stuff for IT, it doesn't (some say shouldn't) have to be pretty just functional. In other words, this isn't the dogfood we wake it's just the dog food we have to eat.</p>
<hr>
<p>We started talking about it and decided that the 'mail form' would give us exactly what we are looking for.</p>
<ol>
<li>A very different look to let the user know that the gun is loaded
and aimed.</li>
<li>The ability to change/add text to the email.</li>
<li>Send a copy to themselves or not.</li>
<li>Can be coded quickly.</li>
</ol>
| [
{
"answer_id": 5860,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 5,
"selected": true,
"text": "<form action=\"mailto:[email protected]\">\n <input type=\"hidden\" name=\"Subject\" value=\"Email subject\">\n <input type=\"hidden\" name=\"Body\" value=\"Email body\">\n <input type=\"submit\">\n</form>\n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/730/"
] |
5,863 | <p>I'm just getting into creating some WCF services, but I have a requirement to make them backward compatible for legacy (.NET 1.1 and 2.0) client applications. </p>
<p>I've managed to get the services to run correctly for 3.0 and greater clients, but when I publish the services using a basicHttpBinding endpoint (which I believe is required for the compatibility I need), the service refactors my method signatures. e.g.</p>
<pre><code>public bool MethodToReturnTrue(string seedValue);
</code></pre>
<p>appears to the client apps as</p>
<pre><code>public void MethodToReturnTrue(string seedValue, out bool result, out bool MethodToReturnTrueResultSpecified);
</code></pre>
<p>I've tried every configuration parameter I can think of in the app.config for my self-hosting console app, but I can't seem to make this function as expected. I suppose this might lead to the fact that my expectations are flawed, but I'd be surprised that a WCF service is incapable of handling a bool return type to a down-level client.</p>
<p>My current app.config looks like this.</p>
<pre><code><?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="MyServiceTypeBehaviors" Name="MyCompany.Services.CentreService.CentreService">
<clear />
<endpoint address="http://localhost:8080/CSMEX" binding="basicHttpBinding" bindingConfiguration="" contract="IMetadataExchange" />
<endpoint address="http://localhost:8080/CentreService" binding="basicHttpBinding" bindingName="Compatible" name="basicEndpoint" contract="MyCompany.Services.CentreService.ICentreService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors" >
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
</code></pre>
<p>Can anyone advise, please?</p>
| [
{
"answer_id": 3810639,
"author": "Christian Hayter",
"author_id": 115413,
"author_profile": "https://Stackoverflow.com/users/115413",
"pm_score": 0,
"selected": false,
"text": "[ServiceContract(Namespace=\"CentreServiceNamespace\")]\n[XmlSerializerFormat(Style=OperationFormatStyle.Document, SupportFaults=true, Use=OperationFormatUse.Literal)]\npublic interface ICentreService {\n [OperationContract(Action=\"CentreServiceNamespace/MethodToReturnTrue\")]\n bool MethodToReturnTrue(string seedValue);\n}\n [XmlType] [DataContract]"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/377/"
] |
5,872 | <p>If you are working in PHP (or I guess any programming language) and using subversion as your source control, is there a way to take your project (for example):</p>
<blockquote>
<p>C:\Projects\test\.svn<br>
C:\Projects\test\docs\<br>
C:\Projects\test\faq.php<br>
C:\Projects\test\guestbook.php<br>
C:\Projects\test\index.php<br>
C:\Projects\test\test.php</p>
</blockquote>
<p>and build/copy/whatever it so it weeds out certain files and becomes:</p>
<blockquote>
<p>C:\Projects\test\faq.php<br>
C:\Projects\test\guestbook.php<br>
C:\Projects\test\index.php</p>
</blockquote>
<p>automatically? I'm getting tired of making a branch, and then going through the branch and deleting all of the ".svn" folders, the docs directory, and my prototyping files.</p>
<p>I know I could probably use a .bat file to only copy the specific files I want, but I was hoping there was some way with subversion to sort of pseudo ignore a file, to where it will still version it, but where you could make a snapshot of the project that ignores the files you told it to pseudo ignore.</p>
<p>I know I read online somewhere about some functionality that at least lets you copy without the .svn folders, but I can't find it now.</p>
| [
{
"answer_id": 5887,
"author": "Grant",
"author_id": 30,
"author_profile": "https://Stackoverflow.com/users/30",
"pm_score": 4,
"selected": true,
"text": "TortoiseSVN > Export .svn"
},
{
"answer_id": 6199,
"author": "cmcculloh",
"author_id": 58,
"author_profile": "https://Stackoverflow.com/users/58",
"pm_score": 1,
"selected": false,
"text": "rem replace the v1 directory with the export directory\nrd /s /q v1\nmove /y export\\newIMS v1\nrd /s /q export\n\nrem remove the prepDocs directory from the project\nrd /s /q v1\\prepDocs\n\nrem remove the scripts directory from the project\nrd /s /q v1\\scripts\n\nrem remove individual files from project\ndel v1\\.project\nrem del v1\\inc\\testLoad.html\nrem del v1\\inc\\testInc.js\n\nSET /P version=Please enter version number:\n\nrem zip the file up with 7-Zip and name it after whatever version number the user typed in.\n7z a -r v%version%.zip v1\n\nrem copy everything to the shared space ready for deployment\nxcopy v%version%.zip /s /q /y /i \"Z:\\IT\\IT Security\\IT Projects\\IMS\\v%version%.zip\"\nxcopy v1 /s /q /y /i \"Z:\\IT\\IT Security\\IT Projects\\IMS\\currentVersion\"\n\nrem keep the window open until user presses any key\nPAUSE\n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58/"
] |
5,876 | <p>I use <a href="http://www.thekelleys.org.uk/dnsmasq/doc.html" rel="nofollow noreferrer">dnsmasq</a> to resolve DNS queries on my home network. Unfortunately, if a domain name is not known, it will append my own domain name to the request which means that I always end up viewing my own site in a browser.</p>
<p>For example, if I enter <a href="http://dlksfhoiahdsfiuhsdf.com" rel="nofollow noreferrer">http://dlksfhoiahdsfiuhsdf.com</a> in a browser, I end up viewing my own site with that URL. If I try something like:</p>
<pre><code>host dlksfhoiahdsfiuhsdf.com
</code></pre>
<p>Instead of the expected:</p>
<pre><code>Host dlksfhoiahdsfiuhsdf.com not found: 3(NXDOMAIN)
</code></pre>
<p>I get this:</p>
<pre><code>dlksfhoiahdsfiuhsdf.com.mydomainname.com has address W.X.Y.Z.
</code></pre>
<p>Clearly, dnsmasq is appending my domain name to impossible name requests in an effort to resolve them, but I'd rather see the not found error instead.</p>
<p>I've tried playing with the <em>expand-hosts</em> and <em>domain</em> configuration settings, but to no avail. Is there anything else I can try?</p>
| [
{
"answer_id": 5980,
"author": "jj33",
"author_id": 430,
"author_profile": "https://Stackoverflow.com/users/430",
"pm_score": 2,
"selected": false,
"text": "host dlksfhoiahdsfiuhsdf.com.\n"
},
{
"answer_id": 342481,
"author": "benc",
"author_id": 2910,
"author_profile": "https://Stackoverflow.com/users/2910",
"pm_score": 1,
"selected": false,
"text": "benc$ host thing.one\nHost thing.one not found: 3(NXDOMAIN)\n benc$ cat /etc/resolv.conf \nnameserver 192.168.1.1\n benc$ cat /etc/resolv.conf \nsearch test.com\nnameserver 192.168.1.1\nbenc$ host thing.one\nthing.one.test.com has address 64.214.163.132\n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/726/"
] |
5,892 | <p>I've opened an old workspace that is a libray and its test harness. It used to work fine but now doesn't and older versions of the code don't work either with the same errors. I've tried recreating the project and that causes the same errors too. Nothing seems out of order in project settings and the code generated works in the main app.</p>
<p>I've stripped out most of the files and got it down to the bare minimum to generate the error. Unfortunately I can't post the project as this is used in production code.</p>
<p>The LNK2001 linker error I get usually means I've left off a library or forgot to implement a virtual function. However this is part of the standard template library - and is a header at that.</p>
<p>The code that is listed as having the problem in IOCompletionPort.obj doesn't actually use <code>std::string</code> directly, but does call a class that does: <code>Comms::Exception</code> accepts a <code>std::string</code> and the value of <code>GetLastError</code> or <code>WSAGetLastError</code>.</p>
<p>The function mentioned in the error (<code>GetMessage</code>) is implemented, but is a virtual function so other classes can override it if need be. However it appears that the compiler has made it as an Ansi version, but I can't find any options in the settings that would control that. I suspect that might be the problem but since there's very little in the way of options for the library I have no way of knowing for sure. However both projects to specify _MBCS in the compiler options.</p>
<blockquote>
<p>--------------------Configuration: TestComms - Win32 Debug-------------------- Linking... Comms.lib(IOCompletionPort.obj)
: error LNK2001: unresolved external symbol "public: virtual class
std::basic_string,class
std::allocator > __thiscall
Comms::Exception::GetMessageA(void)const " (?GetMessageA@
Exception@Comms@@UBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
Debug/TestComms.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.</p>
<p>TestComms.exe - 2 error(s), 0 warning(s)</p>
</blockquote>
<p>Any suggestions? I've lost most of the morning to this and don't want to lose most of the afternoon too.</p>
| [
{
"answer_id": 5903,
"author": "Curt Hagenlocher",
"author_id": 533,
"author_profile": "https://Stackoverflow.com/users/533",
"pm_score": 4,
"selected": true,
"text": "GetMessage GetMessageA GetMessageW GetMessage GetMessage GetMessage GetMessageA GetMessage GetMessageW Comms::Exception"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5892",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/342/"
] |
5,908 | <p>I need to get a log of user access to our <code>SQL Server</code> so I can track <strong>average</strong> and <strong>peak concurrency usage</strong>. Is there a hidden table or something I'm missing that has this information for me? To my knowledge the application I'm looking at does not track this at the application level.</p>
<p>I'm currently working on <code>SQL Server 2000</code>, but will moving to <code>SQL Server 2005</code> shortly, so solutions for both are greatly appreciated.</p>
| [
{
"answer_id": 5917,
"author": "SQLMenace",
"author_id": 740,
"author_profile": "https://Stackoverflow.com/users/740",
"pm_score": 3,
"selected": false,
"text": "2000 sp_who2 dbo.sysprocesses 2005 sys.dm_exec_sessions SELECT COUNT(*) AS StatusCount,CASE status \nWHEN 'Running' THEN 'Running - Currently running one or more requests' \nWHEN 'Sleeping ' THEN 'Sleeping - Currently running no requests' \nELSE 'Dormant – Session is in prelogin state' END status \nFROM sys.dm_exec_sessions \nGROUP BY status\n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/71/"
] |
5,909 | <p>I'm downloading an entire directory from a web server. It works OK, but I can't figure how to get the file size before download to compare if it was updated on the server or not. Can this be done as if I was downloading the file from a FTP server?</p>
<pre><code>import urllib
import re
url = "http://www.someurl.com"
# Download the page locally
f = urllib.urlopen(url)
html = f.read()
f.close()
f = open ("temp.htm", "w")
f.write (html)
f.close()
# List only the .TXT / .ZIP files
fnames = re.findall('^.*<a href="(\w+(?:\.txt|.zip)?)".*$', html, re.MULTILINE)
for fname in fnames:
print fname, "..."
f = urllib.urlopen(url + "/" + fname)
#### Here I want to check the filesize to download or not ####
file = f.read()
f.close()
f = open (fname, "w")
f.write (file)
f.close()
</code></pre>
<hr>
<p>@Jon: thank for your quick answer. It works, but the filesize on the web server is slightly less than the filesize of the downloaded file. </p>
<p>Examples:</p>
<pre><code>Local Size Server Size
2.223.533 2.115.516
664.603 662.121
</code></pre>
<p>It has anything to do with the CR/LF conversion?</p>
| [
{
"answer_id": 5927,
"author": "Jonathan Works",
"author_id": 309844,
"author_profile": "https://Stackoverflow.com/users/309844",
"pm_score": 3,
"selected": false,
"text": ">>> site = urllib.urlopen(\"http://python.org\")\n>>> meta = site.info()\n>>> print meta.getheaders(\"Content-Length\")\n['16535']\n>>>\n"
},
{
"answer_id": 5935,
"author": "dbr",
"author_id": 745,
"author_profile": "https://Stackoverflow.com/users/745",
"pm_score": 5,
"selected": false,
"text": "info() >>> import urllib\n>>> d = urllib.urlopen(\"http://www.google.co.uk/logos/olympics08_opening.gif\")\n>>> print d.info()\n\nContent-Type: image/gif\nLast-Modified: Thu, 07 Aug 2008 16:20:19 GMT \nExpires: Sun, 17 Jan 2038 19:14:07 GMT \nCache-Control: public \nDate: Fri, 08 Aug 2008 13:40:41 GMT \nServer: gws \nContent-Length: 20172 \nConnection: Close\n urllibobject.info()['Content-Length'] print f.info()['Content-Length']\n os.stat(\"/the/local/file.zip\").st_size\n"
},
{
"answer_id": 5985,
"author": "Jonathan Works",
"author_id": 309844,
"author_profile": "https://Stackoverflow.com/users/309844",
"pm_score": 6,
"selected": true,
"text": "import urllib, os\nlink = \"http://python.org\"\nprint \"opening url:\", link\nsite = urllib.urlopen(link)\nmeta = site.info()\nprint \"Content-Length:\", meta.getheaders(\"Content-Length\")[0]\n\nf = open(\"out.txt\", \"r\")\nprint \"File on disk:\",len(f.read())\nf.close()\n\n\nf = open(\"out.txt\", \"w\")\nf.write(site.read())\nsite.close()\nf.close()\n\nf = open(\"out.txt\", \"r\")\nprint \"File on disk after download:\",len(f.read())\nf.close()\n\nprint \"os.stat().st_size returns:\", os.stat(\"out.txt\").st_size\n opening url: http://python.org\nContent-Length: 16535\nFile on disk: 16535\nFile on disk after download: 16535\nos.stat().st_size returns: 16861\n import urllib, os\nlink = \"http://python.org\"\nprint \"opening url:\", link\nsite = urllib.urlopen(link)\nmeta = site.info()\nprint \"Content-Length:\", meta.getheaders(\"Content-Length\")[0]\n\nf = open(\"out.txt\", \"rb\")\nprint \"File on disk:\",len(f.read())\nf.close()\n\n\nf = open(\"out.txt\", \"wb\")\nf.write(site.read())\nsite.close()\nf.close()\n\nf = open(\"out.txt\", \"rb\")\nprint \"File on disk after download:\",len(f.read())\nf.close()\n\nprint \"os.stat().st_size returns:\", os.stat(\"out.txt\").st_size\n $ python test.py\nopening url: http://python.org\nContent-Length: 16535\nFile on disk: 16535\nFile on disk after download: 16535\nos.stat().st_size returns: 16535\n // open for binary write\nopen(filename, \"wb\")\n// open for binary read\nopen(filename, \"rb\")\n"
},
{
"answer_id": 25502448,
"author": "Madhusudhan",
"author_id": 3963432,
"author_profile": "https://Stackoverflow.com/users/3963432",
"pm_score": 3,
"selected": false,
"text": ">>> import urllib.request\n>>> site = urllib.request.urlopen(\"http://python.org\")\n>>> print(\"FileSize: \", site.length)\n"
},
{
"answer_id": 40957594,
"author": "ccpizza",
"author_id": 191246,
"author_profile": "https://Stackoverflow.com/users/191246",
"pm_score": 4,
"selected": false,
"text": "#!/usr/bin/python\n# display size of a remote file without downloading\n\nfrom __future__ import print_function\nimport sys\nimport requests\n\n# number of bytes in a megabyte\nMBFACTOR = float(1 << 20)\n\nresponse = requests.head(sys.argv[1], allow_redirects=True)\n\nprint(\"\\n\".join([('{:<40}: {}'.format(k, v)) for k, v in response.headers.items()]))\nsize = response.headers.get('content-length', 0)\nprint('{:<40}: {:.2f} MB'.format('FILE SIZE', int(size) / MBFACTOR))\n $ python filesize-remote-url.py https://httpbin.org/image/jpeg\n...\nContent-Length : 35588\nFILE SIZE (MB) : 0.03 MB\n"
},
{
"answer_id": 46440161,
"author": "yukashima huksay",
"author_id": 5120089,
"author_profile": "https://Stackoverflow.com/users/5120089",
"pm_score": 2,
"selected": false,
"text": "with urlopen(file_url) as in_file, open(local_file_address, 'wb') as out_file:\n print(in_file.getheader('Content-Length'))\n out_file.write(response.read())\n"
},
{
"answer_id": 70382014,
"author": "Kalob Taulien",
"author_id": 2074077,
"author_profile": "https://Stackoverflow.com/users/2074077",
"pm_score": 2,
"selected": false,
"text": "requests import requests \nresponse = requests.head( \n \"https://website.com/yourfile.mp4\", # Example file \n allow_redirects=True\n)\nprint(response.headers['Content-Length']) \n Content-Length if 'Content-Length' in response.headers:\n ... # Do your stuff here \n"
},
{
"answer_id": 73009100,
"author": "Harshana",
"author_id": 6952359,
"author_profile": "https://Stackoverflow.com/users/6952359",
"pm_score": 1,
"selected": false,
"text": "import urllib.request\nsite = urllib.request.urlopen(\"http://python.org\")\nmeta = site.info()\nmeta.get('Content-Length') \n '49829'\n meta.get('Content-Length')"
},
{
"answer_id": 74214042,
"author": "Eugene Chabanov",
"author_id": 11524604,
"author_profile": "https://Stackoverflow.com/users/11524604",
"pm_score": 0,
"selected": false,
"text": "import urllib\n\nurl = 'https://<your url here>'\n\nsize = urllib.request.urlopen(url).info().get('Content-Length', 0)\n .get(<dict key>, 0)"
},
{
"answer_id": 74595076,
"author": "kareem said",
"author_id": 14272080,
"author_profile": "https://Stackoverflow.com/users/14272080",
"pm_score": 0,
"selected": false,
"text": "\nFile_Name=requests.head(LINK).headers[\"X-File-Name\"]\n\n#And other useful info** like the size of the file from this dict (headers)\n#like \n\nFile_size=requests.head(LINK).headers[\"Content-Length\"]\n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/394/"
] |
5,913 | <p>This gets the value of whatever is selected in my dropdown menu.</p>
<pre><code>document.getElementById('newSkill').value
</code></pre>
<p>I cannot however find out what property to go after for the text that's currently displayed by the drop down menu. I tried "text" then looked at <a href="http://w3schools.com/" rel="noreferrer">W3Schools</a> but that didn't have the answer, does anybody here know?</p>
<p>For those not sure, here's the HTML for a drop down box.</p>
<pre><code><select name="newSkill" id="newSkill">
<option value="1">A skill</option>
<option value="2">Another skill</option>
<option value="3">Yet another skill</option>
</select>
</code></pre>
| [
{
"answer_id": 5921,
"author": "Brian Childress",
"author_id": 721,
"author_profile": "https://Stackoverflow.com/users/721",
"pm_score": 1,
"selected": false,
"text": "document.getElementById(\"newSkill\").innerHTML\n"
},
{
"answer_id": 5924,
"author": "Thejesh GN",
"author_id": 482,
"author_profile": "https://Stackoverflow.com/users/482",
"pm_score": 3,
"selected": false,
"text": "document.getElementById('newSkill').options[document.getElementById('newSkill').selectedIndex].value \n"
},
{
"answer_id": 5939,
"author": "Tanerax",
"author_id": 567,
"author_profile": "https://Stackoverflow.com/users/567",
"pm_score": 3,
"selected": false,
"text": "var vSkill = document.getElementById('newSkill');\n\nvar vSkillText = vSkill.options[vSkill.selectedIndex].innerHTML;\n\nalert(vSkillText);\n"
},
{
"answer_id": 5947,
"author": "Patrick McElhaney",
"author_id": 437,
"author_profile": "https://Stackoverflow.com/users/437",
"pm_score": 8,
"selected": true,
"text": "var skillsSelect = document.getElementById(\"newSkill\");\nvar selectedText = skillsSelect.options[skillsSelect.selectedIndex].text;\n"
},
{
"answer_id": 14665677,
"author": "Lilith",
"author_id": 1533141,
"author_profile": "https://Stackoverflow.com/users/1533141",
"pm_score": 2,
"selected": false,
"text": "document.getElementById(\"newSkill\").options[document.getElementById('newSkill').selectedIndex].text;\n"
},
{
"answer_id": 23616510,
"author": "raton",
"author_id": 1770154,
"author_profile": "https://Stackoverflow.com/users/1770154",
"pm_score": 0,
"selected": false,
"text": " var ele = document.getElementById('newSkill')\n ele.onchange = function(){\n var length = ele.children.length\n for(var i=0; i<length;i++){\n if(ele.children[i].selected){alert(ele.children[i].text)}; \n }\n } \n"
},
{
"answer_id": 32887007,
"author": "shekh danishuesn",
"author_id": 5291660,
"author_profile": "https://Stackoverflow.com/users/5291660",
"pm_score": 2,
"selected": false,
"text": "<select name=\"sweets\" multiple=\"multiple\">\n <option>Chocolate</option>\n <option>Candy</option>\n <option>Taffy</option>\n <option selected=\"selected\">Caramel</option>\n <option>Fudge</option>\n <option>Cookie</option>\n</select>\n<div></div>\n\n\n$(\"select\").change(function () {\n var str = \"\";\n\n $(\"select option:selected\").each(function() {\n str += $( this ).text() + \" \";\n });\n\n $( \"div\" ).text( str );\n}).change();\n"
},
{
"answer_id": 35123258,
"author": "Debanjan Roy",
"author_id": 5086165,
"author_profile": "https://Stackoverflow.com/users/5086165",
"pm_score": 0,
"selected": false,
"text": "var selectoption = document.getElementById(\"dropdown\");\nvar optionText = selectoption.options[selectoption.selectedIndex].text;\n"
},
{
"answer_id": 36276432,
"author": "IbrahimSediq",
"author_id": 6127529,
"author_profile": "https://Stackoverflow.com/users/6127529",
"pm_score": 0,
"selected": false,
"text": "var newSkill_Text = document.getElementById(\"newSkill\")[document.getElementById(\"newSkill\").selectedIndex];\n"
},
{
"answer_id": 44130853,
"author": "BOBIN JOSEPH",
"author_id": 4238869,
"author_profile": "https://Stackoverflow.com/users/4238869",
"pm_score": 4,
"selected": false,
"text": "$(\"#yourdropdownid option:selected\").text();\n"
},
{
"answer_id": 46924743,
"author": "Muhammad Tariq Ahmed Khan",
"author_id": 8829462,
"author_profile": "https://Stackoverflow.com/users/8829462",
"pm_score": 2,
"selected": false,
"text": "function getValue(obj)\n{ \n // it will return the selected text\n // obj variable will contain the object of check box\n var text = obj.options[obj.selectedIndex].innerHTML ; \n\n}\n <asp:DropDownList ID=\"ddl\" runat=\"server\" CssClass=\"ComboXXX\" \n onchange=\"getValue(this)\">\n</asp:DropDownList>\n"
},
{
"answer_id": 54680935,
"author": "Manpreet Singh Dhillon",
"author_id": 3495713,
"author_profile": "https://Stackoverflow.com/users/3495713",
"pm_score": 2,
"selected": false,
"text": "document.getElementById('elementID').selectedOptions[0].innerHTML\n"
},
{
"answer_id": 67819800,
"author": "RayH",
"author_id": 16084726,
"author_profile": "https://Stackoverflow.com/users/16084726",
"pm_score": 0,
"selected": false,
"text": " <select id=\"mfrbtn\" onchange=\"changemfr()\" > \n <option selected=\"selected\">Choose one</option>\n <?php\n foreach($rows as $row)\n {\n echo '<option value=implode($rows)>'.$row[\"Mfrname\"].'</option>';\n }\n ?>\n </select>\n <script language=\"JavaScript\">\n \n function changemfr()\n {\n var $mfr2=document.getElementById(\"mfrbtn\").selectedOptions[0].text;\n alert($mfr2);\n }\n</script>\n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] |
5,916 | <p>For those of you in the Visual Studio environment, how do you feel about wrapping any of your code in #regions? (or if any other IDE has something similar...)</p>
| [
{
"answer_id": 7767,
"author": "Lars Mæhlum",
"author_id": 960,
"author_profile": "https://Stackoverflow.com/users/960",
"pm_score": 6,
"selected": true,
"text": "foreach (var item in Items)\n{\n //.. 100 lines of validation and data logic..\n}\n foreach (var item in Items)\n{\n if (ValidatorClass.Validate(item))\n RepositoryClass.Update(item);\n}\n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/396/"
] |
5,948 | <p>In my web application I have a file which hold the current revision number via $Rev$. This work fine except, if I don't make any changes to that file, it doesn't get committed.</p>
<p><strong>Is there anyway I can force a single file to always get committed to the SVN server?</strong></p>
<p><em>I'm using TortoiseSVN for Windows so any code or step-by-step instructions would be helpful.</em></p>
| [
{
"answer_id": 5978,
"author": "yukondude",
"author_id": 726,
"author_profile": "https://Stackoverflow.com/users/726",
"pm_score": 1,
"selected": false,
"text": "svn commit"
},
{
"answer_id": 581625,
"author": "dbr",
"author_id": 745,
"author_profile": "https://Stackoverflow.com/users/745",
"pm_score": 2,
"selected": false,
"text": "$ version=$(svnversion)\n$ svn export . /tmp/staging/\nExport complete.\n$ echo \"Revision: ${version}\" > /tmp/staging/version.txt\n /tmp/staging/version.txt $Rev$ version.txt"
},
{
"answer_id": 581739,
"author": "Can Berk Güder",
"author_id": 2119,
"author_profile": "https://Stackoverflow.com/users/2119",
"pm_score": 4,
"selected": false,
"text": "svnversion svn up svnversion svn up svnversion"
},
{
"answer_id": 602819,
"author": "Chris Dail",
"author_id": 5077,
"author_profile": "https://Stackoverflow.com/users/5077",
"pm_score": 3,
"selected": false,
"text": "svn propset svn:keywords \"Revision\" file.txt\n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383/"
] |
5,949 | <p>I've always preferred to use long integers as primary keys in databases, for simplicity and (assumed) speed. But when using a <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer" rel="noreferrer">REST</a> or Rails-like URL scheme for object instances, I'd then end up with URLs like this:</p>
<pre><code>http://example.com/user/783
</code></pre>
<p>And then the assumption is that there are also users with IDs of 782, 781, ..., 2, and 1. Assuming that the web app in question is secure enough to prevent people entering other numbers to view other users without authorization, a simple sequentially-assigned surrogate key also "leaks" the total number of instances (older than this one), in this case users, which might be privileged information. (For instance, I am user #726 in stackoverflow.)</p>
<p>Would a <a href="http://en.wikipedia.org/wiki/Uuid" rel="noreferrer">UUID</a>/GUID be a better solution? Then I could set up URLs like this:</p>
<pre><code>http://example.com/user/035a46e0-6550-11dd-ad8b-0800200c9a66
</code></pre>
<p>Not exactly succinct, but there's less implied information about users on display. Sure, it smacks of "security through obscurity" which is no substitute for proper security, but it seems at least a little more secure.</p>
<p>Is that benefit worth the cost and complexity of implementing UUIDs for web-addressable object instances? I think that I'd still want to use integer columns as database PKs just to speed up joins.</p>
<p>There's also the question of in-database representation of UUIDs. I know MySQL stores them as 36-character strings. Postgres seems to have a more efficient internal representation (128 bits?) but I haven't tried it myself. Anyone have any experience with this?</p>
<hr>
<p>Update: for those who asked about just using the user name in the URL (e.g., <a href="http://example.com/user/yukondude" rel="noreferrer">http://example.com/user/yukondude</a>), that works fine for object instances with names that are unique, but what about the zillions of web app objects that can really only be identified by number? Orders, transactions, invoices, duplicate image names, stackoverflow questions, ...</p>
| [
{
"answer_id": 5967,
"author": "SQLMenace",
"author_id": 740,
"author_profile": "https://Stackoverflow.com/users/740",
"pm_score": 5,
"selected": false,
"text": "457180FB-C2EA-48DF-8BEF-458573DA1C10 1\n9A70FF3C-B7DA-4593-93AE-4A8945943C8A 2\n"
},
{
"answer_id": 6227,
"author": "Josh",
"author_id": 257,
"author_profile": "https://Stackoverflow.com/users/257",
"pm_score": 2,
"selected": false,
"text": "http://example.com/user/783\n http://example.com/user/yukondude\n"
},
{
"answer_id": 72440275,
"author": "ZiiMakc",
"author_id": 10188661,
"author_profile": "https://Stackoverflow.com/users/10188661",
"pm_score": 0,
"selected": false,
"text": "userId: 25 bookId: 25 ID uuid http://example.com/sale/super-duper-phone\n http://example.com/book/035a46e0-6550-11dd-ad8b-0800200c9a66/new-title\n AYEWXcsicACGA6PT7v_h3A AYEWXcsicACGA6PT7v_h3A 035a46e0-6550-11dd-ad8b-0800200c9a66 http://example.com/book/AYEWXcsicACGA6PT7v_h3A/new-title\n http://example.com/book/icACEWXcsAY-new-title\nhttp://example.com/book/icACEWXcsAY/new-title\n http://example.com/sale/phone-1-title\n http://example.com/sale/phone-1-title-updated\n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/726/"
] |
5,966 | <p>Basically, I've written an API to www.thetvdb.com in Python. The current code can be found <a href="http://github.com/dbr/tvdb_api/tree/master/tvdb_api.py" rel="noreferrer">here</a>.</p>
<p>It grabs data from the API as requested, and has to store the data somehow, and make it available by doing:</p>
<pre><code>print tvdbinstance[1][23]['episodename'] # get the name of episode 23 of season 1
</code></pre>
<p>What is the "best" way to abstract this data within the <code>Tvdb()</code> class?</p>
<p>I originally used a extended <code>Dict()</code> that automatically created sub-dicts (so you could do <code>x[1][2][3][4] = "something"</code> without having to do <code>if x[1].has_key(2): x[1][2] = []</code> and so on)</p>
<p>Then I just stored the data by doing <code>self.data[show_id][season_number][episode_number][attribute_name] = "something"</code></p>
<p>This worked okay, but there was no easy way of checking if <code>x[3][24]</code> was supposed to exist or not (so I couldn't raise the season_not_found exception).</p>
<p>Currently it's using four classes: <code>ShowContainer</code>, <code>Show</code>, <code>Season</code> and <code>Episode</code>. Each one is a very basic dict, which I can easily add extra functionality in (the <code>search()</code> function on <code>Show()</code> for example). Each has a <code>__setitem__</code>, <code>__getitem_</code> and <code>has_key</code>.</p>
<p>This works mostly fine, I can check in Shows if it has that season in it's <code>self.data</code> dict, if not, <code>raise season_not_found</code>. I can also check in <code>Season()</code> if it has that episode and so on.</p>
<p>The problem now is it's presenting itself as a dict, but doesn't have all the functionality, and because I'm overriding the <code>__getitem__</code> and <code>__setitem__</code> functions, it's easy to accidentally recursively call <code>__getitem__</code> (so I'm not sure if extending the <code>Dict</code> class will cause problems).</p>
<p>The other slight problem is adding data into the dict is a lot more work than the old <code>Dict</code> method (which was <code>self.data[seas_no][ep_no]['attribute'] = 'something'</code>). See <code>_setItem</code> and <code>_setData</code>. It's not too bad, since it's currently only a read-only API interface (so the users of the API should only ever retrieve data, not add more), but it's hardly... Elegant.</p>
<p>I think the series-of-classes system is probably the best way, but does anyone have a better idea for storing the data? And would extending the <code>ShowContainer</code>/etc classes with <code>Dict</code> cause problems?</p>
| [
{
"answer_id": 6125,
"author": "Jonathan Works",
"author_id": 309844,
"author_profile": "https://Stackoverflow.com/users/309844",
"pm_score": 2,
"selected": false,
"text": "episodes = []\nepisodes.append({'season':1, 'episode': 2, 'name':'Something'})\nepisodes.append({'season':1, 'episode': 2, 'name':'Something', 'actors':['Billy Bob', 'Sean Penn']})\n season_1 = [e for e in episodes if e['season'] == 1]\nbilly_bob = [e for e in episodes if 'actors' in e and 'Billy Bob' in e['actors']]\n\nfor episode in billy_bob:\n print \"Billy bob was in Season %s Episode %s\" % (episode['season'], episode['episode'])\n"
},
{
"answer_id": 8165,
"author": "Bartosz Radaczyński",
"author_id": 985,
"author_profile": "https://Stackoverflow.com/users/985",
"pm_score": 0,
"selected": false,
"text": ">>>x={}\n>>>x[1]={}\n>>>x[1][2]={}\n>>>x\n{1: {2: {}}}\n>>> 2 in x[1]\nTrue\n>>> 3 in x[1]\nFalse\n"
},
{
"answer_id": 9080,
"author": "dbr",
"author_id": 745,
"author_profile": "https://Stackoverflow.com/users/745",
"pm_score": 0,
"selected": false,
"text": "x['some show'][3][24] __getitem__ if self.seasons.has_key(requested_season_number) if self.episodes.has_key(requested_episode_number)"
},
{
"answer_id": 10778,
"author": "Bartosz Radaczyński",
"author_id": 985,
"author_profile": "https://Stackoverflow.com/users/985",
"pm_score": 4,
"selected": true,
"text": "classobj classobj import new\nmyexc=new.classobj(\"ExcName\",(Exception,),{})\ni=myexc(\"This is the exc msg!\")\nraise i\n Traceback (most recent call last):\nFile \"<stdin>\", line 1, in <module>\n__main__.ExcName: This is the exc msg!\n self.__class__.__name__\n raise(self.__class__.__name__+\"Exception\")\n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/745/"
] |
5,982 | <p>Does anyone know why when using BindingUtils on the selectedItem property of a ComboBox you get the following warning? Any ideas how to resolve the issue?</p>
<p>The binding still works properly, but it would be nice to get rid of the warning.</p>
<pre><code>warning: multiple describeType entries for 'selectedItem' on type 'mx.controls::ComboBox':
<accessor name="selectedItem" access="readwrite" type="Object" declaredBy="mx.controls::ComboBase">
<metadata name="Bindable">
<arg key="" value="valueCommit"/>
</metadata>
</code></pre>
| [
{
"answer_id": 14237,
"author": "Matt MacLean",
"author_id": 22,
"author_profile": "https://Stackoverflow.com/users/22",
"pm_score": 0,
"selected": false,
"text": "public static function bindProperty2(site:Object, prop:String, host:Object, chain:Object, commitOnly:Boolean = false):ChangeWatcher\n{\n var cbx:ComboBox = null;\n if ( site is ComboBox ) { cbx = ComboBox(site); }\n if ( host is ComboBox ) { cbx = ComboBox(host); }\n var labelField:String = \"listID\";\n \n var w:ChangeWatcher = ChangeWatcher.watch(host, chain, null, commitOnly);\n \n if (w != null)\n {\n var func:Function;\n \n if ( site is ComboBox )\n {\n func = function(event:*):void\n {\n var dp:ICollectionView = ICollectionView(site.dataProvider);\n var selItem:Object = null;\n \n for ( var i:int=0; i<dp.length; i++ )\n {\n var obj:Object = dp[i];\n if ( obj.hasOwnProperty(labelField) )\n {\n var val:String = String(obj[labelField]);\n if ( val == w.getValue() )\n {\n selItem = obj;\n break;\n }\n }\n }\n \n site.selectedItem = selItem;\n };\n \n w.setHandler(func);\n func(null);\n }\n else\n {\n func = function(event:*):void\n {\n var value:Object = w.getValue();\n if ( value == null )\n {\n site[prop] = null;\n }\n else\n {\n site[prop] = String(w.getValue()[labelField]);\n }\n };\n w.setHandler(func);\n func(null);\n }\n }\n \n return w;\n}\n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/5982",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22/"
] |
6,007 | <p>How do I make <a href="http://logging.apache.org/log4net/index.html" rel="noreferrer">Log4net</a> only log Info level logs? Is that even possible? Can you only set a threshold? </p>
<p>This is what I have, and it logs Info and above as I would expect. Is there anything i can do to make it only log info?</p>
<pre class="lang-xml prettyprint-override"><code><logger name="BrokerCollection.Model.XmlDocumentCreationTask">
<appender-ref ref="SubmissionAppender"/>
<level value="Info" />
</logger>
</code></pre>
| [
{
"answer_id": 10383,
"author": "Brandon Wood",
"author_id": 423,
"author_profile": "https://Stackoverflow.com/users/423",
"pm_score": 8,
"selected": true,
"text": "<appender name=\"AdoNetAppender\" type=\"log4net.Appender.AdoNetAppender\">\n <filter type=\"log4net.Filter.LevelRangeFilter\">\n <param name=\"LevelMin\" value=\"INFO\"/>\n <param name=\"LevelMax\" value=\"INFO\"/>\n </filter>\n ...\n</appender>\n"
},
{
"answer_id": 85028,
"author": "Charley Rathkopf",
"author_id": 10119,
"author_profile": "https://Stackoverflow.com/users/10119",
"pm_score": 3,
"selected": false,
"text": "<appender name=\"RollingFileAppender\" type=\"log4net.Appender.RollingFileAppender\">\n <file value=\"${HOMEDRIVE}\\\\PI.Logging\\\\PI.ECSignage.${COMPUTERNAME}.log\" />\n <appendToFile value=\"true\" />\n <maxSizeRollBackups value=\"30\" />\n <maximumFileSize value=\"5MB\" />\n <rollingStyle value=\"Size\" /> <!--A maximum number of backup files when rolling on date/time boundaries is not supported. -->\n <staticLogFileName value=\"false\" />\n <lockingModel type=\"log4net.Appender.FileAppender+MinimalLock\" />\n <layout type=\"log4net.Layout.PatternLayout\">\n <param name=\"ConversionPattern\" value=\"%date{yyyy-MM-dd HH:mm:ss.ffff} [%2thread] %-5level %20.20type{1}.%-25method at %-4line| (%-30.30logger) %message%newline\" />\n </layout>\n\n <filter type=\"log4net.Filter.LevelRangeFilter\">\n <levelMin value=\"INFO\" />\n <levelMax value=\"INFO\" />\n </filter>\n</appender> \n"
},
{
"answer_id": 816854,
"author": "Yordan Georgiev",
"author_id": 65706,
"author_profile": "https://Stackoverflow.com/users/65706",
"pm_score": 2,
"selected": false,
"text": "using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing log4net;\nusing log4net.Config;\nusing NUnit.Framework;\n\nnamespace ExampleConsoleApplication\n{\n enum DebugLevel : int\n { \n Fatal_Msgs = 0 , \n Fatal_Error_Msgs = 1 , \n Fatal_Error_Warn_Msgs = 2 , \n Fatal_Error_Warn_Info_Msgs = 3 ,\n Fatal_Error_Warn_Info_Debug_Msgs = 4 \n }\n\n class TestClass\n {\n private static readonly ILog logger = LogManager.GetLogger(typeof(TestClass));\n\n static void Main ( string[] args )\n {\n TestClass objTestClass = new TestClass ();\n\n Console.WriteLine ( \" START \" );\n\n int shouldLog = 4; //CHANGE THIS FROM 0 TO 4 integer to check the functionality of the example\n //0 -- prints only FATAL messages \n //1 -- prints FATAL and ERROR messages \n //2 -- prints FATAL , ERROR and WARN messages \n //3 -- prints FATAL , ERROR , WARN and INFO messages \n //4 -- prints FATAL , ERROR , WARN , INFO and DEBUG messages \n\n string srtLogLevel = String.Empty; \n switch (shouldLog)\n {\n case (int)DebugLevel.Fatal_Msgs :\n srtLogLevel = \"FATAL\";\n break;\n case (int)DebugLevel.Fatal_Error_Msgs:\n srtLogLevel = \"ERROR\";\n break;\n case (int)DebugLevel.Fatal_Error_Warn_Msgs :\n srtLogLevel = \"WARN\";\n break;\n case (int)DebugLevel.Fatal_Error_Warn_Info_Msgs :\n srtLogLevel = \"INFO\"; \n break;\n case (int)DebugLevel.Fatal_Error_Warn_Info_Debug_Msgs :\n srtLogLevel = \"DEBUG\" ;\n break ;\n default:\n srtLogLevel = \"FATAL\";\n break;\n }\n\n objTestClass.SetLogingLevel ( srtLogLevel );\n\n\n objTestClass.LogSomething ();\n\n\n Console.WriteLine ( \" END HIT A KEY TO EXIT \" );\n Console.ReadLine ();\n } //eof method \n\n /// <summary>\n /// Activates debug level \n /// </summary>\n /// <sourceurl>http://geekswithblogs.net/rakker/archive/2007/08/22/114900.aspx</sourceurl>\n private void SetLogingLevel ( string strLogLevel )\n {\n string strChecker = \"WARN_INFO_DEBUG_ERROR_FATAL\" ;\n\n if (String.IsNullOrEmpty ( strLogLevel ) == true || strChecker.Contains ( strLogLevel ) == false)\n throw new Exception ( \" The strLogLevel should be set to WARN , INFO , DEBUG ,\" );\n\n\n\n log4net.Repository.ILoggerRepository[] repositories = log4net.LogManager.GetAllRepositories ();\n\n //Configure all loggers to be at the debug level.\n foreach (log4net.Repository.ILoggerRepository repository in repositories)\n {\n repository.Threshold = repository.LevelMap[ strLogLevel ];\n log4net.Repository.Hierarchy.Hierarchy hier = (log4net.Repository.Hierarchy.Hierarchy)repository;\n log4net.Core.ILogger[] loggers = hier.GetCurrentLoggers ();\n foreach (log4net.Core.ILogger logger in loggers)\n {\n ( (log4net.Repository.Hierarchy.Logger)logger ).Level = hier.LevelMap[ strLogLevel ];\n }\n }\n\n //Configure the root logger.\n log4net.Repository.Hierarchy.Hierarchy h = (log4net.Repository.Hierarchy.Hierarchy)log4net.LogManager.GetRepository ();\n log4net.Repository.Hierarchy.Logger rootLogger = h.Root;\n rootLogger.Level = h.LevelMap[ strLogLevel ];\n }\n\n private void LogSomething ()\n {\n #region LoggerUsage\n DOMConfigurator.Configure (); //tis configures the logger \n logger.Debug ( \"Here is a debug log.\" );\n logger.Info ( \"... and an Info log.\" );\n logger.Warn ( \"... and a warning.\" );\n logger.Error ( \"... and an error.\" );\n logger.Fatal ( \"... and a fatal error.\" );\n #endregion LoggerUsage\n\n }\n } //eof class \n} //eof namespace \n <?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<configuration>\n <configSections>\n <section name=\"log4net\"\n type=\"log4net.Config.Log4NetConfigurationSectionHandler, log4net\" />\n </configSections>\n <log4net>\n <appender name=\"LogFileAppender\" type=\"log4net.Appender.FileAppender\">\n <param name=\"File\" value=\"LogTest2.txt\" />\n <param name=\"AppendToFile\" value=\"true\" />\n <layout type=\"log4net.Layout.PatternLayout\">\n <param name=\"Header\" value=\"[Header] \\r\\n\" />\n <param name=\"Footer\" value=\"[Footer] \\r\\n\" />\n <param name=\"ConversionPattern\" value=\"%d [%t] %-5p %c %m%n\" />\n </layout>\n </appender>\n\n <appender name=\"ColoredConsoleAppender\" type=\"log4net.Appender.ColoredConsoleAppender\">\n <mapping>\n <level value=\"ERROR\" />\n <foreColor value=\"White\" />\n <backColor value=\"Red, HighIntensity\" />\n </mapping>\n <layout type=\"log4net.Layout.PatternLayout\">\n <conversionPattern value=\"%date [%thread] %-5level %logger [%property{NDC}] - %message%newline\" />\n </layout>\n </appender>\n\n\n <appender name=\"AdoNetAppender\" type=\"log4net.Appender.AdoNetAppender\">\n <connectionType value=\"System.Data.SqlClient.SqlConnection, System.Data, Version=1.2.10.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" />\n <connectionString value=\"data source=ysg;initial catalog=DBGA_DEV;integrated security=true;persist security info=True;\" />\n <commandText value=\"INSERT INTO [DBGA_DEV].[ga].[tb_Data_Log] ([Date],[Thread],[Level],[Logger],[Message]) VALUES (@log_date, @thread, @log_level, @logger, @message)\" />\n\n <parameter>\n <parameterName value=\"@log_date\" />\n <dbType value=\"DateTime\" />\n <layout type=\"log4net.Layout.PatternLayout\" value=\"%date{yyyy'-'MM'-'dd HH':'mm':'ss'.'fff}\" />\n </parameter>\n <parameter>\n <parameterName value=\"@thread\" />\n <dbType value=\"String\" />\n <size value=\"255\" />\n <layout type=\"log4net.Layout.PatternLayout\" value=\"%thread\" />\n </parameter>\n <parameter>\n <parameterName value=\"@log_level\" />\n <dbType value=\"String\" />\n <size value=\"50\" />\n <layout type=\"log4net.Layout.PatternLayout\" value=\"%level\" />\n </parameter>\n <parameter>\n <parameterName value=\"@logger\" />\n <dbType value=\"String\" />\n <size value=\"255\" />\n <layout type=\"log4net.Layout.PatternLayout\" value=\"%logger\" />\n </parameter>\n <parameter>\n <parameterName value=\"@message\" />\n <dbType value=\"String\" />\n <size value=\"4000\" />\n <layout type=\"log4net.Layout.PatternLayout\" value=\"%messag2e\" />\n </parameter>\n </appender>\n <root>\n <level value=\"INFO\" />\n <appender-ref ref=\"LogFileAppender\" />\n <appender-ref ref=\"AdoNetAppender\" />\n <appender-ref ref=\"ColoredConsoleAppender\" />\n </root>\n </log4net>\n</configuration>\n <Reference Include=\"log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL\">\n <SpecificVersion>False</SpecificVersion>\n <HintPath>..\\..\\..\\Log4Net\\log4net-1.2.10\\bin\\net\\2.0\\release\\log4net.dll</HintPath>\n</Reference>\n<Reference Include=\"nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL\" />\n"
},
{
"answer_id": 6879650,
"author": "Javier Sanchez",
"author_id": 185766,
"author_profile": "https://Stackoverflow.com/users/185766",
"pm_score": 5,
"selected": false,
"text": "threshold <appender name=\"RollingFileAppender\" type=\"log4net.Appender.RollingFileAppender\">\n <threshold value=\"WARN\"/>\n <param name=\"File\" value=\"File.log\" />\n <param name=\"AppendToFile\" value=\"true\" />\n <param name=\"RollingStyle\" value=\"Size\" />\n <param name=\"MaxSizeRollBackups\" value=\"10\" />\n <param name=\"MaximumFileSize\" value=\"1024KB\" />\n <param name=\"StaticLogFileName\" value=\"true\" />\n <layout type=\"log4net.Layout.PatternLayout\">\n <param name=\"Header\" value=\"[Server startup] \" />\n <param name=\"Footer\" value=\"[Server shutdown] \" />\n <param name=\"ConversionPattern\" value=\"%d %m%n\" />\n </layout>\n </appender>\n <appender name=\"EventLogAppender\" type=\"log4net.Appender.EventLogAppender\" >\n <threshold value=\"ERROR\"/>\n <layout type=\"log4net.Layout.PatternLayout\">\n <conversionPattern value=\"%date [%thread]- %message%newline\" />\n </layout>\n </appender>\n <appender name=\"ConsoleAppender\" type=\"log4net.Appender.ConsoleAppender\">\n <threshold value=\"INFO\"/>\n <layout type=\"log4net.Layout.PatternLayout\">\n <param name=\"ConversionPattern\" value=\"%d [%thread] %m%n\" />\n </layout>\n </appender>\n"
},
{
"answer_id": 47055940,
"author": "Sarfaraaz",
"author_id": 4801298,
"author_profile": "https://Stackoverflow.com/users/4801298",
"pm_score": 1,
"selected": false,
"text": "<filter type=\"log4net.Filter.LevelMatchFilter\">\n <levelToMatch value=\"Info\" />\n <acceptOnMatch value=\"true\" />\n</filter>\n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/6007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/230/"
] |
6,009 | <p>Let's say you have a typical web app and with a file configuration.whatever. Every developer working on the project will have one version for their dev boxes, there will be a dev, prod and stage versions. How do you deal with this in source control? Not check in this file at all, check it with different names or do something fancy altogether?</p>
| [
{
"answer_id": 6012,
"author": "GateKiller",
"author_id": 383,
"author_profile": "https://Stackoverflow.com/users/383",
"pm_score": 3,
"selected": false,
"text": "web.config.rename\n"
},
{
"answer_id": 36767,
"author": "Damien Diederen",
"author_id": 3844,
"author_profile": "https://Stackoverflow.com/users/3844",
"pm_score": 3,
"selected": false,
"text": "A---B---C---D--- <- mainline (public)\n \\ \\\n B'------D'--- <- testing (private)\n"
},
{
"answer_id": 5905724,
"author": "JackAce",
"author_id": 738985,
"author_profile": "https://Stackoverflow.com/users/738985",
"pm_score": 3,
"selected": false,
"text": "web.config\nweb.qa.config\nweb.staging.config\nweb.production.config\n"
},
{
"answer_id": 21111088,
"author": "Benny Emmers",
"author_id": 3190261,
"author_profile": "https://Stackoverflow.com/users/3190261",
"pm_score": 0,
"selected": false,
"text": "update-index --assume-unchanged IF NOT EXIST %2%\\.git GOTO NOGIT\nset fileName=%1\nset fileName=%fileName:\\=/%\nfor /f \"useback tokens=*\" %%a in ('%fileName%') do set fileName=%%~a\nset \"gitUpdate=git update-index --assume-unchanged\"\nset parameter= \"%gitUpdate% %fileName%\"\necho %parameter% as parameter for git\n\"C:\\Program Files (x86)\\Git\\bin\\sh.exe\" --login -i -c %parameter%\necho Make FIleBehaveLikeUnchangedForGit Done.\nGOTO END\n:NOGIT\necho no git here.\necho %2%\n:END\n call \"$(ProjectDir)\\..\\..\\MakeFileBehaveLikeUnchangedForGit.bat\" \"$(ProjectDir)Web.config.developer\" \"$(SolutionDir)\"\n @echo off\necho Comparing two files: %1 with %2\nif not exist %1 goto File1NotFound\nif not exist %2 goto File2NotFound\nfc %1 %2 \nif %ERRORLEVEL%==0 GOTO NoCopy\necho Files are not the same. Copying %1 over %2\ncopy %1 %2 /y & goto END\n:NoCopy\necho Files are the same. Did nothing\ngoto END\n:File1NotFound\necho %1 not found.\ngoto END\n:File2NotFound\ncopy %1 %2 /y\ngoto END\n:END\necho Done.\n call \"$(ProjectDir)\\..\\..\\copyifnewer.bat\" \"$(ProjectDir)web.config.$(ConfigurationName)\" \"$(ProjectDir)web.config\n"
},
{
"answer_id": 35206904,
"author": "gafi",
"author_id": 3716153,
"author_profile": "https://Stackoverflow.com/users/3716153",
"pm_score": 1,
"selected": false,
"text": "configs config root\n|\n|- config (not tracked)\n|\n|- configs/ (all tracked)\n |- development\n |- staging\n |- live\n |- James\n config development staging"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/6009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/556/"
] |
6,076 | <p>I am building a server control that will search our db and return results. The server control is contains an ASP:Panel. I have set the default button on the panel equal to my button id and have set the form default button equal to my button id.</p>
<p>On the Panel:</p>
<pre><code> MyPanel.DefaultButton = SearchButton.ID</code></pre>
<p>On the Control:</p>
<pre><code>Me.Page.Form.DefaultButton = SearchButton.UniqueID </code></pre>
<p>Works fine in IE & Safari I can type a search term and hit the enter key and it searches fine. If I do it in Firefox I get an alert box saying "Object reference not set to an instance of an a object.</p>
<p>Anyone run across this before?</p>
| [
{
"answer_id": 6097,
"author": "Bryan Roth",
"author_id": 299,
"author_profile": "https://Stackoverflow.com/users/299",
"pm_score": 0,
"selected": false,
"text": "Me.Page.Form.DefaultButton = SearchButton.ID\n Me.Page.Form.DefaultButton = SearchButton.UniqueID\n"
},
{
"answer_id": 7740,
"author": "brendan",
"author_id": 225,
"author_profile": "https://Stackoverflow.com/users/225",
"pm_score": 3,
"selected": true,
"text": " SearchButton.UseSubmitBehavior = False\n"
}
] | 2008/08/08 | [
"https://Stackoverflow.com/questions/6076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225/"
] |