qid
int64 4
19.1M
| question
stringlengths 18
48.3k
| answers
list | date
stringlengths 10
10
| metadata
list |
---|---|---|---|---|
73,628 |
<p>If you have a JSF <code><h:commandLink></code> (which uses the <code>onclick</code> event of an <code><a></code> to submit the current form), how do you execute JavaScript (such as asking for delete confirmation) prior to the action being performed?</p>
|
[
{
"answer_id": 73644,
"author": "Grant Wagner",
"author_id": 9254,
"author_profile": "https://Stackoverflow.com/users/9254",
"pm_score": 4,
"selected": true,
"text": "<h:commandLink id=\"myCommandLink\" action=\"#{myPageCode.doDelete}\">\n <h:outputText value=\"#{msgs.deleteText}\" />\n</h:commandLink>\n<script type=\"text/javascript\">\nif (document.getElementById) {\n var commandLink = document.getElementById('<c:out value=\"${myPageCode.myCommandLinkClientId}\" />');\n if (commandLink && commandLink.onclick) {\n var commandLinkOnclick = commandLink.onclick;\n commandLink.onclick = function() {\n var result = confirm('Do you really want to <c:out value=\"${msgs.deleteText}\" />?');\n if (result) {\n return commandLinkOnclick();\n }\n return false;\n }\n }\n}\n</script>\n confirm()"
},
{
"answer_id": 73800,
"author": "noah",
"author_id": 12034,
"author_profile": "https://Stackoverflow.com/users/12034",
"pm_score": 1,
"selected": false,
"text": "var a=function(){/*your onclick*/}; var b=function(){/*JSF onclick*/}; return (a()==false) ? false : b();\n"
},
{
"answer_id": 82125,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<h:commandLink action=\"#{bean.action}\" onclick=\"if(confirm('Are you sure?')) return false;\" />\n return confirm(...)"
},
{
"answer_id": 82962,
"author": "Victor",
"author_id": 14514,
"author_profile": "https://Stackoverflow.com/users/14514",
"pm_score": 0,
"selected": false,
"text": "myform.onsubmit = function(){confirm(\"really really sure?\")};\n"
},
{
"answer_id": 510671,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": " onclick=\"if(confirm('Are you sure?')) return false;\" />\n onclick=\"if(confirm(\\\"Are you sure?\\\"))return true; else return false;\"\n"
},
{
"answer_id": 4542190,
"author": "iordan",
"author_id": 555424,
"author_profile": "https://Stackoverflow.com/users/555424",
"pm_score": 4,
"selected": false,
"text": "onclick=\"return confirm('Are you sure?');\"\n"
},
{
"answer_id": 4622401,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "var deleteClick;\nvar mess=\"xxx\";\nfunction assignDeleteClick(link) {\n if (link.onclick == confirmDelete) {\n return;\n }\n deleteClick = link.onclick;\n link.onclick = confirmDelete;\n}\n\n\nfunction confirmDelete() {\n var ans = confirm(mess);\n if (ans == true) {\n return deleteClick();\n } else {\n return false;\n }\n} \n"
},
{
"answer_id": 6113403,
"author": "Hanynowsky",
"author_id": 754756,
"author_profile": "https://Stackoverflow.com/users/754756",
"pm_score": 3,
"selected": false,
"text": "<h:commandButton title=\"#{bundle.NewPatient}\" action=\"#{identifController.prepareCreate}\" \n id=\"newibutton\" \n onclick=\"if(confirm('#{bundle.NewPatient}?'))return true; else return false;\" \n value=\"#{bundle.NewPatient}\"/>\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9254/"
] |
73,629 |
<p>I have a string that is like below.</p>
<pre><code>,liger, unicorn, snipe
</code></pre>
<p>in other languages I'm familiar with I can just do a string.trim(",") but how can I do that in c#?</p>
<p>Thanks.</p>
<hr>
<p><em>There's been a lot of back and forth about the StartTrim function. As several have pointed out, the StartTrim doesn't affect the primary variable. However, given the construction of the data vs the question, I'm torn as to which answer to accept. True the question only wants the first character trimmed off not the last (if anny), however, there would never be a "," at the end of the data. So, with that said, I'm going to accept the first answer that that said to use StartTrim assigned to a new variable.</em></p>
|
[
{
"answer_id": 73650,
"author": "Bob King",
"author_id": 6897,
"author_profile": "https://Stackoverflow.com/users/6897",
"pm_score": 0,
"selected": false,
"text": "if (s.StartsWith(\",\")) {\n s = s.Substring(1, s.Length - 1);\n}\n"
},
{
"answer_id": 73652,
"author": "DevelopingChris",
"author_id": 1220,
"author_profile": "https://Stackoverflow.com/users/1220",
"pm_score": 4,
"selected": false,
"text": "string s = \",liger, unicorn, snipe\";\ns.TrimStart(',');\n"
},
{
"answer_id": 73656,
"author": "Kieran Benton",
"author_id": 5777,
"author_profile": "https://Stackoverflow.com/users/5777",
"pm_score": 0,
"selected": false,
"text": "string t = \",liger, unicorn, snipe\".TrimStart(new char[] {','});\n"
},
{
"answer_id": 73660,
"author": "Matt Dawdy",
"author_id": 232,
"author_profile": "https://Stackoverflow.com/users/232",
"pm_score": 0,
"selected": false,
"text": " string s = \",liger, tiger\";\n\n if (s.Substring(0, 1) == \",\")\n s = s.Substring(1);\n"
},
{
"answer_id": 73665,
"author": "chakrit",
"author_id": 3055,
"author_profile": "https://Stackoverflow.com/users/3055",
"pm_score": 0,
"selected": false,
"text": "s = s.Replace(\",\", \"\");\n"
},
{
"answer_id": 73676,
"author": "Clinton Pierce",
"author_id": 8173,
"author_profile": "https://Stackoverflow.com/users/8173",
"pm_score": 0,
"selected": false,
"text": " string o = \",liger, unicorn, snipe\";\n string s = o.Substring(1);\n"
},
{
"answer_id": 73681,
"author": "Jay Bazuzi",
"author_id": 5314,
"author_profile": "https://Stackoverflow.com/users/5314",
"pm_score": 2,
"selected": false,
"text": "params \",liger, unicorn, snipe\".TrimStart(',')\n \",liger, unicorn, snipe\".TrimStart(\",; \".ToCharArray())\n"
},
{
"answer_id": 73708,
"author": "bentford",
"author_id": 946,
"author_profile": "https://Stackoverflow.com/users/946",
"pm_score": 0,
"selected": false,
"text": " string animals = \",liger, unicorn, snipe\";\n\n //trimmed will contain \"liger, unicorn, snipe\"\n string trimmed = word.Trim(',');\n"
},
{
"answer_id": 73734,
"author": "RickL",
"author_id": 7261,
"author_profile": "https://Stackoverflow.com/users/7261",
"pm_score": 5,
"selected": true,
"text": "string sample = \",liger, unicorn, snipe\";\nsample = sample.TrimStart(','); // to remove just the first comma\n sample = sample.Trim().TrimStart(','); // to remove any whitespace and then the first comma\n"
},
{
"answer_id": 73749,
"author": "hamishmcn",
"author_id": 3590,
"author_profile": "https://Stackoverflow.com/users/3590",
"pm_score": 1,
"selected": false,
"text": "string s1 = \",abc,d\";\nstring s2 = s1.TrimStart(\",\".ToCharArray());\nConsole.WriteLine(\"s1 = {0}\", s1);\nConsole.WriteLine(\"s2 = {0}\", s2);\n s1 = ,abc,d\ns2 = abc,d\n"
},
{
"answer_id": 74536,
"author": "justin.m.chase",
"author_id": 12958,
"author_profile": "https://Stackoverflow.com/users/12958",
"pm_score": 2,
"selected": false,
"text": "string[] animals = { \"liger\", \"unicorn\", \"snipe\" };\nstring joined = string.Join(\", \", animals);\n"
},
{
"answer_id": 79881,
"author": "Wonko",
"author_id": 14842,
"author_profile": "https://Stackoverflow.com/users/14842",
"pm_score": 1,
"selected": false,
"text": "string s = \",liger, unicorn, snipe\";\ns = s.TrimStart(',');\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/730/"
] |
73,663 |
<p>How do I exit a script early, like the <code>die()</code> command in PHP?</p>
|
[
{
"answer_id": 73673,
"author": "pjz",
"author_id": 8002,
"author_profile": "https://Stackoverflow.com/users/8002",
"pm_score": 12,
"selected": true,
"text": "import sys\nsys.exit()\n sys sys.exit([arg]) SystemExit try stderr sys.exit(\"some error message\") exit() os._exit(*errorcode*) sys.exit()"
},
{
"answer_id": 73680,
"author": "Vhaerun",
"author_id": 11234,
"author_profile": "https://Stackoverflow.com/users/11234",
"pm_score": 7,
"selected": false,
"text": "raise SystemExit\n"
},
{
"answer_id": 73695,
"author": "cleg",
"author_id": 29503,
"author_profile": "https://Stackoverflow.com/users/29503",
"pm_score": 5,
"selected": false,
"text": "from sys import exit\nexit()\n"
},
{
"answer_id": 76374,
"author": "Glyph",
"author_id": 13564,
"author_profile": "https://Stackoverflow.com/users/13564",
"pm_score": 6,
"selected": false,
"text": "sys.exit SystemExit os._exit"
},
{
"answer_id": 14836329,
"author": "j.m.g.r",
"author_id": 2065348,
"author_profile": "https://Stackoverflow.com/users/2065348",
"pm_score": 9,
"selected": false,
"text": "quit() #do stuff\nif this == that:\n quit()\n"
},
{
"answer_id": 16150238,
"author": "Space cowboy",
"author_id": 1897240,
"author_profile": "https://Stackoverflow.com/users/1897240",
"pm_score": 7,
"selected": false,
"text": "exit() sys.exit() exit() quit() os._exit(0) execfile()"
},
{
"answer_id": 22504027,
"author": "Floggedhorse",
"author_id": 2428737,
"author_profile": "https://Stackoverflow.com/users/2428737",
"pm_score": 5,
"selected": false,
"text": "def main():\n try:\n Answer = 1/0\n print Answer\n except:\n print 'Program terminated'\n return\n print 'You wont see this'\n\nif __name__ == '__main__': \n main()\n import sys\ndef main():\n try:\n Answer = 1/0\n print Answer\n except:\n print 'Program terminated'\n sys.exit()\n print 'You wont see this'\n\nif __name__ == '__main__': \n main()\n"
},
{
"answer_id": 40525942,
"author": "eaydin",
"author_id": 1278994,
"author_profile": "https://Stackoverflow.com/users/1278994",
"pm_score": 6,
"selected": false,
"text": "raise SystemExit sys.exit() os._exit() os._exit import threading\nimport time\nimport sys\nimport os\n\ndef kenny(num=0):\n if num > 3:\n # print(\"Kenny dies now...\")\n # raise SystemExit #Kenny will die, but Cartman will live forever\n # sys.exit(1) #Same as above\n\n print(\"Kenny dies and also kills Cartman!\")\n os._exit(1)\n while True:\n print(\"Kenny lives: {0}\".format(num))\n time.sleep(1)\n num += 1\n kenny(num)\n\ndef cartman():\n i = 0\n while True:\n print(\"Cartman lives: {0}\".format(i))\n i += 1\n time.sleep(1)\n\nif __name__ == '__main__':\n daemon_kenny = threading.Thread(name='kenny', target=kenny)\n daemon_cartman = threading.Thread(name='cartman', target=cartman)\n daemon_kenny.setDaemon(True)\n daemon_cartman.setDaemon(True)\n\n daemon_kenny.start()\n daemon_cartman.start()\n daemon_kenny.join()\n daemon_cartman.join()\n"
},
{
"answer_id": 41350119,
"author": "David C.",
"author_id": 6036809,
"author_profile": "https://Stackoverflow.com/users/6036809",
"pm_score": 4,
"selected": false,
"text": "## My example:\nif \"ATG\" in my_DNA: \n ## <Do something & proceed...>\nelse: \n print(\"Start codon is missing! Check your DNA sequence!\")\n exit() ## as most folks said above\n ## My example revised:\nif \"ATG\" in my_DNA: \n ## <Do something & proceed...>\nelse: \n raise ValueError(\"Start codon is missing! Check your DNA sequence!\")\n"
},
{
"answer_id": 60805367,
"author": "Matthew",
"author_id": 12898298,
"author_profile": "https://Stackoverflow.com/users/12898298",
"pm_score": 2,
"selected": false,
"text": "sys.exit() immediateExit immediateExit = False\n immediateExit = True\n sys.exit('CSV file corrupted 0.')\n if immediateExit:\n sys.exit('CSV file corrupted 1.')\n if immediateExit:\n sys.exit('CSV file corrupted 1.5.')\n 'CSV file corrupted 1.5.'\n immediateExit = False\nstart_date = '1994.01.01'\nend_date = '1994.01.04'\nresumedDate = end_date\n\n\nend_date_in_working_days = False\nwhile not end_date_in_working_days:\n try:\n end_day_position = working_days.index(end_date)\n\n end_date_in_working_days = True\n except ValueError: # try statement from end_date in workdays check\n print(current_date_and_time())\n end_date = input('>> {} is not in the list of working days. Change the date (YYYY.MM.DD): '.format(end_date))\n print('New end date: ', end_date, '\\n')\n continue\n\n\n csv_filename = 'test.csv'\n csv_headers = 'date,rate,brand\\n' # not real headers, this is just for example\n try:\n with open(csv_filename, 'r') as file:\n print('***\\nOld file {} found. Resuming the file by re-processing the last date lines.\\nThey shall be deleted and re-processed.\\n***\\n'.format(csv_filename))\n last_line = file.readlines()[-1]\n start_date = last_line.split(',')[0] # assigning the start date to be the last like date.\n resumedDate = start_date\n\n if last_line == csv_headers:\n pass\n elif start_date not in working_days:\n print('***\\n\\n{} file might be corrupted. Erase or edit the file to continue.\\n***'.format(csv_filename))\n immediateExit = True\n sys.exit('CSV file corrupted 0.')\n else:\n start_date = last_line.split(',')[0] # assigning the start date to be the last like date.\n print('\\nLast date:', start_date)\n file.seek(0) # setting the cursor at the beginnning of the file\n lines = file.readlines() # reading the file contents into a list\n count = 0 # nr. of lines with last date\n for line in lines: #cycling through the lines of the file\n if line.split(',')[0] == start_date: # cycle for counting the lines with last date in it.\n count = count + 1\n if immediateExit:\n sys.exit('CSV file corrupted 1.')\n for iter in range(count): # removing the lines with last date\n lines.pop()\n print('\\n{} lines removed from date: {} in {} file'.format(count, start_date, csv_filename))\n\n\n\n if immediateExit:\n sys.exit('CSV file corrupted 1.2.')\n with open(csv_filename, 'w') as file:\n print('\\nFile', csv_filename, 'open for writing')\n file.writelines(lines)\n\n print('\\nRemoving', count, 'lines from', csv_filename)\n\n fileExists = True\n\n except:\n if immediateExit:\n sys.exit('CSV file corrupted 1.5.')\n with open(csv_filename, 'w') as file:\n file.write(csv_headers)\n fileExists = False\n if immediateExit:\n sys.exit('CSV file corrupted 2.')\n\n"
},
{
"answer_id": 70811775,
"author": "Artyom Vancyan",
"author_id": 12755187,
"author_profile": "https://Stackoverflow.com/users/12755187",
"pm_score": 4,
"selected": false,
"text": "quit() exit(0) os._exit(0) sys.exit(0) os.kill(os.getppid(), 9) os.getppid() pkill import os\n\n# This can be called even in process worker and will kill\n# whole application included correlated processes as well\nos.system(f\"pkill -f {os.path.basename(__file__)}\")\n"
},
{
"answer_id": 70824754,
"author": "ChanceMeteor515",
"author_id": 18007782,
"author_profile": "https://Stackoverflow.com/users/18007782",
"pm_score": 1,
"selected": false,
"text": "quit()"
},
{
"answer_id": 72902963,
"author": "jimh",
"author_id": 3705490,
"author_profile": "https://Stackoverflow.com/users/3705490",
"pm_score": 2,
"selected": false,
"text": "raise SystemExit(\"Because I said so\")"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] |
73,667 |
<p>How can I start an interactive console for Perl, similar to the <code>irb</code> command for Ruby or <code>python</code> for Python?</p>
|
[
{
"answer_id": 73685,
"author": "Brian Phillips",
"author_id": 7230,
"author_profile": "https://Stackoverflow.com/users/7230",
"pm_score": 3,
"selected": false,
"text": "perl -d % perl -de 0"
},
{
"answer_id": 73689,
"author": "Clinton Pierce",
"author_id": 8173,
"author_profile": "https://Stackoverflow.com/users/8173",
"pm_score": 4,
"selected": false,
"text": " perl -d -e 1\n"
},
{
"answer_id": 73703,
"author": "Daniel Papasian",
"author_id": 7548,
"author_profile": "https://Stackoverflow.com/users/7548",
"pm_score": 9,
"selected": true,
"text": "perl -de1\n"
},
{
"answer_id": 73742,
"author": "Jon Ericson",
"author_id": 1438,
"author_profile": "https://Stackoverflow.com/users/1438",
"pm_score": 4,
"selected": false,
"text": "$ perl -e 'print \"JAPH\\n\"'\n"
},
{
"answer_id": 73780,
"author": "Michael Carman",
"author_id": 8233,
"author_profile": "https://Stackoverflow.com/users/8233",
"pm_score": 3,
"selected": false,
"text": "perl -de 1"
},
{
"answer_id": 76154,
"author": "raldi",
"author_id": 7598,
"author_profile": "https://Stackoverflow.com/users/7598",
"pm_score": 5,
"selected": false,
"text": "#! /usr/bin/perl\n\nwhile (<>) {\n chomp;\n my $result = eval;\n print \"$_ = $result\\n\";\n}\n > gmtime(2**30)\ngmtime(2**30) = Sat Jan 10 13:37:04 2004\n\n> $x = 'foo'\n$x = 'foo' = foo\n\n> $x =~ s/o/a/g\n$x =~ s/o/a/g = 2\n\n> $x\n$x = faa\n"
},
{
"answer_id": 91565,
"author": "ysth",
"author_id": 17389,
"author_profile": "https://Stackoverflow.com/users/17389",
"pm_score": 3,
"selected": false,
"text": "rlwrap perl -wlne'eval;print$@if$@'\n rlwrap perl -wnE'say eval()//$@'\n"
},
{
"answer_id": 18843800,
"author": "KIM Taegyoon",
"author_id": 1941928,
"author_profile": "https://Stackoverflow.com/users/1941928",
"pm_score": 3,
"selected": false,
"text": "$ perl -e'while(<>){print eval,\"\\n\"}'\n"
},
{
"answer_id": 22840242,
"author": "Ján Sáreník",
"author_id": 1255163,
"author_profile": "https://Stackoverflow.com/users/1255163",
"pm_score": 5,
"selected": false,
"text": "~/bin/ips #!/bin/sh\necho 'This is Interactive Perl shell'\nrlwrap -A -pgreen -S\"perl> \" perl -wnE'say eval()//$@'\n $ ips\nThis is Interactive Perl shell\nperl> 2**128\n3.40282366920938e+38\nperl> \n"
},
{
"answer_id": 31283257,
"author": "mklement0",
"author_id": 45375,
"author_profile": "https://Stackoverflow.com/users/45375",
"pm_score": 3,
"selected": false,
"text": "rlwrap rlwrap brew install rlwrap rlwrap sudo apt-get install rlwrap rlwrap print Data::Printer [sudo] cpan Data::Printer p() iperl Data::Printer ~/.bashrc alias iperl='rlwrap -A -S \"iperl> \" perl -MData::Printer -wnE '\\''BEGIN { say \"# Use `p @<arrayOrList>` or `p %<hashTable>` to print arrays/lists/hashtables; e.g.: `p %ENV`\"; } say eval()//$@'\\'\n %ENV $ iperl # start the REPL\niperl> p %ENV # print key-value pairs in hashtable %ENV\n iperl> 22 / 7 # automatically print scalar result of expression: 3.14285714285714\n"
},
{
"answer_id": 32798002,
"author": "mklement0",
"author_id": 45375,
"author_profile": "https://Stackoverflow.com/users/45375",
"pm_score": 4,
"selected": false,
"text": "perli rlwrap npm install -g perli\n perli chmod +x perli.pl .pl perli.pl perli.cmd @%~dpn.pl %* perli"
},
{
"answer_id": 35815564,
"author": "gavenkoa",
"author_id": 173149,
"author_profile": "https://Stackoverflow.com/users/173149",
"pm_score": 2,
"selected": false,
"text": "$ sudo apt-get install libdevel-repl-perl\n$ re.pl\n\n$ sudo apt-get install libapp-repl-perl\n$ iperl\n"
},
{
"answer_id": 37551820,
"author": "Davor Cubranic",
"author_id": 552683,
"author_profile": "https://Stackoverflow.com/users/552683",
"pm_score": 2,
"selected": false,
"text": "perl -de 0 Reply tinyrepl Eval::WithLexicals"
},
{
"answer_id": 67925304,
"author": "HappyFace",
"author_id": 1410221,
"author_profile": "https://Stackoverflow.com/users/1410221",
"pm_score": 0,
"selected": false,
"text": "org-babel emacs org-mode tmp.org #+begin_src perl :results output\n@a = (1,5,9);\nprint ((join \", \", @a) . \"\\n\");\n$b = scalar @a;\nprint \"$#a, $b\\n\";\nprint \"$#a, \" . @a . \"\\n\";\nprint join \", \", 1..$#a; print \"\\n\";\nprint join \", \", @a[0..$#a]\n#+end_src\n CTRL-c CTRL-c #+RESULTS:\n#+begin_example\n1, 5, 9\n2, 3\n2, 3\n1, 2\n1, 5, 9\n#+end_example\n perl org-mode"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5475/"
] |
73,674 |
<p>I talked to a friend of mine and he told me that it's possible to create an image in an image editor (gimp/photoshop) and then use it as a button . He said that's the way applications that have great GUIs do it. </p>
<p>He also said that there is a file describing which parts of the image make up the button.</p>
<p>Is this possible , or is he "crazy"? :)</p>
|
[
{
"answer_id": 73699,
"author": "Joel Anair",
"author_id": 7441,
"author_profile": "https://Stackoverflow.com/users/7441",
"pm_score": 1,
"selected": false,
"text": "<input type=\"button\" src=\"/path/to/image.png\" />\n <img src=\"/path/to/image.png\" onclick=\"function(){doSomething();}\" />\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11234/"
] |
73,686 |
<pre><code>#include <iostream>
using namespace std;
int main()
{
double u = 0;
double w = -u;
cout << w << endl;
return 0;
}
</code></pre>
<p>Why does this great piece of code output <code>-0</code> and not <code>0</code>, as one would expect?</p>
|
[
{
"answer_id": 73728,
"author": "Doug T.",
"author_id": 8123,
"author_profile": "https://Stackoverflow.com/users/8123",
"pm_score": 2,
"selected": false,
"text": "0 -0"
},
{
"answer_id": 73740,
"author": "Drealmer",
"author_id": 12291,
"author_profile": "https://Stackoverflow.com/users/12291",
"pm_score": 2,
"selected": false,
"text": "+0 -0"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6922/"
] |
73,713 |
<p>The following will cause infinite recursion on the == operator overload method</p>
<pre><code> Foo foo1 = null;
Foo foo2 = new Foo();
Assert.IsFalse(foo1 == foo2);
public static bool operator ==(Foo foo1, Foo foo2) {
if (foo1 == null) return foo2 == null;
return foo1.Equals(foo2);
}
</code></pre>
<p>How do I check for nulls?</p>
|
[
{
"answer_id": 73729,
"author": "Andrew Jones",
"author_id": 12767,
"author_profile": "https://Stackoverflow.com/users/12767",
"pm_score": 4,
"selected": false,
"text": "public static bool operator ==(Foo foo1, Foo foo2) {\n if ((object) foo1 == null) return (object) foo2 == null;\n return foo1.Equals(foo2);\n}\n"
},
{
"answer_id": 73732,
"author": "Abe Heidebrecht",
"author_id": 9268,
"author_profile": "https://Stackoverflow.com/users/9268",
"pm_score": 8,
"selected": true,
"text": "ReferenceEquals Foo foo1 = null;\nFoo foo2 = new Foo();\nAssert.IsFalse(foo1 == foo2);\n\npublic static bool operator ==(Foo foo1, Foo foo2) {\n if (object.ReferenceEquals(null, foo1))\n return object.ReferenceEquals(null, foo2);\n return foo1.Equals(foo2);\n}\n"
},
{
"answer_id": 73744,
"author": "Santiago Palladino",
"author_id": 12791,
"author_profile": "https://Stackoverflow.com/users/12791",
"pm_score": 2,
"selected": false,
"text": "Object.ReferenceEquals(foo1, null) == Equals"
},
{
"answer_id": 73840,
"author": "Jon Adams",
"author_id": 2291,
"author_profile": "https://Stackoverflow.com/users/2291",
"pm_score": 3,
"selected": false,
"text": "ReferenceEquals public static bool operator ==(Foo foo1, Foo foo2) {\n if (ReferenceEquals(foo1, null)) return ReferenceEquals(foo2, null);\n if (ReferenceEquals(foo2, null)) return false;\n return foo1.field1 == foo2.field2;\n}\n"
},
{
"answer_id": 73915,
"author": "The Digital Gabeg",
"author_id": 12782,
"author_profile": "https://Stackoverflow.com/users/12782",
"pm_score": -1,
"selected": false,
"text": "public static bool operator ==(Foo foo1, Foo foo2)\n{\n // check if the left parameter is null\n bool LeftNull = false;\n try { Type temp = a_left.GetType(); }\n catch { LeftNull = true; }\n\n // check if the right parameter is null\n bool RightNull = false;\n try { Type temp = a_right.GetType(); }\n catch { RightNull = true; }\n\n // null checking results\n if (LeftNull && RightNull) return true;\n else if (LeftNull || RightNull) return false;\n else return foo1.field1 == foo2.field2;\n}\n"
},
{
"answer_id": 81750,
"author": "Hallgrim",
"author_id": 15454,
"author_profile": "https://Stackoverflow.com/users/15454",
"pm_score": 2,
"selected": false,
"text": "bool Equals(object obj) == Foo.Equals(object obj) != public static bool operator ==(Foo foo1, Foo foo2) {\n return object.Equals(foo1, foo2);\n}\npublic static bool operator !=(Foo foo1, Foo foo2) {\n return !object.Equals(foo1, foo2);\n}\n == foo1.Equals(foo2)"
},
{
"answer_id": 13899647,
"author": "nawfal",
"author_id": 661933,
"author_profile": "https://Stackoverflow.com/users/661933",
"pm_score": 1,
"selected": false,
"text": "(object)item == null\n object public static bool IsNull<T>(this T obj) where T : class\n{\n return (object)obj == null;\n}\n\npublic static bool IsNull<T>(this T? obj) where T : struct\n{\n return !obj.HasValue;\n}\n public static bool IsNull<T>(this T obj) where T : class\n{\n return (object)obj == null || obj == DBNull.Value;\n}\n IsNull object obj = new object();\nGuid? guid = null; \nbool b = obj.IsNull(); // false\nb = guid.IsNull(); // true\n2.IsNull(); // error\n (object)item == null Object.ReferenceEquals(item, null)"
},
{
"answer_id": 40109060,
"author": "Basheer AL-MOMANI",
"author_id": 4251431,
"author_profile": "https://Stackoverflow.com/users/4251431",
"pm_score": -1,
"selected": false,
"text": "(a == b) (a ==null) (b == null) infinite loop ReferenceEquals // If both are null, or both are same instance, return true.\nif (System.Object.ReferenceEquals(a, b))// using ReferenceEquals\n{\n return true;\n}\n\n// If one is null, but not both, return false.\nif (((object)a == null) || ((object)b == null))// using casting the type to Object\n{\n return false;\n}\n"
},
{
"answer_id": 44376857,
"author": "jacekbe",
"author_id": 8116196,
"author_profile": "https://Stackoverflow.com/users/8116196",
"pm_score": 3,
"selected": false,
"text": "public static bool operator==(Foo foo1, Foo foo2)\n{\n if (foo1 is null)\n return foo2 is null;\n return foo1.Equals(foo2);\n}\n"
},
{
"answer_id": 45465996,
"author": "Zach Posten",
"author_id": 2517147,
"author_profile": "https://Stackoverflow.com/users/2517147",
"pm_score": 0,
"selected": false,
"text": "Equals(Object, Object) objA objB null objA objB true ReferenceEquals objA objB null true objA objB null false null objA.Equals(objB) objA Object.Equals(Object) public static bool operator ==(Foo objA, Foo objB) {\n return Object.Equals(objA, objB);\n}\n"
},
{
"answer_id": 51354894,
"author": "CCondron",
"author_id": 602408,
"author_profile": "https://Stackoverflow.com/users/602408",
"pm_score": 0,
"selected": false,
"text": " public static bool operator !=(ValueObject self, ValueObject other) => !Equals(self, other);\n public static bool operator ==(ValueObject self, ValueObject other) => Equals(self, other);\n public override bool Equals(object other) => Equals(other as ValueObject );\n public bool Equals(ValueObject other) {\n return !(other is null) && \n // Value comparisons\n _value == other._value;\n }\n public override int GetHashCode() => _value.GetHashCode();\n"
},
{
"answer_id": 54576557,
"author": "Reto Messerli",
"author_id": 9697734,
"author_profile": "https://Stackoverflow.com/users/9697734",
"pm_score": 2,
"selected": false,
"text": "null if (foo is null)\n"
},
{
"answer_id": 58195524,
"author": "mr5",
"author_id": 2304737,
"author_profile": "https://Stackoverflow.com/users/2304737",
"pm_score": 0,
"selected": false,
"text": "public static bool operator ==(Foo x, Foo y)\n{\n return x is null ? y is null : x.Equals(y);\n}\n\npublic static bool operator !=(Foo x, Foo y)\n{\n return x is null ? !(y is null) : !x.Equals(y);\n}\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12767/"
] |
73,736 |
<p>There are <a href="http://java-source.net/open-source/web-frameworks" rel="noreferrer">zillions</a> of Java web application frameworks.</p>
<p>95% were designed before the modern era of AJAX/DHTML-based development, and that means these new methods are grafted on rather than designed in.</p>
<p>Has any framework been built from the ground up with e.g. <a href="http://extjs.com/products/gxt/" rel="noreferrer">GWT + Extjs</a> in mind?</p>
<p>If not, which framework has adapted best to the world of forms with dynamic numbers of fields and pages that morph client-side?</p>
|
[
{
"answer_id": 46215447,
"author": "Kushal Jain",
"author_id": 2530851,
"author_profile": "https://Stackoverflow.com/users/2530851",
"pm_score": 0,
"selected": false,
"text": "GWT is used by many products at Google, including Google AdWords and Google\nWallet. It's open source, completely free, and used by thousands of \nenthusiastic developers around the world.\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73736",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4926/"
] |
73,748 |
<p>I have a dropdownlist with the autopostback set to true. I want the
user to confirm if they really want to change the value,
which on post back fires a server side event (selectedindexchanged).</p>
<p>I have tried adding an onchange attribute "return confirm('Please click OK to change. Otherwise click CANCEL?';") but it will not postback regardless of the confirm
result and the value in the list does not revert back if cancel
selected. </p>
<p>When I remove the onchange attribute from the DropdownList tag, the page does postback. It does not when the onchange attribute is added. Do I still need to wire the event handler (I'm on C# .Net 2.0 ).</p>
<p>Any leads will be helpful.</p>
<p>Thanks!</p>
|
[
{
"answer_id": 73860,
"author": "Brian Liang",
"author_id": 5853,
"author_profile": "https://Stackoverflow.com/users/5853",
"pm_score": 0,
"selected": false,
"text": "dropDown.SelectedIndexChanged += new EventHandler(dropDown_SelectedIndexChanged);\n dropDown.Attributes.Add(\"onchange\", \"javascript: return confirm('confirmation msg')\");\n"
},
{
"answer_id": 74027,
"author": "Craig",
"author_id": 2047,
"author_profile": "https://Stackoverflow.com/users/2047",
"pm_score": 3,
"selected": false,
"text": " <asp:DropDownList ID=\"TestDropDown\" runat=\"server\" AutoPostBack=\"true\" CausesValidation=\"true\"\n ValidationGroup=\"Group1\"\n OnSelectedIndexChanged=\"TestDropDown_SelectedIndexChanged\">\n <asp:ListItem Value=\"1\" Text=\"One\" />\n <asp:ListItem Value=\"2\" Text=\"Two\" />\n </asp:DropDownList>\n <script type=\"text/javascript\">\n function ConfirmDropDownValueChange(source, arguments) {\n arguments.IsValid = confirm(\"Are you sure?\");\n }\n </script>\n <asp:CustomValidator ID=\"ConfirmDropDownValidator\" runat=\"server\"\n ClientValidationFunction=\"ConfirmDropDownValueChange\" Display=\"Dynamic\" ValidationGroup=\"Group1\" />\n"
},
{
"answer_id": 74251,
"author": "Kyle B.",
"author_id": 6158,
"author_profile": "https://Stackoverflow.com/users/6158",
"pm_score": 4,
"selected": true,
"text": " \ndrpControl.Attributes(\"onChange\") = \"DisplayConfirmation();\"\n\nfunction DisplayConfirmation() {\n if (confirm('Are you sure you want to do this?')) {\n __doPostback('drpControl','');\n }\n}\n"
},
{
"answer_id": 74289,
"author": "Billy Jo",
"author_id": 3447,
"author_profile": "https://Stackoverflow.com/users/3447",
"pm_score": 1,
"selected": false,
"text": "confirm() true onchange return false; confirm() if (!confirm('Please click OK to change. Otherwise click CANCEL?')) return false;\n"
},
{
"answer_id": 74444,
"author": "Craig",
"author_id": 2047,
"author_profile": "https://Stackoverflow.com/users/2047",
"pm_score": 1,
"selected": false,
"text": ";setTimeout('__doPostBack(\\'YourDropDown\\',\\'\\')', 0)\n"
},
{
"answer_id": 2695583,
"author": "JCallico",
"author_id": 143195,
"author_profile": "https://Stackoverflow.com/users/143195",
"pm_score": 3,
"selected": false,
"text": "// caching selected value at the time the control is clicked\nMyDropDownList.Attributes.Add(\n \"onclick\",\n \"this.currentvalue = this.value;\");\n\n// if the user chooses not to continue then restoring cached value and aborting by returning false\nMyDropDownList.Attributes.Add(\n \"onchange\",\n \"if (!confirm('Do you want to continue?')) {this.value = this.currentvalue; return false};\");\n"
},
{
"answer_id": 3301127,
"author": "NealB",
"author_id": 41114,
"author_profile": "https://Stackoverflow.com/users/41114",
"pm_score": 1,
"selected": false,
"text": "if (!confirm('Please click OK to change. Otherwise click CANCEL?')) return false;\n"
},
{
"answer_id": 16061689,
"author": "shailendra sharma",
"author_id": 2290912,
"author_profile": "https://Stackoverflow.com/users/2290912",
"pm_score": 0,
"selected": false,
"text": "<asp:DropDownList runat=\"server\" ID=\"ddlShailendra\" AutoPostBack=\"True\" OnSelectedIndexChanged=\"ddlShailendra_SelectedIndexChanged\" onchange=\"javascript: { if(confirm('Click ok to prevent post back, Cancel to make a postback'))return true;} \" >\n <asp:ListItem Text=\"tes\" Value=\"1\" ></asp:ListItem>\n <asp:ListItem Text=\"test\" Value=\"-1\"></asp:ListItem>\n </asp:DropDownList>\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73748",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/262613/"
] |
73,751 |
<p>I've heard people referring to this table and was not sure what it was about.</p>
|
[
{
"answer_id": 73772,
"author": "Sean McMains",
"author_id": 2041950,
"author_profile": "https://Stackoverflow.com/users/2041950",
"pm_score": 9,
"selected": true,
"text": "select sysdate from dual; select sysdate /* or other value */ from dual"
},
{
"answer_id": 73787,
"author": "Martin08",
"author_id": 8203,
"author_profile": "https://Stackoverflow.com/users/8203",
"pm_score": 4,
"selected": false,
"text": "Select 2*4 from dual Select sysdate from dual"
},
{
"answer_id": 73793,
"author": "mfx",
"author_id": 8015,
"author_profile": "https://Stackoverflow.com/users/8015",
"pm_score": 7,
"selected": false,
"text": " SELECT 3+4\n SELECT 3+4 FROM DUAL\n"
},
{
"answer_id": 73899,
"author": "steevc",
"author_id": 1895,
"author_profile": "https://Stackoverflow.com/users/1895",
"pm_score": 2,
"selected": false,
"text": "DECLARE\nx XMLTYPE;\nBEGIN\nSELECT xmlelement(\"hhh\", 'stuff')\nINTO x\nFROM dual;\nEND;\n"
},
{
"answer_id": 19224594,
"author": "AB01",
"author_id": 2568015,
"author_profile": "https://Stackoverflow.com/users/2568015",
"pm_score": 3,
"selected": false,
"text": "DUMMY\n----- \nX\n"
},
{
"answer_id": 48305056,
"author": "Newton fan 01",
"author_id": 5600260,
"author_profile": "https://Stackoverflow.com/users/5600260",
"pm_score": 1,
"selected": false,
"text": "select ... from dual DBMS_METADATA.GET_DDL select DBMS_METADATA.GET_DDL('TABLE','<table_name>') from DUAL;\n\nselect DBMS_METADATA.GET_DDL('FUNCTION','<function_name>') from DUAL;\n select my_function(<input_params>) from dual;\n"
},
{
"answer_id": 56107698,
"author": "Manjunatha B",
"author_id": 3912972,
"author_profile": "https://Stackoverflow.com/users/3912972",
"pm_score": 1,
"selected": false,
"text": "SELECT SYSDATE from dual; \n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3208/"
] |
73,781 |
<p>If I want to send mail not via SMTP, but rather via sendmail, is there a library for python that encapsulates this process?</p>
<p>Better yet, is there a good library that abstracts the whole 'sendmail -versus- smtp' choice?</p>
<p>I'll be running this script on a bunch of unix hosts, only some of which are listening on localhost:25; a few of these are part of embedded systems and can't be set up to accept SMTP.</p>
<p>As part of Good Practice, I'd really like to have the library take care of header injection vulnerabilities itself -- so just dumping a string to <code>popen('/usr/bin/sendmail', 'w')</code> is a little closer to the metal than I'd like.</p>
<p>If the answer is 'go write a library,' so be it ;-)</p>
|
[
{
"answer_id": 73844,
"author": "Pieter",
"author_id": 5822,
"author_profile": "https://Stackoverflow.com/users/5822",
"pm_score": 5,
"selected": false,
"text": "def sendMail():\n sendmail_location = \"/usr/sbin/sendmail\" # sendmail location\n p = os.popen(\"%s -t\" % sendmail_location, \"w\")\n p.write(\"From: %s\\n\" % \"[email protected]\")\n p.write(\"To: %s\\n\" % \"[email protected]\")\n p.write(\"Subject: thesubject\\n\")\n p.write(\"\\n\") # blank line separating headers from body\n p.write(\"body of the mail\")\n status = p.close()\n if status != 0:\n print \"Sendmail exit status\", status\n"
},
{
"answer_id": 74084,
"author": "Jim",
"author_id": 8427,
"author_profile": "https://Stackoverflow.com/users/8427",
"pm_score": 8,
"selected": true,
"text": "/usr/sbin/sendmail import sys\nfrom email.mime.text import MIMEText\nfrom subprocess import Popen, PIPE\n\n\nmsg = MIMEText(\"Here is the body of my message\")\nmsg[\"From\"] = \"[email protected]\"\nmsg[\"To\"] = \"[email protected]\"\nmsg[\"Subject\"] = \"This is the subject.\"\np = Popen([\"/usr/sbin/sendmail\", \"-t\", \"-oi\"], stdin=PIPE)\n# Both Python 2.X and 3.X\np.communicate(msg.as_bytes() if sys.version_info >= (3,0) else msg.as_string()) \n\n# Python 2.X\np.communicate(msg.as_string())\n\n# Python 3.X\np.communicate(msg.as_bytes())\n"
},
{
"answer_id": 17345007,
"author": "elec3647",
"author_id": 1842416,
"author_profile": "https://Stackoverflow.com/users/1842416",
"pm_score": -1,
"selected": false,
"text": "# Import smtplib for the actual sending function\nimport smtplib\n\n# Import the email modules we'll need\nfrom email.mime.text import MIMEText\n\n# Open a plain text file for reading. For this example, assume that\n# the text file contains only ASCII characters.\nfp = open(textfile, 'rb')\n# Create a text/plain message\nmsg = MIMEText(fp.read())\nfp.close()\n\n# me == the sender's email address\n# you == the recipient's email address\nmsg['Subject'] = 'The contents of %s' % textfile\nmsg['From'] = me\nmsg['To'] = you\n\n# Send the message via our own SMTP server, but don't include the\n# envelope header.\ns = smtplib.SMTP('localhost')\ns.sendmail(me, [you], msg.as_string())\ns.quit()\n"
},
{
"answer_id": 32673496,
"author": "MEI",
"author_id": 5351807,
"author_profile": "https://Stackoverflow.com/users/5351807",
"pm_score": 4,
"selected": false,
"text": "universal_newlines=True subrocess.Popen() from email.mime.text import MIMEText\nfrom subprocess import Popen, PIPE\n\nmsg = MIMEText(\"Here is the body of my message\")\nmsg[\"From\"] = \"[email protected]\"\nmsg[\"To\"] = \"[email protected]\"\nmsg[\"Subject\"] = \"This is the subject.\"\np = Popen([\"/usr/sbin/sendmail\", \"-t\", \"-oi\"], stdin=PIPE, universal_newlines=True)\np.communicate(msg.as_string())\n universal_newlines=True TypeError: 'str' does not support the buffer interface\n"
},
{
"answer_id": 61923564,
"author": "Robin Stewart",
"author_id": 7488171,
"author_profile": "https://Stackoverflow.com/users/7488171",
"pm_score": 3,
"selected": false,
"text": "import subprocess\nfrom email.message import EmailMessage\n\ndef sendEmail(from_addr, to_addrs, msg_subject, msg_body):\n msg = EmailMessage()\n msg.set_content(msg_body)\n msg['From'] = from_addr\n msg['To'] = to_addrs\n msg['Subject'] = msg_subject\n\n sendmail_location = \"/usr/sbin/sendmail\"\n subprocess.run([sendmail_location, \"-t\", \"-oi\"], input=msg.as_bytes())\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12779/"
] |
73,785 |
<p>I need to simply go through all the cells in a Excel Spreadsheet and check the values in the cells. The cells may contain text, numbers or be blank. I am not very familiar / comfortable working with the concept of 'Range'. Therefore, any sample codes would be greatly appreciated. (I did try to google it, but the code snippets I found didn't quite do what I needed)</p>
<p>Thank you.</p>
|
[
{
"answer_id": 73891,
"author": "Martin08",
"author_id": 8203,
"author_profile": "https://Stackoverflow.com/users/8203",
"pm_score": 0,
"selected": false,
"text": "Function getCellContent(Byref ws As Worksheet, ByVal rowindex As Integer, ByVal colindex As Integer) as String\n getCellContent = CStr(ws.Cells(rowindex, colindex))\nEnd Function\n"
},
{
"answer_id": 73900,
"author": "betelgeuce",
"author_id": 366182,
"author_profile": "https://Stackoverflow.com/users/366182",
"pm_score": 4,
"selected": true,
"text": "Sub CheckValues1()\n Dim rwIndex As Integer\n Dim colIndex As Integer\n For rwIndex = 1 To 10\n For colIndex = 1 To 5\n If Cells(rwIndex, colIndex).Value <> 0 Then _\n Cells(rwIndex, colIndex).Value = 0\n Next colIndex\n Next rwIndex\nEnd Sub\n"
},
{
"answer_id": 73907,
"author": "theo",
"author_id": 7870,
"author_profile": "https://Stackoverflow.com/users/7870",
"pm_score": 2,
"selected": false,
"text": "Public Sub IterateThroughRange()\n\nDim wb As Workbook\nDim ws As Worksheet\nDim rng As Range\nDim cell As Range\n\nSet wb = Application.Workbooks(1)\nSet ws = wb.Sheets(1)\nSet rng = ws.Range(\"A1\", \"C3\")\n\nFor Each cell In rng.Cells\n cell.Value = cell.Address\nNext cell\n\nEnd Sub\n"
},
{
"answer_id": 73912,
"author": "cori",
"author_id": 8151,
"author_profile": "https://Stackoverflow.com/users/8151",
"pm_score": 6,
"selected": false,
"text": "sub IterateCells()\n\n For Each Cell in ActiveSheet.UsedRange.Cells\n 'do some stuff\n Next\n\nEnd Sub\n"
},
{
"answer_id": 74006,
"author": "w4ik",
"author_id": 4232,
"author_profile": "https://Stackoverflow.com/users/4232",
"pm_score": 1,
"selected": false,
"text": "myWs = (Worksheet)MyWb.Worksheets[1];\n Range myBigRange = myWs.get_Range(\"A1\", \"A256\");\n\n string myValue;\n\n foreach(Range myCell in myBigRange )\n {\n myValue = myCell.Value2.ToString();\n }\n"
},
{
"answer_id": 74012,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "public sub CellProcessing()\non error goto errHandler\n\n dim MAX_ROW as Integer 'how many rows in the spreadsheet\n dim i as Integer\n dim cols as String\n\n for i = 1 to MAX_ROW\n 'perform checks on the cell here\n 'access the cell with Range(\"A\" & i) to get cell A1 where i = 1\n next i\n\nexitHandler:\n exit sub\nerrHandler:\n msgbox \"Error \" & err.Number & \": \" & err.Description\n resume exitHandler\nend sub\n"
},
{
"answer_id": 74209,
"author": "Cory Engebretson",
"author_id": 3406,
"author_profile": "https://Stackoverflow.com/users/3406",
"pm_score": 2,
"selected": false,
"text": "\n Excel.Range allCellsRng;\n string lowerRightCell = \"IV65536\";\n allCellsRng = ws.get_Range(\"A1\", lowerRightCell).Cells;\n foreach (Range cell in allCellsRng)\n {\n if (null == cell.Value2 || isBlank(cell.Value2))\n {\n // Do something.\n }\n else if (isText(cell.Value2))\n {\n // Do something.\n }\n else if (isNumeric(cell.Value2))\n {\n // Do something.\n }\n }\n"
},
{
"answer_id": 87577,
"author": "Jon Fournier",
"author_id": 5106,
"author_profile": "https://Stackoverflow.com/users/5106",
"pm_score": 3,
"selected": false,
"text": "Dim ValArray as Variant\nValArray = Range(\"A1:IV\" & Rows.Count).Value\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5899/"
] |
73,797 |
<p>How do I tell Subversion (svn) to treat a file as a binary file?</p>
|
[
{
"answer_id": 73820,
"author": "Jan Krüger",
"author_id": 12471,
"author_profile": "https://Stackoverflow.com/users/12471",
"pm_score": 3,
"selected": false,
"text": "svn propset svn:mime-type image/png foo.png\n"
},
{
"answer_id": 73834,
"author": "KTamas",
"author_id": 6541,
"author_profile": "https://Stackoverflow.com/users/6541",
"pm_score": 4,
"selected": false,
"text": "svn propset svn:mime-type application/octet-stream <filename>\n"
},
{
"answer_id": 73863,
"author": "Evil Andy",
"author_id": 4431,
"author_profile": "https://Stackoverflow.com/users/4431",
"pm_score": 4,
"selected": false,
"text": "svn propset svn:mime-type some/type filename.extension\n"
},
{
"answer_id": 73924,
"author": "grammar31",
"author_id": 12815,
"author_profile": "https://Stackoverflow.com/users/12815",
"pm_score": 2,
"selected": false,
"text": "svn propset svn:mime-type application/octet-stream example.txt"
},
{
"answer_id": 74017,
"author": "stormlash",
"author_id": 12657,
"author_profile": "https://Stackoverflow.com/users/12657",
"pm_score": 7,
"selected": true,
"text": "svn propset svn:mime-type application/octet-stream <filename>\n"
},
{
"answer_id": 11020623,
"author": "user1454388",
"author_id": 1454388,
"author_profile": "https://Stackoverflow.com/users/1454388",
"pm_score": 4,
"selected": false,
"text": "svn: E200009: File 'qt/examples/dialogs/configdialog/images/config.png' has inconsistent newlines\nsvn: E135000: Inconsistent line ending style\n svn add --no-auto-props qt/examples/dialogs/configdialog/images/config.png\nsvn propset svn:mime-type image/png qt/examples/dialogs/configdialog/images/config.png\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5222/"
] |
73,825 |
<p>This is about when a .NET remoting exception is thrown. If you take a look at MSDN, it will mention that a remoting exception is thrown when something goes wrong with remoting. If my server is not running, I get a socket exception which is fine.</p>
<p>What I am trying to figure out is: does getting a remoting exception indicate for sure that my server is up and running? If yes, that would solve the problem. If not: Is there a way to figure out if the remoting exception originated on the client side or the server side?</p>
<h3>Update:</h3>
<p>The problem I am trying to solve is that the server is down initially and then client sends some message to the server. Now I get a socket exception saying "No connection could be made..." which is fine.</p>
<p>There is a thread that is sending messages to the server at regular intervals to see if the server is available. Now, the server comes up, and at that point, you could get the response which is fine or you could get some exception and most probably it will be a remote exception. So, what I am trying to ask is that: in case I don't get a message and I get a remote exception is there a chance that the server is up and running and I am still getting this exception?</p>
<p>All I am doing is just calling a method on the remote object that does nothing and returns. If there is no exception then I am good. Now, if there is a remoting exception and if I knew the remoting exception occurred on the server then I know in spite getting the exception, I am connected to the server.</p>
|
[
{
"answer_id": 74382,
"author": "icelava",
"author_id": 2663,
"author_profile": "https://Stackoverflow.com/users/2663",
"pm_score": 0,
"selected": false,
"text": "HttpChannel channel = new HttpChannel();\nChannelServices.RegisterChannel(channel);\n\nIMyRemoteObject obj = (IMyRemoteObject) Activator.GetObject(\n typeof(IMyRemoteObject),\n \"http://localhost:1234/MyRemoteObject.soap\");\nConsole.WriteLine(\"Client.Main(): Reference to rem.obj. acquired\");\n int tmp = obj.GetValue();\n Console.WriteLine(\"Client.Main(): Original server side value: {0}\",tmp);\nConsole.WriteLine(\"Client.Main(): Will set value to 42\");\n\ntry\n{\n // This method will throw an ApplicationException in the server-side code.\n obj.SetValue(42);\n}\ncatch (Exception ex)\n{\n Console.WriteLine(\"=====\");\n Console.WriteLine(\"Exception type: \" + ex.GetType().ToString());\n Console.WriteLine(\"Message: \" + ex.Message);\n Console.WriteLine(\"Source: \" + ex.Source);\n Console.WriteLine(\"Stack trace: \" + ex.StackTrace);\n Console.WriteLine(\"=====\");\n}\n =====\nException type: System.ApplicationException\nMessage: testing\nSource: Server\nStack trace:\nServer stack trace:\n at Server.MyRemoteObject.SetValue(Int32 newval) in i:\\projects\\remoting.net\\ch03\\01_singlecallobjects\\server\\server.cs:line 27\n at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(MethodBase mb, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)\n at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)\n\nException rethrown at [0]:\n at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)\n at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)\n at General.IMyRemoteObject.SetValue(Int32 newval)\n at Client.Client.Main(String[] args) in i:\\projects\\remoting.net\\ch03\\01_singlecallobjects\\client\\client.cs:line 29\n=====\n"
},
{
"answer_id": 74630,
"author": "icelava",
"author_id": 2663,
"author_profile": "https://Stackoverflow.com/users/2663",
"pm_score": 0,
"selected": false,
"text": "IMyRemoteObject obj = (IMyRemoteObject) Activator.GetObject(\n typeof(IMyRemoteObject),\n \"tcp://localhost:80/MyRemoteObject.rem\");\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
73,833 |
<p>I want to search for files containing DOS line endings with grep on Linux. Something like this:</p>
<pre class="lang-sh prettyprint-override"><code>grep -IUr --color '\r\n' .
</code></pre>
<p>The above seems to match for literal <code>rn</code> which is not what is desired.</p>
<p>The output of this will be piped through xargs into todos to convert crlf to lf like this</p>
<pre><code>grep -IUrl --color '^M' . | xargs -ifile fromdos 'file'
</code></pre>
|
[
{
"answer_id": 73886,
"author": "pjz",
"author_id": 8002,
"author_profile": "https://Stackoverflow.com/users/8002",
"pm_score": 7,
"selected": false,
"text": "grep -IUr --color \"^M\"\n ^M -l -I -U -r"
},
{
"answer_id": 73969,
"author": "Thomee",
"author_id": 12825,
"author_profile": "https://Stackoverflow.com/users/12825",
"pm_score": 9,
"selected": true,
"text": "find . -not -type d -exec file \"{}\" \";\" | grep CRLF ./1/dos1.txt: ASCII text, with CRLF line terminators\n./2/dos2.txt: ASCII text, with CRLF line terminators\n./dos.txt: ASCII text, with CRLF line terminators"
},
{
"answer_id": 74739,
"author": "Linulin",
"author_id": 12481,
"author_profile": "https://Stackoverflow.com/users/12481",
"pm_score": 4,
"selected": false,
"text": "grep -lUP '\\r$'\n"
},
{
"answer_id": 3184434,
"author": "yabt",
"author_id": 384287,
"author_profile": "https://Stackoverflow.com/users/384287",
"pm_score": 4,
"selected": false,
"text": "# list files containing dos line endings (CRLF)\n\ncr=\"$(printf \"\\r\")\" # alternative to ctrl-V ctrl-M\n\ngrep -Ilsr \"${cr}$\" . \n\ngrep -Ilsr $'\\r$' . # yet another & even shorter alternative\n"
},
{
"answer_id": 3773573,
"author": "Peter Y",
"author_id": 455551,
"author_profile": "https://Stackoverflow.com/users/455551",
"pm_score": 2,
"selected": false,
"text": "0x0d 0x0d 0x0a grep -P '\\x0d\\x0a'\n grep -P '\\x0d\\x0d\\x0a'\n grep -P '\\x0d\\x0d'\n"
},
{
"answer_id": 7715813,
"author": "MykennaC",
"author_id": 30818,
"author_profile": "https://Stackoverflow.com/users/30818",
"pm_score": 1,
"selected": false,
"text": "$ for file in `find . -type f` ; do\n> dump $file | cut -c9-50 | egrep -m1 -q ' 0d| 0d'\n> if [ $? -eq 0 ] ; then echo $file ; fi\n> done\n od -t x2 -N 1000 $file | cut -c8- | egrep -m1 -q ' 0d| 0d|0d$'\n"
},
{
"answer_id": 13643222,
"author": "Zombo",
"author_id": 1002260,
"author_profile": "https://Stackoverflow.com/users/1002260",
"pm_score": 6,
"selected": false,
"text": "rg -l \\r\n -l, --files-with-matches\nOnly print the paths with at least one match.\n"
},
{
"answer_id": 47165349,
"author": "Murali Krishna Parimi",
"author_id": 5943385,
"author_profile": "https://Stackoverflow.com/users/5943385",
"pm_score": 2,
"selected": false,
"text": "$ file myfile\nmyfile: ISO-8859 text, with CRLF line terminators\n$ file myfile | grep -ow CRLF\nCRLF \n"
},
{
"answer_id": 61631159,
"author": "dessert",
"author_id": 6164712,
"author_profile": "https://Stackoverflow.com/users/6164712",
"pm_score": 2,
"selected": false,
"text": "dos2unix dos2unix -ic /path/to/file\n bash globstar shopt -s globstar dos2unix -ic ** # all files recursively\ndos2unix -ic **/file # files called “file” recursively\n find find -type f -exec dos2unix -ic {} + # all files recursively (ignoring directories)\nfind -name file -exec dos2unix -ic {} + # files called “file” recursively\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10245/"
] |
73,879 |
<p>I have a small to medium project that is in C++/CLI. I really hate the syntax extensions of C++/CLI and I would prefer to work in C#. Is there a tool that does a decent job of translating one to the other?</p>
<p><strong>EDIT:</strong> When I said Managed c++ before I apparently meant c++/CLI</p>
|
[
{
"answer_id": 71609586,
"author": "Shahin Dohan",
"author_id": 1469494,
"author_profile": "https://Stackoverflow.com/users/1469494",
"pm_score": 1,
"selected": false,
"text": "git mv Ctrl+H ^ :: . -> . nullptr null for each foreach gcnew new L\" \" L\"cool\" \"cool\" \"coo\" ClassName:: MyClass::MyMethod MyMethod MyType^ variable; MyType variable; MyType variable = new MyType(); ^ ^ BaseClass->DoStuff base.DoStuff if (foo) if (foo != 0) if (foo != null) OnSomeEvent MyEvent?.Invoke(this, EventArgs.Empty); dynamic_cast as (int) something gcnew new virtual override override Convert Convert.ToInt32 Convert e catch (Exception e) e // number is 2\nint number = 2;\n\nfor (int number = 0; number < 5; number++)\n{\n // number is now 0, and goes up to 4\n}\n\n// number is again 2!\n throw; SEHException % ref out * & If (this == null) { return; } vcxproj #ifdef #ifndef IDisposable Marshal.StructureToPtr #pragma make_public // put this at the top of the wrapper class, after includes\n#pragma make_public(SomeNamespace::NativeCppClass)\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8508/"
] |
73,881 |
<p>Currently, I am working on a new version control system as part of a final year project at University. The idea is to make it highly adaptable and pluggable.</p>
<p>We're using the OSGi framework (Equinox implementation) to manage our plug ins. My problem is that I can't find a simple & easy to use method for testing OSGi bundles.</p>
<p>Currently, I have to build the bundle using Maven and then execute a test harness. I'm looking for something like the JUnit test runner for Eclipse, as it will save me a bunch of time.</p>
<p>Is there a quick and easy way to test OSGi bundles?</p>
<p>EDIT: I don't need something to test Eclipse plug ins or GUI components, just OSGi bundles.</p>
<p>EDIT2: Is there some framework that supports JUnit4?</p>
|
[
{
"answer_id": 8128727,
"author": "rescdsk",
"author_id": 88198,
"author_profile": "https://Stackoverflow.com/users/88198",
"pm_score": 3,
"selected": false,
"text": "getServiceReference()"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12828/"
] |
73,883 |
<p>I understand the difference between <code>String</code> and <code>StringBuilder</code> (<code>StringBuilder</code> being mutable) but is there a large performance difference between the two? </p>
<p>The program I’m working on has a lot of case driven string appends (500+). Is using <code>StringBuilder</code> a better choice?</p>
|
[
{
"answer_id": 73929,
"author": "Jay Bazuzi",
"author_id": 5314,
"author_profile": "https://Stackoverflow.com/users/5314",
"pm_score": 9,
"selected": true,
"text": "StringBuilder"
},
{
"answer_id": 74028,
"author": "Steve g",
"author_id": 12092,
"author_profile": "https://Stackoverflow.com/users/12092",
"pm_score": 1,
"selected": false,
"text": "O(n^2) StringBuilder StringBuilder(int capacity) String StringBuilder"
},
{
"answer_id": 74053,
"author": "moswald",
"author_id": 8368,
"author_profile": "https://Stackoverflow.com/users/8368",
"pm_score": 3,
"selected": false,
"text": "string result = \"\";\nfor(int i = 0; i != N; ++i)\n{\n result = result + i.ToString(); // allocates a new string, then assigns it to result, which gets repeated N times\n}\n String result;\nStringBuilder sb = new StringBuilder(10000); // create a buffer of 10k\nfor(int i = 0; i != N; ++i)\n{\n sb.Append(i.ToString()); // fill the buffer, resizing if it overflows the buffer\n}\n\nresult = sb.ToString(); // assigns once\n"
},
{
"answer_id": 74136,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 6,
"selected": false,
"text": "string a,b,c,d;\n a = b + c + d;\n string a,b,c,d;\n a = a + b;\n a = a + c;\n a = a + d;\n string a,b,c,d;\nStringBuilder e = new StringBuilder();\n e.Append(b);\n e.Append(c);\n e.Append(d);\n a = e.ToString();\n"
},
{
"answer_id": 74233,
"author": "Matt Trunnell",
"author_id": 12894,
"author_profile": "https://Stackoverflow.com/users/12894",
"pm_score": 5,
"selected": false,
"text": "string buffer = \"The numbers are: \";\nfor( int i = 0; i < 5; i++)\n{\n buffer += i.ToString();\n}\nreturn buffer;\n 1 - \"The numbers are: \"\n2 - \"0\"\n3 - \"The numbers are: 0\"\n4 - \"1\"\n5 - \"The numbers are: 01\"\n6 - \"2\"\n7 - \"The numbers are: 012\"\n8 - \"3\"\n9 - \"The numbers are: 0123\"\n10 - \"4\"\n11 - \"The numbers are: 01234\"\n12 - \"5\"\n13 - \"The numbers are: 012345\"\n"
},
{
"answer_id": 74596,
"author": "Jason Jackson",
"author_id": 13103,
"author_profile": "https://Stackoverflow.com/users/13103",
"pm_score": 1,
"selected": false,
"text": "EnsureCapacity(int capacity) StringBuilder StringBuilder var sb = new StringBuilder(int capacity);\n Append()"
},
{
"answer_id": 75003,
"author": "calebjenkins",
"author_id": 13199,
"author_profile": "https://Stackoverflow.com/users/13199",
"pm_score": 5,
"selected": false,
"text": "string myString = \"Some stuff\" + var1 + \" more stuff\"\n + var2 + \" other stuff\" .... etc... etc...;\n StringBuilder sb = new StringBuilder();\nsb.Append(\"Some Stuff\");\nsb.Append(var1);\nsb.Append(\" more stuff\");\nsb.Append(var2);\nsb.Append(\"other stuff\");\n// etc.. etc.. etc..\n"
},
{
"answer_id": 76664,
"author": "JasonTrue",
"author_id": 13433,
"author_profile": "https://Stackoverflow.com/users/13433",
"pm_score": 2,
"selected": false,
"text": "StringBuilder int minutesPerYear = 24 * 365 * 60 StringBuilder StringBuilder"
},
{
"answer_id": 14567185,
"author": "CathalMF",
"author_id": 1680271,
"author_profile": "https://Stackoverflow.com/users/1680271",
"pm_score": 1,
"selected": false,
"text": "StringBuilder StringBuilder string s = string.Empty;\nStringBuilder sb = new StringBuilder();\n\nConsole.WriteLine(\"Beginning String + at \" + DateTime.Now.ToString());\n\nfor (int i = 0; i <= 50000; i++)\n{\n s = s + 'A';\n}\n\nConsole.WriteLine(\"Finished String + at \" + DateTime.Now.ToString());\nConsole.WriteLine();\n\nConsole.WriteLine(\"Beginning String + at \" + DateTime.Now.ToString());\n\nfor (int i = 0; i <= 200000; i++)\n{\n s = s + 'A';\n}\n\nConsole.WriteLine(\"Finished String + at \" + DateTime.Now.ToString());\nConsole.WriteLine();\nConsole.WriteLine(\"Beginning Sb append at \" + DateTime.Now.ToString());\n\nfor (int i = 0; i <= 1000000; i++)\n{\n sb.Append(\"A\");\n}\nConsole.WriteLine(\"Finished Sb append at \" + DateTime.Now.ToString());\n\nConsole.ReadLine();\n"
},
{
"answer_id": 17940168,
"author": "Diizzy",
"author_id": 1701599,
"author_profile": "https://Stackoverflow.com/users/1701599",
"pm_score": 5,
"selected": false,
"text": "String StringBuilder System.Diagnostics.Stopwatch time = new Stopwatch();\nstring test = string.Empty;\ntime.Start();\nfor (int i = 0; i < 100000; i++)\n{\n test += i;\n}\ntime.Stop();\nSystem.Console.WriteLine(\"Using String concatenation: \" + time.ElapsedMilliseconds + \" milliseconds\");\n StringBuilder test1 = new StringBuilder();\ntime.Reset();\ntime.Start();\nfor (int i = 0; i < 100000; i++)\n{\n test1.Append(i);\n}\ntime.Stop();\nSystem.Console.WriteLine(\"Using StringBuilder: \" + time.ElapsedMilliseconds + \" milliseconds\");\n StringBuilder StringBuilder"
},
{
"answer_id": 28749377,
"author": "Shamseer K",
"author_id": 4133590,
"author_profile": "https://Stackoverflow.com/users/4133590",
"pm_score": 4,
"selected": false,
"text": "StringBuilder String String System StringBuilder System.Text"
},
{
"answer_id": 53795136,
"author": "Rehan Shah",
"author_id": 10759317,
"author_profile": "https://Stackoverflow.com/users/10759317",
"pm_score": 4,
"selected": false,
"text": "System System.Text System Using System; System.text Using System.text; using System;\n\nnamespace StringVsStrigBuilder\n{\n class Program\n {\n static void Main(string[] args)\n {\n // String Example\n\n string name = \"Rehan\";\n name = name + \"Shah\";\n name = name + \"RS\";\n name = name + \"---\";\n name = name + \"I love to write programs.\";\n\n // Now when I run this program this output will be look like this.\n // output : \"Rehan Shah RS --- I love to write programs.\"\n }\n }\n}\n string name = \"Rehan\" string name using System;\nusing System.Text;\n\nnamespace StringVsStrigBuilder\n{\n class Program\n {\n static void Main(string[] args)\n {\n // StringBuilder Example\n\n StringBuilder name = new StringBuilder();\n name.Append(\"Rehan\");\n name.Append(\"Shah\");\n name.Append(\"RS\");\n name.Append(\"---\");\n name.Append(\"I love to write programs.\");\n\n\n // Now when I run this program this output will be look like this.\n // output : \"Rehan Shah Rs --- I love to write programs.\"\n }\n }\n}\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12623/"
] |
73,889 |
<p>What's the best framework for writing modules -- <a href="http://search.cpan.org/perldoc/ExtUtils::MakeMaker" rel="noreferrer">ExtUtils::MakeMaker</a> (h2xs) or <a href="http://search.cpan.org/perldoc/Module::Build" rel="noreferrer">Module::Build</a>?</p>
|
[
{
"answer_id": 214717,
"author": "Schwern",
"author_id": 14660,
"author_profile": "https://Stackoverflow.com/users/14660",
"pm_score": 7,
"selected": true,
"text": "configure_requires"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8233/"
] |
73,892 |
<p>How can I <strong>pre pend</strong> (insert at beginning of file) a file to all files of a type in folder and sub-folders using <code>Powershell</code>?</p>
<p>I need to add a standard header file to all <code>.cs</code> and was trying to use <code>Powershell</code> to do so, but while I was able to append it in a few lines of code I was stuck when trying to <strong>pre-pend</strong> it.</p>
|
[
{
"answer_id": 74073,
"author": "Mark Schill",
"author_id": 9482,
"author_profile": "https://Stackoverflow.com/users/9482",
"pm_score": 4,
"selected": true,
"text": "$Content = \"This is your content`n\"\nGet-ChildItem *.cs | foreach-object { \n$FileContents = Get-Content -Path $_\nSet-Content -Path $_ -Value ($Content + $FileContents)\n}\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73892",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11673/"
] |
73,927 |
<p>I'm looking into clustering points on a map (latitude/longitude). Are there any recommendations as to a suitable algorithm that is fast and scalable?</p>
<p>More specifically, I have a series of latitude/longitude coordinates and a map viewport. I'm trying to cluster the points that are close together in order to remove clutter.</p>
<p>I already have a solution to the problem (<a href="http://bouldr.net" rel="noreferrer">see here</a>), only I am wondering if there is any formal algorithm that solves the problem efficiently.</p>
|
[
{
"answer_id": 18633159,
"author": "user1530779",
"author_id": 1530779,
"author_profile": "https://Stackoverflow.com/users/1530779",
"pm_score": 1,
"selected": false,
"text": "static int OFFSET = 268435456;\n static double RADIUS = 85445659.4471;\n static double pi = 3.1444;\n\npublic static double lonToX(double lon) {\n return Math.round(OFFSET + RADIUS * lon * pi / 180);\n }\n\n public static double latToY(double lat) {\n return Math.round(OFFSET\n - RADIUS\n * Math.log((1 + Math.sin(lat * pi / 180))\n / (1 - Math.sin(lat * pi / 180))) / 2);\n }\n public static int pixelDistance(double lat1, double lon1, double lat2,\n double lon2, int zoom) {\n double x1 = lonToX(lon1);\n double y1 = latToY(lat1);\n\n double x2 = lonToX(lon2);\n double y2 = latToY(lat2);\n\n return (int) (Math\n .sqrt(Math.pow((x1 - x2), 2) + Math.pow((y1 - y2), 2))) >> (21 - zoom);\n }\n static ArrayList<Cluster> cluster(ArrayList<Marker> markers, int zoom) {\n\n ArrayList<Cluster> clusterList = new ArrayList<Cluster>();\n\n ArrayList<Marker> originalListCopy = new ArrayList<Marker>();\n\n for (Marker marker : markers) {\n originalListCopy.add(marker);\n }\n\n /* Loop until all markers have been compared. */\n for (int i = 0; i < originalListCopy.size();) {\n\n /* Compare against all markers which are left. */\n\n ArrayList<Marker> markerList = new ArrayList<Marker>();\n for (int j = i + 1; j < markers.size();) {\n int pixelDistance = pixelDistance(markers.get(i).getLatitude(),\n markers.get(i).getLongitude(), markers.get(j)\n .getLatitude(), markers.get(j).getLongitude(),\n zoom);\n\n if (pixelDistance < 40) {\n\n markerList.add(markers.get(i));\n markerList.add(markers.get(j));\n\n markers.remove(j);\n\n originalListCopy.remove(j);\n j = i + 1;\n } else {\n j++;\n }\n\n }\n\n if (markerList.size() > 0) {\n Cluster cluster = new Cluster(clusterList.size(), markerList,\n markerList.size() + 1, originalListCopy.get(i)\n .getLatitude(), originalListCopy.get(i)\n .getLongitude());\n clusterList.add(cluster);\n originalListCopy.remove(i);\n markers.remove(i);\n i = 0;\n\n } else {\n i++;\n }\n\n /* If a marker has been added to cluster, add also the one */\n /* we were comparing to and remove the original from array. */\n\n }\n return clusterList;\n }\n\nJust pass in your array list here containing latitude and longitude\n\nthen to display clusters\nhere goes the function\n\n\n@Override\n public void onTaskCompleted(ArrayList<FlatDetails> flatDetailsList) {\n\n LatLngBounds.Builder builder = new LatLngBounds.Builder();\n\n originalListCopy = new ArrayList<FlatDetails>();\n ArrayList<Marker> markersList = new ArrayList<Marker>();\n for (FlatDetails detailList : flatDetailsList) {\n\n markersList.add(new Marker(detailList.getLatitude(), detailList\n .getLongitude(), detailList.getApartmentTypeString()));\n\n originalListCopy.add(detailList);\n\n builder.include(new LatLng(detailList.getLatitude(), detailList\n .getLongitude()));\n\n }\n\n LatLngBounds bounds = builder.build();\n int padding = 0; // offset from edges of the map in pixels\n CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);\n\n googleMap.moveCamera(cu);\n\n ArrayList<Cluster> clusterList = Utils.cluster(markersList,\n (int) googleMap.getCameraPosition().zoom);\n\n // Removes all markers, overlays, and polylines from the map.\n googleMap.clear();\n\n // Zoom in, animating the camera.\n googleMap.animateCamera(CameraUpdateFactory.zoomTo(previousZoomLevel),\n 2000, null);\n\n CircleOptions circleOptions = new CircleOptions().center(point) //\n // setcenter\n .radius(3000) // set radius in meters\n .fillColor(Color.TRANSPARENT) // default\n .strokeColor(Color.BLUE).strokeWidth(5);\n\n googleMap.addCircle(circleOptions);\n\n for (Marker detail : markersList) {\n\n if (detail.getBhkTypeString().equalsIgnoreCase(\"1 BHK\")) {\n googleMap.addMarker(new MarkerOptions()\n .position(\n new LatLng(detail.getLatitude(), detail\n .getLongitude()))\n .snippet(String.valueOf(\"\"))\n .title(\"Flat\" + flatDetailsList.indexOf(detail))\n .icon(BitmapDescriptorFactory\n .fromResource(R.drawable.bhk1)));\n } else if (detail.getBhkTypeString().equalsIgnoreCase(\"2 BHK\")) {\n googleMap.addMarker(new MarkerOptions()\n .position(\n new LatLng(detail.getLatitude(), detail\n .getLongitude()))\n .snippet(String.valueOf(\"\"))\n .title(\"Flat\" + flatDetailsList.indexOf(detail))\n .icon(BitmapDescriptorFactory\n .fromResource(R.drawable.bhk_2)));\n\n }\n\n else if (detail.getBhkTypeString().equalsIgnoreCase(\"3 BHK\")) {\n googleMap.addMarker(new MarkerOptions()\n .position(\n new LatLng(detail.getLatitude(), detail\n .getLongitude()))\n .snippet(String.valueOf(\"\"))\n .title(\"Flat\" + flatDetailsList.indexOf(detail))\n .icon(BitmapDescriptorFactory\n .fromResource(R.drawable.bhk_3)));\n\n } else if (detail.getBhkTypeString().equalsIgnoreCase(\"2.5 BHK\")) {\n googleMap.addMarker(new MarkerOptions()\n .position(\n new LatLng(detail.getLatitude(), detail\n .getLongitude()))\n .snippet(String.valueOf(\"\"))\n .title(\"Flat\" + flatDetailsList.indexOf(detail))\n .icon(BitmapDescriptorFactory\n .fromResource(R.drawable.bhk2)));\n\n } else if (detail.getBhkTypeString().equalsIgnoreCase(\"4 BHK\")) {\n googleMap.addMarker(new MarkerOptions()\n .position(\n new LatLng(detail.getLatitude(), detail\n .getLongitude()))\n .snippet(String.valueOf(\"\"))\n .title(\"Flat\" + flatDetailsList.indexOf(detail))\n .icon(BitmapDescriptorFactory\n .fromResource(R.drawable.bhk_4)));\n\n } else if (detail.getBhkTypeString().equalsIgnoreCase(\"5 BHK\")) {\n googleMap.addMarker(new MarkerOptions()\n .position(\n new LatLng(detail.getLatitude(), detail\n .getLongitude()))\n .snippet(String.valueOf(\"\"))\n .title(\"Flat\" + flatDetailsList.indexOf(detail))\n .icon(BitmapDescriptorFactory\n .fromResource(R.drawable.bhk5)));\n\n } else if (detail.getBhkTypeString().equalsIgnoreCase(\"5+ BHK\")) {\n googleMap.addMarker(new MarkerOptions()\n .position(\n new LatLng(detail.getLatitude(), detail\n .getLongitude()))\n .snippet(String.valueOf(\"\"))\n .title(\"Flat\" + flatDetailsList.indexOf(detail))\n .icon(BitmapDescriptorFactory\n .fromResource(R.drawable.bhk_5)));\n\n }\n\n else if (detail.getBhkTypeString().equalsIgnoreCase(\"2 BHK\")) {\n googleMap.addMarker(new MarkerOptions()\n .position(\n new LatLng(detail.getLatitude(), detail\n .getLongitude()))\n .snippet(String.valueOf(\"\"))\n .title(\"Flat\" + flatDetailsList.indexOf(detail))\n .icon(BitmapDescriptorFactory\n .fromResource(R.drawable.bhk_2)));\n\n }\n }\n\n for (Cluster cluster : clusterList) {\n\n BitmapFactory.Options options = new BitmapFactory.Options();\n options.inMutable = true;\n options.inPurgeable = true;\n Bitmap bitmap = BitmapFactory.decodeResource(getResources(),\n R.drawable.cluster_marker, options);\n\n Canvas canvas = new Canvas(bitmap);\n\n Paint paint = new Paint();\n paint.setColor(getResources().getColor(R.color.white));\n paint.setTextSize(30);\n\n canvas.drawText(String.valueOf(cluster.getMarkerList().size()), 10,\n 40, paint);\n\n googleMap.addMarker(new MarkerOptions()\n .position(\n new LatLng(cluster.getClusterLatitude(), cluster\n .getClusterLongitude()))\n .snippet(String.valueOf(cluster.getMarkerList().size()))\n .title(\"Cluster\")\n .icon(BitmapDescriptorFactory.fromBitmap(bitmap)));\n\n }\n\n }\n\n\n\n\nANY QUESTIONS OR DOUBTS PLEASE ASK WILL CLEAR THEM ALL ...........THANKS\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12037/"
] |
73,930 |
<p>What do I need to add to my <code>.spec</code> file to create the desktop shortcut and assign an icon to the shortcut during install of my <code>.rpm</code>? If a script is required, an example would be very helpful.</p>
|
[
{
"answer_id": 74003,
"author": "akdom",
"author_id": 145,
"author_profile": "https://Stackoverflow.com/users/145",
"pm_score": 3,
"selected": false,
"text": "[Desktop Entry]\nEncoding=UTF-8\nGenericName=Generic Piece Of Software\nName=FooBar\nExec=/usr/bin/foo.sh\nIcon=foo.png\nTerminal=false\nType=Application\nCategories=Qt;Gnome;Applications;\n"
},
{
"answer_id": 36131913,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "gedit ~/.local/share/applications/NameYouWantForApplication.desktop\n [Desktop Entry]\nType=Application\nEncoding=UTF-8\nName=JeremysPentaho\nComment=Whatever Comment You want\nExec=/home/[email protected]/Source/Pentaho/data-integration/spoon.sh\nIcon=/home/[email protected]/Source/Pentaho/data-integration/NameOfmyIconFile.jpg\nTerminal=false\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
73,947 |
<p>I'm talking about an action game with no upper score limit and no way to verify the score on the server by replaying moves etc. </p>
<p>What I really need is the strongest encryption possible in Flash/PHP, and a way to prevent people calling the PHP page other than through my Flash file. I have tried some simple methods in the past of making multiple calls for a single score and completing a checksum / fibonacci sequence etc, and also obfuscating the SWF with Amayeta SWF Encrypt, but they were all hacked eventually.</p>
<p>Thanks to StackOverflow responses I have now found some more info from Adobe - <a href="http://www.adobe.com/devnet/flashplayer/articles/secure_swf_apps_12.html" rel="noreferrer">http://www.adobe.com/devnet/flashplayer/articles/secure_swf_apps_12.html</a> and <a href="https://github.com/mikechambers/as3corelib" rel="noreferrer">https://github.com/mikechambers/as3corelib</a> - which I think I can use for the encryption. Not sure this will get me around CheatEngine though.</p>
<p>I need to know the best solutions for both AS2 and AS3, if they are different.</p>
<p>The main problems seem to be things like TamperData and LiveHTTP headers, but I understand there are more advanced hacking tools as well - like CheatEngine (thanks Mark Webster)</p>
|
[
{
"answer_id": 74841,
"author": "tqbf",
"author_id": 5674,
"author_profile": "https://Stackoverflow.com/users/5674",
"pm_score": 10,
"selected": true,
"text": "hex-encoding( AES(secret-key-stored-only-on-server, timestamp, user-id, random-number))\n hex-encoding( AES(key-hardcoded-in-flash-game, random-128-bit-key))\n hex-encoding( AES(random-128-bit-key-from-above, high-score, SHA1(high-score)))\n"
},
{
"answer_id": 17994553,
"author": "Chris Panayotoff",
"author_id": 1584898,
"author_profile": "https://Stackoverflow.com/users/1584898",
"pm_score": 2,
"selected": false,
"text": "private function addPoint(event:Event = null):void{\n trace(\"expectedHash: \" + expectedHash + \" || new hash: \" + MD5.hash( Number(SCORES + POINT).toString() + expectedHashSalt) );\n if(expectedHash == MD5.hash( Number(SCORES + POINT).toString() + expectedHashSalt)){\n SCORES +=POINT;\n callPhp();\n expectedHash = MD5.hash( Number(SCORES + POINT).toString() + expectedHashSalt);\n } else {\n //trace(\"cheat engine usage\");\n }\n }\n package {\n\n import bassta.utils.Hash;\n\n public class ScoresEncoder {\n\n private static var ranChars:Array;\n private static var charsTable:Hash;\n\n public function ScoresEncoder() {\n\n }\n\n public static function init():void{\n\n ranChars = String(\"qwertyuiopasdfghjklzxcvbnm\").split(\"\")\n\n charsTable = new Hash({\n \"0\": \"x\",\n \"1\": \"f\",\n \"2\": \"q\",\n \"3\": \"z\",\n \"4\": \"a\",\n \"5\": \"o\",\n \"6\": \"n\",\n \"7\": \"p\",\n \"8\": \"w\",\n \"9\": \"y\"\n\n });\n\n }\n\n public static function encodeScore(_s:Number):String{\n\n var _fin:String = \"\";\n\n var scores:String = addLeadingZeros(_s);\n for(var i:uint = 0; i< scores.length; i++){\n //trace( scores.charAt(i) + \" - > \" + charsTable[ scores.charAt(i) ] );\n _fin += charsTable[ scores.charAt(i) ];\n }\n\n return _fin;\n\n }\n\n public static function decodeScore(_s:String):String{\n\n var _fin:String = \"\";\n\n var decoded:String = _s;\n\n for(var i:uint = 0; i< decoded.length; i++){\n //trace( decoded.charAt(i) + \" - > \" + charsTable.getKey( decoded.charAt(i) ) );\n _fin += charsTable.getKey( decoded.charAt(i) );\n }\n\n return _fin;\n\n }\n\n public static function encodeScoreRand(_s:Number):String{\n var _fin:String = \"\";\n\n _fin += generateRandomChars(10) + encodeScore(_s) + generateRandomChars(3)\n\n return _fin;\n }\n\n public static function decodeScoreRand(_s:String):Number{\n\n var decodedString:String = _s;\n var decoded:Number;\n\n decodedString = decodedString.substring(10,13); \n decodedString = decodeScore(decodedString);\n\n decoded = Number(decodedString);\n\n return decoded;\n }\n\n public static function generateRandomChars(_length:Number):String{\n\n var newRandChars:String = \"\";\n\n for(var i:uint = 0; i< _length; i++){\n newRandChars+= ranChars[ Math.ceil( Math.random()*ranChars.length-1 )];\n }\n\n return newRandChars;\n }\n\n private static function addLeadingZeros(_s:Number):String{\n\n var _fin:String;\n\n if(_s < 10 ){\n _fin = \"00\" + _s.toString();\n }\n\n if(_s >= 10 && _s < 99 ) {\n _fin = \"0\" + _s.toString();\n }\n\n if(_s >= 100 ) {\n _fin = _s.toString();\n } \n\n return _fin;\n }\n\n\n }//end\n}\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11911/"
] |
73,950 |
<p>How can I combine multiple PDFs into one PDF without a 3rd party component?</p>
|
[
{
"answer_id": 22138935,
"author": "Sajitha Rathnayake",
"author_id": 2345900,
"author_profile": "https://Stackoverflow.com/users/2345900",
"pm_score": 2,
"selected": false,
"text": "string[] lstFiles=new string[3];\n lstFiles[0]=@\"C:/pdf/1.pdf\";\n lstFiles[1]=@\"C:/pdf/2.pdf\";\n lstFiles[2]=@\"C:/pdf/3.pdf\";\n\n PdfReader reader = null;\n Document sourceDocument = null;\n PdfCopy pdfCopyProvider = null;\n PdfImportedPage importedPage;\n string outputPdfPath=@\"C:/pdf/new.pdf\";\n\n\n sourceDocument = new Document();\n pdfCopyProvider = new PdfCopy(sourceDocument, new System.IO.FileStream(outputPdfPath, System.IO.FileMode.Create));\n\n //Open the output file\n sourceDocument.Open();\n\n try\n {\n //Loop through the files list\n for (int f = 0; f < lstFiles.Length-1; f++)\n {\n int pages =get_pageCcount(lstFiles[f]);\n\n reader = new PdfReader(lstFiles[f]);\n //Add pages of current file\n for (int i = 1; i <= pages; i++)\n {\n importedPage = pdfCopyProvider.GetImportedPage(reader, i);\n pdfCopyProvider.AddPage(importedPage);\n }\n\n reader.Close();\n }\n //At the end save the output file\n sourceDocument.Close();\n }\n catch (Exception ex)\n {\n throw ex;\n }\n\n\nprivate int get_pageCcount(string file)\n{\n using (StreamReader sr = new StreamReader(File.OpenRead(file)))\n {\n Regex regex = new Regex(@\"/Type\\s*/Page[^s]\");\n MatchCollection matches = regex.Matches(sr.ReadToEnd());\n\n return matches.Count;\n }\n}\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
73,958 |
<p>In a shellscript, I'd like to set the IP of my box, run a command, then move to the next IP. The IPs are an entire C block.</p>
<p>The question is how do I set the IP of the box without editing a file? What command sets the IP on Slackware?</p>
<p>Thanks</p>
|
[
{
"answer_id": 74039,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "ifconfig eth0 192.168.0.42 up"
},
{
"answer_id": 74058,
"author": "tialaramex",
"author_id": 9654,
"author_profile": "https://Stackoverflow.com/users/9654",
"pm_score": 0,
"selected": false,
"text": "ip addr add 10.1.2.3 dev eth0\n ip addr del 10.1.2.3 dev eth0\n ifconfig eth0 10.1.2.3 netmask 255.255.255.0\n"
},
{
"answer_id": 75221,
"author": "Thomee",
"author_id": 12825,
"author_profile": "https://Stackoverflow.com/users/12825",
"pm_score": 2,
"selected": false,
"text": "#!/bin/bash\nSUBNET=192.168.135.\nETH=eth0\n\nfor i in {1..254}\ndo\n ip addr add ${SUBNET}${i}/24 dev ${ETH}\n\n # do whatever you want here\n\n ip addr del ${SUBNET}${i}/24 dev ${ETH}\ndone"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
73,960 |
<p>In IE, the dropdown-list takes the same width as the dropbox (I hope I am making sense) whereas in Firefox the dropdown-list's width varies according to the content. </p>
<p>This basically means that I have to make sure that the dropbox is wide enough to display the longest selection possible. This makes my page look very ugly :(</p>
<p>Is there any workaround for this problem?
How can I use CSS to set different widths for dropbox and the dropdownlist?</p>
|
[
{
"answer_id": 74062,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<select name=\"foo\" style=\"width: 200px\">"
},
{
"answer_id": 74550,
"author": "Sleep Deprivation Ninja",
"author_id": 13002,
"author_profile": "https://Stackoverflow.com/users/13002",
"pm_score": 4,
"selected": false,
"text": "<select> <span class=\"select-box\"> <script src=\"http://us.js2.yimg.com/us.js.yimg.com/lib/common/utils/2/yahoo_2.0.0-b3.js\" type=\"text/javascript\">\n</script>\n<script src=\"http://us.js2.yimg.com/us.js.yimg.com/lib/common/utils/2/event_2.0.0-b3.js\" type=\"text/javascript\">\n</script>\n<script src=\"http://us.js2.yimg.com/us.js.yimg.com/lib/common/utils/2/dom_2.0.2-b3.js\" type=\"text/javascript\">\n</script>\n<script src=\"ie-select-width-fix.js\" type=\"text/javascript\">\n</script>\n<script>\n// for each select box you want to affect, apply this:\nvar s1 = new YAHOO.Hack.FixIESelectWidth( 's1' ); // s1 is the ID of the select box you want to affect\n</script>\n"
},
{
"answer_id": 912435,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "$(document).ready(function(){\n\n $(\"#dropdown\").mousedown(function(){\n if($.browser.msie) {\n $(this).css(\"width\",\"auto\");\n }\n });\n $(\"#dropdown\").change(function(){\n if ($.browser.msie) {\n $(this).css(\"width\",\"175px\");\n }\n });\n\n});\n"
},
{
"answer_id": 1037055,
"author": "Tinus",
"author_id": 121290,
"author_profile": "https://Stackoverflow.com/users/121290",
"pm_score": 3,
"selected": false,
"text": "$(document).ready(function(){\n $(\"#dropdown\").mousedown(function(){\n if($.browser.msie) {\n $(this).css(\"width\",\"auto\");\n }\n });\n $(\"#dropdown\").change(function(){\n if ($.browser.msie) {\n $(this).css(\"width\",\"175px\");\n }\n });\n $(\"#dropdown\").blur(function(){\n if ($.browser.msie) {\n $(this).css(\"width\",\"175px\");\n }\n });\n});\n"
},
{
"answer_id": 1383840,
"author": "Justin Fisher",
"author_id": 169060,
"author_profile": "https://Stackoverflow.com/users/169060",
"pm_score": 3,
"selected": false,
"text": "<style>\nselect{width:100px}\n</style>\n\n<html>\n<select onmousedown=\"if($.browser.msie){this.style.position='absolute';this.style.width='auto'}\" onblur=\"this.style.position='';this.style.width=''\">\n <option>One</option>\n <option>Two - A long option that gets cut off in IE</option>\n</select>\n</html>\n"
},
{
"answer_id": 1568875,
"author": "bluwater2001",
"author_id": 175111,
"author_profile": "https://Stackoverflow.com/users/175111",
"pm_score": 2,
"selected": false,
"text": ".ctrDropDown\n{\n width:420px; <%--this is the actual width of the dropdown list--%>\n}\n.ctrDropDownClick\n{\n width:420px; <%-- this the width of the dropdown select box.--%>\n}\n\n<div style=\"width:170px; overflow:hidden;\">\n<asp:DropDownList runat=\"server\" ID=\"ddlApplication\" onmouseout = \"this.className='ctrDropDown';\" onmouseover =\"this.className='ctrDropDownClick';\" class=\"ctrDropDown\" onBlur=\"this.className='ctrDropDown';\" onMouseDown=\"this.className='ctrDropDownClick';\" onChange=\"this.className='ctrDropDown';\"></asp:DropDownList>\n</div>\n .ctrDropDown\n{\n width:170px; <%--this is the actual width of the dropdown list--%>\n}\n.ctrDropDownClick\n{\n width:auto; <%-- this the width of the dropdown select box.--%>\n}\n"
},
{
"answer_id": 2516571,
"author": "BalusC",
"author_id": 157882,
"author_profile": "https://Stackoverflow.com/users/157882",
"pm_score": 8,
"selected": true,
"text": "if (!$.support.leadingWhitespace) { // if IE6/7/8\n $('select.wide')\n .bind('focus mouseover', function() { $(this).addClass('expand').removeClass('clicked'); })\n .bind('click', function() { $(this).toggleClass('clicked'); })\n .bind('mouseout', function() { if (!$(this).hasClass('clicked')) { $(this).removeClass('expand'); }})\n .bind('blur', function() { $(this).removeClass('expand clicked'); });\n}\n select {\n width: 150px; /* Or whatever width you want. */\n}\nselect.expand {\n width: auto;\n}\n wide <select class=\"wide\">\n ...\n</select>\n"
},
{
"answer_id": 2969250,
"author": "Sai",
"author_id": 337515,
"author_profile": "https://Stackoverflow.com/users/337515",
"pm_score": 4,
"selected": false,
"text": " styleClass=\"someStyleWidth\"\n onmousedown=\"javascript:if(navigator.appName=='Microsoft Internet Explorer'){this.style.position='absolute';this.style.width='auto'}\" \n onblur=\"this.style.position='';this.style.width=''\"\n"
},
{
"answer_id": 3048216,
"author": "lucien",
"author_id": 367610,
"author_profile": "https://Stackoverflow.com/users/367610",
"pm_score": 2,
"selected": false,
"text": "onmousedown=\"javascript:if(navigator.appName=='Microsoft Internet Explorer'){this.style.width='auto'}\" \nonchange=\"this.style.width='35%'\"\nonblur=\"this.style.width='35%'\"\n"
},
{
"answer_id": 3303191,
"author": "lhoess",
"author_id": 398403,
"author_profile": "https://Stackoverflow.com/users/398403",
"pm_score": 0,
"selected": false,
"text": "$(document).ready(function(){\n $(\"#dropdown\").mouseover(function(){\n if($.browser.msie) {\n $(this).css(\"width\",\"auto\");\n }\n });\n $(\"#dropdown\").change(function(){\n if ($.browser.msie) {\n $(\"#dropdown\").trigger(\"mouseover\");\n }\n });\n\n});\n"
},
{
"answer_id": 3494994,
"author": "jbabey",
"author_id": 386152,
"author_profile": "https://Stackoverflow.com/users/386152",
"pm_score": 2,
"selected": false,
"text": ".bind('mouseover', function() { $(this).addClass('expand').removeClass('clicked');\n if ($(this).width() < 300) // put your desired minwidth here\n {\n $(this).removeClass('expand');\n }})\n"
},
{
"answer_id": 6389369,
"author": "Derrick",
"author_id": 265100,
"author_profile": "https://Stackoverflow.com/users/265100",
"pm_score": 2,
"selected": false,
"text": " $(document).ready(function () {\n if (document.all) {\n\n $('#<%=cboDisability.ClientID %>').mousedown(function () {\n $('#<%=cboDisability.ClientID %>').css({ 'width': 'auto' });\n });\n\n $('#<%=cboDisability.ClientID %>').blur(function () {\n $(this).css({ 'width': '208px' });\n });\n\n $('#<%=cboDisability.ClientID %>').change(function () {\n $('#<%=cboDisability.ClientID %>').css({ 'width': '208px' });\n });\n\n $('#<%=cboEthnicity.ClientID %>').mousedown(function () {\n $('#<%=cboEthnicity.ClientID %>').css({ 'width': 'auto' });\n });\n\n $('#<%=cboEthnicity.ClientID %>').blur(function () {\n $(this).css({ 'width': '208px' });\n });\n\n $('#<%=cboEthnicity.ClientID %>').change(function () {\n $('#<%=cboEthnicity.ClientID %>').css({ 'width': '208px' });\n });\n\n }\n });\n <div id=\"dvEthnicity\" style=\"width: 208px; overflow: hidden; position: relative; float: right;\"><asp:DropDownList CssClass=\"select\" ID=\"cboEthnicity\" runat=\"server\" DataTextField=\"description\" DataValueField=\"id\" Width=\"200px\"></asp:DropDownList></div>\n"
},
{
"answer_id": 7312042,
"author": "Federico Valido",
"author_id": 929457,
"author_profile": "https://Stackoverflow.com/users/929457",
"pm_score": 1,
"selected": false,
"text": "function fixIeCombos() {\n if ($.browser.msie && $.browser.version < 9) {\n var style = $('<style>select.expand { width: auto; }</style>');\n $('html > head').append(style);\n\n var defaultWidth = \"200\";\n\n // get predefined combo's widths.\n var widths = new Array();\n $('select.wide').each(function() {\n var width = $(this).width();\n if (!width) {\n width = defaultWidth;\n }\n widths[$(this).attr('id')] = width;\n });\n\n $('select.wide')\n .bind('focus mouseover', function() {\n // We're going to do the expansion only if the resultant size is bigger\n // than the original size of the combo.\n // In order to find out the resultant size, we first clon the combo as\n // a hidden element, add to the dom, and then test the width.\n var originalWidth = widths[$(this).attr('id')];\n\n var $selectClone = $(this).clone();\n $selectClone.addClass('expand').hide();\n $(this).after( $selectClone );\n var expandedWidth = $selectClone.width()\n $selectClone.remove();\n if (expandedWidth > originalWidth) {\n $(this).addClass('expand').removeClass('clicked');\n }\n })\n .bind('click', function() {\n $(this).toggleClass('clicked'); \n })\n .bind('mouseout', function() {\n if (!$(this).hasClass('clicked')) {\n $(this).removeClass('expand');\n }\n })\n .bind('blur', function() {\n $(this).removeClass('expand clicked');\n })\n }\n}\n"
},
{
"answer_id": 7659553,
"author": "Ahmad Alfy",
"author_id": 497828,
"author_profile": "https://Stackoverflow.com/users/497828",
"pm_score": 0,
"selected": false,
"text": "$(document).ready(function() {\n if ($.browser.msie) $('select.wide')\n .bind('onmousedown', function() { $(this).css({position:'absolute',width:'auto'}); })\n .bind('blur', function() { $(this).css({position:'static',width:''}); });\n});\n"
},
{
"answer_id": 9115565,
"author": "mcmwhfy",
"author_id": 1057912,
"author_profile": "https://Stackoverflow.com/users/1057912",
"pm_score": 2,
"selected": false,
"text": "select:focus{\n min-width:165px;\n width:auto;\n z-index:9999999999;\n position:absolute;\n}\n"
},
{
"answer_id": 9200617,
"author": "n0nag0n",
"author_id": 721019,
"author_profile": "https://Stackoverflow.com/users/721019",
"pm_score": 0,
"selected": false,
"text": "onmousedown=\"if(navigator.appName=='Microsoft Internet Explorer'){this.style.position='absolute';this.style.width='auto'}\nonblur=\"if(navigator.appName=='Microsoft Internet Explorer'){this.style.position=''; this.style.width= '225px';}\"\n <td valign=\"top\" style=\"width:225px; overflow:hidden;\">\n <div style=\"position: absolute; z-index: 5;\" onmousedown=\"var select = document.getElementById('select'); if(navigator.appName=='Microsoft Internet Explorer'){select.style.position='absolute';select.style.width='auto'}\">\n <select name=\"select_name\" id=\"select\" style=\"width: 225px;\" onblur=\"if(navigator.appName=='Microsoft Internet Explorer'){this.style.position=''; this.style.width= '225px';}\" onChange=\"reportFormValues('filter_<?=$job_id?>','form_values')\">\n <option value=\"0\">All</option>\n <!--More Options-->\n </select>\n </div>\n</td>\n"
},
{
"answer_id": 10497987,
"author": "Arif",
"author_id": 1196718,
"author_profile": "https://Stackoverflow.com/users/1196718",
"pm_score": 0,
"selected": false,
"text": "<!-- begin hiding\nfunction expandSELECT(sel) {\n sel.style.width = '';\n}\n\nfunction contractSELECT(sel) {\n sel.style.width = '100px';\n}\n// end hiding -->\n <select name=\"sideeffect\" id=\"sideeffect\" style=\"width:100px;\" onfocus=\"expandSELECT(this);\" onblur=\"contractSELECT(this);\" >\n <option value=\"0\" selected=\"selected\" readonly=\"readonly\">Select</option>\n <option value=\"1\" >Apple</option>\n <option value=\"2\" >Orange + Banana + Grapes</option>\n"
},
{
"answer_id": 13035783,
"author": "RasTheDestroyer",
"author_id": 836366,
"author_profile": "https://Stackoverflow.com/users/836366",
"pm_score": 0,
"selected": false,
"text": "$(document).ready(function () {\n\nvar clicknum = 0;\n\n$('.dropdown').click(\n function() {\n clicknum++;\n if (clicknum == 2) {\n clicknum = 0;\n $(this).css('position', '');\n $(this).css('width', '');\n }\n }).blur(\n function() {\n $(this).css('position', '');\n $(this).css('width', '');\n clicknum = 0;\n }).focus(\n function() {\n $(this).css('position', 'relative');\n $(this).css('width', 'auto');\n }).mousedown(\n function() {\n $(this).css('position', 'relative');\n $(this).css('width', 'auto');\n });\n})(jQuery);\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/747/"
] |
73,964 |
<p>I would like to turn the HTML generated by my CFM page into a PDF, and have the user prompted with the standard "Save As" prompt when navigating to my page.</p>
|
[
{
"answer_id": 74374,
"author": "Soldarnal",
"author_id": 3420,
"author_profile": "https://Stackoverflow.com/users/3420",
"pm_score": 5,
"selected": true,
"text": "<cfdocument format=\"PDF\" filename=\"file.pdf\" overwrite=\"Yes\">\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n<html>\n<head>\n <title>Hello World</title>\n</head>\n<body>\n Hello World\n</body>\n</html>\n</cfdocument>\n<cfheader name=\"Content-Disposition\" value=\"attachment;filename=file.pdf\">\n<cfcontent type=\"application/octet-stream\" file=\"#expandPath('.')#\\file.pdf\" deletefile=\"Yes\">\n"
},
{
"answer_id": 88297,
"author": "Andy Waschick",
"author_id": 6000,
"author_profile": "https://Stackoverflow.com/users/6000",
"pm_score": 2,
"selected": false,
"text": "<cfdocument> <cfdocument> <cfx_pdf>"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2232/"
] |
73,971 |
<p>In JavaScript, what is the best way to determine if a date provided falls within a valid range?</p>
<p>An example of this might be checking to see if the user input <code>requestedDate</code> is part of the next valid work week. Note that this is not just checking to see if one date is larger than another as a valid date would be equal to or greater than the lower end of the range while less than or equal to the upper end of the range.</p>
|
[
{
"answer_id": 74024,
"author": "Jesper Blad Jensen",
"author_id": 11559,
"author_profile": "https://Stackoverflow.com/users/11559",
"pm_score": 3,
"selected": false,
"text": "function ValidRange(date1,date2)\n{\n return date2.getTime() > date1.getTime();\n}\n ValidRange(Date.parse('10-10-2008'),Date.parse('11-11-2008'));\n"
},
{
"answer_id": 74040,
"author": "rjzii",
"author_id": 1185,
"author_profile": "https://Stackoverflow.com/users/1185",
"pm_score": 5,
"selected": true,
"text": "// checkDateRange - Checks to ensure that the values entered are dates and \n// are of a valid range. By this, the dates must be no more than the \n// built-in number of days appart.\nfunction checkDateRange(start, end) {\n // Parse the entries\n var startDate = Date.parse(start);\n var endDate = Date.parse(end);\n // Make sure they are valid\n if (isNaN(startDate)) {\n alert(\"The start date provided is not valid, please enter a valid date.\");\n return false;\n }\n if (isNaN(endDate)) {\n alert(\"The end date provided is not valid, please enter a valid date.\");\n return false;\n }\n // Check the date range, 86400000 is the number of milliseconds in one day\n var difference = (endDate - startDate) / (86400000 * 7);\n if (difference < 0) {\n alert(\"The start date must come before the end date.\");\n return false;\n }\n if (difference <= 1) {\n alert(\"The range must be at least seven days apart.\");\n return false;\n }\n return true;\n}\n Date.parse"
},
{
"answer_id": 74051,
"author": "Grant Wagner",
"author_id": 9254,
"author_profile": "https://Stackoverflow.com/users/9254",
"pm_score": 3,
"selected": false,
"text": "var myDate = new Date(2008, 9, 16);\n\n// is myDate between Sept 1 and Sept 30?\n\nvar startDate = new Date(2008, 9, 1);\nvar endDate = new Date(2008, 9, 30);\n\nif (startDate < myDate && myDate < endDate) {\n alert('yes');\n // myDate is between startDate and endDate\n}\n var now = new Date();\n now.setYear(...);\nnow.setMonth(...);\n// etc\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/73971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1185/"
] |
74,010 |
<p>I am a bit rusty on my cursor lingo in PL/SQL. Anyone know this?</p>
|
[
{
"answer_id": 74105,
"author": "Dave Costa",
"author_id": 6568,
"author_profile": "https://Stackoverflow.com/users/6568",
"pm_score": 2,
"selected": false,
"text": "CURSOR my_cursor IS\n SELECT table_name FROM USER_TABLES\n"
},
{
"answer_id": 74135,
"author": "stjohnroe",
"author_id": 2985,
"author_profile": "https://Stackoverflow.com/users/2985",
"pm_score": 4,
"selected": false,
"text": "DECLARE \nCURSOR cur IS \n SELECT columns FROM table WHERE condition;\nBEGIN\n...\n ...\nBEGIN\n SELECT columns INTO variables FROM table where condition;\nEND;\n...\n"
},
{
"answer_id": 76178,
"author": "Sten Vesterli",
"author_id": 9363,
"author_profile": "https://Stackoverflow.com/users/9363",
"pm_score": 6,
"selected": true,
"text": "SELECT col INTO var FROM table WHERE something;\n DECLARE \n CURSOR cur IS SELECT col FROM table WHERE something; \nBEGIN\n OPEN cur;\n FETCH cur INTO var;\n CLOSE cur;\nEND;\n"
},
{
"answer_id": 2833203,
"author": "UltraCommit",
"author_id": 297267,
"author_profile": "https://Stackoverflow.com/users/297267",
"pm_score": 1,
"selected": false,
"text": "BEGIN\n DECLARE\n CURSOR C1\n IS\n SELECT DROPPED_CALLS FROM ALARM_UMTS;\n\n C1_REC C1%ROWTYPE;\n BEGIN\n FOR C1_REC IN C1\n LOOP\n DBMS_OUTPUT.PUT_LINE ('DROPPED CALLS: ' || C1_REC.DROPPED_CALLS);\n END LOOP;\n END;\nEND;\n/\n BEGIN\n DECLARE\n CURSOR C1\n IS\n SELECT DROPPED_CALLS FROM ALARM_UMTS;\n\n C1_REC C1%ROWTYPE;\n BEGIN\n OPEN c1;\n\n LOOP\n FETCH c1 INTO c1_rec;\n\n EXIT WHEN c1%NOTFOUND;\n\n DBMS_OUTPUT.PUT_LINE ('DROPPED CALLS: ' || C1_REC.DROPPED_CALLS);\n END LOOP;\n\n CLOSE c1;\n END;\nEND;\n/\n"
},
{
"answer_id": 9258147,
"author": "Ganesh Pathare",
"author_id": 1206438,
"author_profile": "https://Stackoverflow.com/users/1206438",
"pm_score": 2,
"selected": false,
"text": "declare \n cursor emp_cursor \n is \n select id,name,salary,dept_id \n from employees; \n v_id employees.id%type; \n v_name employees.name%type; \n v_salary employees.salary%type; \n v_dept_id employees.dept_id%type; \n begin \n open emp_cursor; \n loop \n fetch emp_cursor into v_id,v_name,v_salary,v_dept_id; \n exit when emp_cursor%notfound;\n dbms_output.put_line(v_id||', '||v_name||', '||v_salary||','||v_dept_id); \n end loop; \n close emp_cursor; \n end;\n"
},
{
"answer_id": 28938170,
"author": "Lalit Kumar B",
"author_id": 3989608,
"author_profile": "https://Stackoverflow.com/users/3989608",
"pm_score": 2,
"selected": false,
"text": "SQL> DECLARE\n 2 l_loops NUMBER := 100000;\n 3 l_dummy dual.dummy%TYPE;\n 4 l_start NUMBER;\n 5 -- explicit cursor declaration\n 6 CURSOR c_dual IS\n 7 SELECT dummy\n 8 FROM dual;\n 9 BEGIN\n 10 l_start := DBMS_UTILITY.get_time;\n 11 -- explicitly open, fetch and close the cursor\n 12 FOR i IN 1 .. l_loops LOOP\n 13 OPEN c_dual;\n 14 FETCH c_dual\n 15 INTO l_dummy;\n 16 CLOSE c_dual;\n 17 END LOOP;\n 18\n 19 DBMS_OUTPUT.put_line('Explicit: ' ||\n 20 (DBMS_UTILITY.get_time - l_start) || ' hsecs');\n 21\n 22 l_start := DBMS_UTILITY.get_time;\n 23 -- implicit cursor for loop\n 24 FOR i IN 1 .. l_loops LOOP\n 25 SELECT dummy\n 26 INTO l_dummy\n 27 FROM dual;\n 28 END LOOP;\n 29\n 30 DBMS_OUTPUT.put_line('Implicit: ' ||\n 31 (DBMS_UTILITY.get_time - l_start) || ' hsecs');\n 32 END;\n 33 /\nExplicit: 332 hsecs\nImplicit: 176 hsecs\n\nPL/SQL procedure successfully completed.\n"
},
{
"answer_id": 47336170,
"author": "Vadzim",
"author_id": 603516,
"author_profile": "https://Stackoverflow.com/users/603516",
"pm_score": 1,
"selected": false,
"text": "begin\n for cur in (\n select t.id from parent_trx pt inner join trx t on pt.nested_id = t.id\n where t.started_at > sysdate - 31 and t.finished_at is null and t.extended_code is null\n )\n loop\n update trx set finished_at=sysdate, extended_code = -1 where id = cur.id;\n update parent_trx set result_code = -1 where nested_id = cur.id;\n end loop cur;\nend;\n"
},
{
"answer_id": 55813639,
"author": "GOVIND DIXIT",
"author_id": 8549281,
"author_profile": "https://Stackoverflow.com/users/8549281",
"pm_score": 1,
"selected": false,
"text": "CURSOR cursor_name IS select_statement; \n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3208/"
] |
74,019 |
<p>How can I specify the filename when dumping data into the response stream?</p>
<p>Right now I'm doing the following:</p>
<pre><code>byte[] data= GetFoo();
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/pdf";
Response.BinaryWrite(data);
Response.End();
</code></pre>
<p>With the code above, I get "foo.aspx.pdf" as the filename to save. I seem to remember being able to add a header to the response to specify the filename to save.</p>
|
[
{
"answer_id": 74044,
"author": "Sklivvz",
"author_id": 7028,
"author_profile": "https://Stackoverflow.com/users/7028",
"pm_score": 4,
"selected": false,
"text": "Response.AppendHeader(\"Content-Disposition\", \"attachment; filename=foo.pdf\");\n"
},
{
"answer_id": 74049,
"author": "Ryan Farley",
"author_id": 1627,
"author_profile": "https://Stackoverflow.com/users/1627",
"pm_score": 7,
"selected": true,
"text": "Response.AddHeader(\"content-disposition\", @\"attachment;filename=\"\"MyFile.pdf\"\"\");\n"
},
{
"answer_id": 74060,
"author": "Kibbee",
"author_id": 1862,
"author_profile": "https://Stackoverflow.com/users/1862",
"pm_score": 1,
"selected": false,
"text": " Response.AddHeader(\"Content-Disposition\", \"attachment;filename=\" & FileName & \";\")\n"
},
{
"answer_id": 14347162,
"author": "EMR",
"author_id": 729980,
"author_profile": "https://Stackoverflow.com/users/729980",
"pm_score": 5,
"selected": false,
"text": "Response.AppendHeader(\"content-disposition\", string.Format(\"inline;FileName=\\\"{0}\\\"\", fileName));\n"
},
{
"answer_id": 30972670,
"author": "Sam",
"author_id": 238753,
"author_profile": "https://Stackoverflow.com/users/238753",
"pm_score": 2,
"selected": false,
"text": "ContentDisposition Response.AppendHeader(\"Content-Disposition\", new ContentDisposition\n{\n FileName = yourFilename\n}.ToString());\n ContentDisposition.ToString()"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1672/"
] |
74,032 |
<p>I'm looking for real world best practices, how other people might have implemented solutions with complex domains.</p>
|
[
{
"answer_id": 74070,
"author": "Eric Schoonover",
"author_id": 3957,
"author_profile": "https://Stackoverflow.com/users/3957",
"pm_score": 2,
"selected": false,
"text": "IEqualityComparer Hashtable NameValueCollection OrderedDictionary IComparer Dictionary<(Of <(TKey, TValue>)>)"
},
{
"answer_id": 74110,
"author": "Chris Marasti-Georg",
"author_id": 96,
"author_profile": "https://Stackoverflow.com/users/96",
"pm_score": 1,
"selected": false,
"text": "IComparer<T> IEqualityComparer<T>"
},
{
"answer_id": 533826,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "public class GenericEqualityComparer<T> : IEqualityComparer<T>\n{\n private Func<T, T, Boolean> _comparer;\n private Func<T, int> _hashCodeEvaluator;\n public GenericEqualityComparer(Func<T, T, Boolean> comparer)\n {\n _comparer = comparer;\n }\n\n public GenericEqualityComparer(Func<T, T, Boolean> comparer, Func<T, int> hashCodeEvaluator)\n {\n _comparer = comparer;\n _hashCodeEvaluator = hashCodeEvaluator;\n }\n\n #region IEqualityComparer<T> Members\n\n public bool Equals(T x, T y)\n {\n return _comparer(x, y);\n }\n\n public int GetHashCode(T obj)\n {\n if(obj == null) {\n throw new ArgumentNullException(\"obj\");\n }\n if(_hashCodeEvaluator == null) {\n return 0;\n } \n return _hashCodeEvaluator(obj);\n }\n\n #endregion\n}\n var comparer = new GenericEqualityComparer<ShopByProduct>((x, y) => x.ProductId == y.ProductId);\nvar current = SelectAll().Where(p => p.ShopByGroup == group).ToList();\nvar toDelete = current.Except(products, comparer);\nvar toAdd = products.Except(current, comparer);\n var comparer = new GenericEqualityComparer<ShopByProduct>(\n (x, y) => { return x.ProductId == y.ProductId; }, \n (x) => { return x.Product.GetHashCode()}\n);\n"
},
{
"answer_id": 1535426,
"author": "dahlbyk",
"author_id": 54249,
"author_profile": "https://Stackoverflow.com/users/54249",
"pm_score": 4,
"selected": false,
"text": "IEqualityComparer<T> IEquatable<T> Product StringComparer IEquatable<T> class ProductByIdComparer : GenericEqualityComparer<ShopByProduct>\n{\n public ProductByIdComparer()\n : base((x, y) => x.ProductId == y.ProductId, z => z.ProductId)\n { }\n}\n ToLower() StringComparer"
},
{
"answer_id": 4679491,
"author": "Peet Brits",
"author_id": 371917,
"author_profile": "https://Stackoverflow.com/users/371917",
"pm_score": 3,
"selected": false,
"text": "obj.GetHashCode();"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5802/"
] |
74,057 |
<p>Is there a way to use sql-server like analytic functions in Hibernate?</p>
<p>Something like </p>
<pre><code>select foo from Foo foo where f.x = max(f.x) over (partition by f.y)
</code></pre>
|
[
{
"answer_id": 75287,
"author": "Jason Weathered",
"author_id": 3736,
"author_profile": "https://Stackoverflow.com/users/3736",
"pm_score": 3,
"selected": false,
"text": "Query q = em.createNativeQuery(\"select foo.* from Foo foo \" +\n \"where f.x = max(f.x) over \" +\n \"(partition by f.y)\", Foo.class);\n Query q = session.createSQLQuery(\"select {foo.*} from Foo foo \" +\n \"where f.x = max(f.x) over \"+\n \"(partition by f.y)\");\nq.addEntity(\"foo\", Foo.class);\n"
},
{
"answer_id": 33003427,
"author": "Eric Mayes",
"author_id": 1661071,
"author_profile": "https://Stackoverflow.com/users/1661071",
"pm_score": 2,
"selected": false,
"text": "public class ExtendedDialect extends Oracle10gDialect{\n public ExtendedDialect()\n {\n super();\n registerKeyword(\"over\");\n registerKeyword(\"partition\");\n }\n}\n <property name=\"jpaVendorAdapter\">\n <bean class=\"org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter\">\n <property name=\"databasePlatform\" value=\"path.to.dialect.ExtendedDialect\" />\n </bean>\n </property>\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12905/"
] |
74,083 |
<p>When using Business Objects' CrystalReportViewer control, how can you detect and manually print the report the user has currently drilled into? You can print this automatically using the Print() method of the CrystalReportViewer, but I want to be able to do a manual printing of this report.</p>
<p>It is possible to print the main ReportSource of the CrystalReportViewer, but I need to know what report the user has drilled into and then do a manual printing of that particular drill down. Any ideas?</p>
|
[
{
"answer_id": 75287,
"author": "Jason Weathered",
"author_id": 3736,
"author_profile": "https://Stackoverflow.com/users/3736",
"pm_score": 3,
"selected": false,
"text": "Query q = em.createNativeQuery(\"select foo.* from Foo foo \" +\n \"where f.x = max(f.x) over \" +\n \"(partition by f.y)\", Foo.class);\n Query q = session.createSQLQuery(\"select {foo.*} from Foo foo \" +\n \"where f.x = max(f.x) over \"+\n \"(partition by f.y)\");\nq.addEntity(\"foo\", Foo.class);\n"
},
{
"answer_id": 33003427,
"author": "Eric Mayes",
"author_id": 1661071,
"author_profile": "https://Stackoverflow.com/users/1661071",
"pm_score": 2,
"selected": false,
"text": "public class ExtendedDialect extends Oracle10gDialect{\n public ExtendedDialect()\n {\n super();\n registerKeyword(\"over\");\n registerKeyword(\"partition\");\n }\n}\n <property name=\"jpaVendorAdapter\">\n <bean class=\"org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter\">\n <property name=\"databasePlatform\" value=\"path.to.dialect.ExtendedDialect\" />\n </bean>\n </property>\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
74,092 |
<p>I have a function in Python which is iterating over the attributes returned from <code>dir(obj)</code>, and I want to check to see if any of the objects contained within is a function, method, built-in function, etc. Normally you could use <code>callable()</code> for this, but I don't want to include classes. The best I've come up with so far is:</p>
<pre><code>isinstance(obj, (types.BuiltinFunctionType, types.FunctionType, types.MethodType))
</code></pre>
<p>Is there a more future-proof way to do this check?</p>
<p><strong>Edit:</strong> I misspoke before when I said: "Normally you could use <code>callable()</code> for this, but I don't want to disqualify classes." I actually <em>do</em> want to disqualify classes. I want to match <em>only</em> functions, not classes.</p>
|
[
{
"answer_id": 74138,
"author": "Jim",
"author_id": 8427,
"author_profile": "https://Stackoverflow.com/users/8427",
"pm_score": 2,
"selected": false,
"text": "if hasattr(obj, '__call__'): pass\n callable()"
},
{
"answer_id": 74295,
"author": "dF.",
"author_id": 3002,
"author_profile": "https://Stackoverflow.com/users/3002",
"pm_score": 3,
"selected": false,
"text": "__call__ inspect inspect.isfunction(obj)\ninspect.isbuiltin(obj)\ninspect.ismethod(obj)\n"
},
{
"answer_id": 75370,
"author": "Matthieu",
"author_id": 9310,
"author_profile": "https://Stackoverflow.com/users/9310",
"pm_score": 1,
"selected": false,
"text": "callable( obj ) and not inspect.isclass( obj )\n callable( obj ) and not isinstance( obj, types.ClassType )\n >>> callable( dict ) and not inspect.isclass( dict )\nFalse\n>>> callable( dict ) and not isinstance( dict, types.ClassType )\nTrue\n"
},
{
"answer_id": 75507,
"author": "Matthieu",
"author_id": 9310,
"author_profile": "https://Stackoverflow.com/users/9310",
"pm_score": 5,
"selected": true,
"text": "inspect.isroutine( obj )\n def isroutine(object):\n \"\"\"Return true if the object is any kind of function or method.\"\"\"\n return (isbuiltin(object)\n or isfunction(object)\n or ismethod(object)\n or ismethoddescriptor(object))\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/156/"
] |
74,108 |
<p>I wrote a script to export twitter friends as foaf rdf description. Now I'm looking for a tool to visualize the friend networks. I tried <a href="http://foafscape.berlios.de/" rel="nofollow noreferrer">http://foafscape.berlios.de/</a> but for 300+ Nodes it is really slow and does a bad job on auto formatting.</p>
<p>Any hints for good graph visualization tools? It's ok if they do not support foaf directly, but they should be able to use images for graph nodes and be able to display large graphs. Linux support would be nice.</p>
<p>Oh, and I'm searching for an interactive tool where I can move nodes by hand.</p>
<p><strong>Update:</strong> Thanks for your input. I know graphviz and for static images it is really great. But for large datasets I need to be able to select nodes and highlight all neighbours. </p>
<ul>
<li><strong>Prefuse</strong> looks great: <a href="http://prefuse.org/gallery/graphview/" rel="nofollow noreferrer">http://prefuse.org/gallery/graphview/</a></li>
<li>trough prefuse I found <strong>vizster</strong>, which is exactly what I search (just need to find some sourcecode) <a href="http://jheer.org/vizster/" rel="nofollow noreferrer">http://jheer.org/vizster/</a></li>
</ul>
|
[
{
"answer_id": 74395,
"author": "wxs",
"author_id": 12981,
"author_profile": "https://Stackoverflow.com/users/12981",
"pm_score": 2,
"selected": false,
"text": "graph G {\n \"George Formby\" [shape=custom, shapefile=\"file:formby.png\"];\n \"Michael Jackson\" [shape=custom, shapefile=\"file:jackson.png\"];\n \"George Formby\" -- \"Michael Jackson\";\n \"Fred Flinstone\" -- \"Michael Jackson\";\n \"Michael Jackson\" -- \"Steve McQueen\";\n}\n dot -Tpdf foaf.dot > foaf.pdf\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/720/"
] |
74,113 |
<p>It seems obvious that some people have been able to figure out how to access the iPhone camera through the SDK (Spore Origins, for example). How can this be done?</p>
|
[
{
"answer_id": 74255,
"author": "wxs",
"author_id": 12981,
"author_profile": "https://Stackoverflow.com/users/12981",
"pm_score": 7,
"selected": true,
"text": "UIImagePickerController UIImagePickerController *picker = [[UIImagePickerController alloc] init];\npicker.delegate = pickerDelegate\npicker.sourceType = UIImagePickerControllerSourceTypeCamera\n pickerDelegate - (void)imagePickerController:(UIImagePickerController *)picker\n didFinishPickingMediaWithInfo:(NSDictionary *)info\n info UIImagePickerControllerOriginalImage UIImagePickerControllerEditedImage"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5338/"
] |
74,126 |
<p>I have a Windows XP SP2 virtual machine which can be accessed via VNC. It's also running Deep Freeze so there should be no problem in forcing it to reboot. I am looking for a way to force the operating system to reboot instead of shutting down or completely remove the ability to shut down the machine using software applications (such as the usual way from the start menu, the shutdown program or other custom programs).</p>
<p>Thank you,
Tom</p>
|
[
{
"answer_id": 74143,
"author": "Alex Fort",
"author_id": 12624,
"author_profile": "https://Stackoverflow.com/users/12624",
"pm_score": 3,
"selected": false,
"text": "shutdown /r /t 1 /f"
},
{
"answer_id": 74156,
"author": "Toby Mills",
"author_id": 12377,
"author_profile": "https://Stackoverflow.com/users/12377",
"pm_score": 1,
"selected": false,
"text": "shutdown /?"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
74,148 |
<p>How do you convert between hexadecimal numbers and decimal numbers in C#?</p>
|
[
{
"answer_id": 74183,
"author": "Sklivvz",
"author_id": 7028,
"author_profile": "https://Stackoverflow.com/users/7028",
"pm_score": 2,
"selected": false,
"text": "String stringrep = myintvar.ToString(\"X\");\n\nint num = int.Parse(\"FF\", System.Globalization.NumberStyles.HexNumber);\n"
},
{
"answer_id": 74185,
"author": "Jesper Blad Jensen",
"author_id": 11559,
"author_profile": "https://Stackoverflow.com/users/11559",
"pm_score": 5,
"selected": false,
"text": "Convert.ToInt64(value, 16)\n otherVar.ToString(\"X\");\n"
},
{
"answer_id": 74191,
"author": "Rob",
"author_id": 12413,
"author_profile": "https://Stackoverflow.com/users/12413",
"pm_score": 4,
"selected": false,
"text": "// Store integer 182\nint decValue = 182;\n\n// Convert integer 182 as a hex in a string variable\nstring hexValue = decValue.ToString(\"X\");\n\n// Convert the hex string back to the number\nint decAgain = int.Parse(hexValue, System.Globalization.NumberStyles.HexNumber);\n"
},
{
"answer_id": 74198,
"author": "Jonathan Rupp",
"author_id": 12502,
"author_profile": "https://Stackoverflow.com/users/12502",
"pm_score": 6,
"selected": false,
"text": "Convert.ToInt64(hexString, 16);\n string.Format(\"{0:x}\", intValue);\n"
},
{
"answer_id": 74223,
"author": "Andy McCluggage",
"author_id": 3362,
"author_profile": "https://Stackoverflow.com/users/3362",
"pm_score": 9,
"selected": true,
"text": "string hexValue = decValue.ToString(\"X\");\n int decValue = int.Parse(hexValue, System.Globalization.NumberStyles.HexNumber);\n int decValue = Convert.ToInt32(hexValue, 16);\n"
},
{
"answer_id": 2484244,
"author": "Ecstatic Coder",
"author_id": 298120,
"author_profile": "https://Stackoverflow.com/users/298120",
"pm_score": 1,
"selected": false,
"text": " static string chex(byte e) // Convert a byte to a string representing that byte in hexadecimal\n {\n string r = \"\";\n string chars = \"0123456789ABCDEF\";\n r += chars[e >> 4];\n return r += chars[e &= 0x0F];\n } // Easy enough...\n\n static byte CRAZY_BYTE(string t, int i) // Take a byte, if zero return zero, else throw exception (i=0 means false, i>0 means true)\n {\n if (i == 0) return 0;\n throw new Exception(t);\n }\n\n static byte hbyte(string e) // Take 2 characters: these are hex chars, convert it to a byte\n { // WARNING: This code will make small children cry. Rated R.\n e = e.ToUpper(); // \n string msg = \"INVALID CHARS\"; // The message that will be thrown if the hex str is invalid\n\n byte[] t = new byte[] // Gets the 2 characters and puts them in seperate entries in a byte array.\n { // This will throw an exception if (e.Length != 2).\n (byte)e[CRAZY_BYTE(\"INVALID LENGTH\", e.Length ^ 0x02)], \n (byte)e[0x01] \n };\n\n for (byte i = 0x00; i < 0x02; i++) // Convert those [ascii] characters to [hexadecimal] characters. Error out if either character is invalid.\n {\n t[i] -= (byte)((t[i] >= 0x30) ? 0x30 : CRAZY_BYTE(msg, 0x01)); // Check for 0-9\n t[i] -= (byte)((!(t[i] < 0x0A)) ? (t[i] >= 0x11 ? 0x07 : CRAZY_BYTE(msg, 0x01)) : 0x00); // Check for A-F\n } \n\n return t[0x01] |= t[0x00] <<= 0x04; // The moment of truth.\n }\n"
},
{
"answer_id": 4474966,
"author": "Omair",
"author_id": 546562,
"author_profile": "https://Stackoverflow.com/users/546562",
"pm_score": 1,
"selected": false,
"text": " public string octal_to_decimal(string m_value)\n {\n double i, j, x = 0;\n Int64 main_value;\n int k = 0;\n bool pw = true, ch;\n int position_pt = m_value.IndexOf(\".\");\n if (position_pt == -1)\n {\n main_value = Convert.ToInt64(m_value);\n ch = false;\n }\n else\n {\n main_value = Convert.ToInt64(m_value.Remove(position_pt, m_value.Length - position_pt));\n ch = true;\n }\n\n while (k <= 1)\n {\n do\n {\n i = main_value % 10; // Return Remainder\n i = i * Convert.ToDouble(Math.Pow(8, x)); // calculate power\n if (pw)\n x++;\n else\n x--;\n o_to_d = o_to_d + i; // Saving Required calculated value in main variable\n main_value = main_value / 10; // Dividing the main value \n }\n while (main_value >= 1);\n if (ch)\n {\n k++;\n main_value = Convert.ToInt64(Reversestring(m_value.Remove(0, position_pt + 1)));\n }\n else\n k = 2;\n pw = false;\n x = -1;\n }\n return (Convert.ToString(o_to_d));\n } \n"
},
{
"answer_id": 6205484,
"author": "msanjay",
"author_id": 392985,
"author_profile": "https://Stackoverflow.com/users/392985",
"pm_score": 2,
"selected": false,
"text": "String hex = \"68c7b05d0000000002f8\";\n// results in \"494809724602834812404472\"\nString decimal = new Org.BouncyCastle.Math.BigInteger(hex, 16).ToString();\n"
},
{
"answer_id": 6666767,
"author": "Luke Puplett",
"author_id": 107783,
"author_profile": "https://Stackoverflow.com/users/107783",
"pm_score": -1,
"selected": false,
"text": " /// <summary>\n /// Turns the byte array into its Hex representation.\n /// </summary>\n public static string ToHex(this byte[] y)\n {\n StringBuilder sb = new StringBuilder();\n foreach (byte b in y)\n {\n sb.Append(b.ToString(\"X\").PadLeft(2, \"0\"[0]));\n }\n return sb.ToString();\n }\n"
},
{
"answer_id": 9126750,
"author": "Vadym Stetsiak",
"author_id": 6952,
"author_profile": "https://Stackoverflow.com/users/6952",
"pm_score": 4,
"selected": false,
"text": "class TableConvert\n {\n static sbyte[] unhex_table =\n { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1\n ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1\n ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1\n , 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1\n ,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1\n ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1\n ,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1\n ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1\n };\n\n public static int Convert(string hexNumber)\n {\n int decValue = unhex_table[(byte)hexNumber[0]];\n for (int i = 1; i < hexNumber.Length; i++)\n {\n decValue *= 16;\n decValue += unhex_table[(byte)hexNumber[i]];\n }\n return decValue;\n }\n }\n"
},
{
"answer_id": 21079586,
"author": "Chris Panayotoff",
"author_id": 1584898,
"author_profile": "https://Stackoverflow.com/users/1584898",
"pm_score": -1,
"selected": false,
"text": "using System;\nusing System.Collections.Generic;\nclass HexadecimalToDecimal\n{\n static Dictionary<char, int> hexdecval = new Dictionary<char, int>{\n {'0', 0},\n {'1', 1},\n {'2', 2},\n {'3', 3},\n {'4', 4},\n {'5', 5},\n {'6', 6},\n {'7', 7},\n {'8', 8},\n {'9', 9},\n {'a', 10},\n {'b', 11},\n {'c', 12},\n {'d', 13},\n {'e', 14},\n {'f', 15},\n };\n\n static decimal HexToDec(string hex)\n {\n decimal result = 0;\n hex = hex.ToLower();\n\n for (int i = 0; i < hex.Length; i++)\n {\n char valAt = hex[hex.Length - 1 - i];\n result += hexdecval[valAt] * (int)Math.Pow(16, i);\n }\n\n return result;\n }\n\n static void Main()\n {\n\n Console.WriteLine(\"Enter Hexadecimal value\");\n string hex = Console.ReadLine().Trim();\n\n //string hex = \"29A\";\n Console.WriteLine(\"Hex {0} is dec {1}\", hex, HexToDec(hex));\n\n Console.ReadKey();\n }\n}\n"
},
{
"answer_id": 28408141,
"author": "Mihók Balázs",
"author_id": 4545945,
"author_profile": "https://Stackoverflow.com/users/4545945",
"pm_score": 0,
"selected": false,
"text": "using System;\nusing System.Collections.Generic;\n\nstatic class Tool\n{\n public static string DecToHex(int x)\n {\n string result = \"\";\n\n while (x != 0)\n {\n if ((x % 16) < 10)\n result = x % 16 + result;\n else\n {\n string temp = \"\";\n\n switch (x % 16)\n {\n case 10: temp = \"A\"; break;\n case 11: temp = \"B\"; break;\n case 12: temp = \"C\"; break;\n case 13: temp = \"D\"; break;\n case 14: temp = \"E\"; break;\n case 15: temp = \"F\"; break;\n }\n\n result = temp + result;\n }\n\n x /= 16;\n }\n\n return result;\n }\n\n public static int HexToDec(string x)\n {\n int result = 0;\n int count = x.Length - 1;\n for (int i = 0; i < x.Length; i++)\n {\n int temp = 0;\n switch (x[i])\n {\n case 'A': temp = 10; break;\n case 'B': temp = 11; break;\n case 'C': temp = 12; break;\n case 'D': temp = 13; break;\n case 'E': temp = 14; break;\n case 'F': temp = 15; break;\n default: temp = -48 + (int)x[i]; break; // -48 because of ASCII\n }\n\n result += temp * (int)(Math.Pow(16, count));\n count--;\n }\n\n return result;\n }\n}\n\nclass Program\n{\n static void Main(string[] args)\n {\n Console.Write(\"Enter Decimal value: \");\n int decNum = int.Parse(Console.ReadLine());\n\n Console.WriteLine(\"Dec {0} is hex {1}\", decNum, Tool.DecToHex(decNum));\n\n Console.Write(\"\\nEnter Hexadecimal value: \");\n string hexNum = Console.ReadLine().ToUpper();\n\n Console.WriteLine(\"Hex {0} is dec {1}\", hexNum, Tool.HexToDec(hexNum));\n\n Console.ReadKey();\n }\n}\n"
},
{
"answer_id": 29939746,
"author": "Jewel",
"author_id": 4845704,
"author_profile": "https://Stackoverflow.com/users/4845704",
"pm_score": 0,
"selected": false,
"text": "Convert.ToString(Convert.ToUInt32(binary1, 2), 16).ToUpper()\n"
},
{
"answer_id": 44120599,
"author": "user7925882",
"author_id": 7925882,
"author_profile": "https://Stackoverflow.com/users/7925882",
"pm_score": 2,
"selected": false,
"text": "Convert.ToInt32(number, 16);\n int.Parse(number, System.Globalization.NumberStyles.HexNumber)\n"
},
{
"answer_id": 49569835,
"author": "Aravin",
"author_id": 3058254,
"author_profile": "https://Stackoverflow.com/users/3058254",
"pm_score": 2,
"selected": false,
"text": "using System.Numerics;\n...\nvar bigNumber = BigInteger.Parse(\"837593454735734579347547357233757342857087879423437472347757234945743\");\nConsole.WriteLine(bigNumber.ToString(\"X\"));\n 4F30DC39A5B10A824134D5B18EEA3707AC854EE565414ED2E498DCFDE1A15DA5FEB6074AE248458435BD417F06F674EB29A2CFECF\n"
},
{
"answer_id": 54082994,
"author": "Krisztián Molnár",
"author_id": 10881471,
"author_profile": "https://Stackoverflow.com/users/10881471",
"pm_score": -1,
"selected": false,
"text": " public static string DecToHex(long a)\n {\n int n = 1;\n long b = a;\n while (b > 15)\n {\n b /= 16;\n n++;\n }\n string[] t = new string[n];\n int i = 0, j = n - 1;\n do\n {\n if (a % 16 == 10) t[i] = \"A\";\n else if (a % 16 == 11) t[i] = \"B\";\n else if (a % 16 == 12) t[i] = \"C\";\n else if (a % 16 == 13) t[i] = \"D\";\n else if (a % 16 == 14) t[i] = \"E\";\n else if (a % 16 == 15) t[i] = \"F\";\n else t[i] = (a % 16).ToString();\n a /= 16;\n i++;\n }\n while ((a * 16) > 15);\n string[] r = new string[n];\n for (i = 0; i < n; i++)\n {\n r[i] = t[j];\n j--;\n }\n string res = string.Concat(r);\n return res;\n }\n"
},
{
"answer_id": 67015650,
"author": "MohsenB",
"author_id": 1358148,
"author_profile": "https://Stackoverflow.com/users/1358148",
"pm_score": 0,
"selected": false,
"text": "const int decimal_places = 4;\nconst int int_places = 4;\nstatic readonly string decimal_places_format = $\"X{decimal_places}\";\nstatic readonly string int_places_format = $\"X{int_places}\";\n\npublic static string DecimaltoHex(decimal number)\n{\n var n = (int)Math.Truncate(number);\n var f = (int)Math.Truncate((number - n) * ((decimal)Math.Pow(10, decimal_places)));\n return $\"{string.Format($\"{{0:{int_places_format}}}\", n)}{string.Format($\"{{0:{decimal_places_format}}}\", f)}\";\n}\n\npublic static decimal HextoDecimal(string number)\n{\n var n = number.Substring(0, number.Length - decimal_places);\n var f = number.Substring(number.Length - decimal_places);\n return decimal.Parse($\"{int.Parse(n, System.Globalization.NumberStyles.HexNumber)}.{int.Parse(f, System.Globalization.NumberStyles.HexNumber)}\");\n}\n"
},
{
"answer_id": 67652913,
"author": "Dejan Dozet",
"author_id": 4541566,
"author_profile": "https://Stackoverflow.com/users/4541566",
"pm_score": 1,
"selected": false,
"text": "public static decimal HexToDec(string hex)\n{\n if (hex.Length % 2 == 1)\n hex = \"0\" + hex;\n byte[] raw = new byte[hex.Length / 2];\n decimal d = 0;\n for (int i = 0; i < raw.Length; i++)\n {\n raw[i] = Convert.ToByte(hex.Substring(i * 2, 2), 16);\n d += Math.Pow(256, (raw.Length - 1 - i)) * raw[i];\n }\n return d.ToString();\n return d;\n}\n"
},
{
"answer_id": 68256392,
"author": "Rakibul",
"author_id": 12944359,
"author_profile": "https://Stackoverflow.com/users/12944359",
"pm_score": 1,
"selected": false,
"text": " var decValue = int.Parse(Console.ReadLine());\n string hex = string.Format(\"{0:x}\", decValue);\n Console.WriteLine(hex);\n var hexval = Console.ReadLine();\n int decValue = int.Parse(hexval, NumberStyles.HexNumber);\n Console.WriteLine(decValue);\n"
},
{
"answer_id": 71229254,
"author": "Marco Antonio",
"author_id": 6907130,
"author_profile": "https://Stackoverflow.com/users/6907130",
"pm_score": 1,
"selected": false,
"text": "using System;\n\nnamespace Hexadecimal_and_Decimal\n{\n internal class Program\n {\n private static void Main(string[] args)\n {\n string hex = \"4DEAD\";\n int dec;\n\n // hex to dec:\n dec = int.Parse(hex, System.Globalization.NumberStyles.HexNumber);\n // or:\n dec = Convert.ToInt32(hex, 16);\n\n // dec to hex:\n hex = dec.ToString(\"X\"); // lowcase: x, uppercase: X\n // or:\n hex = string.Format(\"{0:X}\", dec); // lowcase: x, uppercase: X\n\n Console.WriteLine(\"Hexadecimal number: \" + hex);\n Console.WriteLine(\"Decimal number: \" + dec);\n }\n }\n}\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3362/"
] |
74,162 |
<p>I'm trying to write a query that extracts and transforms data from a table and then insert those data into another table. Yes, this is a data warehousing query and I'm doing it in MS Access. So basically I want some query like this:</p>
<pre><code>INSERT INTO Table2(LongIntColumn2, CurrencyColumn2) VALUES
(SELECT LongIntColumn1, Avg(CurrencyColumn) as CurrencyColumn1 FROM Table1 GROUP BY LongIntColumn1);
</code></pre>
<p>I tried but get a syntax error message.</p>
<p>What would you do if you want to do this?</p>
|
[
{
"answer_id": 74196,
"author": "Forgotten Semicolon",
"author_id": 1960,
"author_profile": "https://Stackoverflow.com/users/1960",
"pm_score": 3,
"selected": false,
"text": "VALUES"
},
{
"answer_id": 74204,
"author": "pilsetnieks",
"author_id": 6615,
"author_profile": "https://Stackoverflow.com/users/6615",
"pm_score": 9,
"selected": true,
"text": "INSERT INTO Table2(LongIntColumn2, CurrencyColumn2)\nSELECT LongIntColumn1, Avg(CurrencyColumn) as CurrencyColumn1 FROM Table1 GROUP BY LongIntColumn1;\n"
},
{
"answer_id": 74214,
"author": "GSerg",
"author_id": 11683,
"author_profile": "https://Stackoverflow.com/users/11683",
"pm_score": 5,
"selected": false,
"text": "INSERT INTO Table2 (LongIntColumn2, CurrencyColumn2)\nSELECT LongIntColumn1, Avg(CurrencyColumn) FROM Table1 GROUP BY LongIntColumn1\n"
},
{
"answer_id": 74222,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 5,
"selected": false,
"text": "CREATE TABLE Table1 (\n id int identity(1, 1) not null,\n LongIntColumn1 int,\n CurrencyColumn money\n)\n\nCREATE TABLE Table2 (\n id int identity(1, 1) not null,\n LongIntColumn2 int,\n CurrencyColumn2 money\n)\n\nINSERT INTO Table1 VALUES(12, 12.00)\nINSERT INTO Table1 VALUES(11, 13.00)\n\nINSERT INTO Table2\nSELECT LongIntColumn1, Avg(CurrencyColumn) as CurrencyColumn1 FROM Table1 GROUP BY LongIntColumn1\n CREATE TABLE Table1 (\n id int identity(1, 1) not null,\n LongIntColumn1 int,\n CurrencyColumn money\n)\n\nINSERT INTO Table1 VALUES(12, 12.00)\nINSERT INTO Table1 VALUES(11, 13.00)\n\n\nSELECT LongIntColumn1, Avg(CurrencyColumn) as CurrencyColumn1\nINTO Table2\nFROM Table1\nGROUP BY LongIntColumn1\n"
},
{
"answer_id": 74239,
"author": "Sean",
"author_id": 8334,
"author_profile": "https://Stackoverflow.com/users/8334",
"pm_score": 4,
"selected": false,
"text": "INSERT INTO target [(field1[, field2[, …]])] [IN externaldatabase]\nSELECT [source.]field1[, field2[, …]\nFROM tableexpression\n INSERT INTO target [(field1[, field2[, …]])] \nVALUES (value1[, value2[, …])\n"
},
{
"answer_id": 74285,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "SELECT LongIntColumn1, Avg(CurrencyColumn) as CurrencyColumn1 INTO T1 FROM Table1 \nGROUP BY LongIntColumn1);\n"
},
{
"answer_id": 74347,
"author": "Chris OC",
"author_id": 11041,
"author_profile": "https://Stackoverflow.com/users/11041",
"pm_score": 2,
"selected": false,
"text": "INSERT INTO Table2 (LongIntColumn, Junk)\nSELECT LongIntColumn, avg(CurrencyColumn) as CurrencyColumn1\nFROM Table1\nGROUP BY LongIntColumn;\n INSERT INTO Table2 (LongIntColumn, Junk)\nSELECT LongIntColumn, avg(CurrencyColumn)\nFROM Table1\nGROUP BY LongIntColumn;\n"
},
{
"answer_id": 348981,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "insert into DocTypeGroup \n Select DocGrp_Id,DocGrp_SubId,DocGrp_GroupName,DocGrp_PM,DocGrp_DocType \n from Opendatasource( 'SQLOLEDB','Data Source=10.132.20.19;UserID=sa;Password=gchaturthi').dbIPFMCI.dbo.DocTypeGroup\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8203/"
] |
74,171 |
<p>I maintain a Java Swing application.</p>
<p>For backwards compatibility with java 5 (for Apple machines), we maintain two codebases, 1 using features from Java 6, another without those features.</p>
<p>The code is largely the same, except for 3-4 classes that uses Java 6 features.</p>
<p>I wish to just maintain 1 codebase. Is there a way during compilation, to get the Java 5 compiler to 'ignore' some parts of my code?</p>
<p>I do not wish to simply comment/uncomment parts of my code, depending on the version of my java compiler.</p>
|
[
{
"answer_id": 74319,
"author": "Jesse Glick",
"author_id": 12916,
"author_profile": "https://Stackoverflow.com/users/12916",
"pm_score": 2,
"selected": false,
"text": "---%<--- main/RandomClass.java\n// ...\nif (...is JDK 6+...) {\n try {\n JDK6Interface i = (JDK6Interface)\n Class.forName(\"JDK6Impl\").newInstance();\n i.browseDesktop(...);\n } catch (Exception x) {\n // fall back...\n }\n}\n---%<--- main/JDK6Interface.java\npublic interface JDK6Interface {\n void browseDesktop(URI uri);\n}\n---%<--- jdk6/JDK6Impl.java\npublic class JDK6Impl implements JDK6Interface {\n public void browseDesktop(URI uri) {\n java.awt.Desktop.getDesktop().browse(uri);\n }\n}\n---%<---\n"
},
{
"answer_id": 74366,
"author": "Steve g",
"author_id": 12092,
"author_profile": "https://Stackoverflow.com/users/12092",
"pm_score": 2,
"selected": false,
"text": "public interface Opener{\n\npublic void open(File f);\n\n public static class Util{\n public Opener getOpener(){\n if(System.getProperty(\"java.version\").beginsWith(\"1.5\")){\n return new Java5Opener();\n }\n try{ \n return new Java6Opener();\n }catch(Throwable t){\n return new Java5Opener();\n }\n }\n }\n\n}\n"
},
{
"answer_id": 74555,
"author": "18Rabbit",
"author_id": 12662,
"author_profile": "https://Stackoverflow.com/users/12662",
"pm_score": 3,
"selected": true,
"text": "public static final boolean COMPILED_IN_JAVA_6 = false;\n if (VersionUtil.COMPILED_IN_JAVA_6) {\n // Java 6 stuff goes here\n} else {\n // Java 1.5 stuff goes here\n}\n"
},
{
"answer_id": 76114,
"author": "Michael Myers",
"author_id": 13531,
"author_profile": "https://Stackoverflow.com/users/13531",
"pm_score": 1,
"selected": false,
"text": "private static final double javaVersion =\n Double.parseDouble(System.getProperty(\"java.version\").substring(0, 3));\nprivate static final boolean supportsRowSorter =\n (javaVersion >= 1.6);\n\n//...\n\nif (supportsRowSorter) {\n myTable.setAutoCreateRowSorter(true);\n} else {\n // not supported\n}\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74171",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12944/"
] |
74,188 |
<p>I've created a ListBox to display items in groups, where the groups are wrapped right to left when they can no longer fit within the height of the ListBox's panel. So, the groups would appear similar to this in the listbox, where each group's height is arbitrary (group 1, for instance, is twice as tall as group 2):</p>
<pre><code>[ 1 ][ 3 ][ 5 ]
[ ][ 4 ][ 6 ]
[ 2 ][ ]
</code></pre>
<p>The following XAML works correctly in that it performs the wrapping, and allows the horizontal scroll bar to appear when the items run off the right side of the ListBox.</p>
<pre><code><ListBox>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.GroupStyle>
<ItemsPanelTemplate>
<WrapPanel Orientation="Vertical"
Height="{Binding Path=ActualHeight,
RelativeSource={RelativeSource
FindAncestor,
AncestorLevel=1,
AncestorType={x:Type ScrollContentPresenter}}}"/>
</ItemsPanelTemplate>
</ListBox.GroupStyle>
</ListBox>
</code></pre>
<p>The problem occurs when a group of items is longer than the height of the WrapPanel. Instead of allowing the vertical scroll bar to appear to view the cutoff item group, the items in that group are simply clipped. I'm assuming that this is a side effect of the Height binding in the WrapPanel - the scrollbar thinks it does not have to enabled.</p>
<p>Is there any way to enable the scrollbar, or another way around this issue that I'm not seeing?</p>
|
[
{
"answer_id": 74235,
"author": "dcstraw",
"author_id": 10391,
"author_profile": "https://Stackoverflow.com/users/10391",
"pm_score": 0,
"selected": false,
"text": "VerticalAlignment"
},
{
"answer_id": 74306,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "removed MinHeight VerticalAlignment"
},
{
"answer_id": 74565,
"author": "Abe Heidebrecht",
"author_id": 9268,
"author_profile": "https://Stackoverflow.com/users/9268",
"pm_score": 2,
"selected": false,
"text": "public class SmartWrapPanel : WrapPanel\n{\n /// <summary>\n /// Identifies the DesiredHeight dependency property\n /// </summary>\n public static readonly DependencyProperty DesiredHeightProperty = DependencyProperty.Register(\n \"DesiredHeight\",\n typeof(double),\n typeof(SmartWrapPanel),\n new FrameworkPropertyMetadata(Double.NaN, \n FrameworkPropertyMetadataOptions.AffectsArrange |\n FrameworkPropertyMetadataOptions.AffectsMeasure));\n\n /// <summary>\n /// Gets or sets the height to attempt to be. If any child is taller than this, will use the child's height.\n /// </summary>\n public double DesiredHeight\n {\n get { return (double)GetValue(DesiredHeightProperty); }\n set { SetValue(DesiredHeightProperty, value); }\n }\n\n protected override Size MeasureOverride(Size constraint)\n {\n Size ret = base.MeasureOverride(constraint);\n double h = ret.Height;\n\n if (!Double.IsNaN(DesiredHeight))\n {\n h = DesiredHeight;\n foreach (UIElement child in Children)\n {\n if (child.DesiredSize.Height > h)\n h = child.DesiredSize.Height;\n }\n }\n\n return new Size(ret.Width, h);\n }\n\n protected override System.Windows.Size ArrangeOverride(Size finalSize)\n {\n double h = finalSize.Height;\n\n if (!Double.IsNaN(DesiredHeight))\n {\n h = DesiredHeight;\n foreach (UIElement child in Children)\n {\n if (child.DesiredSize.Height > h)\n h = child.DesiredSize.Height;\n }\n }\n\n return base.ArrangeOverride(new Size(finalSize.Width, h));\n }\n}\n"
},
{
"answer_id": 82798,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "// Original code : Abe Heidebrecht\npublic class SmartWrapPanel : WrapPanel\n{\n /// <summary>\n /// Identifies the DesiredHeight dependency property\n /// </summary>\n public static readonly DependencyProperty DesiredHeightProperty = DependencyProperty.Register(\n \"DesiredHeight\",\n typeof(double),\n typeof(SmartWrapPanel),\n new FrameworkPropertyMetadata(Double.NaN, \n FrameworkPropertyMetadataOptions.AffectsArrange |\n FrameworkPropertyMetadataOptions.AffectsMeasure));\n\n /// <summary>\n /// Gets or sets the height to attempt to be. If any child is taller than this, will use the child's height.\n /// </summary>\n public double DesiredHeight\n {\n get { return (double)GetValue(DesiredHeightProperty); }\n set { SetValue(DesiredHeightProperty, value); }\n }\n\n protected override Size MeasureOverride(Size constraint)\n {\n Size ret = base.MeasureOverride(constraint);\n double h = ret.Height;\n\n if (!Double.IsNaN(DesiredHeight))\n {\n h = DesiredHeight;\n foreach (UIElement child in Children)\n {\n if (child.DesiredSize.Height > h)\n h = child.DesiredSize.Height;\n }\n }\n\n return base.MeasureOverride(new Size(ret.Width, h));\n }\n\n protected override System.Windows.Size ArrangeOverride(Size finalSize)\n {\n double h = finalSize.Height;\n\n if (!Double.IsNaN(DesiredHeight))\n {\n h = DesiredHeight;\n foreach (UIElement child in Children)\n {\n if (child.DesiredSize.Height > h)\n h = child.DesiredSize.Height;\n }\n }\n\n return base.ArrangeOverride(new Size(finalSize.Width, h));\n }\n}\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
74,206 |
<p>I have been playing with this for a while, but the closest I have gotten is a button that opens the <code>Paste Special</code> dialog box and requires another couple of mouse clicks to paste the contents of the clipboard as unformatted text. </p>
<p>So often I am doing a <code>copy-paste</code> from a web site into a document where I don't want the additional baggage of the HTML formatting, it would be nice to be able to do this with a shortcut key or a toolbar button.</p>
|
[
{
"answer_id": 74237,
"author": "GSerg",
"author_id": 11683,
"author_profile": "https://Stackoverflow.com/users/11683",
"pm_score": 4,
"selected": true,
"text": "public sub PasteSpecialUnformatted()\n selection.pastespecial datatype:=wdpastetext\nend sub\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30018/"
] |
74,218 |
<p>Is there a way to restart the Rails app (e.g. when you've changed a plugin/config file) while Mongrel is running. Or alternatively quickly restart Mongrel. Mongrel gives these hints that you can but how do you do it?</p>
<p>** Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart).</p>
<p>** Rails signals registered. HUP => reload (without restart). It might not work well.</p>
|
[
{
"answer_id": 74241,
"author": "Jan Krüger",
"author_id": 12471,
"author_profile": "https://Stackoverflow.com/users/12471",
"pm_score": 2,
"selected": false,
"text": "killall -USR2 mongrel_rails\n"
},
{
"answer_id": 74998,
"author": "TonyLa",
"author_id": 1295,
"author_profile": "https://Stackoverflow.com/users/1295",
"pm_score": 2,
"selected": false,
"text": "mongrel_rails cluster::restart\n"
},
{
"answer_id": 75028,
"author": "Lucas Oman",
"author_id": 6726,
"author_profile": "https://Stackoverflow.com/users/6726",
"pm_score": 3,
"selected": false,
"text": "mongrel_rails cluster::restart -c /path/to/config\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6432/"
] |
74,248 |
<p>On a JSTL/JSP page, I have a java.util.Date object from my application. I need to find the day <em>after</em> the day specified by that object. I can use <jsp:scriptlet> to drop into Java and use java.util.Calendar to do the necessary calculations, but this feels clumsy and inelegant to me.</p>
<p>Is there some way to use JSP or JSTL tags to achieve this end without having to switch into full-on Java, or is the latter the only way to accomplish this?</p>
|
[
{
"answer_id": 74274,
"author": "sirprize",
"author_id": 12902,
"author_profile": "https://Stackoverflow.com/users/12902",
"pm_score": 2,
"selected": false,
"text": "// Date d given\nd.setTime(d.getTime()+86400000);\n"
},
{
"answer_id": 74582,
"author": "jodonnell",
"author_id": 4223,
"author_profile": "https://Stackoverflow.com/users/4223",
"pm_score": 2,
"selected": false,
"text": "Calendar cal = Calendar.getInstance();\ncal.setTime (date);\ncal.add (Calendar.DATE, 1);\ndate = cal.getTime ();\n"
},
{
"answer_id": 74646,
"author": "ScArcher2",
"author_id": 1310,
"author_profile": "https://Stackoverflow.com/users/1310",
"pm_score": 4,
"selected": true,
"text": "public static Date addDay(Date date){\n //TODO you may want to check for a null date and handle it.\n Calendar cal = Calendar.getInstance();\n cal.setTime (date);\n cal.add (Calendar.DATE, 1);\n return cal.getTime();\n}\n <?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<taglib xmlns=\"http://java.sun.com/xml/ns/j2ee\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd\"\n version=\"2.0\">\n <description>functions library</description>\n <display-name>functions</display-name>\n <tlib-version>1.1</tlib-version>\n <short-name>xfn</short-name>\n <uri>http://yourdomain/functions.tld</uri>\n <function>\n <description>\n Adds 1 day to a date.\n </description>\n <name>addDay</name>\n <function-class>Functions</function-class>\n <function-signature>java.util.Date addDay(java.util.Date)</function-signature>\n <example>\n ${xfn:addDay(date)}\n </example>\n </function>\n</taglib>\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2041950/"
] |
74,261 |
<p>Is there a general rule of thumb to follow when storing web application data to know what database backend should be used? Is the number of hits per day, number of rows of data, or other metrics that I should consider when choosing?</p>
<p>My initial idea is that the order for this would look something like the following (but not necessarily, which is why I'm asking the question).</p>
<ol>
<li>Flat Files</li>
<li>BDB</li>
<li>SQLite</li>
<li>MySQL</li>
<li>PostgreSQL</li>
<li>SQL Server</li>
<li>Oracle</li>
</ol>
|
[
{
"answer_id": 74354,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 0,
"selected": false,
"text": "SQL Server Compact -> SQL Server Express -> SQL Server Enterprise (clustered). \n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74261",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2581/"
] |
74,266 |
<p>I have an ext combobox which uses a store to suggest values to a user as they type. </p>
<p>An example of which can be found here: <a href="http://extjs.com/deploy/ext/examples/form/combos.html" rel="nofollow noreferrer">combobox example</a></p>
<p>Is there a way of making it so the <strong>suggested text list</strong> is rendered to an element in the DOM. Please note I do not mean the "applyTo" config option, as this would render the whole control, including the textbox to the DOM element.</p>
|
[
{
"answer_id": 75619,
"author": "Thevs",
"author_id": 8559,
"author_profile": "https://Stackoverflow.com/users/8559",
"pm_score": 2,
"selected": true,
"text": "var suggested_text_plugin = {\n\n init: function(o) {\n\n o.onTypeAhead = function() {\n // Original code from the sources goes here:\n\n if(this.store.getCount() > 0){\n var r = this.store.getAt(0);\n var newValue = r.data[this.displayField];\n var len = newValue.length;\n var selStart = this.getRawValue().length;\n if(selStart != len){\n this.setRawValue(newValue);\n this.selectText(selStart, newValue.length);\n }\n }\n\n // Your code to display newValue in DOM\n ......myDom.getEl().update(newValue);\n };\n }\n};\n\n\n// in combobox code:\n\nvar cb = new Ext.form.ComboBox({\n ....\n plugins: suggested_text_plugin,\n ....\n});\n ....\no.origTypeAhead = new Function(this.onTypeAhead.toSource());\n// or just\no.origTypeAhead = this.onTypeAhead;\n....\n\no.onTypeAhead = function() {\n // Call original\n this.origTypeAhead();\n // Display value into your DOM element\n ...myDom....\n};\n"
},
{
"answer_id": 81766,
"author": "Chris James",
"author_id": 3193,
"author_profile": "https://Stackoverflow.com/users/3193",
"pm_score": 0,
"selected": false,
"text": " Ext.override(Ext.form.ComboBox, {\n initList : function(){\n this.view = new Ext.DataView({\n //applyTo: this.innerList,\n applyTo: \"contentbox\",\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3193/"
] |
74,267 |
<p>I'm trying to script the shutdown of my VM Servers in a .bat.
if one of the vmware-cmd commands fails (as the machine is already shutdown say), I'd like it to continue instead of bombing out.</p>
<pre><code>c:
cd "c:\Program Files\VMWare\VmWare Server"
vmware-cmd C:\VMImages\TCVMDEVSQL01\TCVMDEVSQL01.vmx suspend soft -q
vmware-cmd C:\VMImages\DevEnv\DevEnv\DevEnv.vmx suspend soft -q
vmware-cmd C:\VMImages\DevEnv\TCVMDEV02\TCVMDEV02.vmx suspend soft =q
robocopy c:\vmimages\ \\tcedilacie1tb\VMShare\DevEnvironmentBackups\ /mir /z /r:0 /w:0
vmware-cmd C:\VMImages\TCVMDEVSQL01\TCVMDEVSQL01.vmx start
vmware-cmd C:\VMImages\DevEnv\DevEnv\DevEnv.vmx start
vmware-cmd C:\VMImages\DevEnv\TCVMDEV02\TCVMDEV02.vmx start
</code></pre>
|
[
{
"answer_id": 74321,
"author": "chakrit",
"author_id": 3055,
"author_profile": "https://Stackoverflow.com/users/3055",
"pm_score": 6,
"selected": true,
"text": "CMD /C CMD /C vmware-cmd C:\\...\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11538/"
] |
74,315 |
<p>I'm doing a website for a family member's wedding. A feature they requested was a photo section where all the guests could go after the wedding and upload their snaps. I said this was a stellar idea and I went off to build it.</p>
<p>Well there's just the one problem: logistics. Upload speeds are slow and photos from modern cameras are huge (2-5+Megs). </p>
<p>I will only need ~800px wide images and some of them might require rotating so ideally I'm looking about using a client-side editor to do three things:</p>
<ol>
<li>Let users pick multiple files</li>
<li>Let them rotate some images so they're the right way up</li>
<li>Resize them and then upload</li>
</ol>
<p>And in my dream world, it'd be free and open source. Any ideas?</p>
<p>Just a reminder: this is something the guests have to use. Some of them will be pretty computer savvy but others will be almost completely illiterate. Installing desktop apps isn't really an option. And I assume 98% of them have Flash and Java installed.</p>
<p>Edit: I'd prefer a Flash/Java option over SilverLight, not least because it has a smaller install rate at the moment, but also because I'm on Linux and I'd like to test it =)</p>
|
[
{
"answer_id": 80200,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "// UploadServlet.java : Proof of Concept - Mike Smith March 2006\n// Accept a file from the client, assume it is an image, rescale it and save it to disk for later display\nimport javax.servlet.http.*;\nimport javax.imageio.*;\nimport java.io.*;\nimport java.util.*;\nimport java.sql.*;\nimport org.apache.commons.fileupload.*;\nimport org.apache.commons.fileupload.disk.*;\nimport org.apache.commons.fileupload.servlet.*;\nimport java.awt.image.*;\nimport java.awt.*;\n\npublic class UploadServlet extends HttpServlet {\n\npublic static void printHeader(PrintWriter pw) {\n pw.println(\"<HEAD><TITLE>Upload Servlet</TITLE><HEAD>\");\n pw.println(\"<BODY>\");\n}\n\npublic static void printTrailer(PrintWriter pw) {\n pw.println(\"<img src=\\\"../images/poweredby.png\\\" align=left>\");\n pw.println(\"<img src=\\\"../images/tomcat-power.gif\\\" align=right>\");\n pw.println(\"</BODY></HTML>\");\n}\n\n\npublic void init() { // Servlet init() : called when the servlet is LOADED (not when invoked)\n}\n\npublic void service(HttpServletRequest req, HttpServletResponse res) throws IOException {\n DiskFileItemFactory dfifact;\n ServletFileUpload sfu; \n java.util.List items;\n Iterator it;\n FileItem fi;\n String field, filename, contype;\n boolean inmem, ismulti;\n long sz;\n BufferedImage img;\n int width, height, nwidth, nheight, pixels;\n double scaling;\n final int MAXPIXELS = 350 * 350;\n\n res.setContentType(\"text/html\");\n PrintWriter pw = res.getWriter();\n printHeader(pw);\n\n ismulti = FileUpload.isMultipartContent(req);\n if (ismulti) {\n pw.println(\"Great! Multipart detected\");\n dfifact = new DiskFileItemFactory(999999, new File(\"/tmp\"));\n sfu = new ServletFileUpload(dfifact);\n try {\n items = sfu.parseRequest(req);\n } catch (FileUploadException e) {\n pw.println(\"Failed to parse file, error [\" + e + \"]\");\n printTrailer(pw);\n pw.close();\n return;\n }\n it = items.iterator();\n while (it.hasNext()) {\n fi = (FileItem) it.next();\n if (fi.isFormField()) {\n pw.println(\"Form field [\" + fi.getFieldName() + \"] value [\" + fi.getString() + \"]\");\n }\n else { // Its an upload\n field = fi.getFieldName();\n filename = fi.getName();\n contype = fi.getContentType();\n inmem = fi.isInMemory();\n sz = fi.getSize();\n pw.println(\"Upload field=\" + field + \" file=\" + filename + \" content=\" + contype + \" inmem=\" + inmem\n + \" size=\" + sz);\n InputStream istream = fi.getInputStream();\n img = ImageIO.read(istream);\n nwidth = width = img.getWidth();\n nheight = height = img.getHeight();\n pixels = width * height;\n if (pixels > MAXPIXELS) {\n scaling = Math.sqrt((double) MAXPIXELS / (double) pixels);\n nheight = (int) ((double) height * scaling);\n nwidth = (int) ((double) width * scaling);\n }\n BufferedImage output = new BufferedImage(nwidth, nheight, BufferedImage.TYPE_3BYTE_BGR);\n Graphics2D g = output.createGraphics();\n g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);\n g.drawImage(img, 0, 0, nwidth, nheight, null);\n ImageIO.write(output, \"jpeg\", new File(\"/var/tomcat/webapps/pioneer/demo.jpg\"));\n istream.close(); \n }\n }\n }\n else\n pw.println(\"Bugger! Multipart not detected\");\n printTrailer(pw);\n pw.close();\n}\n\npublic void destroy() {\n}\n}\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12870/"
] |
74,326 |
<p>I am working on a large C++ project in Visual Studio 2008, and there are a lot of files with unnecessary <code>#include</code> directives. Sometimes the <code>#include</code>s are just artifacts and everything will compile fine with them removed, and in other cases classes could be forward declared and the #include could be moved to the <code>.cpp</code> file. Are there any good tools for detecting both of these cases?</p>
|
[
{
"answer_id": 74491,
"author": "Eclipse",
"author_id": 8701,
"author_profile": "https://Stackoverflow.com/users/8701",
"pm_score": 7,
"selected": true,
"text": "/showIncludes .cpp Properties->C/C++->Advanced"
},
{
"answer_id": 74547,
"author": "Graeme Perrow",
"author_id": 1821,
"author_profile": "https://Stackoverflow.com/users/1821",
"pm_score": 4,
"selected": false,
"text": "#define USE_FEATURE_X #ifdef USE_FEATURE_X #include \"a.h\" #if defined( WINNT )\n #define USE_FEATURE_X\n#endif\n USE_FEATURE_X WINNT"
},
{
"answer_id": 79991,
"author": "Roger Nelson",
"author_id": 14964,
"author_profile": "https://Stackoverflow.com/users/14964",
"pm_score": 2,
"selected": false,
"text": "#define WIN32_LEAN_AND_MEAN\n#define VC_EXTRALEAN\n"
},
{
"answer_id": 80423,
"author": "bk1e",
"author_id": 8090,
"author_profile": "https://Stackoverflow.com/users/8090",
"pm_score": 2,
"selected": false,
"text": "#include #include"
},
{
"answer_id": 109890,
"author": "Sam",
"author_id": 19791,
"author_profile": "https://Stackoverflow.com/users/19791",
"pm_score": 2,
"selected": false,
"text": "#ifndef __SOMEHEADER_H__\n#define __SOMEHEADER_H__\n// header contents\n#endif\n #ifndef __SOMEHEADER_H__\n#define __SOMEHEADER_H__\n// header contents\n#else \n#pragma message(\"Someheader.h superfluously included\")\n#endif\n"
},
{
"answer_id": 26853966,
"author": "Britton Kerin",
"author_id": 3973301,
"author_profile": "https://Stackoverflow.com/users/3973301",
"pm_score": 0,
"selected": false,
"text": "#ifdef _STRING_H_\n# error string.h is included indirectly\n#endif\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13013/"
] |
74,350 |
<p>I'm trying to implement some drag and drop functionality for a material system being developed at my work. Part of this system includes a 'Material Library' which acts as a repository, divided into groups, of saved materials on the user's hard drive.</p>
<p>As part of some UI polish, I was hoping to implement a 'highlight' type feature. When dragging and dropping, windows that you can legally drop a material onto will very subtly change color to improve feedback to the user that this is a valid action.</p>
<p>I am changing the bar with 'Basic Materials' (Just a CWnd with a CStatic) from having a medium gray background when unhighlighed to a blue background when hovered over. It all works well, the OnDragEnter and OnDragExit messages seem robust and set a flag indicating the highlight status. Then in OnCtrlColor I do this:</p>
<pre><code> if (!m_bHighlighted) {
pDC->FillSolidRect(0, 0, m_SizeX, kGroupHeaderHeight, kBackgroundColour);
}
else {
pDC->FillSolidRect(0, 0, m_SizeX, kGroupHeaderHeight, kHighlightedBackgroundColour);
}
</code></pre>
<p>However, as you can see in the screenshot, the painting 'glitches' below the dragged object, leaving the original gray in place. It looks really ugly and basically spoils the whole effect.</p>
<p>Is there any way I can get around this?</p>
|
[
{
"answer_id": 81662,
"author": "Ali Parr",
"author_id": 1169,
"author_profile": "https://Stackoverflow.com/users/1169",
"pm_score": 1,
"selected": true,
"text": "ImageList_DragShowNolock(FALSE);\nm_pDragDropTargetWnd->SendMessage(WM_USER_DRAG_DROP_OBJECT_DRAG_ENTER, (WPARAM)pDragDropObject, (LPARAM)(&dragDropPoint));\nImageList_DragShowNolock(TRUE);\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74350",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1169/"
] |
74,358 |
<p>How can I get <a href="http://search.cpan.org/perldoc?LWP" rel="noreferrer">LWP</a> to verify that the certificate of the server I'm connecting to is signed by a trusted authority and issued to the correct host? As far as I can tell, it doesn't even check that the certificate claims to be for the hostname I'm connecting to. That seems like a major security hole (especially with the recent DNS vulnerabilities).</p>
<p><strong>Update:</strong> It turns out what I really wanted was <code>HTTPS_CA_DIR</code>, because I don't have a ca-bundle.crt. But <code>HTTPS_CA_DIR=/usr/share/ca-certificates/</code> did the trick. I'm marking the answer as accepted anyway, because it was close enough.</p>
<p><strong>Update 2:</strong> It turns out that <code>HTTPS_CA_DIR</code> and <code>HTTPS_CA_FILE</code> only apply if you're using Net::SSL as the underlying SSL library. But LWP also works with IO::Socket::SSL, which will ignore those environment variables and happily talk to any server, no matter what certificate it presents. Is there a more general solution?</p>
<p><strong>Update 3:</strong> Unfortunately, the solution still isn't complete. Neither Net::SSL nor IO::Socket::SSL is checking the host name against the certificate. This means that someone can get a legitimate certificate for some domain, and then impersonate any other domain without LWP complaining.</p>
<p><strong>Update 4:</strong> <a href="http://search.cpan.org/dist/libwww-perl/" rel="noreferrer">LWP 6.00</a> finally solves the problem. See <a href="https://stackoverflow.com/questions/74358/how-can-i-get-lwp-to-validate-ssl-server-certificates#5329129">my answer</a> for details.</p>
|
[
{
"answer_id": 74432,
"author": "Brian Phillips",
"author_id": 7230,
"author_profile": "https://Stackoverflow.com/users/7230",
"pm_score": 3,
"selected": false,
"text": "HTTPS_CA_FILE HTTPS_CA_DIR \nuse LWP::Simple qw(get);\n$ENV{HTTPS_CA_FILE} = \"/path/to/your/ca/file/ca-bundle\";\n$ENV{HTTPS_DEBUG} = 1;\n\nprint get(\"https://some-server-with-bad-certificate.com\");\n\n__END__\nSSL_connect:before/connect initialization\nSSL_connect:SSLv2/v3 write client hello A\nSSL_connect:SSLv3 read server hello A\nSSL3 alert write:fatal:unknown CA\nSSL_connect:error in SSLv3 read server certificate B\nSSL_connect:error in SSLv3 read server certificate B\nSSL_connect:before/connect initialization\nSSL_connect:SSLv3 write client hello A\nSSL_connect:SSLv3 read server hello A\nSSL3 alert write:fatal:bad certificate\nSSL_connect:error in SSLv3 read server certificate B\nSSL_connect:before/connect initialization\nSSL_connect:SSLv2 write client hello A\nSSL_connect:error in SSLv2 read server hello B\n die undef IO::Socket::SSL \nuse IO::Socket::SSL qw(debug3);\nuse Net::SSLeay;\nBEGIN {\n IO::Socket::SSL::set_ctx_defaults(\n verify_mode => Net::SSLeay->VERIFY_PEER(),\n ca_file => \"/path/to/ca-bundle.crt\",\n # ca_path => \"/alternate/path/to/cert/authority/directory\"\n );\n}\nuse LWP::Simple qw(get);\n\nwarn get(\"https:://some-server-with-bad-certificate.com\");\n get() STDERR \n% perl ssl_test.pl\nDEBUG: .../IO/Socket/SSL.pm:1387: new ctx 139403496\nDEBUG: .../IO/Socket/SSL.pm:269: socket not yet connected\nDEBUG: .../IO/Socket/SSL.pm:271: socket connected\nDEBUG: .../IO/Socket/SSL.pm:284: ssl handshake not started\nDEBUG: .../IO/Socket/SSL.pm:327: Net::SSLeay::connect -> -1\nDEBUG: .../IO/Socket/SSL.pm:1135: SSL connect attempt failed with unknown errorerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed\n\nDEBUG: .../IO/Socket/SSL.pm:333: fatal SSL error: SSL connect attempt failed with unknown errorerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed\nDEBUG: .../IO/Socket/SSL.pm:1422: free ctx 139403496 open=139403496\nDEBUG: .../IO/Socket/SSL.pm:1425: OK free ctx 139403496\nDEBUG: .../IO/Socket/SSL.pm:1135: IO::Socket::INET configuration failederror:00000000:lib(0):func(0):reason(0)\n500 Can't connect to some-server-with-bad-certificate.com:443 (SSL connect attempt failed with unknown errorerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed) \n"
},
{
"answer_id": 612238,
"author": "dave0",
"author_id": 73886,
"author_profile": "https://Stackoverflow.com/users/73886",
"pm_score": 2,
"selected": false,
"text": "#!/usr/bin/perl \nuse LWP::UserAgent;\nmy $ua = LWP::UserAgent->new();\nmy $req = HTTP::Request->new(GET => 'https://yourdomain.tld/whatever');\n$req->header('If-SSL-Cert-Subject' => '/CN=make-it-fail.tld');\n\nmy $res = $ua->request( $req );\n\nprint \"Status: \" . $res->status_line . \"\\n\"\n Status: 500 Bad SSL certificate subject: '/C=CA/ST=Ontario/L=Ottawa/O=Your Org/CN=yourdomain.tld' !~ //CN=make-it-fail.tld/\n"
},
{
"answer_id": 5329129,
"author": "cjm",
"author_id": 8355,
"author_profile": "https://Stackoverflow.com/users/8355",
"pm_score": 6,
"selected": true,
"text": "$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} $ENV{HTTPS_CA_FILE} $ENV{HTTPS_CA_DIR} ssl_opts verify_hostname verify_hostname => 1 ssl_opts use LWP::UserAgent 6;"
},
{
"answer_id": 7722012,
"author": "blumentopf",
"author_id": 988281,
"author_profile": "https://Stackoverflow.com/users/988281",
"pm_score": 2,
"selected": false,
"text": "IO::Socket::SSL verifycn_scheme use IO::Socket::SSL;\nuse Net::SSLeay;\nBEGIN {\n IO::Socket::SSL::set_ctx_defaults(\n verify_mode => Net::SSLeay->VERIFY_PEER(),\n verifycn_scheme => 'http',\n ca_path => \"/etc/ssl/certs\"\n );\n}\n"
},
{
"answer_id": 23570769,
"author": "bshok",
"author_id": 1544311,
"author_profile": "https://Stackoverflow.com/users/1544311",
"pm_score": 3,
"selected": false,
"text": "use strict;\nuse warnings;\nuse LWP::UserAgent;\nuse HTTP::Request::Common qw(GET);\nuse Net::SSL;\n\nmy $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 }, );\nmy $req = GET 'https://github.com';\nmy $res = $ua->request($req);\nif ($res->is_success) {\n print $res->content;\n} else {\n print $res->status_line . \"\\n\";\n}\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8355/"
] |
74,372 |
<p>I am involved in the process of porting a system containing several hundreds of ksh scripts from AIX, Solaris and HPUX to Linux. I have come across the following difference in the way ksh behaves on the two systems:</p>
<pre><code>#!/bin/ksh
flag=false
echo "a\nb" | while read x
do
flag=true
done
echo "flag = ${flag}"
exit 0
</code></pre>
<p>On AIX, Solaris and HPUX the output is "flag = true" on Linux the output is "flag = false".</p>
<p>My questions are:</p>
<ul>
<li>Is there an environment variable that I can set to get Linux's ksh to behave like the
other Os's'? Failing that:</li>
<li>Is there an option on Linux's ksh to get the required behavior? Failing that:</li>
<li>Is there a ksh implementation available for Linux with the desired behavior?</li>
</ul>
<p>Other notes:</p>
<ul>
<li>On AIX, Solaris and HPUX ksh is a variant of ksh88.</li>
<li>On Linux, ksh is the public domain ksh (pdksh)</li>
<li>On AIX, Solaris and HPUX dtksh and ksh93 (where I have them installed) are consistent with ksh</li>
<li>The Windows NT systems I have access to: Cygwin and MKS NT, are consistent with Linux.</li>
<li>On AIX, Solaris and Linux, bash is consistent, giving the incorrect (from my perspective) result of "flag = false".</li>
</ul>
<p>The following table summarizes the systems the problem:</p>
<pre><code>uname -s uname -r which ksh ksh version flag =
======== ======== ========= =========== ======
Linux 2.6.9-55.0.0.0.2.ELsmp /bin/ksh PD KSH v5.2.14 99/07/13.2 false
AIX 3 /bin/ksh Version M-11/16/88f true // AIX 5.3
/bin/ksh93 Version M-12/28/93e true
SunOS 5.8, 5.9 and 5.10 /bin/ksh Version M-11/16/88i true
/usr/dt/bin/dtksh Version M-12/28/93d true
HP-UX B.11.11 and B.11.23 /bin/ksh Version 11/16/88 true
/usr/dt/bin/dtksh Version M-12/28/93d true
CYGWIN_NT-5.1 1.5.25(0.156/4/2) /bin/ksh PD KSH v5.2.14 99/07/13.2 false
Windows_NT 5 .../mksnt/ksh.exe Version 8.7.0 build 1859... false // MKS
</code></pre>
<h1>Update</h1>
<p>After some advice from people in my company we decided to make the following modification to the code. This gives us the same result whether using the "real" ksh's (ksh88, ksh93) or any of the ksh clones (pdksh, MSK ksh). This also works correctly with bash.</p>
<pre><code>#!/bin/ksh
echo "a\nb" > junk
flag=false
while read x
do
flag=true
done < junk
echo "flag = ${flag}"
exit 0
</code></pre>
<p>Thanks to jj33 for the previously accepted answer.</p>
|
[
{
"answer_id": 74580,
"author": "Alex M",
"author_id": 9652,
"author_profile": "https://Stackoverflow.com/users/9652",
"pm_score": 0,
"selected": false,
"text": "zsh emulate -L ksh zsh"
},
{
"answer_id": 74787,
"author": "jtimberman",
"author_id": 7672,
"author_profile": "https://Stackoverflow.com/users/7672",
"pm_score": 1,
"selected": false,
"text": "ii ksh 93s+20071105-1 The real, AT&T version of the Korn shell\nii pdksh 5.2.14-21ubunt A public domain version of the Korn shell\n"
},
{
"answer_id": 95267,
"author": "Andrew Stein",
"author_id": 13029,
"author_profile": "https://Stackoverflow.com/users/13029",
"pm_score": 3,
"selected": true,
"text": "#!/bin/ksh\necho \"a\\nb\" > junk\nflag=false\nwhile read x\ndo\n flag=true\ndone < junk\necho \"flag = ${flag}\"\nexit 0\n"
},
{
"answer_id": 255217,
"author": "mpez0",
"author_id": 27898,
"author_profile": "https://Stackoverflow.com/users/27898",
"pm_score": 1,
"selected": false,
"text": "#!/bin/ksh\nflag=false\necho \"a\\nb\" | { while read x\ndo \n flag=true\ndone }\necho \"flag = ${flag}\"\nexit 0\n"
},
{
"answer_id": 22537900,
"author": "venkat",
"author_id": 3442785,
"author_profile": "https://Stackoverflow.com/users/3442785",
"pm_score": 1,
"selected": false,
"text": "$ rpm -qa --queryformat \"%{NAME}-%{VERSION}-%{RELEASE}(%{ARCH})\\n\" | grep \"ksh\"\nksh-20100621-19.el6_4.3(x86_64) $ sudo yum remove ksh-20100621-19.el6_4.3.x86_64 $ sudo yum -y install /SCRIPT_PATH/pdksh-5.2.14-37.el5_8.1.x86_64.rpm $ ora_db_start_stop.sh\n\\n==============\nUsage: START\n==============\\n\\n\n./ora_db_start_stop.sh START ALL \\n\nOR \\n\n./ora_db_start_stop.sh START ONE_OR_MORE \\n\n\\n==============\nUsage: STOP\n==============\\n\\n\n./ora_db_start_stop.sh STOP ALL \\n\nOR \\n\n./ora_db_start_stop.sh STOP ONE_OR_MORE \\n\\n\n ./ora_db_start_stop.sh START ALL ./ora_db_start_stop.sh START ONE_OR_MORE ./ora_db_start_stop.sh STOP ALL ./ora_db_start_stop.sh STOP ONE_OR_MORE"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13029/"
] |
74,385 |
<p>I need to convert a value which is in a <code>DateTime</code> variable into a <code>varchar</code> variable formatted as <code>yyyy-mm-dd</code> format (without time part).</p>
<p>How do I do that?</p>
|
[
{
"answer_id": 74394,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 8,
"selected": false,
"text": "CONVERT(varchar(10), [MyDateTimecolumn], 20)\n CONVERT(varchar(23), [MyDateTimecolumn], 121)\n"
},
{
"answer_id": 74404,
"author": "Per Hornshøj-Schierbeck",
"author_id": 11619,
"author_profile": "https://Stackoverflow.com/users/11619",
"pm_score": 3,
"selected": false,
"text": "Cast Convert CAST CAST ( expression AS data_type [ (length ) ])\n CONVERT CONVERT ( data_type [ ( length ) ] , expression [ , style ] )\n REPLACE(CONVERT(varchar(10), Date, 102), '.', '-')\n"
},
{
"answer_id": 74431,
"author": "Allan Wind",
"author_id": 9706,
"author_profile": "https://Stackoverflow.com/users/9706",
"pm_score": 1,
"selected": false,
"text": "mysql> select date(now());\n+-------------+\n| date(now()) |\n+-------------+\n| 2008-09-16 | \n+-------------+\n1 row in set (0.00 sec)\n"
},
{
"answer_id": 74438,
"author": "Amy Patterson",
"author_id": 300930,
"author_profile": "https://Stackoverflow.com/users/300930",
"pm_score": 2,
"selected": false,
"text": "CONVERT(VARCHAR(10),GetDate(),102)\n"
},
{
"answer_id": 74469,
"author": "TonyOssa",
"author_id": 3276,
"author_profile": "https://Stackoverflow.com/users/3276",
"pm_score": 9,
"selected": true,
"text": "--\n-- Create test case\n--\nDECLARE @myDateTime DATETIME\nSET @myDateTime = '2008-05-03'\n\n--\n-- Convert string\n--\nSELECT LEFT(CONVERT(VARCHAR, @myDateTime, 120), 10)\n"
},
{
"answer_id": 74473,
"author": "Johnny Bravado",
"author_id": 12222,
"author_profile": "https://Stackoverflow.com/users/12222",
"pm_score": -1,
"selected": false,
"text": "C#/.NET DateTime ToString DateTime d = DateTime.Today;\nstring result = d.ToString(\"yyyy-MM-dd\");\n"
},
{
"answer_id": 138476,
"author": "Andy Jones",
"author_id": 5096,
"author_profile": "https://Stackoverflow.com/users/5096",
"pm_score": 2,
"selected": false,
"text": "declare @dt datetime\n\nset @dt = getdate()\n\nselect convert(char(10),@dt,120) \n char(10)"
},
{
"answer_id": 6254392,
"author": "Arek Bee",
"author_id": 664252,
"author_profile": "https://Stackoverflow.com/users/664252",
"pm_score": 2,
"selected": false,
"text": "select replace(convert(varchar, getdate(), 111),'/','-');\n"
},
{
"answer_id": 6430393,
"author": "P's-SQL",
"author_id": 809074,
"author_profile": "https://Stackoverflow.com/users/809074",
"pm_score": 3,
"selected": false,
"text": "\nSELECT CAST( CONVERT(VARCHAR, GETDATE(), 101) AS DATETIME) ; \n"
},
{
"answer_id": 7040880,
"author": "OldBuildingAndLoan",
"author_id": 70870,
"author_profile": "https://Stackoverflow.com/users/70870",
"pm_score": 2,
"selected": false,
"text": "convert( varchar(10), convert( date, @yourDate ) , 111 )\n"
},
{
"answer_id": 10819689,
"author": "dmunozpa",
"author_id": 1017892,
"author_profile": "https://Stackoverflow.com/users/1017892",
"pm_score": 3,
"selected": false,
"text": "CONVERT ( data_type [ ( length ) ] , expression [ , style ] )\n SELECT CONVERT(varchar,d.dateValue,1-9)\n"
},
{
"answer_id": 11587309,
"author": "FCKOE",
"author_id": 1541843,
"author_profile": "https://Stackoverflow.com/users/1541843",
"pm_score": 3,
"selected": false,
"text": "DATEPART(DATEPART, VARIABLE) DECLARE @DAY INT \nDECLARE @MONTH INT\nDECLARE @YEAR INT\nDECLARE @DATE DATETIME\n@DATE = GETDATE()\nSELECT @DAY = DATEPART(DAY,@DATE)\nSELECT @MONTH = DATEPART(MONTH,@DATE)\nSELECT @YEAR = DATEPART(YEAR,@DATE)\n"
},
{
"answer_id": 15621120,
"author": "IvanSnek",
"author_id": 1899696,
"author_profile": "https://Stackoverflow.com/users/1899696",
"pm_score": 2,
"selected": false,
"text": "CONVERT(NVARCHAR(10), DATE1, 103) )"
},
{
"answer_id": 17713768,
"author": "Zar Shardan",
"author_id": 913845,
"author_profile": "https://Stackoverflow.com/users/913845",
"pm_score": 5,
"selected": false,
"text": "FORMAT(VALUE,'dd/MM/yyyy h:mm:ss tt')\n"
},
{
"answer_id": 19537658,
"author": "Colin",
"author_id": 150342,
"author_profile": "https://Stackoverflow.com/users/150342",
"pm_score": 9,
"selected": false,
"text": "DECLARE @now datetime\nSET @now = GETDATE()\nselect convert(nvarchar(MAX), @now, 0) as output, 0 as style \nunion select convert(nvarchar(MAX), @now, 1), 1\nunion select convert(nvarchar(MAX), @now, 2), 2\nunion select convert(nvarchar(MAX), @now, 3), 3\nunion select convert(nvarchar(MAX), @now, 4), 4\nunion select convert(nvarchar(MAX), @now, 5), 5\nunion select convert(nvarchar(MAX), @now, 6), 6\nunion select convert(nvarchar(MAX), @now, 7), 7\nunion select convert(nvarchar(MAX), @now, 8), 8\nunion select convert(nvarchar(MAX), @now, 9), 9\nunion select convert(nvarchar(MAX), @now, 10), 10\nunion select convert(nvarchar(MAX), @now, 11), 11\nunion select convert(nvarchar(MAX), @now, 12), 12\nunion select convert(nvarchar(MAX), @now, 13), 13\nunion select convert(nvarchar(MAX), @now, 14), 14\n--15 to 19 not valid\nunion select convert(nvarchar(MAX), @now, 20), 20\nunion select convert(nvarchar(MAX), @now, 21), 21\nunion select convert(nvarchar(MAX), @now, 22), 22\nunion select convert(nvarchar(MAX), @now, 23), 23\nunion select convert(nvarchar(MAX), @now, 24), 24\nunion select convert(nvarchar(MAX), @now, 25), 25\n--26 to 99 not valid\nunion select convert(nvarchar(MAX), @now, 100), 100\nunion select convert(nvarchar(MAX), @now, 101), 101\nunion select convert(nvarchar(MAX), @now, 102), 102\nunion select convert(nvarchar(MAX), @now, 103), 103\nunion select convert(nvarchar(MAX), @now, 104), 104\nunion select convert(nvarchar(MAX), @now, 105), 105\nunion select convert(nvarchar(MAX), @now, 106), 106\nunion select convert(nvarchar(MAX), @now, 107), 107\nunion select convert(nvarchar(MAX), @now, 108), 108\nunion select convert(nvarchar(MAX), @now, 109), 109\nunion select convert(nvarchar(MAX), @now, 110), 110\nunion select convert(nvarchar(MAX), @now, 111), 111\nunion select convert(nvarchar(MAX), @now, 112), 112\nunion select convert(nvarchar(MAX), @now, 113), 113\nunion select convert(nvarchar(MAX), @now, 114), 114\nunion select convert(nvarchar(MAX), @now, 120), 120\nunion select convert(nvarchar(MAX), @now, 121), 121\n--122 to 125 not valid\nunion select convert(nvarchar(MAX), @now, 126), 126\nunion select convert(nvarchar(MAX), @now, 127), 127\n--128, 129 not valid\nunion select convert(nvarchar(MAX), @now, 130), 130\nunion select convert(nvarchar(MAX), @now, 131), 131\n--132 not valid\norder BY style\n output style\nApr 28 2014 9:31AM 0\n04/28/14 1\n14.04.28 2\n28/04/14 3\n28.04.14 4\n28-04-14 5\n28 Apr 14 6\nApr 28, 14 7\n09:31:28 8\nApr 28 2014 9:31:28:580AM 9\n04-28-14 10\n14/04/28 11\n140428 12\n28 Apr 2014 09:31:28:580 13\n09:31:28:580 14\n2014-04-28 09:31:28 20\n2014-04-28 09:31:28.580 21\n04/28/14 9:31:28 AM 22\n2014-04-28 23\n09:31:28 24\n2014-04-28 09:31:28.580 25\nApr 28 2014 9:31AM 100\n04/28/2014 101\n2014.04.28 102\n28/04/2014 103\n28.04.2014 104\n28-04-2014 105\n28 Apr 2014 106\nApr 28, 2014 107\n09:31:28 108\nApr 28 2014 9:31:28:580AM 109\n04-28-2014 110\n2014/04/28 111\n20140428 112\n28 Apr 2014 09:31:28:580 113\n09:31:28:580 114\n2014-04-28 09:31:28 120\n2014-04-28 09:31:28.580 121\n2014-04-28T09:31:28.580 126\n2014-04-28T09:31:28.580 127\n28 جمادى الثانية 1435 9:31:28:580AM 130\n28/06/1435 9:31:28:580AM 131\n nvarchar(max) select convert(nvarchar(11), GETDATE(), 0)\nunion select convert(nvarchar(max), GETDATE(), 0)\n May 18 2018\nMay 18 2018 9:57AM\n"
},
{
"answer_id": 23369972,
"author": "Gabriel",
"author_id": 3112707,
"author_profile": "https://Stackoverflow.com/users/3112707",
"pm_score": 1,
"selected": false,
"text": "CONVERT(VARCHAR, GETDATE(), 23)\n"
},
{
"answer_id": 27231940,
"author": "Konstantin",
"author_id": 1665649,
"author_profile": "https://Stackoverflow.com/users/1665649",
"pm_score": 2,
"selected": false,
"text": "DECLARE @now AS DATETIME = GETDATE()\n\nSELECT CONVERT(VARCHAR, @now, 23)\n"
},
{
"answer_id": 41594909,
"author": "Ema.H",
"author_id": 2630447,
"author_profile": "https://Stackoverflow.com/users/2630447",
"pm_score": 2,
"selected": false,
"text": "CONVERT('TheTypeYouWant', 'TheDateToConvert', 'TheCodeForFormating' * )\nCONVERT(NVARCHAR(10), DATE_OF_DAY, 103) => 15/09/2016\n CONVERT(NVARCHAR(10), MY_DATE_TIME, 120) => 2016-09-15\n CAST(MY_DATE_TIME as DATE) => 2016-09-15\n"
},
{
"answer_id": 45005103,
"author": "Dilkhush",
"author_id": 7384154,
"author_profile": "https://Stackoverflow.com/users/7384154",
"pm_score": 2,
"selected": false,
"text": "select REPLACE(CONVERT(VARCHAR(24),GETDATE(),103),'/','_') + '_'+ \n REPLACE(CONVERT(VARCHAR(24),GETDATE(),114),':','_')\n"
},
{
"answer_id": 53440678,
"author": "Dilkhush",
"author_id": 7384154,
"author_profile": "https://Stackoverflow.com/users/7384154",
"pm_score": 1,
"selected": false,
"text": "DECLARE @DateTime DATETIME\nSET @DateTime = '2018-11-23 10:03:23'\nSELECT CONVERT(VARCHAR(100),@DateTime,121 )\n"
},
{
"answer_id": 53486217,
"author": "Peter Majko",
"author_id": 4528229,
"author_profile": "https://Stackoverflow.com/users/4528229",
"pm_score": 2,
"selected": false,
"text": "CONVERT(VARCHAR, FORMAT(GETDATE(), 'dd.MM.yyyy HH:mm:ss', 'de-DE'))\n"
},
{
"answer_id": 57322855,
"author": "Beyhan",
"author_id": 2599859,
"author_profile": "https://Stackoverflow.com/users/2599859",
"pm_score": 0,
"selected": false,
"text": "CREATE FUNCTION dbo.TO_SAP_DATETIME(@input datetime)\nRETURNS VARCHAR(14)\nAS BEGIN\n DECLARE @ret VARCHAR(14)\n SET @ret = COALESCE(SUBSTRING(REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(26), @input, 25),'-',''),' ',''),':',''),1,14),'00000000000000');\n RETURN @ret\nEND\n"
},
{
"answer_id": 61617060,
"author": "Andres Galindo",
"author_id": 13475919,
"author_profile": "https://Stackoverflow.com/users/13475919",
"pm_score": 1,
"selected": false,
"text": "select REPLACE(CONVERT(VARCHAR, FORMAT(GETDATE(), N'dd/MM/yyyy hh:mm:ss tt')),'.', '/')\n 05/05/2020 10:41:05 AM"
},
{
"answer_id": 67225951,
"author": "Zain",
"author_id": 4281423,
"author_profile": "https://Stackoverflow.com/users/4281423",
"pm_score": 0,
"selected": false,
"text": "DECLARE @myDateTime DATETIME\nSET @myDateTime = '2008-05-03'\n\nSELECT FORMAT(CONVERT(date, @myDateTime ),'yyyy-MM-dd')\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74385",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7604/"
] |
74,386 |
<p>Is it possible to call managed code, specifically IronRuby or IronPython from unamanaged code such as C++ or Delphi?</p>
<p>For example, we have an application written in Delphi that is being moved to C#.NET We'd like to provide Ruby or Python scripting in our new application to replace VBSCRIPT. However, we would need to provide Ruby/Python scripting in the old Delphi application. Is it possible to use the managed dlls provided by IronRuby/IronPython from Delphi code?</p>
|
[
{
"answer_id": 2351140,
"author": "Lukas Cenovsky",
"author_id": 138803,
"author_profile": "https://Stackoverflow.com/users/138803",
"pm_score": 2,
"selected": false,
"text": "Set8087CW($133F);"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12999/"
] |
74,430 |
<p>I am trying to use the <code>import random</code> statement in python, but it doesn't appear to have any methods in it to use.</p>
<p>Am I missing something?</p>
|
[
{
"answer_id": 74459,
"author": "Chris AtLee",
"author_id": 4558,
"author_profile": "https://Stackoverflow.com/users/4558",
"pm_score": 0,
"selected": false,
"text": "import random\nprint random.randint(0,10)\n"
},
{
"answer_id": 74476,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 1,
"selected": false,
"text": "Python 2.5.2 (r252:60911, Jun 16 2008, 18:27:58)\n[GCC 3.3.4 (pre 3.3.5 20040809)] on linux2\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> import random\n>>> random.seed()\n>>> dir(random)\n['BPF', 'LOG4', 'NV_MAGICCONST', 'RECIP_BPF', 'Random', 'SG_MAGICCONST', 'SystemRandom', 'TWOPI', 'WichmannHill', '_BuiltinMethodType', '_MethodType', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '_acos', '_ceil', '_cos', '_e', '_exp', '_hexlify', '_inst', '_log', '_pi', '_random', '_sin', '_sqrt', '_test', '_test_generator', '_urandom', '_warn', 'betavariate', 'choice', 'expovariate', 'gammavariate', 'gauss', 'getrandbits', 'getstate', 'jumpahead', 'lognormvariate', 'normalvariate', 'paretovariate', 'randint', 'random', 'randrange', 'sample', 'seed', 'setstate', 'shuffle', 'uniform', 'vonmisesvariate', 'weibullvariate']\n>>> random.randint(0,3)\n3\n>>> random.randint(0,3)\n1\n>>> \n"
},
{
"answer_id": 74485,
"author": "Chris Bunch",
"author_id": 422,
"author_profile": "https://Stackoverflow.com/users/422",
"pm_score": 0,
"selected": false,
"text": ">>> import random\n>>> random.random()\n0.69130806168332215\n>>> random.uniform(1, 10)\n8.8384170917436293\n>>> random.randint(1, 10)\n4\n"
},
{
"answer_id": 75360,
"author": "Thomas Vander Stichele",
"author_id": 2900,
"author_profile": "https://Stackoverflow.com/users/2900",
"pm_score": 0,
"selected": false,
"text": "Python 2.5.1 (r251:54863, Jun 15 2008, 18:24:51) \n[GCC 4.3.0 20080428 (Red Hat 4.3.0-8)] on linux2\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> import random\n>>> brothers = ['larry', 'curly', 'moe']\n>>> random.choice(brothers)\n'moe'\n>>> random.choice(brothers)\n'curly'\n"
},
{
"answer_id": 75427,
"author": "Jerry Hill",
"author_id": 12773,
"author_profile": "https://Stackoverflow.com/users/12773",
"pm_score": 6,
"selected": true,
"text": ">>> import random\n>>> print random.__file__\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13050/"
] |
74,451 |
<p>Windows file system is case insensitive. How, given a file/folder name (e.g. "somefile"), I get the <em>actual</em> name of that file/folder (e.g. it should return "SomeFile" if Explorer displays it so)?</p>
<p>Some ways I know, all of which seem quite backwards:</p>
<ol>
<li>Given the full path, search for each folder on the path (via FindFirstFile). This gives proper cased results of each folder. At the last step, search for the file itself.</li>
<li>Get filename from handle (as in <a href="http://msdn.microsoft.com/en-us/library/aa366789(VS.85).aspx" rel="noreferrer">MSDN example</a>). This requires opening a file, creating file mapping, getting it's name, parsing device names etc. Pretty convoluted. And it does not work for folders or zero-size files.</li>
</ol>
<p>Am I missing some obvious WinAPI call? The simplest ones, like GetActualPathName() or GetFullPathName() return the name using casing that was passed in (e.g. returns "program files" if that was passed in, even if it should be "Program Files").</p>
<p>I'm looking for a native solution (not .NET one).</p>
|
[
{
"answer_id": 74563,
"author": "bugmagnet",
"author_id": 426,
"author_profile": "https://Stackoverflow.com/users/426",
"pm_score": 2,
"selected": false,
"text": "Dim fso\nSet fso = CreateObject(\"Scripting.FileSystemObject\")\nDim f\nSet f = fso.GetFile(\"C:\\testfile.dat\") 'actually named \"testFILE.dAt\"\nwscript.echo f.Name\n testFILE.dAt\n"
},
{
"answer_id": 81493,
"author": "NeARAZ",
"author_id": 6799,
"author_profile": "https://Stackoverflow.com/users/6799",
"pm_score": 4,
"selected": true,
"text": "std::wstring GetActualPathName( const wchar_t* path )\n{\n // This is quite involved, but the meat is SHGetFileInfo\n\n const wchar_t kSeparator = L'\\\\';\n\n // copy input string because we'll be temporary modifying it in place\n size_t length = wcslen(path);\n wchar_t buffer[MAX_PATH];\n memcpy( buffer, path, (length+1) * sizeof(path[0]) );\n\n size_t i = 0;\n\n std::wstring result;\n\n // for network paths (\\\\server\\share\\RestOfPath), getting the display\n // name mangles it into unusable form (e.g. \"\\\\server\\share\" turns\n // into \"share on server (server)\"). So detect this case and just skip\n // up to two path components\n if( length >= 2 && buffer[0] == kSeparator && buffer[1] == kSeparator )\n {\n int skippedCount = 0;\n i = 2; // start after '\\\\'\n while( i < length && skippedCount < 2 )\n {\n if( buffer[i] == kSeparator )\n ++skippedCount;\n ++i;\n }\n\n result.append( buffer, i );\n }\n // for drive names, just add it uppercased\n else if( length >= 2 && buffer[1] == L':' )\n {\n result += towupper(buffer[0]);\n result += L':';\n if( length >= 3 && buffer[2] == kSeparator )\n {\n result += kSeparator;\n i = 3; // start after drive, colon and separator\n }\n else\n {\n i = 2; // start after drive and colon\n }\n }\n\n size_t lastComponentStart = i;\n bool addSeparator = false;\n\n while( i < length )\n {\n // skip until path separator\n while( i < length && buffer[i] != kSeparator )\n ++i;\n\n if( addSeparator )\n result += kSeparator;\n\n // if we found path separator, get real filename of this\n // last path name component\n bool foundSeparator = (i < length);\n buffer[i] = 0;\n SHFILEINFOW info;\n\n // nuke the path separator so that we get real name of current path component\n info.szDisplayName[0] = 0;\n if( SHGetFileInfoW( buffer, 0, &info, sizeof(info), SHGFI_DISPLAYNAME ) )\n {\n result += info.szDisplayName;\n }\n else\n {\n // most likely file does not exist.\n // So just append original path name component.\n result.append( buffer + lastComponentStart, i - lastComponentStart );\n }\n\n // restore path separator that we might have nuked before\n if( foundSeparator )\n buffer[i] = kSeparator;\n\n ++i;\n lastComponentStart = i;\n addSeparator = true;\n }\n\n return result;\n}\n"
},
{
"answer_id": 47353320,
"author": "raymai97",
"author_id": 1261956,
"author_profile": "https://Stackoverflow.com/users/1261956",
"pm_score": 1,
"selected": false,
"text": "Scripting.FileSystemObject MAX_PATH #include <Windows.h>\n#include <objbase.h>\n#include <conio.h> // for _getch()\n\n#ifndef __cplusplus\n# include <stdio.h>\n\n#define SafeFree(p, fn) \\\n if (p) { fn(p); (p) = NULL; }\n\n#define SafeFreeCOM(p) \\\n if (p) { (p)->lpVtbl->Release(p); (p) = NULL; }\n\n\nstatic HRESULT CorrectPathCasing2(\n LPCWSTR const pszSrc, LPWSTR *ppszDst)\n{\n DWORD const clsCtx = CLSCTX_INPROC_SERVER;\n LCID const lcid = LOCALE_USER_DEFAULT;\n LPCWSTR const pszProgId = L\"Scripting.FileSystemObject\";\n LPCWSTR const pszMethod = L\"GetAbsolutePathName\";\n HRESULT hr = 0;\n CLSID clsid = { 0 };\n IDispatch *pDisp = NULL;\n DISPID dispid = 0;\n VARIANT vtSrc = { VT_BSTR };\n VARIANT vtDst = { VT_BSTR };\n DISPPARAMS params = { 0 };\n SIZE_T cbDst = 0;\n LPWSTR pszDst = NULL;\n\n // CoCreateInstance<IDispatch>(pszProgId, &pDisp)\n\n hr = CLSIDFromProgID(pszProgId, &clsid);\n if (FAILED(hr)) goto eof;\n\n hr = CoCreateInstance(&clsid, NULL, clsCtx,\n &IID_IDispatch, (void**)&pDisp);\n if (FAILED(hr)) goto eof;\n if (!pDisp) {\n hr = E_UNEXPECTED; goto eof;\n }\n\n // Variant<BSTR> vtSrc(pszSrc), vtDst;\n // vtDst = pDisp->InvokeMethod( pDisp->GetIDOfName(pszMethod), vtSrc );\n\n hr = pDisp->lpVtbl->GetIDsOfNames(pDisp, NULL,\n (LPOLESTR*)&pszMethod, 1, lcid, &dispid);\n if (FAILED(hr)) goto eof;\n\n vtSrc.bstrVal = SysAllocString(pszSrc);\n if (!vtSrc.bstrVal) {\n hr = E_OUTOFMEMORY; goto eof;\n }\n params.rgvarg = &vtSrc;\n params.cArgs = 1;\n hr = pDisp->lpVtbl->Invoke(pDisp, dispid, NULL, lcid,\n DISPATCH_METHOD, ¶ms, &vtDst, NULL, NULL);\n if (FAILED(hr)) goto eof;\n if (!vtDst.bstrVal) {\n hr = E_UNEXPECTED; goto eof;\n }\n\n // *ppszDst = AllocWStrCopyBStrFrom(vtDst.bstrVal);\n\n cbDst = SysStringByteLen(vtDst.bstrVal);\n pszDst = HeapAlloc(GetProcessHeap(),\n HEAP_ZERO_MEMORY, cbDst + sizeof(WCHAR));\n if (!pszDst) {\n hr = E_OUTOFMEMORY; goto eof;\n }\n CopyMemory(pszDst, vtDst.bstrVal, cbDst);\n *ppszDst = pszDst;\n\neof:\n SafeFree(vtDst.bstrVal, SysFreeString);\n SafeFree(vtSrc.bstrVal, SysFreeString);\n SafeFreeCOM(pDisp);\n return hr;\n}\n\nstatic void Cout(char const *psz)\n{\n printf(\"%s\", psz);\n}\n\nstatic void CoutErr(HRESULT hr)\n{\n printf(\"Error HRESULT 0x%.8X!\\n\", hr);\n}\n\nstatic void Test(LPCWSTR pszPath)\n{\n LPWSTR pszRet = NULL;\n HRESULT hr = CorrectPathCasing2(pszPath, &pszRet);\n if (FAILED(hr)) {\n wprintf(L\"Input: <%s>\\n\", pszPath);\n CoutErr(hr);\n }\n else {\n wprintf(L\"Was: <%s>\\nNow: <%s>\\n\", pszPath, pszRet);\n HeapFree(GetProcessHeap(), 0, pszRet);\n }\n}\n\n\n#else // Use C++ STL and ATL\n# include <iostream>\n# include <iomanip>\n# include <string>\n# include <atlbase.h>\n\nstatic HRESULT CorrectPathCasing2(\n std::wstring const &srcPath,\n std::wstring &dstPath)\n{\n HRESULT hr = 0;\n CComPtr<IDispatch> disp;\n hr = disp.CoCreateInstance(L\"Scripting.FileSystemObject\");\n if (FAILED(hr)) return hr;\n\n CComVariant src(srcPath.c_str()), dst;\n hr = disp.Invoke1(L\"GetAbsolutePathName\", &src, &dst);\n if (FAILED(hr)) return hr;\n\n SIZE_T cch = SysStringLen(dst.bstrVal);\n dstPath = std::wstring(dst.bstrVal, cch);\n return hr;\n}\n\nstatic void Cout(char const *psz)\n{\n std::cout << psz;\n}\n\nstatic void CoutErr(HRESULT hr)\n{\n std::wcout\n << std::hex << std::setfill(L'0') << std::setw(8)\n << \"Error HRESULT 0x\" << hr << \"\\n\";\n}\n\nstatic void Test(std::wstring const &path)\n{\n std::wstring output;\n HRESULT hr = CorrectPathCasing2(path, output);\n if (FAILED(hr)) {\n std::wcout << L\"Input: <\" << path << \">\\n\";\n CoutErr(hr);\n }\n else {\n std::wcout << L\"Was: <\" << path << \">\\n\"\n << \"Now: <\" << output << \">\\n\";\n }\n}\n\n#endif\n\n\nstatic void TestRoutine(void)\n{\n HRESULT hr = CoInitialize(NULL);\n\n if (FAILED(hr)) {\n Cout(\"CoInitialize failed!\\n\");\n CoutErr(hr);\n return;\n }\n\n Cout(\"\\n[ Absolute Path ]\\n\");\n Test(L\"c:\\\\uSers\\\\RayMai\\\\docuMENTs\");\n Test(L\"C:\\\\WINDOWS\\\\SYSTEM32\");\n\n Cout(\"\\n[ Relative Path ]\\n\");\n Test(L\".\");\n Test(L\"..\");\n Test(L\"\\\\\");\n\n Cout(\"\\n[ UNC Path ]\\n\");\n Test(L\"\\\\\\\\VMWARE-HOST\\\\SHARED FOLDERS\\\\D\\\\PROGRAMS INSTALLER\");\n\n Cout(\"\\n[ Very Long Path ]\\n\");\n Test(L\"\\\\\\\\?\\\\C:\\\\VERYVERYVERYLOOOOOOOONGFOLDERNAME\\\\\"\n L\"VERYVERYVERYLOOOOOOOONGFOLDERNAME\\\\\"\n L\"VERYVERYVERYLOOOOOOOONGFOLDERNAME\\\\\"\n L\"VERYVERYVERYLOOOOOOOONGFOLDERNAME\\\\\"\n L\"VERYVERYVERYLOOOOOOOONGFOLDERNAME\\\\\"\n L\"VERYVERYVERYLOOOOOOOONGFOLDERNAME\\\\\"\n L\"VERYVERYVERYLOOOOOOOONGFOLDERNAME\\\\\"\n L\"VERYVERYVERYLOOOOOOOONGFOLDERNAME\\\\\"\n L\"VERYVERYVERYLOOOOOOOONGFOLDERNAME\");\n\n Cout(\"\\n!! Worth Nothing Behavior !!\\n\");\n Test(L\"\");\n Test(L\"1234notexist\");\n Test(L\"C:\\\\bad\\\\PATH\");\n\n CoUninitialize();\n}\n\nint main(void)\n{\n TestRoutine();\n _getch();\n return 0;\n}\n FindFirstFile() fd.cFileName c:\\winDOWs\\exPLORER.exe FindFirstFile() fd.cFileName explorer.exe fd.cFileName c:\\winDOWs\\explorer.exe #include <windows.h>\n#include <stdio.h>\n\n/*\n c:\\windows\\windowsupdate.log --> c:\\windows\\WindowsUpdate.log\n*/\nstatic HRESULT MyProcessLastPart(LPTSTR szPath)\n{\n HRESULT hr = 0;\n HANDLE hFind = NULL;\n WIN32_FIND_DATA fd = {0};\n TCHAR *p = NULL, *q = NULL;\n /* thePart = GetCorrectCasingFileName(thePath); */\n hFind = FindFirstFile(szPath, &fd);\n if (hFind == INVALID_HANDLE_VALUE) {\n hr = HRESULT_FROM_WIN32(GetLastError());\n hFind = NULL; goto eof;\n }\n /* thePath = thePath.ReplaceLast(thePart); */\n for (p = szPath; *p; ++p);\n for (q = fd.cFileName; *q; ++q, --p);\n for (q = fd.cFileName; *p = *q; ++p, ++q);\neof:\n if (hFind) { FindClose(hFind); }\n return hr;\n}\n\n/*\n Important! 'szPath' should be absolute path only.\n MUST NOT SPECIFY relative path or UNC or short file name.\n*/\nEXTERN_C\nHRESULT __stdcall\nCorrectPathCasing(\n LPTSTR szPath)\n{\n HRESULT hr = 0;\n TCHAR *p = NULL;\n if (GetFileAttributes(szPath) == -1) {\n hr = HRESULT_FROM_WIN32(GetLastError()); goto eof;\n }\n for (p = szPath; *p; ++p)\n {\n if (*p == '\\\\' || *p == '/')\n {\n TCHAR slashChar = *p;\n if (p[-1] == ':') /* p[-2] is drive letter */\n {\n p[-2] = toupper(p[-2]);\n continue;\n }\n *p = '\\0';\n hr = MyProcessLastPart(szPath);\n *p = slashChar;\n if (FAILED(hr)) goto eof;\n }\n }\n hr = MyProcessLastPart(szPath);\neof:\n return hr;\n}\n\nint main()\n{\n TCHAR szPath[] = TEXT(\"c:\\\\windows\\\\EXPLORER.exe\");\n HRESULT hr = CorrectPathCasing(szPath);\n if (SUCCEEDED(hr))\n {\n MessageBox(NULL, szPath, TEXT(\"Test\"), MB_ICONINFORMATION);\n }\n return 0;\n}\n FindFirstFile() goto goto for strcpy strchr"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6799/"
] |
74,461 |
<p>I'm currently playing with the Silverlight(Beta 2) Datagrid control. Before I wired up the SelectionChanged event, the grid would sort perfectly by clicking on the header. Now, when the grid is clicked, it will fire the SelectionChanged event when I click the header to sort. Is there any way around this?</p>
<p>In a semi-related topic, I'd like to have the SelectionChanged event fire when I click on an already selected item (so that I can have a pop-up occur to allow the user to edit the selected value). Right now, you have to click on a different value and then back to the value you wanted in order for it to pop up. Is there another way? </p>
<p>Included is my code. </p>
<p>The Page:</p>
<pre><code><UserControl x:Class="WebServicesApp.Page"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
Width="1280" Height="1024" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
<Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" x:Name="OurStack" Orientation="Vertical" Margin="5,5,5,5">
<ContentControl VerticalAlignment="Center" HorizontalAlignment="Center">
<StackPanel x:Name="SearchStackPanel" Orientation="Horizontal" Margin="5,5,5,5">
<TextBlock x:Name="SearchEmail" HorizontalAlignment="Stretch" VerticalAlignment="Center" Text="Email Address:" Margin="5,5,5,5" />
<TextBox x:Name="InputText" HorizontalAlignment="Stretch" VerticalAlignment="Center" Width="150" Height="Auto" Margin="5,5,5,5"/>
<Button x:Name="SearchButton" Content="Search" Click="CallServiceButton_Click" HorizontalAlignment="Center" VerticalAlignment="Center" Width="75" Height="Auto" Background="#FFAFAFAF" Margin="5,5,5,5"/>
</StackPanel>
</ContentControl>
<Grid x:Name="DisplayRoot" Background="White" ShowGridLines="True"
HorizontalAlignment="Center" VerticalAlignment="Center" MaxHeight="300" MinHeight="100" MaxWidth="800" MinWidth="200"
ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible">
<data:DataGrid ItemsSource="{Binding ''}" CanUserReorderColumns="False" CanUserResizeColumns="False"
AutoGenerateColumns="False" AlternatingRowBackground="#FFAFAFAF" SelectionMode="Single"
HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,5,5,5" x:Name="IncidentGrid" SelectionChanged="IncidentGrid_SelectionChanged">
<data:DataGrid.Columns>
<data:DataGridTextColumn DisplayMemberBinding="{Binding Address}" Header="Email Address" IsReadOnly="True" /> <!--Width="150"-->
<data:DataGridTextColumn DisplayMemberBinding="{Binding whereClause}" Header="Where Clause" IsReadOnly="True" /> <!--Width="500"-->
<data:DataGridTextColumn DisplayMemberBinding="{Binding Enabled}" Header="Enabled" IsReadOnly="True" />
</data:DataGrid.Columns>
</data:DataGrid>
</Grid>
</StackPanel>
<Grid x:Name="EditPersonPopupGrid" Visibility="Collapsed">
<Rectangle HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Opacity="0.765" Fill="#FF8A8A8A" />
<Border CornerRadius="30" Background="#FF2D1DCC" Width="700" Height="400" HorizontalAlignment="Center" VerticalAlignment="Center" BorderThickness="1,1,1,1" BorderBrush="#FF000000">
<StackPanel x:Name="EditPersonStackPanel" Orientation="Vertical" Background="White" HorizontalAlignment="Center" VerticalAlignment="Center" Width="650" >
<ContentControl>
<StackPanel x:Name="EmailEditStackPanel" Orientation="Horizontal">
<TextBlock Text="Email Address:" Width="200" Margin="5,0,5,0" />
<TextBox x:Name="EmailPopupTextBox" Width="200" />
</StackPanel>
</ContentControl>
<ContentControl>
<StackPanel x:Name="AppliesToDropdownStackPanel" Orientation="Horizontal" Margin="2,2,2,0">
<TextBlock Text="Don't send when update was done by:" />
<StackPanel Orientation="Vertical" MaxHeight="275" MaxWidth="350" >
<TextBlock x:Name="SelectedItemTextBlock" TextAlignment="Right" Width="200" Margin="5,0,5,0" />
<Grid x:Name="UserDropDownGrid" MaxHeight="75" MaxWidth="200" Visibility="Collapsed" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Hidden" >
<Rectangle Fill="White" />
<Border Background="White">
<ListBox x:Name="UsersListBox" SelectionChanged="UsersListBox_SelectionChanged" ItemsSource="{Binding UserID}" />
</Border>
</Grid>
</StackPanel>
<Button x:Name="DropDownButton" Click="DropDownButton_Click" VerticalAlignment="Top" Width="25" Height="25">
<Path Height="10" Width="10" Fill="#FF000000" Stretch="Fill" Stroke="#FF000000" Data="M514.66669,354 L542.16669,354 L527.74988,368.41684 z" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="1,1,1,1"/>
</Button>
</StackPanel>
</ContentControl>
<TextBlock Text="Where Clause Condition:" />
<TextBox x:Name="WhereClauseTextBox" Height="200" Width="800" AcceptsReturn="True" TextWrapping="Wrap" />
<ContentControl>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Button x:Name="TestConditionButton" Content="Test Condition" Margin="5,5,5,5" Click="TestConditionButton_Click" />
<Button x:Name="Save" Content="Save" HorizontalAlignment="Right" Margin="5,5,5,5" Click="Save_Click" />
<Button x:Name="Cancel" Content="Cancel" HorizontalAlignment="Right" Margin="5,5,5,5" Click="Cancel_Click" />
</StackPanel>
<TextBlock x:Name="TestContitionResults" Visibility="Collapsed" />
</StackPanel>
</ContentControl>
</StackPanel>
</Border>
</Grid>
</Grid>
</code></pre>
<p></p>
<p>And the call that occurs when the grid's selection is changed:</p>
<pre><code>Private Sub IncidentGrid_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
If mFirstTime Then
mFirstTime = False
Else
Dim data As SimpleASMX.EMailMonitor = CType(IncidentGrid.SelectedItem, SimpleASMX.EMailMonitor)
Dim selectedGridItem As SimpleASMX.EMailMonitor = Nothing
If IncidentGrid.SelectedItem IsNot Nothing Then
selectedGridItem = CType(IncidentGrid.SelectedItem, SimpleASMX.EMailMonitor)
EmailPopupTextBox.Text = selectedGridItem.Address
SelectedItemTextBlock.Text = selectedGridItem.AppliesToUserID
WhereClauseTextBox.Text = selectedGridItem.whereClause
IncidentGrid.SelectedIndex = mEmailMonitorData.IndexOf(selectedGridItem)
End If
If IncidentGrid.SelectedIndex > -1 Then
EditPersonPopupGrid.Visibility = Windows.Visibility.Visible
Else
EditPersonPopupGrid.Visibility = Windows.Visibility.Collapsed
End If
End If
End Sub
</code></pre>
<p>Sorry if my code is atrocious, I'm still learning Silverlight.</p>
|
[
{
"answer_id": 74877,
"author": "Senkwe",
"author_id": 6419,
"author_profile": "https://Stackoverflow.com/users/6419",
"pm_score": 3,
"selected": true,
"text": "public partial class Page : UserControl\n{\n private Person _currentSelectedPerson;\n\n public Page()\n {\n InitializeComponent();\n\n List<Person> persons = new List<Person>();\n persons.Add(new Person() { Age = 5, Name = \"Tom\" });\n persons.Add(new Person() { Age = 3, Name = \"Lisa\" });\n persons.Add(new Person() { Age = 4, Name = \"Sam\" });\n\n dg.ItemsSource = persons;\n } \n\n private void SelectionChanged(object sender, EventArgs e)\n {\n DataGrid grid = sender as DataGrid;\n if (grid.SelectedItem != null)\n {\n _currentSelectedPerson = grid.SelectedItem as Person;\n }\n else\n {\n grid.SelectedItem = _currentSelectedPerson;\n }\n }\n }\n\npublic class Person\n{\n public string Name { get; set; }\n public int Age { get; set; }\n}\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12413/"
] |
74,466 |
<p>I have a .ico file that is embedded as a resource (build action set to resource). I am trying to create a NotifyIcon. How can I reference my icon?</p>
<pre><code>notifyIcon = new NotifyIcon();
notifyIcon.Icon = ?? // my icon file is called MyIcon.ico and is embedded
</code></pre>
|
[
{
"answer_id": 74671,
"author": "user13125",
"author_id": 13125,
"author_profile": "https://Stackoverflow.com/users/13125",
"pm_score": 8,
"selected": true,
"text": "System.Windows.Forms.NotifyIcon icon = new System.Windows.Forms.NotifyIcon();\nStream iconStream = Application.GetResourceStream( new Uri( \"pack://application:,,,/YourReferencedAssembly;component/YourPossibleSubFolder/YourResourceFile.ico\" )).Stream;\nicon.Icon = new System.Drawing.Icon( iconStream );\n"
},
{
"answer_id": 75049,
"author": "shinybluesphere",
"author_id": 10282,
"author_profile": "https://Stackoverflow.com/users/10282",
"pm_score": 2,
"selected": false,
"text": "//IconTest = namespace; exclamic.ico = resource \nSystem.IO.Stream stream = this.GetType().Assembly.GetManifestResourceStream(\"IconTest.Resources.exclamic.ico\");\n\n if (stream != null)\n {\n //Decode the icon from the stream and set the first frame to the BitmapSource\n BitmapDecoder decoder = IconBitmapDecoder.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.None);\n BitmapSource source = decoder.Frames[0];\n\n //set the source of your image\n image.Source = source;\n }\n"
},
{
"answer_id": 1870823,
"author": "Thomas Bratt",
"author_id": 15985,
"author_profile": "https://Stackoverflow.com/users/15985",
"pm_score": 5,
"selected": false,
"text": "var iconHandle = MyNamespace.Properties.Resources.MyImage.GetHicon();\nthis.notifyIcon.Icon = System.Drawing.Icon.FromHandle(iconHandle);\n <Window x:Class=\"MyNamespace.Window1\"\nxmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\nxmlns:local=\"clr-namespace:Seahorse\"\nxmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\nHeight=\"600\"\nIcon=\"images\\MyImage.png\">\n"
},
{
"answer_id": 32081321,
"author": "Mike Sage",
"author_id": 862414,
"author_profile": "https://Stackoverflow.com/users/862414",
"pm_score": 2,
"selected": false,
"text": " <Window x:Class=\"MyApp.MainWindow\"\n xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\n xmlns:d=\"http://schemas.microsoft.com/expression/blend/2008\"\n xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"\n mc:Ignorable=\"d\"\n Height=\"100\"\n Width=\"200\"\n Icon=\"pack://application:,,,/MyApp;component/Resources/small_icon.ico\">\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3047/"
] |
74,471 |
<p>I have a function that takes, amongst others, a parameter declared as <em>int privateCount</em>. When I want to call ToString() on this param, ReSharper greys it out and marks it as a redundant call. So, curious as I am, I remove the ToString(), and the code still builds!</p>
<p>How can a C# compiler allow this, where <em>str</em> is a string?</p>
<p><code>str += privateCount +</code> ...</p>
|
[
{
"answer_id": 74495,
"author": "Haacked",
"author_id": 598,
"author_profile": "https://Stackoverflow.com/users/598",
"pm_score": 5,
"selected": true,
"text": "string x = \"123\" + 45;\n String.Concat(\"123\", 45);\n"
},
{
"answer_id": 74546,
"author": "Stephen Deken",
"author_id": 7154,
"author_profile": "https://Stackoverflow.com/users/7154",
"pm_score": 2,
"selected": false,
"text": "aString = aString + 23;\n aString += 23;\n"
},
{
"answer_id": 74606,
"author": "Drejc",
"author_id": 6482,
"author_profile": "https://Stackoverflow.com/users/6482",
"pm_score": 1,
"selected": false,
"text": "myInt = myInt + 23;\n myInt = mInt + \"23\";\n myInt = string.Format(\"{0}{1}\", myInt, 23);\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8741/"
] |
74,494 |
<p>I'm developing a website on an XP virtual machine and have an SMTP virtual server set up in IIS -- it delivers mail just fine. What I would <em>like</em> is to confirm that any emails the site sends are only going to a specific domain.</p>
<p>The XP firewall seems to only involve incoming connections, I can't block outgoing TCP on port 25. And I haven't been able to configure the SMTP server to filter by delivery address.</p>
<p>With this setup, is there any easy way to filter outgoing email by destination address?</p>
|
[
{
"answer_id": 75434,
"author": "Neil C. Obremski",
"author_id": 9642,
"author_profile": "https://Stackoverflow.com/users/9642",
"pm_score": 2,
"selected": true,
"text": "Advanced Delivery SMTP Virtual Server Properties Delivery Advanced"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13071/"
] |
74,514 |
<p>Implementing Equals() for reference types is harder than it seems. My current canonical implementation goes like this:</p>
<pre><code>public bool Equals( MyClass obj )
{
// If both refer to the same reference they are equal.
if( ReferenceEquals( obj, this ) )
return true;
// If the other object is null they are not equal because in C# this cannot be null.
if( ReferenceEquals( obj, null ) )
return false;
// Compare data to evaluate equality
return _data.Equals( obj._data );
}
public override bool Equals( object obj )
{
// If both refer to the same reference they are equal.
if( ReferenceEquals( obj, this ) )
return true;
// If the other object is null or is of a different types the objects are not equal.
if( ReferenceEquals( obj, null ) || obj.GetType() != GetType() )
return false;
// Use type-safe equality comparison
return Equals( (MyClass)obj );
}
public override int GetHashCode()
{
// Use data's hash code as our hashcode
return _data.GetHashCode();
}
</code></pre>
<p>I think that this covers all corner (inheritance and such) cases but I may be wrong. What do you guys think?</p>
|
[
{
"answer_id": 74559,
"author": "chakrit",
"author_id": 3055,
"author_profile": "https://Stackoverflow.com/users/3055",
"pm_score": 0,
"selected": false,
"text": "GetType()"
},
{
"answer_id": 74704,
"author": "Santiago Palladino",
"author_id": 12791,
"author_profile": "https://Stackoverflow.com/users/12791",
"pm_score": 0,
"selected": false,
"text": " public override bool Equals(object obj)\n {\n var other = obj as MyClass;\n if (other == null) return false;\n\n return this.data.Equals(other.data);\n }\n"
},
{
"answer_id": 74765,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": false,
"text": "public bool Equals( MyClass obj )\n{\n if (obj == null) {\n return false;\n }\n else {\n return (this._data != null && this._data.Equals( obj._data ))\n || obj._data == null;\n }\n}\n\npublic override bool Equals( object obj )\n{\n if (obj == null || !(obj is MyClass)) {\n return false;\n }\n else {\n return this.Equals( (MyClass)obj );\n }\n}\n\npublic override int GetHashCode() {\n return this._data == null ? 0 : this._data.GetHashCode();\n}\n"
},
{
"answer_id": 69503610,
"author": "Manfred",
"author_id": 411428,
"author_profile": "https://Stackoverflow.com/users/411428",
"pm_score": 0,
"selected": false,
"text": "Equals() public override bool Equals(object obj) => this.Equals(obj as TwoDPoint);\n\npublic bool Equals(TwoDPoint p)\n{\n if (p is null)\n {\n return false;\n }\n\n // Optimization for a common success case.\n if (Object.ReferenceEquals(this, p))\n {\n return true;\n }\n\n // If run-time types are not exactly the same, return false.\n if (this.GetType() != p.GetType())\n {\n return false;\n }\n\n // Return true if the fields match.\n // Note that the base class is not invoked because it is\n // System.Object, which defines Equals as reference equality.\n return (X == p.X) && (Y == p.Y);\n}\n GetHashCode() public override int GetHashCode()\n{\n return HashCode.Combine(X, Y);\n}\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12851/"
] |
74,519 |
<p>I would like to use the 7-Zip DLLs from Delphi but have not been able to find decent documentation or examples. Does anyone know how to use the 7-Zip DLLs from Delphi?</p>
|
[
{
"answer_id": 1344656,
"author": "jasonpenny",
"author_id": 28445,
"author_profile": "https://Stackoverflow.com/users/28445",
"pm_score": 5,
"selected": false,
"text": "uses\n JclCompression;\n\nprocedure TfrmSevenZipTest.Button1Click(Sender: TObject);\nconst\n FILENAME = 'F:\\temp\\test.zip';\nvar\n archiveclass: TJclDecompressArchiveClass;\n archive: TJclDecompressArchive;\n item: TJclCompressionItem;\n s: String;\n i: Integer;\nbegin\n archiveclass := GetArchiveFormats.FindDecompressFormat(FILENAME);\n\n if not Assigned(archiveclass) then\n raise Exception.Create('Could not determine the Format of ' + FILENAME);\n\n archive := archiveclass.Create(FILENAME);\n try\n if not (archive is TJclSevenZipDecompressArchive) then\n raise Exception.Create('This format is not handled by 7z.dll');\n\n archive.ListFiles;\n\n s := Format('test.zip Item Count: %d'#13#10#13#10, [archive.ItemCount]);\n\n for i := 0 to archive.ItemCount - 1 do\n begin\n item := archive.Items[i];\n case item.Kind of\n ikFile:\n s := s + IntToStr(i+1) + ': ' + item.PackedName + #13#10;\n ikDirectory:\n s := s + IntToStr(i+1) + ': ' + item.PackedName + '\\'#13#10;//'\n end;\n end;\n\n if archive.ItemCount > 0 then\n begin\n// archive.Items[0].Selected := true;\n// archive.ExtractSelected('F:\\temp\\test');\n\n archive.ExtractAll('F:\\temp\\test');\n end;\n\n ShowMessage(s);\n finally\n archive.Free;\n end;\nend;\n"
},
{
"answer_id": 42602091,
"author": "Tone Škoda",
"author_id": 3572009,
"author_profile": "https://Stackoverflow.com/users/3572009",
"pm_score": 0,
"selected": false,
"text": "using sevenzip;\n\nprocedure Unzip7zFile (zipFullFname:string);\n var\n outDir:string;\n begin\n with CreateInArchive(CLSID_CFormat7z) do\n begin \n OpenFile(zipFullFname);\n outDir := ChangeFileExt(zipFullFname, '');\n ForceDirectories (outDir);\n ExtractTo(outDir);\n end;\n end;\n Unzip7zFile(ExtractFilePath(Application.ExeName) + 'STR_SI_FULL_1000420.7z');\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13054/"
] |
74,521 |
<p>Does anyone have details in setting up Qt4 in Visual Studio 2008? Links to other resources would be appreciated as well.</p>
<p>I already know that the commercial version of Qt has applications to this end. I also realize that I'll probably need to compile from source as the installer for the open source does not support Visual Studio and installs Cygwin.</p>
|
[
{
"answer_id": 1344656,
"author": "jasonpenny",
"author_id": 28445,
"author_profile": "https://Stackoverflow.com/users/28445",
"pm_score": 5,
"selected": false,
"text": "uses\n JclCompression;\n\nprocedure TfrmSevenZipTest.Button1Click(Sender: TObject);\nconst\n FILENAME = 'F:\\temp\\test.zip';\nvar\n archiveclass: TJclDecompressArchiveClass;\n archive: TJclDecompressArchive;\n item: TJclCompressionItem;\n s: String;\n i: Integer;\nbegin\n archiveclass := GetArchiveFormats.FindDecompressFormat(FILENAME);\n\n if not Assigned(archiveclass) then\n raise Exception.Create('Could not determine the Format of ' + FILENAME);\n\n archive := archiveclass.Create(FILENAME);\n try\n if not (archive is TJclSevenZipDecompressArchive) then\n raise Exception.Create('This format is not handled by 7z.dll');\n\n archive.ListFiles;\n\n s := Format('test.zip Item Count: %d'#13#10#13#10, [archive.ItemCount]);\n\n for i := 0 to archive.ItemCount - 1 do\n begin\n item := archive.Items[i];\n case item.Kind of\n ikFile:\n s := s + IntToStr(i+1) + ': ' + item.PackedName + #13#10;\n ikDirectory:\n s := s + IntToStr(i+1) + ': ' + item.PackedName + '\\'#13#10;//'\n end;\n end;\n\n if archive.ItemCount > 0 then\n begin\n// archive.Items[0].Selected := true;\n// archive.ExtractSelected('F:\\temp\\test');\n\n archive.ExtractAll('F:\\temp\\test');\n end;\n\n ShowMessage(s);\n finally\n archive.Free;\n end;\nend;\n"
},
{
"answer_id": 42602091,
"author": "Tone Škoda",
"author_id": 3572009,
"author_profile": "https://Stackoverflow.com/users/3572009",
"pm_score": 0,
"selected": false,
"text": "using sevenzip;\n\nprocedure Unzip7zFile (zipFullFname:string);\n var\n outDir:string;\n begin\n with CreateInArchive(CLSID_CFormat7z) do\n begin \n OpenFile(zipFullFname);\n outDir := ChangeFileExt(zipFullFname, '');\n ForceDirectories (outDir);\n ExtractTo(outDir);\n end;\n end;\n Unzip7zFile(ExtractFilePath(Application.ExeName) + 'STR_SI_FULL_1000420.7z');\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11994/"
] |
74,570 |
<p>I'm maintaining <a href="http://perl-begin.org/" rel="nofollow noreferrer">the Perl Beginners' Site</a> and used a modified template from Open Source Web Designs. Now, the problem is that I still have an undesired artifact: a gray line on the left side of the main frame, to the left of the navigation menu. Here's <a href="http://www.shlomifish.org/Files/files/images/Computer/Screenshots/perl-begin-bad-artif.png" rel="nofollow noreferrer">an image</a> highlighting the undesired effect.</p>
<p>How can I fix the CSS to remedy this problem?</p>
|
[
{
"answer_id": 74610,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 4,
"selected": true,
"text": "background-image #page-container\n{\n background-color: white;\n}\n"
},
{
"answer_id": 74621,
"author": "Jonathan Rupp",
"author_id": 12502,
"author_profile": "https://Stackoverflow.com/users/12502",
"pm_score": 0,
"selected": false,
"text": "#page-container {\n border-left: solid 1px rgb(150,150,150); border-right: solid 1px rgb(150,150,150); \n}\n"
},
{
"answer_id": 74663,
"author": "Jim",
"author_id": 8427,
"author_profile": "https://Stackoverflow.com/users/8427",
"pm_score": 1,
"selected": false,
"text": "background-color .buffer {\n float: left; width: 160px; height: 20px; margin: 0px; padding: 0px; background-color: rgb(255,255,255); \n}\n"
},
{
"answer_id": 74774,
"author": "user11070",
"author_id": 11070,
"author_profile": "https://Stackoverflow.com/users/11070",
"pm_score": 0,
"selected": false,
"text": "border-left:2px solid #BDBDBD;\n .buffer {style.css (line 328)\n background-color:#FFFFFF;\n border-left:2px solid #BDBDBD; /* Grey border */\n float:left;\n height:20px;\n margin:0px;\n padding:0px;\n width:160px;\n}\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7709/"
] |
74,612 |
<p>I have a table inside a div. I want the table to occupy the entire width of the div tag.</p>
<p>In the CSS, I've set the <code>width</code> of the table to <code>100%</code>. Unfortunately, when the div has some <code>margin</code> on it, the table ends up wider than the div it's in.</p>
<p>I need to support IE6 and IE7 (as this is an internal app), although I'd obviously like a fully cross-browser solution if possible!</p>
<p>I'm using the following DOCTYPE...</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
</code></pre>
<hr>
<p><strong>Edit</strong>: Unfortunately I can't hard-code the width as I'm dynamically generating the HTML and it includes nesting the divs recursively inside each other (with left margin on each div, this creates a nice 'nested' effect).</p>
|
[
{
"answer_id": 74715,
"author": "Nate",
"author_id": 12779,
"author_profile": "https://Stackoverflow.com/users/12779",
"pm_score": 3,
"selected": false,
"text": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n\n<html>\n <head>\n <title>Test</title>\n </head>\n <body>\n <div style=\"width: 500px; background-color:#F33;\">\n This is the outer div\n <div style=\"background-color: #FAA; padding: 10px; margin:10px;\">\n This is the inner div\n <table cellpadding=\"0\" cellspacing=\"0\" style=\"width: 100%\">\n <tr>\n <td style=\"border: 1px solid blue; background-color:#FEE;\">Here is my td</td>\n </tr>\n </table>\n </div>\n </div>\n </body>\n</html>\n"
},
{
"answer_id": 74799,
"author": "Nate",
"author_id": 12779,
"author_profile": "https://Stackoverflow.com/users/12779",
"pm_score": 1,
"selected": false,
"text": "<div>"
},
{
"answer_id": 75100,
"author": "Joe Morgan",
"author_id": 13244,
"author_profile": "https://Stackoverflow.com/users/13244",
"pm_score": 1,
"selected": false,
"text": "<table width=\"100%\">"
},
{
"answer_id": 76242,
"author": "farzad",
"author_id": 9394,
"author_profile": "https://Stackoverflow.com/users/9394",
"pm_score": 0,
"selected": false,
"text": "div {\n padding: 0px;\n}\n\ntable {\n width: 100%;\n margin: 0px;\n}\n"
},
{
"answer_id": 76478,
"author": "Eric DeLabar",
"author_id": 7556,
"author_profile": "https://Stackoverflow.com/users/7556",
"pm_score": 2,
"selected": false,
"text": "DOM DOCTYPE DOCTYPE IE6 overflow: hidden css"
},
{
"answer_id": 84685,
"author": "David Heggie",
"author_id": 4309,
"author_profile": "https://Stackoverflow.com/users/4309",
"pm_score": 2,
"selected": false,
"text": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n\n<html>\n <head>\n <title>Boxes and Tables</title>\n <style type=\"text/css\">\n\n div.container {\n background-color: yellow;\n border: 1px solid #000;\n width: 500px;\n margin: 5px auto;\n }\n\n table.contained {\n width: 100%;\n border-collapse: collapse;\n }\n\n table td {\n border: 2px solid #999;\n }\n\n </style>\n </head>\n\n <body>\n <div class=\"container\">\n <table class=\"contained\">\n <thead>\n <tr><th>Column1</th><th>Column2</th><th>Column3</th></tr>\n </thead>\n <tbody>\n <tr><td>Value</td><td>Value</td><td>Value</td></tr>\n <tr><td>Value</td><td>Value</td><td>Value</td></tr>\n <tr><td>Value</td><td>Value</td><td>Value</td></tr>\n <tr><td>Value</td><td>Value</td><td>Value</td></tr>\n <tr><td>Value</td><td>Value</td><td>Value</td></tr>\n </tbody>\n </table>\n </div>\n </body>\n</html>\n"
},
{
"answer_id": 650759,
"author": "Chris",
"author_id": 13700,
"author_profile": "https://Stackoverflow.com/users/13700",
"pm_score": 2,
"selected": false,
"text": "border-collapse border-collapse:collapse border: 40px solid blue border: 40px solid #999; border-collapse:collapse border-collapse"
},
{
"answer_id": 3908157,
"author": "Nestor",
"author_id": 470854,
"author_profile": "https://Stackoverflow.com/users/470854",
"pm_score": 0,
"selected": false,
"text": "<style type=\"text/css\">\n div.container \n {\n width: 500px;\n padding: 10px;\n margin: 10px;\n border: 1px solid red;\n }\n table.contained \n {\n width: 100%;\n border: 1px solid blue;\n }\n</style>\n\n<div class=\"container\">\n <table class=\"contained\">\n <tr>\n <td>Hello</td><td>World</td>\n </tr>\n </table>\n</div>\n"
},
{
"answer_id": 28622543,
"author": "Sharad Biradar",
"author_id": 2114874,
"author_profile": "https://Stackoverflow.com/users/2114874",
"pm_score": 5,
"selected": false,
"text": "<table> table-layout: fixed;\nwidth: 100%;\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/475/"
] |
74,616 |
<p>example:</p>
<pre><code>public static void DoSomething<K,V>(IDictionary<K,V> items) {
items.Keys.Each(key => {
if (items[key] **is IEnumerable<?>**) { /* do something */ }
else { /* do something else */ }
}
</code></pre>
<p>Can this be done without using reflection? How do I say IEnumerable in C#? Should I just use IEnumerable since IEnumerable<> implements IEnumerable? </p>
|
[
{
"answer_id": 74648,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 2,
"selected": false,
"text": "if (typeof(IEnumerable).IsAssignableFrom(typeof(V))) {\n"
},
{
"answer_id": 74772,
"author": "Isak Savo",
"author_id": 8521,
"author_profile": "https://Stackoverflow.com/users/8521",
"pm_score": 0,
"selected": false,
"text": "// Not allowed\nif (string is Object)\n Foo();\n// You have to use \nif (typeof(object).IsAssignableFrom(typeof(string))\n Foo();\n"
},
{
"answer_id": 75341,
"author": "Thomas Danecker",
"author_id": 9632,
"author_profile": "https://Stackoverflow.com/users/9632",
"pm_score": 1,
"selected": false,
"text": "public static void DoSomething<K,V>(IDictionary<K,V> items)\n where V : IEnumerable\n{\n items.Keys.Each(key => { /* do something */ });\n}\n\npublic static void DoSomething<K,V>(IDictionary<K,V> items)\n{\n items.Keys.Each(key => { /* do something else */ });\n}\n"
},
{
"answer_id": 75502,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 6,
"selected": true,
"text": "IEnumerable if (items[key] is IEnumerable)\n V IEnumerable`1 IEnumerable<> static bool IsGenericEnumerable(Type t) {\n var genArgs = t.GetGenericArguments();\n if (genArgs.Length == 1 &&\n typeof(IEnumerable<>).MakeGenericType(genArgs).IsAssignableFrom(t))\n return true;\n else\n return t.BaseType != null && IsGenericEnumerable(t.BaseType);\n}\n var xs = new List<string>();\nvar ys = new System.Collections.ArrayList();\nConsole.WriteLine(IsGenericEnumerable(xs.GetType()));\nConsole.WriteLine(IsGenericEnumerable(ys.GetType()));\n True\nFalse\n is IsAssignableToGenericType public static bool IsAssignableToGenericType(Type givenType, Type genericType) {\n var interfaceTypes = givenType.GetInterfaces();\n\n foreach (var it in interfaceTypes)\n if (it.IsGenericType)\n if (it.GetGenericTypeDefinition() == genericType) return true;\n\n Type baseType = givenType.BaseType;\n if (baseType == null) return false;\n\n return baseType.IsGenericType &&\n baseType.GetGenericTypeDefinition() == genericType ||\n IsAssignableToGenericType(baseType, genericType);\n}\n genericType givenType IsAssignableToGenericType(typeof(List<int>), typeof(List<>)) == false\nIsAssignableToGenericType(typeof(int?), typeof(Nullable<>)) == false\n"
},
{
"answer_id": 75600,
"author": "Rich Visotcky",
"author_id": 400730,
"author_profile": "https://Stackoverflow.com/users/400730",
"pm_score": 3,
"selected": false,
"text": "public class MyListBase<T> : IEnumerable<T> where T : ItemBase\n{\n}\n\npublic class MyItem : ItemBase\n{\n}\n\npublic class MyDerivedList : MyListBase<MyItem>\n{\n}\n MyDerivedList MyListBase<T> <T> MyListBase<MyItem> MyListBase<T> public static bool IsDerivedFromGenericType(Type givenType, Type genericType)\n {\n Type baseType = givenType.BaseType;\n if (baseType == null) return false;\n if (baseType.IsGenericType)\n {\n if (baseType.GetGenericTypeDefinition() == genericType) return true;\n }\n return IsDerivedFromGenericType(baseType, genericType);\n }\n public static bool IsAssignableToGenericType(Type givenType, Type genericType)\n {\n var interfaces = givenType.GetInterfaces().Where(it => it.IsGenericType).Select(it => it.GetGenericTypeDefinition());\n var foundInterface = interfaces.FirstOrDefault(it => it == genericType);\n if (foundInterface != null) return true;\n\n Type baseType = givenType.BaseType;\n if (baseType == null) return false;\n\n return baseType.IsGenericType ?\n baseType.GetGenericTypeDefinition() == genericType :\n IsAssignableToGenericType(baseType, genericType);\n }\n"
},
{
"answer_id": 390981,
"author": "Hosam Aly",
"author_id": 41283,
"author_profile": "https://Stackoverflow.com/users/41283",
"pm_score": 0,
"selected": false,
"text": "public static void DoSomething<K, V, U>(IDictionary<K,V> items)\n where V : IEnumerable<U> { /* do something */ }\npublic static void DoSomething<K, V>(IDictionary<K,V> items)\n { /* do something else */ }\n"
},
{
"answer_id": 1075059,
"author": "James Fraumeni",
"author_id": 132345,
"author_profile": "https://Stackoverflow.com/users/132345",
"pm_score": 7,
"selected": false,
"text": "public static bool IsAssignableToGenericType(Type givenType, Type genericType)\n{\n var interfaceTypes = givenType.GetInterfaces();\n\n foreach (var it in interfaceTypes)\n {\n if (it.IsGenericType && it.GetGenericTypeDefinition() == genericType)\n return true;\n }\n\n if (givenType.IsGenericType && givenType.GetGenericTypeDefinition() == genericType)\n return true;\n\n Type baseType = givenType.BaseType;\n if (baseType == null) return false;\n\n return IsAssignableToGenericType(baseType, genericType);\n}\n"
},
{
"answer_id": 8684023,
"author": "Matt Johnson-Pint",
"author_id": 634824,
"author_profile": "https://Stackoverflow.com/users/634824",
"pm_score": 2,
"selected": false,
"text": "public static bool IsAssignableToGenericType(this Type givenType, Type genericType)\n{\n return givenType.GetInterfaces().Any(t => t.IsGenericType && t.GetGenericTypeDefinition() == genericType) ||\n givenType.BaseType != null && (givenType.BaseType.IsGenericType && givenType.BaseType.GetGenericTypeDefinition() == genericType ||\n givenType.BaseType.IsAssignableToGenericType(genericType));\n}\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12934/"
] |
74,620 |
<p>Can't understand why the following takes place:</p>
<pre><code>String date = "06-04-2007 07:05";
SimpleDateFormat fmt = new SimpleDateFormat("MM-dd-yyyy HH:mm");
Date myDate = fmt.parse(date);
System.out.println(myDate); //Mon Jun 04 07:05:00 EDT 2007
long timestamp = myDate.getTime();
System.out.println(timestamp); //1180955100000 -- where are the milliseconds?
// on the other hand...
myDate = new Date();
System.out.println(myDate); //Tue Sep 16 13:02:44 EDT 2008
timestamp = myDate.getTime();
System.out.println(timestamp); //1221584564703 -- why, oh, why?
</code></pre>
|
[
{
"answer_id": 74652,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 5,
"selected": true,
"text": "String date = \"06-04-2007 07:05:00.999\";\nSimpleDateFormat fmt = new SimpleDateFormat(\"MM-dd-yyyy HH:mm:ss.S\");\nDate myDate = fmt.parse(date);\n\nSystem.out.println(myDate); \nlong timestamp = myDate.getTime();\nSystem.out.println(timestamp);\n"
},
{
"answer_id": 74694,
"author": "tim_yates",
"author_id": 6509,
"author_profile": "https://Stackoverflow.com/users/6509",
"pm_score": 0,
"selected": false,
"text": " System.out.printf( \"ms = %d\\n\", myDate.getTime() % 1000 ) ;\n"
},
{
"answer_id": 76006,
"author": "Michael",
"author_id": 13379,
"author_profile": "https://Stackoverflow.com/users/13379",
"pm_score": 0,
"selected": false,
"text": "getTime() Date SimpleDateFormat.format() String date = \"06-04-2007 07:05:23:123\";\nSimpleDateFormat fmt = new SimpleDateFormat(\"MM-dd-yyyy HH:mm:ss:S\");\nDate myDate = fmt.parse(date); \n\nSystem.out.println(myDate); //Mon Jun 04 07:05:23 EDT 2007\nString formattedDate = fmt.format(myDate);\nSystem.out.println(formattedDate); //06-04-2007 07:05:23:123\n"
},
{
"answer_id": 647220,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "import java.util.*;\n\npublic class Time {\n public static void main(String[] args) {\n Long l = 0L;\n Calendar c = Calendar.getInstance();\n //milli sec part of current time\n l = c.getTimeInMillis() % 1000; \n //current time without millisec\n StringBuffer sb = new StringBuffer(c.getTime().toString());\n //millisec in string\n String s = \":\" + l.toString();\n //insert at right place\n sb.insert(19, s);\n //ENJOY\n System.out.println(sb);\n }\n}\n"
},
{
"answer_id": 61567225,
"author": "Basil Bourque",
"author_id": 642706,
"author_profile": "https://Stackoverflow.com/users/642706",
"pm_score": 1,
"selected": false,
"text": "LocalDateTime.parse\n( \n \"06-04-2007 07:05\" , \n DateTimeFormatter.ofPattern( \"MM-dd-uuuu HH:mm\" ) \n)\n.atZone\n(\n ZoneId.of( \"Africa/Casablanca\" ) \n)\n.toInstant()\n.getEpochMilli()\n String input = \"06-04-2007 07:05\" ;\nDateTimeFormatter f = DateTimeFormatter.ofPattern( \"MM-dd-uuuu HH:mm\" ) ;\n LocalDateTime LocalDateTime ldt = LocalDateTime.parse( input , f ) ;\n LocalDateTime OffsetDateTime ZoneOffset.UTC OffsetDateTime odt = ldt.atOffset( ZoneOffset.UTC ) ; // Do this if your date and time represent a moment as seen in UTC. \n ZonedDateTime ZoneId z = ZoneId.of( \"Asia/Tokyo\" ) ;\nZonedDateTime zdt = ldt.atZone( z ) ;\n OffsetDateTime ZonedDateTime Instant toInstant Instant instant = odt.toInstant() ;\n Instant instant = zdt.toInstant() ;\n long millisecondsSinceEpoch = instant.toEpochMilli() ;\n java.util.Date Calendar SimpleDateFormat java.sql.*"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10675/"
] |
74,625 |
<p>A good while ago, I read <a href="http://www.viemu.com/a-why-vi-vim.html" rel="noreferrer">an article by the creator of viemu</a>, clearing up a lot of the misconceptions about vi, as well as explaining why it's a good idea (and why it's been very popular for the last 30 years+). The same guy also has <a href="http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html" rel="noreferrer">a great set of graphical cheat sheets</a> that teach the basics a few bits at a time.</p>
<p>I'm convinced.</p>
<p>I've been convinced for the past 2 years in fact. But I still really haven't gotten around to force myself to learn vi as my primary editor, the learning curve is just too high. When I get down to work, acceptable but immediate productivity (using my current editor) has so far won over tremendous productivity farther down the line (using vi).</p>
<p>Does anybody have any good tips to help get past the learning curve? It can be straight out tips, some other tutorial or article, whatever.</p>
<p>Edit: Note that I'm aware of the <a href="http://www.vim.org/" rel="noreferrer">vim/gVim</a>, <a href="http://cream.sourceforge.net/" rel="noreferrer">Cream</a> and <a href="http://code.google.com/p/macvim/" rel="noreferrer">MacVim</a> (etc.) variants of vi. I kept my question about vi to refer to the vi family as a whole. Thanks for all the great answers.</p>
<h3>Update (April 2009)</h3>
<p>I've been using Vim (more precisely, MacVim) in my day to day professional life since last December. I'm not going back :-)</p>
<p>Good luck to everyone in their Vim mastery.</p>
|
[
{
"answer_id": 74730,
"author": "Jon Ericson",
"author_id": 1438,
"author_profile": "https://Stackoverflow.com/users/1438",
"pm_score": 2,
"selected": false,
"text": "$ sudu rm /usr/local/bin/emacs\n"
},
{
"answer_id": 75151,
"author": "Eduardo Marinho",
"author_id": 13211,
"author_profile": "https://Stackoverflow.com/users/13211",
"pm_score": 2,
"selected": false,
"text": "ESC gg=G :retab vimtutor"
},
{
"answer_id": 75212,
"author": "Roberto Bonvallet",
"author_id": 13169,
"author_profile": "https://Stackoverflow.com/users/13169",
"pm_score": 4,
"selected": false,
"text": ".vimrc"
},
{
"answer_id": 75548,
"author": "user13060",
"author_id": 13060,
"author_profile": "https://Stackoverflow.com/users/13060",
"pm_score": 2,
"selected": false,
"text": "gVim :help vimtutor vimtutor"
},
{
"answer_id": 102478,
"author": "webmat",
"author_id": 6349,
"author_profile": "https://Stackoverflow.com/users/6349",
"pm_score": 0,
"selected": false,
"text": "git commit --amend"
},
{
"answer_id": 456101,
"author": "bk1e",
"author_id": 8090,
"author_profile": "https://Stackoverflow.com/users/8090",
"pm_score": 3,
"selected": false,
"text": "h j k l"
},
{
"answer_id": 834586,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "vim-tutor\n"
},
{
"answer_id": 858158,
"author": "Aaron Digulla",
"author_id": 34088,
"author_profile": "https://Stackoverflow.com/users/34088",
"pm_score": 2,
"selected": false,
"text": "vi ssh vi"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6349/"
] |
74,626 |
<p>I have a CIFS share mounted on a Linux machine. The CIFS server is down, or the internet connection is down, and anything that touches the CIFS mount now takes several minutes to timeout, and is unkillable while you wait. I can't even run ls in my home directory because there is a symlink pointing inside the CIFS mount and ls tries to follow it to decide what color it should be. If I try to umount it (even with -fl), the umount process hangs just like ls does. Not even sudo kill -9 can kill it. How can I force the kernel to unmount?</p>
|
[
{
"answer_id": 74695,
"author": "Chris AtLee",
"author_id": 4558,
"author_profile": "https://Stackoverflow.com/users/4558",
"pm_score": 2,
"selected": false,
"text": "umount -f /mnt/fileshare\n"
},
{
"answer_id": 96288,
"author": "Kemal",
"author_id": 7506,
"author_profile": "https://Stackoverflow.com/users/7506",
"pm_score": 9,
"selected": true,
"text": "umount -l L"
},
{
"answer_id": 12945984,
"author": "jnice",
"author_id": 1754934,
"author_profile": "https://Stackoverflow.com/users/1754934",
"pm_score": 3,
"selected": false,
"text": "mount -t smbfs -o soft //username@server/share /users/username/smb/share\n\nstat /users/username/smb/share/file\nstat: /users/username/smb/share/file: stat: Operation timed out\n"
},
{
"answer_id": 17128821,
"author": "ivanlan",
"author_id": 2489809,
"author_profile": "https://Stackoverflow.com/users/2489809",
"pm_score": 6,
"selected": false,
"text": "umount -a -t cifs -l"
},
{
"answer_id": 21489953,
"author": "Phil Johnson",
"author_id": 3258894,
"author_profile": "https://Stackoverflow.com/users/3258894",
"pm_score": 4,
"selected": false,
"text": " sudo umount -f /mnt/my_share\n sudo mount -t cifs -o username=me,password=mine //192.168.0.111/serv_share /mnt/my_share\n"
},
{
"answer_id": 23168749,
"author": "Benedikt Köppel",
"author_id": 1067124,
"author_profile": "https://Stackoverflow.com/users/1067124",
"pm_score": 2,
"selected": false,
"text": "umount.davfs -f -l -n -r -v umount.davfs umount -i -f -l /media/davmount"
},
{
"answer_id": 26286465,
"author": "Andy Fraley",
"author_id": 866057,
"author_profile": "https://Stackoverflow.com/users/866057",
"pm_score": 4,
"selected": false,
"text": "umount -f -a -t cifs -l \n"
},
{
"answer_id": 28272031,
"author": "zhjb7",
"author_id": 4518793,
"author_profile": "https://Stackoverflow.com/users/4518793",
"pm_score": 1,
"selected": false,
"text": "umount -f -t cifs -l /mnt &\n & umount umount /mnt df umount /mnt"
},
{
"answer_id": 29678826,
"author": "JimmyPheonix",
"author_id": 4797231,
"author_profile": "https://Stackoverflow.com/users/4797231",
"pm_score": -1,
"selected": false,
"text": "umount -l <mount path>\n"
},
{
"answer_id": 73278742,
"author": "mgutt",
"author_id": 318765,
"author_profile": "https://Stackoverflow.com/users/318765",
"pm_score": 0,
"selected": false,
"text": "mountpoint mountpoint /mnt/smb_share\n is a mountpoint / is not a mountpoint is not a mountpoint umount /mnt/smb_share umount /mnt/smb_share -f device is busy umount /mnt/smb_share -l # lsof | grep mount | grep cwd\nmount.cif 3125 root cwd unknown / (stat: No such device)\nmount.cif 3150 root cwd unknown / (stat: No such device)\n kill -9 $pid mount /mnt/smb_share umount mount.cifs //smb.server/share /mnt/smb_share -o username=smb_user,password=smb_pw\n mount.cifs //smb.server/share /mnt/smb_share -o username=smb_user,password=smb_pw,vers=3.1\n mount.cifs //smb.server/share /mnt/smb_share -o username=smb_user,password=smb_pw,vers=3.0\n mount.cifs //smb.server/share /mnt/smb_share -o username=smb_user,password=smb_pw,vers=2.1\n iptables iptables -t nat -A OUTPUT -d 10.0.0.250 -j DNAT --to-destination 10.0.0.1\n /etc/fstab smbclient //smb.server -U \"smb_user\" -m SMB3 -L\n smbclient //smb.server -U \"smb_user\" -m NT1 -c ls\n"
},
{
"answer_id": 73978769,
"author": "Aliceisnt",
"author_id": 10095447,
"author_profile": "https://Stackoverflow.com/users/10095447",
"pm_score": 0,
"selected": false,
"text": "cd ~\numount /path/to/my/share\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10168/"
] |
74,641 |
<p>I currently am tasked with updating an XML file (persistance.xml) within a jar at a customers site. I can of course unjar the file, update the xml, then rejar the file for redeployment. I would like to kind these command line operations in a Swing App so that the person doing it does not have to drop to the command line. Any thoughts on a way to do this programatically? </p>
|
[
{
"answer_id": 74702,
"author": "jodonnell",
"author_id": 4223,
"author_profile": "https://Stackoverflow.com/users/4223",
"pm_score": 2,
"selected": false,
"text": "File tmp = new File (\"tmp\");\ntmp.mkdirs();\nProcess unjar = new ProcessBuilder (\"jar\", \"-xf\", \"myjar.jar\", tmp.getName ()).start();\nunjar.waitFor();\n// TODO read and update persistence.xml\nProcess jar = new ProcessBuilder (\"jar\", \"-cf\", \"myjar.jar\", tmp.getName()).start();\njar.waitFor();\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/387361/"
] |
74,674 |
<p>I need to check CPU and memory usage for the server in java, anyone know how it could be done?</p>
|
[
{
"answer_id": 74742,
"author": "Rich Adams",
"author_id": 10018,
"author_profile": "https://Stackoverflow.com/users/10018",
"pm_score": 3,
"selected": false,
"text": "long total = Runtime.getRuntime().totalMemory();\nlong used = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();\n"
},
{
"answer_id": 74763,
"author": "Jeremy",
"author_id": 4419,
"author_profile": "https://Stackoverflow.com/users/4419",
"pm_score": 6,
"selected": false,
"text": "Runtime runtime = Runtime.getRuntime();\n\nNumberFormat format = NumberFormat.getInstance();\n\nStringBuilder sb = new StringBuilder();\nlong maxMemory = runtime.maxMemory();\nlong allocatedMemory = runtime.totalMemory();\nlong freeMemory = runtime.freeMemory();\n\nsb.append(\"free memory: \" + format.format(freeMemory / 1024) + \"<br/>\");\nsb.append(\"allocated memory: \" + format.format(allocatedMemory / 1024) + \"<br/>\");\nsb.append(\"max memory: \" + format.format(maxMemory / 1024) + \"<br/>\");\nsb.append(\"total free memory: \" + format.format((freeMemory + (maxMemory - allocatedMemory)) / 1024) + \"<br/>\");\n"
},
{
"answer_id": 75129,
"author": "Javamann",
"author_id": 10166,
"author_profile": "https://Stackoverflow.com/users/10166",
"pm_score": 4,
"selected": false,
"text": "OperatingSystemMXBean operatingSystemMXBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();\noperatingSystemMXBean.getSystemCpuLoad();\n"
},
{
"answer_id": 76113,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "[GC 325407K->83000K(776768K), 0.2300771 secs]\n[GC 325816K->83372K(776768K), 0.2454258 secs]\n[Full GC 267628K->83769K(776768K), 1.8479984 secs]\n 325407K->83000K (in the first line)\n (776768K) (in the first line)\n 0.2300771 secs (in the first line)\n"
},
{
"answer_id": 7870722,
"author": "Phil",
"author_id": 661773,
"author_profile": "https://Stackoverflow.com/users/661773",
"pm_score": 2,
"selected": false,
"text": "double currentMemory = ( (double)((double)(Runtime.getRuntime().totalMemory()/1024)/1024))- ((double)((double)(Runtime.getRuntime().freeMemory()/1024)/1024));\n"
},
{
"answer_id": 8973770,
"author": "Dave",
"author_id": 1165214,
"author_profile": "https://Stackoverflow.com/users/1165214",
"pm_score": 5,
"selected": false,
"text": "import java.io.File;\nimport java.text.NumberFormat;\n\npublic class SystemInfo {\n\n private Runtime runtime = Runtime.getRuntime();\n\n public String info() {\n StringBuilder sb = new StringBuilder();\n sb.append(this.osInfo());\n sb.append(this.memInfo());\n sb.append(this.diskInfo());\n return sb.toString();\n }\n\n public String osName() {\n return System.getProperty(\"os.name\");\n }\n\n public String osVersion() {\n return System.getProperty(\"os.version\");\n }\n\n public String osArch() {\n return System.getProperty(\"os.arch\");\n }\n\n public long totalMem() {\n return Runtime.getRuntime().totalMemory();\n }\n\n public long usedMem() {\n return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();\n }\n\n public String memInfo() {\n NumberFormat format = NumberFormat.getInstance();\n StringBuilder sb = new StringBuilder();\n long maxMemory = runtime.maxMemory();\n long allocatedMemory = runtime.totalMemory();\n long freeMemory = runtime.freeMemory();\n sb.append(\"Free memory: \");\n sb.append(format.format(freeMemory / 1024));\n sb.append(\"<br/>\");\n sb.append(\"Allocated memory: \");\n sb.append(format.format(allocatedMemory / 1024));\n sb.append(\"<br/>\");\n sb.append(\"Max memory: \");\n sb.append(format.format(maxMemory / 1024));\n sb.append(\"<br/>\");\n sb.append(\"Total free memory: \");\n sb.append(format.format((freeMemory + (maxMemory - allocatedMemory)) / 1024));\n sb.append(\"<br/>\");\n return sb.toString();\n\n }\n\n public String osInfo() {\n StringBuilder sb = new StringBuilder();\n sb.append(\"OS: \");\n sb.append(this.osName());\n sb.append(\"<br/>\");\n sb.append(\"Version: \");\n sb.append(this.osVersion());\n sb.append(\"<br/>\");\n sb.append(\": \");\n sb.append(this.osArch());\n sb.append(\"<br/>\");\n sb.append(\"Available processors (cores): \");\n sb.append(runtime.availableProcessors());\n sb.append(\"<br/>\");\n return sb.toString();\n }\n\n public String diskInfo() {\n /* Get a list of all filesystem roots on this system */\n File[] roots = File.listRoots();\n StringBuilder sb = new StringBuilder();\n\n /* For each filesystem root, print some info */\n for (File root : roots) {\n sb.append(\"File system root: \");\n sb.append(root.getAbsolutePath());\n sb.append(\"<br/>\");\n sb.append(\"Total space (bytes): \");\n sb.append(root.getTotalSpace());\n sb.append(\"<br/>\");\n sb.append(\"Free space (bytes): \");\n sb.append(root.getFreeSpace());\n sb.append(\"<br/>\");\n sb.append(\"Usable space (bytes): \");\n sb.append(root.getUsableSpace());\n sb.append(\"<br/>\");\n }\n return sb.toString();\n }\n}\n"
},
{
"answer_id": 15733233,
"author": "danieln",
"author_id": 1083423,
"author_profile": "https://Stackoverflow.com/users/1083423",
"pm_score": 4,
"selected": false,
"text": " OperatingSystemMXBean operatingSystemMXBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();\n RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();\n int availableProcessors = operatingSystemMXBean.getAvailableProcessors();\n long prevUpTime = runtimeMXBean.getUptime();\n long prevProcessCpuTime = operatingSystemMXBean.getProcessCpuTime();\n double cpuUsage;\n try\n {\n Thread.sleep(500);\n }\n catch (Exception ignored) { }\n\n operatingSystemMXBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();\n long upTime = runtimeMXBean.getUptime();\n long processCpuTime = operatingSystemMXBean.getProcessCpuTime();\n long elapsedCpu = processCpuTime - prevProcessCpuTime;\n long elapsedTime = upTime - prevUpTime;\n\n cpuUsage = Math.min(99F, elapsedCpu / (elapsedTime * 10000F * availableProcessors));\n System.out.println(\"Java CPU: \" + cpuUsage);\n"
},
{
"answer_id": 31187628,
"author": "sbeliakov",
"author_id": 2182091,
"author_profile": "https://Stackoverflow.com/users/2182091",
"pm_score": 2,
"selected": false,
"text": "import java.lang.management.ManagementFactory;\nimport com.sun.management.OperatingSystemMXBean;\n\ndouble getCpuLoad() {\n OperatingSystemMXBean osBean =\n (com.sun.management.OperatingSystemMXBean) ManagementFactory.\n getPlatformMXBeans(OperatingSystemMXBean.class);\n return osBean.getProcessCpuLoad();\n}\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13123/"
] |
74,690 |
<p>I have a QMainWindow in a Qt application. When I close it I want it to store its current restore size (the size of the window when it is not maximized). This works well when I close the window in restore mode (that is, not maximized). But if I close the window if it is maximized, then next time i start the application and restore the application (because it starts in maximized mode), then it does not remember the size it should restore to. Is there a way to do this?</p>
|
[
{
"answer_id": 74885,
"author": "dF.",
"author_id": 3002,
"author_profile": "https://Stackoverflow.com/users/3002",
"pm_score": 2,
"selected": false,
"text": "QWidget::isMaximized() QWidget::resize() QWidget::showMaximized()"
},
{
"answer_id": 8736705,
"author": "iforce2d",
"author_id": 624593,
"author_profile": "https://Stackoverflow.com/users/624593",
"pm_score": 4,
"selected": false,
"text": "void MainWindow::writePositionSettings()\n{\n QSettings qsettings( \"iforce2d\", \"killerapp\" );\n\n qsettings.beginGroup( \"mainwindow\" );\n\n qsettings.setValue( \"geometry\", saveGeometry() );\n qsettings.setValue( \"savestate\", saveState() );\n qsettings.setValue( \"maximized\", isMaximized() );\n if ( !isMaximized() ) {\n qsettings.setValue( \"pos\", pos() );\n qsettings.setValue( \"size\", size() );\n }\n\n qsettings.endGroup();\n}\n\nvoid MainWindow::readPositionSettings()\n{\n QSettings qsettings( \"iforce2d\", \"killerapp\" );\n\n qsettings.beginGroup( \"mainwindow\" );\n\n restoreGeometry(qsettings.value( \"geometry\", saveGeometry() ).toByteArray());\n restoreState(qsettings.value( \"savestate\", saveState() ).toByteArray());\n move(qsettings.value( \"pos\", pos() ).toPoint());\n resize(qsettings.value( \"size\", size() ).toSize());\n if ( qsettings.value( \"maximized\", isMaximized() ).toBool() )\n showMaximized();\n\n qsettings.endGroup();\n}\n MainWindow mainWindow;\nmainWindow.readPositionSettings();\nmainWindow.show();\n void MainWindow::moveEvent( QMoveEvent* )\n{\n writePositionSettings();\n}\n\nvoid MainWindow::resizeEvent( QResizeEvent* )\n{\n writePositionSettings();\n}\n\nvoid MainWindow::closeEvent( QCloseEvent* )\n{\n writePositionSettings();\n}\n"
},
{
"answer_id": 10866437,
"author": "Raimar",
"author_id": 894142,
"author_profile": "https://Stackoverflow.com/users/894142",
"pm_score": 0,
"selected": false,
"text": "geometry.x() geometry.y() x() y() pos() x()\ny()\nwidth()\nheight()\n move()\nresize()\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1585/"
] |
74,723 |
<p>This problem has been afflicting me for quite a while and it's been really annoying.</p>
<p>Every time I login after a reboot/power cycle the explorer takes some time to show up.
I've taken the step of waiting for all the services to boot up and then I login, but it doesn't make any difference.
The result is always the same: Some of the icons do not show up even if the applications have started.</p>
<p>I've dug a bit on the code that makes one application "stick" an icon in there, but is there an API call that one can perform so explorer re-reads all that icon info? Like invalidate or redraw or something of the sort?</p>
<hr>
<p>Apparently, it looks like Jon was right and it's not possible to do it.</p>
<p>I've followed Bob Dizzle and Mark Ransom code and build this (Delphi Code):</p>
<pre><code>procedure Refresh;
var
hSysTray: THandle;
begin
hSysTray := GetSystrayHandle;
SendMessage(hSysTray, WM_PAINT, 0, 0);
end;
function GetSystrayHandle: THandle;
var
hTray, hNotify, hSysPager: THandle;
begin
hTray := FindWindow('Shell_TrayWnd', '');
if hTray = 0 then
begin
Result := hTray;
exit;
end;
hNotify := FindWindowEx(hTray, 0, 'TrayNotifyWnd', '');
if hNotify = 0 then
begin
Result := hNotify;
exit;
end;
hSyspager := FindWindowEx(hNotify, 0, 'SysPager', '');
if hSyspager = 0 then
begin
Result := hSyspager;
exit;
end;
Result := FindWindowEx(hSysPager, 0, 'ToolbarWindow32', 'Notification Area');
end;</code></pre>
<p>But to no avail.</p>
<p>I've even tried with <pre><code>InvalidateRect()</code></pre> and still no show.</p>
<p>Any other suggestions?</p>
|
[
{
"answer_id": 74781,
"author": "Bob Dizzle",
"author_id": 9581,
"author_profile": "https://Stackoverflow.com/users/9581",
"pm_score": 2,
"selected": false,
"text": "public const int WM_PAINT = 0xF;\n[DllImport(\"USER32.DLL\")]\npublic static extern int SendMessage(IntPtr hwnd, int msg, int character,\n IntPtr lpsText);\n\nSend WM_PAINT Message to paint System Tray which will refresh it.\nSendMessage(traynotifywnd, WM_PAINT, 0, IntPtr.Zero);\n"
},
{
"answer_id": 74871,
"author": "Mark Ransom",
"author_id": 5987,
"author_profile": "https://Stackoverflow.com/users/5987",
"pm_score": 1,
"selected": false,
"text": "HWND FindSystemTrayIcons(void)\n{\n // the system tray icons are contained in a specific window hierarchy;\n // use the Spy++ utility to see the chain\n HWND hwndTray = ::FindWindow(\"Shell_TrayWnd\", \"\");\n if (hwndTray == NULL)\n return NULL;\n HWND hwndNotifyWnd = ::FindWindowEx(hwndTray, NULL, \"TrayNotifyWnd\", \"\");\n if (hwndNotifyWnd == NULL)\n return NULL;\n HWND hwndSysPager = ::FindWindowEx(hwndNotifyWnd, NULL, \"SysPager\", \"\");\n if (hwndSysPager == NULL)\n return NULL;\n return ::FindWindowEx(hwndSysPager, NULL, \"ToolbarWindow32\", \"Notification Area\");\n}\n"
},
{
"answer_id": 1052920,
"author": "Louis Davis",
"author_id": 103205,
"author_profile": "https://Stackoverflow.com/users/103205",
"pm_score": 5,
"selected": true,
"text": "#define FW(x,y) FindWindowEx(x, NULL, y, L\"\")\n\nvoid RefreshTaskbarNotificationArea()\n{\n HWND hNotificationArea;\n RECT r;\n\n GetClientRect(\n hNotificationArea = FindWindowEx(\n FW(FW(FW(NULL, L\"Shell_TrayWnd\"), L\"TrayNotifyWnd\"), L\"SysPager\"),\n NULL,\n L\"ToolbarWindow32\",\n // L\"Notification Area\"), // Windows XP\n L\"User Promoted Notification Area\"), // Windows 7 and up\n &r);\n\n for (LONG x = 0; x < r.right; x += 5)\n for (LONG y = 0; y < r.bottom; y += 5)\n SendMessage(\n hNotificationArea,\n WM_MOUSEMOVE,\n 0,\n (y << 16) + x);\n}\n"
},
{
"answer_id": 18038441,
"author": "Stephen Klancher",
"author_id": 221018,
"author_profile": "https://Stackoverflow.com/users/221018",
"pm_score": 4,
"selected": false,
"text": "//Hidden icons\nGetClientRect(\n hNotificationArea = FindWindowEx(\n FW(NULL, L\"NotifyIconOverflowWindow\"),\n NULL,\n L\"ToolbarWindow32\",\n L\"Overflow Notification Area\"),\n &r);\n\nfor (LONG x = 0; x < r.right; x += 5)\n for (LONG y = 0; y < r.bottom; y += 5)\n SendMessage(\n hNotificationArea,\n WM_MOUSEMOVE,\n 0,\n (y << 16) + x);\n"
},
{
"answer_id": 53938471,
"author": "user2712225",
"author_id": 2712225,
"author_profile": "https://Stackoverflow.com/users/2712225",
"pm_score": 0,
"selected": false,
"text": "choco install mingw --x86 --force --params \"/exception:sjlj\"\n C:\\ProgramData\\chocolatey\\lib\\mingw\\tools\\install\\mingw32\\bin\\gcc.exe\n gcc refresh_notification_area.c\n #include <windows.h>\n\n#define FW(x,y) FindWindowEx(x, NULL, y, \"\")\n\nint main ()\n{\n\n HWND hNotificationArea;\n RECT r;\n\n //WinXP\n // technique found at:\n // https://stackoverflow.com/questions/74723/can-you-send-a-signal-to-windows-explorer-to-make-it-refresh-the-systray-icons#18038441\n GetClientRect(\n hNotificationArea = FindWindowEx(\n FW(FW(FW(NULL, \"Shell_TrayWnd\"), \"TrayNotifyWnd\"), \"SysPager\"),\n NULL,\n \"ToolbarWindow32\",\n \"Notification Area\"),\n &r);\n\n for (LONG x = 0; x < r.right; x += 5)\n for (LONG y = 0; y < r.bottom; y += 5)\n SendMessage(\n hNotificationArea,\n WM_MOUSEMOVE,\n 0,\n (y << 16) + x);\n\n return 0;\n\n}\n"
},
{
"answer_id": 56088800,
"author": "Yuanhui",
"author_id": 5001634,
"author_profile": "https://Stackoverflow.com/users/5001634",
"pm_score": 1,
"selected": false,
"text": "NotifyIconOverflowWindow Shell_TrayWnd caption FindWindowEx spy++ #define FW(x,y) FindWindowEx(x, NULL, y, L\"\")\nvoid RefreshTaskbarNotificationArea()\n{\n HWND hNotificationArea;\n RECT r;\n GetClientRect(hNotificationArea = FindWindowEx(FW(NULL, L\"NotifyIconOverflowWindow\"), NULL, L\"ToolbarWindow32\", NULL), &r);\n for (LONG x = 0; x < r.right; x += 5)\n {\n for (LONG y = 0; y < r.bottom; y += 5)\n {\n SendMessage(hNotificationArea, WM_MOUSEMOVE, 0, (y << 16) + x);\n }\n }\n}\n"
},
{
"answer_id": 73008007,
"author": "tom42",
"author_id": 10959519,
"author_profile": "https://Stackoverflow.com/users/10959519",
"pm_score": 0,
"selected": false,
"text": "Add-Type -AssemblyName System.Windows.Forms\nAdd-Type @\"\nusing System;\nusing System.Runtime.InteropServices;\n\npublic struct RECT {\n public int left;\n public int top;\n public int right;\n public int bottom;\n}\n\npublic class pInvoke {\n [DllImport(\"user32.dll\")]\n public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);\n\n [DllImport(\"user32.dll\")]\n public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);\n\n [DllImport(\"user32.dll\")]\n public static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect);\n\n [DllImport(\"user32.dll\")]\n public static extern IntPtr SendMessage(IntPtr hWnd, uint msg, int wParam, int lParam);\n \n public static void RefreshTrayArea() {\n IntPtr systemTrayContainerHandle = FindWindow(\"Shell_TrayWnd\", null);\n IntPtr systemTrayHandle = FindWindowEx(systemTrayContainerHandle, IntPtr.Zero, \"TrayNotifyWnd\", null);\n IntPtr sysPagerHandle = FindWindowEx(systemTrayHandle, IntPtr.Zero, \"SysPager\", null);\n IntPtr notificationAreaHandle = FindWindowEx(sysPagerHandle, IntPtr.Zero, \"ToolbarWindow32\", \"Notification Area\");\n if (notificationAreaHandle == IntPtr.Zero) {\n notificationAreaHandle = FindWindowEx(sysPagerHandle, IntPtr.Zero, \"ToolbarWindow32\", \"User Promoted Notification Area\");\n IntPtr notifyIconOverflowWindowHandle = FindWindow(\"NotifyIconOverflowWindow\", null);\n IntPtr overflowNotificationAreaHandle = FindWindowEx(notifyIconOverflowWindowHandle, IntPtr.Zero, \"ToolbarWindow32\", \"Overflow Notification Area\");\n RefreshTrayArea(overflowNotificationAreaHandle);\n }\n RefreshTrayArea(notificationAreaHandle);\n }\n\n private static void RefreshTrayArea(IntPtr windowHandle) {\n const uint wmMousemove = 0x0200;\n RECT rect;\n GetClientRect(windowHandle, out rect);\n for (var x = 0; x < rect.right; x += 5)\n for (var y = 0; y < rect.bottom; y += 5)\n SendMessage(windowHandle, wmMousemove, 0, (y << 16) + x);\n }\n}\n\"@\n [pInvoke]::RefreshTrayArea()"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8167/"
] |
74,782 |
<p>What's the difference between eruby and erb? What considerations would drive me to choose one or the other?</p>
<p>My application is generating config files for network devices (routers, load balancers, firewalls, etc.). My plan is to template the config files, using embedded ruby (via either eruby or erb) within the source files to do things like iteratively generate all the interface config blocks for a router (these blocks are all very similar, differing only in a label and an IP address). For example, I might have a config template file like this:</p>
<pre><code>hostname sample-router
<%=
r = String.new;
[
["GigabitEthernet1/1", "10.5.16.1"],
["GigabitEthernet1/2", "10.5.17.1"],
["GigabitEthernet1/3", "10.5.18.1"]
].each { |tuple|
r << "interface #{tuple[0]}\n"
r << " ip address #{tuple[1]} netmask 255.255.255.0\n"
}
r.chomp
%>
logging 10.5.16.26
</code></pre>
<p>which, when run through an embedded ruby interpreter (either erb or eruby), produces the following output:</p>
<pre><code>hostname sample-router
interface GigabitEthernet1/1
ip address 10.5.16.1 netmask 255.255.255.0
interface GigabitEthernet1/2
ip address 10.5.17.1 netmask 255.255.255.0
interface GigabitEthernet1/3
ip address 10.5.18.1 netmask 255.255.255.0
logging 10.5.16.26
</code></pre>
|
[
{
"answer_id": 74823,
"author": "Daniel Spiewak",
"author_id": 9815,
"author_profile": "https://Stackoverflow.com/users/9815",
"pm_score": 2,
"selected": false,
"text": ".rhtml"
},
{
"answer_id": 81574,
"author": "Jon Wood",
"author_id": 25258,
"author_profile": "https://Stackoverflow.com/users/25258",
"pm_score": 0,
"selected": false,
"text": "device = Device.new\ndevice.add_interface(\"GigabitEthernet1/1\", \"10.5.16.1\")\ndevice.add_interface(\"GigabitEthernet1/2\", \"10.5.17.1\")\n\ntemplate = File.read(\"/path/to/your/template.erb\")\nconfig = ERB.new(template).result(device.binding)\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13157/"
] |
74,790 |
<p>Is it possible to listen for a certain hotkey (e.g:<kbd>Ctrl</kbd><kbd>-</kbd><kbd>I</kbd>) and then perform a specific action? My application is written in C, will only run on Linux, and it doesn't have a GUI. Are there any libraries that help with this kind of task?</p>
<p>EDIT: as an example, amarok has global shortcuts, so for example if you map a combination of keys to an action (let's say <kbd>Ctrl</kbd><kbd>-</kbd><kbd>+</kbd>, <kbd>Ctrl</kbd> and <kbd>+</kbd>) you could execute that action when you press the keys. If I would map <kbd>Ctrl</kbd><kbd>-</kbd><kbd>+</kbd> to the volume increase action, each time I press <kbd>ctrl</kbd><kbd>-</kbd><kbd>+</kbd> the volume should increase by a certain amount.</p>
<p>Thanks</p>
|
[
{
"answer_id": 74989,
"author": "Incident",
"author_id": 11613,
"author_profile": "https://Stackoverflow.com/users/11613",
"pm_score": 0,
"selected": false,
"text": "man 5 terminfo\n man 3 ncurses\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11234/"
] |
74,829 |
<p>What should I type on the Mac OS X terminal to run a script as root?</p>
|
[
{
"answer_id": 74833,
"author": "dF.",
"author_id": 3002,
"author_profile": "https://Stackoverflow.com/users/3002",
"pm_score": 7,
"selected": true,
"text": "sudo $ sudo script-name\n root"
},
{
"answer_id": 75016,
"author": "jackrabbit",
"author_id": 3707,
"author_profile": "https://Stackoverflow.com/users/3707",
"pm_score": 2,
"selected": false,
"text": "admin"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/877/"
] |
74,844 |
<p>I am not new to *nix, however lately I have been spending a lot of time at the prompt. My question is what are the advantages of using KornShell (ksh) or Bash Shell? Where are the pitfalls of using one over the other? </p>
<p>Looking to understand from the perspective of a user, rather than purely scripting.</p>
|
[
{
"answer_id": 74936,
"author": "Hank Gay",
"author_id": 4203,
"author_profile": "https://Stackoverflow.com/users/4203",
"pm_score": 2,
"selected": false,
"text": "sh /bin/sh bash perl"
},
{
"answer_id": 5525644,
"author": "Henk Langeveld",
"author_id": 667820,
"author_profile": "https://Stackoverflow.com/users/667820",
"pm_score": 5,
"selected": false,
"text": "shopt -s lithist lithist b=42 && echo one two three four |\n read a b junk && echo $b\n echo print -n \\c"
},
{
"answer_id": 6985612,
"author": "David W.",
"author_id": 368630,
"author_profile": "https://Stackoverflow.com/users/368630",
"pm_score": 7,
"selected": false,
"text": "print echo r cd old new old new /foo/bar/barfoo/one/bar/bar/foo/bar /foo/bar/barfoo/two/bar/bar/foo/bar cd one two cd ../../../../../two/bar/bar/foo/bar"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13158/"
] |
74,847 |
<p>Typically I use <code>E_ALL</code> to see anything that PHP might say about my code to try and improve it.</p>
<p>I just noticed a error constant <code>E_STRICT</code>, but have never used or heard about it, is this a good setting to use for development? The manual says:</p>
<blockquote>
<p>Run-time notices. Enable to have PHP suggest changes to your code which will ensure the best interoperability and forward compatibility of your code. </p>
</blockquote>
<p>So I'm wondering if I'm using the best <code>error_reporting</code> level with <code>E_ALL</code> or would that along with <code>E_STRICT</code> be the best? Or is there any other combination I've yet to learn?</p>
|
[
{
"answer_id": 74907,
"author": "Daniel Papasian",
"author_id": 7548,
"author_profile": "https://Stackoverflow.com/users/7548",
"pm_score": 3,
"selected": false,
"text": "syslog E_ALL | E_STRICT E_RECOVERABLE_ERROR E_DEPRECATED E_USER_DEPRECATED error_reporting 2^n-1 16777215 1..n E_ALL"
},
{
"answer_id": 74923,
"author": "Jim",
"author_id": 8427,
"author_profile": "https://Stackoverflow.com/users/8427",
"pm_score": 6,
"selected": true,
"text": "E_STRICT E_ALL error_reporting(E_ALL | E_STRICT);\n E_STRICT E_ALL E_ALL error_reporting(-1);\n error_reporting(~0);\n"
},
{
"answer_id": 74963,
"author": "stormlash",
"author_id": 12657,
"author_profile": "https://Stackoverflow.com/users/12657",
"pm_score": 1,
"selected": false,
"text": "E_STRICT E_STRICT E_STRICT E_ALL E_STRICT E_STRICT E_ALL E_ALL E_STRICT"
},
{
"answer_id": 75368,
"author": "Pablo Borowicz",
"author_id": 13275,
"author_profile": "https://Stackoverflow.com/users/13275",
"pm_score": 0,
"selected": false,
"text": "$GLOBALS $_GLOBALS $_GLOBALS"
},
{
"answer_id": 75392,
"author": "Eduardo Marinho",
"author_id": 13211,
"author_profile": "https://Stackoverflow.com/users/13211",
"pm_score": 3,
"selected": false,
"text": "error_reporting = E_ALL | E_STRICT\n"
},
{
"answer_id": 7227429,
"author": "RiaD",
"author_id": 768110,
"author_profile": "https://Stackoverflow.com/users/768110",
"pm_score": 2,
"selected": false,
"text": "error_reporting = -1"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5261/"
] |
74,865 |
<p>I recently was working with a subversion project that checked out code not only from the repository I was working with, but also from a separate repository on a different server.</p>
<p>How can I configure my repository to do this?</p>
<p>I'm using the subversion client version 1.3.2 on Linux, and I also have access to TortoiseSVN version 1.4.8 (built on svn version 1.4.6) in Windows.</p>
|
[
{
"answer_id": 74878,
"author": "Hank Gay",
"author_id": 4203,
"author_profile": "https://Stackoverflow.com/users/4203",
"pm_score": 5,
"selected": true,
"text": "svn checkout svn:externals svn propset svn propedit"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7154/"
] |
74,879 |
<p>I am looking for a tool which will take an XML instance document and output a corresponding XSD schema.</p>
<p>I certainly recognize that the generated XSD schema will be limited when compared to creating a schema by hand (it probably won't handle optional or repeating elements, or data constraints), but it could at least serve as a quick starting point.</p>
|
[
{
"answer_id": 88683,
"author": "Pat Hermens",
"author_id": 1677,
"author_profile": "https://Stackoverflow.com/users/1677",
"pm_score": 4,
"selected": false,
"text": "C:\\Program Files\\Microsoft Visual Studio 8\\VC>xsd\nMicrosoft (R) Xml Schemas/DataTypes support utility\n[Microsoft (R) .NET Framework, Version 2.0.50727.42]\nCopyright (C) Microsoft Corporation. All rights reserved.\n\nxsd.exe -\n Utility to generate schema or class files from given source.\n\nxsd.exe <schema>.xsd /classes|dataset [/e:] [/l:] [/n:] [/o:] [/s] [/uri:]\nxsd.exe <assembly>.dll|.exe [/outputdir:] [/type: [...]]\nxsd.exe <instance>.xml [/outputdir:]\nxsd.exe <schema>.xdr [/outputdir:]\n /o:<your path> /classes /L:VB (or CS) /o:<your path>"
},
{
"answer_id": 8397984,
"author": "edorian",
"author_id": 285578,
"author_profile": "https://Stackoverflow.com/users/285578",
"pm_score": 4,
"selected": false,
"text": "XML schema learner"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/863/"
] |
74,880 |
<p>Conceptually, I would like to accomplish the following but have had trouble understand how to code it properly in C#:</p>
<pre><code>
SomeMethod { // Member of AClass{}
DoSomething;
Start WorkerMethod() from BClass in another thread;
DoSomethingElse;
}
</code></pre>
<p>Then, when WorkerMethod() is complete, run this:</p>
<p><pre><code>
void SomeOtherMethod() // Also member of AClass{}
{ ... }
</pre></code></p>
<p>Can anyone please give an example of that? </p>
|
[
{
"answer_id": 74948,
"author": "Isak Savo",
"author_id": 8521,
"author_profile": "https://Stackoverflow.com/users/8521",
"pm_score": 5,
"selected": true,
"text": "BackgroundWorker worker = new BackgroundWorker();\nworker.DoWork += delegate { myBClass.DoHardWork(); }\nworker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(SomeOtherMethod);\nworker.RunWorkerAsync();\n"
},
{
"answer_id": 75050,
"author": "Randolpho",
"author_id": 12716,
"author_profile": "https://Stackoverflow.com/users/12716",
"pm_score": 0,
"selected": false,
"text": "public class AClass\n{\n public void SomeMethod()\n {\n DoSomething();\n\n ThreadPool.QueueUserWorkItem(delegate(object state)\n {\n BClass.WorkerMethod();\n SomeOtherMethod();\n });\n\n DoSomethingElse();\n }\n\n private void SomeOtherMethod()\n {\n // handle the fact that WorkerMethod has completed. \n // Note that this is called on the Worker Thread, not\n // the main thread.\n }\n}\n"
},
{
"answer_id": 75164,
"author": "Vivek",
"author_id": 7418,
"author_profile": "https://Stackoverflow.com/users/7418",
"pm_score": 1,
"selected": false,
"text": "// Method that does the real work\npublic int SomeMethod(int someInput)\n{\nThread.Sleep(20);\nConsole.WriteLine(”Processed input : {0}”,someInput);\nreturn someInput+1;\n} \n\n\n// Method that will be called after work is complete\npublic void EndSomeOtherMethod(IAsyncResult result)\n{\nSomeMethodDelegate myDelegate = result.AsyncState as SomeMethodDelegate;\n// obtain the result\nint resultVal = myDelegate.EndInvoke(result);\nConsole.WriteLine(”Returned output : {0}”,resultVal);\n}\n\n// Define a delegate\ndelegate int SomeMethodDelegate(int someInput);\nSomeMethodDelegate someMethodDelegate = SomeMethod;\n\n// Call the method that does the real work\n// Give the method name that must be called once the work is completed.\nsomeMethodDelegate.BeginInvoke(10, // Input parameter to SomeMethod()\nEndSomeOtherMethod, // Callback Method\nsomeMethodDelegate); // AsyncState\n"
},
{
"answer_id": 75513,
"author": "ashwnacharya",
"author_id": 1909,
"author_profile": "https://Stackoverflow.com/users/1909",
"pm_score": 2,
"selected": false,
"text": " public delegate void AsyncMethodCaller();\n\n\n public static void WorkerMethod()\n {\n Console.WriteLine(\"I am the first method that is called.\");\n Thread.Sleep(5000);\n Console.WriteLine(\"Exiting from WorkerMethod.\");\n }\n\n public static void SomeOtherMethod(IAsyncResult result)\n {\n Console.WriteLine(\"I am called after the Worker Method completes.\");\n }\n\n\n\n static void Main(string[] args)\n {\n AsyncMethodCaller asyncCaller = new AsyncMethodCaller(WorkerMethod);\n AsyncCallback callBack = new AsyncCallback(SomeOtherMethod);\n IAsyncResult result = asyncCaller.BeginInvoke(callBack, null);\n Console.WriteLine(\"Worker method has been called.\");\n Console.WriteLine(\"Waiting for all invocations to complete.\");\n Console.Read();\n\n }\n}\n"
},
{
"answer_id": 75743,
"author": "Keith",
"author_id": 905,
"author_profile": "https://Stackoverflow.com/users/905",
"pm_score": 3,
"selected": false,
"text": "BackgroundWorker bw = new BackgroundWorker { WorkerReportsProgress = true };\n\nbw.DoWork += (sender, e) => \n {\n //what happens here must not touch the form\n //as it's in a different thread\n };\n\nbw.ProgressChanged += ( sender, e ) =>\n {\n //update progress bars here\n };\n\nbw.RunWorkerCompleted += (sender, e) => \n {\n //now you're back in the UI thread you can update the form\n //remember to dispose of bw now\n };\n\nworker.RunWorkerAsync();\n"
},
{
"answer_id": 77113,
"author": "Romain Verdier",
"author_id": 4687,
"author_profile": "https://Stackoverflow.com/users/4687",
"pm_score": 2,
"selected": false,
"text": "BeginInvoke EndInvoke IAsyncResult"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10505/"
] |
74,883 |
<p>I cannot seem to compile mod_dontdothat on Windows. Has anybody managed to achieve this?</p>
<p>Edit:</p>
<p>I've tried compiling the file according to the readme on the site and I've tried to add extra libs to reduce the link errors. Ive got the following installed:</p>
<ol>
<li>Apache 2.2.9</li>
<li>Visual Studio 2008</li>
<li>ActivePerl</li>
<li>apxs-win32 from ApacheLounge</li>
<li>Subversion libs and headers</li>
</ol>
<p>I run the following command line:</p>
<pre>
C:\Program Files\Apache Software Foundation\Apache2.2\bin>apxs -c -I ..\include\
svn_config.h -L ..\lib -L C:\Progra~1\Micros~1.0\VC\lib -l apr-1.lib -l aprutil-
1.lib -l svn_subr-1.lib -l libapr-1.lib -l libaprutil-1.lib -l libhttpd.lib -l l
ibsvn_subr-1.lib -l mod_dav.lib mod_dontdothat.c
</pre>
<p>Then I get the following errors:</p>
<pre>
cl /nologo /MD /W3 /O2 /D WIN32 /D _WINDOWS /D NDEBUG -I"C:\PROGRA~1\APACHE~
1\Apache2.2\include" /I"..\include\svn_config.h" /c /Fomod_dontdothat.lo mod_d
ontdothat.c
mod_dontdothat.c
link kernel32.lib /nologo /subsystem:windows /dll /machine:I386 /libpath:"C:\PRO
GRA~1\APACHE~1\Apache2.2\lib" /out:mod_dontdothat.so /libpath:"..\lib" /libpat
h:"C:\Progra~1\Micros~1.0\VC\lib" apr-1.lib aprutil-1.lib svn_subr-1.lib libapr
-1.lib libaprutil-1.lib libhttpd.lib libsvn_subr-1.lib mod_dav.lib mod_dontdot
hat.lo
Creating library mod_dontdothat.lib and object mod_dontdothat.exp
mod_dontdothat.lo : error LNK2019: unresolved external symbol _dav_svn_split_uri
@32 referenced in function _is_this_legal
svn_subr-1.lib(io.obj) : error LNK2001: unresolved external symbol __imp__libint
l_dgettext
svn_subr-1.lib(subst.obj) : error LNK2001: unresolved external symbol __imp__lib
intl_dgettext
svn_subr-1.lib(config_auth.obj) : error LNK2001: unresolved external symbol __im
p__libintl_dgettext
svn_subr-1.lib(time.obj) : error LNK2001: unresolved external symbol __imp__libi
ntl_dgettext
svn_subr-1.lib(nls.obj) : error LNK2001: unresolved external symbol __imp__libin
tl_dgettext
svn_subr-1.lib(dso.obj) : error LNK2001: unresolved external symbol __imp__libin
tl_dgettext
svn_subr-1.lib(path.obj) : error LNK2001: unresolved external symbol __imp__libi
ntl_dgettext
svn_subr-1.lib(prompt.obj) : error LNK2001: unresolved external symbol __imp__li
bintl_dgettext
svn_subr-1.lib(error.obj) : error LNK2019: unresolved external symbol __imp__lib
intl_dgettext referenced in function _print_error
svn_subr-1.lib(config.obj) : error LNK2001: unresolved external symbol __imp__li
bintl_dgettext
svn_subr-1.lib(utf.obj) : error LNK2001: unresolved external symbol __imp__libin
tl_dgettext
svn_subr-1.lib(cmdline.obj) : error LNK2001: unresolved external symbol __imp__l
ibintl_dgettext
svn_subr-1.lib(utf.obj) : error LNK2019: unresolved external symbol __imp__libin
tl_sprintf referenced in function _fuzzy_escape
svn_subr-1.lib(path.obj) : error LNK2001: unresolved external symbol __imp__libi
ntl_sprintf
svn_subr-1.lib(cmdline.obj) : error LNK2019: unresolved external symbol __imp__l
ibintl_fprintf referenced in function _svn_cmdline_init
svn_subr-1.lib(config_win.obj) : error LNK2019: unresolved external symbol __imp
__SHGetFolderPathA@20 referenced in function _svn_config__win_config_path
svn_subr-1.lib(config_win.obj) : error LNK2019: unresolved external symbol __imp
__SHGetFolderPathW@20 referenced in function _svn_config__win_config_path
svn_subr-1.lib(config_win.obj) : error LNK2019: unresolved external symbol __imp
__RegCloseKey@4 referenced in function _svn_config__parse_registry
svn_subr-1.lib(config_win.obj) : error LNK2019: unresolved external symbol __imp
__RegEnumKeyExA@32 referenced in function _svn_config__parse_registry
svn_subr-1.lib(config_win.obj) : error LNK2019: unresolved external symbol __imp
__RegOpenKeyExA@20 referenced in function _svn_config__parse_registry
svn_subr-1.lib(config_win.obj) : error LNK2019: unresolved external symbol __imp
__RegQueryValueExA@24 referenced in function _parse_section
svn_subr-1.lib(config_win.obj) : error LNK2019: unresolved external symbol __imp
__RegEnumValueA@32 referenced in function _parse_section
svn_subr-1.lib(win32_xlate.obj) : error LNK2019: unresolved external symbol __im
p__CoUninitialize@0 referenced in function _svn_subr__win32_xlate_open
svn_subr-1.lib(win32_xlate.obj) : error LNK2019: unresolved external symbol __im
p__CoInitializeEx@8 referenced in function _svn_subr__win32_xlate_open
svn_subr-1.lib(win32_xlate.obj) : error LNK2019: unresolved external symbol __im
p__CoCreateInstance@20 referenced in function _get_page_id_from_name
svn_subr-1.lib(nls.obj) : error LNK2019: unresolved external symbol __imp__libin
tl_bindtextdomain referenced in function _svn_nls_init
svn_subr-1.lib(stream.obj) : error LNK2019: unresolved external symbol _inflate
referenced in function _read_handler_gz
svn_subr-1.lib(stream.obj) : error LNK2019: unresolved external symbol _inflateI
nit_ referenced in function _read_handler_gz
svn_subr-1.lib(stream.obj) : error LNK2019: unresolved external symbol _deflate
referenced in function _write_handler_gz
svn_subr-1.lib(stream.obj) : error LNK2019: unresolved external symbol _deflateI
nit_ referenced in function _write_handler_gz
svn_subr-1.lib(stream.obj) : error LNK2019: unresolved external symbol _deflateE
nd referenced in function _close_handler_gz
svn_subr-1.lib(stream.obj) : error LNK2019: unresolved external symbol _inflateE
nd referenced in function _close_handler_gz
mod_dontdothat.so : fatal error LNK1120: 21 unresolved externals
apxs:Error: Command failed with rc=6291456
.
</pre>
<p>I'm not too much of a C guru, so any help in finding these unresolved external symbols will be much appreciated!</p>
|
[
{
"answer_id": 482896,
"author": "agnul",
"author_id": 6069,
"author_profile": "https://Stackoverflow.com/users/6069",
"pm_score": 2,
"selected": false,
"text": "mod_dav_svn.lib _dav_svn_split_uri intl3_svn.lib _libintl shell32.lib advapi32.lib Reg ole32.lib CoInitialize inflate deflate zlib1.lib"
},
{
"answer_id": 499837,
"author": "Eduard Wirch",
"author_id": 17428,
"author_profile": "https://Stackoverflow.com/users/17428",
"pm_score": 4,
"selected": true,
"text": "mod_dav_svn c:\\temp\\svn c:\\temp\\svn-src mod_dontdothat C:\\Temp\\dontdothat mod_dontdothat mod_dav_svn mod_dav_svn mod_dav_svn cd C:\\Temp\\svn-src\\subversion\\mod_dav_svn\napxs -c -I ..\\include -L C:\\Temp\\svn\\lib -l libsvn_delta-1.lib -l libsvn_diff-1.lib -l libsvn_fs-1.lib -l libsvn_fs_base-1.lib -l libsvn_fs_fs-1.lib -l libsvn_fs_util-1.lib -l libsvn_repos-1.lib -l libsvn_subr-1.lib -l libapr-1.lib -l libaprutil-1.lib -l libhttpd.lib -l mod_dav.lib -l xml.lib -n mod_dav_svn mod_dav_svn.c activity.c authz.c deadprops.c liveprops.c lock.c merge.c mirror.c repos.c util.c version.c reports\\dated-rev.c reports\\file-revs.c reports\\get-locations.c reports\\get-location-segments.c reports\\get-locks.c reports\\log.c reports\\mergeinfo.c reports\\replay.c reports\\update.c\n libmod_dav_svn.lib lib kernel32.lib /nologo /subsystem:windows /machine:I386 /libpath:\"C:\\PROGRA~1\\APACHE~1\\Apache2.2\\lib\" /out:libmod_dav_svn.lib /libpath:\"C:\\Temp\\svn\\lib\" libsvn_delta-1.lib libsvn_diff-1.lib libsvn_fs-1.lib libsvn_fs_base-1.lib libsvn_fs_fs-1.lib libsvn_fs_util-1.lib libsvn_repos-1.lib libsvn_subr-1.lib libapr-1.lib libaprutil-1.lib libhttpd.lib mod_dav.lib xml.lib reports\\update.lo reports\\replay.lo reports\\mergeinfo.lo reports\\log.lo reports\\get-locks.lo reports\\get-location-segments.lo reports\\get-locations.lo reports\\file-revs.lo reports\\dated-rev.lo version.lo util.lo repos.lo mirror.lo merge.lo lock.lo liveprops.lo deadprops.lo authz.lo activity.lo mod_dav_svn.lo\n libmod_dav_svn.lib mod_dontdothat mod_dontdothat C:\\Temp\\dontdothat\napxs -c -I C:\\Temp\\svn\\include -L C:\\Temp\\svn\\lib -l libsvn_subr-1.lib -l libapr-1.lib -l libaprutil-1.lib -l libhttpd.lib -l mod_dav.lib -l xml.lib -l libmod_dav_svn.lib mod_dontdothat.c\napxs -i -n dontdothat mod_dontdothat.so\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2822/"
] |
74,886 |
<p>I need to rearrange some content in various directories but it's a bit of a pain. In order to debug the application I'm working on (a ruby app) I need to move my gems into my gem folder one at a time (long story; nutshell: one is broken and I can't figure out which one).</p>
<p>So I need to do something like:</p>
<pre><code>sudo mv backup/gem/foo gem/
sudo mv backup/doc/foo doc/
sudo mv backup/specification/foo.gemspec specification/
</code></pre>
<p>replacing "foo" each time. How can I author a simple shell script to let me do something like: gemMove("foo") and it fill in the blanks for me?</p>
|
[
{
"answer_id": 74920,
"author": "pjz",
"author_id": 8002,
"author_profile": "https://Stackoverflow.com/users/8002",
"pm_score": 4,
"selected": true,
"text": "gemmove #!/bin/bash\n\nif [ \"x$1\" == x ]; then\n echo \"Must have an arg\"\n exit 1\nfi\n\nfor d in gem doc specification ; do \n mv \"backup/$d/$1\" \"$d\"\ndone\n chmod a+x gemmove\n sudo /path/to/gemmove foo"
},
{
"answer_id": 74937,
"author": "sirprize",
"author_id": 12902,
"author_profile": "https://Stackoverflow.com/users/12902",
"pm_score": 1,
"selected": false,
"text": "#!/bin/bash\n# This is move.sh\nmv backup/gem/$1 gem/\nmv backup/doc/$1 doc/\n# ...\n sudo ./move.sh foo\n chmod +x move.sh\n"
},
{
"answer_id": 74995,
"author": "catfood",
"author_id": 12802,
"author_profile": "https://Stackoverflow.com/users/12802",
"pm_score": 1,
"selected": false,
"text": "function gemMove()\n{\nfilename=$1\n mv backup/gem/$filename gem/$filename\n mv backup/doc/$filename doc/$filename\n mv backup/specification/$filename.spec specification\n}\n gemMove(\"foo\")"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10071/"
] |
74,902 |
<p>I installed Mono on my iMac last night and I immidiately had a change of heart! I don't think Mono is ready for prime time. </p>
<p>The Mono website says to run the following script to uninstall:</p>
<pre><code>#!/bin/sh -x
#This script removes Mono from an OS X System. It must be run as root
rm -r /Library/Frameworks/Mono.framework
rm -r /Library/Receipts/MonoFramework-SVN.pkg
cd /usr/bin
for i in `ls -al | grep Mono | awk '{print $9}'`; do
rm ${i}
done
</code></pre>
<p>Has anyone had to uninstall Mono? Was it as straight forward as running the above script or do I have to do more? How messy was it? Any pointers are appreciated.</p>
|
[
{
"answer_id": 768240,
"author": "joev",
"author_id": 3449,
"author_profile": "https://Stackoverflow.com/users/3449",
"pm_score": 2,
"selected": false,
"text": "cd\ncp /Library/Receipts/MonoFramework-2.4_7.macos10.novell.universal.pkg/Contents/Resources/uninstallMono.sh .\nsudo ./uninstallMono.sh\nrm uninstallMono.sh\n"
},
{
"answer_id": 6657711,
"author": "Albireo",
"author_id": 91696,
"author_profile": "https://Stackoverflow.com/users/91696",
"pm_score": 3,
"selected": false,
"text": "#!/bin/sh -x\n\n#This script removes Mono from an OS X System. It must be run as root\n\nrm -r /Library/Frameworks/Mono.framework\n\nrm -r /Library/Receipts/MonoFramework-*\n\nfor dir in /usr/bin /usr/share/man/man1 /usr/share/man/man3 /usr/share/man/man5; do\n (cd ${dir};\n for i in `ls -al | grep /Library/Frameworks/Mono.framework/ | awk '{print $9}'`; do\n rm ${i}\n done);\ndone\n /Library/Receipts"
},
{
"answer_id": 46015929,
"author": "montrealist",
"author_id": 65232,
"author_profile": "https://Stackoverflow.com/users/65232",
"pm_score": 3,
"selected": false,
"text": "sudo rm -rf /Library/Frameworks/Mono.framework\nsudo pkgutil --forget com.xamarin.mono-MDK.pkg\nsudo rm -rf /etc/paths.d/mono-commands\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74902",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/877/"
] |
74,951 |
<p>Flex has built in drag-n-drop for list controls, and allows you to override this. But they don't cover this in examples. The built-in functionality automatically drags the list-item, if you want to override this you find the handlers are being set up on the list itself.
What I specifically want to do, is my TileList shows small thumbnails of items I can drag onto a large Canvas. As I drag an item from the list, the drag proxy should be a different image.</p>
<p><strong>So, I followed the technique suggested and it only works if I explicitly set the width/height on the proxy Image. Why?</strong></p>
|
[
{
"answer_id": 75541,
"author": "Theo",
"author_id": 1109,
"author_profile": "https://Stackoverflow.com/users/1109",
"pm_score": 2,
"selected": false,
"text": "<List>\n <mouseDown>onListMouseDown(event)</mouseDown>\n</Tree>\n private function onMouseDown( event : MouseEvent ) : void {\n var list : List = List(event.currentTarget);\n\n // the data of the clicked row, change the name of the class to your own\n var item : MyDataType = MyDataType(list.selectedItem);\n\n var source : DragSource = new DragSource();\n\n // MyAwsomeDragFormat is the key that you will retrieve the data by in the\n // component that handles the drop\n source.addData(item, \"MyAwsomeDragFormat\");\n\n // this is the component that will be shown as the drag proxy image\n var dragView : UIComponent = new Image();\n\n // set the source of the image to a bigger version here\n dragView.source = getABiggerImage(item);\n\n // get hold of the renderer of the clicked row, to use as the drag initiator\n var rowRenderer : UIComponent = UIComponent(list.indexToItemRenderer(list.selectedIndex));\n\n DragManager.doDrag(\n rowRenderer,\n source,\n event,\n dragView\n );\n}\n dragEnabled if ( event.target is ScrollThumb || event.target is Button ) {\n return;\n}\n"
},
{
"answer_id": 2185111,
"author": "Ola",
"author_id": 264449,
"author_profile": "https://Stackoverflow.com/users/264449",
"pm_score": 1,
"selected": false,
"text": "public class CustomDragList extends List {\n\n [Bindable]\n public var dragProxyImageSource:Object;\n\n override protected function get dragImage():IUIComponent {\n var image:Image = new Image();\n image.width = 50;\n image.height = 50;\n image.source = dragProxyImageSource;\n image.owner = this;\n return image;\n }\n}\n <control:CustomDragList\n allowMultipleSelection=\"true\"\n dragEnabled=\"true\" \n dragProxyImageSource=\"{someImageSource}\"\n dragStart=\"onDragStart(event)\"/>\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13220/"
] |
74,957 |
<p>In PowerShell I'm reading in a text file. I'm then doing a Foreach-Object over the text file and am only interested in the lines that do NOT contain strings that are in <code>$arrayOfStringsNotInterestedIn</code>.</p>
<p>What is the syntax for this?</p>
<pre><code> Get-Content $filename | Foreach-Object {$_}
</code></pre>
|
[
{
"answer_id": 75034,
"author": "Mark Schill",
"author_id": 9482,
"author_profile": "https://Stackoverflow.com/users/9482",
"pm_score": 4,
"selected": false,
"text": " Get-Content $FileName | foreach-object { \n if ($_ -notmatch $arrayofStringsNotInterestedIn) { $) }\n"
},
{
"answer_id": 75091,
"author": "Chris Bilson",
"author_id": 12934,
"author_profile": "https://Stackoverflow.com/users/12934",
"pm_score": 7,
"selected": true,
"text": "Get-Content $FileName | foreach-object { `\n if ($arrayofStringsNotInterestedIn -notcontains $_) { $) }\n Get-Content $FileName | where { $arrayofStringsNotInterestedIn -notcontains $_}\n"
},
{
"answer_id": 143727,
"author": "Bruno Gomes",
"author_id": 8669,
"author_profile": "https://Stackoverflow.com/users/8669",
"pm_score": 2,
"selected": false,
"text": "(Get-Content $FileName) -notmatch [String]::Join('|',$arrayofStringsNotInterestedIn)\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] |
74,960 |
<p>I'm looking at the SOAP output from a web service I'm developing, and I noticed something curious:</p>
<pre><code><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<ns1:CreateEntityTypesResponse xmlns:ns1="http://somedomain.com/wsinterface">
<newKeys>
<value>1234</value>
</newKeys>
<newKeys>
<value>2345</value>
</newKeys>
<newKeys>
<value>3456</value>
</newKeys>
<newKeys xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<newKeys xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<errors>Error1</errors>
<errors>Error2</errors>
</ns1:CreateEntityTypesResponse>
</soapenv:Body>
</soapenv:Envelope>
</code></pre>
<p>I have two newKeys elements that are nil, and both elements insert a namespace reference for xsi. I'd like to include that namespace in the soapenv:Envelope element so that the namespace reference is only sent once.</p>
<p>I am using WSDL2Java to generate the service skeleton, so I don't directly have access to the Axis2 API.</p>
|
[
{
"answer_id": 75128,
"author": "Michael Sharek",
"author_id": 1958,
"author_profile": "https://Stackoverflow.com/users/1958",
"pm_score": 3,
"selected": false,
"text": " // create SOAP envelope with that payload\n org.apache.axiom.soap.SOAPEnvelope env = null;\n env = toEnvelope(\n getFactory(_operationClient.getOptions().getSoapVersionURI()),\n methodName,\n optimizeContent(new javax.xml.namespace.QName\n (\"http://tempuri.org/\",\"methodName\")));\n\n//adding SOAP soap_headers\n_serviceClient.addHeadersToEnvelope(env);\n OMNamespace xsi = getFactory(_operationClient.getOptions().getSoapVersionURI()).\n createOMNamespace(\"http://www.w3.org/2001/XMLSchema-instance\", \"xsi\");\n\nenv.declareNamespace(xsi);\n SOAPFactory fac = OMAbstractFactory.getSOAP11Factory(); \nSOAPEnvelope envelope = fac.getDefaultEnvelope();\nOMNamespace xsi = fac.createOMNamespace(\"http://www.w3.org/2001/XMLSchema-instance\", \"xsi\");\n\nenvelope.declareNamespace(xsi);\nOMNamespace methodNs = fac.createOMNamespace(\"http://somedomain.com/wsinterface\", \"ns1\");\n\nOMElement method = fac.createOMElement(\"CreateEntityTypesResponse\", methodNs);\n\n//add the newkeys and errors as OMElements here...\n"
},
{
"answer_id": 11162724,
"author": "dodoconr",
"author_id": 726202,
"author_profile": "https://Stackoverflow.com/users/726202",
"pm_score": 1,
"selected": false,
"text": "public static final QName MY_QNAME = new QName(\"http://www.hello.com/Service/\",\n \"tagname\",\n \"prefix\");\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13224/"
] |
74,986 |
<p>I'm developing a .NET 3.5 XBAP application that runs perfectly fine in FF3 and IE6/7 etc. I'm just wondering if its possible to get these to run under other browsers, specifically (as its in the limelight at the moment) Google Chrome.</p>
|
[
{
"answer_id": 7306745,
"author": "Noora",
"author_id": 928674,
"author_profile": "https://Stackoverflow.com/users/928674",
"pm_score": 2,
"selected": false,
"text": "aspnet_regiis.exe -iru C:\\Program Files\\Mozilla Firefox C:\\Users\\[Username]\\AppData\\Local\\Google\\Chrome\\Application C:\\Program Files (x86)\\Mozilla Firefox\\plugins"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5777/"
] |
74,993 |
<p>When running any kind of server under load there are several resources that one would like to monitor to make sure that the server is healthy. This is specifically true when testing the system under load.</p>
<p>Some examples for this would be CPU utilization, memory usage, and perhaps disk space.
What other resource should I be monitoring, and what tools are available to do so?</p>
|
[
{
"answer_id": 75020,
"author": "GEOCHET",
"author_id": 5640,
"author_profile": "https://Stackoverflow.com/users/5640",
"pm_score": -1,
"selected": false,
"text": "top tail -f /var/log/auth.log"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/74993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9435/"
] |
75,001 |
<p>As popular as Ruby and Rails are, it seems like this problem would already be solved. JRuby and mod_rails are all fine and dandy, but why isn't there an Apache mod for just straight Ruby?</p>
|
[
{
"answer_id": 75217,
"author": "mislav",
"author_id": 11687,
"author_profile": "https://Stackoverflow.com/users/11687",
"pm_score": 5,
"selected": false,
"text": "call"
},
{
"answer_id": 75628,
"author": "Nate",
"author_id": 12779,
"author_profile": "https://Stackoverflow.com/users/12779",
"pm_score": 3,
"selected": false,
"text": "class HelloWorld\n def call(env)\n [200, {\"Content-Type\" => \"text/plain\"}, [\"Hello world!\"]]\n end\nend\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/75001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6726/"
] |
75,011 |
<p>In a VB6 application, I have a <code>Dictionary</code> whose keys are <code>String</code>s and values are instances of a custom class. If I call <code>RemoveAll()</code> on the <code>Dictionary</code>, will it first free the custom objects? Or do I explicitly need to do this myself?</p>
<pre><code>Dim d as Scripting.Dictionary
d("a") = New clsCustom
d("b") = New clsCustom
' Are these two lines necessary?
Set d("a") = Nothing
Set d("b") = Nothing
d.RemoveAll
</code></pre>
|
[
{
"answer_id": 75066,
"author": "Neil C. Obremski",
"author_id": 9642,
"author_profile": "https://Stackoverflow.com/users/9642",
"pm_score": 3,
"selected": true,
"text": "Dictionary RemoveAll() Nothing RemoveAll()"
},
{
"answer_id": 75073,
"author": "Chris Smith",
"author_id": 9073,
"author_profile": "https://Stackoverflow.com/users/9073",
"pm_score": 2,
"selected": false,
"text": "RemoveAll Dictionary Dictionary Dictionary"
},
{
"answer_id": 75107,
"author": "palehorse",
"author_id": 312,
"author_profile": "https://Stackoverflow.com/users/312",
"pm_score": 0,
"selected": false,
"text": "d(\"a\") = New clsCustom\nd(\"b\") = New clsCustom code.\nsObj = d(\"b\")\n\nd.RemoveAll()\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/75011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/863/"
] |
75,014 |
<p>In a multi-threaded application I'm working on, we occasionally see <code>ConcurrentModificationExceptions</code> on our Lists (which are mostly <code>ArrayList</code>, sometimes Vectors). But there are other times when I think concurrent modifications are happening because iterating through the collection appears to be missing items, but no exceptions are thrown. I know that the docs for <code>ConcurrentModificationException</code> says you can't rely on it, but how would I go about making sure I'm not concurrently modifying a List? And is wrapping every access to the collection in a synchronized block the only way to prevent it?</p>
<p><strong>Update:</strong> Yes, I know about <code>Collections.synchronizedCollection</code>, but it doesn't guard against somebody modifying the collection while you're iterating through it. I think at least some of my problem is happening when somebody adds something to a collection while I'm iterating through it.</p>
<p><strong>Second Update</strong> If somebody wants to combine the mention of the synchronizedCollection and cloning like Jason did with a mention of the java.util.concurrent and the apache collections frameworks like jacekfoo and Javamann did, I can accept an answer.</p>
|
[
{
"answer_id": 75043,
"author": "Hank Gay",
"author_id": 4203,
"author_profile": "https://Stackoverflow.com/users/4203",
"pm_score": 1,
"selected": false,
"text": "List"
},
{
"answer_id": 75048,
"author": "Jason Cohen",
"author_id": 4926,
"author_profile": "https://Stackoverflow.com/users/4926",
"pm_score": 2,
"selected": false,
"text": "List<String> safeList = Collections.synchronizedList( originalList );\n for ( String el : safeList.clone() )\n{ ... }\n"
},
{
"answer_id": 75068,
"author": "Mat Mannion",
"author_id": 6282,
"author_profile": "https://Stackoverflow.com/users/6282",
"pm_score": 2,
"selected": false,
"text": "List<Blah> list = new ArrayList<Blah>();\nfor (Blah blah : list) {\n list.remove(blah); // will throw the exception\n}\n"
},
{
"answer_id": 75205,
"author": "jb.",
"author_id": 7918,
"author_profile": "https://Stackoverflow.com/users/7918",
"pm_score": 1,
"selected": false,
"text": "transient volatile int modCount;\n"
},
{
"answer_id": 76998,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": -1,
"selected": false,
"text": "List<Blah> list = fillMyList();\nList<Blah> temp = new ArrayList<Blah>();\nfor (Blah blah : list) {\n //list.remove(blah); would throw the exception\n temp.add(blah);\n}\nlist.removeAll(temp);\n"
},
{
"answer_id": 82025,
"author": "Bill Michell",
"author_id": 7938,
"author_profile": "https://Stackoverflow.com/users/7938",
"pm_score": 3,
"selected": true,
"text": "java.util.concurrent"
},
{
"answer_id": 796493,
"author": "Sean Turner",
"author_id": 96894,
"author_profile": "https://Stackoverflow.com/users/96894",
"pm_score": 1,
"selected": false,
"text": "List<String> safeList = Collections.synchronizedList( originalList );\n\npublic void doSomething() {\n synchronized(safeList){\n for(String s : safeList){\n System.out.println(s);\n\n }\n }\n\n}\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/75014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3333/"
] |
75,052 |
<p>I have a flash player that has a set of songs loaded via an xml file.</p>
<p>The files dont start getting stream until you pick one.</p>
<p>If I quickly cycle through each of the 8 files, then flash starts trying to download each of the 8 files at the same time.</p>
<p>I'm wondering if there is a way to clear the file that is being downloaded. So that bandwidth is not eaten up if someone decides to click on lots of track names.</p>
<p>Something like mySound.clear would be great, or mySound.stopStreaming..</p>
<p>Has anyone had this problem before?</p>
<p>Regards,</p>
<p>Chris</p>
|
[
{
"answer_id": 259891,
"author": "HanClinto",
"author_id": 26933,
"author_profile": "https://Stackoverflow.com/users/26933",
"pm_score": 2,
"selected": true,
"text": "package {\n import flash.display.Sprite;\n import flash.net.URLRequest;\n import flash.media.Sound; \n import flash.text.TextField;\n import flash.text.TextFieldAutoSize;\n import flash.events.MouseEvent;\n import flash.errors.IOError;\n import flash.events.IOErrorEvent;\n\n public class Sound_closeExample extends Sprite {\n private var snd:Sound = new Sound();\n private var button:TextField = new TextField();\n private var req:URLRequest = new URLRequest(\"http://av.adobe.com/podcast/csbu_dev_podcast_epi_2.mp3\");\n\n public function Sound_closeExample() {\n button.x = 10;\n button.y = 10;\n button.text = \"START\";\n button.border = true;\n button.background = true;\n button.selectable = false;\n button.autoSize = TextFieldAutoSize.LEFT;\n\n button.addEventListener(MouseEvent.CLICK, clickHandler);\n\n this.addChild(button);\n }\n\n private function clickHandler(e:MouseEvent):void {\n\n if(button.text == \"START\") {\n\n snd.load(req);\n snd.play(); \n\n snd.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);\n\n button.text = \"STOP\";\n }\n else if(button.text == \"STOP\") {\n\n try {\n snd.close();\n button.text = \"Wait for loaded stream to finish.\";\n }\n catch (error:IOError) {\n button.text = \"Couldn't close stream \" + error.message; \n }\n }\n }\n\n private function errorHandler(event:IOErrorEvent):void {\n button.text = \"Couldn't load the file \" + event.text;\n }\n }\n}\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/75052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6822/"
] |
75,057 |
<p>What is the best way of ensuring that a user supplied password is a strong password in a registration or change password form?</p>
<p>One idea I had (in python)</p>
<pre><code>def validate_password(passwd):
conditions_met = 0
conditions_total = 3
if len(passwd) >= 6:
if passwd.lower() != passwd: conditions_met += 1
if len([x for x in passwd if x.isdigit()]) > 0: conditions_met += 1
if len([x for x in passwd if not x.isalnum()]) > 0: conditions_met += 1
result = False
print conditions_met
if conditions_met >= 2: result = True
return result
</code></pre>
|
[
{
"answer_id": 75498,
"author": "user9116",
"author_id": 9116,
"author_profile": "https://Stackoverflow.com/users/9116",
"pm_score": 3,
"selected": false,
"text": "abstract class Rule {\n\n float weight;\n\n float calculateScore( string password );\n\n}\n float getPasswordStrength( string password ) { \n\n float totalWeight = 0.0f;\n float totalScore = 0.0f;\n\n foreach ( rule in rules ) {\n\n totalWeight += weight;\n totalScore += rule.calculateScore( password ) * rule.weight;\n\n }\n\n return (totalScore / totalWeight) / rules.count;\n\n}\n float calculateScore( string password ) {\n\n float score = 0.0f;\n\n // NUMBER_CLASS is a constant char array { '0', '1', '2', ... }\n if ( password.contains( NUMBER_CLASS ) )\n score += 1.0f;\n\n if ( password.contains( UPPERCASE_CLASS ) )\n score += 1.0f;\n\n if ( password.contains( LOWERCASE_CLASS ) )\n score += 1.0f;\n\n // Sub rule as private method\n if ( containsPunctuation( password ) )\n score += 1.0f;\n\n return score / 4.0f;\n\n}\n"
},
{
"answer_id": 1872514,
"author": "SapphireSun",
"author_id": 210920,
"author_profile": "https://Stackoverflow.com/users/210920",
"pm_score": 0,
"selected": false,
"text": "import re\n\nclass SecurityException(Exception):\n pass\n\nclass Rule:\n \"\"\"Creates a rule to evaluate against a string.\n Rules can be regex patterns or a boolean returning function.\n Whether a rule is inclusive or exclusive is decided by the sign\n of the weight. Positive weights are inclusive, negative weights are\n exclusive. \n\n\n Call score() to return either 0 or the weight if the rule \n is fufilled. \n\n Raises a SecurityException if a required rule is violated.\n \"\"\"\n\n def __init__(self,rule,weight=1,required=False,name=u\"The Unnamed Rule\"):\n try:\n getattr(rule,\"__call__\")\n except AttributeError:\n self.rule = re.compile(rule) # If a regex, compile\n else:\n self.rule = rule # Otherwise it's a function and it should be scored using it\n\n if weight == 0:\n return ValueError(u\"Weights can not be 0\")\n\n self.weight = weight\n self.required = required\n self.name = name\n\n def exclusive(self):\n return self.weight < 0\n def inclusive(self):\n return self.weight >= 0\n exclusive = property(exclusive)\n inclusive = property(inclusive)\n\n def _score_regex(self,password):\n match = self.rule.search(password)\n if match is None:\n if self.exclusive: # didn't match an exclusive rule\n return self.weight\n elif self.inclusive and self.required: # didn't match on a required inclusive rule\n raise SecurityException(u\"Violation of Rule: %s by input \\\"%s\\\"\" % (self.name.title(), password))\n elif self.inclusive and not self.required:\n return 0\n else:\n if self.inclusive:\n return self.weight\n elif self.exclusive and self.required:\n raise SecurityException(u\"Violation of Rule: %s by input \\\"%s\\\"\" % (self.name,password))\n elif self.exclusive and not self.required:\n return 0\n\n return 0\n\n def score(self,password):\n try:\n getattr(self.rule,\"__call__\")\n except AttributeError:\n return self._score_regex(password)\n else:\n return self.rule(password) * self.weight\n\n def __unicode__(self):\n return u\"%s (%i)\" % (self.name.title(), self.weight)\n\n def __str__(self):\n return self.__unicode__()\n rules = [ Rule(\"^foobar\",weight=20,required=True,name=u\"The Fubared Rule\"), ]\ntry:\n score = 0\n for rule in rules:\n score += rule.score()\nexcept SecurityException e:\n print e \nelse:\n print score\n"
},
{
"answer_id": 4191130,
"author": "Sean Reifschneider",
"author_id": 267126,
"author_profile": "https://Stackoverflow.com/users/267126",
"pm_score": 2,
"selected": false,
"text": ">>> FascistCheck('jafo1234', 'jafo')\n'it is based on your username'\n>>> FascistCheck('myofaj123', 'jafo')\n'it is based on your username'\n>>> FascistCheck('jxayfoxo', 'jafo')\n'it is too similar to your username'\n>>> FascistCheck('cretse')\n'it is based on a dictionary word'\n"
},
{
"answer_id": 4298717,
"author": "siznax",
"author_id": 59037,
"author_profile": "https://Stackoverflow.com/users/59037",
"pm_score": 2,
"selected": false,
"text": "import re\nimport string\nmax_score = 6\ndef score(username,passwd):\n if passwd == username:\n return -1\n if username in passwd:\n return 0\n score = 0\n if len(passwd) > 7:\n score+=1\n if len(passwd) > 11:\n score+=1\n if re.search('\\d+',passwd):\n score+=1\n if re.search('[a-z]',passwd) and re.search('[A-Z]',passwd):\n score+=1\n if len([x for x in passwd if x in string.punctuation]) > 0:\n score+=1\n if len([x for x in passwd if x not in string.printable]) > 0:\n score+=1\n return score\n import pwscore\n score = pwscore(username,passwd)\n if score < 3:\n return \"weak password (score=\" \n + str(score) + \"/\"\n + str(pwscore.max_score)\n + \"), try again.\"\n"
},
{
"answer_id": 7285380,
"author": "varun",
"author_id": 95967,
"author_profile": "https://Stackoverflow.com/users/95967",
"pm_score": 1,
"selected": false,
"text": " var getStrength = function (passwd) {\n intScore = 0;\n intScore = (intScore + passwd.length);\n if (passwd.match(/[a-z]/)) {\n intScore = (intScore + 1);\n }\n if (passwd.match(/[A-Z]/)) {\n intScore = (intScore + 5);\n }\n if (passwd.match(/\\d+/)) {\n intScore = (intScore + 5);\n }\n if (passwd.match(/(\\d.*\\d)/)) {\n intScore = (intScore + 5);\n }\n if (passwd.match(/[!,@#$%^&*?_~]/)) {\n intScore = (intScore + 5);\n }\n if (passwd.match(/([!,@#$%^&*?_~].*[!,@#$%^&*?_~])/)) {\n intScore = (intScore + 5);\n }\n if (passwd.match(/[a-z]/) && passwd.match(/[A-Z]/)) {\n intScore = (intScore + 2);\n }\n if (passwd.match(/\\d/) && passwd.match(/\\D/)) {\n intScore = (intScore + 2);\n }\n if (passwd.match(/[a-z]/) && passwd.match(/[A-Z]/) && passwd.match(/\\d/) && passwd.match(/[!,@#$%^&*?_~]/)) {\n intScore = (intScore + 2);\n }\n return intScore;\n} \n"
},
{
"answer_id": 50489987,
"author": "Johan",
"author_id": 650492,
"author_profile": "https://Stackoverflow.com/users/650492",
"pm_score": 4,
"selected": true,
"text": "1 ! Additions (better passwords)\n-----------------------------\n- Number of Characters Flat +(n*4) \n- Uppercase Letters Cond/Incr +((len-n)*2) \n- Lowercase Letters Cond/Incr +((len-n)*2) \n- Numbers Cond +(n*4) \n- Symbols Flat +(n*6)\n- Middle Numbers or Symbols Flat +(n*2) \n- Shannon Entropy Complex *EntropyScore\n\nDeductions (worse passwords)\n----------------------------- \n- Letters Only Flat -n \n- Numbers Only Flat -(n*16) \n- Repeat Chars (Case Insensitive) Complex - \n- Consecutive Uppercase Letters Flat -(n*2) \n- Consecutive Lowercase Letters Flat -(n*2) \n- Consecutive Numbers Flat -(n*2) \n- Sequential Letters (3+) Flat -(n*3) \n- Sequential Numbers (3+) Flat -(n*3) \n- Sequential Symbols (3+) Flat -(n*3)\n- Repeated words Complex - \n- Only 1st char is uppercase Flat -n\n- Last (non symbol) char is number Flat -n\n- Only last char is symbol Flat -n\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/75057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13099/"
] |
75,076 |
<p>I would like to be able to obtain all the parameter values from the stack frame in .NET. A bit like how you're able to see the values in the call stack when in the Visual Studio debugger. My approach has concentrated on using the <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.stackframe%28v=vs.71%29.aspx" rel="noreferrer">StackFrame class</a> and then to reflect over a <a href="http://msdn.microsoft.com/en-us/library/system.reflection.parameterinfo%28v=vs.71%29.aspx" rel="noreferrer">ParameterInfo</a> array. I've had success with reflection and properties, but this is proving a bit trickier.</p>
<p>Is there an approach for achieving this?</p>
<p>The code so far looks like this:</p>
<pre><code>class Program
{
static void Main(string[] args)
{
A a = new A();
a.Go(1);
}
}
public class A
{
internal void Go(int x)
{
B b = new B();
b.Go(4);
}
}
public class B
{
internal void Go(int y)
{
Console.WriteLine(GetStackTrace());
}
public static string GetStackTrace()
{
StringBuilder sb = new StringBuilder();
StackTrace st = new StackTrace(true);
StackFrame[] frames = st.GetFrames();
foreach (StackFrame frame in frames)
{
MethodBase method = frame.GetMethod();
sb.AppendFormat("{0} - {1}",method.DeclaringType, method.Name);
ParameterInfo[] paramaters = method.GetParameters();
foreach (ParameterInfo paramater in paramaters)
{
sb.AppendFormat("{0}: {1}", paramater.Name, paramater.ToString());
}
sb.AppendLine();
}
return sb.ToString();
}
}
</code></pre>
<h2>The output looks like this:</h2>
<pre><code>SfApp.B - GetStackTrace
SfApp.B - Go
y: Int32 y
SfApp.A - Go
x: Int32 x
SfApp.Program - Main
args: System.String[] args
</code></pre>
<h2>I'd like it to look more like this:</h2>
<pre><code>SfApp.B - GetStackTrace
SfApp.B - Go
y: 4
SfApp.A - Go
x: 1
SfApp.Program - Main
</code></pre>
<hr/>
<p>Just for a bit of context, my plan was to try and use this when I throw my own exceptions. I'll look at your suggestions in more detail and see if I can see it fitting.</p>
|
[
{
"answer_id": 70553027,
"author": "Marco Luzzara",
"author_id": 5587393,
"author_profile": "https://Stackoverflow.com/users/5587393",
"pm_score": 1,
"selected": false,
"text": "StackTrace DebugLogger dotnet add package DebugLogger --version 1.0.0\n DebugLogger"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/75076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2422/"
] |
75,105 |
<p>I need to store phone numbers in a table. Please suggest which datatype should I use?
<strong>Wait. Please read on before you hit reply..</strong></p>
<p>This field needs to be indexed heavily as Sales Reps can use this field for searching (including wild character search).</p>
<p>As of now, we are expecting phone numbers to come in a number of formats (from an XML file). Do I have to write a parser to convert to a uniform format? There could be millions of data (with duplicates) and I dont want to tie up the server resources (in activities like preprocessing too much) every time some source data comes through..</p>
<p>Any suggestions are welcome..</p>
<p>Update: <strong>I have no control over source data. Just that the structure of xml file is standard. Would like to keep the xml parsing to a minimum.
Once it is in database, retrieval should be quick. One crazy suggestion going on around here is that it should even work with Ajax AutoComplete feature (so Sales Reps can see the matching ones immediately). OMG!!</strong></p>
|
[
{
"answer_id": 75125,
"author": "user13270",
"author_id": 13270,
"author_profile": "https://Stackoverflow.com/users/13270",
"pm_score": 1,
"selected": false,
"text": "varchar"
},
{
"answer_id": 42965499,
"author": "Mr. Tripodi",
"author_id": 4220094,
"author_profile": "https://Stackoverflow.com/users/4220094",
"pm_score": 1,
"selected": false,
"text": ".DefaultCellStyle.Format = \"(###)###-####\" // Will not work on a string\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/75105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13205/"
] |
75,123 |
<p>I have a DataSet which I get a DataTable from that I am being passed back from a function call. It has 15-20 columns, however I only want 10 columns of the data.</p>
<p>Is there a way to remove those columns that I don't want, copy the DataTable to another that has only the columns defined that I want or is it just better to iterate the collection and just use the columns I need.</p>
<p>I need to write the values out to a fixed length data file.</p>
|
[
{
"answer_id": 75178,
"author": "Tom Ritter",
"author_id": 8435,
"author_profile": "https://Stackoverflow.com/users/8435",
"pm_score": 9,
"selected": true,
"text": "DataTable t;\nt.Columns.Remove(\"columnName\");\nt.Columns.RemoveAt(columnIndex);\n"
},
{
"answer_id": 75558,
"author": "Timothy Carter",
"author_id": 4660,
"author_profile": "https://Stackoverflow.com/users/4660",
"pm_score": 5,
"selected": false,
"text": "DataTable dt;\nint desiredSize = 10;\n\nwhile (dt.Columns.Count > desiredSize)\n{\n dt.Columns.RemoveAt(desiredSize);\n}\n"
},
{
"answer_id": 58115639,
"author": "SU7",
"author_id": 8043435,
"author_profile": "https://Stackoverflow.com/users/8043435",
"pm_score": 3,
"selected": false,
"text": "DataTable string[] ColumnsToBeDeleted = { \"col1\", \"col2\", \"col3\", \"col4\" };\n\nforeach (string ColName in ColumnsToBeDeleted)\n{\n if (dt.Columns.Contains(ColName))\n dt.Columns.Remove(ColName);\n}\n"
},
{
"answer_id": 69431049,
"author": "Hannington Mambo",
"author_id": 1909689,
"author_profile": "https://Stackoverflow.com/users/1909689",
"pm_score": 0,
"selected": false,
"text": "Dim Subjects As String = \"Math, English\"\nDim SubjectData As DataTable = Table.AsDataView.ToTable(True, Subjects.Split(\",\"))\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/75123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3208/"
] |
75,127 |
<p>I have a bulletin board (punBB based) that I was running out of the root directory for a couple of years. I foolishly decided to do a little gardening and in the process moved the punbb code into it's own subdirectory. The code works great; as long as you point the browser at the new subdirectory. The issue is that the users expect to see it at the root...</p>
<p>I tried an index file in the root that had the following:</p>
<pre><code><?php chdir('punbb');
include('index.php');
</code></pre>
<p>But that didn't seem to do the trick. So, I tried using the "damn cool voodoo" of mod_rewrite in .htaccess but I can't seem to figure out the right combination of rules to make it work.</p>
<p>Here is what I would like to make happen:</p>
<p>User enters: </p>
<pre><code> http://guardthe.net
</code></pre>
<p>Browser displays: </p>
<pre><code> http://guardthe.net/punbb/
</code></pre>
<p>or</p>
<pre><code> http://punbb.guardthe.net/
</code></pre>
<p>Is this possible, or should I just move the code base back into the root?</p>
|
[
{
"answer_id": 75144,
"author": "user13270",
"author_id": 13270,
"author_profile": "https://Stackoverflow.com/users/13270",
"pm_score": 1,
"selected": false,
"text": "<?php\nHeader( \"HTTP/1.1 301 Moved Permanently\" );\nHeader( \"Location: http://guardthe.net/punbb/\" );\n?>\n"
},
{
"answer_id": 75147,
"author": "Jan Krüger",
"author_id": 12471,
"author_profile": "https://Stackoverflow.com/users/12471",
"pm_score": 0,
"selected": false,
"text": "RewriteEngine on\nRewriteRule ^$ http://guardthe.net/punbb/ [L,R=301]\n"
},
{
"answer_id": 75185,
"author": "toluju",
"author_id": 12457,
"author_profile": "https://Stackoverflow.com/users/12457",
"pm_score": 0,
"selected": false,
"text": "<?php \nheader( 'Location: http://guardthe.net/punbb/' ); \n?>\n"
},
{
"answer_id": 75214,
"author": "Mr Shark",
"author_id": 6093,
"author_profile": "https://Stackoverflow.com/users/6093",
"pm_score": 2,
"selected": false,
"text": " RewriteEngine On\n RewriteRule ^/?$ /punbb/ [R=301,L]\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/75127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
75,134 |
<p>How do I have two effects in jQuery run in <code>sequence</code>, not simultaneously? Take this piece of code for example:</p>
<pre><code>$("#show-projects").click(function() {
$(".page:visible").fadeOut("normal");
$("#projects").fadeIn("normal");
});
</code></pre>
<p>The <code>fadeOut</code> and the <code>fadeIn</code> run simultaneously, how do I make them run one after the other?</p>
|
[
{
"answer_id": 75259,
"author": "Jim",
"author_id": 8427,
"author_profile": "https://Stackoverflow.com/users/8427",
"pm_score": 6,
"selected": true,
"text": "$(\"#show-projects\").click(function() {\n $(\".page:visible\").fadeOut(\"normal\", function() {\n $(\"#projects\").fadeIn(\"normal\");\n });\n});\n"
},
{
"answer_id": 23672352,
"author": "niall.campbell",
"author_id": 323722,
"author_profile": "https://Stackoverflow.com/users/323722",
"pm_score": 0,
"selected": false,
"text": "//example of adding sequential effects through\n//event handlers and a jquery event trigger\njQuery( document ).unbind( \"bk_prompt_collapse.slide_up\" );\njQuery( document ).bind( \"bk_prompt_collapse.slide_up\" , function( e, j_obj ) {\n jQuery(j_obj).queue(function() {\n //running our timed effect\n jQuery(this).find('div').slideUp(400);\n //adding a fill delay to the parent\n jQuery(this).delay(400).dequeue();\n });\n}); \n//the last action removes the content from the dom\n//if its in the queue then it will fire sequentially\njQuery( document ).unbind( \"bk_prompt_collapse.last_action\" );\njQuery( document ).bind( \"bk_prompt_collapse.last_action\" , function( e, j_obj ) {\n jQuery(j_obj).queue(function() {\n //Hot dog!!\n jQuery(this).remove().dequeue();\n });\n});\njQuery(\"tr.bk_removing_cart_row\").trigger( \n \"bk_prompt_collapse\" , \n jQuery(\"tr.bk_removing_cart_row\") \n);\n"
},
{
"answer_id": 26987154,
"author": "brilliantairic",
"author_id": 586204,
"author_profile": "https://Stackoverflow.com/users/586204",
"pm_score": 1,
"selected": false,
"text": "$( \"#foo\" ).fadeOut( 300 ).delay( 800 ).fadeIn( 400 );\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/75134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6967/"
] |
75,139 |
<p>Google custom search code is provided as a form tag. However, Asp.net only allows a single form tag on a page. What is the best way to implement their code so you can include it on an aspx page (say as part of a Masterpage or navigation element). </p>
|
[
{
"answer_id": 75234,
"author": "Chris Van Opstal",
"author_id": 7264,
"author_profile": "https://Stackoverflow.com/users/7264",
"pm_score": 3,
"selected": false,
"text": "<body>\n<form action=\"http://www.google.com/cse\" id=\"cse-search-box\"> ... </form>\n<form runat=\"server\" id=\"aspNetform\"> ... </form>\n<body>\n"
},
{
"answer_id": 75380,
"author": "Timothy Lee Russell",
"author_id": 12919,
"author_profile": "https://Stackoverflow.com/users/12919",
"pm_score": 0,
"selected": false,
"text": "<input name=\"Query\" type=\"text\" class=\"searchField\" id=\"Query\" value=\"Search\" size=\"15\" onfocus=\"if(this.value == 'Search') { this.value = ''; }\" onblur=\"if(this.value == '') { this.value = 'Search'; }\" onkeydown=\"var event = event || window.event; var key = event.which || event.keyCode; if(key==13) window.open('http://www.google.com/search?q=' + getElementById('Query').value ); \" /><input name=\"\" type=\"button\" class=\"searchButton\" value=\"go\" onclick=\"window.open('http://www.google.com/search?q=' + getElementById('Query').value );\" />\n"
}
] |
2008/09/16
|
[
"https://Stackoverflow.com/questions/75139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.