qid
int64 4
22.2M
| question
stringlengths 18
48.3k
| answers
list | date
stringlengths 10
10
| metadata
list |
|---|---|---|---|---|
79,935
|
<p>Is there an equivalent to Java's Robot class (java.awt.Robot) for Perl?</p>
|
[
{
"answer_id": 87112,
"author": "Bob_Gneu",
"author_id": 16703,
"author_profile": "https://Stackoverflow.com/users/16703",
"pm_score": 3,
"selected": false,
"text": "use WWW::Mechanize;\n\nmy $Agent = WWW::Mechanize->new(cookie_jar => {});\n\n$Agent->get(\"http://www.google.com/search?q=stack+overflow+mechanize\");\nprint \"Found Mechanize\" $Agent->content =~ /WWW::Mechanize/;\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/79935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14948/"
] |
79,939
|
<p>I have the following (pretty standard) table structure:</p>
<pre><code>Post <-> PostTag <-> Tag
</code></pre>
<p>Suppose I have the following records:</p>
<pre><code>PostID Title
1, 'Foo'
2, 'Bar'
3, 'Baz'
TagID Name
1, 'Foo'
2, 'Bar'
PostID TagID
1 1
1 2
2 2
</code></pre>
<p>In other words, the first post has two tags, the second has one and the third one doesn't have any.</p>
<p><strong>I'd like to load all posts and it's tags in one query</strong> but haven't been able to find the right combination of operators. I've been able to load either <em>posts with tags only</em> or <em>repeated posts when more than one tag</em>.</p>
<p>Given the database above, <strong>I'd like to receive three posts and their tags (if any) in a collection property of the Post objects</strong>. Is it possible at all?</p>
<p>Thanks</p>
|
[
{
"answer_id": 79979,
"author": "sirrocco",
"author_id": 5246,
"author_profile": "https://Stackoverflow.com/users/5246",
"pm_score": 0,
"selected": false,
"text": "DataLoadOptions options = new DataLoadOptions(); \noptions.LoadWith<Post>(p => p.PostTag);\noptions.LoadWith<PostTag>(pt => pt.Tag); \n"
},
{
"answer_id": 80038,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "var options = new DataLoadOptions();\noptions.LoadWith<Post>(p => p.PostTags);\noptions.LoadWith<PostTag>(pt => pt.Tag);\nusing (var db = new BlogDataContext())\n{\n db.LoadOptions = options;\n return (from p in db.Posts\n where p.Status != PostStatus.Closed\n orderby p.PublishDateGmt descending\n select p);\n}\n"
},
{
"answer_id": 80629,
"author": "sirrocco",
"author_id": 5246,
"author_profile": "https://Stackoverflow.com/users/5246",
"pm_score": 1,
"selected": false,
"text": "DataLoadOptions o = new DataLoadOptions ( );\no.LoadWith<Listing> ( l => l.ListingStaffs );\no.LoadWith<ListingStaff> ( ls => ls.MerchantStaff );\nctx.LoadOptions = o;\n\nIQueryable<Listing> listings = (from a in ctx.Listings\n where a.IsActive == false \n select a);\nList<Listing> list = listings.ToList ( );\n"
},
{
"answer_id": 83396,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "public IList<Post> GetPosts(int page, int records)\n{\n var options = new DataLoadOptions();\n options.LoadWith<Post>(p => p.PostTags);\n options.LoadWith<PostTag>(pt => pt.Tag);\n using (var db = new BlogDataContext())\n {\n db.LoadOptions = options;\n return (from p in db.Posts\n where p.Status != PostStatus.Closed\n orderby p.PublishDateGmt descending\n select p)\n .Skip(page * records)\n //.Take(records)\n .ToList();\n }\n}\n"
},
{
"answer_id": 83771,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "public IList<Post> GetPosts(int page, int record)\n{\n var options = new DataLoadOptions();\n options.LoadWith<Post>(p => p.PostTags);\n options.LoadWith<PostTag>(pt => pt.Tag);\n using (var db = new DatabaseDataContext(m_connectionString))\n {\n var publishDateGmt = (from p in db.Posts\n where p.Status != PostStatus.Hidden\n orderby p.PublishDateGmt descending\n select p.PublishDateGmt)\n .Skip(page * record)\n .Take(record)\n .ToList()\n .Last();\n db.LoadOptions = options;\n return (from p in db.Posts\n where p.Status != PostStatus.Closed \n && p.PublishDateGmt >= publishDateGmt\n orderby p.PublishDateGmt descending\n select p)\n .Skip(page * record)\n .ToList();\n }\n}\n"
},
{
"answer_id": 3980733,
"author": "jordanbtucker",
"author_id": 164430,
"author_profile": "https://Stackoverflow.com/users/164430",
"pm_score": 0,
"selected": false,
"text": "var q = from p in db.Posts\n where db.Posts.Take(10).Contains(p)\n select p;\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/79939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
79,954
|
<p>When I debug in Visual Studio, Firefox opens and that is annoying because of the hookups that Internet Explorer and Visual Studio have, such as when you close the Internet Explorer browser that starting debug opened, Visual Studio stops debugging. How can I get Visual Studio to open Internet Explorer instead without having to set Internet Explorer as my default browser?</p>
|
[
{
"answer_id": 7610169,
"author": "Davut Gürbüz",
"author_id": 413032,
"author_profile": "https://Stackoverflow.com/users/413032",
"pm_score": 1,
"selected": false,
"text": "Tool"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/79954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/590/"
] |
79,960
|
<p>I have a code snippet written in PHP that pulls a block of text from a database and sends it out to a widget on a webpage. The original block of text can be a lengthy article or a short sentence or two; but for this widget I can't display more than, say, 200 characters. I could use substr() to chop off the text at 200 chars, but the result would be cutting off in the middle of words-- what I really want is to chop the text at the end of the last <i>word</i> before 200 chars.</p>
|
[
{
"answer_id": 79986,
"author": "Grey Panther",
"author_id": 1265,
"author_profile": "https://Stackoverflow.com/users/1265",
"pm_score": 9,
"selected": true,
"text": "substr($string, 0, strpos(wordwrap($string, $your_desired_width), \"\\n\"));\n"
},
{
"answer_id": 80001,
"author": "Lucas Oman",
"author_id": 6726,
"author_profile": "https://Stackoverflow.com/users/6726",
"pm_score": 3,
"selected": false,
"text": "<?php\n\n$longString = \"I have a code snippet written in PHP that pulls a block of text.\";\n$truncated = substr($longString,0,strpos($longString,' ',30));\n\necho $truncated;\n"
},
{
"answer_id": 80014,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "https://Stackoverflow.com/users/115",
"pm_score": 3,
"selected": false,
"text": "function neat_trim($str, $n, $delim='…') {\n $len = strlen($str);\n if ($len > $n) {\n preg_match('/(.{' . $n . '}.*?)\\b/', $str, $matches);\n return rtrim($matches[1]) . $delim;\n }\n else {\n return $str;\n }\n}\n"
},
{
"answer_id": 80030,
"author": "Justin Poliey",
"author_id": 6967,
"author_profile": "https://Stackoverflow.com/users/6967",
"pm_score": 2,
"selected": false,
"text": "$matches = array();\n$result = preg_match(\"/^(.{1,199})[\\s]/i\", $text, $matches);\n"
},
{
"answer_id": 80066,
"author": "mattmac",
"author_id": 14935,
"author_profile": "https://Stackoverflow.com/users/14935",
"pm_score": 7,
"selected": false,
"text": "preg_replace('/\\s+?(\\S+)?$/', '', substr($string, 0, 201));\n"
},
{
"answer_id": 2523223,
"author": "Camsoft",
"author_id": 248848,
"author_profile": "https://Stackoverflow.com/users/248848",
"pm_score": 3,
"selected": false,
"text": "function shorten($string, $width) {\n if(strlen($string) > $width) {\n $string = wordwrap($string, $width);\n $string = substr($string, 0, strpos($string, \"\\n\"));\n }\n\n return $string;\n}\n"
},
{
"answer_id": 4400574,
"author": "amateur barista",
"author_id": 467453,
"author_profile": "https://Stackoverflow.com/users/467453",
"pm_score": 1,
"selected": false,
"text": "// Trim very long text to 120 characters. Add an ellipsis if the text is trimmed.\nif(strlen($very_long_text) > 120) {\n $matches = array();\n preg_match(\"/^(.{1,120})[\\s]/i\", $very_long_text, $matches);\n $trimmed_text = $matches[0]. '...';\n}\n"
},
{
"answer_id": 4665347,
"author": "Dave",
"author_id": 382927,
"author_profile": "https://Stackoverflow.com/users/382927",
"pm_score": 6,
"selected": false,
"text": "$WidgetText = substr($string, 0, strrpos(substr($string, 0, 200), ' '));\n"
},
{
"answer_id": 7904269,
"author": "Yo-L",
"author_id": 310108,
"author_profile": "https://Stackoverflow.com/users/310108",
"pm_score": 2,
"selected": false,
"text": "function neatest_trim($content, $chars) \n if (strlen($content) > $chars) \n {\n $content = str_replace(' ', ' ', $content);\n $content = str_replace(\"\\n\", '', $content);\n // use with wordpress \n //$content = strip_tags(strip_shortcodes(trim($content)));\n $content = strip_tags(trim($content));\n $content = preg_replace('/\\s+?(\\S+)?$/', '', mb_substr($content, 0, $chars));\n\n $content = trim($content) . '...';\n return $content;\n }\n"
},
{
"answer_id": 8072672,
"author": "tanc",
"author_id": 1037075,
"author_profile": "https://Stackoverflow.com/users/1037075",
"pm_score": 2,
"selected": false,
"text": "preg_replace('/\\s+?(\\S+)?$/', '', substr($string . ' ', 0, 201));\n"
},
{
"answer_id": 10026115,
"author": "Bud Damyanov",
"author_id": 632524,
"author_profile": "https://Stackoverflow.com/users/632524",
"pm_score": 2,
"selected": false,
"text": "/*\nCut the string without breaking any words, UTF-8 aware \n* param string $str The text string to split\n* param integer $start The start position, defaults to 0\n* param integer $words The number of words to extract, defaults to 15\n*/\nfunction wordCutString($str, $start = 0, $words = 15 ) {\n $arr = preg_split(\"/[\\s]+/\", $str, $words+1);\n $arr = array_slice($arr, $start, $words);\n return join(' ', $arr);\n}\n"
},
{
"answer_id": 15089518,
"author": "gosukiwi",
"author_id": 1015566,
"author_profile": "https://Stackoverflow.com/users/1015566",
"pm_score": 0,
"selected": false,
"text": "function _truncate($str, $limit) {\n if(strlen($str) < $limit)\n return $str;\n $uid = uniqid();\n return array_shift(explode($uid, wordwrap($str, $limit, $uid)));\n}\n"
},
{
"answer_id": 17852480,
"author": "Sergiy Sokolenko",
"author_id": 131337,
"author_profile": "https://Stackoverflow.com/users/131337",
"pm_score": 5,
"selected": false,
"text": "/**\n * Truncates the given string at the specified length.\n *\n * @param string $str The input string.\n * @param int $width The number of chars at which the string will be truncated.\n * @return string\n */\nfunction truncate($str, $width) {\n return strtok(wordwrap($str, $width, \"...\\n\"), \"\\n\");\n}\n"
},
{
"answer_id": 21659546,
"author": "Yousef Altaf",
"author_id": 454012,
"author_profile": "https://Stackoverflow.com/users/454012",
"pm_score": -1,
"selected": false,
"text": "<?php\n $your_desired_width = 200;\n $string = $var->content;\n if (strlen($string) > $your_desired_width) {\n $string = wordwrap($string, $your_desired_width);\n $string = substr($string, 0, strpos($string, \"\\n\")) . \" More...\";\n }\n echo $string;\n?>\n"
},
{
"answer_id": 22783274,
"author": "slash3b",
"author_id": 3478120,
"author_profile": "https://Stackoverflow.com/users/3478120",
"pm_score": -1,
"selected": false,
"text": "<?php\n\n $string = \"Your line of text\";\n $spl = preg_match(\"/([, \\.\\d\\-''\\\"\\\"_()]*\\w+[, \\.\\d\\-''\\\"\\\"_()]*){50}/\", $string, $matches);\n if (isset($matches[0])) {\n $matches[0] .= \"...\";\n echo \"<br />\" . $matches[0];\n } else {\n echo \"<br />\" . $string;\n }\n\n?>\n"
},
{
"answer_id": 24204404,
"author": "Rikudou_Sennin",
"author_id": 3601208,
"author_profile": "https://Stackoverflow.com/users/3601208",
"pm_score": 1,
"selected": false,
"text": "<?php\nfunction stripByWords($string,$length,$delimiter = '<br>') {\n $words_array = explode(\" \",$string);\n $strlen = 0;\n $return = '';\n foreach($words_array as $word) {\n $strlen += mb_strlen($word,'utf8');\n $return .= $word.\" \";\n if($strlen >= $length) {\n $strlen = 0;\n $return .= $delimiter;\n }\n }\n return $return;\n}\n?>\n"
},
{
"answer_id": 24557257,
"author": "Artem P",
"author_id": 712308,
"author_profile": "https://Stackoverflow.com/users/712308",
"pm_score": 3,
"selected": false,
"text": "$shorttext = preg_replace('/^([\\s\\S]{1,200})[\\s]+?[\\s\\S]+/', '$1', $fulltext);\n"
},
{
"answer_id": 27420699,
"author": "Shashank Saxena",
"author_id": 2735410,
"author_profile": "https://Stackoverflow.com/users/2735410",
"pm_score": 1,
"selected": false,
"text": "$string = \"I appreciate your service & idea to provide the branded toys at a fair rent price. This is really a wonderful to watch the kid not just playing with variety of toys but learning faster compare to the other kids who are not using the BooksandBeyond service. We wish you all the best\";\n\nprint_r(substr($string, 0, strpos(wordwrap($string, 250), \"\\n\")));\n"
},
{
"answer_id": 31030129,
"author": "evandro777",
"author_id": 1671683,
"author_profile": "https://Stackoverflow.com/users/1671683",
"pm_score": 0,
"selected": false,
"text": "function substr_full_word($str, $start, $end){\n $pos_ini = ($start == 0) ? $start : stripos(substr($str, $start, $end), ' ') + $start;\n if(strlen($str) > $end){ $pos_end = strrpos(substr($str, 0, ($end + 1)), ' '); } // IF STRING SIZE IS LESSER THAN END\n if(empty($pos_end)){ $pos_end = $end; } // FALLBACK\n return substr($str, $pos_ini, $pos_end);\n}\n"
},
{
"answer_id": 32227063,
"author": "Abhijeet kumar sharma",
"author_id": 1101353,
"author_profile": "https://Stackoverflow.com/users/1101353",
"pm_score": -1,
"selected": false,
"text": "substr( $str, 0, strpos($str, ' ', 200) ); \n"
},
{
"answer_id": 32340759,
"author": "orrd",
"author_id": 1257764,
"author_profile": "https://Stackoverflow.com/users/1257764",
"pm_score": 2,
"selected": false,
"text": "function wholeWordTruncate($s, $characterCount) \n{\n if (preg_match(\"/^.{1,$characterCount}\\b/su\", $s, $match)) return $match[0];\n return $s;\n}\n"
},
{
"answer_id": 35061022,
"author": "jdorenbush",
"author_id": 2321998,
"author_profile": "https://Stackoverflow.com/users/2321998",
"pm_score": 0,
"selected": false,
"text": "if ((strpos($string, ' ') !== false) && (strlen($string) > 200)) { \n $WidgetText = substr($string, 0, strrpos(substr($string, 0, 200), ' ')); \n} \nelseif (strlen($string) > 200) {\n $WidgetText = substr($string, 0, 200);\n}\n"
},
{
"answer_id": 49194868,
"author": "Namida",
"author_id": 9467793,
"author_profile": "https://Stackoverflow.com/users/9467793",
"pm_score": -1,
"selected": false,
"text": "$lines = explode('♦♣♠',wordwrap($string, $length, '♦♣♠'));\n$newstring = $lines[0] . ' • • •';\n"
},
{
"answer_id": 50290843,
"author": "Mat Barnett",
"author_id": 2098954,
"author_profile": "https://Stackoverflow.com/users/2098954",
"pm_score": 0,
"selected": false,
"text": "function abbreviate_string_to_whole_word($string, $max_length, $buffer) {\n if (strlen($string) > $max_length) {\n $string_cropped = substr($string, 0, $max_length - $buffer);\n $last_space = strrpos($string_cropped, \" \");\n if ($last_space > 0) {\n $string_cropped = substr($string_cropped, 0, $last_space);\n }\n $abbreviated_string = $string_cropped . \" ...\";\n }\n else {\n $abbreviated_string = $string;\n }\n return $abbreviated_string;\n}\n"
},
{
"answer_id": 53894324,
"author": "Mahbub Alam",
"author_id": 6659365,
"author_profile": "https://Stackoverflow.com/users/6659365",
"pm_score": -1,
"selected": false,
"text": "substr($string, 0, strrpos(substr($string, 0, $comparingLength), ','))\n"
},
{
"answer_id": 61022066,
"author": "Will B.",
"author_id": 1144627,
"author_profile": "https://Stackoverflow.com/users/1144627",
"pm_score": 1,
"selected": false,
"text": "sprintf"
},
{
"answer_id": 66559438,
"author": "HOSSEIN B",
"author_id": 14182190,
"author_profile": "https://Stackoverflow.com/users/14182190",
"pm_score": 2,
"selected": false,
"text": "function word_shortener($text, $words=10, $sp='...'){\n\n $all = explode(' ', $text);\n $str = '';\n $count = 1;\n\n foreach($all as $key){\n $str .= $key . ($count >= $words ? '' : ' ');\n $count++;\n if($count > $words){\n break;\n }\n }\n\n return $str . (count($all) <= $words ? '' : $sp);\n\n}\n"
},
{
"answer_id": 69532106,
"author": "JesusIniesta",
"author_id": 3198983,
"author_profile": "https://Stackoverflow.com/users/3198983",
"pm_score": 0,
"selected": false,
"text": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna liqua. Ut enim ad minim veniam.\n"
},
{
"answer_id": 70406161,
"author": "younghallaji",
"author_id": 16925848,
"author_profile": "https://Stackoverflow.com/users/16925848",
"pm_score": 0,
"selected": false,
"text": "function trunc($phrase, $max_words) {\n $phrase_array = explode(' ',$phrase);\n if(count($phrase_array) > $max_words && $max_words > 0)\n $phrase = implode(' ',array_slice($phrase_array, 0, $max_words)).'...';\n return $phrase;\n }\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/79960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14956/"
] |
79,968
|
<p>I have a string which is like this:</p>
<pre><code>this is "a test"
</code></pre>
<p>I'm trying to write something in Python to split it up by space while ignoring spaces within quotes. The result I'm looking for is:</p>
<pre><code>['this', 'is', 'a test']
</code></pre>
<p>PS. I know you are going to ask "what happens if there are quotes within the quotes, well, in my application, that will never happen.</p>
|
[
{
"answer_id": 79985,
"author": "Jerub",
"author_id": 14648,
"author_profile": "https://Stackoverflow.com/users/14648",
"pm_score": 10,
"selected": true,
"text": "split"
},
{
"answer_id": 79989,
"author": "Allen",
"author_id": 6043,
"author_profile": "https://Stackoverflow.com/users/6043",
"pm_score": 6,
"selected": false,
"text": "shlex"
},
{
"answer_id": 80015,
"author": "pjz",
"author_id": 8002,
"author_profile": "https://Stackoverflow.com/users/8002",
"pm_score": -1,
"selected": false,
"text": " def adamsplit(s):\n result = []\n inquotes = False\n for substring in s.split('\"'):\n if not inquotes:\n result.extend(substring.split())\n else:\n result.append(substring)\n inquotes = not inquotes\n return result\n"
},
{
"answer_id": 80361,
"author": "Gregory",
"author_id": 14351,
"author_profile": "https://Stackoverflow.com/users/14351",
"pm_score": -1,
"selected": false,
"text": ">>> 'a short sized string with spaces '.split()\n"
},
{
"answer_id": 80449,
"author": "elifiner",
"author_id": 15109,
"author_profile": "https://Stackoverflow.com/users/15109",
"pm_score": 3,
"selected": false,
"text": "import re\n\ns = 'this is \"a test\" some text \"another test\"'\n\ndef splitter(s):\n def replacer(m):\n return m.group(0).replace(\" \", \"\\x00\")\n parts = re.sub('\".+?\"', replacer, s).split()\n parts = [p.replace(\"\\x00\", \" \") for p in parts]\n return parts\n\ndef splitter2(s):\n return [p.replace(\"\\x00\", \" \") for p in re.sub('\".+?\"', lambda m: m.group(0).replace(\" \", \"\\x00\"), s).split()]\n\nprint splitter2(s)\n"
},
{
"answer_id": 524796,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 6,
"selected": false,
"text": "test = 'this is \"a test\"' # or \"this is 'a test'\"\n# pieces = [p for p in re.split(\"( |[\\\\\\\"'].*[\\\\\\\"'])\", test) if p.strip()]\n# From comments, use this:\npieces = [p for p in re.split(\"( |\\\\\\\".*?\\\\\\\"|'.*?')\", test) if p.strip()]\n"
},
{
"answer_id": 525011,
"author": "Ryan Ginstrom",
"author_id": 10658,
"author_profile": "https://Stackoverflow.com/users/10658",
"pm_score": 5,
"selected": false,
"text": "csv"
},
{
"answer_id": 2159337,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": " [i.strip('\"').strip(\"'\") for i in re.split(r'(\\s+|(?<!\\\\)\".*?(?<!\\\\)\"|(?<!\\\\)\\'.*?(?<!\\\\)\\')', string) if i.strip()]\n"
},
{
"answer_id": 11194593,
"author": "moschlar",
"author_id": 1175818,
"author_profile": "https://Stackoverflow.com/users/1175818",
"pm_score": 1,
"selected": false,
"text": "from shlex import split as _split\nsplit = lambda a: [b.decode('utf-8') for b in _split(a.encode('utf-8'))]\n"
},
{
"answer_id": 23155180,
"author": "Daniel Dai",
"author_id": 1089262,
"author_profile": "https://Stackoverflow.com/users/1089262",
"pm_score": 4,
"selected": false,
"text": "import re\n\ndef line_split(line):\n return re.findall(r'[^\"\\s]\\S*|\".+?\"', line)\n"
},
{
"answer_id": 32480710,
"author": "hussic",
"author_id": 4111130,
"author_profile": "https://Stackoverflow.com/users/4111130",
"pm_score": 0,
"selected": false,
"text": "s = 'abc \"ad\" \\'fg\\' \"kk\\'rdt\\'\" zzz\"34\"zzz \"\" \\'\\''\n"
},
{
"answer_id": 43035638,
"author": "THE_MAD_KING",
"author_id": 7771160,
"author_profile": "https://Stackoverflow.com/users/7771160",
"pm_score": 2,
"selected": false,
"text": "def getArgs(s):\n args = []\n cur = ''\n inQuotes = 0\n for char in s.strip():\n if char == ' ' and not inQuotes:\n args.append(cur)\n cur = ''\n elif char == '\"' and not inQuotes:\n inQuotes = 1\n cur += char\n elif char == '\"' and inQuotes:\n inQuotes = 0\n cur += char\n else:\n cur += char\n args.append(cur)\n return args\n"
},
{
"answer_id": 49791573,
"author": "har777",
"author_id": 1851428,
"author_profile": "https://Stackoverflow.com/users/1851428",
"pm_score": 3,
"selected": false,
"text": "import re\nimport shlex\nimport csv\n\nline = 'this is \"a test\"'\n\n%timeit [p for p in re.split(\"( |\\\\\\\".*?\\\\\\\"|'.*?')\", line) if p.strip()]\n100000 loops, best of 3: 5.17 µs per loop\n\n%timeit re.findall(r'[^\"\\s]\\S*|\".+?\"', line)\n100000 loops, best of 3: 2.88 µs per loop\n\n%timeit list(csv.reader([line], delimiter=\" \"))\nThe slowest run took 9.62 times longer than the fastest. This could mean that an intermediate result is being cached.\n100000 loops, best of 3: 2.4 µs per loop\n\n%timeit shlex.split(line)\n10000 loops, best of 3: 50.2 µs per loop\n"
},
{
"answer_id": 51560564,
"author": "Ton van den Heuvel",
"author_id": 79111,
"author_profile": "https://Stackoverflow.com/users/79111",
"pm_score": 3,
"selected": false,
"text": "shlex"
},
{
"answer_id": 53210803,
"author": "hochl",
"author_id": 589206,
"author_profile": "https://Stackoverflow.com/users/589206",
"pm_score": 4,
"selected": false,
"text": "re"
},
{
"answer_id": 60929888,
"author": "Mikhail Zakharov",
"author_id": 9127614,
"author_profile": "https://Stackoverflow.com/users/9127614",
"pm_score": 1,
"selected": false,
"text": "In [1]: from tssplit import tssplit\nIn [2]: tssplit('this is \"a test\"', quote='\"', delimiter='')\nOut[2]: ['this', 'is', 'a test']\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/79968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5324/"
] |
79,992
|
<p>Ideally the reader has upgraded a native C++ program to Visual Studio 2008, which contains an OpenClipboard() block. Why not try setting a breakpoint just after getting a successful return-code from OpenClipboard() and step through your code. According to the Internet it may work on your system, but of course, not on mine, thanks for trying. </p>
<p>Googling on e.g. (( OpenClipboard 1418 vc6 )) finds articles like "GetClipboardData fails in debugger" and "No Error in VC++6 but Error in VC++ 2005". Pragmatically for-the-moment, problem solved - I simply cannot set breakpoints within such code, I need to squirrel information and set the breakpoint after the clipboard operations are done. Error 1418 is "Thread does not have a clipboard open" but it works fine as long as you don't step with VS.NET, or like I say if you keep breakpoints outside of the clipboard-open-close-block.<p>
I would feel better knowing what the exact issue is with the VS.NET debugger.<p>
Being a C++ person I am only dimly aware that you are not supposed to think in terms of threads when doing dot-Net. Anyway I did not find a guru-quality explanation of what's really going on, whether in-fact the problem is that the dot-Net debugger is subtly interfering with the thread-information somehow, when you single-step thru native C++ code. <P></p>
<p>System-wise: about a year old, two dual-core Xeon's, 4 CPU's according to XP-pro.
I had just finished debugging the code by single-stepping thru it in vc6 under XP-SP2-32-bit. So I know the code was pretty-much-fine under vc6. However when I tested with a 10-megabyte CF_TEXT I got exceptions. I thought to try debugging under the nicer exception model of XP-x64.<p>
Recompiled with visual-studio-2008, I could not get the code to single-step at all. OpenClipboard worked, but EnumClipboardFormats() did not work, nothing worked when single-stepped. However, when I set the breakpoint below the complete block of code, everything worked fine. And <em>YES</em> vc2008 made a pinpoint diagnostic 'stack frame corruption around szBuf. There is a lot to like about vc2008. It would be nice if this were somehow merely a clipboard problem - without knowing that I would feel compelled to worry about stepping thru ANYTHING, whether thread-context-issues might be due to the dot-Net-debugger.</p>
|
[
{
"answer_id": 79985,
"author": "Jerub",
"author_id": 14648,
"author_profile": "https://Stackoverflow.com/users/14648",
"pm_score": 10,
"selected": true,
"text": "split"
},
{
"answer_id": 79989,
"author": "Allen",
"author_id": 6043,
"author_profile": "https://Stackoverflow.com/users/6043",
"pm_score": 6,
"selected": false,
"text": "shlex"
},
{
"answer_id": 80015,
"author": "pjz",
"author_id": 8002,
"author_profile": "https://Stackoverflow.com/users/8002",
"pm_score": -1,
"selected": false,
"text": " def adamsplit(s):\n result = []\n inquotes = False\n for substring in s.split('\"'):\n if not inquotes:\n result.extend(substring.split())\n else:\n result.append(substring)\n inquotes = not inquotes\n return result\n"
},
{
"answer_id": 80361,
"author": "Gregory",
"author_id": 14351,
"author_profile": "https://Stackoverflow.com/users/14351",
"pm_score": -1,
"selected": false,
"text": ">>> 'a short sized string with spaces '.split()\n"
},
{
"answer_id": 80449,
"author": "elifiner",
"author_id": 15109,
"author_profile": "https://Stackoverflow.com/users/15109",
"pm_score": 3,
"selected": false,
"text": "import re\n\ns = 'this is \"a test\" some text \"another test\"'\n\ndef splitter(s):\n def replacer(m):\n return m.group(0).replace(\" \", \"\\x00\")\n parts = re.sub('\".+?\"', replacer, s).split()\n parts = [p.replace(\"\\x00\", \" \") for p in parts]\n return parts\n\ndef splitter2(s):\n return [p.replace(\"\\x00\", \" \") for p in re.sub('\".+?\"', lambda m: m.group(0).replace(\" \", \"\\x00\"), s).split()]\n\nprint splitter2(s)\n"
},
{
"answer_id": 524796,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 6,
"selected": false,
"text": "test = 'this is \"a test\"' # or \"this is 'a test'\"\n# pieces = [p for p in re.split(\"( |[\\\\\\\"'].*[\\\\\\\"'])\", test) if p.strip()]\n# From comments, use this:\npieces = [p for p in re.split(\"( |\\\\\\\".*?\\\\\\\"|'.*?')\", test) if p.strip()]\n"
},
{
"answer_id": 525011,
"author": "Ryan Ginstrom",
"author_id": 10658,
"author_profile": "https://Stackoverflow.com/users/10658",
"pm_score": 5,
"selected": false,
"text": "csv"
},
{
"answer_id": 2159337,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": " [i.strip('\"').strip(\"'\") for i in re.split(r'(\\s+|(?<!\\\\)\".*?(?<!\\\\)\"|(?<!\\\\)\\'.*?(?<!\\\\)\\')', string) if i.strip()]\n"
},
{
"answer_id": 11194593,
"author": "moschlar",
"author_id": 1175818,
"author_profile": "https://Stackoverflow.com/users/1175818",
"pm_score": 1,
"selected": false,
"text": "from shlex import split as _split\nsplit = lambda a: [b.decode('utf-8') for b in _split(a.encode('utf-8'))]\n"
},
{
"answer_id": 23155180,
"author": "Daniel Dai",
"author_id": 1089262,
"author_profile": "https://Stackoverflow.com/users/1089262",
"pm_score": 4,
"selected": false,
"text": "import re\n\ndef line_split(line):\n return re.findall(r'[^\"\\s]\\S*|\".+?\"', line)\n"
},
{
"answer_id": 32480710,
"author": "hussic",
"author_id": 4111130,
"author_profile": "https://Stackoverflow.com/users/4111130",
"pm_score": 0,
"selected": false,
"text": "s = 'abc \"ad\" \\'fg\\' \"kk\\'rdt\\'\" zzz\"34\"zzz \"\" \\'\\''\n"
},
{
"answer_id": 43035638,
"author": "THE_MAD_KING",
"author_id": 7771160,
"author_profile": "https://Stackoverflow.com/users/7771160",
"pm_score": 2,
"selected": false,
"text": "def getArgs(s):\n args = []\n cur = ''\n inQuotes = 0\n for char in s.strip():\n if char == ' ' and not inQuotes:\n args.append(cur)\n cur = ''\n elif char == '\"' and not inQuotes:\n inQuotes = 1\n cur += char\n elif char == '\"' and inQuotes:\n inQuotes = 0\n cur += char\n else:\n cur += char\n args.append(cur)\n return args\n"
},
{
"answer_id": 49791573,
"author": "har777",
"author_id": 1851428,
"author_profile": "https://Stackoverflow.com/users/1851428",
"pm_score": 3,
"selected": false,
"text": "import re\nimport shlex\nimport csv\n\nline = 'this is \"a test\"'\n\n%timeit [p for p in re.split(\"( |\\\\\\\".*?\\\\\\\"|'.*?')\", line) if p.strip()]\n100000 loops, best of 3: 5.17 µs per loop\n\n%timeit re.findall(r'[^\"\\s]\\S*|\".+?\"', line)\n100000 loops, best of 3: 2.88 µs per loop\n\n%timeit list(csv.reader([line], delimiter=\" \"))\nThe slowest run took 9.62 times longer than the fastest. This could mean that an intermediate result is being cached.\n100000 loops, best of 3: 2.4 µs per loop\n\n%timeit shlex.split(line)\n10000 loops, best of 3: 50.2 µs per loop\n"
},
{
"answer_id": 51560564,
"author": "Ton van den Heuvel",
"author_id": 79111,
"author_profile": "https://Stackoverflow.com/users/79111",
"pm_score": 3,
"selected": false,
"text": "shlex"
},
{
"answer_id": 53210803,
"author": "hochl",
"author_id": 589206,
"author_profile": "https://Stackoverflow.com/users/589206",
"pm_score": 4,
"selected": false,
"text": "re"
},
{
"answer_id": 60929888,
"author": "Mikhail Zakharov",
"author_id": 9127614,
"author_profile": "https://Stackoverflow.com/users/9127614",
"pm_score": 1,
"selected": false,
"text": "In [1]: from tssplit import tssplit\nIn [2]: tssplit('this is \"a test\"', quote='\"', delimiter='')\nOut[2]: ['this', 'is', 'a test']\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/79992",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10972/"
] |
79,999
|
<p>If you were writing a new application from scratch today, and wanted it to scale to all the cores you could throw at it tomorrow, what parallel programming model/system/language/library would you choose? Why?</p>
<p>I am particularly interested in answers along these axes:</p>
<ol>
<li>Programmer productivity / ease of use (can mortals successfully use it?)</li>
<li>Target application domain (what problems is it (not) good at?)</li>
<li>Concurrency style (does it support tasks, pipelines, data parallelism, messages...?)
<li>Maintainability / future-proofing (will anybody still be using it in 20 years?)</li>
<li>Performance (how does it scale on what kinds of hardware?)</li>
</ol>
<p>I am being deliberately vague on the nature of the application in anticipation of getting good general answers useful for a variety of applications.</p>
|
[
{
"answer_id": 1344944,
"author": "Ira Baxter",
"author_id": 120163,
"author_profile": "https://Stackoverflow.com/users/120163",
"pm_score": 1,
"selected": false,
"text": "(|; a (... a's computation)\n (<< a) b ( ... b's computation ... )\n (<< a) c ( ....c's computation ...)\n (>> c) d ( ... d's computation...)\n)|;\n"
},
{
"answer_id": 2893087,
"author": "J D",
"author_id": 13924,
"author_profile": "https://Stackoverflow.com/users/13924",
"pm_score": 1,
"selected": false,
"text": "map"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/79999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/171236/"
] |
80,021
|
<p>I recently started using Eclipse at work for my Java servlet projects. I've been using jEdit for years, which is a uber-powerful text editor. It has syntax highlighting, but it doesn't have any language-specific features like code completion and intelligent refactoring. I'm finding that's hindering my productivity. I <em>desperately</em> want to like Eclipse. I really do. But I keep running into problem after problem. </p>
<ol>
<li>Now that Eclipse can use an ant script to build, instead of just creating its own build environment from an ant script then ignoring any changes to it, I found some online guides and set it up. It doesn't seem ready for prime time, though. My ant script builds fine from the command line, but I get all these build errors because I need to tell Eclipse all this stuff the build.xml already has in it, like the CLASSPATH, and where external jars are.</li>
<li>When I leave Eclipse running for too long, or sometimes after my laptop wakes up from hibernate, the UI starts breaking. For instance, the tabs on the editor pane disappear, so I can only edit one file at a time, and it doesn't say which one it is.</li>
<li>We have faced several instances where classes weren't rebuilt that should have been, leading to inaccurate line numbers in debugging walkthroughs and other unpredictable behavior (this isn't just me; the two other developers trying it out with me are seeing the same thing).</li>
<li>I find it a huge hassle that the workspace is in a different place than my source code. I have other files I need to edit (xml files, etc), and for each directory I want to edit files in, I need to set up a special entry, and it doesn't even default to where my source code is when setting that up.</li>
</ol>
<p>Do others face these same issues?</p>
<p>Are there better alternatives? </p>
|
[
{
"answer_id": 80057,
"author": "Thomas",
"author_id": 14637,
"author_profile": "https://Stackoverflow.com/users/14637",
"pm_score": 0,
"selected": false,
"text": ""
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14924/"
] |
80,062
|
<p>My friends and I are starting a game like Pokemon and we wanted to know how will we add monsters to the game? We're using VisualBasic because my friend's brother said it would be easier.</p>
<p>So far we can put pictures of the monsters on the screen and you can click to attack and stuff.</p>
<p>Right now when we want to add a monster we have to make a new window. This will take us a long time to make all the windows for each type of monster. Is there a tool or something to make this go faster? How do game companies do this?</p>
|
[
{
"answer_id": 150773,
"author": "Rory Becker",
"author_id": 11356,
"author_profile": "https://Stackoverflow.com/users/11356",
"pm_score": 1,
"selected": false,
"text": "Class Monster\n Public Name as String \n Public Filename as String ' Location of graphics file on disk\n Public Strength as Integer \n Public Speed as Integer \n Public Sub New(Name as String, Filename as String, Strength as Integer, Speed as Integer)\n Me.Name = Name\n Me.Filename = Filename\n Me.Strength = Strength\n Me.Speed = Speed\n End Sub \nEnd Class\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
80,084
|
<p>In JavaScript, the "this" operator can refer to different things under different scenarios. </p>
<p>Typically in a method within a JavaScript "object", it refers to the current object.</p>
<p>But when used as a callback, it becomes a reference to the calling object.</p>
<p>I have found that this causes problems in code, because if you use a method within a JavaScript "object" as a callback function you can't tell whether "this" refers to the current "object" or whether "this" refers to the calling object.</p>
<p>Can someone clarify usage and best practices regarding how to get around this problem?</p>
<pre><code> function TestObject() {
TestObject.prototype.firstMethod = function(){
this.callback();
YAHOO.util.Connect.asyncRequest(method, uri, callBack);
}
TestObject.prototype.callBack = function(o){
// do something with "this"
//when method is called directly, "this" resolves to the current object
//when invoked by the asyncRequest callback, "this" is not the current object
//what design patterns can make this consistent?
this.secondMethod();
}
TestObject.prototype.secondMethod = function() {
alert('test');
}
}
</code></pre>
|
[
{
"answer_id": 80119,
"author": "dimarzionist",
"author_id": 10778,
"author_profile": "https://Stackoverflow.com/users/10778",
"pm_score": 0,
"selected": false,
"text": "var ctx = function CallbackContext()\n{\n_callbackSender\n...\n}\n\nfunction DoCallback(_sender, delegate, callbackFunc)\n{\n ctx = _callbackSender = _sender;\n delegate();\n}\n\nfunction TestObject()\n{\n test = function()\n {\n DoCallback(otherFunc, callbackHandler);\n }\n\n callbackHandler = function()\n{\n ctx._callbackSender;\n //or this = ctx._callbacjHandler;\n}\n}\n"
},
{
"answer_id": 80127,
"author": "Ricky",
"author_id": 653,
"author_profile": "https://Stackoverflow.com/users/653",
"pm_score": 5,
"selected": true,
"text": "this"
},
{
"answer_id": 80159,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 2,
"selected": false,
"text": "this"
},
{
"answer_id": 80177,
"author": "jeannicolas",
"author_id": 14981,
"author_profile": "https://Stackoverflow.com/users/14981",
"pm_score": 0,
"selected": false,
"text": "YAHOO.util.Connect.asyncRequest(method, uri, callBack.Apply(this));\n"
},
{
"answer_id": 80478,
"author": "Alan Storm",
"author_id": 4668,
"author_profile": "https://Stackoverflow.com/users/4668",
"pm_score": 6,
"selected": false,
"text": "var foo = {};\nfoo.someMethod = function(){\n alert(this);\n}\n"
},
{
"answer_id": 83730,
"author": "Chase Seibert",
"author_id": 7679,
"author_profile": "https://Stackoverflow.com/users/7679",
"pm_score": 1,
"selected": false,
"text": "var myObject = new TestObject();\nmyObject.firstMethod.bind(myObject);\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80084",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
80,091
|
<p>How do I do a diff of two strings or arrays in Ruby?</p>
|
[
{
"answer_id": 80117,
"author": "Chris Bunch",
"author_id": 422,
"author_profile": "https://Stackoverflow.com/users/422",
"pm_score": 5,
"selected": false,
"text": ">> foo = [1, 2, 3]\n=> [1, 2, 3]\n>> goo = [2, 3, 4]\n=> [2, 3, 4]\n>> foo - goo\n=> [1]\n"
},
{
"answer_id": 416136,
"author": "da01",
"author_id": 52001,
"author_profile": "https://Stackoverflow.com/users/52001",
"pm_score": 4,
"selected": false,
"text": "gem install differ\n\nirb\nrequire 'differ'\n\none = \"one two three\"\ntwo = \"one two 3\"\n\nDiffer.format = :color\nputs Differ.diff_by_word(one, two).to_s\n\nDiffer.format = :html\nputs Differ.diff_by_word(one, two).to_s\n"
},
{
"answer_id": 419013,
"author": "Grant Hutchins",
"author_id": 6304,
"author_profile": "https://Stackoverflow.com/users/6304",
"pm_score": 3,
"selected": false,
"text": "diff-lcs"
},
{
"answer_id": 739161,
"author": "Brian Armstrong",
"author_id": 76486,
"author_profile": "https://Stackoverflow.com/users/76486",
"pm_score": 3,
"selected": false,
"text": "script/plugin install git://github.com/myobie/htmldiff.git\n\n# bottom of environment.rb\nrequire 'htmldiff'\n\n# in model\nclass Page < ActiveRecord::Base\n extend HTMLDiff\nend\n\n# in view\n<h1>Revisions for <%= @page.name %></h1>\n<ul>\n<% @page.revisions.each do |revision| %>\n <li>\n <b>Revised <%= distance_of_time_in_words_to_now revision.created_at %> ago</b><BR>\n <%= Page.diff(\n revision.changes['description'][0],\n revision.changes['description'][1]\n ) %>\n <BR><BR>\n </li>\n<% end %>\n\n# in style.css\nins.diffmod, ins.diffins { background: #d4fdd5; text-decoration: none; }\ndel.diffmod, del.diffdel { color: #ff9999; }\n"
},
{
"answer_id": 1511882,
"author": "Daniel Cukier",
"author_id": 105514,
"author_profile": "https://Stackoverflow.com/users/105514",
"pm_score": 2,
"selected": false,
"text": " def diff str1, str2\n system \"diff #{file_for str1} #{file_for str2}\"\n end\n\n private\n def file_for text\n exp = Tempfile.new(\"bk\", \"/tmp\").open\n exp.write(text)\n exp.close\n exp.path\n end\n"
},
{
"answer_id": 3146315,
"author": "samg",
"author_id": 211136,
"author_profile": "https://Stackoverflow.com/users/211136",
"pm_score": 5,
"selected": false,
"text": "diff"
},
{
"answer_id": 45572385,
"author": "dimus",
"author_id": 23080,
"author_profile": "https://Stackoverflow.com/users/23080",
"pm_score": 1,
"selected": false,
"text": "require \"damerau-levenshtein\"\ndiffer = DamerauLevenshtein::Differ.new\ndiffer.run \"Something\", \"Smothing\"\n# returns [\"S<ins>o</ins>m<subst>e</subst>thing\", \n# \"S<del>o</del>m<subst>o</subst>thing\"]\n"
},
{
"answer_id": 51544818,
"author": "Steve",
"author_id": 6621187,
"author_profile": "https://Stackoverflow.com/users/6621187",
"pm_score": 3,
"selected": false,
"text": "t=s2.chars; s1.chars.map{|c| c == t.shift ? c : '^'}.join\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5004/"
] |
80,101
|
<p>I am currently programming a scheduling application which loosely based on iCalendar standard. Does anyone knows in which property can I store the event creator's information? By browsing through the iCalendar RFC 2445, I find this property: <a href="http://www.kanzaki.com/docs/ical/organizer.html" rel="nofollow noreferrer">Organizer</a>. can I store the event creator's information in the property even if he/she is the only person involved in the event? or there is already a field to store the event creator's information???!</p>
|
[
{
"answer_id": 80124,
"author": "Dave Cheney",
"author_id": 6449,
"author_profile": "https://Stackoverflow.com/users/6449",
"pm_score": 3,
"selected": false,
"text": "ORGANIZER;CN=\"Sally Example\":mailto:sally@example.com"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5742/"
] |
80,105
|
<p>Java is one of my programming languages of choice. I always run into the problem though of distributing my application to end-users.</p>
<p>Giving a user a JAR is not always as user friendly as I would like and using Java WebStart requires that I maintain a web server.</p>
<p>What's the best way to distribute a Java application? What if the Java application needs to install artifacts to the user's computer? Are there any good Java installation/packaging systems out there?</p>
|
[
{
"answer_id": 80128,
"author": "jjnguy",
"author_id": 2598,
"author_profile": "https://Stackoverflow.com/users/2598",
"pm_score": 1,
"selected": false,
"text": "java -jar jarname.jar\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14204/"
] |
80,141
|
<p>What algorithms and processes are involved in storing revision changes like stackoverflow and wikipedia do?</p>
<p>Is only one copy of the message kept? And if so is it only the latest copy? Then only changes to go back to the previous version(s) are stored from there? (This would make for a faster display of the main message).
Or are complete messages stored? And if so is the compare done between these on each display?</p>
<p>What algorithms are best used to determine the exact changes in the message? How is this data stored in a database?</p>
<p>If anyone knows exactly what wikipedia or stackoverlfow does I'd love to know.</p>
|
[
{
"answer_id": 80179,
"author": "Thomas",
"author_id": 14637,
"author_profile": "https://Stackoverflow.com/users/14637",
"pm_score": 2,
"selected": true,
"text": "(article_id, revision_id, differences)"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3153/"
] |
80,175
|
<p>This is somewhat similar to <a href="https://stackoverflow.com/questions/25653/hide-a-column-in-aspnet-dynamic-data">this question</a>.</p>
<p>However, rather than wanting to hide a column all together, I am just looking to hide the column on the List.aspx page.</p>
<p>My specific example is that fields that are long (or at least nvarchar(MAX)) automatically hide from the List.aspx page as is but are still visible on the Edit.aspx page.</p>
<p>I would like to replicate this behaviour for other (shorter) columns.</p>
<p>Is this possible?</p>
|
[
{
"answer_id": 81806,
"author": "Mark Pattison",
"author_id": 15519,
"author_profile": "https://Stackoverflow.com/users/15519",
"pm_score": 4,
"selected": true,
"text": "AutoGenerateColumns=\"false\""
},
{
"answer_id": 33539874,
"author": "iamtonyzhou",
"author_id": 1027127,
"author_profile": "https://Stackoverflow.com/users/1027127",
"pm_score": 0,
"selected": false,
"text": "<asp:DynamicField DataField=\"Id\" ItemStyle-CssClass=\"hidden\" HeaderStyle-CssClass=\"hidden\" FooterStyle-CssClass=\"hidden\"/>\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364/"
] |
80,182
|
<p>I get the concept of creating a business object or entity to represent something like a Person. I can then serialize the Person using a DTO and send it down to the client. If the client changes the object, it can have an IsDirty flag on there so when it gets sent back to the server I know to update it.</p>
<p>But what if I have an Order object? This has the main header informaton, customer, supplier, required date, etc. Then it has OrderItems which is a List< OrderItem>, being the items to be ordered. I want to be able to use this business object on my UI. So I have some textboxes hooked up to the location, supplier, required date, etc and a grid hooked up to OrderItems. Since OrderItems is a List I can easily add and delete records to it. But how do I track this, especially the deleted items. I don't want the deleted items to be visible in my grid and I shouldn't be able to iterate over them if I used foreach, because they have been deleted. But I still need to track the fact there was a deletion. How do I track the changes. I think I need to use a unit of work? But then the code seems to become quite complex. So then I wonder why not simply use DataTables and get the change tracking for free? But then I read how business objects are the way to go.</p>
<p>I’ve found various examples on simple Person examples, bnut not header-detail examples like Orders.</p>
<p>BTW using C# 3.5 for this.</p>
|
[
{
"answer_id": 80266,
"author": "Dean Poulin",
"author_id": 5462,
"author_profile": "https://Stackoverflow.com/users/5462",
"pm_score": -1,
"selected": false,
"text": "public class FooDataContext : DataContext\n{\n public Table<Order> Orders; \n}\n\npublic class Order\n{\n [DbColumn(Identity = true)]\n [Column(DbType = \"Int NOT NULL IDENTITY\", IsPrimaryKey = true, IsDbGenerated = true)]\n public int Id { get; set; }\n\n [DbColumn(Default = \"(getutcdate())\")]\n [Column(DbType = \"DateTime\", CanBeNull = false, IsDbGenerated = true)]\n public DateTime DateCreated { get; set; }\n\n [Column(DbType = \"varchar(50)\", CanBeNull = false, IsDbGenerated = false)]\n public string Name { get; set; }\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11355/"
] |
80,186
|
<p>I can't seem to find much documentation on X-Sendfile or example code for PHP (there is some rails code).</p>
<p>Anyone used it before and would mind giving a quick snippet of code and a brief description?</p>
|
[
{
"answer_id": 80201,
"author": "Don Neufeld",
"author_id": 13097,
"author_profile": "https://Stackoverflow.com/users/13097",
"pm_score": 5,
"selected": false,
"text": "header(\"X-Sendfile: $filename\");\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
80,195
|
<p>I would like to make 2 TB or so available via NFS and CIFS. I am looking for a 2 (or more) server solution for high availability and the ability to load balance across the servers if possible. Any suggestions for clustering or high availability solutions?</p>
<p>This is business use, planning on growing to 5-10 TB over next few years. Our facility is almost 24 hours a day, six days a week. We could have 15-30 minutes of downtime, but we want to minimize data loss. I want to minimize 3 AM calls. </p>
<p>We are currently running one server with ZFS on Solaris and we are looking at AVS for the HA part, but we have had minor issues with Solaris (CIFS implementation doesn't work with Vista, etc) that have held us up. </p>
<p>We have started looking at </p>
<ul>
<li>DRDB over GFS (GFS for distributed
lock capability)</li>
<li>Gluster (needs
client pieces, no native CIFS
support?)</li>
<li>Windows DFS (doc says only
replicates after file closes?)</li>
</ul>
<p>We are looking for a "black box" that serves up data.</p>
<p>We currently snapshot the data in ZFS and send the snapshot over the net to a remote datacenter for offsite backup.</p>
<p>Our original plan was to have a 2nd machine and rsync every 10 - 15 min. The issue on a failure would be that ongoing production processes would lose 15 minutes of data and be left "in the middle". They would almost be easier to start from the beginning than to figure out where to pickup in the middle. That is what drove us to look at HA solutions.</p>
|
[
{
"answer_id": 85606,
"author": "Tony Dodd",
"author_id": 16465,
"author_profile": "https://Stackoverflow.com/users/16465",
"pm_score": 3,
"selected": false,
"text": "\n/etc/drbd.conf\n\nglobal {\n usage-count no;\n}\ncommon {\n protocol C;\n disk { on-io-error detach; }\n}\nresource export {\n syncer {\n rate 125M;\n }\n on hanfs2 {\n address 172.20.1.218:7789;\n device /dev/drbd1;\n disk /dev/sda3;\n meta-disk internal;\n }\n on hanfs1 {\n address 172.20.1.219:7789;\n device /dev/drbd1;\n disk /dev/sda3;\n meta-disk internal;\n }\n}"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15020/"
] |
80,202
|
<p>I want to use javascript to insert some elements into the current page.
Such as this is the original document:
<p>Hello world!</p></p>
<p>Now I want to insert an element in to the text so that it will become:</p>
<p><p>Hello <span id=span1>new</span> world!</p></p>
<p>I need the span tag because I want to handle it later.Show or hide.
But now problem comes out, if the original page has already defined a strange CSS style on all <span> tags, the "new" I just inserted will not appear to be the same as "Hello" and "world". How can I avoid this? I want the "new" be exactly the same as the "Hello" and "world".</p>
|
[
{
"answer_id": 80228,
"author": "Sev",
"author_id": 83819,
"author_profile": "https://Stackoverflow.com/users/83819",
"pm_score": 0,
"selected": false,
"text": "<span>"
},
{
"answer_id": 80251,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackoverflow.com/users/1790",
"pm_score": 1,
"selected": false,
"text": "<p style=\"display: inline\">Hello <p id=\"myIdValue\" style=\"display: inline\">new</p> World</p>\n"
},
{
"answer_id": 80262,
"author": "Prestaul",
"author_id": 5628,
"author_profile": "https://Stackoverflow.com/users/5628",
"pm_score": 1,
"selected": false,
"text": "span {\n display: block;\n margin: 10px;\n padding: 10px;\n}\n"
},
{
"answer_id": 80408,
"author": "Prestaul",
"author_id": 5628,
"author_profile": "https://Stackoverflow.com/users/5628",
"pm_score": 2,
"selected": true,
"text": "span#yourSpan {\n /* defaults */\n position: static;\n display: inline;\n margin: 0;\n padding: 0;\n background: transparent;\n border: none;\n\n /* inherit from parent node */\n font: inherit;\n color: inherit;\n text-decoration: inherit;\n line-height: inherit;\n letter-spacing: inherit;\n text-transform: inherit;\n white-space: inherit;\n word-spacing: inherit;\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15023/"
] |
80,247
|
<p>How can I get all implementations of an interface through reflection in C#?</p>
|
[
{
"answer_id": 80325,
"author": "Alex Duggleby",
"author_id": 5790,
"author_profile": "https://Stackoverflow.com/users/5790",
"pm_score": 1,
"selected": false,
"text": "ObjX foo = new ObjX();\nType tFoo = foo.GetType();\nType[] tFooInterfaces = tFoo.GetInterfaces();\nforeach(Type tInterface in tFooInterfaces)\n{\n // do something with it\n}\n"
},
{
"answer_id": 80343,
"author": "Anton",
"author_id": 6464,
"author_profile": "https://Stackoverflow.com/users/6464",
"pm_score": 3,
"selected": false,
"text": "Assembly.GetTypes()"
},
{
"answer_id": 80375,
"author": "Adam Driscoll",
"author_id": 13688,
"author_profile": "https://Stackoverflow.com/users/13688",
"pm_score": 2,
"selected": false,
"text": "Assembly assembly = Assembly.GetExecutingAssembly();\nList<Type> types = assembly.GetTypes();\nList<Type> childTypes = new List<Type>();\nforeach (Type type in Types) {\n foreach (Type interfaceType in type.GetInterfaces()) {\n if (interfaceType.Equals(typeof([yourinterfacetype)) {\n childTypes.Add(type)\n break;\n }\n }\n}\n"
},
{
"answer_id": 80467,
"author": "Steve Cooper",
"author_id": 6722,
"author_profile": "https://Stackoverflow.com/users/6722",
"pm_score": 6,
"selected": false,
"text": "/// <summary>\n/// Returns all types in the current AppDomain implementing the interface or inheriting the type. \n/// </summary>\npublic static IEnumerable<Type> TypesImplementingInterface(Type desiredType)\n{\n return AppDomain\n .CurrentDomain\n .GetAssemblies()\n .SelectMany(assembly => assembly.GetTypes())\n .Where(type => desiredType.IsAssignableFrom(type));\n}\n"
},
{
"answer_id": 17267339,
"author": "Sam",
"author_id": 238753,
"author_profile": "https://Stackoverflow.com/users/238753",
"pm_score": 2,
"selected": false,
"text": "Type"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80247",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
80,278
|
<p>I am trying to use the Google Maps API in a ColdFusion template that is a border type cflayoutarea container. However, the map simply doesn't show up:</p>
<pre><code><cfif isdefined("url.lat")>
<cfset lat="#url.lat#">
<cfset lng="#url.lng#">
</cfif>
<head>
<script src= "http://maps.google.com/maps?file=api&amp;v=2&amp;key=xxxx" type="text/javascript">
function getMap(lat,lng){
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
var pt= new GLatLng(lat,lng);
map.setCenter(pt, 18,G_HYBRID_MAP);
map.addOverlay(new GMarker(pt));
}
}
</script>
</head>
<cfoutput>
<body onLoad="getMap(#lat#,#lng#)" onUnload="GUnload()">
Map:<br>
<div id="map_canvas" style="width: 500px; height: 300px"/>
</body>
</cfoutput>"
</code></pre>
<p>where lat and lng are the co-ordinates in degree.decimal format. I have traced down to the line where GBrowserIsCompatible() somehow never returns TRUE and thus no further action was taken.</p>
<p>If opened separately the template works perfectly but just not when opened as a cflayoutarea container. Anyone has experience in this? Any suggestions is much appreciated.</p>
<p>Lawrence</p>
<p>Using CF 8.01, Dreamweaver 8</p>
<hr>
<p>Tried your suggestion but still doesn't work; the map only shows when the calling code is inline. However, if this container page was called from yet another div the map disappears again.</p>
<p>I suspect this issue is related to the cflayout container; I'll look up the Extjs doc to see if there're any leads to a solution.</p>
|
[
{
"answer_id": 80298,
"author": "convex hull",
"author_id": 10747,
"author_profile": "https://Stackoverflow.com/users/10747",
"pm_score": 0,
"selected": false,
"text": "position: absolute\n"
},
{
"answer_id": 82887,
"author": "Adam Tuttle",
"author_id": 751,
"author_profile": "https://Stackoverflow.com/users/751",
"pm_score": 0,
"selected": false,
"text": "<script src=\"http://maps.google.com/maps?file=api&v=2&key=xxxx\" type=\"text/javascript\">\n function getMap(lat,lng){ \n if (GBrowserIsCompatible()) { \n var map = new GMap2(document.getElementById(\"map_canvas\"));\n var pt= new GLatLng(lat,lng);\n map.setCenter(pt, 18,G_HYBRID_MAP); \n map.addOverlay(new GMarker(pt));\n } \n }\n</script>\n<cflayout>...</cflayout>\n"
},
{
"answer_id": 100406,
"author": "lawrencem49",
"author_id": 15007,
"author_profile": "https://Stackoverflow.com/users/15007",
"pm_score": 2,
"selected": true,
"text": "<script src= \"http://maps.google.com/maps?file=api&v=2&key=xxxx\" type=\"text/javascript\"></script>\n<script type=\"text/javascript\">\n getMap=function(lat,lng){ \n if (GBrowserIsCompatible()){\n var map = new GMap2(document.getElementById(\"map_canvas\"));\n var pt = new GLatLng(lat,lng);\n map.setCenter(pt, 18,G_HYBRID_MAP); \n map.addOverlay(new GMarker(pt)); \n } \n }\n</script> \n\n <cflayout name=\"testlayout\" type=\"border\">\n <cflayoutarea name=\"left\" position=\"left\" size=\"250\"/>\n <cflayoutarea name=\"center\" position=\"center\"> \n <!--- sample hard-coded co-ordinates --->\n <body onLoad=\"getMap(22.280161,114.185096)\">\n Map:<br />\n <div id=\"map_canvas\" style=\"width:500px; height: 300px\"/>\n </body>\n </cflayoutarea> \n<!--- <cflayoutarea name=\"center\" position=\"center\" source=\"map_content.cfm?lat=22.280161&lng=114.185096\"/> --->\n</cflayout> \n"
},
{
"answer_id": 101544,
"author": "Adam Tuttle",
"author_id": 751,
"author_profile": "https://Stackoverflow.com/users/751",
"pm_score": 1,
"selected": false,
"text": "<body>\n Map:<br />\n <div id=\"map_canvas\" style=\"width:500px; height: 300px\"/>\n <script type=\"text/javascript\">\n getMap(22.280161,114.185096);\n </script>\n</body>\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15007/"
] |
80,287
|
<p>I can get easily see what projects and dlls a single project references from within a Visual Studio .NET project.</p>
<p>Is there any application or use of reflection that can build me a full dependency tree that I can use to plot a graphical chart of dependencies?</p>
|
[
{
"answer_id": 10472374,
"author": "Danny Tuppeny",
"author_id": 25124,
"author_profile": "https://Stackoverflow.com/users/25124",
"pm_score": 3,
"selected": false,
"text": "Function Get-ProjectReferences ($rootFolder)\n{\n $projectFiles = Get-ChildItem $rootFolder -Filter *.csproj -Recurse\n $ns = @{ defaultNamespace = \"http://schemas.microsoft.com/developer/msbuild/2003\" }\n\n $projectFiles | ForEach-Object {\n $projectFile = $_ | Select-Object -ExpandProperty FullName\n $projectName = $_ | Select-Object -ExpandProperty BaseName\n $projectXml = [xml](Get-Content $projectFile)\n \n $projectReferences = $projectXml | Select-Xml '//defaultNamespace:ProjectReference/defaultNamespace:Name' -Namespace $ns | Select-Object -ExpandProperty Node | Select-Object -ExpandProperty \"#text\"\n \n $projectReferences | ForEach-Object {\n \"[\" + $projectName + \"] -> [\" + $_ + \"]\"\n }\n }\n}\n\nGet-ProjectReferences \"C:\\Users\\DanTup\\Documents\\MyProject\" | Out-File \"C:\\Users\\DanTup\\Documents\\MyProject\\References.txt\"\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80287",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5302/"
] |
80,291
|
<p>In Sql Server 2000/2005, I have a few NT user groups that need to be granted access to hundreds of stored procedures.</p>
<p>Is there a nice easy way to do that?</p>
|
[
{
"answer_id": 83079,
"author": "Paul G",
"author_id": 162,
"author_profile": "https://Stackoverflow.com/users/162",
"pm_score": 2,
"selected": true,
"text": "DECLARE @DB sysname ; set @DB = DB_NAME()\nDECLARE @U sysname ; set @U = QUOTENAME('UserID')\n\nDECLARE @ID integer,\n @LAST_ID integer,\n @NAME varchar(1000),\n @SQL varchar(4000)\n\nSET @LAST_ID = 0\n\nWHILE @LAST_ID IS NOT NULL\nBEGIN\n SELECT @ID = MIN(id)\n FROM dbo.sysobjects\n WHERE id > @LAST_ID AND type = 'P' AND category = 0\n\n SET @LAST_ID = @ID\n\n -- We have a record so go get the name\n IF @ID IS NOT NULL\n BEGIN\n SELECT @NAME = name\n FROM dbo.sysobjects\n WHERE id = @ID\n\n -- Build the DCL to do the GRANT\n SET @SQL = 'GRANT EXECUTE ON ' + @NAME + ' TO ' + @U\n\n -- Run the SQL Statement you just generated\n EXEC master.dbo.xp_execresultset @SQL, @DB\n\n END \nEND\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3276/"
] |
80,292
|
<p>I was writing a database handler class in PHP using the mysqli class and prepared statements. I was attempting to print out the result. It didn't work right off the bat so I decided to do some debugging. I tried to use the <code>num_rows()</code> method from the <code>mysqli_statement</code> class, but it kept returning 0. I decided to write a small portion of the test code to keep it simpler so I could see what was going wrong. I was then able to return the data I wanted, but the <code>num_rows()</code> method still returns 0 even when it is actually selecting and retrieving some data. Here is the code:</p>
<pre><code>$mysqli = new mysqli('localhost', 'username', 'password', 'database');
if(mysqli_connect_errno())
{
die('connection failed');
}
$statement = $mysqli->stmt_init();
$query = "SELECT name FROM table WHERE id = '2000'";
if($statement->prepare($query))
{
$statement->execute();
$statement->bind_result($name);
$statement->fetch();
$statement->store_result();
echo $statement->num_rows();
echo $name;
}
else
{
echo 'prepare statement failed';
exit();
}
</code></pre>
<p>The expected result is:</p>
<pre><code>1name
</code></pre>
<p>And the actual result is:</p>
<pre><code>0name
</code></pre>
<p>Can anyone tell me why this is?</p>
|
[
{
"answer_id": 80382,
"author": "Cetra",
"author_id": 15087,
"author_profile": "https://Stackoverflow.com/users/15087",
"pm_score": -1,
"selected": false,
"text": "$statement->execute();\n\n$statement->store_result();\n\nprintf(\"Number of rows: %d.\\n\", $statement->num_rows);\n"
},
{
"answer_id": 80400,
"author": "Nathan Strong",
"author_id": 9780,
"author_profile": "https://Stackoverflow.com/users/9780",
"pm_score": 4,
"selected": true,
"text": "if($statement->prepare($query))\n{\n $statement->execute();\n $statement->store_result();\n echo $statement->num_rows();\n $statement->bind_result($name);\n $statement->fetch();\n echo $name; \n}\n"
},
{
"answer_id": 624630,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "num_rows"
},
{
"answer_id": 66500988,
"author": "Dharman",
"author_id": 1839439,
"author_profile": "https://Stackoverflow.com/users/1839439",
"pm_score": 0,
"selected": false,
"text": "mysqli_stmt::num_rows(),"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3831/"
] |
80,307
|
<p>I've read in a couple of places that the desktop wallpaper can be set to an HTML document. Has anyone had any success changing it programmatically? </p>
<p>The following snippet of VB6 helps me set things up for BMPs but when I try to use it for HTML, I get a nice blue background and nothing else.</p>
<pre><code>Dim reg As New StdRegistry
Public Function CurrentWallpaper() As String
CurrentWallpaper = reg.ValueEx(HKEY_CURRENT_USER, "Control Panel\Desktop", "Wallpaper", REG_SZ, "")
End Function
Public Sub SetWallpaper(cFilename As Variant)
reg.ClassKey = HKEY_CURRENT_USER
reg.SectionKey = "Control Panel\Desktop"
reg.ValueKey = "Wallpaper"
reg.ValueType = REG_SZ
reg.Default = ""
reg.Value = cFilename
End Sub
Public Sub RefreshDesktop()
Dim oShell As Object
Set oShell = CreateObject("WScript.Shell")
oShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, True
End Sub
</code></pre>
<p>Perhaps there's some other setting that's required. Any ideas?</p>
|
[
{
"answer_id": 80334,
"author": "Blorgbeard",
"author_id": 369,
"author_profile": "https://Stackoverflow.com/users/369",
"pm_score": 2,
"selected": false,
"text": "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\ForceActiveDesktopOn"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/426/"
] |
80,319
|
<p>I have video durations stored in HH:MM:SS format. I'd like to display it as HH hours, MM minutes, SS seconds. It shouldn't display hours if it's less than 1.</p>
<p>What would be the best approach?</p>
|
[
{
"answer_id": 80366,
"author": "Mladen Mihajlovic",
"author_id": 11421,
"author_profile": "https://Stackoverflow.com/users/11421",
"pm_score": 2,
"selected": false,
"text": "$vals = explode(':', $duration);\n\nif ( $vals[0] == 0 )\n $result = $vals[1] . ' minutes, ' . $vals[2] . ' seconds';\nelse\n $result = $vals[0] . 'hours, ' . $vals[1] . ' minutes, ' . $vals[2] . ' seconds';\n"
},
{
"answer_id": 80380,
"author": "paan",
"author_id": 2976,
"author_profile": "https://Stackoverflow.com/users/2976",
"pm_score": 3,
"selected": true,
"text": "list($hh,$mm,$ss)= split(':',$duration);\n"
},
{
"answer_id": 80389,
"author": "Mladen Mihajlovic",
"author_id": 11421,
"author_profile": "https://Stackoverflow.com/users/11421",
"pm_score": 1,
"selected": false,
"text": "$vals = explode(':', $duration);\n\nif ( $vals[0] == 0 )\n $result = \"{$vals[1]} minutes, {$vals[2]} seconds\";\nelse\n $result = \"{$vals[0]} hours, {$vals[1]} minutes, {$vals[2]} seconds\";\n"
},
{
"answer_id": 80395,
"author": "Garrett Albright",
"author_id": 11023,
"author_profile": "https://Stackoverflow.com/users/11023",
"pm_score": -1,
"selected": false,
"text": "<?php\npreg_match('/^(\\d\\d):(\\d\\d):(\\d\\d)$/', $video_duration, $parts);\nif ($parts[1] !== '00') {\n echo(\"{$parts[1]} hours, {$parts[2]} minutes, {$parts[3]} seconds\");\n}\nelse {\n echo(\"{$parts[2]} minutes, {$parts[3]} seconds\");\n}\n"
},
{
"answer_id": 80442,
"author": "Nathan Strong",
"author_id": 9780,
"author_profile": "https://Stackoverflow.com/users/9780",
"pm_score": 1,
"selected": false,
"text": "list( $h, $m, $s) = explode(':', $hms);\necho ($h ? \"$h hours, \" : \"\").($m ? \"$m minutes, \" : \"\").(($h || $m) ? \"and \" : \"\").\"$s seconds\";\n"
},
{
"answer_id": 80459,
"author": "Steve Obbayi",
"author_id": 11190,
"author_profile": "https://Stackoverflow.com/users/11190",
"pm_score": 0,
"selected": false,
"text": "<?php\n// your time\n$var = \"00:00:00\";\n\nif(substr($var, 0, 2) == 0){\n $myTime = substr_replace(substr_replace($var, '', 0, 3), ' Minutes, ', 2, 1);\n}\nelseif(substr($var, 1, 1) == 1){\n$myTime = substr_replace(substr_replace($var, ' Hour, ', 2, 1), ' Minutes, ', 11, 1); \n }\nelse{\n$myTime = substr_replace(substr_replace($var, ' Hours, ', 2, 1), ' Minutes, ', 12, 1);\n}\n// work with your variable\necho $myTime .' Seconds';\n\n?>\n"
},
{
"answer_id": 80704,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": " date_default_timezone_set('UTC'); \n $date = strtotime($hms,0); \n"
},
{
"answer_id": 80981,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "print gmdate($seconds >= 3600 ? 'H:i:s' : 'i:s', $seconds);"
},
{
"answer_id": 83497,
"author": "enobrev",
"author_id": 14651,
"author_profile": "https://Stackoverflow.com/users/14651",
"pm_score": 1,
"selected": false,
"text": "$sTime = '04:20:00';\n$oTime = new DateTime($sTime);\n$aOutput = array();\nif ($oTime->format('G') > 0) {\n $aOutput[] = $oTime->format('G') . ' hours';\n}\n$aOutput[] = $oTime->format('i') . ' minutes';\n$aOutput[] = $oTime->format('s') . ' seconds';\necho implode(', ', $aOutput);\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
80,348
|
<p>In C++0x I would like to write a function like this:</p>
<pre><code>template <typename... Types>
void fun(typename std::tuple<Types...> my_tuple) {
//Put things into the tuple
}
</code></pre>
<p>I first tried to use a for loop on <code>int i</code> and then do:</p>
<pre><code>get<i>(my_tuple);
</code></pre>
<p>And then store some value in the result. However, <code>get</code> only works on <code>constexpr</code>.</p>
<p>If I could get the variables out of the <code>tuple</code> and pass them to a variadic templated function I could recurse through the arguments very easily, but I have no idea how to get the variables out of the tuple without <code>get</code>. Any ideas on how to do that? Or does anyone have another way of modifying this <code>tuple</code>?</p>
|
[
{
"answer_id": 80573,
"author": "Adam Mitz",
"author_id": 2574,
"author_profile": "https://Stackoverflow.com/users/2574",
"pm_score": 3,
"selected": true,
"text": "get<i>(tup)\n"
},
{
"answer_id": 80687,
"author": "Daniel James",
"author_id": 2434,
"author_profile": "https://Stackoverflow.com/users/2434",
"pm_score": 2,
"selected": false,
"text": "std::pair"
},
{
"answer_id": 103372,
"author": "Timmie Smith",
"author_id": 8405,
"author_profile": "https://Stackoverflow.com/users/8405",
"pm_score": 0,
"selected": false,
"text": "template \nvoid fun(typename std::tuple& my_tuple) {\n //Put things into the tuple\n}"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
80,351
|
<p>I have tried:</p>
<ol>
<li>Xdebug and Eclipse. Eclipse launches a web browser, but the browser tries to access a non-existent file in Eclipse's .app bundle.</li>
<li>Xdebug and NetBeans. It does a little bit better; a browser opens a page in /tmp which says "Launching. Please wait…" but nothing happens beyond that.</li>
<li>Xdebug and debugclient, the CLI tool which comes with Xdebug. MacPorts (which I used to install PHP and Xdebug) doesn't seem to install this by itself, and when I try compiling it by hand, I get told "you have strange libedit". Installing libedit via MacPorts doesn't solve that.</li>
<li>Zend's debugger (the precise name escapes me right now) and Eclipse. I can't recall what the problem was, as this was some time ago, but it didn't work.</li>
</ol>
<p>With regards to Xdebug, at least, I'm fairly confident I've installed it correctly. It shows up with both a phpinfo() in a PHP file and a <code>php -i</code> in the CLI.</p>
<p>If anyone has managed to get PHP debugging working in some way or other on the Mac, I'd appreciate it if you could share with me how. Littering code with <code>var_dump($foo);die();</code> gets old quick. Bonus points if it can be done <em>without</em> using some bloatware editor like Eclipse, or that expensive proprietary thing Zend wants to sell me.</p>
<p>My server is connecting to PHP via FastCGI, if that makes a diff.</p>
|
[
{
"answer_id": 426452,
"author": "Luke Dennis",
"author_id": 24010,
"author_profile": "https://Stackoverflow.com/users/24010",
"pm_score": 4,
"selected": false,
"text": "zend_extension=\"/usr/libexec/xdebug.so\"\nxdebug.remote_enable=1\nxdebug.remote_host=localhost\nxdebug.remote_port=9000\nxdebug.remote_autostart=1\n"
},
{
"answer_id": 38305526,
"author": "Arif Dewi",
"author_id": 2668045,
"author_profile": "https://Stackoverflow.com/users/2668045",
"pm_score": 1,
"selected": false,
"text": "brew install php70 \nbrew install php70-xdebug\n"
},
{
"answer_id": 39327220,
"author": "Aurovrata",
"author_id": 3596672,
"author_profile": "https://Stackoverflow.com/users/3596672",
"pm_score": 0,
"selected": false,
"text": "/Applications/MAMP/bin/php/php5.6.25/conf/php.ini\n/Applications/MAMP/conf/php5.6.25/php.ini\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80351",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11023/"
] |
80,357
|
<p>Is there a quick way to find every match of a regular expression in Ruby? I've looked through the Regex object in the Ruby STL and searched on Google to no avail.</p>
|
[
{
"answer_id": 80387,
"author": "Jean",
"author_id": 7898,
"author_profile": "https://Stackoverflow.com/users/7898",
"pm_score": 11,
"selected": true,
"text": "scan"
},
{
"answer_id": 35964234,
"author": "sudo bangbang",
"author_id": 3951782,
"author_profile": "https://Stackoverflow.com/users/3951782",
"pm_score": 6,
"selected": false,
"text": "scan"
},
{
"answer_id": 36751235,
"author": "MVP",
"author_id": 6231595,
"author_profile": "https://Stackoverflow.com/users/6231595",
"pm_score": 4,
"selected": false,
"text": "str=\"A 54mpl3 string w1th 7 numbers scatter3r ar0und\"\nre=/(\\d+)[m-t]/\n"
},
{
"answer_id": 60586543,
"author": "Datt",
"author_id": 1398515,
"author_profile": "https://Stackoverflow.com/users/1398515",
"pm_score": 3,
"selected": false,
"text": "string.scan(your_regex).flatten"
},
{
"answer_id": 72266342,
"author": "Victor",
"author_id": 7644846,
"author_profile": "https://Stackoverflow.com/users/7644846",
"pm_score": 0,
"selected": false,
"text": "()"
},
{
"answer_id": 73542998,
"author": "some_guy",
"author_id": 4019925,
"author_profile": "https://Stackoverflow.com/users/4019925",
"pm_score": -1,
"selected": false,
"text": "MatchData"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/422/"
] |
80,388
|
<p>I'm trying to trigger a progress animation when ever the ViewModel/Presentation Model is Busy. I have an IsBusy Property, and the ViewModel is set as the DataContext of the UserControl. What is the best way to trigger a "progressAnimation" storyboard when the IsBusy property is true? Blend only lets me add event triggers at the UserControl level, and I can only create property triggers in my data templates.</p>
<p>The "progressAnimation" is defined as a resource in the user control.</p>
<p>I tried adding the DataTriggers as a Style on the UserControl, but when I try to start the StoryBoard I get the following error:</p>
<blockquote>
<p>'System.Windows.Style' value cannot be assigned to property 'Style'
of object'Colorful.Control.SearchPanel'. A Storyboard tree in a Style
cannot specify a TargetName. Remove TargetName 'progressWheel'.</p>
</blockquote>
<p>ProgressWheel is the name of the object I'm trying to animate, so removing the target name is obviously NOT what I want.</p>
<p>I was hoping to solve this in XAML using data binding techniques, instead of having to expose events and start/stop the animation through code.</p>
|
[
{
"answer_id": 81175,
"author": "ligaz",
"author_id": 6409,
"author_profile": "https://Stackoverflow.com/users/6409",
"pm_score": 0,
"selected": false,
"text": "<Trigger Property=\"IsBusy\" Value=\"true\">\n <Trigger.EnterActions>\n <BeginStoryboard x:Name=\"BeginBusy\" Storyboard=\"{StaticResource MyStoryboard}\" />\n </Trigger.EnterActions>\n <Trigger.ExitActions>\n <StopStoryboard BeginStoryboardName=\"BeginBusy\" />\n </Trigger.ExitActions>\n</Trigger>\n"
},
{
"answer_id": 1735810,
"author": "Dabblernl",
"author_id": 108493,
"author_profile": "https://Stackoverflow.com/users/108493",
"pm_score": 7,
"selected": true,
"text": "<UserControl x:Class=\"TriggerSpike.UserControl1\"\nxmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\nxmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\nHeight=\"300\" Width=\"300\">\n<UserControl.Resources>\n <DoubleAnimation x:Key=\"SearchAnimation\" Storyboard.TargetProperty=\"Opacity\" To=\"1\" Duration=\"0:0:4\"/>\n <DoubleAnimation x:Key=\"StopSearchAnimation\" Storyboard.TargetProperty=\"Opacity\" To=\"0\" Duration=\"0:0:4\"/>\n</UserControl.Resources>\n<StackPanel>\n <TextBlock Name=\"progressWheel\" TextAlignment=\"Center\" Opacity=\"0\">\n <TextBlock.Style>\n <Style>\n <Style.Triggers>\n <DataTrigger Binding=\"{Binding IsBusy}\" Value=\"True\">\n <DataTrigger.EnterActions>\n <BeginStoryboard>\n <Storyboard>\n <StaticResource ResourceKey=\"SearchAnimation\"/>\n </Storyboard>\n </BeginStoryboard>\n </DataTrigger.EnterActions>\n <DataTrigger.ExitActions>\n <BeginStoryboard>\n <Storyboard>\n <StaticResource ResourceKey=\"StopSearchAnimation\"/> \n </Storyboard>\n </BeginStoryboard>\n </DataTrigger.ExitActions>\n </DataTrigger>\n </Style.Triggers>\n </Style>\n </TextBlock.Style>\n Searching\n </TextBlock>\n <Label Content=\"Here your search query\"/>\n <TextBox Text=\"{Binding SearchClause}\"/>\n <Button Click=\"Button_Click\">Search!</Button>\n <TextBlock Text=\"{Binding Result}\"/>\n</StackPanel>\n"
},
{
"answer_id": 24774823,
"author": "Ian Griffiths",
"author_id": 497397,
"author_profile": "https://Stackoverflow.com/users/497397",
"pm_score": 4,
"selected": false,
"text": "DataTrigger"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1199387/"
] |
80,415
|
<p>I have a string which starts with <code>//#...</code> goes upto the newline characater. I have figured out the regex for the which is this <code>..#([^\n]*)</code>.</p>
<p>My question is how do you remove this line from a file if the following condition matches</p>
|
[
{
"answer_id": 80498,
"author": "bmb",
"author_id": 5298,
"author_profile": "https://Stackoverflow.com/users/5298",
"pm_score": 0,
"selected": false,
"text": ".."
},
{
"answer_id": 80703,
"author": "Pat",
"author_id": 238,
"author_profile": "https://Stackoverflow.com/users/238",
"pm_score": 0,
"selected": false,
"text": "perl -ne 'print unless m{^//#}' input.txt > output.txt\n"
},
{
"answer_id": 80791,
"author": "Aeon",
"author_id": 13289,
"author_profile": "https://Stackoverflow.com/users/13289",
"pm_score": 1,
"selected": false,
"text": "sed '/^\\/\\/#/d' inputfile > outputfile\n"
},
{
"answer_id": 80853,
"author": "kixx",
"author_id": 11260,
"author_profile": "https://Stackoverflow.com/users/11260",
"pm_score": 3,
"selected": false,
"text": "perl -n -i.orig -e 'print unless /^#/' file1 file2 file3\n"
},
{
"answer_id": 80948,
"author": "Aristotle Pagaltzis",
"author_id": 9410,
"author_profile": "https://Stackoverflow.com/users/9410",
"pm_score": 6,
"selected": true,
"text": ".."
},
{
"answer_id": 81383,
"author": "arclight",
"author_id": 13366,
"author_profile": "https://Stackoverflow.com/users/13366",
"pm_score": 2,
"selected": false,
"text": "//#"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13046/"
] |
80,424
|
<p>I have a few models that need to have custom find conditions placed on them. For example, if I have a Contact model, every time Contact.find is called, I want to restrict the contacts returned that only belong to the Account in use.</p>
<p>I found this via Google (which I've customized a little):</p>
<pre><code>def self.find(*args)
with_scope(:find => { :conditions => "account_id = #{$account.id}" }) do
super(*args)
end
end
</code></pre>
<p>This works great, except for a few occasions where account_id is ambiguous so I adapted it to:</p>
<pre><code>def self.find(*args)
with_scope(:find => { :conditions => "#{self.to_s.downcase.pluralize}.account_id = #{$account.id}" }) do
super(*args)
end
end
</code></pre>
<p>This also works great, however, I want it to be DRY. Now I have a few different models that I want this kind of function to be used. What is the best way to do this?</p>
<p>When you answer, please include the code to help our minds grasp the metaprogramming Ruby-fu.</p>
<p>(I'm using Rails v2.1)</p>
|
[
{
"answer_id": 80440,
"author": "Jean",
"author_id": 7898,
"author_profile": "https://Stackoverflow.com/users/7898",
"pm_score": 4,
"selected": true,
"text": "account.contacts.find(...) \n"
},
{
"answer_id": 80610,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "class Contact\n include NarrowFind\n ...\nend\n"
},
{
"answer_id": 83010,
"author": "Nathan de Vries",
"author_id": 11109,
"author_profile": "https://Stackoverflow.com/users/11109",
"pm_score": 3,
"selected": false,
"text": "class Contact < ActiveRecord::Base\n belongs_to :account\nend\n\nclass Account < ActiveRecord::Base\n has_many :contacts\nend\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80424",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14530/"
] |
80,427
|
<p>Code I have:</p>
<pre><code>cell_val = CStr(Nz(fld.value, ""))
Dim iter As Long
For iter = 0 To Len(cell_val) - 1 Step 1
If Asc(Mid(cell_val, iter, 1)) > 127 Then
addlog "Export contains ascii character > 127"
End If
Next iter
</code></pre>
<p>This code doesn't work. Anyone know how to do this? I've simply got no idea with VB or VBA.</p>
|
[
{
"answer_id": 80457,
"author": "jan.vdbergh",
"author_id": 9540,
"author_profile": "https://Stackoverflow.com/users/9540",
"pm_score": 5,
"selected": true,
"text": "For iter = 1 To Len(cell_val) \n If Asc(Mid(cell_val, iter, 1)) > 127 Then\n addlog \"Export contains ascii character > 127\"\n End If\nNext\n"
},
{
"answer_id": 80472,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 0,
"selected": false,
"text": "For iter = 1 To Len(cell_val)\n"
},
{
"answer_id": 80489,
"author": "vzczc",
"author_id": 224,
"author_profile": "https://Stackoverflow.com/users/224",
"pm_score": 2,
"selected": false,
"text": " Dim cell_val As String\n cell_val = \"øabcdæøå~!#%&/()\"\n Dim iter As Long\n For iter = 1 To Len(cell_val)\n If Asc(Mid(cell_val, iter, 1)) > 127 Then\n 'addlog \"Export contains ascii character > 127\"\n Debug.Print iter, \"Export contains ascii character > 127\"\n End If\n Next iter\n"
},
{
"answer_id": 80531,
"author": "Sam",
"author_id": 9406,
"author_profile": "https://Stackoverflow.com/users/9406",
"pm_score": 2,
"selected": false,
"text": "Dim b() as byte\nDim iter As Long\nb = CStr(Nz(fld.value, \"\"))\n\nFor iter = 0 To UBound(b)\n if b(iter) > 127 then\n addlog \"Export contains ascii character > 127\"\n end if\nnext\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/924607/"
] |
80,447
|
<p>What are futures? It's something to do with lazy evaluation.</p>
|
[
{
"answer_id": 80519,
"author": "Motti",
"author_id": 3848,
"author_profile": "https://Stackoverflow.com/users/3848",
"pm_score": 3,
"selected": false,
"text": "int add(int i, int j) { return i + j; }\n// first calculate both Nth_prime results then pass them to add\nint sum = add(Nth_prime(4), Nth_prime(2)); \n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
80,476
|
<p>I need to concatenate two <code>String</code> arrays in Java.</p>
<pre><code>void f(String[] first, String[] second) {
String[] both = ???
}
</code></pre>
<p>Which is the easiest way to do this?</p>
|
[
{
"answer_id": 80503,
"author": "jeannicolas",
"author_id": 14981,
"author_profile": "https://Stackoverflow.com/users/14981",
"pm_score": 10,
"selected": false,
"text": "public <T> T[] concatenate(T[] a, T[] b) {\n int aLen = a.length;\n int bLen = b.length;\n\n @SuppressWarnings(\"unchecked\")\n T[] c = (T[]) Array.newInstance(a.getClass().getComponentType(), aLen + bLen);\n System.arraycopy(a, 0, c, 0, aLen);\n System.arraycopy(b, 0, c, aLen, bLen);\n\n return c;\n}\n"
},
{
"answer_id": 80559,
"author": "Antti Kissaniemi",
"author_id": 2948,
"author_profile": "https://Stackoverflow.com/users/2948",
"pm_score": 10,
"selected": false,
"text": "ArrayUtils.addAll(T[], T...)"
},
{
"answer_id": 80621,
"author": "Apocalisp",
"author_id": 3434,
"author_profile": "https://Stackoverflow.com/users/3434",
"pm_score": 5,
"selected": false,
"text": "import static fj.data.Array.array;\n"
},
{
"answer_id": 80977,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "\nString[] join(String[]... arrays) {\n // calculate size of target array\n int size = 0;\n for (String[] array : arrays) {\n size += array.length;\n }\n\n // create list of appropriate size\n java.util.List list = new java.util.ArrayList(size);\n\n // add arrays\n for (String[] array : arrays) {\n list.addAll(java.util.Arrays.asList(array));\n }\n\n // create and return final array\n return list.toArray(new String[size]);\n}\n"
},
{
"answer_id": 85216,
"author": "volley",
"author_id": 13905,
"author_profile": "https://Stackoverflow.com/users/13905",
"pm_score": 4,
"selected": false,
"text": "static <T> T[] concat(T[] a, T[] b) {\n final int alen = a.length;\n final int blen = b.length;\n final T[] result = (T[]) java.lang.reflect.Array.\n newInstance(a.getClass().getComponentType(), alen + blen);\n System.arraycopy(a, 0, result, 0, alen);\n System.arraycopy(b, 0, result, alen, blen);\n return result;\n}\n"
},
{
"answer_id": 85266,
"author": "volley",
"author_id": 13905,
"author_profile": "https://Stackoverflow.com/users/13905",
"pm_score": 5,
"selected": false,
"text": "private static <T> T[] concatOrReturnSame(T[] a, T[] b) {\n final int alen = a.length;\n final int blen = b.length;\n if (alen == 0) {\n return b;\n }\n if (blen == 0) {\n return a;\n }\n final T[] result = (T[]) java.lang.reflect.Array.\n newInstance(a.getClass().getComponentType(), alen + blen);\n System.arraycopy(a, 0, result, 0, alen);\n System.arraycopy(b, 0, result, alen, blen);\n return result;\n}\n"
},
{
"answer_id": 96892,
"author": "Fabian Steeg",
"author_id": 18154,
"author_profile": "https://Stackoverflow.com/users/18154",
"pm_score": 6,
"selected": false,
"text": "String[] f(String[] first, String[] second) {\n List<String> both = new ArrayList<String>(first.length + second.length);\n Collections.addAll(both, first);\n Collections.addAll(both, second);\n return both.toArray(new String[both.size()]);\n}\n"
},
{
"answer_id": 135237,
"author": "Bob Cross",
"author_id": 5812,
"author_profile": "https://Stackoverflow.com/users/5812",
"pm_score": 2,
"selected": false,
"text": "public final String [] f(final String [] first, final String [] second) {\n // Assuming non-null for brevity.\n final ArrayList<String> resultList = new ArrayList<String>(Arrays.asList(first));\n resultList.addAll(new ArrayList<String>(Arrays.asList(second)));\n return resultList.toArray(new String [resultList.size()]);\n}\n"
},
{
"answer_id": 707558,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "public void testConcatArrayString(){\n String[] a = null;\n String[] b = null;\n String[] c = null;\n a = new String[] {\"1\",\"2\",\"3\",\"4\",\"5\"};\n b = new String[] {\"A\",\"B\",\"C\",\"D\",\"E\"};\n\n c = (String[]) ArrayUtils.addAll(a, b);\n if(c!=null){\n for(int i=0; i<c.length; i++){\n System.out.println(\"c[\" + (i+1) + \"] = \" + c[i]);\n }\n }\n}\n"
},
{
"answer_id": 784813,
"author": "glue",
"author_id": 94685,
"author_profile": "https://Stackoverflow.com/users/94685",
"pm_score": 3,
"selected": false,
"text": "public class StringConcatenate {\n\n public static void main(String[] args){\n\n // Create two arrays to concatenate and one array to hold both\n String[] arr1 = new String[]{\"s\",\"t\",\"r\",\"i\",\"n\",\"g\"};\n String[] arr2 = new String[]{\"s\",\"t\",\"r\",\"i\",\"n\",\"g\"};\n String[] arrBoth = new String[arr1.length+arr2.length];\n\n // Copy elements from first array into first part of new array\n for(int i = 0; i < arr1.length; i++){\n arrBoth[i] = arr1[i];\n }\n\n // Copy elements from second array into last part of new array\n for(int j = arr1.length;j < arrBoth.length;j++){\n arrBoth[j] = arr2[j-arr1.length];\n }\n\n // Print result\n for(int k = 0; k < arrBoth.length; k++){\n System.out.print(arrBoth[k]);\n }\n\n // Additional line to make your terminal look better at completion!\n System.out.println();\n }\n}\n"
},
{
"answer_id": 784842,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 9,
"selected": false,
"text": "Arrays.copyOf()"
},
{
"answer_id": 786450,
"author": "MetroidFan2002",
"author_id": 8026,
"author_profile": "https://Stackoverflow.com/users/8026",
"pm_score": 2,
"selected": false,
"text": "ArrayList baseArray = new ArrayList(Arrays.asList(array1));\nbaseArray.addAll(Arrays.asList(array2));\nString concatenated[] = (String []) baseArray.toArray(new String[baseArray.size()]);\n"
},
{
"answer_id": 1012285,
"author": "Damo",
"author_id": 2955,
"author_profile": "https://Stackoverflow.com/users/2955",
"pm_score": 3,
"selected": false,
"text": "public static String[] join(String[]...arrays) {\n\n final List<String> output = new ArrayList<String>();\n\n for(String[] array : arrays) {\n output.addAll(Arrays.asList(array));\n }\n\n return output.toArray(new String[output.size()]);\n}\n"
},
{
"answer_id": 1012309,
"author": "Damo",
"author_id": 2955,
"author_profile": "https://Stackoverflow.com/users/2955",
"pm_score": 2,
"selected": false,
"text": "@SuppressWarnings(\"unchecked\")\npublic static <T> T[] join(T[]...arrays) {\n\n final List<T> output = new ArrayList<T>();\n\n for(T[] array : arrays) {\n output.addAll(Arrays.asList(array));\n }\n\n return output.toArray((T[])Array.newInstance(\n arrays[0].getClass().getComponentType(), output.size()));\n}\n"
},
{
"answer_id": 4552278,
"author": "Sujay",
"author_id": 556856,
"author_profile": "https://Stackoverflow.com/users/556856",
"pm_score": 2,
"selected": false,
"text": "public String[] concat(String[]... arrays)\n{\n int length = 0;\n for (String[] array : arrays) {\n length += array.length;\n }\n String[] result = new String[length];\n int destPos = 0;\n for (String[] array : arrays) {\n System.arraycopy(array, 0, result, destPos, array.length);\n destPos += array.length;\n }\n return result;\n}\n"
},
{
"answer_id": 4574691,
"author": "Doug",
"author_id": 543770,
"author_profile": "https://Stackoverflow.com/users/543770",
"pm_score": 2,
"selected": false,
"text": "private byte[] concat(byte[]... args)\n{\n int fulllength = 0;\n for (byte[] arrItem : args)\n {\n fulllength += arrItem.length;\n }\n byte[] retArray = new byte[fulllength];\n int start = 0;\n for (byte[] arrItem : args)\n {\n System.arraycopy(arrItem, 0, retArray, start, arrItem.length);\n start += arrItem.length;\n }\n return retArray;\n}\n"
},
{
"answer_id": 5247896,
"author": "KARASZI István",
"author_id": 221213,
"author_profile": "https://Stackoverflow.com/users/221213",
"pm_score": 8,
"selected": false,
"text": "String[] both = ObjectArrays.concat(first, second, String.class);\n"
},
{
"answer_id": 5497557,
"author": "Adham",
"author_id": 671613,
"author_profile": "https://Stackoverflow.com/users/671613",
"pm_score": 0,
"selected": false,
"text": "Object[] obj = {\"hi\",\"there\"};\nObject[] obj2 ={\"im\",\"fine\",\"what abt u\"};\nObject[] obj3 = new Object[obj.length+obj2.length];\n\nfor(int i =0;i<obj3.length;i++)\n obj3[i] = (i<obj.length)?obj[i]:obj2[i-obj.length];\n"
},
{
"answer_id": 6295624,
"author": "candrews",
"author_id": 791247,
"author_profile": "https://Stackoverflow.com/users/791247",
"pm_score": 2,
"selected": false,
"text": " public static <T> T[] concatAll(T[] first, T[]... rest) {\n int totalLength = first.length;\n for (T[] array : rest) {\n totalLength += array.length;\n }\n T[] result;\n try {\n Method arraysCopyOf = Arrays.class.getMethod(\"copyOf\", Object[].class, int.class);\n result = (T[]) arraysCopyOf.invoke(null, first, totalLength);\n } catch (Exception e){\n //Java 6 / Android >= 9 way didn't work, so use the \"traditional\" approach\n result = (T[]) java.lang.reflect.Array.newInstance(first.getClass().getComponentType(), totalLength);\n System.arraycopy(first, 0, result, 0, first.length);\n }\n int offset = first.length;\n for (T[] array : rest) {\n System.arraycopy(array, 0, result, offset, array.length);\n offset += array.length;\n }\n return result;\n }\n"
},
{
"answer_id": 6301908,
"author": "Muhammad Haris Altaf",
"author_id": 789261,
"author_profile": "https://Stackoverflow.com/users/789261",
"pm_score": 0,
"selected": false,
"text": "\nList allFiltersList = Arrays.asList(regularFilters);\nallFiltersList.addAll(Arrays.asList(preFiltersArray));\nFilter[] mergedFilterArray = (Filter[]) allFiltersList.toArray();\n"
},
{
"answer_id": 6318217,
"author": "Oritm",
"author_id": 574736,
"author_profile": "https://Stackoverflow.com/users/574736",
"pm_score": 3,
"selected": false,
"text": "public String[] mergeArrays(String[] mainArray, String[] addArray) {\n String[] finalArray = new String[mainArray.length + addArray.length];\n System.arraycopy(mainArray, 0, finalArray, 0, mainArray.length);\n System.arraycopy(addArray, 0, finalArray, mainArray.length, addArray.length);\n\n return finalArray;\n}\n"
},
{
"answer_id": 6691787,
"author": "Jeroen",
"author_id": 844342,
"author_profile": "https://Stackoverflow.com/users/844342",
"pm_score": 2,
"selected": false,
"text": "Import java.util.*;\n\nString array1[] = {\"bla\",\"bla\"};\nString array2[] = {\"bla\",\"bla\"};\n\nArrayList<String> tempArray = new ArrayList<String>(Arrays.asList(array1));\ntempArray.addAll(Arrays.asList(array2));\nString array3[] = films.toArray(new String[1]); // size will be overwritten if needed\n"
},
{
"answer_id": 6777237,
"author": "Sushim ",
"author_id": 856097,
"author_profile": "https://Stackoverflow.com/users/856097",
"pm_score": 0,
"selected": false,
"text": " public static Object[] addTwoArray(Object[] objArr1, Object[] objArr2){\n int arr1Length = objArr1!=null && objArr1.length>0?objArr1.length:0;\n int arr2Length = objArr2!=null && objArr2.length>0?objArr2.length:0;\n Object[] resutlentArray = new Object[arr1Length+arr2Length]; \n for(int i=0,j=0;i<resutlentArray.length;i++){\n if(i+1<=arr1Length){\n resutlentArray[i]=objArr1[i];\n }else{\n resutlentArray[i]=objArr2[j];\n j++;\n }\n }\n\n return resutlentArray;\n}\n"
},
{
"answer_id": 7724875,
"author": "francois",
"author_id": 989332,
"author_profile": "https://Stackoverflow.com/users/989332",
"pm_score": 5,
"selected": false,
"text": "System.arraycopy"
},
{
"answer_id": 7733971,
"author": "Ephraim",
"author_id": 432499,
"author_profile": "https://Stackoverflow.com/users/432499",
"pm_score": 3,
"selected": false,
"text": "public static class Array {\n\n public static <T> T[] concat(T[]... arrays) {\n ArrayList<T> al = new ArrayList<T>();\n for (T[] one : arrays)\n Collections.addAll(al, one);\n return (T[]) al.toArray(arrays[0].clone());\n }\n}\n"
},
{
"answer_id": 8728568,
"author": "hpgisler",
"author_id": 757684,
"author_profile": "https://Stackoverflow.com/users/757684",
"pm_score": 3,
"selected": false,
"text": "public class Array {\n\n public static <T> T[] concat(T[] a, T[] b, ArrayBuilderI<T> builder) {\n T[] c = builder.build(a.length + b.length);\n System.arraycopy(a, 0, c, 0, a.length);\n System.arraycopy(b, 0, c, a.length, b.length);\n return c;\n }\n}\n"
},
{
"answer_id": 9512746,
"author": "Jerome",
"author_id": 811865,
"author_profile": "https://Stackoverflow.com/users/811865",
"pm_score": -1,
"selected": false,
"text": "[a, b, c] ++ [d, e]"
},
{
"answer_id": 10056834,
"author": "filosofem",
"author_id": 1319411,
"author_profile": "https://Stackoverflow.com/users/1319411",
"pm_score": -1,
"selected": false,
"text": "private static void concatArrays(char[] destination, char[]... sources) {\n int currPos = 0;\n for (char[] source : sources) {\n int length = source.length;\n System.arraycopy(source, 0, destination, currPos, length);\n currPos += length;\n }\n}\n"
},
{
"answer_id": 10382513,
"author": "user462990",
"author_id": 462990,
"author_profile": "https://Stackoverflow.com/users/462990",
"pm_score": 2,
"selected": false,
"text": "private double[] concat (double[]a,double[]b){\n if (a == null) return b;\n if (b == null) return a;\n double[] r = new double[a.length+b.length];\n System.arraycopy(a, 0, r, 0, a.length);\n System.arraycopy(b, 0, r, a.length, b.length);\n return r;\n\n}\nprivate double[] copyRest (double[]a, int start){\n if (a == null) return null;\n if (start > a.length)return null;\n double[]r = new double[a.length-start];\n System.arraycopy(a,start,r,0,a.length-start); \n return r;\n}\n"
},
{
"answer_id": 11470232,
"author": "Reto Höhener",
"author_id": 1124509,
"author_profile": "https://Stackoverflow.com/users/1124509",
"pm_score": 4,
"selected": false,
"text": "@SuppressWarnings(\"unchecked\")\npublic static <T> T[] concat(T[]... inputArrays) {\n if(inputArrays.length < 2) {\n throw new IllegalArgumentException(\"inputArrays must contain at least 2 arrays\");\n }\n\n for(int i = 0; i < inputArrays.length; i++) {\n if(inputArrays[i] == null) {\n throw new IllegalArgumentException(\"inputArrays[\" + i + \"] is null\");\n }\n }\n\n int totalLength = 0;\n\n for(T[] array : inputArrays) {\n totalLength += array.length;\n }\n\n T[] result = (T[]) Array.newInstance(inputArrays[0].getClass().getComponentType(), totalLength);\n\n int offset = 0;\n\n for(T[] array : inputArrays) {\n System.arraycopy(array, 0, result, offset, array.length);\n\n offset += array.length;\n }\n\n return result;\n}\n"
},
{
"answer_id": 13112678,
"author": "doles",
"author_id": 1118233,
"author_profile": "https://Stackoverflow.com/users/1118233",
"pm_score": 3,
"selected": false,
"text": "String [] arg1 = new String{\"a\",\"b\",\"c\"};\nString [] arg2 = new String{\"x\",\"y\",\"z\"};\n\nArrayList<String> temp = new ArrayList<String>();\ntemp.addAll(Arrays.asList(arg1));\ntemp.addAll(Arrays.asList(arg2));\nString [] concatedArgs = temp.toArray(new String[arg1.length+arg2.length]);\n"
},
{
"answer_id": 15103456,
"author": "Earth Engine",
"author_id": 812034,
"author_profile": "https://Stackoverflow.com/users/812034",
"pm_score": 2,
"selected": false,
"text": "List<T>"
},
{
"answer_id": 17235840,
"author": "Frimousse",
"author_id": 2509077,
"author_profile": "https://Stackoverflow.com/users/2509077",
"pm_score": 2,
"selected": false,
"text": "String [] both = new ArrayList<String>(){{addAll(Arrays.asList(first)); addAll(Arrays.asList(second));}}.toArray(new String[0]);\n"
},
{
"answer_id": 18350255,
"author": "h-rai",
"author_id": 1109689,
"author_profile": "https://Stackoverflow.com/users/1109689",
"pm_score": 5,
"selected": false,
"text": "ArrayList<String> both = new ArrayList(Arrays.asList(first));\nboth.addAll(Arrays.asList(second));\n\nboth.toArray(new String[0]);\n"
},
{
"answer_id": 19666913,
"author": "SuperCamp",
"author_id": 2782483,
"author_profile": "https://Stackoverflow.com/users/2782483",
"pm_score": -1,
"selected": false,
"text": "List<String> myList = new ArrayList<String>(Arrays.asList(first));\nmyList.addAll(new ArrayList<String>(Arrays.asList(second)));\nString[] both = myList.toArray(new String[myList.size()]);\n"
},
{
"answer_id": 20903551,
"author": "Ricardo Vallejo",
"author_id": 3144146,
"author_profile": "https://Stackoverflow.com/users/3144146",
"pm_score": 0,
"selected": false,
"text": "public static int[] junta(int[] v, int[] w) {\n\nint[] junta = new int[v.length + w.length];\n\nfor (int i = 0; i < v.length; i++) { \n junta[i] = v[i];\n}\n\nfor (int j = v.length; j < junta.length; j++) {\n junta[j] = w[j - v.length];\n}\n"
},
{
"answer_id": 23188881,
"author": "Vitalii Fedorenko",
"author_id": 288671,
"author_profile": "https://Stackoverflow.com/users/288671",
"pm_score": 9,
"selected": false,
"text": "Stream"
},
{
"answer_id": 25026341,
"author": "spacebiker",
"author_id": 1114732,
"author_profile": "https://Stackoverflow.com/users/1114732",
"pm_score": 2,
"selected": false,
"text": "/* This for non primitive types */\npublic static <T> T[] concatenate (T[]... elements) {\n\n T[] C = null;\n for (T[] element: elements) {\n if (element==null) continue;\n if (C==null) C = (T[]) Array.newInstance(element.getClass().getComponentType(), element.length);\n else C = resizeArray(C, C.length+element.length);\n\n System.arraycopy(element, 0, C, C.length-element.length, element.length);\n }\n\n return C;\n}\n\n/**\n * as far as i know, primitive types do not accept generics \n * http://stackoverflow.com/questions/2721546/why-dont-java-generics-support-primitive-types\n * for primitive types we could do something like this:\n * */\npublic static int[] concatenate (int[]... elements){\n int[] C = null;\n for (int[] element: elements) {\n if (element==null) continue;\n if (C==null) C = new int[element.length];\n else C = resizeArray(C, C.length+element.length);\n\n System.arraycopy(element, 0, C, C.length-element.length, element.length);\n }\n return C;\n}\n\nprivate static <T> T resizeArray (T array, int newSize) {\n int oldSize =\n java.lang.reflect.Array.getLength(array);\n Class elementType =\n array.getClass().getComponentType();\n Object newArray =\n java.lang.reflect.Array.newInstance(\n elementType, newSize);\n int preserveLength = Math.min(oldSize, newSize);\n if (preserveLength > 0)\n System.arraycopy(array, 0,\n newArray, 0, preserveLength);\n return (T) newArray;\n}\n"
},
{
"answer_id": 28466684,
"author": "clément francomme",
"author_id": 4151755,
"author_profile": "https://Stackoverflow.com/users/4151755",
"pm_score": 2,
"selected": false,
"text": "public String[] combineArray (String[] ... strings) {\n List<String> tmpList = new ArrayList<String>();\n for (int i = 0; i < strings.length; i++)\n tmpList.addAll(Arrays.asList(strings[i]));\n return tmpList.toArray(new String[tmpList.size()]);\n}\n"
},
{
"answer_id": 33018648,
"author": "George",
"author_id": 791195,
"author_profile": "https://Stackoverflow.com/users/791195",
"pm_score": 1,
"selected": false,
"text": "public int[] mergeArrays(int [] a, int [] b) {\n int [] merged = new int[a.length + b.length];\n int i = 0, k = 0, l = a.length;\n int j = a.length > b.length ? a.length : b.length;\n while(i < j) {\n if(k < a.length) {\n merged[k] = a[k];\n k++;\n }\n if((l - a.length) < b.length) {\n merged[l] = b[l - a.length];\n l++;\n }\n i++;\n }\n return merged;\n}\n"
},
{
"answer_id": 33711992,
"author": "Paul",
"author_id": 4908555,
"author_profile": "https://Stackoverflow.com/users/4908555",
"pm_score": 4,
"selected": false,
"text": "ArrayList"
},
{
"answer_id": 35315750,
"author": "Vaseph",
"author_id": 1912860,
"author_profile": "https://Stackoverflow.com/users/1912860",
"pm_score": 4,
"selected": false,
"text": " public String[] concatString(String[] a, String[] b){ \n Stream<String> streamA = Arrays.stream(a);\n Stream<String> streamB = Arrays.stream(b);\n return Stream.concat(streamA, streamB).toArray(String[]::new); \n }\n"
},
{
"answer_id": 35644035,
"author": "Kamil Tomasz Jarmusik",
"author_id": 5642475,
"author_profile": "https://Stackoverflow.com/users/5642475",
"pm_score": 2,
"selected": false,
"text": "public static String[] toArray(String[]... object){\n List<String> list=new ArrayList<>();\n for (String[] i : object) {\n list.addAll(Arrays.asList(i));\n }\n return list.toArray(new String[list.size()]);\n}\n"
},
{
"answer_id": 38448403,
"author": "obwan02",
"author_id": 6554496,
"author_profile": "https://Stackoverflow.com/users/6554496",
"pm_score": 0,
"selected": false,
"text": "Object[] mixArray(String[] a, String[] b)\nString[] s1 = a;\nString[] s2 = b;\nObject[] result;\nList<String> input = new ArrayList<String>();\nfor (int i = 0; i < s1.length; i++)\n{\n input.add(s1[i]);\n}\nfor (int i = 0; i < s2.length; i++)\n{\n input.add(s2[i]);\n}\nresult = input.toArray();\nreturn result;\n"
},
{
"answer_id": 39322165,
"author": "Douglas Held",
"author_id": 399723,
"author_profile": "https://Stackoverflow.com/users/399723",
"pm_score": 2,
"selected": false,
"text": "// I have arrayA and arrayB; would like to treat them as concatenated\n// but leave my damn bytes where they are!\nObject accessElement ( int index ) {\n if ( index < 0 ) throw new ArrayIndexOutOfBoundsException(...);\n // is reading from the head part?\n if ( index < arrayA.length )\n return arrayA[ index ];\n // is reading from the tail part?\n if ( index < ( arrayA.length + arrayB.length ) )\n return arrayB[ index - arrayA.length ];\n throw new ArrayIndexOutOfBoundsException(...); // index too large\n}\n"
},
{
"answer_id": 40855217,
"author": "user_3380739",
"author_id": 3380739,
"author_profile": "https://Stackoverflow.com/users/3380739",
"pm_score": 2,
"selected": false,
"text": "String[] a = {\"a\", \"b\", \"c\"};\nString[] b = {\"1\", \"2\", \"3\"};\nString[] c = N.concat(a, b); // c = [\"a\", \"b\", \"c\", \"1\", \"2\", \"3\"]\n\n// N.concat(...) is null-safety.\na = null;\nc = N.concat(a, b); // c = [\"1\", \"2\", \"3\"]\n"
},
{
"answer_id": 40991067,
"author": "Yashovardhan99",
"author_id": 7252861,
"author_profile": "https://Stackoverflow.com/users/7252861",
"pm_score": -1,
"selected": false,
"text": " void f(String[] first, String[] second) {\n String[] both = new String[first.length+second.length];\n for(int i=0;i<first.length;i++)\n both[i] = first[i];\n for(int i=0;i<second.length;i++)\n both[first.length + i] = second[i];\n}\n"
},
{
"answer_id": 42201601,
"author": "Raj S. Rusia",
"author_id": 7178104,
"author_profile": "https://Stackoverflow.com/users/7178104",
"pm_score": 4,
"selected": false,
"text": "String"
},
{
"answer_id": 46542530,
"author": "c-chavez",
"author_id": 1042409,
"author_profile": "https://Stackoverflow.com/users/1042409",
"pm_score": 0,
"selected": false,
"text": "public static String[] mergeArrays(String[] array1, String[] array2) {\n int totalSize = array1.length + array2.length; // Get total size\n String[] merged = new String[totalSize]; // Create new array\n // Loop over the total size\n for (int i = 0; i < totalSize; i++) {\n if (i < array1.length) // If the current position is less than the length of the first array, take value from first array\n merged[i] = array1[i]; // Position in first array is the current position\n\n else // If current position is equal or greater than the first array, take value from second array.\n merged[i] = array2[i - array1.length]; // Position in second array is current position minus length of first array.\n }\n\n return merged;\n"
},
{
"answer_id": 46972713,
"author": "Hakim",
"author_id": 4800139,
"author_profile": "https://Stackoverflow.com/users/4800139",
"pm_score": 0,
"selected": false,
"text": "public static <T> T[] concatMultipleArrays(T[]... arrays)\n{\n int length = 0;\n for (T[] array : arrays)\n {\n length += array.length;\n }\n T[] result = (T[]) Array.newInstance(arrays.getClass().getComponentType(), length) ;\n\n length = 0;\n for (int i = 0; i < arrays.length; i++)\n {\n System.arraycopy(arrays[i], 0, result, length, arrays[i].length);\n length += arrays[i].length;\n }\n\n return result;\n}\n"
},
{
"answer_id": 49772469,
"author": "rghome",
"author_id": 3800782,
"author_profile": "https://Stackoverflow.com/users/3800782",
"pm_score": 7,
"selected": false,
"text": "String[] both = Arrays.copyOf(first, first.length + second.length);\nSystem.arraycopy(second, 0, both, first.length, second.length);\n"
},
{
"answer_id": 49793485,
"author": "Basil Battikhi",
"author_id": 2901129,
"author_profile": "https://Stackoverflow.com/users/2901129",
"pm_score": 0,
"selected": false,
"text": "public String[] concat(String[] arr1, String[] arr2){\n Stream<String> stream1 = Stream.of(arr1);\n Stream<String> stream2 = Stream.of(arr2);\n Stream<String> stream = Stream.concat(stream1, stream2);\n return Arrays.toString(stream.toArray(String[]::new));\n}\n"
},
{
"answer_id": 52375659,
"author": "BrownRecluse",
"author_id": 5143356,
"author_profile": "https://Stackoverflow.com/users/5143356",
"pm_score": 1,
"selected": false,
"text": "public static int[] combineArrays(int[] a, int[] b) {\n int[] c = new int[a.length + b.length];\n\n for (int i = 0; i < a.length; i++) {\n c[i] = a[i];\n }\n\n for (int j = 0, k = a.length; j < b.length; j++, k++) {\n c[k] = b[j];\n }\n\n return c;\n }\n"
},
{
"answer_id": 52950353,
"author": "keisar",
"author_id": 1344070,
"author_profile": "https://Stackoverflow.com/users/1344070",
"pm_score": 4,
"selected": false,
"text": "private static String[] concatArrays(final String[]... arrays) {\n return Arrays.stream(arrays)\n .flatMap(Arrays::stream)\n .toArray(String[]::new);\n}\n"
},
{
"answer_id": 53025243,
"author": "avigaild",
"author_id": 10567980,
"author_profile": "https://Stackoverflow.com/users/10567980",
"pm_score": 3,
"selected": false,
"text": "public String [] concatenate (final String array1[], final String array2[])\n{\n return Stream.concat(Stream.of(array1), Stream.of(array2)).toArray(String[]::new);\n}\n"
},
{
"answer_id": 53181401,
"author": "beaudet",
"author_id": 2730420,
"author_profile": "https://Stackoverflow.com/users/2730420",
"pm_score": 3,
"selected": false,
"text": "public static <T> T[] arrayConcat(T[] a, T[] b) {\n T[] both = Arrays.copyOf(a, a.length + b.length);\n System.arraycopy(b, 0, both, a.length, b.length);\n return both;\n}\n"
},
{
"answer_id": 55320708,
"author": "ZhekaKozlov",
"author_id": 706317,
"author_profile": "https://Stackoverflow.com/users/706317",
"pm_score": 2,
"selected": false,
"text": "public class ArrayConcatenator<T> {\n private final IntFunction<T[]> generator;\n\n private ArrayConcatenator(IntFunction<T[]> generator) {\n this.generator = generator;\n }\n\n public static <T> ArrayConcatenator<T> concat(IntFunction<T[]> generator) {\n return new ArrayConcatenator<>(generator);\n }\n\n public T[] apply(T[] array1, T[] array2) {\n T[] array = generator.apply(array1.length + array2.length);\n System.arraycopy(array1, 0, array, 0, array1.length);\n System.arraycopy(array2, 0, array, array1.length, array2.length);\n return array;\n }\n}\n"
},
{
"answer_id": 58587509,
"author": "Kaplan",
"author_id": 11199879,
"author_profile": "https://Stackoverflow.com/users/11199879",
"pm_score": 0,
"selected": false,
"text": "@SafeVarargs\npublic static <T> T[] concat( T[]... arrays ) {\n return( Stream.of( arrays ).reduce( ( arr1, arr2 ) -> {\n T[] rslt = Arrays.copyOf( arr1, arr1.length + arr2.length );\n System.arraycopy( arr2, 0, rslt, arr1.length, arr2.length );\n return( rslt );\n } ).orElse( null ) );\n};\n"
},
{
"answer_id": 60017520,
"author": "JGFMK",
"author_id": 495157,
"author_profile": "https://Stackoverflow.com/users/495157",
"pm_score": 0,
"selected": false,
"text": "System.arraycopy"
},
{
"answer_id": 60188847,
"author": "Areeha",
"author_id": 6834039,
"author_profile": "https://Stackoverflow.com/users/6834039",
"pm_score": -1,
"selected": false,
"text": "String[] data=null;\nString[] data2=null;\nArrayList<String> data1 = new ArrayList<String>();\nfor(int i=0; i<2;i++) {\n data2 = input.readLine().split(\",\");\n data1.addAll(Arrays.asList(data2));\n data= data1.toArray(new String[data1.size()]);\n }\n"
},
{
"answer_id": 65484015,
"author": "Oleksandr Tsurika",
"author_id": 1663094,
"author_profile": "https://Stackoverflow.com/users/1663094",
"pm_score": 0,
"selected": false,
"text": "public static <G> G[] concatenate(IntFunction<G[]> generator, G[] ... arrays) {\n int len = arrays.length;\n if (len == 0) {\n return generator.apply(0);\n } else if (len == 1) {\n return arrays[0];\n }\n int pos = 0;\n Stream<G> result = Stream.concat(Arrays.stream(arrays[pos]), Arrays.stream(arrays[++pos]));\n while (pos < len - 1) {\n result = Stream.concat(result, Arrays.stream(arrays[++pos]));\n }\n return result.toArray(generator);\n}\n"
},
{
"answer_id": 65727399,
"author": "rizesky",
"author_id": 6324746,
"author_profile": "https://Stackoverflow.com/users/6324746",
"pm_score": 0,
"selected": false,
"text": "public String[] concat(String[] firstArr,String[] secondArr){\n //if both is empty just return\n if(firstArr.length==0 && secondArr.length==0)return new String[0];\n\n String[] res = new String[firstArr.length+secondArr.length];\n int idxFromFirst=0;\n\n //loop over firstArr, idxFromFirst will be used as starting offset for secondArr\n for(int i=0;i<firstArr.length;i++){\n res[i] = firstArr[i];\n idxFromFirst++;\n }\n\n //loop over secondArr, with starting offset idxFromFirst (the offset track from first array)\n for(int i=0;i<secondArr.length;i++){\n res[idxFromFirst+i]=secondArr[i];\n }\n\n return res;\n }\n"
},
{
"answer_id": 67960387,
"author": "Lakshitha Kanchana",
"author_id": 6696702,
"author_profile": "https://Stackoverflow.com/users/6696702",
"pm_score": 0,
"selected": false,
"text": "String[] f(String[] first, String[] second) {\n\n // Variable declaration part\n int len1 = first.length;\n int len2 = second.length;\n int lenNew = len1 + len2;\n String[] both = new String[len1+len2];\n\n // For loop to fill the array \"both\"\n for (int i=0 ; i<lenNew ; i++){\n if (i<len1) {\n both[i] = first[i];\n } else {\n both[i] = second[i-len1];\n }\n }\n\n return both;\n\n}\n"
},
{
"answer_id": 69157437,
"author": "Rajesh Patel",
"author_id": 7866838,
"author_profile": "https://Stackoverflow.com/users/7866838",
"pm_score": 0,
"selected": false,
"text": "static <T> T[] concatWithCollection(T[] array1, T[] array2) {\n List<T> resultList = new ArrayList<>(array1.length + array2.length);\n Collections.addAll(resultList, array1);\n Collections.addAll(resultList, array2);\n\n @SuppressWarnings(\"unchecked\")\n //the type cast is safe as the array1 has the type T[]\n T[] resultArray = (T[]) Array.newInstance(array1.getClass().getComponentType(), 0);\n return resultList.toArray(resultArray);\n}\n"
},
{
"answer_id": 71449230,
"author": "mkemper",
"author_id": 14763038,
"author_profile": "https://Stackoverflow.com/users/14763038",
"pm_score": 0,
"selected": false,
"text": "public static <T> T concat(T a, T b) {\n //Handles both arrays of Objects and primitives! E.g., int[] out = concat(new int[]{6,7,8}, new int[]{9,10});\n //You get a compile error if argument(s) not same type as output. (int[] in example above)\n //You get a runtime error if output type is not an array, i.e., when you do something like: int out = concat(6,7);\n if (a == null && b == null) return null;\n if (a == null) return b;\n if (b == null) return a;\n final int aLen = Array.getLength(a);\n final int bLen = Array.getLength(b);\n if (aLen == 0) return b;\n if (bLen == 0) return a;\n //From here on we really need to concatenate!\n\n Class componentType = a.getClass().getComponentType();\n final T result = (T)Array.newInstance(componentType, aLen + bLen);\n System.arraycopy(a, 0, result, 0, aLen);\n System.arraycopy(b, 0, result, aLen, bLen);\n return result;\n }\n\n public static void main(String[] args) {\n String[] out1 = concat(new String[]{\"aap\", \"monkey\"}, new String[]{\"rat\"});\n int[] out2 = concat(new int[]{6,7,8}, new int[]{9,10});\n }\n"
},
{
"answer_id": 72239759,
"author": "J.R",
"author_id": 3156682,
"author_profile": "https://Stackoverflow.com/users/3156682",
"pm_score": 1,
"selected": false,
"text": " /**\n * With Java Streams\n * @param first First Array\n * @param second Second Array\n * @return Merged Array\n */\n String[] mergeArrayOfStrings(String[] first, String[] second) {\n return Stream.concat(Arrays.stream(first), Arrays.stream(second)).toArray(String[]::new);\n }\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2948/"
] |
80,486
|
<p>I need to know how to turn on Code Coverage when running TFS builds on a solution with a .testrunconfig file. </p>
<p>There is an option in the testrunconfig file that is for code coverage, but when running a TFS build there is no code coverage results.</p>
<p>I am running my tests using the *Tests.dll mask and NOT using Test Lists (.vsmdi).</p>
|
[
{
"answer_id": 80600,
"author": "Martin Woodward",
"author_id": 6438,
"author_profile": "https://Stackoverflow.com/users/6438",
"pm_score": 5,
"selected": true,
"text": "<RunConfigFile>$(SolutionRoot)\\TestRunConfig.testrunconfig</RunConfigFile>\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5132/"
] |
80,493
|
<p>In C, using the standard Windows API, what is the best way to read an unformatted disk? Specifically, I have an <a href="http://en.wikipedia.org/wiki/MultiMediaCard" rel="nofollow noreferrer">MMC</a> or <a href="http://en.wikipedia.org/wiki/Secure_Digital_card" rel="nofollow noreferrer">SD card</a> with data, but no file system (not FAT16, not FAT32, just raw data). If there was a simple way to open the entire card for byte by byte binary access, that would be great.</p>
<p>Thanks!</p>
|
[
{
"answer_id": 81420,
"author": "Andreas Magnusson",
"author_id": 5811,
"author_profile": "https://Stackoverflow.com/users/5811",
"pm_score": 3,
"selected": true,
"text": "HANDLE drive = CreateFile(_T(\"\\\\.\\PhysicalDrive0\"), GENERIC_READ, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);\n// error handling\nDWORD br = 0;\nDISK_GEOMETRY dg;\nDeviceIOControl(drive, IOCTL_DISK_GET_DRIVE_GEOMETRY, 0, 0, &dg, sizeof(dg), &br, 0);\n//\nLARGE_INTEGER pos;\npos.QuadPart = static_cast<LONGLONG>(sectorToRead) * dg.BytesPerSector;\nSetFilePointerEx(drive, pos, 0, FILE_BEGIN);\nconst bool success = ReadFile(drive, sectorData, dg.BytesPerSector, &br) && br == dg.BytesPerSector;\n//\nCloseHandle(drive);\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3175/"
] |
80,515
|
<p>I'd like to install some presentation templates, but don't know where to put them...</p>
<p>Thanks a lot</p>
|
[
{
"answer_id": 80532,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "/usr/lib/openoffice/share/template/\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11104/"
] |
80,541
|
<p>The title is pretty much self explanatory. Given two dates what is the best way of finding the number of week days using PHP? Week days being Monday to Friday.</p>
<p>For instance, how would I find out that there are 10 week days in between <code>31/08/2008</code> and <code>13/09/2008</code>?</p>
|
[
{
"answer_id": 80553,
"author": "erlando",
"author_id": 4192,
"author_profile": "https://Stackoverflow.com/users/4192",
"pm_score": 0,
"selected": false,
"text": "$dif_in_seconds = abs(strtotime($a) - strtotime($b));\n$daysbetween = $dif_in_seconds / 86400;\n"
},
{
"answer_id": 80578,
"author": "kobusb",
"author_id": 1620,
"author_profile": "https://Stackoverflow.com/users/1620",
"pm_score": 3,
"selected": true,
"text": " $datefrom = strtotime($datefrom, 0);\n $dateto = strtotime($dateto, 0);\n\n $difference = $dateto - $datefrom;\n\n $days_difference = floor($difference / 86400);\n $weeks_difference = floor($days_difference / 7); // Complete weeks\n\n $first_day = date(\"w\", $datefrom);\n $days_remainder = floor($days_difference % 7);\n\n $odd_days = $first_day + $days_remainder; // Do we have a Saturday or Sunday in the remainder?\n if ($odd_days > 7) { // Sunday\n $days_remainder--;\n }\n if ($odd_days > 6) { // Saturday\n $days_remainder--;\n }\n\n $datediff = ($weeks_difference * 5) + $days_remainder;\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/131/"
] |
80,561
|
<p>I am going to hosting for files that user submits. I need to grab some data from the file and then move it to some directory.</p>
<p>There two points of interest for the lifetime of this file. The first is when the data is being abstracted and the second is when the file is archived so that it can be shared.</p>
<p>When data is being abstracted, I've thought that renaming the file to something unique or append a unique string to filename to keep it from overwriting other existing files. </p>
<p>When the file is going to be archived, I've thought of three strategies. One is to keep all files uploaded from a certain data in one folder. (2006/sept/04, 2008/jan/05) The other is to keep a folder and keep filling it until some max number of files I want to keep in folder and then create another one (/folder001/, /folder002/, /folder003/, etc..). Another one is to create subfolders once they reach some threshold. So like (/j/jd/jde/jdelator) I've seen this in unix not sure how to explain this.</p>
<p>The questions I have is what kind of strategies you guys have found useful or used?</p>
|
[
{
"answer_id": 81398,
"author": "ofaurax",
"author_id": 15209,
"author_profile": "https://Stackoverflow.com/users/15209",
"pm_score": 3,
"selected": true,
"text": "filename + millisec();"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/438/"
] |
80,563
|
<p>Please consider both commercial and free debuggers. Would like to see also the pros and cons for each.</p>
|
[
{
"answer_id": 80590,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 1,
"selected": false,
"text": "UndoDB"
},
{
"answer_id": 2335293,
"author": "osgx",
"author_id": 196561,
"author_profile": "https://Stackoverflow.com/users/196561",
"pm_score": 2,
"selected": false,
"text": "dbx"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1692070/"
] |
80,564
|
<p>Is there a way to trigger a beep/alarm/sound when my breakpoint is hit? I'm using Visual Studio 2005/2008.</p>
|
[
{
"answer_id": 80735,
"author": "Andrew",
"author_id": 15127,
"author_profile": "https://Stackoverflow.com/users/15127",
"pm_score": 3,
"selected": false,
"text": "Imports System.Runtime.InteropServices\nPublic Module Beeps\n Public Sub WindowsBeep()\n Interaction.Beep()\n End Sub\n Public Sub ForceBeep()\n Beep(900, 300)\n End Sub\n <DllImport(\"Kernel32.dll\")> _\n Private Function Beep(ByVal frequency As UInt32, ByVal duration As UInt32) As Boolean\n End Function\nEnd Module\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80564",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1630/"
] |
80,592
|
<pre><code>public class Test {
public static void main(String[] args) {
}
}
class Outer {
void aMethod() {
class MethodLocalInner {
void bMethod() {
System.out.println("Inside method-local bMethod");
}
}
}
}
</code></pre>
<p>Can someone tell me how to print the message from <code>bMethod</code>?</p>
|
[
{
"answer_id": 80615,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": true,
"text": "MethodLocalInner"
},
{
"answer_id": 80616,
"author": "Benno Richters",
"author_id": 3565,
"author_profile": "https://Stackoverflow.com/users/3565",
"pm_score": 1,
"selected": false,
"text": "new MethodLocalInner().bMethod();\n"
},
{
"answer_id": 80625,
"author": "Lior",
"author_id": 13321,
"author_profile": "https://Stackoverflow.com/users/13321",
"pm_score": 1,
"selected": false,
"text": "MethodLocalInner"
},
{
"answer_id": 19292897,
"author": "Fco Javier Perez",
"author_id": 2866485,
"author_profile": "https://Stackoverflow.com/users/2866485",
"pm_score": 0,
"selected": false,
"text": "public class Test {\n public static void main(String[] args) {\n new Outer().aMethod();\n }\n}\n\n\nvoid aMethod() {\n class MethodLocalInner {\n void bMethod() {\n System.out.println(\"Inside method-local bMethod\");\n }\n }\n new MethodLocalInner().bMethod();\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11193/"
] |
80,593
|
<p>I have a FlowDocument in a standard WPF application window where I have some text, and in this text some hyperlinks and buttons.</p>
<p>The problem is, if I put this FlowDocument inside anything <strong>except</strong> a <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.flowdocumentpageviewer.aspx" rel="nofollow noreferrer">FlowDocumentPageViewer</a> the hyperlinks and buttons are disabled ("grayed out").</p>
<pre><code><FlowDocumentScrollViewer>
<FlowDocument>
<Paragraph>
Hello, World!
<Hyperlink NavigateUri="some-uri">click me</Hyperlink>
<Button Click="myButton_Click" Content="Click me too!" />
</Paragraph>
</FlowDocument>
</FlowDocumentScrollViewer>
</code></pre>
<p>The above will work and the link will be clickable. However, I don't want the full pageviewer thing since it will show navigation buttons (back/forward) zoom and it also has a weird column behavior.</p>
<p>I want it in a simple <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.flowdocumentscrollviewer.aspx" rel="nofollow noreferrer">FlowDocumentScrollViewer</a> (or anything else that just displays the text without additional fuzz).</p>
<p><strong>EDIT:</strong>
It's not only hyperlinks that is the problem. <em>Any</em> control, like Button, ListBox, ComboBox - anything that the user can interact with - is "grayed out" regardless of the IsEnabled properties if the FlowDocument is inside a FlowDocumentScrollViewer.</p>
<p><strong>EDIT2:</strong>
Alright, it must have been a mistake or something from my end, because I ended up rewriting the control and now it works. I guess there was some sort if IsEnabled=False somewhere in the visual tree that caused this.</p>
|
[
{
"answer_id": 80757,
"author": "Jobi Joy",
"author_id": 8091,
"author_profile": "https://Stackoverflow.com/users/8091",
"pm_score": 0,
"selected": false,
"text": "<TextBlock>\n<Hyperlink>\n <Run Text=\"Test link\"/>\n</Hyperlink >\n"
},
{
"answer_id": 153713,
"author": "David Schmitt",
"author_id": 4918,
"author_profile": "https://Stackoverflow.com/users/4918",
"pm_score": 3,
"selected": true,
"text": "<FlowDocumentScrollViewer VerticalScrollBarVisibility=\"Auto\">\n <FlowDocument>\n <Paragraph>\n <!-- ... -->\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8521/"
] |
80,601
|
<p>When multiple <code>scanf()</code> statements are encountered in the code, then, except the first <code>scanf()</code> statement, all others are skipped, that is, there is no prompt for input for those <code>scanf()</code> statements when the code is run.</p>
<p>I have a tried a few suggestions. For eg, use of <code>flushall()</code> was suggested on some site, but that gives a compilation error. </p>
<p>Any help greatly appreciated.</p>
<p>[The code was added as <a href="https://stackoverflow.com/a/2787189/256431">an answer</a>.]</p>
|
[
{
"answer_id": 2787189,
"author": "Michał",
"author_id": 335226,
"author_profile": "https://Stackoverflow.com/users/335226",
"pm_score": 0,
"selected": false,
"text": "#include <stdio.h>\nint main()\n{\nlong int z,s,n,i,j,m,x;\nscanf(\"%ld \",&z);\nfor(i=0; i<z; i++)\n {\n scanf(\"%ld\",&s); n=0;\n for (j=0; j<s; j++) { scanf(\"%ld\",&m); n+=m; }\n x=n+s-1;\n printf(\"%ld\\n\",n);\n }\nreturn 0;\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
80,609
|
<p>I need to "merge" two XML documents, overwriting the overlapsed attributes and elements. For instance if I have <strong>document1</strong>:</p>
<pre><code><mapping>
<key value="assigned">
<a/>
</key>
<whatever attribute="x">
<k/>
<j/>
</whatever>
</mapping>
</code></pre>
<p>and <strong>document2</strong>:</p>
<pre><code><mapping>
<key value="identity">
<a/>
<b/>
</key>
</mapping>
</code></pre>
<p>I want to merge the two like this:</p>
<pre><code><mapping>
<key value="identity">
<a/>
<b/>
</key>
<whatever attribute="x">
<k/>
<j/>
</whatever>
</mapping>
</code></pre>
<p>I prefer <strong>Java</strong> or <strong>XSLT</strong>-based solutions, <strong>ant</strong> will do fine, but if there's an easy way to do that in <strong>Rake</strong>, <strong>Ruby</strong> or <strong>Python</strong> please don't be shy :-)</p>
<p><strong>EDIT:</strong> actually I find I'd rather use an automated tool/script, even <a href="http://web.archive.org/web/20100818203850/http://stackoverflow.com:80/questions/58640/great-programming-quotes" rel="nofollow noreferrer">writing it by myself</a>, because manually merging some 30 XML files is a bit unwieldy... :-(</p>
|
[
{
"answer_id": 27258761,
"author": "Sławek",
"author_id": 1116153,
"author_profile": "https://Stackoverflow.com/users/1116153",
"pm_score": 2,
"selected": false,
"text": "import org.atteo.xmlcombiner.XmlCombiner;\n\n// create combiner\nXmlCombiner combiner = new XmlCombiner();\n// combine files\ncombiner.combine(firstFile);\ncombiner.combine(secondFile);\n// store the result\ncombiner.buildDocument(resultFile);\n"
},
{
"answer_id": 43150501,
"author": "mwallner",
"author_id": 2279385,
"author_profile": "https://Stackoverflow.com/users/2279385",
"pm_score": 1,
"selected": false,
"text": "param(\n[Parameter(Mandatory = $True)][string]$file1,\n[Parameter(Mandatory = $True)][string]$file2,\n[Parameter(Mandatory = $True)][string]$path\n)\n\n# using only abs paths .. just to be safe\n$file1 = Join-Path $(Get-Location) $file1\n$file2 = Join-Path $(Get-Location) $file2\n$path = Join-Path $(Get-Location) $path\n\n# awesome xsl stylesheet from Oliver Becker\n# http://web.archive.org/web/20160502194427/http://www2.informatik.hu-berlin.de/~obecker/XSLT/merge/merge.xslt\n$xsltfile = Join-Path $(Get-Location) \"merge.xslt\"\n\n$XsltSettings = New-Object System.Xml.Xsl.XsltSettings\n$XsltSettings.EnableDocumentFunction = 1\n\n$xslt = New-Object System.Xml.Xsl.XslCompiledTransform;\n$xslt.Load($xsltfile , $XsltSettings, $(New-Object System.Xml.XmlUrlResolver))\n\n[System.Xml.Xsl.XsltArgumentList]$al = [System.Xml.Xsl.XsltArgumentList]::new()\n$al.AddParam(\"with\", \"\", $file2)\n$al.AddParam(\"replace\", \"\", \"true\")\n\n[System.Xml.XmlWriter]$xmlwriter = [System.Xml.XmlWriter]::Create($path)\n$xslt.Transform($file1, $al, $xmlwriter)\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4690/"
] |
80,612
|
<p>I've recently had to dust off my Perl and shell script skills to help out some colleagues. The colleagues in question have been tasked with providing some reports from an internal application with a large Oracle database backend, and they simply don't have the skills to do this. While some might question whether I have those skills either (grin), apparently enough people think I do to mean I can't weasel out of it.</p>
<p>So to my question - in order to extract the reports from the database, my script is obviously having to connect and run queries. I haven't thus far managed to come up with a good solution for where to store the username and password for the database so it is currently being stored as plaintext in the script.</p>
<p>Is there a good solution for this that someone else has already written, perhaps as a CPAN module? Or is there something else that's better to do - like keep the user / password combo in a completely separate file that's hidden away somewhere else on the filesystem? Or should I be keeping them trivially encrypted to just avoid them being pulled out of my scripts with a system-wide grep?</p>
<p>Edit:
The Oracle database sits on an HP-UX server.<br>
The Application server (running the shell scripts) is Solaris.<br>
Setting the scripts to be owned by just me is a no-go, they have to be owned by a service account that multiple support personnel have access to.<br>
The scripts are intended to be run as cron jobs.<br>
I'd love to go with public-key authentication, but am unaware of methods to make that work with Oracle - if there is such a method - enlighten me!</p>
|
[
{
"answer_id": 81416,
"author": "Mark Nold",
"author_id": 4134,
"author_profile": "https://Stackoverflow.com/users/4134",
"pm_score": 1,
"selected": false,
"text": "CREATE USER OPS$SCOTT IDENTIFIED BY EXTERNALLY"
},
{
"answer_id": 47402279,
"author": "Kexin Z",
"author_id": 4677830,
"author_profile": "https://Stackoverflow.com/users/4677830",
"pm_score": 0,
"selected": false,
"text": "openssl rsautl -decrypt -inkey ~/.ssh/id_rsa -in ~/.ssh/secret.dat"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6756/"
] |
80,619
|
<p>While refactoring some old code I have stripped out a number of public methods that should actually of been statics as they a) don't operate on any member data or call any other member functions and b) because they might prove useful elsewhere.</p>
<p>This led me to think about the best way to group 'helper' functions together. The Java/C# way would be to use a class of static functions with a private constructor, e.g.:</p>
<pre><code>class Helper
{
private:
Helper() { }
public:
static int HelperFunc1();
static int HelperFunc2();
};
</code></pre>
<p>However, being C++ you could also use a namespace:</p>
<pre><code>namespace Helper
{
int HelperFunc1();
int HelperFunc2();
}
</code></pre>
<p>In most cases I think I would prefer the namespace approach but I wanted to know what the pros and cons of each approach are. If used the class approach for example, would there be any overheads?</p>
|
[
{
"answer_id": 80651,
"author": "Pieter",
"author_id": 5822,
"author_profile": "https://Stackoverflow.com/users/5822",
"pm_score": 6,
"selected": true,
"text": "namespace LittleEndianHelper {\n void Function();\n}\nnamespace BigEndianHelper {\n void Function();\n}\n\n#if powerpc\n namespace Helper = BigEndianHelper;\n#elif intel\n namespace Helper = LittleEndianHelper;\n#endif\n"
},
{
"answer_id": 80804,
"author": "Tom Leys",
"author_id": 11440,
"author_profile": "https://Stackoverflow.com/users/11440",
"pm_score": 3,
"selected": false,
"text": "//Header a.h\n// Lots of big header files, spreading throughout your code\nclass foo\n{\n struct bar {/* ... */);\n};\n\n//header b.h\n#include a.h // Required, no way around it, pulls in big headers\nclass b\n{\n //...\n DoSomething(foo::bar);\n};\n"
},
{
"answer_id": 88965,
"author": "jwfearn",
"author_id": 10559,
"author_profile": "https://Stackoverflow.com/users/10559",
"pm_score": 4,
"selected": false,
"text": "class"
},
{
"answer_id": 383365,
"author": "paercebal",
"author_id": 14089,
"author_profile": "https://Stackoverflow.com/users/14089",
"pm_score": 2,
"selected": false,
"text": "struct AAA\n{\n void makeSomething() ;\n} ;\n\nnamespace BBB\n{\n void makeSomethingElse() ;\n}\n\nvoid willCompile()\n{\n AAA::makeSomething() ;\n BBB::makeSomethingElse() ;\n}\n\nvoid willCompileAgain()\n{\n using BBB ;\n\n makeSomethingElse() ; // This will call BBB::makeSomethingElse()\n}\n\nvoid WONT_COMPILE()\n{\n using AAA ; // ERROR : Won't compile\n\n makeSomething() ; // ERROR : Won't compile\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9236/"
] |
80,646
|
<p>What is the difference between <code>==</code> and <code>===</code>?</p>
<ul>
<li>How exactly does the loosely <code>==</code> comparison work?</li>
<li>How exactly does the strict <code>===</code> comparison work?</li>
</ul>
<p>What would be some useful examples?</p>
|
[
{
"answer_id": 80649,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 10,
"selected": true,
"text": "=="
},
{
"answer_id": 80694,
"author": "Stacey Richards",
"author_id": 1142,
"author_profile": "https://Stackoverflow.com/users/1142",
"pm_score": 2,
"selected": false,
"text": "$needle = 'a';\n$haystack = 'abc';\n$pos = strpos($haystack, $needle);\nif ($pos === false) {\n echo $needle . ' was not found in ' . $haystack;\n} else {\n echo $needle . ' was found in ' . $haystack . ' at location ' . $pos;\n}\n"
},
{
"answer_id": 80796,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": false,
"text": "var x = 4;\nvar y = '4';\nif (x == y) {\n alert('x and y are equal');\n}\nif (x === y) {\n alert('x and y are identical');\n}\n"
},
{
"answer_id": 80861,
"author": "ofaurax",
"author_id": 15209,
"author_profile": "https://Stackoverflow.com/users/15209",
"pm_score": 1,
"selected": false,
"text": "if ($var == 1) {... do something ...}\n"
},
{
"answer_id": 589558,
"author": "Patrick Glandien",
"author_id": 66760,
"author_profile": "https://Stackoverflow.com/users/66760",
"pm_score": 8,
"selected": false,
"text": "1 === 1: true\n1 == 1: true\n1 === \"1\": false // 1 is an integer, \"1\" is a string\n1 == \"1\": true // \"1\" gets casted to an integer, which is 1\n\"foo\" === \"foo\": true // both operands are strings and have the same value"
},
{
"answer_id": 589748,
"author": "soulmerge",
"author_id": 44562,
"author_profile": "https://Stackoverflow.com/users/44562",
"pm_score": 5,
"selected": false,
"text": "$a == $b"
},
{
"answer_id": 11545695,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "BOOL"
},
{
"answer_id": 32642207,
"author": "Sathish",
"author_id": 1691723,
"author_profile": "https://Stackoverflow.com/users/1691723",
"pm_score": 1,
"selected": false,
"text": "<?php\n\n /**\n * Comparison of two PHP objects == ===\n * Checks for\n * 1. References yes yes\n * 2. Instances with matching attributes and its values yes no\n * 3. Instances with different attributes yes no\n **/\n\n // There is no need to worry about comparing visibility of property or\n // method, because it will be the same whenever an object instance is\n // created, however visibility of an object can be modified during run\n // time using ReflectionClass()\n // http://php.net/manual/en/reflectionproperty.setaccessible.php\n //\n class Foo\n {\n public $foobar = 1;\n\n public function createNewProperty($name, $value)\n {\n $this->{$name} = $value;\n }\n }\n\n class Bar\n {\n }\n // 1. Object handles or references\n // Is an object a reference to itself or a clone or totally a different object?\n //\n // == true Name of two objects are same, for example, Foo() and Foo()\n // == false Name of two objects are different, for example, Foo() and Bar()\n // === true ID of two objects are same, for example, 1 and 1\n // === false ID of two objects are different, for example, 1 and 2\n\n echo \"1. Object handles or references (both == and ===) <br />\";\n\n $bar = new Foo(); // New object Foo() created\n $bar2 = new Foo(); // New object Foo() created\n $baz = clone $bar; // Object Foo() cloned\n $qux = $bar; // Object Foo() referenced\n $norf = new Bar(); // New object Bar() created\n echo \"bar\";\n var_dump($bar);\n echo \"baz\";\n var_dump($baz);\n echo \"qux\";\n var_dump($qux);\n echo \"bar2\";\n var_dump($bar2);\n echo \"norf\";\n var_dump($norf);\n\n // Clone: == true and === false\n echo '$bar == $bar2';\n var_dump($bar == $bar2); // true\n\n echo '$bar === $bar2';\n var_dump($bar === $bar2); // false\n\n echo '$bar == $baz';\n var_dump($bar == $baz); // true\n\n echo '$bar === $baz';\n var_dump($bar === $baz); // false\n\n // Object reference: == true and === true\n echo '$bar == $qux';\n var_dump($bar == $qux); // true\n\n echo '$bar === $qux';\n var_dump($bar === $qux); // true\n\n // Two different objects: == false and === false\n echo '$bar == $norf';\n var_dump($bar == $norf); // false\n\n echo '$bar === $norf';\n var_dump($bar === $norf); // false\n\n // 2. Instances with matching attributes and its values (only ==).\n // What happens when objects (even in cloned object) have same\n // attributes but varying values?\n\n // $foobar value is different\n echo \"2. Instances with matching attributes and its values (only ==) <br />\";\n\n $baz->foobar = 2;\n echo '$foobar' . \" value is different <br />\";\n echo '$bar->foobar = ' . $bar->foobar . \"<br />\";\n echo '$baz->foobar = ' . $baz->foobar . \"<br />\";\n echo '$bar == $baz';\n var_dump($bar == $baz); // false\n\n // $foobar's value is the same again\n $baz->foobar = 1;\n echo '$foobar' . \" value is the same again <br />\";\n echo '$bar->foobar is ' . $bar->foobar . \"<br />\";\n echo '$baz->foobar is ' . $baz->foobar . \"<br />\";\n echo '$bar == $baz';\n var_dump($bar == $baz); // true\n\n // Changing values of properties in $qux object will change the property\n // value of $bar and evaluates true always, because $qux = &$bar.\n $qux->foobar = 2;\n echo '$foobar value of both $qux and $bar is 2, because $qux = &$bar' . \"<br />\";\n echo '$qux->foobar is ' . $qux->foobar . \"<br />\";\n echo '$bar->foobar is ' . $bar->foobar . \"<br />\";\n echo '$bar == $qux';\n var_dump($bar == $qux); // true\n\n // 3. Instances with different attributes (only ==)\n // What happens when objects have different attributes even though\n // one of the attributes has same value?\n echo \"3. Instances with different attributes (only ==) <br />\";\n\n // Dynamically create a property with the name in $name and value\n // in $value for baz object\n $name = 'newproperty';\n $value = null;\n $baz->createNewProperty($name, $value);\n echo '$baz->newproperty is ' . $baz->{$name};\n var_dump($baz);\n\n $baz->foobar = 2;\n echo '$foobar' . \" value is same again <br />\";\n echo '$bar->foobar is ' . $bar->foobar . \"<br />\";\n echo '$baz->foobar is ' . $baz->foobar . \"<br />\";\n echo '$bar == $baz';\n var_dump($bar == $baz); // false\n var_dump($bar);\n var_dump($baz);\n?>\n"
},
{
"answer_id": 40392064,
"author": "Eric Leschinski",
"author_id": 445131,
"author_profile": "https://Stackoverflow.com/users/445131",
"pm_score": 7,
"selected": false,
"text": "=="
},
{
"answer_id": 43857980,
"author": "DavidWalley",
"author_id": 3298321,
"author_profile": "https://Stackoverflow.com/users/3298321",
"pm_score": 1,
"selected": false,
"text": "$n = 1000;\n$d = $n + 0.0e0;\necho '<br/>'. ( ($n == $d)?'equal' :'not equal' );\necho '<br/>'. ( ($n === $d)?'equal' :'not equal' );\n"
},
{
"answer_id": 52299551,
"author": "MAChitgarha",
"author_id": 4215651,
"author_profile": "https://Stackoverflow.com/users/4215651",
"pm_score": 1,
"selected": false,
"text": "=="
},
{
"answer_id": 65644706,
"author": "thomas",
"author_id": 12903396,
"author_profile": "https://Stackoverflow.com/users/12903396",
"pm_score": 2,
"selected": false,
"text": "=="
},
{
"answer_id": 66167669,
"author": "Gufran Hasan",
"author_id": 3041435,
"author_profile": "https://Stackoverflow.com/users/3041435",
"pm_score": 1,
"selected": false,
"text": "'=='"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
80,650
|
<p>How do I register a custom protocol with Windows so that when clicking a link in an email or on a web page my application is opened and the parameters from the URL are passed to it?</p>
|
[
{
"answer_id": 38205984,
"author": "Matas Vaitkevicius",
"author_id": 1509764,
"author_profile": "https://Stackoverflow.com/users/1509764",
"pm_score": 7,
"selected": false,
"text": "Start"
},
{
"answer_id": 67330359,
"author": "Shubham Kumar",
"author_id": 15748724,
"author_profile": "https://Stackoverflow.com/users/15748724",
"pm_score": 2,
"selected": false,
"text": "npm i protocol-registry\n"
},
{
"answer_id": 73008905,
"author": "duck",
"author_id": 343311,
"author_profile": "https://Stackoverflow.com/users/343311",
"pm_score": 3,
"selected": false,
"text": "Windows Registry Editor Version 5.00\n\n[HKEY_CLASSES_ROOT\\duck]\n\"URL Protocol\"=\"\"\n[HKEY_CLASSES_ROOT\\duck\\shell]\n[HKEY_CLASSES_ROOT\\duck\\shell\\open]\n[HKEY_CLASSES_ROOT\\duck\\shell\\open\\command] \n@=\"\\\"C:\\\\Users\\\\duck\\\\source\\\\repos\\\\ConsoleApp1\\\\ConsoleApp1\\\\bin\\\\Debug\\\\net6.0\\\\ConsoleApp1.exe\\\" \\\"%1\\\"\"\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2189521/"
] |
80,653
|
<p>I may be wrong, but if you are working with SmtpClient.SendAsync in ASP.NET
2.0 and it throws an exception, the thread processing the request waits
indefinitely for the operation to complete.</p>
<p>To reproduce this problem, simply use an invalid SMTP address for the host
that could not be resolved when sending an email.</p>
<p>Note that you should set Page.Async = true to use SendAsync.</p>
<p>If Page.Async is set to false and Send throws an exception the thread
does not block, and the page is processed correctly.</p>
<p>TIA.</p>
|
[
{
"answer_id": 80887,
"author": "bzlm",
"author_id": 7724,
"author_profile": "https://Stackoverflow.com/users/7724",
"pm_score": 2,
"selected": false,
"text": "RegisterAsyncTask()"
},
{
"answer_id": 83592,
"author": "Olivier MATROT",
"author_id": 15186,
"author_profile": "https://Stackoverflow.com/users/15186",
"pm_score": 0,
"selected": false,
"text": "public partial class _Default : System.Web.UI.Page\n{\n protected void Page_Load(object sender, EventArgs e)\n {\n // Using an incorrect SMTP server\n SmtpClient client = new SmtpClient(@\"smtp.nowhere.private\");\n // Specify the e-mail sender.\n // Create a mailing address that includes a UTF8 character\n // in the display name.\n MailAddress from = new MailAddress(\"someone@somewhere.com\",\n \"SOMEONE\" + (char)0xD8 + \" SOMEWHERE\",\n System.Text.Encoding.UTF8);\n // Set destinations for the e-mail message.\n MailAddress to = new MailAddress(\"someone@somewhere.com\");\n // Specify the message content.\n MailMessage message = new MailMessage(from, to);\n message.Body = \"This is a test e-mail message sent by an application. \";\n // Include some non-ASCII characters in body and subject.\n string someArrows = new string(new char[] { '\\u2190', '\\u2191', '\\u2192', '\\u2193' });\n message.Body += Environment.NewLine + someArrows;\n message.BodyEncoding = System.Text.Encoding.UTF8;\n message.Subject = \"test message 1\" + someArrows;\n message.SubjectEncoding = System.Text.Encoding.UTF8;\n // Set the method that is called back when the send operation ends.\n client.SendCompleted += new\n SendCompletedEventHandler(SendCompletedCallback);\n // The userState can be any object that allows your callback \n // method to identify this send operation.\n // For this example, the userToken is a string constant.\n string userState = \"test message1\";\n try\n {\n client.SendAsync(message, userState);\n }\n catch (System.Net.Mail.SmtpException ex)\n {\n Response.Write(string.Format(\"Send Error [{0}].\", ex.InnerException.Message));\n }\n finally\n {\n }\n }\n private void SendCompletedCallback(object sender, AsyncCompletedEventArgs e)\n {\n // Get the unique identifier for this asynchronous operation.\n String token = (string)e.UserState;\n\n if (e.Cancelled)\n {\n Response.Write(string.Format(\"[{0}] Send canceled.\", token));\n }\n if (e.Error != null)\n {\n Response.Write(string.Format(\"[{0}] {1}\", token, e.Error.ToString()));\n }\n else\n {\n Response.Write(\"Message sent.\");\n }\n }\n\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15186/"
] |
80,655
|
<p>I want to send email with Exchange by using telnet to port 25. Until two week ago I was able to, but now a "security fix" from Microsoft has removed this possibility.</p>
<p>When I try, I get this message:</p>
<p>421 4.3.2 Service not available, closing transmission channel</p>
<p>What can I do?</p>
|
[
{
"answer_id": 41740424,
"author": "smartbit",
"author_id": 7440569,
"author_profile": "https://Stackoverflow.com/users/7440569",
"pm_score": 0,
"selected": false,
"text": "Get-TransportServer | select ReceiveProtocolLogPath"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15173/"
] |
80,657
|
<p>In the process of learning <a href="https://en.wikipedia.org/wiki/TinyOS" rel="nofollow noreferrer">TinyOS</a> I have discovered that I am totally clueless about makefiles.</p>
<p>There are many optional compile time features that can be used by way of declaring preprocessor variables.</p>
<p>To use them you have to do things like:</p>
<p><code>CFLAGS="-DPACKET_LINK"</code> this enables a certain feature.</p>
<p>and</p>
<p><code>CFLAGS="-DPACKET_LINK" "-DLOW_POWER"</code> enables two features.</p>
<p>Can someone dissect these lines for me and tell me whats going on? Not in terms of TinyOS, but in terms of makefiles!</p>
|
[
{
"answer_id": 80689,
"author": "Ilya",
"author_id": 6807,
"author_profile": "https://Stackoverflow.com/users/6807",
"pm_score": 3,
"selected": false,
"text": "$(CC) $(CFLAGS) $(C_INCLUDES) $<"
},
{
"answer_id": 80698,
"author": "Isak Savo",
"author_id": 8521,
"author_profile": "https://Stackoverflow.com/users/8521",
"pm_score": 5,
"selected": false,
"text": "-DPACKET_LINK"
},
{
"answer_id": 80717,
"author": "Jonas Engström",
"author_id": 7634,
"author_profile": "https://Stackoverflow.com/users/7634",
"pm_score": 2,
"selected": false,
"text": "#ifdef PACKET_LINK\n/* whatever code here */\n#endif\n"
},
{
"answer_id": 80880,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 1,
"selected": false,
"text": ".c.exe:\n commands: $(CC) $(CFLAGS) $<\n\n.c.obj:\n commands: $(CC) $(CFLAGS) /c $<\n\n.cpp.exe:\n commands: $(CXX) $(CXXFLAGS) $<\n\n.cpp.obj:\n commands: $(CXX) $(CXXFLAGS) /c $<\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
80,677
|
<p>One of the best tips for using vim that I have learned so far has been that one can press <kbd>Ctrl</kbd>+<kbd>C</kbd> or <kbd>Ctrl</kbd>+<kbd>[</kbd> instead of the <kbd>Esc</kbd> key. However I use a dvorak keyboard so <kbd>Ctrl</kbd>+<kbd>[</kbd> is a little out of reach for me as well so I mostly use <kbd>Ctrl</kbd>+<kbd>C</kbd>. Now I've read somewhere that these two key combinations don't actually have exactly the same behaviour and that it is better to use <kbd>Ctrl</kbd>+<kbd>[</kbd>. I haven't come across any problems so far though so I'd like to know what exactly is the difference between the two?</p>
|
[
{
"answer_id": 80761,
"author": "jeannicolas",
"author_id": 14981,
"author_profile": "https://Stackoverflow.com/users/14981",
"pm_score": 4,
"selected": false,
"text": "InsertLeave"
},
{
"answer_id": 80826,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 1,
"selected": false,
"text": "<C-[>"
},
{
"answer_id": 11333911,
"author": "weronika",
"author_id": 456876,
"author_profile": "https://Stackoverflow.com/users/456876",
"pm_score": 2,
"selected": false,
"text": "c"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13060/"
] |
80,690
|
<p>Phantom References serve for post-mortem operations.
The Java specification states that a <strong>phantom referenced object</strong> will not be deallocated until the phantom-reference itself is cleaned.</p>
<p>My question is: What purpose does this feature (object not deallocated) serve?</p>
<p>(The only idea i came up with, is to allow native code to do post-mortem cleanup on the object, but it isn't much convincing).</p>
|
[
{
"answer_id": 42442953,
"author": "Grwww",
"author_id": 7371705,
"author_profile": "https://Stackoverflow.com/users/7371705",
"pm_score": 0,
"selected": false,
"text": "trker"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15100/"
] |
80,691
|
<p>I've started refactoring some legacy code recently and came across two functions for drawing a coordinate grid, the problem is that these functions differ only in orthogonal variables they treat, something like that</p>
<pre><code>void DrawScaleX(HDC dc, int step, int x0, int x1, int y0, int y1)
{
for(int x = x0; x < x1; x += step)
{
MoveToEx(dc, x, y0, NULL);
LineTo(dc, x, y1);
}
}
void DrawScaleY(HDC dc, int step, int x0, int x1, int y0, int y1)
{
for(int y = y0; y < y1; y += step)
{
MoveToEx(dc, x0, y, NULL);
LineTo(dc, x1, y);
}
}
</code></pre>
<p>So if I decide to add some fancy stuff, like antialiasing or merely change drawing pencil or whatever I'll have to put the same code in both of them and it's code duplication and it's bad we all know why.</p>
<p>My question is how would you rewrite these two functions into a single one to avoid this problem?</p>
|
[
{
"answer_id": 80722,
"author": "Serge",
"author_id": 1007,
"author_profile": "https://Stackoverflow.com/users/1007",
"pm_score": 0,
"selected": false,
"text": "\nclass CoordGenerator\n{\npublic:\n CoordGenerator(int _from, int _to, int _step)\n :from(_from), to(_to), step(_step), pos(_from){}\n virtual POINT GetPoint00() const = 0;\n virtual POINT GetPoint01() const = 0;\n bool Next()\n {\n if(pos > step) return false;\n pos += step;\n }\nprotected:\n int from;\n int to;\n int step;\n int pos;\n};\n\nclass GenX: public CoordGenerator\n{\npublic:\n GenX(int x0, int x1, int step, int _y0, int _y1)\n :CoordGenerator(x0, x1, step),y0(_y0), y1(_y1){}\n virtual POINT GetPoint00() const\n {\n const POINT p = {pos, y0};\n return p;\n }\n virtual POINT GetPoint01() const\n {\n const POINT p = {pos, y1};\n return p;\n }\nprivate:\n int y0;\n int y1;\n};\n\nclass GenY: public CoordGenerator\n{\npublic:\n GenY(int y0, int y1, int step, int _x0, int _x1)\n :CoordGenerator(y0, y1, step),x0(_x0), x1(_x1){}\n virtual POINT GetPoint00() const\n {\n const POINT p = {x0, pos};\n return p;\n }\n virtual POINT GetPoint01() const\n {\n const POINT p = {x1, pos};\n return p;\n }\nprivate:\n int x1;\n int x0;\n};\n\nvoid DrawScale(HDC dc, CoordGenerator* g)\n{\n do\n {\n POINT p = g->GetPoint00();\n MoveToEx(dc, p.x, p.y, 0);\n p = g->GetPoint01();\n LineTo(dc, p.x, p.y);\n }while(g->Next());\n}\n"
},
{
"answer_id": 80750,
"author": "Matej",
"author_id": 11457,
"author_profile": "https://Stackoverflow.com/users/11457",
"pm_score": 3,
"selected": false,
"text": "void DrawScaleX(HDC dc, int step, int x0, int x1, int y0, int y1)\n{\n for(int x = x0; x < x1; x += step)\n {\n DrawScale(dc, x, y0, x, y1);\n }\n}\n\nvoid DrawScaleY(HDC dc, int step, int x0, int x1, int y0, int y1)\n{\n for(int y = y0; y < y1; y += step)\n {\n DrawScale(dc, x0, y, x1, y);\n }\n}\n\nprivate void DrawScale(HDC dc, int x0, int y0, int x1, int y1)\n{\n //Add funny stuff here\n\n MoveToEx(dc, x0, y0, NULL);\n LineTo(dc, x1, y1);\n\n //Add funny stuff here\n}\n"
},
{
"answer_id": 80760,
"author": "Douglas Leeder",
"author_id": 3978,
"author_profile": "https://Stackoverflow.com/users/3978",
"pm_score": 0,
"selected": false,
"text": " MoveToEx(dc, x0, y, NULL);\n LineTo(dc, x1, y);\n"
},
{
"answer_id": 80906,
"author": "Igor Semenov",
"author_id": 11401,
"author_profile": "https://Stackoverflow.com/users/11401",
"pm_score": 0,
"selected": false,
"text": "void DrawLine(HDC dc, int x0, int y0, int x0, int x1)\n{\n // anti-aliasing stuff\n MoveToEx(dc, x0, y0, NULL);\n LineTo(dc, x1, y1);\n}\n\nstruct DrawBinderX\n{\n DrawBinderX(int y0, int y1) : y0_(y0), y1_(y1) {}\n\n void operator()(HDC dc, int i)\n {\n DrawLine(dc, i, y0_, i, y1_);\n }\n\nprivate:\n int y0_;\n int y1_;\n\n};\n\nstruct DrawBinderY\n{\n DrawBinderX(int x0, int x1) : x0_(x0), x1_(x1) {}\n\n void operator()(HDC dc, int i)\n {\n DrawLine(dc, x0_, i, x1_, i);\n }\n\nprivate:\n int x0_;\n int x1_;\n\n};\n\ntemplate< class Drawer >\nvoid DrawScale(Drawer drawer, HDC dc, int from, int to, int step)\n{\n for (int i = from; i < to; i += step)\n {\n drawer(dc, i);\n }\n}\n\nvoid DrawScaleX(HDC dc, int step, int x0, int x1, int y0, int y1)\n{\n DrawBindexX drawer(y0, y1);\n DrawScale(drawer, dc, x0, x1, step);\n}\n\nvoid DrawScaleY(HDC dc, int step, int x0, int x1, int y0, int y1)\n{\n DrawBindexY drawer( x0, x1 );\n DrawScale(drawer, dc, y0, y1, step);\n}\n"
},
{
"answer_id": 81827,
"author": "ppi",
"author_id": 2044155,
"author_profile": "https://Stackoverflow.com/users/2044155",
"pm_score": 3,
"selected": true,
"text": "template< int XIncrement, YIncrement >\nstruct DrawScale\n{\n void operator()(HDC dc, int step, int x0, int x1, int y0, int y1)\n {\n const int deltaX = XIncrement*step;\n const int deltaY = YIncrement*step;\n const int ymax = y1;\n const int xmax = x1;\n while( x0 < xmax && y0 < ymax )\n {\n MoveToEx(dc, x0, y0, NULL);\n LineTo(dc, x1, y1);\n x0 += deltaX;\n x1 += deltaX;\n y0 += deltaY;\n y1 += deltaY;\n }\n }\n};\ntypedef DrawScale< 1, 0 > DrawScaleX;\ntypedef DrawScale< 0, 1 > DrawScaleY;\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1007/"
] |
80,692
|
<pre><code>public static Logger getLogger() {
final Throwable t = new Throwable();
final StackTraceElement methodCaller = t.getStackTrace()[1];
final Logger logger = Logger.getLogger(methodCaller.getClassName());
logger.setLevel(ResourceManager.LOGLEVEL);
return logger;
}
</code></pre>
<p>This method would return a logger that knows the class it's logging for.
Any ideas against it?</p>
<p>Many years later: <a href="https://github.com/yanchenko/droidparts/blob/master/droidparts/src/org/droidparts/util/L.java" rel="noreferrer">https://github.com/yanchenko/droidparts/blob/master/droidparts/src/org/droidparts/util/L.java</a></p>
|
[
{
"answer_id": 80851,
"author": "Mario Ortegón",
"author_id": 2309,
"author_profile": "https://Stackoverflow.com/users/2309",
"pm_score": 0,
"selected": false,
"text": "public static Logger getLogger(Object o) {\n final Logger logger = Logger.getLogger(o.getClass());\n logger.setLevel(ResourceManager.LOGLEVEL);\n return logger;\n}\n"
},
{
"answer_id": 83847,
"author": "18Rabbit",
"author_id": 12662,
"author_profile": "https://Stackoverflow.com/users/12662",
"pm_score": 3,
"selected": false,
"text": "private static final Logger logger = Logger.getLogger(MyClass.class.getName());\n"
},
{
"answer_id": 83866,
"author": "Asgeir S. Nilsen",
"author_id": 16023,
"author_profile": "https://Stackoverflow.com/users/16023",
"pm_score": 0,
"selected": false,
"text": "final Logger logger = LoggerFactory.getLogger(getClass());\n"
},
{
"answer_id": 104851,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 5,
"selected": false,
"text": "private static final Logger log = Logger.getLogger(MyClass.class);\n"
},
{
"answer_id": 303344,
"author": "ykaganovich",
"author_id": 10026,
"author_profile": "https://Stackoverflow.com/users/10026",
"pm_score": 2,
"selected": false,
"text": "Thread.currentThread().getStackTrace()[1]"
},
{
"answer_id": 1268633,
"author": "EGB",
"author_id": 155399,
"author_profile": "https://Stackoverflow.com/users/155399",
"pm_score": 3,
"selected": false,
"text": "public class LoggerUtils extends SecurityManager\n{\n public static Logger getLogger()\n {\n String className = new LoggerUtils().getClassName();\n Logger logger = Logger.getLogger(className);\n return logger;\n }\n\n private String getClassName()\n {\n return getClassContext()[2].getName();\n }\n}\n"
},
{
"answer_id": 1705696,
"author": "Cowan",
"author_id": 17041,
"author_profile": "https://Stackoverflow.com/users/17041",
"pm_score": 4,
"selected": false,
"text": "private static final Logger LOG = LogUtils.loggerForThisClass();\n"
},
{
"answer_id": 2400226,
"author": "Alaa Murad",
"author_id": 288624,
"author_profile": "https://Stackoverflow.com/users/288624",
"pm_score": 2,
"selected": false,
"text": "public class LoggerUtil {\n\n public static Level level=Level.ALL;\n\n public static java.util.logging.Logger getLogger() {\n final Throwable t = new Throwable();\n final StackTraceElement methodCaller = t.getStackTrace()[1];\n final java.util.logging.Logger logger = java.util.logging.Logger.getLogger(methodCaller.getClassName());\n logger.setLevel(level);\n\n return logger;\n }\n}\n"
},
{
"answer_id": 6459115,
"author": "Ed Sarrazin",
"author_id": 812881,
"author_profile": "https://Stackoverflow.com/users/812881",
"pm_score": 2,
"selected": false,
"text": "package com.edsdev.testapp.util;\n\nimport java.util.concurrent.ConcurrentHashMap;\n\nimport org.apache.log4j.Level;\nimport org.apache.log4j.Priority;\n\npublic class Logger extends SecurityManager {\n\nprivate static ConcurrentHashMap<String, org.apache.log4j.Logger> loggerMap = new ConcurrentHashMap<String, org.apache.log4j.Logger>();\n\npublic static org.apache.log4j.Logger getLog() {\n String className = new Logger().getClassName();\n if (!loggerMap.containsKey(className)) {\n loggerMap.put(className, org.apache.log4j.Logger.getLogger(className));\n }\n return loggerMap.get(className);\n}\npublic String getClassName() {\n return getClassContext()[3].getName();\n}\npublic static void trace(Object message) {\n getLog().trace(message);\n}\npublic static void trace(Object message, Throwable t) {\n getLog().trace(message, t);\n}\npublic static boolean isTraceEnabled() {\n return getLog().isTraceEnabled();\n}\npublic static void debug(Object message) {\n getLog().debug(message);\n}\npublic static void debug(Object message, Throwable t) {\n getLog().debug(message, t);\n}\npublic static void error(Object message) {\n getLog().error(message);\n}\npublic static void error(Object message, Throwable t) {\n getLog().error(message, t);\n}\npublic static void fatal(Object message) {\n getLog().fatal(message);\n}\npublic static void fatal(Object message, Throwable t) {\n getLog().fatal(message, t);\n}\npublic static void info(Object message) {\n getLog().info(message);\n}\npublic static void info(Object message, Throwable t) {\n getLog().info(message, t);\n}\npublic static boolean isDebugEnabled() {\n return getLog().isDebugEnabled();\n}\npublic static boolean isEnabledFor(Priority level) {\n return getLog().isEnabledFor(level);\n}\npublic static boolean isInfoEnabled() {\n return getLog().isInfoEnabled();\n}\npublic static void setLevel(Level level) {\n getLog().setLevel(level);\n}\npublic static void warn(Object message) {\n getLog().warn(message);\n}\npublic static void warn(Object message, Throwable t) {\n getLog().warn(message, t);\n}\n"
},
{
"answer_id": 11937492,
"author": "joseaio",
"author_id": 1312464,
"author_profile": "https://Stackoverflow.com/users/1312464",
"pm_score": 0,
"selected": false,
"text": "package my.pkg;\n\nimport java.text.MessageFormat;\nimport java.util.Arrays;\nimport java.util.IllegalFormatException;\nimport java.util.logging.Level;\nimport java.util.logging.LogRecord;\n\nimport sun.misc.JavaLangAccess;\nimport sun.misc.SharedSecrets;\n\n\npublic class Logger {\nstatic final int CLASS_NAME = 0;\nstatic final int METHOD_NAME = 1;\n\n// Private method to infer the caller's class and method names\nprotected static String[] getClassName() {\n JavaLangAccess access = SharedSecrets.getJavaLangAccess();\n Throwable throwable = new Throwable();\n int depth = access.getStackTraceDepth(throwable);\n\n boolean lookingForLogger = true;\n for (int i = 0; i < depth; i++) {\n // Calling getStackTraceElement directly prevents the VM\n // from paying the cost of building the entire stack frame.\n StackTraceElement frame = access.getStackTraceElement(throwable, i);\n String cname = frame.getClassName();\n boolean isLoggerImpl = isLoggerImplFrame(cname);\n if (lookingForLogger) {\n // Skip all frames until we have found the first logger frame.\n if (isLoggerImpl) {\n lookingForLogger = false;\n }\n } else {\n if (!isLoggerImpl) {\n // skip reflection call\n if (!cname.startsWith(\"java.lang.reflect.\") && !cname.startsWith(\"sun.reflect.\")) {\n // We've found the relevant frame.\n return new String[] {cname, frame.getMethodName()};\n }\n }\n }\n }\n return new String[] {};\n // We haven't found a suitable frame, so just punt. This is\n // OK as we are only committed to making a \"best effort\" here.\n}\n\nprotected static String[] getClassNameJDK5() {\n // Get the stack trace.\n StackTraceElement stack[] = (new Throwable()).getStackTrace();\n // First, search back to a method in the Logger class.\n int ix = 0;\n while (ix < stack.length) {\n StackTraceElement frame = stack[ix];\n String cname = frame.getClassName();\n if (isLoggerImplFrame(cname)) {\n break;\n }\n ix++;\n }\n // Now search for the first frame before the \"Logger\" class.\n while (ix < stack.length) {\n StackTraceElement frame = stack[ix];\n String cname = frame.getClassName();\n if (isLoggerImplFrame(cname)) {\n // We've found the relevant frame.\n return new String[] {cname, frame.getMethodName()};\n }\n ix++;\n }\n return new String[] {};\n // We haven't found a suitable frame, so just punt. This is\n // OK as we are only committed to making a \"best effort\" here.\n}\n\n\nprivate static boolean isLoggerImplFrame(String cname) {\n // the log record could be created for a platform logger\n return (\n cname.equals(\"my.package.Logger\") ||\n cname.equals(\"java.util.logging.Logger\") ||\n cname.startsWith(\"java.util.logging.LoggingProxyImpl\") ||\n cname.startsWith(\"sun.util.logging.\"));\n}\n\nprotected static java.util.logging.Logger getLogger(String name) {\n return java.util.logging.Logger.getLogger(name);\n}\n\nprotected static boolean log(Level level, String msg, Object... args) {\n return log(level, null, msg, args);\n}\n\nprotected static boolean log(Level level, Throwable thrown, String msg, Object... args) {\n String[] values = getClassName();\n java.util.logging.Logger log = getLogger(values[CLASS_NAME]);\n if (level != null && log.isLoggable(level)) {\n if (msg != null) {\n log.log(getRecord(level, thrown, values[CLASS_NAME], values[METHOD_NAME], msg, args));\n }\n return true;\n }\n return false;\n}\n\nprotected static LogRecord getRecord(Level level, Throwable thrown, String className, String methodName, String msg, Object... args) {\n LogRecord record = new LogRecord(level, format(msg, args));\n record.setSourceClassName(className);\n record.setSourceMethodName(methodName);\n if (thrown != null) {\n record.setThrown(thrown);\n }\n return record;\n}\n\nprivate static String format(String msg, Object... args) {\n if (msg == null || args == null || args.length == 0) {\n return msg;\n } else if (msg.indexOf('%') >= 0) {\n try {\n return String.format(msg, args);\n } catch (IllegalFormatException esc) {\n // none\n }\n } else if (msg.indexOf('{') >= 0) {\n try {\n return MessageFormat.format(msg, args);\n } catch (IllegalArgumentException exc) {\n // none\n }\n }\n if (args.length == 1) {\n Object param = args[0];\n if (param != null && param.getClass().isArray()) {\n return msg + Arrays.toString((Object[]) param);\n } else if (param instanceof Throwable){\n return msg;\n } else {\n return msg + param;\n }\n } else {\n return msg + Arrays.toString(args);\n }\n}\n\npublic static void severe(String msg, Object... args) {\n log(Level.SEVERE, msg, args);\n}\n\npublic static void warning(String msg, Object... args) {\n log(Level.WARNING, msg, args);\n}\n\npublic static void info(Throwable thrown, String format, Object... args) {\n log(Level.INFO, thrown, format, args);\n}\n\npublic static void warning(Throwable thrown, String format, Object... args) {\n log(Level.WARNING, thrown, format, args);\n}\n\npublic static void warning(Throwable thrown) {\n log(Level.WARNING, thrown, thrown.getMessage());\n}\n\npublic static void severe(Throwable thrown, String format, Object... args) {\n log(Level.SEVERE, thrown, format, args);\n}\n\npublic static void severe(Throwable thrown) {\n log(Level.SEVERE, thrown, thrown.getMessage());\n}\n\npublic static void info(String msg, Object... args) {\n log(Level.INFO, msg, args);\n}\n\npublic static void fine(String msg, Object... args) {\n log(Level.FINE, msg, args);\n}\n\npublic static void finer(String msg, Object... args) {\n log(Level.FINER, msg, args);\n}\n\npublic static void finest(String msg, Object... args) {\n log(Level.FINEST, msg, args);\n}\n\npublic static boolean isLoggableFinest() {\n return isLoggable(Level.FINEST);\n}\n\npublic static boolean isLoggableFiner() {\n return isLoggable(Level.FINER);\n}\n\npublic static boolean isLoggableFine() {\n return isLoggable(Level.FINE);\n}\n\npublic static boolean isLoggableInfo() {\n return isLoggable(Level.INFO);\n}\n\npublic static boolean isLoggableWarning() {\n return isLoggable(Level.WARNING);\n}\npublic static boolean isLoggableSevere() {\n return isLoggable(Level.SEVERE);\n}\n\nprivate static boolean isLoggable(Level level) {\n return log(level, null);\n}\n\n}\n"
},
{
"answer_id": 14670532,
"author": "yegor256",
"author_id": 187141,
"author_profile": "https://Stackoverflow.com/users/187141",
"pm_score": 0,
"selected": false,
"text": "Logger"
},
{
"answer_id": 32010391,
"author": "muttonUp",
"author_id": 3696510,
"author_profile": "https://Stackoverflow.com/users/3696510",
"pm_score": 1,
"selected": false,
"text": " private static final Logger log = \n LoggerFactory.getLogger(new Throwable().getStackTrace()[0].getClassName());\n"
},
{
"answer_id": 32132312,
"author": "Neeraj",
"author_id": 528757,
"author_profile": "https://Stackoverflow.com/users/528757",
"pm_score": 5,
"selected": false,
"text": "import java.lang.invoke.MethodHandles;\n\npublic class Main {\n private static final Class clazz = MethodHandles.lookup().lookupClass();\n private static final String CLASSNAME = clazz.getSimpleName();\n\n public static void main( String args[] ) {\n System.out.println( CLASSNAME );\n }\n}\n"
},
{
"answer_id": 52744364,
"author": "James Mudd",
"author_id": 4653517,
"author_profile": "https://Stackoverflow.com/users/4653517",
"pm_score": 1,
"selected": false,
"text": "private static final FluentLogger logger = FluentLogger.forEnclosingClass();\n"
},
{
"answer_id": 54787201,
"author": "James Mudd",
"author_id": 4653517,
"author_profile": "https://Stackoverflow.com/users/4653517",
"pm_score": 1,
"selected": false,
"text": "private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());\n"
},
{
"answer_id": 56684047,
"author": "Choletski",
"author_id": 3595288,
"author_profile": "https://Stackoverflow.com/users/3595288",
"pm_score": 1,
"selected": false,
"text": "public class MyLogs { \n public static void LOG(String theClass, String theMethod, String theComment) {\n Log.d(\"MY_TAG\", \"class: \" + theClass + \" meth : \" + theMethod + \" comm : \" + theComment);\n }\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15187/"
] |
80,693
|
<p>Why would one choose <a href="http://yaml.org/" rel="noreferrer">YAML</a> over XML or any other formats?</p>
|
[
{
"answer_id": 361695,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 1,
"selected": false,
"text": "<name type=\"string\">Orion</name>\n<age type=\"integer\">26</age>\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10708/"
] |
80,706
|
<p>I want to find 2<sup>nd</sup>, 3<sup>rd</sup>, ... n<sup>th</sup> maximum value of a column.</p>
|
[
{
"answer_id": 80720,
"author": "TK.",
"author_id": 1816,
"author_profile": "https://Stackoverflow.com/users/1816",
"pm_score": 5,
"selected": true,
"text": "SELECT DOB FROM (SELECT DOB FROM USERS ORDER BY DOB DESC) WHERE ROWID = 6\n"
},
{
"answer_id": 80734,
"author": "Pieter",
"author_id": 5822,
"author_profile": "https://Stackoverflow.com/users/5822",
"pm_score": 4,
"selected": false,
"text": "SELECT column FROM table ORDER BY column DESC LIMIT 7,10;\n"
},
{
"answer_id": 80771,
"author": "Blorgbeard",
"author_id": 369,
"author_profile": "https://Stackoverflow.com/users/369",
"pm_score": 0,
"selected": false,
"text": "select distinct top n+1 column from table order by column desc\n"
},
{
"answer_id": 81088,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "SELECT column \nFROM table \nWHERE column IS NOT NULL \nGROUP BY column \nORDER BY column DESC \nLIMIT 5 OFFSET 2;\n"
},
{
"answer_id": 82609,
"author": "Matt Rogish",
"author_id": 2590,
"author_profile": "https://Stackoverflow.com/users/2590",
"pm_score": 3,
"selected": false,
"text": "select id from table order by id desc limit 4 ;\n+------+\n| id |\n+------+\n| 2211 | \n| 2210 | \n| 2209 | \n| 2208 | \n+------+\n\n\nSELECT yourvalue\n FROM yourtable t1\n WHERE EXISTS( SELECT COUNT(*)\n FROM yourtable t2\n WHERE t1.id <> t2.id\n AND t1.yourvalue < t2.yourvalue\n HAVING COUNT(*) = 3 )\n\n\n+------+\n| id |\n+------+\n| 2208 | \n+------+\n"
},
{
"answer_id": 82829,
"author": "Dave Costa",
"author_id": 6568,
"author_profile": "https://Stackoverflow.com/users/6568",
"pm_score": 1,
"selected": false,
"text": " select created from (\n select created from (\n select created from user_objects\n order by created desc\n )\n where rownum <= 9\n order by created asc\n )\n where rownum = 1\n"
},
{
"answer_id": 83170,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "SELECT col1 from \n (select col1, dense_rank(col1) over (order by col1 desc) ranking \n from t1) subq where ranking between 2 and @n\n"
},
{
"answer_id": 86447,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "select distinct col1 --distinct is required to remove matching value of column\nfrom \n( select col1, dense_rank() over (order by col1 desc) rnk\n from tbl\n)\nwhere rnk = :b1\n"
},
{
"answer_id": 734650,
"author": "Phil H",
"author_id": 36537,
"author_profile": "https://Stackoverflow.com/users/36537",
"pm_score": 1,
"selected": false,
"text": "SELECT MIN(q.col1) FROM (\n SELECT\n DISTINCT TOP n col1\n FROM myTable\n ORDER BY col1 DESC\n) q;\n"
},
{
"answer_id": 750539,
"author": "dexter",
"author_id": 1385252,
"author_profile": "https://Stackoverflow.com/users/1385252",
"pm_score": 5,
"selected": false,
"text": "select SAL from EMPLOYEE E1 where \n (N - 1) = (select count(distinct(SAL)) \n from EMPLOYEE E2 \n where E2.SAL > E1.SAL )\n"
},
{
"answer_id": 815171,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "select sal,ename from emp e where\n 2=(select count(distinct sal) from emp where e.sal<=emp.sal) or\n 3=(select count(distinct sal) from emp where e.sal<=emp.sal) or\n 4=(select count(distinct sal) from emp where e.sal<=emp.sal) order by sal desc;\n"
},
{
"answer_id": 1730110,
"author": "Piyush",
"author_id": 210562,
"author_profile": "https://Stackoverflow.com/users/210562",
"pm_score": 1,
"selected": false,
"text": "Select max(sal) \nfrom table t1 \nwhere N (select max(sal) \n from table t2 \n where t2.sal > t1.sal)\n"
},
{
"answer_id": 4182477,
"author": "shankar",
"author_id": 507987,
"author_profile": "https://Stackoverflow.com/users/507987",
"pm_score": 1,
"selected": false,
"text": "SELECT * FROM tablename \nWHERE columnname<(select max(columnname) from tablename) \norder by columnname desc limit 1\n"
},
{
"answer_id": 4538635,
"author": "Ritesh",
"author_id": 554948,
"author_profile": "https://Stackoverflow.com/users/554948",
"pm_score": 0,
"selected": false,
"text": "select distinct(salary) from employee order by salary desc limit (n-1), 1;\n"
},
{
"answer_id": 12241522,
"author": "Raman kumar",
"author_id": 1642680,
"author_profile": "https://Stackoverflow.com/users/1642680",
"pm_score": -1,
"selected": false,
"text": "salary \n1256\n1256\n2563\n8546\n5645\n"
},
{
"answer_id": 12318458,
"author": "parveen",
"author_id": 1654762,
"author_profile": "https://Stackoverflow.com/users/1654762",
"pm_score": 0,
"selected": false,
"text": "select * from (select * from deletetable where rownum <=2 order by rownum desc) where rownum <=1\n"
},
{
"answer_id": 13466974,
"author": "German Alex",
"author_id": 1837741,
"author_profile": "https://Stackoverflow.com/users/1837741",
"pm_score": 2,
"selected": false,
"text": "select * from(select row_number() over (order by mark desc) as t,mark from student group by mark) as td where t=4\n"
},
{
"answer_id": 13468939,
"author": "German Alex",
"author_id": 1837741,
"author_profile": "https://Stackoverflow.com/users/1837741",
"pm_score": 0,
"selected": false,
"text": "select *\nfrom student \nwhere mark=(select mark \n from(select row_number() over (order by mark desc) as t,\n mark \n from student group by mark) as td \n where t=2)\n"
},
{
"answer_id": 14473660,
"author": "Abhishek B Patel",
"author_id": 2001168,
"author_profile": "https://Stackoverflow.com/users/2001168",
"pm_score": 2,
"selected": false,
"text": "SELECT * FROM TableName a WHERE\n n = (SELECT count(DISTINCT(b.ColumnName)) \n FROM TableName b WHERE a.ColumnName <=b.ColumnName);\n"
},
{
"answer_id": 17875240,
"author": "ria",
"author_id": 2621681,
"author_profile": "https://Stackoverflow.com/users/2621681",
"pm_score": 0,
"selected": false,
"text": "employee"
},
{
"answer_id": 20630590,
"author": "user3110552",
"author_id": 3110552,
"author_profile": "https://Stackoverflow.com/users/3110552",
"pm_score": 0,
"selected": false,
"text": "Select min(fee) \nfrom fl_FLFee \nwhere fee in (Select top 4 Fee from fl_FLFee order by 1 desc)\n"
},
{
"answer_id": 24801342,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "SELECT MIN(Sal) FROM TableName\nWHERE Sal IN\n(SELECT TOP 4 Sal FROM TableName ORDER BY Sal DESC)\n"
},
{
"answer_id": 27187656,
"author": "Prashant Maheshwari Andro",
"author_id": 2646705,
"author_profile": "https://Stackoverflow.com/users/2646705",
"pm_score": 1,
"selected": false,
"text": " SELECT * FROM TableName\n WHERE ColomnName<(select max(ColomnName) from TableName)-n order by ColomnName desc limit 1;\n"
},
{
"answer_id": 46322804,
"author": "Rahul Raina",
"author_id": 2828087,
"author_profile": "https://Stackoverflow.com/users/2828087",
"pm_score": 1,
"selected": false,
"text": "Salary"
},
{
"answer_id": 46408544,
"author": "rashedcs",
"author_id": 6714430,
"author_profile": "https://Stackoverflow.com/users/6714430",
"pm_score": 2,
"selected": false,
"text": "select column_name from table_name \norder by column_name desc limit n-1,1;\n"
},
{
"answer_id": 48053324,
"author": "Trung Lê Hoàng",
"author_id": 4902809,
"author_profile": "https://Stackoverflow.com/users/4902809",
"pm_score": 0,
"selected": false,
"text": "SELECT * FROM Employee WHERE salary in \n(SELECT salary FROM Employee ORDER BY salary DESC LIMIT N) \nORDER BY salary ASC LIMIT 1;\n"
},
{
"answer_id": 51723878,
"author": "mjp",
"author_id": 9253770,
"author_profile": "https://Stackoverflow.com/users/9253770",
"pm_score": 1,
"selected": false,
"text": "select salary \nform employee\norder by salary desc\nlimit n-1,1 ;\n"
},
{
"answer_id": 52591150,
"author": "ARSHAD M",
"author_id": 9196559,
"author_profile": "https://Stackoverflow.com/users/9196559",
"pm_score": 0,
"selected": false,
"text": "==========\nId name\n=========\n6 ARSHAD M\n7 Manu\n8 Shaji\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15181/"
] |
80,726
|
<pre><code>> jruby -S gem install warbler
JRuby limited openssl loaded. gem install jruby-openssl for full support.
Successfully installed warbler-0.9.11
1 gem installed
Installing ri documentation for warbler-0.9.11...
Installing RDoc documentation for warbler-0.9.11...
> jruby -S warble
<snip>/jruby-1.1.4/bin/warble:1: undefined method `warble' for JRuby::Commands:Class (NoMethodError)
</code></pre>
<p>Any ideas why I don't get a warbler command in my jruby bin directory?</p>
<p>Thanks,</p>
|
[
{
"answer_id": 1548574,
"author": "Vinod Singh",
"author_id": 47704,
"author_profile": "https://Stackoverflow.com/users/47704",
"pm_score": 0,
"selected": false,
"text": "gem install warbler"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14952/"
] |
80,766
|
<p>I got a typed (not connected) dataset, and many records (binary seriliazed) created with this dataset.
I've added a property to one of the types, and I want to convert the old records with the new data set.
I know how to load them: providing custom binder for the BinaryFormatter with the old schema dll.
The question is how can I convert objects of the old type to objects of the new type - both types has the same name but the new one has one more property.</p>
|
[
{
"answer_id": 81230,
"author": "Brownie",
"author_id": 6600,
"author_profile": "https://Stackoverflow.com/users/6600",
"pm_score": 2,
"selected": false,
"text": "MyDataSet myDS = new MyDataSet();\nMyDataSet.MyTableRow row1 = myDS.MyTable.NewMyTableRow();\nrow1.Name = \"Brownie\";\nmyDS.MyTable.Rows.Add(row1);\n\nMyNewDataSet myNewDS = new MyNewDataSet();\n\nusing(MemoryStream ms = new MemoryStream()){\n myDS.WriteXml(ms);\n ms.Position = 0;\n myNewDS.ReadXml(ms);\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
80,770
|
<p>I have been reading a lot of XQuery tutorials on the website. Almost all of them are teaching me XQuery syntax. Let's say I have understood the XQuery syntax, how am I going to actually implement XQuery on my website?</p>
<p>For example, I have <strong>book.xml</strong>:</p>
<pre><code><?xml version="1.0" encoding="iso-8859-1" ?>
<books>
<book>
<title>Doraemon</title>
<authorid>1</authorid>
</book>
<book>
<title>Ultraman</title>
<authorid>2</authorid>
</book>
</books>
</code></pre>
<p>Then, I have <strong>author.xml</strong></p>
<pre><code><?xml version="1.0" encoding="iso-8859-1" ?>
<authors>
<author id="1">Mr A</author>
<author id="2">Mr B</author>
</authors>
</code></pre>
<p>I want to generate HTML which looks like following:</p>
<pre><code><table>
<tr> <td>Title</td> <td>Author</td> </tr>
<tr> <td>Doraemon</td> <td>Mr A</td> </tr>
<tr> <td>Ultraman</td> <td>Mr B</td> </tr>
</table>
</code></pre>
<p>Please show me some examples. Or any website that I can do reference. Thanks very much.</p>
|
[
{
"answer_id": 82980,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<table>\n<tr><td>Title<td><td>Author<td></tr>\n{\n let $authordoc := fn:doc(\"author.xml\")\n for $book in fn:doc(\"book.xml\")/books/book\n return\n <tr>\n <td>{ $book/title }</td>\n <td>{ $authordoc/authors/author/[@id eq $book/authorid] }</td>\n </tr>\n}\n</table>\n"
},
{
"answer_id": 89704,
"author": "frglps",
"author_id": 6015,
"author_profile": "https://Stackoverflow.com/users/6015",
"pm_score": 3,
"selected": false,
"text": "(: file: titles.xqy :)\n<table>\n<tr><th>title</th><th>author</th></tr>\n{\nlet $books-doc := doc(\"books.xml\")\nlet $authors-doc := doc(\"authors.xml\")\nfor $b in $books-doc//book,\n $a in $authors-doc//author\nwhere $a/@id = $b/authorid\nreturn \n<tr>\n <td>{$b/title/text()}</td>\n <td>{$a/text()}</td>\n</tr>\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
80,787
|
<p>Any ideas how to determine the number of active threads currently running in an <a href="https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/ExecutorService.html" rel="noreferrer"><code>ExecutorService</code></a>?</p>
|
[
{
"answer_id": 80809,
"author": "Daan",
"author_id": 197,
"author_profile": "https://Stackoverflow.com/users/197",
"pm_score": 7,
"selected": true,
"text": "int getActiveCount() \n// Returns the approximate number of threads that are actively executing tasks.\n"
},
{
"answer_id": 80828,
"author": "Arno",
"author_id": 13685,
"author_profile": "https://Stackoverflow.com/users/13685",
"pm_score": 5,
"selected": false,
"text": "Executors.newFixedThreadPool()"
},
{
"answer_id": 80874,
"author": "Dave Cheney",
"author_id": 6449,
"author_profile": "https://Stackoverflow.com/users/6449",
"pm_score": 3,
"selected": false,
"text": "public int getPoolSize()\nReturns the current number of threads in the pool.\n"
},
{
"answer_id": 18563922,
"author": "andyroid",
"author_id": 1546403,
"author_profile": "https://Stackoverflow.com/users/1546403",
"pm_score": 5,
"selected": false,
"text": "pool"
},
{
"answer_id": 38182852,
"author": "Ankit Katiyar",
"author_id": 3373597,
"author_profile": "https://Stackoverflow.com/users/3373597",
"pm_score": 2,
"selected": false,
"text": "import java.util.concurrent.ExecutorService;\nimport java.util.concurrent.ThreadPoolExecutor;\n\npublic class ExecutorServiceAnalyzer implements Runnable\n{\n private final ThreadPoolExecutor threadPoolExecutor;\n private final int timeDiff;\n\n public ExecutorServiceAnalyzer(ExecutorService executorService, int timeDiff)\n {\n this.timeDiff = timeDiff;\n if (executorService instanceof ThreadPoolExecutor)\n {\n threadPoolExecutor = (ThreadPoolExecutor) executorService;\n }\n else\n {\n threadPoolExecutor = null;\n System.out.println(\"This executor doesn't support ThreadPoolExecutor \");\n }\n\n }\n\n @Override\n public void run()\n {\n if (threadPoolExecutor != null)\n {\n do\n {\n System.out.println(\"#### Thread Report:: Active:\" + threadPoolExecutor.getActiveCount() + \" Pool: \"\n + threadPoolExecutor.getPoolSize() + \" MaxPool: \" + threadPoolExecutor.getMaximumPoolSize()\n + \" ####\");\n try\n {\n Thread.sleep(timeDiff);\n }\n catch (Exception e)\n {\n }\n } while (threadPoolExecutor.getActiveCount() > 1);\n System.out.println(\"##### Terminating as only 1 thread is active ######\");\n }\n\n }\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8441/"
] |
80,801
|
<p>If I have a large number of SQLite databases, all with the same schema, what is the best way to merge them together in order to perform a query on all databases? </p>
<p>I know it is possible to use <a href="http://www.sqlite.org/lang_attach.html" rel="noreferrer">ATTACH</a> to do this but it has <a href="http://www.sqlite.org/limits.html#max_attached" rel="noreferrer">a limit</a> of 32 and 64 databases depending on the memory system on the machine.</p>
|
[
{
"answer_id": 11089277,
"author": "dfrankow",
"author_id": 34935,
"author_profile": "https://Stackoverflow.com/users/34935",
"pm_score": 7,
"selected": false,
"text": "attach 'c:\\test\\b.db3' as toMerge; \nBEGIN; \ninsert into AuditRecords select * from toMerge.AuditRecords; \nCOMMIT; \ndetach toMerge;\n"
},
{
"answer_id": 53313528,
"author": "Damilola Olowookere",
"author_id": 1823554,
"author_profile": "https://Stackoverflow.com/users/1823554",
"pm_score": 3,
"selected": false,
"text": "Ctrl + O"
},
{
"answer_id": 61954182,
"author": "Pedro Lobito",
"author_id": 797495,
"author_profile": "https://Stackoverflow.com/users/797495",
"pm_score": 2,
"selected": false,
"text": "#!/usr/bin/python\n\nimport sys, sqlite3\n\nclass sqlMerge(object):\n \"\"\"Basic python script to merge data of 2 !!!IDENTICAL!!!! SQL tables\"\"\"\n\n def __init__(self, parent=None):\n super(sqlMerge, self).__init__()\n\n self.db_a = None\n self.db_b = None\n\n def loadTables(self, file_a, file_b):\n self.db_a = sqlite3.connect(file_a)\n self.db_b = sqlite3.connect(file_b)\n\n cursor_a = self.db_a.cursor()\n cursor_a.execute(\"SELECT name FROM sqlite_master WHERE type='table';\")\n\n table_counter = 0\n print(\"SQL Tables available: \\n===================================================\\n\")\n for table_item in cursor_a.fetchall():\n current_table = table_item[0]\n table_counter += 1\n print(\"-> \" + current_table)\n print(\"\\n===================================================\\n\")\n\n if table_counter == 1:\n table_to_merge = current_table\n else:\n table_to_merge = input(\"Table to Merge: \")\n\n return table_to_merge\n\n def merge(self, table_name):\n cursor_a = self.db_a.cursor()\n cursor_b = self.db_b.cursor()\n\n new_table_name = table_name + \"_new\"\n\n try:\n cursor_a.execute(\"CREATE TABLE IF NOT EXISTS \" + new_table_name + \" AS SELECT * FROM \" + table_name)\n for row in cursor_b.execute(\"SELECT * FROM \" + table_name):\n print(row)\n cursor_a.execute(\"INSERT INTO \" + new_table_name + \" VALUES\" + str(row) +\";\")\n\n cursor_a.execute(\"DROP TABLE IF EXISTS \" + table_name);\n cursor_a.execute(\"ALTER TABLE \" + new_table_name + \" RENAME TO \" + table_name);\n self.db_a.commit()\n\n print(\"\\n\\nMerge Successful!\\n\")\n\n except sqlite3.OperationalError:\n print(\"ERROR!: Merge Failed\")\n cursor_a.execute(\"DROP TABLE IF EXISTS \" + new_table_name);\n\n finally:\n self.db_a.close()\n self.db_b.close()\n\n return\n\n def main(self):\n print(\"Please enter name of db file\")\n file_name_a = input(\"File Name A:\")\n file_name_b = input(\"File Name B:\")\n\n table_name = self.loadTables(file_name_a, file_name_b)\n self.merge(table_name)\n\n return\n\nif __name__ == '__main__':\n app = sqlMerge()\n app.main()\n"
},
{
"answer_id": 68526717,
"author": "Mohammadsadegh",
"author_id": 11586886,
"author_profile": "https://Stackoverflow.com/users/11586886",
"pm_score": 3,
"selected": false,
"text": "import sqlite3\nimport os\n\n\ndef merge_databases(db1, db2):\n con3 = sqlite3.connect(db1)\n\n con3.execute(\"ATTACH '\" + db2 + \"' as dba\")\n\n con3.execute(\"BEGIN\")\n for row in con3.execute(\"SELECT * FROM dba.sqlite_master WHERE type='table'\"):\n combine = \"INSERT OR IGNORE INTO \"+ row[1] + \" SELECT * FROM dba.\" + row[1]\n print(combine)\n con3.execute(combine)\n con3.commit()\n con3.execute(\"detach database dba\")\n\n\ndef read_files(directory):\n fname = []\n for root,d_names,f_names in os.walk(directory):\n for f in f_names:\n c_name = os.path.join(root, f)\n filename, file_extension = os.path.splitext(c_name)\n if (file_extension == '.sqlitedb'):\n fname.append(c_name)\n\n return fname\n\ndef batch_merge(directory):\n db_files = read_files(directory)\n for db_file in db_files[1:]:\n merge_databases(db_files[0], db_file)\n\nif __name__ == '__main__':\n batch_merge('/directory/to/database/files')\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2183/"
] |
80,802
|
<p>I've been wondering, is there a performance difference between using named functions and anonymous functions in Javascript? </p>
<pre><code>for (var i = 0; i < 1000; ++i) {
myObjects[i].onMyEvent = function() {
// do something
};
}
</code></pre>
<p>vs</p>
<pre><code>function myEventHandler() {
// do something
}
for (var i = 0; i < 1000; ++i) {
myObjects[i].onMyEvent = myEventHandler;
}
</code></pre>
<p>The first is tidier since it doesn't clutter up your code with rarely-used functions, but does it matter that you're re-declaring that function multiple times?</p>
|
[
{
"answer_id": 80882,
"author": "Sarhanis",
"author_id": 7966,
"author_profile": "https://Stackoverflow.com/users/7966",
"pm_score": 0,
"selected": false,
"text": "for (var i = 0, iLength = imgs.length; i < iLength; i++)\n{\n // do something\n}\n"
},
{
"answer_id": 80927,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 5,
"selected": false,
"text": "var dummyVar;\nfunction test1() {\n for (var i = 0; i < 1000000; ++i) {\n dummyVar = myFunc;\n }\n}\n\nfunction test2() {\n for (var i = 0; i < 1000000; ++i) {\n dummyVar = function() {\n var x = 0;\n x++;\n };\n }\n}\n\nfunction myFunc() {\n var x = 0;\n x++;\n}\n\ndocument.onclick = function() {\n var start = new Date();\n test1();\n var mid = new Date();\n test2();\n var end = new Date();\n alert (\"Test 1: \" + (mid - start) + \"\\n Test 2: \" + (end - mid));\n}\n"
},
{
"answer_id": 81185,
"author": "annakata",
"author_id": 13018,
"author_profile": "https://Stackoverflow.com/users/13018",
"pm_score": 0,
"selected": false,
"text": "function test(m)\n{\n for (var i = 0; i < 1000000; ++i) \n {\n m();\n }\n}\n\nfunction named() {var x = 0; x++;}\n\nvar test1 = named;\n\nvar test2 = function() {var x = 0; x++;}\n\ndocument.onclick = function() {\n var start = new Date();\n test(test1);\n var mid = new Date();\n test(test2);\n var end = new Date();\n alert (\"Test 1: \" + (mid - start) + \"ms\\n Test 2: \" + (end - mid) + \"ms\");\n}\n"
},
{
"answer_id": 81329,
"author": "Atif Aziz",
"author_id": 6682,
"author_profile": "https://Stackoverflow.com/users/6682",
"pm_score": 8,
"selected": true,
"text": "for (var i = 0; i < 1000; ++i) { \n myObjects[i].onMyEvent = function() {\n // do something \n };\n}\n"
},
{
"answer_id": 81354,
"author": "matt lohkamp",
"author_id": 14026,
"author_profile": "https://Stackoverflow.com/users/14026",
"pm_score": 0,
"selected": false,
"text": "alert(1 + 1);\n"
},
{
"answer_id": 44602865,
"author": "bluenote10",
"author_id": 1804173,
"author_profile": "https://Stackoverflow.com/users/1804173",
"pm_score": 0,
"selected": false,
"text": "// Variant 1: create once\nfunction adder(a, b) {\n return a + b;\n}\nfor (var i = 0; i < 100000; ++i) {\n var x = adder(412, 123);\n}\n\n// Variant 2: repeated creation via function statement\nfor (var i = 0; i < 100000; ++i) {\n function adder(a, b) {\n return a + b;\n }\n var x = adder(412, 123);\n}\n\n// Variant 3: repeated creation via function expression\nfor (var i = 0; i < 100000; ++i) {\n var x = (function(a, b) { return a + b; })(412, 123);\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
80,820
|
<p>On a file path field, I want to capture the directory path like:</p>
<pre><code>textbox1.Text = directory path
</code></pre>
<p>Anyone?</p>
|
[
{
"answer_id": 80824,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 3,
"selected": false,
"text": "DialogResult result = folderBrowserDialog1.ShowDialog();\nif (result.Equals(get_DialogResult().OK)) {\n textbox1.Text = folderBrowserDialog1.get_SelectedPath();\n}\n"
},
{
"answer_id": 81047,
"author": "MarlonRibunal",
"author_id": 10385,
"author_profile": "https://Stackoverflow.com/users/10385",
"pm_score": 3,
"selected": true,
"text": "private void button1_Click(object sender, EventArgs e)\n{\n FolderBrowserDialog profilePath = new FolderBrowserDialog();\n\n if (profilePath.ShowDialog() == DialogResult.OK) \n {\n profilePathTextBox.Text = profilePath.SelectedPath;\n }\n else\n {\n profilePathTextBox.Text = \"Please Specify The Profile Path\";\n }\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10385/"
] |
80,831
|
<p>There is a <a href="http://support.microsoft.com/?scid=194627" rel="nofollow noreferrer">Microsoft knowledge base article</a> with sample code to open all mailboxes in a given information store. It works so far (requires a bit of <a href="http://blogs.msdn.com/jasonjoh/archive/2004/08/01/204585.aspx" rel="nofollow noreferrer">copy & pasting</a> on compilers newer than VC++ 6.0).</p>
<p>At one point it calls IExchangeManageStore::GetMailboxTable with the distinguished name of the information store. For the Exchange 2007 Trial Virtual Server image it has to look like this: </p>
<pre><code>"/o=Litware Inc/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Configuration/cn=servers/cn=DC1".
</code></pre>
<p>Using <a href="http://www.dimastr.com/outspy/" rel="nofollow noreferrer">OutlookSpy</a> and clicking on IMsgStore and IExchangeManageStore reveals the desired string next to "Server DN:".</p>
<p>I want to avoid forcing the user to put this into a config file. So if OutlookSpy can do it, how can my application find out the distinguished name of the information store where the currently open mailbox is on?</p>
|
[
{
"answer_id": 90972,
"author": "Sebastian Kirsche",
"author_id": 4097,
"author_profile": "https://Stackoverflow.com/users/4097",
"pm_score": 3,
"selected": true,
"text": "printf(\"Created MAPI session\\n\");\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4097/"
] |
80,832
|
<p>I have an Access 2007 form that is searchable by a combobox. When I add a new record, I need to update the combobox to include the newly added item. </p>
<p>I assume that something needs to be done in AfterInsert event of the form but I can't figure out what. </p>
<p>How can I rebind the combobox after inserting so that the new item appears in the list?</p>
|
[
{
"answer_id": 81147,
"author": "Philippe Grondier",
"author_id": 11436,
"author_profile": "https://Stackoverflow.com/users/11436",
"pm_score": 0,
"selected": false,
"text": "myComboBoxControl.recordsource = _\n \"SELECT relationDescription FROM Table_relationType\"\n"
},
{
"answer_id": 81536,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 0,
"selected": false,
"text": " Response = acDataErrAdded\n"
},
{
"answer_id": 81872,
"author": "Chris OC",
"author_id": 11041,
"author_profile": "https://Stackoverflow.com/users/11041",
"pm_score": 0,
"selected": false,
"text": "Private Sub Form_AfterUpdate() \n On Error GoTo Proc_Err \n\n Me.cboSearch.Requery \n\n Exit Sub \nProc_Err: \n MsgBox Err.Number & vbCrLf & vbCrLf & Err.Description\n Err.Clear \nEnd Sub\n"
},
{
"answer_id": 89106,
"author": "David-W-Fenton",
"author_id": 9787,
"author_profile": "https://Stackoverflow.com/users/9787",
"pm_score": 1,
"selected": false,
"text": " Private Sub RequerySearchCombo()\n If Me.Dirty Then Me.Dirty = False\n Me!MyCombo.Requery\n End Sub\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14579/"
] |
80,833
|
<p>As the local subversion czar i explain to everyone to keep only source code and non-huge text files in the repository, not huge binary data files. Smaller binary files that are parts of tests, maybe. </p>
<p>Unfortunately i work with <em>humans</em>! Someone is likely to someday accidentally commit a 800MB binary hulk. This slows down repository operations. </p>
<p>Last time i checked, you can't delete a file from the repository; only make it not part of the latest revision. The repository keeps the monster for all eternity, in case anyone ever wants to recall the state of the repository for that date or revision number. </p>
<p>Is there a way to really delete that monster file and end up with a decent sized repository? I've tried the svnadmin dump/load thing but it was a pain.</p>
|
[
{
"answer_id": 85409,
"author": "Max Cantor",
"author_id": 16034,
"author_profile": "https://Stackoverflow.com/users/16034",
"pm_score": 2,
"selected": false,
"text": "svnadmin dump /var/repos -r 1:3848 > ~/repos_dump\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10468/"
] |
80,846
|
<p>I am trying to use Zend_Db_Select to write a select query that looks somewhat like this:</p>
<pre><code>SELECT * FROM bar WHERE a = 1 AND (b = 2 OR b = 3)
</code></pre>
<p>However, when using a combination of where() and orWhere(), it seems impossible to use condition grouping like the above.</p>
<p>Are there any native ways in Zend Framework to achieve the above (without writing the actual query?)</p>
|
[
{
"answer_id": 80871,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": true,
"text": "\n// Build this query:\n// SELECT product_id, product_name, price\n// FROM \"products\"\n// WHERE (price < 100.00 OR price > 500.00)\n// AND (product_name = 'Apple')\n\n$minimumPrice = 100;\n$maximumPrice = 500;\n$prod = 'Apple';\n\n$select = $db->select()\n ->from('products',\n array('product_id', 'product_name', 'price'))\n ->where(\"price < $minimumPrice OR price > $maximumPrice\")\n ->where('product_name = ?', $prod);\n\n"
},
{
"answer_id": 727266,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "// Build this query:\n// SELECT product_id, product_name, price\n// FROM \"products\"\n// WHERE (product_name = 'Bananas' OR product_name = 'Apples')\n// AND (price = 100)\n\n$name1 = 'Bananas';\n\n$name2 = 'Apples';\n\n$price = 100;\n\n$select = $db->select()\n\n->from('products',\n array('product_id', 'product_name', 'price'))\n\n->where(\"product_name = '\" . $name1 . \"' OR product_name = '\" . $name2 . \"'\")\n\n->where(\"price=?\", $price);\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11568/"
] |
80,857
|
<p>In the Delphi IDE, you can hold control and click on a method to jump to its definition. In VS2008, you have to right-click and select "Go To Definition".</p>
<p>I use this function quite often, so I'd really like to get VS to behave like Delphi in this regard - its so much quicker to ctrl+click.</p>
<p>I don't think there's a way to get this working in base VS2008 - am I wrong? Or maybe there's a plugin I could use?</p>
<p><strong>Edit</strong>: Click then F12 does work - but isn't really a good solution for me.. It's still way slower than ctrl+click.
I might try AutoHotkey, since I'm already running it for something else.</p>
<p><strong>Edit</strong>: <a href="http://www.autohotkey.com" rel="nofollow noreferrer">AutoHotkey</a> worked for me. Here's my script:</p>
<pre><code>SetTitleMatchMode RegEx
#IfWinActive, .* - Microsoft Visual Studio
^LButton::Send {click}{f12}
</code></pre>
|
[
{
"answer_id": 2633651,
"author": "Tianhao Qiu",
"author_id": 315969,
"author_profile": "https://Stackoverflow.com/users/315969",
"pm_score": 2,
"selected": false,
"text": "SetTitleMatchMode 2\n#IfWinActive, Microsoft Visual C++ 2010 Express\n^LButton::Send {click}{f12}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/369/"
] |
80,859
|
<p>I'm writing a Rails application which will monitor data quality over some specific databases. In order to do that, I need to be able to execute direct SQL queries over these databases - which of course are not the same as the one used to drive the Rails application models. In short, this means I can't use the trick of going through the ActiveRecord base connection.</p>
<p>The databases I need to connect to are not known at design time (i.e.: I can't put their details in database.yaml). Rather, I have a model 'database_details' which the user will use to enter the details of the databases over which the application will execute queries at runtime. </p>
<p>So the connection to these databases really is dynamic and the details are resolved at runtime only.</p>
|
[
{
"answer_id": 80946,
"author": "Codebeef",
"author_id": 12037,
"author_profile": "https://Stackoverflow.com/users/12037",
"pm_score": 0,
"selected": false,
"text": "self.establish_connection"
},
{
"answer_id": 81207,
"author": "Jean",
"author_id": 7898,
"author_profile": "https://Stackoverflow.com/users/7898",
"pm_score": 3,
"selected": false,
"text": "ActiveRecord::Base.establish_connection(\n :adapter => \"mysql\",\n :host => \"localhost\",\n :username => \"myuser\",\n :password => \"mypass\",\n :database => \"somedatabase\"\n)\n"
},
{
"answer_id": 3737505,
"author": "brokenbeatnik",
"author_id": 90709,
"author_profile": "https://Stackoverflow.com/users/90709",
"pm_score": 4,
"selected": true,
"text": " def get_custom_connection(identifier, host, port, dbname, dbuser, password)\n eval(\"Custom_#{identifier} = Class::new(ActiveRecord::Base)\")\n eval(\"Custom_#{identifier}.establish_connection(:adapter=>'mysql', :host=>'#{host}', :port=>#{port}, :database=>'#{dbname}', \" +\n \":username=>'#{dbuser}', :password=>'#{password}')\") \n return eval(\"Custom_#{identifier}.connection\")\n end\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11477/"
] |
80,875
|
<p>How do you create a hardlink (as opposed to a symlink or a Mac OS alias) in OS X that points to a directory? I already know the command "ln target destination" but that only works when the target is a file. I know that Mac OS, unlike other Unix environments, does allow hardlinking to folders (this is used for Time Machine, for example) but I don't know how to do it myself.</p>
|
[
{
"answer_id": 805001,
"author": "username",
"author_id": 4939,
"author_profile": "https://Stackoverflow.com/users/4939",
"pm_score": 6,
"selected": true,
"text": "#include <unistd.h>\n#include <stdio.h>\n\nint main(int argc, char *argv[])\n{\n if (argc != 3) return 1;\n\n int ret = link(argv[1], argv[2]);\n\n if (ret != 0) perror(\"link\");\n\n return ret;\n}\n"
},
{
"answer_id": 1565096,
"author": "Jesper Rønn-Jensen",
"author_id": 109305,
"author_profile": "https://Stackoverflow.com/users/109305",
"pm_score": 2,
"selected": false,
"text": "rsync"
},
{
"answer_id": 2038065,
"author": "Rich",
"author_id": 247592,
"author_profile": "https://Stackoverflow.com/users/247592",
"pm_score": 4,
"selected": false,
"text": " -d, -F, --directory\n allow the superuser to attempt to hard link directories (note:\n will probably fail due to system restrictions, even for the\n superuser)\n"
},
{
"answer_id": 4707231,
"author": "Bob",
"author_id": 577700,
"author_profile": "https://Stackoverflow.com/users/577700",
"pm_score": 6,
"selected": false,
"text": "#include <stdio.h>\n#include <unistd.h>\nint\nmain(int argc, char *argv[])\n{\n if (argc != 2)\n return 1;\n int ret = unlink(argv[1]);\n if (ret != 0)\n perror(\"unlink\");\n return ret;\n}\n\ngcc -o hunlink hunlink.c\n"
},
{
"answer_id": 14842414,
"author": "Kit Sunde",
"author_id": 29347,
"author_profile": "https://Stackoverflow.com/users/29347",
"pm_score": 0,
"selected": false,
"text": "sudo port install bindfs\nsudo bindfs ~/source_dir ~/target_dir\n"
},
{
"answer_id": 36540025,
"author": "zainengineer",
"author_id": 3232611,
"author_profile": "https://Stackoverflow.com/users/3232611",
"pm_score": 1,
"selected": false,
"text": "sudo mount --bind /some/existing_real_contents /else/dummy_but_existing_directory\nsudo umount /else/dummy_but_existing_directory\n"
},
{
"answer_id": 37742750,
"author": "Simon East",
"author_id": 195835,
"author_profile": "https://Stackoverflow.com/users/195835",
"pm_score": 4,
"selected": false,
"text": "brew install hardlink-osx\n"
},
{
"answer_id": 39472511,
"author": "techiejohn",
"author_id": 4805400,
"author_profile": "https://Stackoverflow.com/users/4805400",
"pm_score": 1,
"selected": false,
"text": "perl -e 'link \"/Users/me/Documents\", \"/Users/me/Google Drive/Documents\"'\n"
},
{
"answer_id": 39891753,
"author": "ccpizza",
"author_id": 191246,
"author_profile": "https://Stackoverflow.com/users/191246",
"pm_score": 3,
"selected": false,
"text": "ln"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4939/"
] |
80,892
|
<p>getEmployeeNameByBatchId(int batchID)<BR>
getEmployeeNameBySSN(Object SSN)<BR>
getEmployeeNameByEmailId(String emailID)<BR>
getEmployeeNameBySalaryAccount(SalaryAccount salaryAccount)<BR></p>
<p>or</p>
<p>getEmployeeName(int typeOfIdentifier, byte[] identifier) -> In this methods the typeOfIdentifier tells if identifier is batchID/SSN/emailID/salaryAccount</p>
<p>Which one of the above is better way implement a get method? </p>
<p>These methods would be in a Servlet and calls would be made from an API which would be provided to the customers.</p>
|
[
{
"answer_id": 80954,
"author": "Javaxpert",
"author_id": 15241,
"author_profile": "https://Stackoverflow.com/users/15241",
"pm_score": -1,
"selected": false,
"text": "public ??? getEmployeeName(Object obj){\n\nif (obj instanceof Integer){\n\n ...\n\n} else if (obj instanceof String){\n\n...\n\n} else if .... // and so on\n\n\n} else throw SomeMeaningFullRuntimeException()\n\nreturn employeeName\n}\n"
},
{
"answer_id": 80956,
"author": "user9116",
"author_id": 9116,
"author_profile": "https://Stackoverflow.com/users/9116",
"pm_score": 0,
"selected": false,
"text": "getEmployeeName( int batchID );\ngetEmployeeName( Object SSN );\n\netc.\n"
},
{
"answer_id": 80962,
"author": "m_pGladiator",
"author_id": 446104,
"author_profile": "https://Stackoverflow.com/users/446104",
"pm_score": 2,
"selected": false,
"text": "getEmployeeName(int batchID)\ngetEmployeeName(Object SSN)\ngetEmployeeName(String emailID)\ngetEmployeeName(SalaryAccount salaryAccount)\n"
},
{
"answer_id": 81018,
"author": "jrudolph",
"author_id": 7647,
"author_profile": "https://Stackoverflow.com/users/7647",
"pm_score": 3,
"selected": false,
"text": "interface Employee{\n public String getName();\n int getBatchId();\n}\ninterface Filter{\n boolean matches(Employee e);\n}\npublic Filter byName(final String name){\n return new Filter(){\n public boolean matches(Employee e) {\n return e.getName().equals(name);\n }\n };\n}\npublic Filter byBatchId(final int id){\n return new Filter(){\n public boolean matches(Employee e) {\n return e.getBatchId() == id;\n }\n };\n}\npublic Employee findEmployee(Filter sel){\n List<Employee> allEmployees = null;\n for (Employee e:allEmployees)\n if (sel.matches(e))\n return e;\n return null;\n}\npublic void usage(){\n findEmployee(byName(\"Gustav\"));\n findEmployee(byBatchId(5));\n}\n"
},
{
"answer_id": 81712,
"author": "Krakkos",
"author_id": 15533,
"author_profile": "https://Stackoverflow.com/users/15533",
"pm_score": -1,
"selected": false,
"text": "GetEmployeeName(Enum identifier)\n{\n switch (identifier)\n case eBatchID:\n {\n // Do stuff\n }\n case eSSN:\n {\n }\n case eEmailId:\n {\n }\n case eSalary:\n {\n }\n default:\n {\n // No match\n return 0;\n }\n}\n\nenum Identifier\n{\n eBatchID,\n eSSN,\n eEmailID,\n eSalary\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80892",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15264/"
] |
80,923
|
<p>I'm working an a very large scale projects, where the compilation time is <strong>very</strong> long. What tools can I use (preferably open source) on Linux, to find the most heavily included files and that optimize their useages?
Just to be clearer, I need a tool which will, given the dependencies, show me which headers are the most included. By the way, we do use distributed compiling</p>
|
[
{
"answer_id": 81003,
"author": "shodanex",
"author_id": 11589,
"author_profile": "https://Stackoverflow.com/users/11589",
"pm_score": 0,
"selected": false,
"text": "strace -e trace=open -o outfile make\ngrep 'some handy regex to match header' \n"
},
{
"answer_id": 81065,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 2,
"selected": false,
"text": "find . -exec grep '[ \\t]*#include[ \\t][ \\t]*[\"<][^\">][\">]' {} ';'\n | sed 's/^[ \\t]*#include[ \\t][ \\t]*[\"<]//'\n | sed 's/[\">].*$//'\n | sort\n | uniq -c\n | sort -r -k1 -n\n"
},
{
"answer_id": 81075,
"author": "Joe Hildebrand",
"author_id": 8388,
"author_profile": "https://Stackoverflow.com/users/8388",
"pm_score": 1,
"selected": false,
"text": "makedepend -m *.c -f - > /dev/null\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12371/"
] |
80,963
|
<p>I am trying to write some JavaScript RegEx to replace user inputed tags with real html tags, so <code>[b]</code> will become <code><b></code> and so forth. the RegEx I am using looks like so</p>
<pre><code>var exptags = /\[(b|u|i|s|center|code){1}]((.){1,}?)\[\/(\1){1}]/ig;
</code></pre>
<p>with the following JavaScript</p>
<pre><code>s.replace(exptags,"<$1>$2</$1>");
</code></pre>
<p>this works fine for single nested tags, for example:</p>
<pre><code>[b]hello[/b] [u]world[/u]
</code></pre>
<p>but if the tags are nested inside each other it will only match the outer tags, for example </p>
<pre><code>[b]foo [u]to the[/u] bar[/b]
</code></pre>
<p>this will only match the <code>b</code> tags. how can I fix this? should i just loop until the starting string is the same as the outcome? I have a feeling that the <code>((.){1,}?)</code> patten is wrong also?</p>
<p>Thanks</p>
|
[
{
"answer_id": 81123,
"author": "vava",
"author_id": 6258,
"author_profile": "https://Stackoverflow.com/users/6258",
"pm_score": 0,
"selected": false,
"text": "[b]"
},
{
"answer_id": 81142,
"author": "Richard Szalay",
"author_id": 3603,
"author_profile": "https://Stackoverflow.com/users/3603",
"pm_score": 0,
"selected": false,
"text": "((.){1,}?)\n"
},
{
"answer_id": 81418,
"author": "Jonathan Lonowski",
"author_id": 15031,
"author_profile": "https://Stackoverflow.com/users/15031",
"pm_score": 0,
"selected": false,
"text": "var s = '[b]hello[/b] [u]world[/u] [b]foo [u]to the[/u] bar[/b]';\nvar exptags = /\\[(b|u|i|s|center|code){1}]((.){1,}?)\\[\\/(\\1){1}]/ig;\n\nwhile (s.match(exptags)) {\n s = s.replace(exptags, \"<$1>$2</$1>\");\n}\n\ndocument.writeln('<div>' + s + '</div>'); // after\n"
},
{
"answer_id": 81573,
"author": "Joe Hildebrand",
"author_id": 8388,
"author_profile": "https://Stackoverflow.com/users/8388",
"pm_score": 0,
"selected": false,
"text": "var exptags = /\\[(b|u|i|s|center|code)](.*)\\[\\/\\1]/ig;\n"
},
{
"answer_id": 82990,
"author": "freespace",
"author_id": 8297,
"author_profile": "https://Stackoverflow.com/users/8297",
"pm_score": 0,
"selected": false,
"text": "tagreg=/\\[(.?)?(b|u|i|s|center|code)\\]/gi;\n\"[b][i]helloworld[/i][/b]\".replace(tagreg, \"<$1$2>\");\n\"[b]helloworld[/b]\".replace(tagreg, \"<$1$2>\");\n"
},
{
"answer_id": 83441,
"author": "A Nony Mouse",
"author_id": 7182,
"author_profile": "https://Stackoverflow.com/users/7182",
"pm_score": 2,
"selected": false,
"text": ".innerHTML"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2098/"
] |
80,993
|
<p>As you can see, even after the program should have died it speaks from the grave. Is there a way to "deregister" the exitfunction in case of exceptions?</p>
<pre><code>import atexit
def helloworld():
print("Hello World!")
atexit.register(helloworld)
raise Exception("Good bye cruel world!")
</code></pre>
<p>outputs</p>
<pre><code>Traceback (most recent call last):
File "test.py", line 8, in <module>
raise Exception("Good bye cruel world!")
Exception: Good bye cruel world!
Hello World!
</code></pre>
|
[
{
"answer_id": 81051,
"author": "Joe Skora",
"author_id": 14057,
"author_profile": "https://Stackoverflow.com/users/14057",
"pm_score": -1,
"selected": false,
"text": "import os\nos._exit(0)\n"
},
{
"answer_id": 81087,
"author": "Sylvain Defresne",
"author_id": 5353,
"author_profile": "https://Stackoverflow.com/users/5353",
"pm_score": 4,
"selected": true,
"text": "atexit"
},
{
"answer_id": 81107,
"author": "Ber",
"author_id": 11527,
"author_profile": "https://Stackoverflow.com/users/11527",
"pm_score": 0,
"selected": false,
"text": "import atexit\nimport os\n\ndef helloworld():\n print \"Hello World!\"\n\natexit.register(helloworld) \n\ntry:\n raise Exception(\"Good bye cruel world!\")\n\nexcept Exception, e:\n print 'caught unhandled exception', str(e)\n\n os._exit(1)\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/80993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15274/"
] |
81,021
|
<p>I'm looking for an efficient way (using PHP with a Mysql Database) to suggest alternative spelling for a query.</p>
<p>I know I can use services such as <a href="http://developer.yahoo.com/search/web/V1/spellingSuggestion.html" rel="nofollow noreferrer">Yahoo's Spelling Suggestion</a> but I want the suggestions to be based on what is currently available in the database. </p>
<p>For example: The user has to fill a form with a "City" field, and I want to make sure that everyone will use the same spelling for said city, (so I don't end up with people filling in "Pitsburgh" when what they mean is "Pittsburgh" ). </p>
<p>This was only an example but, basically I want to search what is already in the database for entries where the spelling is really close to what the user entered...</p>
<p>Any algorithm, tutorials or ideas on how to achieve this?</p>
|
[
{
"answer_id": 81254,
"author": "sven",
"author_id": 46,
"author_profile": "https://Stackoverflow.com/users/46",
"pm_score": 1,
"selected": false,
"text": "int LevenshteinDistance(char s[1..m], char t[1..n])\n // d is a table with m+1 rows and n+1 columns\n declare int d[0..m, 0..n]\n\n for i from 0 to m\n d[i, 0] := i\n for j from 0 to n\n d[0, j] := j\n\n for i from 1 to m\n for j from 1 to n\n {\n if s[i] = t[j] then cost := 0\n else cost := 1\n d[i, j] := minimum(\n d[i-1, j] + 1, // deletion\n d[i, j-1] + 1, // insertion\n d[i-1, j-1] + cost // substitution\n )\n }\n\n return d[m, n]\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14981/"
] |
81,022
|
<p>In the KornShell (ksh) on <b>AIX UNIX Version 5.3</b> with the editor mode set to vi using:</p>
<pre><code>set -o vi
</code></pre>
<p>What are the key-strokes at the shell command line to autocomplete a file or directory name?</p>
|
[
{
"answer_id": 81135,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 5,
"selected": true,
"text": "Press keys: Command line is:\nx x\n<ESC>\\ x\n1 x1\n<ESC>\\ x171\ng<ESC>\\ x171go\n"
},
{
"answer_id": 86599,
"author": "Brian Deterling",
"author_id": 14619,
"author_profile": "https://Stackoverflow.com/users/14619",
"pm_score": 2,
"selected": false,
"text": "<ESC><shift-8> x.txt x171 x171go\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/381/"
] |
81,052
|
<p>Why wouldn't I choose abstract? What are the limitations to declaring a class member virtual? Can only methods be declared virtual?</p>
|
[
{
"answer_id": 81171,
"author": "Kokuma",
"author_id": 12088,
"author_profile": "https://Stackoverflow.com/users/12088",
"pm_score": 4,
"selected": true,
"text": "using System;\nusing C=System.Console;\n\nnamespace Foo\n{\n public class Bar\n {\n public static void Main(string[] args)\n {\n myImplementationOfTest miot = new myImplementationOfTest();\n miot.myVirtualMethod();\n miot.myOtherVirtualMethod();\n miot.myProperty = 42;\n miot.myAbstractMethod();\n }\n }\n\n public abstract class test\n {\n public abstract int myProperty\n {\n get;\n set;\n }\n\n public abstract void myAbstractMethod();\n\n public virtual void myVirtualMethod()\n {\n C.WriteLine(\"foo\");\n }\n\n public virtual void myOtherVirtualMethod()\n {\n }\n }\n\n public class myImplementationOfTest : test\n {\n private int _foo;\n public override int myProperty\n {\n get { return _foo; }\n set { _foo = value; }\n }\n\n public override void myAbstractMethod()\n {\n C.WriteLine(myProperty);\n }\n\n public override void myOtherVirtualMethod()\n {\n C.WriteLine(\"bar\");\n }\n }\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6651/"
] |
81,071
|
<p>I get the following error in Visual Studio 2005 when doing a build:</p>
<blockquote>
<p>Error 9 Cannot register assembly
"E:\CSharp\project\Some.Assembly.dll"
- access denied. Access is denied. (Exception from HRESULT: 0x80070005
(E_ACCESSDENIED)) project</p>
</blockquote>
<p>It happens only intermittantly and does go away if I restart the IDE, however this is incredibly annoying and I would like to put a stop to it happening permanently, if I can. I've checked the assembly itself, and it is not set to read only, so I've no idea why Visul Studio is getting a lock on it. I am working in Debug mode.</p>
<p>I've had a look around google, but can't seem to find anything other than "restart VS". Does anyone have any suggestions as to how I can resolve this annoying problem?</p>
|
[
{
"answer_id": 53152824,
"author": "AlainD",
"author_id": 2377399,
"author_profile": "https://Stackoverflow.com/users/2377399",
"pm_score": 0,
"selected": false,
"text": ".reg"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3181/"
] |
81,073
|
<p>I need to access a <strong>SVN</strong> repository from home, that runs under the IP <code>192.168.0.10</code> in the work network.
I can establish a <code>SSH</code> tunnel to my localhost.
Now I have to map <code>192.168.0.10</code> in a way, that instead <code>127.0.0.1</code> is accessed.
Does anybody know a way to do this under Windows?</p>
|
[
{
"answer_id": 81101,
"author": "prakash",
"author_id": 123,
"author_profile": "https://Stackoverflow.com/users/123",
"pm_score": 0,
"selected": false,
"text": "%SystemRoot%\\system32\\drivers\\etc\\"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
81,099
|
<p>As the title states, I'd be interested to find a safe feature-based (that is, without using navigator.appName or navigator.appVersion) way to detect Google Chrome.</p>
<p>By feature-based I mean, for example:</p>
<pre><code>if(window.ActiveXObject) {
// internet explorer!
}
</code></pre>
<p><strong>Edit:</strong> As it's been pointed out, the question doesn't make much sense (obviously if you want to implement a feature, you test for it, if you want to detect for a specific browser, you check the user agent), sorry, it's 5am ;) Let me me phrase it like this: Are there any javascript objects and/or features that are unique to Chrome... </p>
|
[
{
"answer_id": 81179,
"author": "micahwittman",
"author_id": 11181,
"author_profile": "https://Stackoverflow.com/users/11181",
"pm_score": 1,
"selected": false,
"text": "var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;"
},
{
"answer_id": 84699,
"author": "pcorcoran",
"author_id": 15992,
"author_profile": "https://Stackoverflow.com/users/15992",
"pm_score": 6,
"selected": true,
"text": "isChrome = function() {\n return Boolean(window.chrome);\n}\n"
},
{
"answer_id": 2855010,
"author": "Jan Turoň",
"author_id": 343721,
"author_profile": "https://Stackoverflow.com/users/343721",
"pm_score": 3,
"selected": false,
"text": "var is = {\n ff: window.globalStorage,\n ie: document.all && !window.opera,\n ie6: !window.XMLHttpRequest,\n ie7: document.all && window.XMLHttpRequest && !XDomainRequest && !window.opera,\n ie8: document.documentMode==8,\n opera: Boolean(window.opera),\n chrome: Boolean(window.chrome),\n safari: window.getComputedStyle && !window.globalStorage && !window.opera\n}\n"
},
{
"answer_id": 50942571,
"author": "ugur akkurt",
"author_id": 7496956,
"author_profile": "https://Stackoverflow.com/users/7496956",
"pm_score": 0,
"selected": false,
"text": "window.chrome"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81099",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14981/"
] |
81,104
|
<p>Does anyone know why Microsoft does not ship a numeric text box with its .NET framework e.g. a text box which would ensure that the characters entered are always a valid number? It's something which is commonly used across applications of different flavours and indeed something which most GUI libraries (well, those that I know) deliver in some way. While it's not <em>that</em> difficult to write your own, it's not trivial either.</p>
<p>So, I'm interested in finding out if anyone can rationalise this omission.</p>
<p>edit: Thanks for the suggestions. Whilst masked text boxes and numeric up-downs have their place; I am interested in a control that looks like a text box but automatically performs validation on key press that the input corresponds to a valid number. In my (admittedly limited) experience, this is something which is used quite a bit (we don't always want the static constraints imposed by masked text boxes, just as we don't always want the up-down controls at the side). </p>
<p>There are lots of implementations with varying degrees of quality of this on the net and indeed there's even an example of this on the <a href="http://msdn.microsoft.com/en-us/library/ms229644.aspx" rel="nofollow noreferrer">MSDN</a>. </p>
<p>edit2: Thanks guys, so it sounds like the numeric up-down is the .NET control to use for numeric input only (and the reason why we don't actually have an explicit numeric text box control). It would have been great if it automatically disallowed the input of non-numeric characters (on keypress, on paste etc) but I guess it's good enough that it performs the validation when the control loses focus. And, one could do the on keypress, on paste validation if one were really keen... </p>
|
[
{
"answer_id": 81853,
"author": "Mike Dimmick",
"author_id": 6970,
"author_profile": "https://Stackoverflow.com/users/6970",
"pm_score": 1,
"selected": false,
"text": "ES_NUMBER"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4368/"
] |
81,150
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/48935/how-can-i-register-a-global-hot-key-to-say-ctrlshiftletter-using-wpf-and-ne">How can I register a global hot key to say CTRL+SHIFT+(LETTER) using WPF and .NET 3.5?</a> </p>
</blockquote>
<p>I'd like to have multiple global hotkeys in my new app (to control the app from anywhere in windows), and all of the given sources/solutions I found on the web seem to provide with a sort of a limping solution (either solutions only for one g.hotkey, or solutions that while running create annoying mouse delays on the screen).</p>
<p>Does anyone here know of a resource that can help me achive this, that I can learn from?
Anything?</p>
<p>Thanks ! :)</p>
|
[
{
"answer_id": 2611761,
"author": "Ohad Schneider",
"author_id": 67824,
"author_profile": "https://Stackoverflow.com/users/67824",
"pm_score": 5,
"selected": false,
"text": "Hotkey hk = new Hotkey();\n\nhk.KeyCode = Keys.1;\nhk.Windows = true;\nhk.Pressed += delegate { Console.WriteLine(\"Windows+1 pressed!\"); };\n\nhk.Register(myForm); \n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
81,154
|
<p>I have an MS Access database, how can I determine which encoding characters are used in the database?</p>
|
[
{
"answer_id": 30446096,
"author": "denfromufa",
"author_id": 2230844,
"author_profile": "https://Stackoverflow.com/users/2230844",
"pm_score": 2,
"selected": false,
"text": "str.encode('dbcs')"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/205368/"
] |
81,158
|
<p>I'm desperately looking for cheap ways to lower the build times on my home PC. I just read an <a href="http://www.axantum.com/Blog/post/How-to-make-a-file-read-in-Windows-not-become-a-write.aspx" rel="nofollow noreferrer">article about disabling the Last Access Time attribute</a> of a file on Windows XP, so that simple reads don't write anything back to disk.</p>
<blockquote>
<p>It's really simple too. At a DOS-prompt write:</p>
<p><code>fsutil behavior set disablelastaccess 1</code></p>
</blockquote>
<p>Has anyone ever tried it in the context of <strong>building C++ projects</strong>? Any drawbacks?</p>
<p>[Edit] More on the topic <a href="http://www.windowsdevcenter.com/pub/a/windows/2005/02/08/NTFS_Hacks.html" rel="nofollow noreferrer">here</a>.</p>
|
[
{
"answer_id": 83057,
"author": "Mark",
"author_id": 4405,
"author_profile": "https://Stackoverflow.com/users/4405",
"pm_score": 0,
"selected": false,
"text": "#include \"file1.cpp\"\n#include \"file2.cpp\"\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2095/"
] |
81,160
|
<p>What is the best, preferably free/open source tool for auto-generating Java unit-tests? I know, the unit-tests cannot really serve the same purpose as normal TDD Unit-Tests which document and drive the design of the system. However auto-generated unit-tests can be useful if you have a huge legacy codebase and want to know whether the changes you are required to make will have unwanted, obscure side-effects.</p>
|
[
{
"answer_id": 64465028,
"author": "the_limey",
"author_id": 3104986,
"author_profile": "https://Stackoverflow.com/users/3104986",
"pm_score": 2,
"selected": false,
"text": "@Test\npublic void testInitUpdateOwnerForm() throws Exception {\n // Arrange\n Owner owner = new Owner();\n owner.setLastName(\"Doe\");\n owner.setId(1);\n owner.setCity(\"Oxford\");\n owner.setPetsInternal(new HashSet<Pet>());\n owner.setAddress(\"42 Main St\");\n owner.setFirstName(\"Jane\");\n owner.setTelephone(\"4105551212\");\n when(this.ownerRepository.findById((Integer) any())).thenReturn(owner);\n MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get(\"/owners/{ownerId}/edit\", 123456789);\n\n // Act and Assert\n MockMvcBuilders.standaloneSetup(this.ownerController)\n .build()\n .perform(requestBuilder)\n .andExpect(MockMvcResultMatchers.status().isOk())\n .andExpect(MockMvcResultMatchers.model().size(1))\n .andExpect(MockMvcResultMatchers.model().attributeExists(\"owner\"))\n .andExpect(MockMvcResultMatchers.view().name(\"owners/createOrUpdateOwnerForm\"))\n .andExpect(MockMvcResultMatchers.forwardedUrl(\"owners/createOrUpdateOwnerForm\"));\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4110/"
] |
81,174
|
<p>I want to have a text box that the user can type in that shows an Ajax-populated list of my model's names, and then when the user selects one I want the HTML to save the model's ID, and use that when the form is submitted.</p>
<p>I've been poking at the auto_complete plugin that got excised in Rails 2, but it seems to have no inkling that this might be useful. There's a <a href="http://railscasts.com/episodes/102-auto-complete-association" rel="nofollow noreferrer">Railscast episode</a> that covers using that plugin, but it doesn't touch on this topic. The comments <a href="http://railscasts.com/episodes/102-auto-complete-association#comment_37039" rel="nofollow noreferrer">point out that it could be an issue</a>, and <a href="http://model-ac.rubyforge.org/" rel="nofollow noreferrer">point to <code>model_auto_completer</code> as a possible solution</a>, which seems to work if the viewed items are simple strings, but the inserted text includes lots of junk spaces if (as I would like to do) you include a picture into the list items, <a href="http://model-ac.rubyforge.org/classes/ModelAutoCompleterHelper.html#M000003" rel="nofollow noreferrer">despite what the documentation says</a>.</p>
<p>I could probably hack <code>model_auto_completer</code> into shape, and I may still end up doing so, but I am eager to find out if there are better options out there.</p>
|
[
{
"answer_id": 81370,
"author": "TALlama",
"author_id": 5657,
"author_profile": "https://Stackoverflow.com/users/5657",
"pm_score": 1,
"selected": true,
"text": ":after_update_element => \"trimSelectedItem\""
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5657/"
] |
81,180
|
<p>We have simple HTML form with <code><input type="file"></code>, like shown below:</p>
<pre><code><form>
<label for="attachment">Attachment:</label>
<input type="file" name="attachment" id="attachment">
<input type="submit">
</form>
</code></pre>
<p>In IE7 (and probably all famous browsers, including old Firefox 2), if we submit a file like '//server1/path/to/file/filename' it works properly and gives the full path to the
file and the filename.</p>
<p>In Firefox 3, it returns only 'filename', because of their new 'security feature' to truncate the path, as explained in Firefox bug tracking system (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=143220" rel="noreferrer">https://bugzilla.mozilla.org/show_bug.cgi?id=143220</a>)</p>
<p>I have no clue how to overcome this 'new feature' because it causes all upload forms in my webapp to stop working on Firefox 3.</p>
<p>Can anyone help to find a single solution to get the file path both on Firefox 3 and IE7?</p>
|
[
{
"answer_id": 1308506,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<form>\n <input type=\"text\" id=\"file_path\" value=\"C:/\" />\n <input type=\"file\" id=\"file_name\" />\n <input type=\"button\" onclick=\"ajax_restore();\" value=\"Restore Database\" />\n</form>\n"
},
{
"answer_id": 1995751,
"author": "houba",
"author_id": 242775,
"author_profile": "https://Stackoverflow.com/users/242775",
"pm_score": 3,
"selected": false,
"text": " if (attachment.files)\n previewImage.src = attachment.files.item(0).getAsDataURL();\n else\n previewImage.src = attachment.value;\n"
},
{
"answer_id": 4381889,
"author": "Jay",
"author_id": 534269,
"author_profile": "https://Stackoverflow.com/users/534269",
"pm_score": 2,
"selected": false,
"text": "<script>\n\nfunction setFileName()\n{\n var file1=document.forms[0].firstAttachmentFileName.value; \n\n initFileUploads('firstFile1','fileinputs1',file1);\n }\nfunction initFileUploads(fileName,fileinputs,fileValue) {\n var fakeFileUpload = document.createElement('div');\n fakeFileUpload.className = 'fakefile';\n var filename = document.createElement('input');\n filename.type='text';\n filename.value=fileValue;\n filename.id=fileName;\n filename.title='Title';\n fakeFileUpload.appendChild(filename);\n var image = document.createElement('input');\n image.type='button';\n image.value='Browse File';\n image.size=5100;\n image.style.border=0;\n fakeFileUpload.appendChild(image);\n var x = document.getElementsByTagName('input');\n for (var i=0; i<x.length;i++) {\n if (x[i].type != 'file') continue;\n if (x[i].parentNode.className != fileinputs) continue;\n x[i].className = 'file hidden';\n var clone = fakeFileUpload.cloneNode(true);\n x[i].parentNode.appendChild(clone);\n x[i].relatedElement = clone.getElementsByTagName('input')[0];\n x[i].onchange= function () {\n this.relatedElement.value = this.value;\n }}\n if(document.forms[0].firstFile != null && document.getElementById('firstFile1') != null)\n {\n document.getElementById('firstFile1').value= document.forms[0].firstFile.value;\n document.forms[0].firstAttachmentFileName.title=document.forms[0].firstFile.value;\n }\n}\n\nfunction submitFile()\n{\nalert( document.forms[0].firstAttachmentFileName.value);\n}\n</script>\n<style>div.fileinputs1 {position: relative;}div.fileinputs2 {position: relative;}\ndiv.fakefile {position: absolute;top: 0px;left: 0px;z-index: 1;}\ninput.file {position: relative;text-align: right;-moz-opacity:0 ;filter:alpha(opacity: 0);\n opacity: 0;z-index: 2;}</style>\n\n<html>\n<body onLoad =\"setFileName();\">\n<form>\n<div class=\"fileinputs1\">\n<INPUT TYPE=file NAME=\"firstAttachmentFileName\" styleClass=\"file\" />\n</div>\n<INPUT type=\"button\" value=\"submit\" onclick=\"submitFile();\" />\n</form>\n</body>\n</html>\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/446104/"
] |
81,191
|
<p>While answering <a href="https://stackoverflow.com/questions/68645/python-static-variable#81002">Static class variables in Python</a> </p>
<p>I noticed that PythonWin PyWin32 build 209.2 interpreter seems to evaluate twice?</p>
<pre><code>PythonWin 2.5 (r25:51908, Mar 9 2007, 17:40:28) [MSC v.1310 32 bit (Intel)] on win32.
Portions Copyright 1994-2006 Mark Hammond - see 'Help/About PythonWin' for further copyright information.
>>> class X:
... l = []
... def __init__(self):
... self.__class__.l.append(1)
...
>>> X().l
[1, 1]
>>>
</code></pre>
<p>while the python interpreter does the right thing</p>
<pre><code>C:\>python
ActivePython 2.5.0.0 (ActiveState Software Inc.) based on
Python 2.5 (r25:51908, Mar 9 2007, 17:40:28) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> class X:
... l = []
... def __init__(self):
... self.__class__.l.append(1)
...
>>> X().l
[1]
>>>
</code></pre>
|
[
{
"answer_id": 81274,
"author": "David Webb",
"author_id": 3171,
"author_profile": "https://Stackoverflow.com/users/3171",
"pm_score": 3,
"selected": true,
"text": "myobject."
},
{
"answer_id": 81751,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 1,
"selected": false,
"text": "self.__class__.l.append(1)"
},
{
"answer_id": 84248,
"author": "Bill Barksdale",
"author_id": 16113,
"author_profile": "https://Stackoverflow.com/users/16113",
"pm_score": 2,
"selected": false,
"text": ">>> class X:\n... l = []\n... def __init__(self):\n... print 'inited'\n... self.__class__.l.append(1)\n... \n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14351/"
] |
81,194
|
<p>We're using the Eclipse CDT 5 C++ IDE on Windows to develop a C++ application on a remote AIX host. </p>
<p>Eclipse CDT has the ability to perform remote debugging using gdbserver. Unfortunately, gdbserver is not supported on AIX. </p>
<p>Is anyone familiar with a way to debug remotely using Eclipse CDT without gdbserver? Perhaps using an SSH shell connection to gdb?</p>
|
[
{
"answer_id": 363441,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "X:\\abin\\vlmi9506"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15367/"
] |
81,202
|
<p>Why does the linux kernel generate a segfault on stack overflow? This can make debugging very awkward when alloca in c or fortran creation of temporary arrays overflows. Surely it mjust be possible for the runtime to produce a more helpful error.</p>
|
[
{
"answer_id": 81223,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 3,
"selected": false,
"text": "char *x = alloca(100);\nchar y = x[150];\n"
},
{
"answer_id": 81264,
"author": "Sargun Dhillon",
"author_id": 10432,
"author_profile": "https://Stackoverflow.com/users/10432",
"pm_score": 3,
"selected": false,
"text": "int main() \n{\n printf(\"Starting\\n\");\n void *foo=malloc(1000);\n memcpy(foo, 0, 100); //this line will segfault\n exit(0);\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
81,209
|
<p>Is there a way to call an external script or program from Flash CS3 every time it builds a SWF file? I'd like to add subversion information using subwcrev - the SVN keywords don't work because they only update when the version class file is updated.</p>
|
[
{
"answer_id": 81944,
"author": "Simon",
"author_id": 15371,
"author_profile": "https://Stackoverflow.com/users/15371",
"pm_score": 0,
"selected": false,
"text": "subwcrev . Version.svn.as Version.as\nIF ERRORLEVEL 1 EXIT /B $ErrLev\nflash.exe ./build.jsfl\nIF ERRORLEVEL 1 EXIT /B $ErrLev\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15371/"
] |
81,214
|
<p>I just want an ASP.NET DropDownList with no selected item. Setting SelectedIndex to -1 is of no avail, so far. I am using Framework 3.5 with AJAX, i.e. this DropDownList is within an UpdatePanel.
Here is what I am doing:</p>
<pre><code> protected void Page_Load (object sender, EventArgs e)
{
this.myDropDownList.SelectedIndex = -1;
this.myDropDownList.ClearSelection();
this.myDropDownList.Items.Add("Item1");
this.myDropDownList.Items.Add("Item2");
}
</code></pre>
<p>The moment I add an element in the DropDown, its SelectedIndex changes to 0 and can be no more set to -1 (I tried calling SelectedIndex after adding items as well)... What I am doing wrong? Ant help would be appreciated!</p>
|
[
{
"answer_id": 81379,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": true,
"text": "myDropDownList.DataSource = DataAccess.GetDropDownItems(); // Psuedo Code\nmyDropDownList.DataTextField = \"Value\";\nmyDropDownList.DataValueField = \"Id\";\nmyDropDownList.DataBind();\n\nmyDropDownList.Items.Insert(0, new ListItem(\"Please select\", \"\"));\n"
},
{
"answer_id": 201012,
"author": "Alexander Prokofyev",
"author_id": 11256,
"author_profile": "https://Stackoverflow.com/users/11256",
"pm_score": 3,
"selected": false,
"text": "<form id=\"form1\" runat=\"server\">\n <asp:DropDownList ID=\"DropDownList1\" runat=\"server\">\n <asp:ListItem Value=\"A\"></asp:ListItem>\n <asp:ListItem Value=\"B\"></asp:ListItem>\n <asp:ListItem Value=\"C\"></asp:ListItem>\n </asp:DropDownList>\n <button id=\"СlearButton\">Clear</button>\n</form>\n\n<script src=\"jquery-1.2.6.js\" type=\"text/javascript\"></script>\n<script type=\"text/javascript\">\n $(document).ready(function()\n {\n $(\"#СlearButton\").click(function()\n {\n $(\"#DropDownList1\").attr(\"selectedIndex\", -1); // pay attention to property casing\n })\n\n $(\"#ClearButton\").click();\n })\n</script>\n"
},
{
"answer_id": 11666108,
"author": "Vimal Patel",
"author_id": 1488039,
"author_profile": "https://Stackoverflow.com/users/1488039",
"pm_score": 0,
"selected": false,
"text": "DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByValue(\"Select\"))\n"
},
{
"answer_id": 13221668,
"author": "Lemaire Stewart",
"author_id": 1798517,
"author_profile": "https://Stackoverflow.com/users/1798517",
"pm_score": 2,
"selected": false,
"text": "AppendDataBoundItems"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
81,236
|
<p>Which built in (if any) tool can I use to determine the allocation unit size of a certain NTFS partition ?</p>
|
[
{
"answer_id": 81257,
"author": "William",
"author_id": 14829,
"author_profile": "https://Stackoverflow.com/users/14829",
"pm_score": 8,
"selected": true,
"text": "fsutil fsinfo ntfsinfo [your drive]\n"
},
{
"answer_id": 3561054,
"author": "steven",
"author_id": 430037,
"author_profile": "https://Stackoverflow.com/users/430037",
"pm_score": 6,
"selected": false,
"text": "diskpart.exe"
},
{
"answer_id": 13905409,
"author": "robertcollier4",
"author_id": 1781201,
"author_profile": "https://Stackoverflow.com/users/1781201",
"pm_score": 2,
"selected": false,
"text": "fsutil fsinfo ntfsinfo C:\n"
},
{
"answer_id": 35299012,
"author": "Aman Arora",
"author_id": 5904669,
"author_profile": "https://Stackoverflow.com/users/5904669",
"pm_score": 3,
"selected": false,
"text": "C:\\temp>fsutil fsinfo drives\n\nDrives: C:\\ D:\\ E:\\ F:\\ G:\\ I:\\ J:\\ N:\\ O:\\ P:\\ S:\\\n\nC:\\temp>fsutil fsinfo ntfsInfo N:\nNTFS Volume Serial Number : 0xfe5a90935a9049f3\nNTFS Version : 3.1\nLFS Version : 2.0\nNumber Sectors : 0x00000002e15befff\nTotal Clusters : 0x000000005c2b7dff\nFree Clusters : 0x000000005c2a15f0\nTotal Reserved : 0x0000000000000000\nBytes Per Sector : 512\nBytes Per Physical Sector : 512\nBytes Per Cluster : 4096\nBytes Per FileRecord Segment : 1024\nClusters Per FileRecord Segment : 0\nMft Valid Data Length : 0x0000000000040000\nMft Start Lcn : 0x00000000000c0000\nMft2 Start Lcn : 0x0000000000000002\nMft Zone Start : 0x00000000000c0000\nMft Zone End : 0x00000000000cc820\nResource Manager Identifier : 560F51B2-CEFA-11E5-80C9-98BE94F91273\n\nC:\\temp>fsutil fsinfo ntfsInfo N:\nNTFS Volume Serial Number : 0x36acd4b1acd46d3d\nNTFS Version : 3.1\nLFS Version : 2.0\nNumber Sectors : 0x00000002e15befff\nTotal Clusters : 0x0000000005c2b7df\nFree Clusters : 0x0000000005c2ac28\nTotal Reserved : 0x0000000000000000\nBytes Per Sector : 512\nBytes Per Physical Sector : 512\nBytes Per Cluster : 65536\nBytes Per FileRecord Segment : 1024\nClusters Per FileRecord Segment : 0\nMft Valid Data Length : 0x0000000000010000\nMft Start Lcn : 0x000000000000c000\nMft2 Start Lcn : 0x0000000000000001\nMft Zone Start : 0x000000000000c000\nMft Zone End : 0x000000000000cca0\nResource Manager Identifier : 560F51C3-CEFA-11E5-80C9-98BE94F91273\n"
},
{
"answer_id": 49454825,
"author": "SQLing4ever",
"author_id": 8507689,
"author_profile": "https://Stackoverflow.com/users/8507689",
"pm_score": 5,
"selected": false,
"text": "Get-Volume | Format-List AllocationUnitSize, FileSystemLabel"
},
{
"answer_id": 68730990,
"author": "Khalil Al-rahman Yossefi",
"author_id": 5827730,
"author_profile": "https://Stackoverflow.com/users/5827730",
"pm_score": 2,
"selected": false,
"text": "CMD"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
81,238
|
<p>Is there some way to block access from a referrer using a .htaccess file or similar? My bandwidth is being eaten up by people referred from <a href="http://www.dizzler.com" rel="nofollow noreferrer">http://www.dizzler.com</a> which is a flash based site that allows you to browse a library of crawled publicly available mp3s.</p>
<p><strong>Edit:</strong> Dizzler was still getting in (probably wasn't indicating referrer in all cases) so instead I moved all my mp3s to a new folder, disabled directory browsing, and created a robots.txt file to (hopefully) keep it from being indexed again. Accepted answer changed to reflect futility of my previous attempt :P</p>
|
[
{
"answer_id": 81250,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 2,
"selected": false,
"text": "RewriteEngine on\nRewriteCond %{HTTP_REFERER} ^http://((www\\.)?dizzler\\.com [NC]\nRewriteRule .* - [F]\n"
},
{
"answer_id": 81269,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "SetEnvIfNoCase Referer dizzler.com spammer=yes\n\nOrder allow,deny\nallow from all\ndeny from env=spammer\n"
},
{
"answer_id": 81290,
"author": "matt lohkamp",
"author_id": 14026,
"author_profile": "https://Stackoverflow.com/users/14026",
"pm_score": 3,
"selected": true,
"text": "<Directory /directoryName/subDirectory>\nOrder Allow,Deny\nAllow from all\nDeny from 66.232.150.219\n</Directory>\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81238",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/327/"
] |
81,243
|
<p>In Delphi, the application's main help file is assigned through the TApplication.HelpFile property. All calls to the application's help system then use this property (in conjunction with CurrentHelpFile) to determine the help file to which help calls should be routed.</p>
<p>In addition to TApplication.HelpFile, each form also has a TForm.HelpFile property which can be used to specify a different (separate) help file for help calls originating from that specific form.</p>
<p>If an application's main help window is already open however, and a help call is made display help from a secondary help file, both help windows hang. Neither of the help windows can now be accessed, and neither can be closed. The only way to get rid of the help windows is to close the application, which results in both help windows being automatically closed as well.</p>
<p>Example:</p>
<pre><code>Application.HelpFile := 'Main Help.chm'; //assign the main help file name
Application.HelpContext(0); //dispays the main help window
Form1.HelpFile := 'Secondary Help.chm'; //assign a different help file
Application.HelpContext(0); //should display a second help window
</code></pre>
<p>The last line of code above opens the secondary help window (but with no content) and then both help windows hang.</p>
<p>My Question is this:</p>
<ol>
<li><p>Is it possible to display two HTMLHelp windows at the same time, and if so, what is the procedure to be followed?</p></li>
<li><p>If not, is there a way to tell whether or not an application's help window is already open, and then close it programatically before displaying a different help window?</p></li>
</ol>
<p>(I am Using Delphi 2007 with HTMLHelp files on Windows Vista)</p>
<p><strong>UPDATE: 2008-09-18</strong></p>
<p>Opening two help files at the same time does in fact work as expected using the code above. The problem seems to be with the actual help files I was using - not the code.</p>
<p>I tried the same code with different help files, and it worked fine.</p>
<p>Strangely enough, the two help files I was using each works fine on it's own - it's only when you try to open both at the same time that they hang, and only if you open them from code (in Windows explorer I can open both at the same time without a problem).</p>
<p>Anyway - the problem is definitely with the help files and not the code - so the original questions is now pretty much invalid.</p>
<p><strong>UPDATE 2: 2008-09-18</strong></p>
<p>I eventually found the cause of the hanging help windows. I will post the answer below and accept it as the correct one for future reference. I have also changed the questions title.</p>
<p>Oops... It seems that I cannot accept my own answer...</p>
<p>Please vote it up so it stays at the top.</p>
|
[
{
"answer_id": 88869,
"author": "Francesca",
"author_id": 9842,
"author_profile": "https://Stackoverflow.com/users/9842",
"pm_score": 1,
"selected": false,
"text": "procedure TForm1.Button1Click(Sender: TObject);\nbegin\n Application.HelpFile:= 'depends.chm';\n Application.HelpContext(0);\n HelpFile:='GExperts.chm';\n Application.HelpContext(0);\nend;\n"
},
{
"answer_id": 90501,
"author": "user5888",
"author_id": 5888,
"author_profile": "https://Stackoverflow.com/users/5888",
"pm_score": 3,
"selected": false,
"text": "procedure TForm1.Button1Click(Sender: TObject);\nbegin\n Application.HelpFile := 'Help File 1.chm';\n Application.HelpContext(0);\nend;\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5888/"
] |
81,260
|
<p>Is there a tool or script which easily merges a bunch of <a href="http://en.wikipedia.org/wiki/JAR_%28file_format%29" rel="noreferrer">JAR</a> files into one JAR file? A bonus would be to easily set the main-file manifest and make it executable.</p>
<p>The concrete case is a <a href="http://jrst.labs.libre-entreprise.org/en/user/functionality.html" rel="noreferrer">Java restructured text tool</a>. I would like to run it with something like:</p>
<blockquote>
<p>java -jar rst.jar</p>
</blockquote>
<p>As far as I can tell, it has no dependencies which indicates that it shouldn't be an easy single-file tool, but the downloaded ZIP file contains a lot of libraries.</p>
<pre><code> 0 11-30-07 10:01 jrst-0.8.1/
922 11-30-07 09:53 jrst-0.8.1/jrst.bat
898 11-30-07 09:53 jrst-0.8.1/jrst.sh
2675 11-30-07 09:42 jrst-0.8.1/readmeEN.txt
108821 11-30-07 09:59 jrst-0.8.1/jrst-0.8.1.jar
2675 11-30-07 09:42 jrst-0.8.1/readme.txt
0 11-30-07 10:01 jrst-0.8.1/lib/
81508 11-30-07 09:49 jrst-0.8.1/lib/batik-util-1.6-1.jar
2450757 11-30-07 09:49 jrst-0.8.1/lib/icu4j-2.6.1.jar
559366 11-30-07 09:49 jrst-0.8.1/lib/commons-collections-3.1.jar
83613 11-30-07 09:49 jrst-0.8.1/lib/commons-io-1.3.1.jar
207723 11-30-07 09:49 jrst-0.8.1/lib/commons-lang-2.1.jar
52915 11-30-07 09:49 jrst-0.8.1/lib/commons-logging-1.1.jar
260172 11-30-07 09:49 jrst-0.8.1/lib/commons-primitives-1.0.jar
313898 11-30-07 09:49 jrst-0.8.1/lib/dom4j-1.6.1.jar
1994150 11-30-07 09:49 jrst-0.8.1/lib/fop-0.93-jdk15.jar
55147 11-30-07 09:49 jrst-0.8.1/lib/activation-1.0.2.jar
355030 11-30-07 09:49 jrst-0.8.1/lib/mail-1.3.3.jar
77977 11-30-07 09:49 jrst-0.8.1/lib/servlet-api-2.3.jar
226915 11-30-07 09:49 jrst-0.8.1/lib/jaxen-1.1.1.jar
153253 11-30-07 09:49 jrst-0.8.1/lib/jdom-1.0.jar
50789 11-30-07 09:49 jrst-0.8.1/lib/jewelcli-0.41.jar
324952 11-30-07 09:49 jrst-0.8.1/lib/looks-1.2.2.jar
121070 11-30-07 09:49 jrst-0.8.1/lib/junit-3.8.1.jar
358085 11-30-07 09:49 jrst-0.8.1/lib/log4j-1.2.12.jar
72150 11-30-07 09:49 jrst-0.8.1/lib/logkit-1.0.1.jar
342897 11-30-07 09:49 jrst-0.8.1/lib/lutinwidget-0.9.jar
2160934 11-30-07 09:49 jrst-0.8.1/lib/docbook-xsl-nwalsh-1.71.1.jar
301249 11-30-07 09:49 jrst-0.8.1/lib/xmlgraphics-commons-1.1.jar
68610 11-30-07 09:49 jrst-0.8.1/lib/sdoc-0.5.0-beta.jar
3149655 11-30-07 09:49 jrst-0.8.1/lib/xalan-2.6.0.jar
1010675 11-30-07 09:49 jrst-0.8.1/lib/xercesImpl-2.6.2.jar
194205 11-30-07 09:49 jrst-0.8.1/lib/xml-apis-1.3.02.jar
78440 11-30-07 09:49 jrst-0.8.1/lib/xmlParserAPIs-2.0.2.jar
86249 11-30-07 09:49 jrst-0.8.1/lib/xmlunit-1.1.jar
108874 11-30-07 09:49 jrst-0.8.1/lib/xom-1.0.jar
63966 11-30-07 09:49 jrst-0.8.1/lib/avalon-framework-4.1.3.jar
138228 11-30-07 09:49 jrst-0.8.1/lib/batik-gui-util-1.6-1.jar
216394 11-30-07 09:49 jrst-0.8.1/lib/l2fprod-common-0.1.jar
121689 11-30-07 09:49 jrst-0.8.1/lib/lutinutil-0.26.jar
76687 11-30-07 09:49 jrst-0.8.1/lib/batik-ext-1.6-1.jar
124724 11-30-07 09:49 jrst-0.8.1/lib/xmlParserAPIs-2.6.2.jar
</code></pre>
<p>As you can see, it is somewhat desirable to not need to do this manually.</p>
<p>So far I've only tried AutoJar and ProGuard, both of which were fairly easy to get running. It appears that there's some issue with the constant pool in the JAR files.</p>
<p>Apparently jrst is slightly broken, so I'll make a go of fixing it. The <a href="http://en.wikipedia.org/wiki/Apache_Maven" rel="noreferrer">Maven</a> <code>pom.xml</code> file was apparently broken too, so I'll have to fix that before fixing jrst ... I feel like a bug-magnet :-)</p>
<hr>
<p>Update: I never got around to fixing this application, but I checked out <a href="http://en.wikipedia.org/wiki/Eclipse_%28software%29" rel="noreferrer">Eclipse</a>'s "Runnable JAR export wizard" which is based on a fat JAR. I found this very easy to use for deploying my own code.</p>
<p>Some of the other excellent suggestions might be better for builds in a non-Eclipse environment, oss probably should make a nice build using <a href="http://en.wikipedia.org/wiki/Apache_Ant" rel="noreferrer">Ant</a>. (Maven, so far has just given me pain, but others love it.)</p>
|
[
{
"answer_id": 81273,
"author": "larsivi",
"author_id": 14047,
"author_profile": "https://Stackoverflow.com/users/14047",
"pm_score": 4,
"selected": false,
"text": "mvn assembly:assembly\n"
},
{
"answer_id": 81482,
"author": "Ashley Mercer",
"author_id": 13065,
"author_profile": "https://Stackoverflow.com/users/13065",
"pm_score": 5,
"selected": false,
"text": "Main-Class: com.simontuffs.onejar.Boot\nOne-Jar-Main-Class: org.codelutin.jrst.JRST\n"
},
{
"answer_id": 81509,
"author": "jrudolph",
"author_id": 7647,
"author_profile": "https://Stackoverflow.com/users/7647",
"pm_score": 3,
"selected": false,
"text": "icu.jar"
},
{
"answer_id": 185116,
"author": "akuhn",
"author_id": 24468,
"author_profile": "https://Stackoverflow.com/users/24468",
"pm_score": 6,
"selected": false,
"text": "zipfileset"
},
{
"answer_id": 5652720,
"author": "象嘉道",
"author_id": 571828,
"author_profile": "https://Stackoverflow.com/users/571828",
"pm_score": 3,
"selected": false,
"text": "<jar id=\"files\" jarfile=\"all.jar\">\n <zipgroupfileset dir=\"${library.dir}\" includes=\"*.jar\" excludes=\"test-helper.jar\"/>\n <zipfileset src=\"first.jar\" includes=\"**/*.java **/*.class\"/>\n <zipfileset src=\"second.jar\" includes=\"**/*.java **/*.class\"/>\n <fileset dir=\".\">\n <include name=\"LICENSE\"/>\n <include name=\"NOTICE\"/>\n </fileset>\n</jar>\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12677/"
] |
81,268
|
<p>I have been sick and tired Googling the solution for doing case-insensitive search on Sybase ASE (Sybase data/column names are case sensitive). The Sybase documentation proudly says that there is only one way to do such search which is using the Upper and Lower functions, but the adage goes, it has performance problems. And believe me they are right, if your table has huge data the performance is so awkward you are never gonna use Upper and Lower again. My question to fellow developers is: how do you guys tackle this? </p>
<p>P.S. Don't advise to change the sort-order or move to any other Database please, in real world developers don't control the databases.</p>
|
[
{
"answer_id": 3090940,
"author": "Bipin Daga",
"author_id": 372873,
"author_profile": "https://Stackoverflow.com/users/372873",
"pm_score": 3,
"selected": true,
"text": "functional index"
},
{
"answer_id": 8236651,
"author": "kamsky",
"author_id": 1061007,
"author_profile": "https://Stackoverflow.com/users/1061007",
"pm_score": 2,
"selected": false,
"text": "select col1, upper(col1) upp_col1 from table1 order by upp_col1\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/81268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15395/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.