qid
int64 4
19.1M
| question
stringlengths 18
48.3k
| answers
list | date
stringlengths 10
10
| metadata
list |
|---|---|---|---|---|
197,233
|
<p>I want to split a command line like string in single string parameters. How look the regular expression for it. The problem are that the parameters can be quoted. For example like:</p>
<p>"param 1" param2 "param 3"</p>
<p>should result in:</p>
<p>param 1, param2, param 3</p>
|
[
{
"answer_id": 197244,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 3,
"selected": false,
"text": "(\"[^\"]*\"|[^\"]+)(\\s+|$)\n \"[^\"]*\" [^\"]+ \\s+ $"
},
{
"answer_id": 197255,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 0,
"selected": false,
"text": "\"(?:(?<=\")([^\"]+)\"\\s*)|\\s*([^\"\\s]+)\n \"([^\"]+)\"|\\s*([^\"\\s]+)\n"
},
{
"answer_id": 197305,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": ">>> import shlex\n>>> shlex.split('\"param 1\" param2 \"param 3\"')\n['param 1', 'param2', 'param 3']\n>>> shlex.split('\"param 1\" param2 \"param 3')\nTraceback (most recent call last):\n [...]\nValueError: No closing quotation\n>>> shlex.split('\"param 1\" param2 \"param 3\\\\\"\"')\n['param 1', 'param2', 'param 3\"']\n"
},
{
"answer_id": 197329,
"author": "Scott James",
"author_id": 6715,
"author_profile": "https://Stackoverflow.com/users/6715",
"pm_score": -1,
"selected": false,
"text": " Getopt g = new Getopt(\"testprog\", argv, \"ab:c::d\");\n //\n int c;\n String arg;\n while ((c = g.getopt()) != -1)\n {\n switch(c)\n {\n case 'a':\n case 'd':\n System.out.print(\"You picked \" + (char)c + \"\\n\");\n break;\n //\n case 'b':\n case 'c':\n arg = g.getOptarg();\n System.out.print(\"You picked \" + (char)c + \n \" with an argument of \" +\n ((arg != null) ? arg : \"null\") + \"\\n\");\n break;\n //\n case '?':\n break; // getopt() already printed an error\n //\n default:\n System.out.print(\"getopt() returned \" + c + \"\\n\");\n }\n }\n"
},
{
"answer_id": 8540755,
"author": "ymerej",
"author_id": 186034,
"author_profile": "https://Stackoverflow.com/users/186034",
"pm_score": 0,
"selected": false,
"text": "(?<cmd>^\"[^\"]*\"|\\S*) *(?<prm>.*)?\n try {\n Regex RegexObj = new Regex(\"(?<cmd>^\\\\\\\"[^\\\\\\\"]*\\\\\\\"|\\\\S*) *(?<prm>.*)?\");\n\n} catch (ArgumentException ex) {\n // Syntax error in the regular expression\n}\n \"c:\\program files\\myapp\\app.exe\" p1 p2 \"p3 with space\"\napp.exe p1 p2 \"p3 with space\"\napp.exe\n"
},
{
"answer_id": 10556196,
"author": "kares",
"author_id": 454312,
"author_profile": "https://Stackoverflow.com/users/454312",
"pm_score": 1,
"selected": false,
"text": "require 'shellwords'\nShellwords.shellsplit '\"param 1\" param2 \"param 3\"'\n#=> [\"param 1\", \"param2\", \"param 3\"] or :\n'\"param 1\" param2 \"param 3\"'.shellsplit\n"
},
{
"answer_id": 11644634,
"author": "boqapt",
"author_id": 484936,
"author_profile": "https://Stackoverflow.com/users/484936",
"pm_score": -1,
"selected": false,
"text": "\\s*(\"[^\"]+\"|[^\\s\"]+)\n"
},
{
"answer_id": 19856614,
"author": "Alexander Drichel",
"author_id": 1872824,
"author_profile": "https://Stackoverflow.com/users/1872824",
"pm_score": 3,
"selected": false,
"text": "(\"[^\"]+\"|[^\\s\"]+)\n #include <iostream>\n#include <iterator>\n#include <string>\n#include <regex>\n\nvoid foo()\n{\n std::string strArg = \" \\\"par 1\\\" par2 par3 \\\"par 4\\\"\"; \n\n std::regex word_regex( \"(\\\"[^\\\"]+\\\"|[^\\\\s\\\"]+)\" );\n auto words_begin = \n std::sregex_iterator(strArg.begin(), strArg.end(), word_regex);\n auto words_end = std::sregex_iterator();\n for (std::sregex_iterator i = words_begin; i != words_end; ++i)\n {\n std::smatch match = *i;\n std::string match_str = match.str();\n std::cout << match_str << '\\n';\n }\n}\n \"par 1\"\npar2\npar3\n\"par 4\"\n"
},
{
"answer_id": 22216333,
"author": "VertigoRay",
"author_id": 615422,
"author_profile": "https://Stackoverflow.com/users/615422",
"pm_score": 2,
"selected": false,
"text": "^(?:\"([^\"]+(?=\"))|([^\\s]+))[\"]{0,1} +(.+)$\n \"C:\\WINDOWS\\system32\\cmd.exe\" /c echo this\n C:\\WINDOWS\\system32\\cmd.exe /c echo this C:\\WINDOWS\\system32\\cmd.exe /c echo this\n C:\\WINDOWS\\system32\\cmd.exe /c echo this \"C:\\Program Files\\foo\\bar.exe\" /run\n C:\\Program Files\\foo\\bar.exe /run"
},
{
"answer_id": 41020376,
"author": "23W",
"author_id": 987850,
"author_profile": "https://Stackoverflow.com/users/987850",
"pm_score": 2,
"selected": false,
"text": "/[\\/-]?((\\w+)(?:[=:](\"[^\"]+\"|[^\\s\"]+))?)(?:\\s+|$)/g /P1=\"Long value\" /P2=3 /P3=short PwithoutSwitch1=any PwithoutSwitch2 / - = : /P1=\"Long value\" P1=\"Long value\" P1 \"Long value\" /P2=3 P2=3 P2 3 /P3=short P3=short P3 short PwithoutSwitch1=any PwithoutSwitch1=any PwithoutSwitch1 any PwithoutSwitch2 PwithoutSwitch2 PwithoutSwitch2"
},
{
"answer_id": 72245049,
"author": "chrispitude",
"author_id": 2489802,
"author_profile": "https://Stackoverflow.com/users/2489802",
"pm_score": 0,
"selected": false,
"text": "#!/usr/bin/perl\n\nsub parse_arguments {\n my $text = shift;\n my $i = 0;\n my @args;\n while ($text ne '') {\n $text =~ s{^\\s*(['\"]?)}{}; # look for (and remove) leading quote\n my $delimiter = ($1 || ' '); # use space if not quoted\n if ($text =~ s{^(([^$delimiter\\\\]|\\\\.|\\\\$)+)($delimiter|$)}{}) {\n $args[$i++] = $1; # acquired an argument; save it\n }\n }\n return @args;\n}\n\nmy $line = <<'EOS';\n\"param 1\" param\\ 2 \"pa\\\"ram' '3\" 'pa\\'ram\" \"4'\nEOS\n\nsay \"ARG: $_\" for parse_arguments($line);\n ARG: param 1\nARG: param\\ 2\nARG: pa\"ram' '3\nARG: pa'ram\" \"4\n \" ' \\"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12631/"
] |
197,241
|
<p>I came across this class while reading a C# book and have some questions.</p>
<ul>
<li>Why is this added into System.Linq namespace and not into usuall Collections namespace?</li>
<li>What the intention behind this class is</li>
<li>Why this class is not intended for direct instantiation? This is available through the ToLookup extension only, right?</li>
</ul>
|
[
{
"answer_id": 197363,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": false,
"text": "MiscUtil.Linq.EditableLookup<,> ILookup<,>"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/437435/"
] |
197,266
|
<p>Below is the code of a simple html with a table layout.
In FF it's looking as I think it should look like,
in IE7 it doesn't. what am I doing wrong?<br><br>
And how can I fix it?</p>
<pre><code><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<TITLE>test</TITLE>
</head>
<body>
<table id="MainTable" cellspacing="0" cellpadding="0" border="1">
<tbody>
<tr>
<td colspan="4">
<div style='width:769; height:192;'>192
</div>
</td>
</tr>
<tr>
<td colspan="2" valign="top">
<div style='width:383; height:100;'>100
</div>
</td>
<td rowspan="2" valign="top">
<div style='width:190; height:200;'>200
</div>
</td>
<td rowspan="2" valign="top">
<div style='width:190; height:200;'>200
</div>
</td>
</tr>
<tr>
<td valign="top" rowspan="2">
<div style='width:190; height:200;'>200
</div>
</td>
<td valign="top" rowspan="2">
<div style='width:190; height:200;'>200
</div>
</td>
</tr>
<tr>
<td valign="top">
<div style='width:190; height:100;'>100
</div>
</td>
<td valign="top" >
<div style='width:190; height:100;'>100
</div>
</td>
</tr>
<tr>
<td colspan="2">
<div style='width:383; height:100;'>100
</div>
</td>
<td colspan="2">
<div style='width:383; height:100;'>100
</div>
</td>
</tr>
<tr>
<td>
<div style='width:190; height:100;'>100
</div>
</td>
<td>
<div style='width:190; height:100;'>100
</div>
</td>
<td colspan="2">
<div style='width:383; height:100;'>100
</div>
</td>
</tr>
</tbody>
</table>
</body>
</html>
</code></pre>
|
[
{
"answer_id": 197284,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 2,
"selected": false,
"text": "width:190; width: 190px;"
},
{
"answer_id": 197413,
"author": "Quentin",
"author_id": 19068,
"author_profile": "https://Stackoverflow.com/users/19068",
"pm_score": 0,
"selected": false,
"text": "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n \"http://www.w3.org/TR/html4/strict.dtd\"> <!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n \"http://www.w3.org/TR/html4/loose.dtd\">"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15981/"
] |
197,268
|
<p>I have a self-hosted service that I want to add transport security to.
I've set WSHttpBinding.SecurityMode to Transport and the ClientCredentialType to HttpClientCredentialType.None.
I've created a certificate and set it to my host with
ServiceHost.Credentials.ServiceCertificate.SetCertificate()
I've also registered it using
netsh http add sslcert ipport=127.0.0.1:80 certhash=[MyCertHash] certstorename=MY appid=[TheGuidOfTheAppTahtRunsTheService] verifyclientcertrevocation=disable</p>
<p>I'm getting the following error message whenever I try to call the service:
"Authentication failed because the remote party has closed the transport stream."</p>
<p>Does this mean the the client and server try to authenticate each other? How can I disable it?
To make things clear, I do not want to install a certificate at the client, I'm not looking for any authentication atm, just securing the messages content, if that's even possible.</p>
|
[
{
"answer_id": 197284,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 2,
"selected": false,
"text": "width:190; width: 190px;"
},
{
"answer_id": 197413,
"author": "Quentin",
"author_id": 19068,
"author_profile": "https://Stackoverflow.com/users/19068",
"pm_score": 0,
"selected": false,
"text": "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n \"http://www.w3.org/TR/html4/strict.dtd\"> <!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n \"http://www.w3.org/TR/html4/loose.dtd\">"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19956/"
] |
197,275
|
<p>The MySQL database used by my Rails application currently has the default collation of <code>latin1_swedish_ci</code>. Since the default charset of Rails applications (including mine) is UTF-8, it seems sensible to me to use the <code>utf8_general_ci</code> collation in the database.</p>
<p>Is my thinking correct? </p>
<p>Assuming it is, what would be the best approach to migrate the collation <em>and all the data in the database</em> to the new encoding? </p>
|
[
{
"answer_id": 39702215,
"author": "shyam",
"author_id": 1640346,
"author_profile": "https://Stackoverflow.com/users/1640346",
"pm_score": 0,
"selected": false,
"text": "ALTER TABLE users MODIFY description VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci;\n SHOW FULL COLUMNS FROM users;\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1174/"
] |
197,291
|
<p>Given a table (mytable) containing a numeric field (mynum), how would one go about writing an SQL query which summarizes the table's data based on ranges of values in that field rather than each distinct value?</p>
<p>For the sake of a more concrete example, let's make it intervals of 3 and just "summarize" with a count(*), such that the results tell the number of rows where mynum is 0-2.99, the number of rows where it's 3-5.99, where it's 6-8.99, etc.</p>
|
[
{
"answer_id": 197300,
"author": "Jouni K. Seppänen",
"author_id": 26575,
"author_profile": "https://Stackoverflow.com/users/26575",
"pm_score": 5,
"selected": true,
"text": "select count(*), round(mynum/3.0) foo from mytable group by foo;\n"
},
{
"answer_id": 197325,
"author": "ila",
"author_id": 1178,
"author_profile": "https://Stackoverflow.com/users/1178",
"pm_score": 3,
"selected": false,
"text": "select \n CASE \n WHEN id <= 20 THEN 'lessthan20' \n WHEN id > 20 and id <= 30 THEN '20and30' ELSE 'morethan30' END,\n count(*) \nfrom Profiles \nwhere 1=1 \ngroup by \n CASE \n WHEN id <= 20 THEN 'lessthan20' \n WHEN id > 20 and id <= 30 THEN '20and30' ELSE 'morethan30' END\n column1 column2 \n ---------- ---------- \n 20and30 3 \n lessthan20 3 \n morethan30 13 \n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18914/"
] |
197,302
|
<p>How can I unset variable? For example, PHP has an <code>unset($var)</code> function.</p>
|
[
{
"answer_id": 197312,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackoverflow.com/users/6491",
"pm_score": 3,
"selected": false,
"text": "MyVar = null;\n"
},
{
"answer_id": 197326,
"author": "Nico",
"author_id": 22970,
"author_profile": "https://Stackoverflow.com/users/22970",
"pm_score": 6,
"selected": true,
"text": "MyType myvar = default(MyType);\nstring a = default(string);\n"
},
{
"answer_id": 197327,
"author": "Arry",
"author_id": 26792,
"author_profile": "https://Stackoverflow.com/users/26792",
"pm_score": 4,
"selected": false,
"text": "{\n int i = 2;\n}\n"
},
{
"answer_id": 197340,
"author": "benPearce",
"author_id": 4490,
"author_profile": "https://Stackoverflow.com/users/4490",
"pm_score": 1,
"selected": false,
"text": "int? i = null;\n"
},
{
"answer_id": 197617,
"author": "Rick Minerich",
"author_id": 9251,
"author_profile": "https://Stackoverflow.com/users/9251",
"pm_score": 1,
"selected": false,
"text": "System.Console.WriteLine(\"let's give this a try: \");\n{\n int j = 0;\n System.Console.WriteLine(j);\n}\n//Won't compile with the following line.\n//System.Console.WriteLine(j);\n"
},
{
"answer_id": 65674601,
"author": "Starlk",
"author_id": 14974522,
"author_profile": "https://Stackoverflow.com/users/14974522",
"pm_score": -1,
"selected": false,
"text": "null int? Foo = 5;\nFoo = null;\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25413/"
] |
197,304
|
<p>On occasion, my local Rails app loses its connection to MySQL. I get some error that the connection failed, but if I just refresh the page, it works fine. This has never happpened in my STAGE or PROD environments (I deploy to Ubuntu), so it has not been that big a deal.<br>
Does this happen to anybody else? Is there something I can do to fix it? Is it MySQL or Ruby?</p>
|
[
{
"answer_id": 197467,
"author": "Matt Brown",
"author_id": 7272,
"author_profile": "https://Stackoverflow.com/users/7272",
"pm_score": 2,
"selected": false,
"text": "sudo gem install mysql"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7272/"
] |
197,307
|
<p>What would you recommend to search a sql server table (varchar(max) column) for a term?</p>
<p>Let's say, like in ebay, if you search for "wii brand new", you get results like "Brand New Nintendo Wii Fit Game + Balance Board Bundle", "Wii Fit (Wii) BRAND NEW WII FIT GAME + BALANCE BOARD".</p>
<p>I think it basically searches every word and returns the ones that contains all the words, what would you recommend?</p>
|
[
{
"answer_id": 197314,
"author": "Matt Brown",
"author_id": 7272,
"author_profile": "https://Stackoverflow.com/users/7272",
"pm_score": 2,
"selected": false,
"text": "select * from table where field like '%word%'"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17648/"
] |
197,310
|
<p>I want to do this (no particular language):</p>
<pre><code>print(foo.objects.bookdb.books[12].title);
</code></pre>
<p>or this:</p>
<pre><code>book = foo.objects.bookdb.book.new();
book.title = 'RPC for Dummies';
book.save();
</code></pre>
<p>Where foo actually is a service connected to my program via some IPC, and to access its methods and objects, some layer actually sends and receives messages over the network.</p>
<p>Now, I'm not really looking for an IPC mechanism, as there are plenty to choose from. It's likely not to be XML based, but rather s. th. like Google's protocol buffers, dbus or CORBA. What I'm unsure about is how to structure the application so I can access the IPC just like I would any object.</p>
<p>In other words, how can I have OOP that maps transparently over process boundaries?</p>
<p>Not that this is a design question and I'm still working at a pretty high level of the overall architecture. So I'm pretty agnostic yet about which language this is going to be in. C#, Java and Python are all likely to get used, though.</p>
|
[
{
"answer_id": 197380,
"author": "edgar.holleis",
"author_id": 24937,
"author_profile": "https://Stackoverflow.com/users/24937",
"pm_score": -1,
"selected": true,
"text": "foreach o, o.isGreen in someList { \n o.makeBlue; \n}\n"
},
{
"answer_id": 210914,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 0,
"selected": false,
"text": "foo= NonLocalFoo( \"http://host:port\" )\nfoo.this= \"that\"\nfoo.save()\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077/"
] |
197,362
|
<p>I have a products table that contains a FK for a category, the Categories table is created in a way that each category can have a parent category, example:</p>
<pre><code>Computers
Processors
Intel
Pentium
Core 2 Duo
AMD
Athlon
</code></pre>
<p>I need to make a select query that if the selected category is Processors, it will return products that is in Intel, Pentium, Core 2 Duo, Amd, etc...</p>
<p>I thought about creating some sort of "cache" that will store all the categories in the hierarchy for every category in the db and include the "IN" in the where clause. Is this the best solution?</p>
|
[
{
"answer_id": 197389,
"author": "Simon",
"author_id": 22404,
"author_profile": "https://Stackoverflow.com/users/22404",
"pm_score": 0,
"selected": false,
"text": "categoriesSet = empty set\nwhile new.size > 0:\n new = select * from categories where parent in categoriesSet\n categoriesSet = categoriesSet+new\n"
},
{
"answer_id": 197403,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 0,
"selected": false,
"text": "select *\nfrom products\nwhere products.category_id IN\n (select c2.category_id \n from categories c1 inner join categories c2 on c1.category_id = c2.parent_id\n where c1.category = 'Processors'\n group by c2.category_id)\n"
},
{
"answer_id": 197503,
"author": "Jonas Lincoln",
"author_id": 17436,
"author_profile": "https://Stackoverflow.com/users/17436",
"pm_score": 0,
"selected": false,
"text": "CREATE TABLE #categories (id INT NOT NULL, parentId INT, [name] NVARCHAR(100))\nINSERT INTO #categories\n SELECT 1, NULL, 'Computers'\n UNION\nSELECT 2, 1, 'Processors'\n UNION\nSELECT 3, 2, 'Intel'\n UNION\nSELECT 4, 2, 'AMD'\n UNION\nSELECT 5, 3, 'Pentium'\n UNION\nSELECT 6, 3, 'Core 2 Duo'\n UNION\nSELECT 7, 4, 'Athlon'\nSELECT * \n FROM #categories\nDECLARE @id INT\n SET @id = 2\n ; WITH r(id, parentid, [name]) AS (\n SELECT id, parentid, [name] \n FROM #categories c \n WHERE id = @id\n UNION ALL\n SELECT c.id, c.parentid, c.[name] \n FROM #categories c JOIN r ON c.parentid=r.id\n )\nSELECT * \n FROM products \n WHERE p.productd IN\n(SELECT id \n FROM r)\nDROP TABLE #categories \n"
},
{
"answer_id": 197594,
"author": "Steven Robbins",
"author_id": 26507,
"author_profile": "https://Stackoverflow.com/users/26507",
"pm_score": 2,
"selected": false,
"text": "with catCTE (catid, parentid)\nas\n(\nselect cat.catid, cat.catparentid from cat where cat.name = 'Processors'\nUNION ALL\nselect cat.catid, cat.catparentid from cat inner join catCTE on cat.catparentid=catcte.catid\n)\nselect distinct * from catCTE\n"
},
{
"answer_id": 197597,
"author": "MDCore",
"author_id": 1896,
"author_profile": "https://Stackoverflow.com/users/1896",
"pm_score": 4,
"selected": true,
"text": "SELECT * FROM products \n INNER JOIN categories ON categories.id = products.category_id \nWHERE categories.lft > 2 and categories.rgt < 11\n Processors"
},
{
"answer_id": 197607,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "DECLARE @startingCatagoryId int\nDECLARE @current int\nSET @startingCatagoryId = 13813 -- or whatever the CatagoryId is for 'Processors'\n\nCREATE TABLE #CatagoriesToFindChildrenFor\n(CatagoryId int)\n\nCREATE TABLE #CatagoryTree\n(CatagoryId int)\n\nINSERT INTO #CatagoriesToFindChildrenFor VALUES (@startingCatagoryId)\n\nWHILE (SELECT count(*) FROM #CatagoriesToFindChildrenFor) > 0\nBEGIN\n SET @current = (SELECT TOP 1 * FROM #CatagoriesToFindChildrenFor)\n\n INSERT INTO #CatagoriesToFindChildrenFor\n SELECT ID FROM Catagory WHERE ParentCatagoryId = @current AND Deleted = 0\n\n INSERT INTO #CatagoryTree VALUES (@current)\n DELETE #CatagoriesToFindChildrenFor WHERE CatagoryId = @current\nEND\n\nSELECT * FROM #CatagoryTree ORDER BY CatagoryId\n\nDROP TABLE #CatagoriesToFindChildrenFor\nDROP TABLE #CatagoryTree\n"
},
{
"answer_id": 206665,
"author": "cheeves",
"author_id": 15826,
"author_profile": "https://Stackoverflow.com/users/15826",
"pm_score": 0,
"selected": false,
"text": "-- create a categories table and fill it with 10 rows (with random parentIds)\nCREATE TABLE Categories ( Id uniqueidentifier, ParentId uniqueidentifier )\nGO\n\nINSERT\nINTO Categories\nSELECT NEWID(),\n NULL \nGO\n\nINSERT\nINTO Categories\nSELECT TOP(1)NEWID(),\n Id\nFROM Categories\nORDER BY Id\nGO 9\n\n\nDECLARE @lvl INT, -- holds onto the level as we move throught the hierarchy\n @Id Uniqueidentifier -- the id of the current item in the stack\n\nSET @lvl = 1\n\nCREATE TABLE #stack (item UNIQUEIDENTIFIER, [lvl] INT)\n-- we fill fill this table with the ids we want\nCREATE TABLE #tmpCategories (Id UNIQUEIDENTIFIER)\n\n-- for this example we’ll just select all the ids \n-- if we want all the children of a specific parent we would include it’s id in\n-- this where clause\nINSERT INTO #stack SELECT Id, @lvl FROM Categories WHERE ParentId IS NULL\n\nWHILE @lvl > 0\nBEGIN -- begin 1\n\n IF EXISTS ( SELECT * FROM #stack WHERE lvl = @lvl )\n BEGIN -- begin 2\n\n SELECT @Id = [item]\n FROM #stack\n WHERE lvl = @lvl\n\n INSERT INTO #tmpCategories\n SELECT @Id\n\n DELETE FROM #stack\n WHERE lvl = @lvl\n AND item = @Id\n\n INSERT INTO #stack\n SELECT Id, @lvl + 1\n FROM Categories\n WHERE ParentId = @Id\n\n IF @@ROWCOUNT > 0\n BEGIN -- begin 3\n SELECT @lvl = @lvl + 1\n END -- end 3\n END -- end 2\n ELSE\n SELECT @lvl = @lvl - 1\n\nEND -- end 1\n\nDROP TABLE #stack\n\nSELECT * FROM #tmpCategories\nDROP TABLE #tmpCategories\nDROP TABLE Categories\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17648/"
] |
197,365
|
<p>I am creating a Visual Studio Setup project. I want to un-install another component from the system from the install of my component. The other component is installed from my own setup created using Visual Studio.</p>
<p>Currently when I am calling the un-install of the other component from the install action of the component I get the error code: <code>1618 (another MSI already running)</code>.</p>
<p>Could anyone suggest me an alternative way to solve this problem?</p>
|
[
{
"answer_id": 264308,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "uninst.exe"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/191/"
] |
197,372
|
<p>I have a JUnit 3.x TestCase which I would like to be able to parameterize. I'd like to parametrize the entire <code>TestCase</code> (including the fixture). However, the <code>TestSuite.addTestSuite()</code> method does not allow be to pass a <code>TestCase</code> object, just a class:</p>
<pre><code> TestSuite suite = new TestSuite("suite");
suite.addTestSuite(MyTestCase.class);
</code></pre>
<p>I would like to be able to pass a parameter (a string) to the MyTestCase instance which is created when the test runs. As it is now, I have to have a separate class for each parameter value.</p>
<p>I tried passing it an anynomous subclass:</p>
<pre><code> MyTestCase testCase = new MyTestCase() {
String getOption() {
return "some value";
}
}
suite.addTestSuite(testCase.getClass());
</code></pre>
<p>However, this fails with the assertion:</p>
<pre><code> ... MyTestSuite$1 has no public constructor TestCase(String name) or TestCase()`
</code></pre>
<p>Any ideas? Am I attacking the problem the wrong way?</p>
|
[
{
"answer_id": 197656,
"author": "matt b",
"author_id": 4249,
"author_profile": "https://Stackoverflow.com/users/4249",
"pm_score": 2,
"selected": false,
"text": "public void testSomething() {\n API myAPI = new BlahAPI();\n assertNotNull(myAPI.something());\n}\n public abstract class AbstractTestCase extends TestCase {\n public abstract API getAPIToTest();\n\n public void testSomething() {\n API myAPI = getAPIToTest();\n assertNotNull(myAPI.something());\n }\n\n public void testSomethingElse() {\n API myAPI = getAPIToTest();\n assertNotNull(myAPI.somethingElse());\n }\n}\n public class ImplementationXTestCase extends AbstractTestCase{\n\n public API getAPIToTest() {\n return new ImplementationX();\n }\n}\n"
},
{
"answer_id": 512707,
"author": "Thomas Dufour",
"author_id": 371593,
"author_profile": "https://Stackoverflow.com/users/371593",
"pm_score": 2,
"selected": false,
"text": "[0] [1] TestRunner package junit.parameterized;\n\nimport java.lang.reflect.Constructor;\nimport java.lang.reflect.InvocationTargetException;\nimport java.lang.reflect.Method;\nimport java.lang.reflect.Modifier;\nimport java.util.ArrayList;\nimport java.util.Collection;\n\nimport junit.framework.Test;\nimport junit.framework.TestCase;\nimport junit.framework.TestSuite;\n\npublic class ParameterizedTestSuite extends TestSuite {\n\n public ParameterizedTestSuite(\n final Class<? extends TestCase> testCaseClass,\n final Collection<Object[]> parameters) {\n\n setName(testCaseClass.getName());\n\n final Constructor<?>[] constructors = testCaseClass.getConstructors();\n if (constructors.length != 1) {\n addTest(warning(testCaseClass.getName()\n + \" must have a single public constructor.\"));\n return;\n }\n\n final Collection<String> names = getTestMethods(testCaseClass);\n\n final Constructor<?> constructor = constructors[0];\n final Collection<TestCase> testCaseInstances = new ArrayList<TestCase>();\n try {\n for (final Object[] objects : parameters) {\n for (final String name : names) {\n TestCase testCase = (TestCase) constructor.newInstance(objects);\n testCase.setName(name);\n testCaseInstances.add(testCase);\n }\n }\n } catch (IllegalArgumentException e) {\n addConstructionException(e);\n return;\n } catch (InstantiationException e) {\n addConstructionException(e);\n return;\n } catch (IllegalAccessException e) {\n addConstructionException(e);\n return;\n } catch (InvocationTargetException e) {\n addConstructionException(e);\n return;\n }\n\n\n for (final TestCase testCase : testCaseInstances) {\n addTest(testCase);\n } \n }\n private Collection<String> getTestMethods(\n final Class<? extends TestCase> testCaseClass) {\n Class<?> superClass= testCaseClass;\n final Collection<String> names= new ArrayList<String>();\n while (Test.class.isAssignableFrom(superClass)) {\n Method[] methods= superClass.getDeclaredMethods();\n for (int i= 0; i < methods.length; i++) {\n addTestMethod(methods[i], names, testCaseClass);\n }\n superClass = superClass.getSuperclass();\n }\n return names;\n }\n private void addTestMethod(Method m, Collection<String> names, Class<?> theClass) {\n String name= m.getName();\n if (names.contains(name))\n return;\n if (! isPublicTestMethod(m)) {\n if (isTestMethod(m))\n addTest(warning(\"Test method isn't public: \"+m.getName()));\n return;\n }\n names.add(name);\n }\n\n private boolean isPublicTestMethod(Method m) {\n return isTestMethod(m) && Modifier.isPublic(m.getModifiers());\n }\n\n private boolean isTestMethod(Method m) {\n String name= m.getName();\n Class<?>[] parameters= m.getParameterTypes();\n Class<?> returnType= m.getReturnType();\n return parameters.length == 0 && name.startsWith(\"test\") && returnType.equals(Void.TYPE);\n }\n\n private void addConstructionException(Exception e) {\n addTest(warning(\"Instantiation of a testCase failed \"\n + e.getClass().getName() + \" \" + e.getMessage()));\n }\n\n}\n package junit.parameterized;\nimport java.util.Arrays;\nimport java.util.Collection;\n\nimport junit.framework.Test;\nimport junit.framework.TestCase;\nimport junit.parameterized.ParameterizedTestSuite;\n\n\npublic class ParameterizedTest extends TestCase {\n\n private final int value;\n private int evilState;\n\n public static Collection<Object[]> parameters() {\n return Arrays.asList(\n new Object[] { 1 },\n new Object[] { 2 },\n new Object[] { -2 }\n );\n }\n\n public ParameterizedTest(final int value) {\n this.value = value;\n }\n\n public void testMathPow() {\n final int square = value * value;\n final int powSquare = (int) Math.pow(value, 2) + evilState;\n assertEquals(square, powSquare);\n evilState++;\n }\n\n public void testIntDiv() {\n final int div = value / value;\n assertEquals(1, div);\n }\n\n public static Test suite() {\n return new ParameterizedTestSuite(ParameterizedTest.class, parameters());\n }\n}\n evilState"
},
{
"answer_id": 5063336,
"author": "user626150",
"author_id": 626150,
"author_profile": "https://Stackoverflow.com/users/626150",
"pm_score": 1,
"selected": false,
"text": " private String displayName;\n\n public ParameterizedTest(final int value) {\n this.value = value;\n this.displayName = Integer.toString(value);\n }\n\n @Override\n public String getName() {\n return super.getName() + \"[\" + displayName + \"]\";\n }\n"
},
{
"answer_id": 26492929,
"author": "Daniel Lubarov",
"author_id": 714009,
"author_profile": "https://Stackoverflow.com/users/714009",
"pm_score": 1,
"selected": false,
"text": "public class ParameterizedTest extends TestCase {\n enum Drink { COKE, PEPSI, RC_COLA }\n\n private final Drink drink;\n\n // Nullary constructor required by Android test framework\n public ConstructorTest() {\n this(null);\n }\n\n public ConstructorTest(Drink drink) {\n this.drink = drink;\n }\n\n public void testSomething() {\n assertNotNull(drink);\n }\n}\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13051/"
] |
197,375
|
<p>I only just recently discovered that Visual C++ 2008 (and perhaps earlier versions as well?) supports <code>for each</code> syntax on stl lists et al to facilitate iteration.
For example:</p>
<pre><code>list<Object> myList;
for each (Object o in myList)
{
o.foo();
}
</code></pre>
<p>I was very happy to discover it, but I'm concerned about portability for the dreaded day when someone decides I need to be able to compile my code in say, gcc or some other compiler. Is this syntax widely supported and can I use it without worrying about portability issues?</p>
|
[
{
"answer_id": 197412,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 4,
"selected": false,
"text": "list<Object> myList;\n\nBOOST_FOREACH(Object o, myList)\n o.foo();\n"
},
{
"answer_id": 197429,
"author": "Luc Touraille",
"author_id": 20984,
"author_profile": "https://Stackoverflow.com/users/20984",
"pm_score": 3,
"selected": false,
"text": "template <class InputIterator, class UnaryFunction>\nUnaryFunction for_each(InputIterator first, InputIterator last, UnaryFunction f);\n void foo(Object o)\n{\n o.foo();\n}\n...\nlist<Object> myList;\n\nstd::for_each(myList.begin(), myList.end(), foo);\n list<Object> myList;\n\nBOOST_FOREACH(Object o, myList)\n{\n o.foo();\n}\n"
},
{
"answer_id": 197646,
"author": "user21714",
"author_id": 21714,
"author_profile": "https://Stackoverflow.com/users/21714",
"pm_score": 0,
"selected": false,
"text": "#define _foreach(x,y) BOOST_FOREACH(x,y)\n"
},
{
"answer_id": 197755,
"author": "Ferruccio",
"author_id": 4086,
"author_profile": "https://Stackoverflow.com/users/4086",
"pm_score": 5,
"selected": false,
"text": "list<Object> myList;\n\nfor (Object o : myList)\n{\n o.foo();\n}\n"
},
{
"answer_id": 197926,
"author": "Mike Hordecki",
"author_id": 19082,
"author_profile": "https://Stackoverflow.com/users/19082",
"pm_score": 3,
"selected": false,
"text": "#define VAR(V,init) __typeof(init) V=(init)\n#define FOREACH(I,C) for(VAR(I,(C).begin());I!=(C).end();I++)\n\nstd::vector<int> numbers;\n\nFOREACH(I, numbers)\n{\n std::cout << *I << std::endl;\n}\n"
},
{
"answer_id": 8714582,
"author": "cdiggins",
"author_id": 184528,
"author_profile": "https://Stackoverflow.com/users/184528",
"pm_score": 1,
"selected": false,
"text": "#define for_each(_ITER_, _COLL_) for (auto _ITER_ = _COLL_.begin(); \\\n _ITER_ != _COLL_.end(); _ITER_++)\n list<Object> myList;\n\nfor_each (o, myList)\n{\n o.foo();\n}\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25731/"
] |
197,379
|
<p>I am looking to create symlinks (soft links) from Java on a Windows Vista/ 2008 machine. I'm happy with the idea that I need to call out to the JNI to do this. I am after help on the actual C code though. What is the appropriate system call to create the link? Pointers to some good documentation on this subject would be very much appreciated.</p>
|
[
{
"answer_id": 197420,
"author": "Scott James",
"author_id": 6715,
"author_profile": "https://Stackoverflow.com/users/6715",
"pm_score": 2,
"selected": false,
"text": "BOOLEAN WINAPI CreateSymbolicLink(\n __in LPTSTR lpSymlinkFileName,\n __in LPTSTR lpTargetFileName,\n __in DWORD dwFlags\n);\n typedef BOOL (WINAPI* CreateSymbolicLinkProc) (LPCSTR, LPCSTR, DWORD);\n\nvoid main(int argc, char *argv[]) \n{\n HMODULE h;\n CreateSymbolicLinkProc CreateSymbolicLink_func;\n LPCSTR link = argv[1];\n LPCSTR target = argv[2];\n DWORD flags = 0;\n\n h = LoadLibrary(\"kernel32\");\n CreateSymbolicLink_func =\n (CreateSymbolicLinkProc)GetProcAddress(h,\n if (CreateSymbolicLink_func == NULL) \n {\n fprintf(stderr, \"CreateSymbolicLinkA not available\\n\");\n } else \n {\n if ((*CreateSymbolicLink_func)(link, target, flags) == 0) \n {\n fprintf(stderr, \"CreateSymbolicLink failed: %d\\n\",\n GetLastError());\n\n } else \n {\n printf(\"Symbolic link created.\");\n }\n}\n"
},
{
"answer_id": 197440,
"author": "mdb",
"author_id": 8562,
"author_profile": "https://Stackoverflow.com/users/8562",
"pm_score": 4,
"selected": true,
"text": "JNIEXPORT jboolean JNICALL Java_ClassName_MethodName\n (JNIEnv *env, jstring symLinkName, jstring targetName)\n{\n const char *nativeSymLinkName = env->GetStringUTFChars(symLinkName, 0);\n const char *nativeTargetName = env->GetStringUTFChars(targetName, 0);\n\n jboolean success = (CreateSymbolicLink(nativeSymLinkName, nativeTargetName, 0) != 0);\n\n env->ReleaseStringUTFChars(symLinkName, nativeSymLinkName);\n env->ReleaseStringUTFChars(targetName, nativeTargetName);\n\n return success;\n}\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7122/"
] |
197,383
|
<p>I want to create a bundle from an arbitrary bundle identifier<br>
e.g. <code>com.apple.iokit.IOStorageFamily</code> </p>
<p>It's not an unreasonable thing to do as bundle IDs are supposed<br>
to be unique, however the obvious code does not work:</p>
<pre><code>NSString* bID = @"com.apple.iokit.IOStorageFamily";
NSBundle* bundle = [NSBundle bundleWithIdentifier:bID];
</code></pre>
<p>This code only works for bundles you've already loaded<br>
(hello, chicken and egg problem), and in fact, you have<br>
to know a little more than you'd like about the the identifier<br>
before you can do anything. For the above style of ID<br>
I grep out the final component and tranform it into<br>
<code>/System/Library/Extensions/IOStorageFamily.kext</code><br>
which I then load by path. </p>
<p>Is this the state of the art or is there a more general way? </p>
|
[
{
"answer_id": 198195,
"author": "Dave Verwer",
"author_id": 4496,
"author_profile": "https://Stackoverflow.com/users/4496",
"pm_score": 3,
"selected": false,
"text": "NSString *path = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:@\"com.apple.TextEdit\"];\n"
},
{
"answer_id": 260466,
"author": "Nik Gervae",
"author_id": 33828,
"author_profile": "https://Stackoverflow.com/users/33828",
"pm_score": 3,
"selected": false,
"text": "kextfind -bundle-id com.apple.iokit.IOStorageFamily\n"
},
{
"answer_id": 1583143,
"author": "Georg Schölly",
"author_id": 24587,
"author_profile": "https://Stackoverflow.com/users/24587",
"pm_score": 3,
"selected": true,
"text": "KextManagerCreateURLForBundleIdentifier() <IOKit/kext/KextManager.h> /*!\n * @function KextManagerCreateURLForBundleIdentifier\n * @abstract Create a URL locating a kext with a given bundle identifier.\n *\n * @param allocator\n * The allocator to use to allocate memory for the new object.\n * Pass <code>NULL</code> or <code>kCFAllocatorDefault</code>\n * to use the current default allocator.\n * @param kextIdentifier\n * The bundle identifier to look up.\n *\n * @result\n * A CFURLRef locating a kext with the requested bundle identifier.\n * Returns <code>NULL</code> if the kext cannot be found, or on error.\n *\n * @discussion\n * Kexts are looked up first by whether they are loaded, second by version.\n * Specifically, if <code>kextIdentifier</code> identifies a kext\n * that is currently loaded,\n * the returned URL will locate that kext if it's still present on disk.\n * If the requested kext is not loaded,\n * or if its bundle is not at the location it was originally loaded from,\n * the returned URL will locate the latest version of the desired kext,\n * if one can be found within the system extensions folder.\n * If no version of the kext can be found, <code>NULL</code> is returned.\n */\nCFURLRef KextManagerCreateURLForBundleIdentifier(\n CFAllocatorRef allocator,\n CFStringRef kextIdentifier);\n"
},
{
"answer_id": 10064287,
"author": "Pierre Lebeaupin",
"author_id": 80734,
"author_profile": "https://Stackoverflow.com/users/80734",
"pm_score": 0,
"selected": false,
"text": "kMDItemCFBundleIdentifier"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22147/"
] |
197,387
|
<p>Is there a way to describe the module's data in a similar way that a docstring describes a module or a funcion?</p>
<pre><code>class MyClass(object):
def my_function():
"""This docstring works!"""
return True
my_list = []
"""This docstring does not work!"""
</code></pre>
|
[
{
"answer_id": 197499,
"author": "codeape",
"author_id": 3571,
"author_profile": "https://Stackoverflow.com/users/3571",
"pm_score": 5,
"selected": true,
"text": "# module.py:\n\"\"\"About the module.\n\nmodule.data: contains the word \"spam\"\n\n\"\"\"\n\ndata = \"spam\"\n"
},
{
"answer_id": 197566,
"author": "DzinX",
"author_id": 18745,
"author_profile": "https://Stackoverflow.com/users/18745",
"pm_score": 4,
"selected": false,
"text": "#: # module.py:\n\n#: Very important data.\n#: Use with caution.\n#: @type: C{str}\ndata = \"important data\"\n data str @type"
},
{
"answer_id": 199179,
"author": "Dan Lenski",
"author_id": 20789,
"author_profile": "https://Stackoverflow.com/users/20789",
"pm_score": 3,
"selected": false,
"text": "property class Foo:\n def get_foo(self): ...\n\n def set_foo(self, val): ...\n\n def del_foo(self): ...\n\n foo = property(get_foo, set_foo, del_foo, '''Doc string here''')\n foo"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/985/"
] |
197,407
|
<p>I need to define a calculated member in MDX (this is SAS OLAP, but I'd appreciate answers from people who work with different OLAP implementations anyway).</p>
<p>The new measure's value should be calculated from an existing measure by applying an additional filter condition. I suppose it will be clearer with an example:</p>
<ul>
<li>Existing measure: "Total traffic"</li>
<li>Existing dimension: "Direction" ("In" or "Out")</li>
<li>I need to create a calculated member "Incoming traffic", which equals "Total traffic" with an additional filter (Direction = "In")</li>
</ul>
<p>The problem is that I don't know MDX and I'm on a very tight schedule (so sorry for a newbie question). The best I could come up with is:</p>
<pre><code>([Measures].[Total traffic], [Direction].[(All)].[In])
</code></pre>
<p>Which almost works, except for cells with specific direction:</p>
<p><img src="https://i.stack.imgur.com/z3BxZ.png" alt="example"></p>
<p>So it looks like the "intrinsic" filter on Direction is overridden with my own filter). I need an intersection of the "intrinsic" filter and my own. My gut feeling was that it has to do with Intersecting <code>[Direction].[(All)].[In]</code> with the intrinsic coords of the cell being evaluated, but it's hard to know what I need without first reading up on the subject :)</p>
<p><strong>[update]</strong> I ended up with </p>
<pre><code>IIF([Direction].currentMember = [Direction].[(All)].[Out],
0,
([Measures].[Total traffic], [Direction].[(All)].[In])
)
</code></pre>
<p>..but at least in SAS OLAP this causes extra queries to be performed (to calculate the value for [in]) to the underlying data set, so I didn't use it in the end.</p>
|
[
{
"answer_id": 200913,
"author": "Magnus Smith",
"author_id": 11461,
"author_profile": "https://Stackoverflow.com/users/11461",
"pm_score": 4,
"selected": true,
"text": "WITH MEMBER [Measures].[Incoming Traffic] AS\n'([Measures].[Total traffic], [Direction].[(All)].[In])'\n WITH MEMBER [Measures].[Incoming Traffic] AS\n'IIF([Direction].currentMember = [Direction].[(All)].[Out],\n ([Measures].[Total traffic]),\n ([Measures].[Total traffic], [Directon].[(All)].[In])\n)'\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1026/"
] |
197,414
|
<p>I'm trying to get my head around the Error Handling in MVC.
What I'm looking for is a centralized way to catch errors, log them, if possible resolve them, if nessecary take other actions and finally show the correct view to the user.</p>
<p>I think I can use the [HandleError] filter for this, but I don't see any way to route it to a Controller/Action. The only option I see is pointing it directly to a view.</p>
|
[
{
"answer_id": 756438,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "[SuppressMessage(\"Microsoft.Performance\", \"CA1813:AvoidUnsealedAttributes\",\n Justification = \"This attribute is AllowMultiple = true and users might want to override behavior.\")]\n[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]\npublic class GenericExceptionHandlerFilter : ActionFilterAttribute, IExceptionFilter\n{\n\n public Type ExceptionType { get; set;}\n public string RedirectToAction { get; set;}\n public string RedirectToController { get; set;}\n\n protected bool ApplyFilter(ExceptionContext filterContext)\n {\n Type lExceptionType = filterContext.Exception.GetType();\n return (ExceptionType == null ||\n lExceptionType.Equals(ExceptionType));\n }\n\n\n #region IExceptionFilter Members\n public void OnException(ExceptionContext filterContext)\n {\n\n if (ApplyFilter(filterContext))\n {\n IbfControllerLogger.Log(filterContext.Exception);\n\n filterContext.ExceptionHandled = true;\n\n #region Calculate Action Controller Error\n RouteValueDictionary lRoutes = new RouteValueDictionary(new\n {\n action = RedirectToAction,\n controller = String.IsNullOrEmpty(RedirectToController) ? (string)filterContext.RouteData.Values[\"controller\"] : RedirectToController\n });\n UrlReWriterUtils.UrlReWriter(filterContext.Controller.ViewData, lRoutes);\n #endregion\n\n filterContext.Controller.TempData[TempDataName.C_TEMPDATA_EXCEPTIONERROR] = filterContext.Exception;\n filterContext.Result = new RedirectToRouteResult(lRoutes);\n }\n }\n #endregion\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] |
197,419
|
<p>I am developing a CMS where the clients will need to upload files larger than 2mb - up to 10mb at least. I have changed the details in the php.ini file and I cannot see anywhere else that the problem might be. Any help?</p>
<p>Cheers</p>
|
[
{
"answer_id": 197445,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "https://Stackoverflow.com/users/115",
"pm_score": -1,
"selected": false,
"text": "ini_set('upload_max_filesize', '10M');\n"
},
{
"answer_id": 197450,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 0,
"selected": false,
"text": "upload_max_filesize post_max_size"
},
{
"answer_id": 197452,
"author": "ConroyP",
"author_id": 2287,
"author_profile": "https://Stackoverflow.com/users/2287",
"pm_score": 2,
"selected": false,
"text": "php.ini ; Maximum allowed size for uploaded files.\nupload_max_filesize = 50M\n\n; Maximum size of POST data that PHP will accept.\npost_max_size = 50M\n ini_set(\"memory_limit\",\"75M\");\n"
},
{
"answer_id": 197458,
"author": "Mark Biek",
"author_id": 305,
"author_profile": "https://Stackoverflow.com/users/305",
"pm_score": 3,
"selected": false,
"text": "_execution _input _max _max"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
197,441
|
<p>I'm a new user of Matlab, can you please help:<br>
I have the following code in an .M file:</p>
<pre><code>function f = divrat(w, C)
S=sqrt(diag(diag(C)));
s=diag(S);
f=sqrt(w'*C*w)/(w'*s);
</code></pre>
<p>I have stored this file (divrat.M) in the normal Matlab path, and therefore I'm assuming that Matlab will read the function when it's starting and that this function therefore should be available to use.</p>
<p>However, when I type</p>
<pre><code>>> divrat(w, C)
</code></pre>
<p>I get the following error</p>
<blockquote>
<p>??? Undefined function or method 'divrat' for input arguments of type 'double'. </p>
</blockquote>
<p>What is the error message telling me to do, I can't see any error in the code or the function call?</p>
|
[
{
"answer_id": 197543,
"author": "hakan",
"author_id": 3993,
"author_profile": "https://Stackoverflow.com/users/3993",
"pm_score": 2,
"selected": false,
"text": "divrat.m divrat divrat.m s = sqrt(diag(C));\n"
},
{
"answer_id": 197605,
"author": "Mr Fooz",
"author_id": 25050,
"author_profile": "https://Stackoverflow.com/users/25050",
"pm_score": 2,
"selected": false,
"text": "divrat.m divrat.M which which divrat\n"
},
{
"answer_id": 214278,
"author": "bastibe",
"author_id": 1034,
"author_profile": "https://Stackoverflow.com/users/1034",
"pm_score": 2,
"selected": false,
"text": "addpath('pathname')"
},
{
"answer_id": 219406,
"author": "Sundar R",
"author_id": 8127,
"author_profile": "https://Stackoverflow.com/users/8127",
"pm_score": 3,
"selected": false,
"text": "Add to Path"
},
{
"answer_id": 219445,
"author": "Marc",
"author_id": 8478,
"author_profile": "https://Stackoverflow.com/users/8478",
"pm_score": 2,
"selected": false,
"text": "pwd path @(whatever the class of the first argument is) which w divrat w [] Double/divrat @(yourclass)/divrat."
},
{
"answer_id": 309136,
"author": "Todd",
"author_id": 30841,
"author_profile": "https://Stackoverflow.com/users/30841",
"pm_score": 5,
"selected": false,
"text": ">> which divrat\nc:\\work\\divrat\\divrat.m\n >> which divrat\n'divrat' not found.\n divrat PATH divrat >> foo\n\nans =\n\n 1\n\n>> divrat(1,1)\n??? Undefined function or method 'divrat' for input arguments of type 'double'.\n\n>> which -all divrat\nc:\\work\\divrat\\private\\divrat.m % Private to divrat\n"
},
{
"answer_id": 29729347,
"author": "user262",
"author_id": 2863327,
"author_profile": "https://Stackoverflow.com/users/2863327",
"pm_score": 0,
"selected": false,
"text": "which divrat Has no license available matlab"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
197,444
|
<p>I'm using libcurl in a Win32 C++ application.</p>
<p>I have the curllib.vcproj project added to my solution and set my other projects to depend on it.</p>
<p>How do I build it with SSL support enabled?</p>
|
[
{
"answer_id": 199052,
"author": "sharkin",
"author_id": 7891,
"author_profile": "https://Stackoverflow.com/users/7891",
"pm_score": 7,
"selected": true,
"text": "USE_SSLEAY\nUSE_OPENSSL\n 1> perl Configure VC-WIN32 --prefix=c:/some/openssl/dir\n 2> ms\\do_ms\n 3> nmake -f ms\\nt.mak (for static library)\n 3> nmake -f ms\\ntdll.mak (for DLL)\n curl_version_info_data * vinfo = curl_version_info( CURLVERSION_NOW );\nif( vinfo->features & CURL_VERSION_SSL )\n // SSL support enabled\nelse\n // No SSL\n"
},
{
"answer_id": 5129202,
"author": "James",
"author_id": 623491,
"author_profile": "https://Stackoverflow.com/users/623491",
"pm_score": 3,
"selected": false,
"text": "if( vinfo->features & CURL_VERSION_SSL )"
},
{
"answer_id": 9750612,
"author": "jayaanand",
"author_id": 1275823,
"author_profile": "https://Stackoverflow.com/users/1275823",
"pm_score": 2,
"selected": false,
"text": "\\ fatal error C1083: Cannot open include\nfile: 'stdlib.h': No such file or directory\nNMAKE: fatal error U1077::return code \n"
},
{
"answer_id": 47651867,
"author": "VincentTellier",
"author_id": 519376,
"author_profile": "https://Stackoverflow.com/users/519376",
"pm_score": 2,
"selected": false,
"text": "curl-7.57.0\\projects openssl build-openssl.bat .\\build-openssl.bat vc14 x64 release ..\\..\\openssl\\ .\\build-openssl.bat -help openssl\\build\\Win64 curl-7.57.0\\projects\\Windows\\VC14\\curl-all.sln LIB Release - LIB OpenSSL curl-7.57.0\\build\\Win64\\VC14\\LIB Release - LIB OpenSSL\\libcurl.lib CURL_STATICLIB CURL_DISABLE_LDAP"
},
{
"answer_id": 48700926,
"author": "Ari Seyhun",
"author_id": 4988637,
"author_profile": "https://Stackoverflow.com/users/4988637",
"pm_score": 2,
"selected": false,
"text": "curl-7.58.0.zip projects/Windows/VC15/curl_all.sln Win32 OpenSSL v1.1.0g C:\\OpenSSL-Win32 curl_all.sln DLL Debug - DLL OpenSSL curl Linker -> General Additional Library Directories OpenSSL directory + \\lib C:\\OpenSSL-Win32\\lib libcurl OpenSSL directory + \\lib Additional Library Directories Linker -> General C/C++ -> General C:\\OpenSSL-Win32\\include Additional Include Directories Linker -> Input Additional Dependencies ws2_32.lib\nwldap32.lib\nopenssl.lib\nlibssl.lib\nlibcrypto.lib\n DLL Debug - DLL OpenSSL Build -> Build Solution libcrypto-1_1.dll libssl-1_1.dll C:\\OpenSSL-Win32\\bin curl-7.58.0\\build\\Win32\\VC15\\DLL Debug - DLL OpenSSL curld.exe"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7891/"
] |
197,447
|
<p>Basically, what I need is something like <a href="http://www.dependencywalker.com/" rel="noreferrer">Dependecy Walker</a>, but it should work with .NET applications. Is there anywhere such tool?</p>
|
[
{
"answer_id": 44527128,
"author": "pallxk",
"author_id": 3463091,
"author_profile": "https://Stackoverflow.com/users/3463091",
"pm_score": 1,
"selected": false,
"text": "ildasm.exe ildasm.exe .assembly extern ildasm.exe"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1353085/"
] |
197,466
|
<p>What's the best/easiest to integrate templating system for PHP, and what are the benefits of using one?</p>
<p>I currently don't use one at all, and am thinking that it might help to seperate content from presentation a little more. </p>
|
[
{
"answer_id": 695217,
"author": "Kornel",
"author_id": 27009,
"author_profile": "https://Stackoverflow.com/users/27009",
"pm_score": 2,
"selected": false,
"text": "echo $foo ${foo} |escape} htmlspecialchars() <strong tal:omit-tag=\"condition\">\n xxx\n</strong>\n {if condition}<strong>{/if}\n xxx\n{if condition-again!}</strong>{/if}\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16511/"
] |
197,468
|
<p>I'm just starting up a new ATL/WTL project and I was wondering if the global _Module variable is still required? </p>
<p>Back a few years when I started working with WTL it was required (at least for ATL 3.0) that you define a global variable such as:</p>
<pre><code>CAppModule _Module;
</code></pre>
<p>To get ATL to work correctly. But recently I've read somewhere that this may not be required anymore (yet the wizard generated code still uses it). Also I did a search through the Visual C++ include directories and it only picked up _Module in a few places - most notably the ATL COM registry stuff.</p>
<p>So do I still need to define a global variable to use ATL these days?</p>
|
[
{
"answer_id": 200210,
"author": "Johann Gerell",
"author_id": 6345,
"author_profile": "https://Stackoverflow.com/users/6345",
"pm_score": 1,
"selected": false,
"text": "extern CAppModule _Module;\n CAppModule _Module;\n"
},
{
"answer_id": 253883,
"author": "Charles",
"author_id": 24898,
"author_profile": "https://Stackoverflow.com/users/24898",
"pm_score": 4,
"selected": true,
"text": "_Module _Module _AtlBaseModule _Module"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3719/"
] |
197,474
|
<p>What are the pros and cons of using <a href="http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html/ch17.html" rel="noreferrer">Criteria</a> or <a href="http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html/ch16.html" rel="noreferrer">HQL</a>? The Criteria API is a nice object-oriented way to express queries in Hibernate, but sometimes Criteria Queries are more difficult to understand/build than HQL. </p>
<p>When do you use Criteria and when HQL? What do you prefer in which use cases? Or is it just a matter of taste?</p>
|
[
{
"answer_id": 8796229,
"author": "Bojan Kraut",
"author_id": 907867,
"author_profile": "https://Stackoverflow.com/users/907867",
"pm_score": 3,
"selected": false,
"text": "(name || ' ' || surname) String hql = \"select \" +\n \"c.uuid as uuid,\" +\n \"c.name as name,\" +\n \"c.objective as objective,\" +\n \"c.startDate as startDate,\" +\n \"c.endDate as endDate,\" +\n \"c.description as description,\" +\n \"s.status as status,\" +\n \"t.type as type \" +\n \"from \" + Campaign.class.getName() + \" c \" +\n \"left join c.type t \" +\n \"left join c.status s\";\n\nQuery query = hibernateTemplate.getSessionFactory().getCurrentSession().getSession(EntityMode.MAP).createQuery(hql);\nquery.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);\nreturn query.list();\n"
},
{
"answer_id": 38447561,
"author": "Pritam Banerjee",
"author_id": 1475228,
"author_profile": "https://Stackoverflow.com/users/1475228",
"pm_score": 0,
"selected": false,
"text": "Criteria Queries HQL"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18722/"
] |
197,482
|
<p>What are the guidelines for when to create a new exception type instead of using one of the built-in exceptions in .Net?</p>
<p>The problem that got me thinking is this. I have a WCF service, which is a basic input-output service. If the service is unable to create an output, because the input is invalid, I want to throw an exception, but which one?</p>
<p>Right now I'm just throwing system.Exception, but this doesn't feel right to me, I don't know why, it just feels wrong.
One thing that bugs me, if I test it with a unit test and I expect the system.Exception to be thrown. The exception could as well be thrown by the framework or other code and not by the code I excepted to throw. The test would then pass, as I get the expected exception, but it should have failed.</p>
<p>What do you recommend?</p>
|
[
{
"answer_id": 197488,
"author": "Keith",
"author_id": 905,
"author_profile": "https://Stackoverflow.com/users/905",
"pm_score": 4,
"selected": false,
"text": "System.Exception System.ApplicationException [FaultContract( typeof( LogInFault ) )]\nvoid LogIn( string userName, string password, bool auditLogin );\n throw new FaultException<LogInFault>( new LogInFault(), \"message\" );\n [DataContract]"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44726/"
] |
197,489
|
<p>I am using the jQuery library to implement drag and drop. </p>
<p>How do I get at the element that is being dragged when it is dropped?</p>
<p>I want to get the id of the image inside the div. The following element is dragged:</p>
<pre><code><div class="block">
<asp:Image ID="Image9" AlternateText="10/12/2008 - Retina" Width=81 Height=84 ImageUrl="~/uploads/ImageModifier/retina.jpg" runat=server />
</div>
</code></pre>
<p>I have the standard dropped function from their example:</p>
<pre><code>$(".drop").droppable({
accept: ".block",
activeClass: 'droppable-active',
hoverClass: 'droppable-hover',
drop: function(ev, ui) { }
});
</code></pre>
<p>I have tried various <code>ui.id</code> etc. which doesn't seem to work.</p>
|
[
{
"answer_id": 197505,
"author": "redsquare",
"author_id": 6440,
"author_profile": "https://Stackoverflow.com/users/6440",
"pm_score": 6,
"selected": true,
"text": " drop: function(ev, ui) {\n //to get the id\n //ui.draggable.attr('id') or ui.draggable.get(0).id or ui.draggable[0].id\n console.dir(ui.draggable) \n }\n"
},
{
"answer_id": 197541,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 2,
"selected": false,
"text": "ui.draggable $(\".drop\").droppable({ accept: \".block\", \n activeClass: 'droppable-active', \n hoverClass: 'droppable-hover', \n drop: function(ev, ui) { \n //do something with ui.draggable here\n }\n});\n"
},
{
"answer_id": 660456,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "$(ui.draggable).attr(\"id\") \n"
},
{
"answer_id": 5634297,
"author": "karvonen",
"author_id": 255906,
"author_profile": "https://Stackoverflow.com/users/255906",
"pm_score": 4,
"selected": false,
"text": "$(event.target).attr(\"id\");\n"
},
{
"answer_id": 6407336,
"author": "Desperado",
"author_id": 290423,
"author_profile": "https://Stackoverflow.com/users/290423",
"pm_score": 2,
"selected": false,
"text": "drop: function( event, ui ) {alert(ui.draggable.attr(\"productid\"));}\n"
},
{
"answer_id": 9196232,
"author": "Daniel Mlodecki",
"author_id": 1011325,
"author_profile": "https://Stackoverflow.com/users/1011325",
"pm_score": 3,
"selected": false,
"text": "event.target.id\n"
},
{
"answer_id": 28863093,
"author": "Maurits Moeys",
"author_id": 4441216,
"author_profile": "https://Stackoverflow.com/users/4441216",
"pm_score": 3,
"selected": false,
"text": "$('#someDraggableGroup').draggable({\n helper: 'clone',\n start: function( event, ui ) {\n console.log(ui.helper.context)\n console.log(ui.helper.clone())\n }\n })\n ui.helper.context clone() draggable() draggable droppable() $('#myDroppable').droppable({\n drop: function(event, ui){\n console.log(ui.draggable.context)\n OR\n console.log(ui.draggable.clone() )\n }\n})\n"
},
{
"answer_id": 51871202,
"author": "Shailesh Dwivedi",
"author_id": 7051725,
"author_profile": "https://Stackoverflow.com/users/7051725",
"pm_score": 0,
"selected": false,
"text": "var target_ui_object_html=$(ui.item.context).attr(\"your attributes\");\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23066/"
] |
197,497
|
<p>What is the best way to determine how many window handles an application is using? Is there a tool or a WMI performance counter that I could use?</p>
<p>I would like to run up an app and watch a counter of some sort and see that the number of window handles is increasing. </p>
<pre><code>for (int i=0; i < 1000; i++)
{
System.Threading.Thread.Sleep(1000);
RichTextBox rt = new RichTextBox();
rt.Text = "hi";
this.Controls.Add(rt);
}
</code></pre>
<p>I am running the above code and watching the "Handle Count" counter on the process, and it does not seem to be increasing. Is there something I am looking at incorrectly?</p>
|
[
{
"answer_id": 197581,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackoverflow.com/users/6491",
"pm_score": 2,
"selected": false,
"text": "PerformanceCounter PC=new PerformanceCounter();\nPC.CategoryName=\"Process\";\nPC.CounterName=\"Handles\";\nPC.InstanceName=\"MyProc\";\nMessageBox.Show(PC.NextValue().ToString());\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/324/"
] |
197,508
|
<p>I know mime_content_type() is deprecated, but it seemed to me the alternative is worse at the moment. <code>Finfo</code> seems to require adding files and changing ini directions on windows; I don't want to require this for the script I am making.</p>
<p>I need to find the mimetype of files, but when calling <code>mime_content_type($filename)</code> on windows it fails. mime_magic.magicfile points to the correct file, but when enabling mime_magic.debug in the ini file, I get this error message:</p>
<p><code><b>Warning:</b> mime_content_type()[<a href="http://www.php.net/mime_magic]" rel="nofollow noreferrer">http://www.php.net/mime_magic]</a>: mime_magic not initialized in <b>C:\xampp\htdocs\test.php</b> on line <b>2</b></code></p>
<p>I am not sure if that is a problem or if it still happens when I disable the debugging and it just doesn't tell me. </p>
<p>I checked, and <code>extension=php_mime_magic.dll</code> is enabled in the ini file and httpd.conf specifies <pre><code>LoadModule mime_module modules/mod_mime.so
#LoadModule mime_magic_module modules/mod_mime_magic.so</code></pre></p>
<p>I am using XAMPP 1.6.5.</p>
|
[
{
"answer_id": 197538,
"author": "ConroyP",
"author_id": 2287,
"author_profile": "https://Stackoverflow.com/users/2287",
"pm_score": 1,
"selected": false,
"text": "'FOO' is not a valid mimetype, entry skipped Fileinfo mime_content_type"
},
{
"answer_id": 199108,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 0,
"selected": false,
"text": "finfo_buffer $finfo = new finfo;\n$filename = $_GET['filename'];\nvar_dump($finfo->buffer(file_get_contents($filename)));\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6752/"
] |
197,521
|
<p>I must implement a web service which expose a list of values (integers, custom classes etc).
My working solution returns a <code>List<T></code>, and according to FxCop it is better to return a <code>Collection<T></code> or <code>ReadOnlyCollection<T></code>.</p>
<p>If I choose to return a <code>ReadOnlyCollection<T></code>, the web service shows an error like:</p>
<blockquote>
<p>To be XML serializable, types which inherit from <code>ICollection</code> must have an implementation of <code>Add(System.Int32)</code> at all levels of their inheritance hierarchy.
<code>System.Collections.ObjectModel.ReadOnlyCollection</code> <code>1</code> <code>[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]</code> does not implement <code>Add(System.Int32)</code>.</p>
</blockquote>
<p>What is your favorite way to use internally a <code>List<T></code> and expose a <code>Collection<T></code> ? (using C#, and preferably framework 2.0 only)</p>
|
[
{
"answer_id": 197530,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 5,
"selected": true,
"text": "List<Foo> list = new List<Foo>();\n// ...\nCollection<Foo> col = new Collection<Foo>(list);\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19756/"
] |
197,593
|
<p>Anyway, I'm a little confused about when to propagate an exception and when to wrap it, and the differences.</p>
<p>At the moment, my understanding tells me that wrapping an exception would involve taking an exception like DriveNotFound (in IO) and then wrap it with the general IOException.</p>
<p>But with the concept of propagating an exception, is this only something that happens if I have an empty catch clause? So in an ASP.NET web app, it would propagate to global.asax. Or in the case of a recently deployed web app, an unhandled HTTPException gave a yellow screen of death and wrote a log to Windows Server (this is a web app I'm rewriting). So the exception happens in a method, it could be handled at the class level, displayed in the page, and then goes up to global.asax or Windows Server.</p>
<p>Why exactly do I want to wrap an exception with a more generic one? The rule is to handle an exception with the most specific type (so DriveNotFound for obviously a drive not found). Also, how would I choose between wrapping and replacing an exception?</p>
<p>Is the exception handling chain just the try and catch (or catches) clauses? I assume from the wording, yes.</p>
<p>Finally, why and how would I want to let an exception propagate up the callstack?</p>
<p>I did read the MS PandP guide on exception handling, but I guess the examples didn't engage me enough to fully understand everything. </p>
<p>This question comes from Enterprise Library the ability to wrap/propagate an exception and etc. It's the propagating I'm not sure about, and the differences in replacing/wrapping an exception.</p>
<p>Also, is it ok to insert complex error handling logic in a catch block (e.g. ifs/elses and things like that).</p>
<p>Thanks</p>
|
[
{
"answer_id": 197601,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 3,
"selected": false,
"text": "FileNotFoundException ConfigurationException throw ex;\n throw;\n"
},
{
"answer_id": 197654,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "catch(Exception ex)"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
197,606
|
<p>I'm exploring various options for mapping common C# code constructs to C++ CUDA code for running on a GPU. The structure of the system is as follows (arrows represent method calls):</p>
<p>C# program -> C# GPU lib -> C++ CUDA implementation lib</p>
<p>A method in the GPU library could look something like this:</p>
<pre><code>public static void Map<T>(this ICollection<T> c, Func<T,T> f)
{
//Call 'f' on each element of 'c'
}
</code></pre>
<p>This is an extension method to ICollection<> types which runs a function on each element. However, what I would like it to do is to call the C++ library and make it run the methods on the GPU. This would require the function to be, somehow, translated into C++ code. Is this possible?</p>
<p>To elaborate, if the user of my library executes a method (in C#) with some arbitrary code in it, I would like to translate this code into the C++ equivelant such that I can run it on CUDA. I have the feeling that there are no easy way to do this but I would like to know if there are any way to do it or to achieve some of the same effect.</p>
<p>One thing I was wondering about is capturing the function to translate in an Expression and use this to map it to a C++ equivelant. Anyone has any experience with this?</p>
|
[
{
"answer_id": 319174,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 0,
"selected": false,
"text": "IQueryable"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4055/"
] |
197,614
|
<p>In chapter 2, the section on bitwise operators (section 2.9), I'm having trouble understanding how one of the sample methods works.</p>
<p>Here's the method provided:</p>
<pre><code>unsigned int getbits(unsigned int x, int p, int n) {
return (x >> (p + 1 - n)) & ~(~0 << n);
}
</code></pre>
<p>The idea is that, for the given number <em>x</em>, it will return the <em>n</em> bits starting at position <em>p</em>, counting from the right (with the farthest right bit being position 0). Given the following <code>main()</code> method:</p>
<pre><code>int main(void) {
int x = 0xF994, p = 4, n = 3;
int z = getbits(x, p, n);
printf("getbits(%u (%x), %d, %d) = %u (%X)\n", x, x, p, n, z, z);
return 0;
}
</code></pre>
<p>The output is:</p>
<blockquote>
<p><code>getbits(63892 (f994), 4, 3) = 5 (5)</code></p>
</blockquote>
<p>I get portions of this, but am having trouble with the "big picture," mostly because of the bits (no pun intended) that I don't understand.</p>
<p>The part I'm specifically having issues with is the complements piece: <code>~(~0 << n)</code>. I think I get the first part, dealing with <em>x</em>; it's this part (and then the mask) that I'm struggling with -- and how it all comes together to actually retrieve those bits. (Which I've verified it is doing, both with code and checking my results using calc.exe -- thank God it has a binary view!)</p>
<p>Any help?</p>
|
[
{
"answer_id": 197652,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 6,
"selected": true,
"text": "~0 1111111111111111\n n 1111111111111000\n 1 0 0000000000000111\n n f994 = 1111 1001 1001 0100 . ff94 ...........101.. # original number\n>> p+1-n [2] .............101 # shift desired bits to right\n& ~(~0 << n) [7] 0000000000000101 # clear all the other (left) bits\n"
},
{
"answer_id": 197660,
"author": "David Grant",
"author_id": 26829,
"author_profile": "https://Stackoverflow.com/users/26829",
"pm_score": 3,
"selected": false,
"text": "~(~0 << n) n 0\n 0000000000000000\n~0\n 1111111111111111\n~0 << 4\n 1111111111110000\n~(~0 << 4)\n 0000000000001111\n n"
},
{
"answer_id": 37164128,
"author": "M.M",
"author_id": 1505939,
"author_profile": "https://Stackoverflow.com/users/1505939",
"pm_score": 2,
"selected": false,
"text": "~0 << n ~0 E1 << E2 E1 E2 E1 2 E2 1"
},
{
"answer_id": 48939440,
"author": "Surfer Boy",
"author_id": 9399238,
"author_profile": "https://Stackoverflow.com/users/9399238",
"pm_score": -1,
"selected": false,
"text": "ANSI C ~0 >> n ~0 <<"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14048/"
] |
197,624
|
<p>Is it possible to integrate my PHP web-based ecommerce application with Quickbook Online Edition?</p>
<p>When I make a sale on my web site, I would like to be able to make the corresponding journal entry in my accounting books.</p>
<p>Note, I'm referring to Quickbook <strong>Online Edition</strong>, <strong>not</strong> the desktop software.</p>
|
[
{
"answer_id": 532455,
"author": "Keith Palmer Jr.",
"author_id": 26133,
"author_profile": "https://Stackoverflow.com/users/26133",
"pm_score": 4,
"selected": false,
"text": "// Create the connection to QuickBooks\n$API = new QuickBooks_API(...);\n\n// Build the Customer object\n$Customer = new QuickBooks_Object_Customer();\n$Customer->setName($name);\n$Customer->setShipAddress('134 Stonemill Road', '', '', '', '', 'Storrs', 'CT', '', '06268');\n\n// Send the request to QuickBooks\n$API->addCustomer($Customer, '_add_customer_callback', 15);\n\n// The framework also supports processing raw qbXML requests\n$API->qbxml('\n <CustomerQueryRq>\n <FullName>Keith Palmer Jr.</FullName>\n </CustomerQueryRq>', '_raw_qbxml_callback');\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
197,634
|
<p>With ASP.NET's view engine/template aspx/ashx pages the way to spit to screen seems to be: </p>
<pre><code><%= Person.Name %>
</code></pre>
<p>Which was fine with webforms as alot of model data was bound to controls programatically. But with MVC we are now using this syntax more oftern. </p>
<p>The issue I have with it is quite trivial, but annoying either way. This is that it seems to break up the mark up i.e.:</p>
<pre><code><% foreach(var Person in People) { %>
<%= Person.Name %>
<% } %>
</code></pre>
<p>That seems like alot of opening and closing tags to me!</p>
<p>Other view engines in the MVC contrib have a means of spitting to screen with out opening and closing the script tags using standard keyword such as "print, out, echo" i.e. (brail example):</p>
<pre><code><%
for element in list:
output "<li>${element}</li>"
end
%>
</code></pre>
<p>Now, I said this may seem trivial, but it just seems more readable this way. So what are the advantages of MS having this syntax, and not providing a output method?</p>
<p>Cheers, Chris.</p>
|
[
{
"answer_id": 197641,
"author": "John Rudy",
"author_id": 14048,
"author_profile": "https://Stackoverflow.com/users/14048",
"pm_score": 5,
"selected": true,
"text": "<% foreach(var Person in People) { \n Response.Write(Person.Name); \n} %>\n Response.Write() Response.Write() Response.Write() <%= %> Response.Write() <%= %> Response.Write Response.Write <%= %>"
},
{
"answer_id": 24130947,
"author": "KurvaBG",
"author_id": 3724124,
"author_profile": "https://Stackoverflow.com/users/3724124",
"pm_score": 1,
"selected": false,
"text": "@Html.Raw(\"SomeStringDirectlyInsideTheBrowserPageHTMLCode\") Response.Write(MyString) @Html.Raw(MyString) ViewContext.Writer.Write() ViewContext.Writer.WriteLine()"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/425/"
] |
197,649
|
<p>While working on SVG implementation for Internet Explorer to be based on its own VML format I came to a problem of translation of an SVG elliptical arc to an VML elliptical arc.</p>
<p>In VML an arc is given by: two angles for two points on ellipse and lengths of radiuses,
In SVG an arc is given by: two pairs of coordinates for two points on ellipse and sizes of ellipse boundary box</p>
<p>So, the question is: How to express angles of two points on ellipse to two pairs of their coordinates.
An intermediate question could be: How to find the center of an ellipse by coordinates of a pair of points on its curve.</p>
<p><b>Update</b>: Let's have a precondition saying that an ellipse is normally placed (its radiuses are parallel to linear coordinate system axis), thus no rotation is applied.</p>
<p><b>Update</b>: This question is not related to svg:ellipse element, rather to "a" elliptical arc command in svg:path element (<a href="http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands" rel="noreferrer">SVG Paths: The elliptical arc curve commands</a>)</p>
|
[
{
"answer_id": 11467200,
"author": "Rikki",
"author_id": 829305,
"author_profile": "https://Stackoverflow.com/users/829305",
"pm_score": 3,
"selected": false,
"text": "// Calculate the centre of the ellipse\n// Based on http://www.w3.org/TR/SVG/implnote.html#ArcConversionEndpointToCenter\nvar x1 = 150; // Starting x-point of the arc\nvar y1 = 150; // Starting y-point of the arc\nvar x2 = 400; // End x-point of the arc\nvar y2 = 300; // End y-point of the arc\nvar fA = 1; // Large arc flag\nvar fS = 1; // Sweep flag\nvar rx = 100; // Horizontal radius of ellipse\nvar ry = 50; // Vertical radius of ellipse\nvar phi = 0; // Angle between co-ord system and ellipse x-axes\n\nvar Cx, Cy;\n\n// Step 1: Compute (x1′, y1′)\nvar M = $M([\n [ Math.cos(phi), Math.sin(phi)],\n [-Math.sin(phi), Math.cos(phi)]\n ]);\nvar V = $V( [ (x1-x2)/2, (y1-y2)/2 ] );\nvar P = M.multiply(V);\n\nvar x1p = P.e(1); // x1 prime\nvar y1p = P.e(2); // y1 prime\n\n\n// Ensure radii are large enough\n// Based on http://www.w3.org/TR/SVG/implnote.html#ArcOutOfRangeParameters\n// Step (a): Ensure radii are non-zero\n// Step (b): Ensure radii are positive\nrx = Math.abs(rx);\nry = Math.abs(ry);\n// Step (c): Ensure radii are large enough\nvar lambda = ( (x1p * x1p) / (rx * rx) ) + ( (y1p * y1p) / (ry * ry) );\nif(lambda > 1)\n{\n rx = Math.sqrt(lambda) * rx;\n ry = Math.sqrt(lambda) * ry;\n}\n\n\n// Step 2: Compute (cx′, cy′)\nvar sign = (fA == fS)? -1 : 1;\n// Bit of a hack, as presumably rounding errors were making his negative inside the square root!\nif((( (rx*rx*ry*ry) - (rx*rx*y1p*y1p) - (ry*ry*x1p*x1p) ) / ( (rx*rx*y1p*y1p) + (ry*ry*x1p*x1p) )) < 1e-7)\n var co = 0;\nelse\n var co = sign * Math.sqrt( ( (rx*rx*ry*ry) - (rx*rx*y1p*y1p) - (ry*ry*x1p*x1p) ) / ( (rx*rx*y1p*y1p) + (ry*ry*x1p*x1p) ) );\nvar V = $V( [rx*y1p/ry, -ry*x1p/rx] );\nvar Cp = V.multiply(co);\n\n// Step 3: Compute (cx, cy) from (cx′, cy′)\nvar M = $M([\n [ Math.cos(phi), -Math.sin(phi)],\n [ Math.sin(phi), Math.cos(phi)]\n ]);\nvar V = $V( [ (x1+x2)/2, (y1+y2)/2 ] );\nvar C = M.multiply(Cp).add(V);\n\nCx = C.e(1);\nCy = C.e(2);\n"
},
{
"answer_id": 61169127,
"author": "Ievgen",
"author_id": 508330,
"author_profile": "https://Stackoverflow.com/users/508330",
"pm_score": 0,
"selected": false,
"text": " ellipseCenter(\n x1: number,\n y1: number,\n rx: number,\n ry: number,\n rotateDeg: number,\n fa: number,\n fs: number,\n x2: number,\n y2: number\n ): DOMPoint {\n const phi = ((rotateDeg % 360) * Math.PI) / 180;\n const m = new DOMMatrix([\n Math.cos(phi),\n -Math.sin(phi),\n Math.sin(phi),\n Math.cos(phi),\n 0,\n 0,\n ]);\n let v = new DOMPoint((x1 - x2) / 2, (y1 - y2) / 2).matrixTransform(m);\n const x1p = v.x;\n const y1p = v.y;\n rx = Math.abs(rx);\n ry = Math.abs(ry);\n const lambda = (x1p * x1p) / (rx * rx) + (y1p * y1p) / (ry * ry);\n if (lambda > 1) {\n rx = Math.sqrt(lambda) * rx;\n ry = Math.sqrt(lambda) * ry;\n }\n const sign = fa === fs ? -1 : 1;\n const div =\n (rx * rx * ry * ry - rx * rx * y1p * y1p - ry * ry * x1p * x1p) /\n (rx * rx * y1p * y1p + ry * ry * x1p * x1p);\n\n const co = sign * Math.sqrt(Math.abs(div));\n\n // inverse matrix b and c\n m.b *= -1;\n m.c *= -1;\n v = new DOMPoint(\n ((rx * y1p) / ry) * co,\n ((-ry * x1p) / rx) * co\n ).matrixTransform(m);\n v.x += (x1 + x2) / 2;\n v.y += (y1 + y2) / 2;\n return v;\n }"
},
{
"answer_id": 71913472,
"author": "NoBullsh1t",
"author_id": 8447743,
"author_profile": "https://Stackoverflow.com/users/8447743",
"pm_score": 0,
"selected": false,
"text": "a b /**\n * We're in 2D, so that's what our vertors look like\n */\nexport type Point = [number, number];\n\n/**\n * Calculates the vector that connects the two points\n */\nfunction deltaXY (from: Point, to: Point): Point {\n return [to[0]-from[0], to[1]-from[1]];\n}\n\n/**\n * Calculates the sum of an arbitrary amount of vertors\n */\nfunction vecAdd (...vectors: Point[]): Point {\n return vectors.reduce((acc, curr) => [acc[0]+curr[0], acc[1]+curr[1]], [0, 0]);\n}\n\n/**\n * Given two points a and b, as well as ellipsis radii rX and rY, this \n * function calculates the center-point of the ellipse, so that it\n * is \"above\" the two points and has them on the circumference\n */\nfunction topLeftOfPointsCenter (a: Point, b: Point, rX: number, rY: number): Point {\n const delta = deltaXY(a, b);\n \n // Sergey's work leads up to a simple system of liner equations. \n // Here, we calculate its general solution for the first of the two angles (t1)\n const A = Math.asin(Math.sqrt((delta[0]/(2*rX))**2+(delta[1]/(2*rY))**2));\n const B = Math.atan(-delta[0]/delta[1] * rY/rX);\n const alpha = A + B;\n \n // This may be the new center, but we don't know to which of the two\n // solutions it belongs, yet\n let newCenter = vecAdd(a, [\n rX * Math.cos(alpha),\n rY * Math.sin(alpha)\n ]);\n\n // Figure out if it is the correct solution, and adjusting if not\n const mean = vecAdd(a, [delta[0] * 0.5, delta[1] * 0.5]);\n const factor = mean[1] > newCenter[1] ? 1 : -1;\n const offMean = deltaXY(mean, newCenter);\n newCenter = vecAdd(mean, [offMean[0] * factor, offMean[1] * factor]);\n\n return newCenter;\n}\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23815/"
] |
197,675
|
<pre><code>Foo* set = new Foo[100];
// ...
delete [] set;
</code></pre>
<p>You don't pass the array's boundaries to <code>delete[]</code>. But where is that information stored? Is it standardised?</p>
|
[
{
"answer_id": 206355,
"author": "MSN",
"author_id": 6210,
"author_profile": "https://Stackoverflow.com/users/6210",
"pm_score": 3,
"selected": false,
"text": "delete[] new[] operator new[] operator new[] new[] new[] operator new[]/operator delete[] new[]/delete[] malloc"
},
{
"answer_id": 21984370,
"author": "Avt",
"author_id": 3140927,
"author_profile": "https://Stackoverflow.com/users/3140927",
"pm_score": 5,
"selected": false,
"text": "int* i = new int[4];\n sizeof(int)*5 int *temp = malloc(sizeof(int)*5)\n sizeof(int) *temp = 4;\n i i = temp + 1;\n i delete[] i;\n int *temp = i - 1;\nint numbers_of_element = *temp; // = 4\n... call destructor for numbers_of_element elements\n... that are stored in temp + 1, temp + 2, ... temp + 4 if needed\nfree (temp)\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4833/"
] |
197,676
|
<p>I'm working with embedded C for the first time. Although my C is rusty, I can read the code but I don't really have a grasp on why certain lines are the way the are. For example, I want to know if a variable is true or false and send it back to another application. Rather than setting the variable to 1 or 0, the original implementor chose 0xFF.</p>
<p>Is he trying to set it to an address space? or else why set a boolean variable to be 255?</p>
|
[
{
"answer_id": 197686,
"author": "Peter Kühne",
"author_id": 27351,
"author_profile": "https://Stackoverflow.com/users/27351",
"pm_score": 6,
"selected": true,
"text": "0xFF 0 1"
},
{
"answer_id": 198303,
"author": "mfx",
"author_id": 8015,
"author_profile": "https://Stackoverflow.com/users/8015",
"pm_score": 4,
"selected": false,
"text": " // FLAGMASK = ..1<<n for n in 0..7...\n FLAGMASK = 0x10; // e.g. n=4\n\n flags &= ~FLAGMASK; // clear bit\n flags |= FLAGMASK; // set bit\n flags ^= FLAGMASK; // flip bit\n flags = (flags & ~FLAGMASK) | (booleanFunction() & FLAGMASK); // clear, then maybe set\n"
},
{
"answer_id": 198571,
"author": "Dan Lenski",
"author_id": 20789,
"author_profile": "https://Stackoverflow.com/users/20789",
"pm_score": 1,
"selected": false,
"text": "0xff 0 0xff 1 0xff"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8040/"
] |
197,678
|
<p>I want to do some checking in a writer accessor. My first idea was returning a boolean.</p>
<pre><code>class MyClass
def var=(var)
@var = var
# some checking
return true
end
end
m = MyClass.new
retval = (m.var = 'foo')
=> "foo"
</code></pre>
<p>Can I set a return value in a writer accessor? If yes, how can I get this value?</p>
|
[
{
"answer_id": 197704,
"author": "epochwolf",
"author_id": 16204,
"author_profile": "https://Stackoverflow.com/users/16204",
"pm_score": 3,
"selected": false,
"text": "Correct\n>>temp = object.var = 7\n=> 7 \n\nWrong\n>>temp = object.var = 7\n=> false\n method=()"
},
{
"answer_id": 197724,
"author": "mwilliams",
"author_id": 23909,
"author_profile": "https://Stackoverflow.com/users/23909",
"pm_score": 2,
"selected": false,
"text": "class MyClass\n attr_accessor :var\nend\n\nm = MyClass.new\nm.var = \"Test\"\nputs m.var # => \"Test\"\n class Person\n include Validatable\n validates_presence_of :name\n attr_accessor :name\nend\n\nclass PersonPresenter\n include Validatable\n include_validations_for :person\n attr_accessor :person\n\n def initialize(person)\n @person = person\n end\nend\n\npresenter = PersonPresenter.new(Person.new)\npresenter.valid? #=> false\npresenter.errors.on(:name) #=> \"can't be blank\"\n"
},
{
"answer_id": 197812,
"author": "Christoph Schiessl",
"author_id": 20467,
"author_profile": "https://Stackoverflow.com/users/20467",
"pm_score": 2,
"selected": false,
"text": "class Test\n def var=(var)\n @var = var\n return true\n end\nend\n\nt1, t2 = Test.new, Test.new\n\nt1.var = 123 # evaluates to 123\n\n# Why is it impossible to return something else:\nt1.var = t2.var = 456\n class Test\n def method_missing(method, *args)\n if method == :var=\n # check something\n @var = args[0]\n return true\n else\n super(method, *args)\n end\n end\n\n def var\n @var\n end\nend\n\nt = Test.new\nt.var = 123 # evaluates to 123\nt.does_not_exists # NoMethodError\n var= class Test\n def var=(var)\n raise ArgumentError if var < 100 # or some other condition\n @var = var\n end\n def var\n @var\n end\nend\n\nt = Test.new\nt.var = 123 # 123\nt.var = 1 # ArgumentError raised\nt.var # 123\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/341/"
] |
197,708
|
<p>I'd like to use Rich Text Editing in place on forms in order to let admins change instructions. What are the best options for doing this?</p>
<p>[To be more clear - the admins are non-technical but may want to control some formatting without using markup or with as little markup as possible. What I'd like is for them to be able to edit inline all AJAXy with an RTE featuring some formatting controls and then submit and be able to see what the instructions will look like to the end user without changing pages.</p>
<p>With Regards to plugins specifically, what I'd like to know is which Rich Test Editing plugins are the best for use in Rails. Easiest to implement, clearest API, easiest to use inline, etc... ] </p>
|
[
{
"answer_id": 1570094,
"author": "Jon",
"author_id": 3231,
"author_profile": "https://Stackoverflow.com/users/3231",
"pm_score": 3,
"selected": false,
"text": "include_puny_mce puny_mce include_puny_mce puny_mce <% content_for :head do %>\n <%= include_puny_mce :profiles => [:full] %>\n<% end %>\n\n<h1>New post</h1>\n\n<% form_for(@post) do |f| %>\n <%= f.error_messages %>\n <%= f.label :title, \"Title\" %><br />\n <%= f.text_field :title %><br />\n <%= f.label :content, \"Post Content\" %><br />\n <%= f.text_area :content, :cols => 100 %>\n <%= puny_mce 'post_content', 'post_content', :profile => :full %>\n <p>\n <%= f.submit 'Create' %>\n </p>\n<% end %>\n"
},
{
"answer_id": 62020514,
"author": "AlecRust",
"author_id": 312681,
"author_profile": "https://Stackoverflow.com/users/312681",
"pm_score": 1,
"selected": false,
"text": "rich_text_area has_rich_text"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6805/"
] |
197,712
|
<pre><code>echo "<td><a href='delete.php?id=$row[id]&&category=$a' onclick='return confirm(\'are you sure you wish to delete this record\');'>delete</a></td>";
</code></pre>
<p>Above is the code I am trying to use. Every time it does nothing and I cannot see how I can use 'proper' JavaScript methods. What is the reason?</p>
|
[
{
"answer_id": 197723,
"author": "ceejayoz",
"author_id": 1902010,
"author_profile": "https://Stackoverflow.com/users/1902010",
"pm_score": 1,
"selected": false,
"text": "echo \"<td><a href='delete.php?id=$row[id]&&category=$a' onclick='return confirm("are you sure you wish to delete this record");'>delete</a></td>\";\n"
},
{
"answer_id": 197749,
"author": "MDCore",
"author_id": 1896,
"author_profile": "https://Stackoverflow.com/users/1896",
"pm_score": 2,
"selected": false,
"text": "echo \"<td><a href='delete.php?id={$row[id]}&&category=$a'...\n ?><td><a href=\"delete.php?id=<?=$row[id];?>&category=<?=$a;?>\" onclick=\"return confirm('are you sure you wish to delete this record');\">delete</a></td><?\n function confirm_delete() {\n return confirm('Are you sure you want to delete this record?');\n}\n return confirm_delete()"
},
{
"answer_id": 197960,
"author": "roenving",
"author_id": 23142,
"author_profile": "https://Stackoverflow.com/users/23142",
"pm_score": -1,
"selected": false,
"text": "echo \"<td><a href='delete.php?id=$row[id]&&category=$a' onclick='return confirm(\\\\'are you sure you wish to delete this record\\\\');'>delete</a></td>\";\n"
},
{
"answer_id": 198319,
"author": "Darryl Hein",
"author_id": 5441,
"author_profile": "https://Stackoverflow.com/users/5441",
"pm_score": 0,
"selected": false,
"text": "echo '<td><a href=\"delete.php?id=' . $row[id] . '&category=' . $a . '\" onclick=\"return confirm(\\'are you sure you wish to delete this record?\\');'>delete</a></td>';\n"
},
{
"answer_id": 199345,
"author": "Brad",
"author_id": 26130,
"author_profile": "https://Stackoverflow.com/users/26130",
"pm_score": -1,
"selected": false,
"text": "?> <td><a href=\"?mode=upd&id=<?= $row[id] ?>&table=<?= $table ?>\">Upd</a> / <a href=\"?mode=del&id=<?= $row[id] ?>&table=<?= $table ?>\" onclick=\"return confirm('Are you sure you want to delete?')\">Del</a></td> <?php\n"
},
{
"answer_id": 199530,
"author": "cole",
"author_id": 910,
"author_profile": "https://Stackoverflow.com/users/910",
"pm_score": 2,
"selected": false,
"text": "window.addEvent('domready', function(){\n $$('a.confirm_delete').each(function(item, index){\n item.addEvent('click', function(){\n var confirm_result = confirm('Sure you want to delete');\n if(confirm_result){\n this.setProperty('href', this.getProperty('href') + '&confirm');\n return true;\n }else{\n return false;\n }\n }); \n });\n});\n"
},
{
"answer_id": 199580,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 2,
"selected": false,
"text": "printf('<td><a id=\"deleteLink\" href=\"delete.php?id=%d&category=%s\">Delete</a></td>', $row[\"id\"], $a);\n document.getElementById('deleteLink').onclick = function() {\n return confirm(\"Are you sure you wish to delete?\");\n};\n confirm(...) id <a class=\"deleteLink\" ... $('.deleteLink').click(function() {\n return confirm(\"...\");\n});\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
197,713
|
<p>I wonder what the best way to make an entire tr clickable would be?</p>
<p>The most common (and only?) solution seems to be using JavaScript, by using onclick="javascript:document.location.href('bla.htm');" (not to forget: Setting a proper cursor with onmouseover/onmouseout).</p>
<p>While that works, it is a pity that the target URL is not visible in the status bar of a browser, unlike normal links.</p>
<p>So I just wonder if there is any room for optimization? Is it possible to display the URL that will be navigated to in the status bar of the browser? Or is there even a non-JavaScript way to make a tr clickable?</p>
|
[
{
"answer_id": 197733,
"author": "MDCore",
"author_id": 1896,
"author_profile": "https://Stackoverflow.com/users/1896",
"pm_score": 1,
"selected": false,
"text": "tr onmouseover=\"window.status='http://bla.com/bla.htm'\" \n tr.clickable {\n cursor: hand; \n cursor: pointer;\n}\n"
},
{
"answer_id": 197740,
"author": "mwilliams",
"author_id": 23909,
"author_profile": "https://Stackoverflow.com/users/23909",
"pm_score": 3,
"selected": false,
"text": "$('tr').click(function () {\n $(this).toggleClass('highlight_row');\n}); \n"
},
{
"answer_id": 197912,
"author": "roenving",
"author_id": 23142,
"author_profile": "https://Stackoverflow.com/users/23142",
"pm_score": 3,
"selected": false,
"text": "onclick=\"javascript:document.location.href('bla.htm');\" onclick=\"window.location.href='bla.html';\"\n style=\"cursor:pointer;\"\n"
},
{
"answer_id": 198110,
"author": "buti-oxa",
"author_id": 2515,
"author_profile": "https://Stackoverflow.com/users/2515",
"pm_score": 2,
"selected": false,
"text": "<script type=\"text/javascript\">\nfunction setLink(elRow) {\nvar elLink = document.getElementById('link');\nelLink.href = elRow.rowIndex + \".com\";\n}\n</script>\n...\n<a id=link>\n<table>\n <tr onMouseOver=\"setLink(this);\"><td>first row</td></tr>\n <tr onMouseOver=\"setLink(this);\"><td>second row</td></tr>\n</table>\n</a> \n"
},
{
"answer_id": 705316,
"author": "Alice Davey",
"author_id": 85647,
"author_profile": "https://Stackoverflow.com/users/85647",
"pm_score": 6,
"selected": false,
"text": "display: block height line-height table.row-clickable tbody tr td {\n padding: 0;\n}\n\ntable.row-clickable tbody tr td a {\n display: block;\n padding: 8px;\n}\n <table class=\"table table-hover row-clickable\">\n <tbody>\n <tr>\n <td><a href=\"#\">Column 1</a></td>\n <td><a href=\"#\">Column 2</a></td>\n <td><a href=\"#\">Column 3</a></td>\n </tr>\n </tbody>\n</table>\n"
},
{
"answer_id": 6533183,
"author": "B.M.",
"author_id": 772994,
"author_profile": "https://Stackoverflow.com/users/772994",
"pm_score": 1,
"selected": false,
"text": ".myDataTable {\n background: 444;\n width: 100%;\n}\n\n.myDataTable thead tr {\n background-image: url('../img/tableHeader.jpg');\n}\n\n.myDataTable thead tr th {\n height: 28px;\n font-size: 14px;\n font-family: tahoma, helvetica, arial, sans-serif;\n padding-left: 5px;\n}\n\n.myDataTable thead tr th img {\n padding-right: 5px;\n padding-top: 1px;\n}\n\n.myDataTable thead tr td {\n height: 15px;\n font-size: 11px;\n font-weight: bold;\n font-family: tahoma, helvetica, arial, sans-serif;\n padding-left: 5px;\n}\n\n.myDataTable tbody {\n background: #f2f5f9;\n}\n\n.myDataTable tbody tr:nth-child(even) td,tbody tr.even td {\n background: #e2ebf4;\n font-size: 12px;\n padding-left: 5px;\n height: 14px;\n}\n\n.myDataTable tbody tr:nth-child(odd) td,tbody tr.odd td {\n background: #f7faff;\n font-size: 12px;\n padding-left: 5px;\n height: 14px;\n}\n\n.myDataTable tbody tr:hover td {\n background-color: #e7e7e7;\n}\n\n.myDataTable tbody tr td {\n height: 14px;\n padding-left: 5px;\n font-size: 12px;\n}\n\n.myDataTable tbody tr td a {\n color: black;\n text-decoration: none;\n font-size: 12px;\n display: block;\n}\n\n.myDataTable thead tr th a {\n color: black;\n text-decoration: none;\n font-size: 12px;\n display: inline;\n}\n <table class=\"myDataTable\">\n <thead>\n <tr>\n <th>Heading 1</th>\n <th>Heading 2</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td><a href=\"#\">Data 1 </a></td>\n <td><a href=\"#\">Data 2 </a></td>\n </tr>\n </tbody>\n</table>\n"
},
{
"answer_id": 7092533,
"author": "nachomaans",
"author_id": 746477,
"author_profile": "https://Stackoverflow.com/users/746477",
"pm_score": 3,
"selected": false,
"text": "$(document).ready(function() {\n $('#example tr').click(function() {\n var href = $(this).find(\"a\").attr(\"href\");\n\n if(href) {\n window.location = href;\n }\n });\n});\n tr:hover #table tr:hover {cursor: pointer;}\n"
},
{
"answer_id": 9527345,
"author": "Tobias Cohen",
"author_id": 66617,
"author_profile": "https://Stackoverflow.com/users/66617",
"pm_score": 1,
"selected": false,
"text": "<a> <tbody> $(function() {\n $('.table-linked').each(function() {\n var table, tbody;\n table = this;\n tbody = $('tbody', this);\n tbody.children().each(function() {\n var href, row;\n row = $(this);\n href = row.attr('data-href');\n $('<a href=\"' + href + '\" style=\"display: table-row-group\" />').append(row).appendTo(table);\n });\n tbody.remove();\n });\n});\n <table class=\"table-linked\">\n <tbody>\n <tr data-href=\"/a\"><td>a</td><td>1</td></tr>\n <tr data-href=\"/b\"><td>b</td><td>2</td></tr>\n </tbody>\n</table>\n <table>\n <a href=\"/a\" style=\"display: table-row-group\">\n <tr><td>a</td><td>1</td></tr>\n </a>\n <a href=\"/b\" style=\"display: table-row-group\">\n <tr><td>b</td><td>1</td></tr>\n </a>\n</table>\n"
},
{
"answer_id": 20428478,
"author": "sckd",
"author_id": 2323738,
"author_profile": "https://Stackoverflow.com/users/2323738",
"pm_score": 2,
"selected": false,
"text": "<table class=\"search_results\">\n <tr>\n <td><a href=\"#\">Some text</a></td>\n <td>more text</td>\n <td>more text</td>\n </tr>\n</table>\n table.search_results a {position:absolute;display:block;width:98%;}\n table.search_results td:first-child {padding:0;}\ntable.search_results a {position:absolute;display:block;width:98%;max-width:1272px;font-weight:normal;color:#000;padding:.5em;}\ntable.search_results a:hover {background:none;}\ntable.search_results tr:hover {border-color:#25505b;background:#b5d6dd;}\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91/"
] |
197,725
|
<p>I'm writing an winforms app that needs to set internet explorer's proxy settings and then open a new browser window. At the moment, I'm applying the proxy settings by going into the registry:</p>
<pre><code>RegistryKey registry = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
registry.SetValue("ProxyEnable", 1);
registry.SetValue("ProxyServer", "127.0.0.1:8080");
</code></pre>
<p>Is going into the registry the <em>best</em> way to do this, or is there a more recommended approach? I'd like to avoid registry changes if there's an alternative solution.</p>
|
[
{
"answer_id": 4493545,
"author": "chris",
"author_id": 528844,
"author_profile": "https://Stackoverflow.com/users/528844",
"pm_score": 4,
"selected": false,
"text": " [DllImport(\"wininet.dll\")]\n public static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int dwBufferLength);\n public const int INTERNET_OPTION_SETTINGS_CHANGED = 39;\n public const int INTERNET_OPTION_REFRESH = 37;\n bool settingsReturn, refreshReturn;\n RegKey.SetValue(\"ProxyServer\", YOURPROXY);\n RegKey.SetValue(\"ProxyEnable\", 1);\n\n // These lines implement the Interface in the beginning of program \n // They cause the OS to refresh the settings, causing IP to realy update\n settingsReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0);\n refreshReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_REFRESH, IntPtr.Zero, 0);\n"
},
{
"answer_id": 8724165,
"author": "Dave",
"author_id": 150094,
"author_profile": "https://Stackoverflow.com/users/150094",
"pm_score": -1,
"selected": false,
"text": "WebProxy proxyObject = new WebProxy(\"http://proxyserver:80/\",true);\nWebRequest req = WebRequest.Create(\"http://www.contoso.com\");\nreq.Proxy = proxyObject;\n"
},
{
"answer_id": 26273084,
"author": "131",
"author_id": 146457,
"author_profile": "https://Stackoverflow.com/users/146457",
"pm_score": 4,
"selected": false,
"text": "using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Runtime.InteropServices;\nusing Microsoft.Win32;\n\nnamespace ProxyToggle\n{\n\n class Program\n {\n\n [DllImport(\"wininet.dll\")]\n public static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int dwBufferLength);\n public const int INTERNET_OPTION_SETTINGS_CHANGED = 39;\n public const int INTERNET_OPTION_REFRESH = 37;\n\n\n static void setProxy(string proxyhost, bool proxyEnabled)\n {\n const string userRoot = \"HKEY_CURRENT_USER\";\n const string subkey = \"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Internet Settings\";\n const string keyName = userRoot + \"\\\\\" + subkey;\n\n if(proxyhost.Length != 0)\n Registry.SetValue(keyName, \"ProxyServer\", proxyhost);\n Registry.SetValue(keyName, \"ProxyEnable\", proxyEnabled ? \"1\" : \"0\", RegistryValueKind.DWord);\n\n // These lines implement the Interface in the beginning of program \n // They cause the OS to refresh the settings, causing IP to realy update\n InternetSetOption(IntPtr.Zero, INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0);\n InternetSetOption(IntPtr.Zero, INTERNET_OPTION_REFRESH, IntPtr.Zero, 0);\n }\n\n static void Main(string[] args)\n {\n if (args.Length == 0)\n {\n setProxy(\"\", false);\n return;\n }\n\n setProxy(args[0], true);\n }\n }\n}\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17623/"
] |
197,734
|
<p>Recent versions of PHP have a cache of filenames for knowing the real path of files, and <code>require_once()</code> and <code>include_once()</code> can take advantage of it.</p>
<p>There's a value you can set in your <em>php.ini</em> to set the size of the cache, but I have no idea how to tell what the size should be. The default value is 16k, but I see no way of telling how much of that cache we're using. The docs are vague: </p>
<p><a href="http://us2.php.net/manual/en/ini.core.php#ini.realpath-cache-size" rel="nofollow noreferrer">Determines the size of the realpath cache to be used by PHP. This value should be increased on systems where PHP opens many files, to reflect the quantity of the file operations performed.</a></p>
<p>Yes, I can jack up the amount of cache allowed, and run tests with <code>ab</code> or some other testing, but I'd like something with a little more introspection than just timing from a distance.</p>
|
[
{
"answer_id": 69048217,
"author": "Vincent",
"author_id": 1380479,
"author_profile": "https://Stackoverflow.com/users/1380479",
"pm_score": 1,
"selected": false,
"text": "<?php\n\necho \"<br>cache size: \".realpath_cache_size();\necho \"<br>\";\necho \"<br>cache: \".print_r(realpath_cache_get(););\n\n?>\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197734",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8454/"
] |
197,747
|
<p>I want to create a new row in my database on a table that has a couple of foreign key relationships and I haven't been able to get a handle on what order and what calls need to be made. This is what I have so far:</p>
<pre><code>db.Models.Order order = DB.Models.Order.CreateOrder( apple );
order.CustomerReference.Attach( ( from c in db.Customer where c.Id == custId select c ).First() );
db.SaveChanges();
</code></pre>
<p>The code is failing on the second line there, saying: </p>
<blockquote>
<p>Attach is not a valid operation when
the source object associated with this
related end is in an added, deleted,
or detached state. Objects loaded
using the NoTracking merge option are
always detached.</p>
</blockquote>
<p>Any ideas?</p>
|
[
{
"answer_id": 197842,
"author": "Jared",
"author_id": 24841,
"author_profile": "https://Stackoverflow.com/users/24841",
"pm_score": 4,
"selected": true,
"text": "db.Models.Order order = DB.Models.Order.CreateOrder( apple );\norder.Customer = (from c in db.Customer where c.Id == custId select c).First();\ndb.SaveChanges();\n"
},
{
"answer_id": 368867,
"author": "kirkmcpherson",
"author_id": 46400,
"author_profile": "https://Stackoverflow.com/users/46400",
"pm_score": 3,
"selected": false,
"text": "SELECT CustomerReference EntityKey order.CustomerReference = new System.Data.Objects.DataClasses.EntityReference<Customers>();\norder.CustomerReference.EntityKey = new EntityKey(\"ModelsEntities.Customers\", \"Id\", custId);\n"
},
{
"answer_id": 992906,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "using (var ctx = new DataModelEntities())\n{\n\n var result = (from p in ctx.UserRole.Where(o => o.UserRoleId == userRole.UserRoleId)\n select p).First();\n\n result.RolesReference.EntityKey = new EntityKey(\"DataModelEntities.Roles\",\n \"RoleId\", userRole.RoleId);\n\n result.UserRoleDescription = userRole.UserRoleDescription; \n ctx.SaveChanges();\n}\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24841/"
] |
197,748
|
<p>Anyone know a simple method to swap the background color of a webpage using JavaScript?</p>
|
[
{
"answer_id": 197761,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 9,
"selected": true,
"text": "document.body.style.background function changeBackground(color) {\n document.body.style.background = color;\n}\n\nwindow.addEventListener(\"load\",function() { changeBackground('red') });\n"
},
{
"answer_id": 197763,
"author": "Duncan Smart",
"author_id": 1278,
"author_profile": "https://Stackoverflow.com/users/1278",
"pm_score": 2,
"selected": false,
"text": "document.body.style.backgroundColor = 'pink';\n"
},
{
"answer_id": 197764,
"author": "Simon Lehmann",
"author_id": 27011,
"author_profile": "https://Stackoverflow.com/users/27011",
"pm_score": 6,
"selected": false,
"text": "document.body.style.backgroundColor = \"#AA0000\";\n"
},
{
"answer_id": 197771,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 4,
"selected": false,
"text": "$('body').css('background', '#ccc');\n document.body.style.background = \"#ccc\";\n"
},
{
"answer_id": 197833,
"author": "redsquare",
"author_id": 6440,
"author_profile": "https://Stackoverflow.com/users/6440",
"pm_score": 2,
"selected": false,
"text": "document.body.className = className;\n"
},
{
"answer_id": 197899,
"author": "Martin Kool",
"author_id": 216896,
"author_profile": "https://Stackoverflow.com/users/216896",
"pm_score": 4,
"selected": false,
"text": "className className AnErrorHasOccured body.AnErrorHasOccured\n{\n background: #f00;\n}\n document.body.className = \"AnErrorHasOccured\";\n className className"
},
{
"answer_id": 4866010,
"author": "james.garriss",
"author_id": 584674,
"author_profile": "https://Stackoverflow.com/users/584674",
"pm_score": 2,
"selected": false,
"text": "<body>\n <p>Hello, World!</p>\n <script type=\"text/javascript\">\n document.body.style.backgroundColor = \"#ff0000\"; // red\n </script>\n</body>"
},
{
"answer_id": 13194318,
"author": "defau1t",
"author_id": 724764,
"author_profile": "https://Stackoverflow.com/users/724764",
"pm_score": 2,
"selected": false,
"text": "document.body.style.background = #000000; //I used black as color code\n $(function() {\n var colors = [\"#0099cc\",\"#c0c0c0\",\"#587b2e\",\"#990000\",\"#000000\",\"#1C8200\",\"#987baa\",\"#981890\",\"#AA8971\",\"#1987FC\",\"#99081E\"];\n\n setInterval(function() { \n var bodybgarrayno = Math.floor(Math.random() * colors.length);\n var selectedcolor = colors[bodybgarrayno];\n $(\"body\").css(\"background\",selectedcolor);\n }, 3000);\n })\n"
},
{
"answer_id": 19145226,
"author": "gaby de wilde",
"author_id": 2117400,
"author_profile": "https://Stackoverflow.com/users/2117400",
"pm_score": 0,
"selected": false,
"text": "<body> <script>\n var myColor = \"#AAAAAA\";\n document.write('\\\n <style>\\\n body{\\\n background-color: '+myColor+';\\\n }\\\n </style>\\\n ');\n</script>\n <head> var myColor = '#'+(Math.random()*0xFFFFFF<<0).toString(16);\n"
},
{
"answer_id": 28083129,
"author": "joel hills",
"author_id": 4481398,
"author_profile": "https://Stackoverflow.com/users/4481398",
"pm_score": 1,
"selected": false,
"text": "<div id=\"example\" onClick=\"colorize()\">Click on this text to change the\nbackground color</div>\n<script type='text/javascript'>\nfunction colorize() {\nvar element = document.getElementById(\"example\");\nelement.style.backgroundColor='#800';\nelement.style.color='white';\nelement.style.textAlign='center';\n}\n</script>\n"
},
{
"answer_id": 28734873,
"author": "Vignesh Subramanian",
"author_id": 848841,
"author_profile": "https://Stackoverflow.com/users/848841",
"pm_score": 4,
"selected": false,
"text": " var imageUrl= \"URL OF THE IMAGE HERE\";\n var BackgroundColor=\"RED\"; // what ever color you want\n document.body.style.backgroundImage=imageUrl //changing bg image\ndocument.body.style.backgroundColor=BackgroundColor //changing bg color\n document.getElementById(\"ElementId\").style.backgroundImage=imageUrl\ndocument.getElementById(\"ElementId\").style.backgroundColor=BackgroundColor \n var elements = document.getElementsByClassName(\"ClassName\")\n for (var i = 0; i < elements.length; i++) {\n elements[i].style.background=imageUrl;\n }\n"
},
{
"answer_id": 39315370,
"author": "Deniz.parlak",
"author_id": 6754044,
"author_profile": "https://Stackoverflow.com/users/6754044",
"pm_score": 2,
"selected": false,
"text": "body{\n background-color:black;\n animation: image 10s infinite alternate;\n animation:image 10s infinite alternate;\n animation:image 10s infinite alternate;\n}\n\n@keyframes image{\n 0%{\nbackground-color:blue;\n}\n25%/{\n background-color:red;\n}\n50%{\n background-color:green;\n}\n75%{\n\n background-color:pink;\n}\n100%{\n background-color:yellow;\n }\n } \n"
},
{
"answer_id": 43015885,
"author": "Ritam Das",
"author_id": 5400367,
"author_profile": "https://Stackoverflow.com/users/5400367",
"pm_score": 2,
"selected": false,
"text": "function changeBG() {\n var selectedBGColor = document.getElementById(\"bgchoice\").value;\n document.body.style.backgroundColor = selectedBGColor;\n} <select id=\"bgchoice\" onchange=\"changeBG()\">\n <option></option>\n <option value=\"red\">Red</option>\n <option value=\"ivory\">Ivory</option>\n <option value=\"pink\">Pink</option>\n</select>"
},
{
"answer_id": 48926051,
"author": "Alex",
"author_id": 9226166,
"author_profile": "https://Stackoverflow.com/users/9226166",
"pm_score": 2,
"selected": false,
"text": "document.querySelector(\"button\").addEventListener(\"click\", function() {\ndocument.body.style.backgroundColor = \"red\";\n});\n"
},
{
"answer_id": 49526545,
"author": "jonathan klevin",
"author_id": 9466285,
"author_profile": "https://Stackoverflow.com/users/9466285",
"pm_score": 1,
"selected": false,
"text": "function changeBodyBg(color){\n document.body.style.background = color;\n}\n"
},
{
"answer_id": 53256265,
"author": "Divakar Rajesh",
"author_id": 8950361,
"author_profile": "https://Stackoverflow.com/users/8950361",
"pm_score": 2,
"selected": false,
"text": "document.getElementById(\"yourid\").style.backgroundColor = `rgb(${a}, ${b}, ${c})`;\n document.getElementById(\"yourid\").style.backgroundColor = 'rgb(224,224,224)';\n"
},
{
"answer_id": 60974198,
"author": "Arslan",
"author_id": 11942876,
"author_profile": "https://Stackoverflow.com/users/11942876",
"pm_score": 2,
"selected": false,
"text": "<!DOCTYPE html>\n<html>\n<body>\n<select name=\"\" id=\"select\" onClick=\"hello();\">\n <option>Select</option>\n <option style=\"background-color: #CD5C5C;\">#CD5C5C</option>\n <option style=\"background-color: #F08080;\">#F08080</option>\n <option style=\"background-color: #FA8072;\">#FA8072</option>\n <option style=\"background-color: #E9967A;\">#E9967A</option>\n <option style=\"background-color: #FFA07A;\">#FFA07A</option>\n</select>\n<script>\nfunction hello(){\nlet d = document.getElementById(\"select\");\nlet text = d.options[d.selectedIndex].value;\ndocument.body.style.backgroundColor=text;\n}\n</script>\n</body>\n</html>\n"
},
{
"answer_id": 63435423,
"author": "Satish Chandra Gupta",
"author_id": 9445290,
"author_profile": "https://Stackoverflow.com/users/9445290",
"pm_score": 2,
"selected": false,
"text": "style.background style.backgroundColor style.background function pink(){ document.body.style.background = \"pink\"; }\nfunction sky(){ document.body.style.background = \"skyblue\"; } <p onclick=\"pink()\" style=\"padding:10px;background:pink\">Pink</p>\n<p onclick=\"sky()\" style=\"padding:10px;background:skyblue\">Sky</p> classList.add() function addClass(yourClass){\n document.body.classList.remove(\"sky\", \"pink\");\n document.body.classList.add(yourClass);\n } .pink {\n background: pink;\n }\n\n .sky {\n background: skyblue;\n } <p onclick=\"addClass('pink')\" style=\"padding:10px;background:pink\">Pink</p>\n <p onclick=\"addClass('sky')\" style=\"padding:10px;background:skyblue\">Sky</p>"
},
{
"answer_id": 66174009,
"author": "Kia Boluki",
"author_id": 2719481,
"author_profile": "https://Stackoverflow.com/users/2719481",
"pm_score": -1,
"selected": false,
"text": "setInterval(changeColor,1000);\nfunction changeColor(){\n let r = Math.random() * 255 ;\n let g = Math.random() * 255 ;\n let b = Math.random() * 255 ;\n \n document.body.style.backgroundColor = `rgb( ${r}, ${g}, ${b} )`;\n}"
},
{
"answer_id": 67374178,
"author": "Moazzam S",
"author_id": 11967419,
"author_profile": "https://Stackoverflow.com/users/11967419",
"pm_score": -1,
"selected": false,
"text": " <p id=\"p1\">Hello, Moazzam!</p>\n <p >Hello, Moazzam!</p>\n <p >Hello, Moazzam!</p>\n <script type=\"text/javascript\">\n document.getElementById(\"p1\").style.color= \"#ff0000\"; // red\n </script>\n"
},
{
"answer_id": 69371706,
"author": "salik saleem",
"author_id": 9542718,
"author_profile": "https://Stackoverflow.com/users/9542718",
"pm_score": 2,
"selected": false,
"text": " function changeBg()\n {\n document.body.style.color.backgroundColor=\"#ffffff\";\n\n }\n"
},
{
"answer_id": 72726955,
"author": "Mouzam Ali",
"author_id": 7188711,
"author_profile": "https://Stackoverflow.com/users/7188711",
"pm_score": 0,
"selected": false,
"text": "document.body.style.color.backgroundColor=\"#000000\";\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197748",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25515/"
] |
197,753
|
<p>I have 2 classes with a LINQ association between them i.e.:</p>
<pre><code>Table1: Table2:
ID ID
Name Description
ForiegnID
</code></pre>
<p>The association here is between <strong>Table1.ID -> Table2.ForiegnID</strong></p>
<p>I need to be able to change the value of Table2.ForiegnID, however I can't and think it is because of the association (as when I remove it, it works).</p>
<p>Therefore, does anyone know how I can change the value of the associated field Table2.ForiegnID?</p>
|
[
{
"answer_id": 197826,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 4,
"selected": true,
"text": "[Column(Storage=\"_ParentKey\", DbType=\"Int\")]\npublic System.Nullable<int> ParentKey\n{\n get\n {\n return this._ParentKey;\n }\n set\n {\n if ((this._ParentKey != value))\n {\n //This code is added by the association\n if (this._Parent.HasLoadedOrAssignedValue)\n {\n throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();\n }\n //This code is present regardless of association\n this.OnParentKeyChanging(value);\n this.SendPropertyChanging();\n this._ParentKey = value;\n this.SendPropertyChanged(\"ParentKey\");\n this.OnServiceAddrIDChanged();\n }\n }\n}\n [Association(Name=\"Parent_Child\", Storage=\"_Parent\", ThisKey=\"ParentKey\", IsForeignKey=true, DeleteRule=\"CASCADE\")]\npublic Parent Parent\n{\n get\n {\n return this._Parent.Entity;\n }\n set\n {\n Parent previousValue = this._Parent.Entity;\n if (((previousValue != value) \n || (this._Parent.HasLoadedOrAssignedValue == false)))\n {\n this.SendPropertyChanging();\n if ((previousValue != null))\n {\n this._Parent.Entity = null;\n previousValue.Exemptions.Remove(this);\n }\n this._Parent.Entity = value;\n if ((value != null))\n {\n value.Exemptions.Add(this);\n this._ParentKey = value.ParentKey;\n }\n else\n {\n this._ParentKey = default(Nullable<int>);\n }\n this.SendPropertyChanged(\"Parent\");\n }\n }\n}\n"
},
{
"answer_id": 839674,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "Table1: Table2:\nID ID\nName Description\n ForeignID\n Table2 table = dataContext.Table2.single(d => d.ID == Id)\n\n table.Table1 = dataContext.Table1.single(d => d.ID == newId);\n newId"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11989/"
] |
197,757
|
<p>I was trying to understand something with pointers, so I wrote this code:</p>
<pre><code>#include <stdio.h>
int main(void)
{
char s[] = "asd";
char **p = &s;
printf("The value of s is: %p\n", s);
printf("The direction of s is: %p\n", &s);
printf("The value of p is: %p\n", p);
printf("The direction of p is: %p\n", &p);
printf("The direction of s[0] is: %p\n", &s[0]);
printf("The direction of s[1] is: %p\n", &s[1]);
printf("The direction of s[2] is: %p\n", &s[2]);
return 0;
}
</code></pre>
<p>When compiling it with gcc I get these warnings:</p>
<pre><code>$ gcc main.c -o main-bin -ansi -pedantic -Wall -lm
main.c: In function ‘main’:
main.c:6: warning: initialization from incompatible pointer type
main.c:9: warning: format ‘%p’ expects type ‘void *’, but argument 2 has type ‘char (*)[4]’
main.c:11: warning: format ‘%p’ expects type ‘void *’, but argument 2 has type ‘char **’
main.c:12: warning: format ‘%p’ expects type ‘void *’, but argument 2 has type ‘char ***’
</code></pre>
<p>(The flags for gcc are because I must be C89)</p>
<p>Why incompatible types of pointer? Isn't the name of an array a pointer to it's first element? So if s is a pointer to 'a', <code>&s</code> must be a <code>char **</code>, no?
And why do I get the other warnings? Do I have to cast the pointers with (<code>void *</code>) in order to print them? </p>
<p>And when running I get something like this:</p>
<pre><code>$ ./main-bin
The value of s is: 0xbfb7c860
The direction of s is: 0xbfb7c860
The value of p is: 0xbfb7c860
The direction of p is: 0xbfb7c85c
The direction of s[0] is: 0xbfb7c860
The direction of s[1] is: 0xbfb7c861
The direction of s[2] is: 0xbfb7c862
</code></pre>
<p>How can the value of s and it's direction (and of course the value of <code>p</code>) be the same?</p>
|
[
{
"answer_id": 197768,
"author": "selwyn",
"author_id": 16314,
"author_profile": "https://Stackoverflow.com/users/16314",
"pm_score": 0,
"selected": false,
"text": "char s[] = \"asd\";\n char *s = \"asd\";\n char s[] = \"asd\";\nchar **p = &s;\n"
},
{
"answer_id": 197780,
"author": "indiv",
"author_id": 19719,
"author_profile": "https://Stackoverflow.com/users/19719",
"pm_score": 5,
"selected": false,
"text": "/* for instance... */\nprintf(\"The value of s is: %p\\n\", (void *) s);\nprintf(\"The direction of s is: %p\\n\", (void *) &s);\n"
},
{
"answer_id": 197791,
"author": "Sergey Golovchenko",
"author_id": 26592,
"author_profile": "https://Stackoverflow.com/users/26592",
"pm_score": 1,
"selected": false,
"text": "char s[] = \"asd\";\n char *s = \"asd\";\n"
},
{
"answer_id": 197800,
"author": "Airsource Ltd",
"author_id": 18017,
"author_profile": "https://Stackoverflow.com/users/18017",
"pm_score": 2,
"selected": false,
"text": "void* p; char* s; char** ps;"
},
{
"answer_id": 197801,
"author": "Chris Conway",
"author_id": 1412,
"author_profile": "https://Stackoverflow.com/users/1412",
"pm_score": 1,
"selected": false,
"text": "s == &s"
},
{
"answer_id": 197824,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 6,
"selected": true,
"text": "char s[] = \"asd\";\nchar *p = &s[0]; // alternately you could use the shorthand char*p = s;\nchar **pp = &p;\n"
},
{
"answer_id": 15423321,
"author": "4pie0",
"author_id": 1141471,
"author_profile": "https://Stackoverflow.com/users/1141471",
"pm_score": 2,
"selected": false,
"text": "char* char* [4] char* s = \"asd\";\nchar** p = &s;\n\nprintf(\"The value of s is: %p\\n\", s);\nprintf(\"The address of s is: %p\\n\", &s);\n\nprintf(\"The value of p is: %p\\n\", p);\nprintf(\"The address of p is: %p\\n\", &p);\n\nprintf(\"The address of s[0] is: %p\\n\", &s[0]);\nprintf(\"The address of s[1] is: %p\\n\", &s[1]);\nprintf(\"The address of s[2] is: %p\\n\", &s[2]);\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27267/"
] |
197,758
|
<p>I have a bunch of XML that has lines that look like this</p>
<pre><code><_char font_name="/ITC Stone Serif Std Bold" italic="true" />
</code></pre>
<p>but sometimes look like this</p>
<pre><code><_char font_size="88175" italic="true" font_name="/ITC Stone Serif Std Bold" />
</code></pre>
<p>Here's what I need to do</p>
<ul>
<li>Replace <strong>italic="true"</strong> with <strong>italic="false</strong> for every line that contains <strong>ITC Stone Serif Std Bold</strong>, regardless of whether it comes before OR after the <strong>italic</strong> part.</li>
</ul>
<p>Can this be done with a single regex?</p>
<p>I'm not looking for a real-time solution. I just have a ton of XML files that have this "mistake" in them and I'm trying to do a global search-and-replace with PowerGrep which would require a single regex. If scripting's the only way to do it, then so be it.</p>
|
[
{
"answer_id": 197804,
"author": "zigdon",
"author_id": 4913,
"author_profile": "https://Stackoverflow.com/users/4913",
"pm_score": 1,
"selected": false,
"text": "if (/ITC Stone Serif Std Bold/) {\n s/italic=\"true\"/italic=\"false\"/g;\n}\n"
},
{
"answer_id": 197805,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 3,
"selected": true,
"text": "name=\"/ITC Stone Sans Std Bold\"[^>]italic=\"(true)\"|italic=\"(true)\"[^>]font_name=\"/ITC Stone Serif Std Bold\"\n"
},
{
"answer_id": 197813,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 0,
"selected": false,
"text": "while (<>)\n{\n s/italic=\"true\"/italic=\"false\"/ if m%font_name=\"/ITC Stone Sans Std Bold\" italic=\"true\"|italic=\"true\" font_name=\"/ITC Stone Serif Std Bold\"%;\n print;\n}\n"
},
{
"answer_id": 198103,
"author": "Markus Jarderot",
"author_id": 22364,
"author_profile": "https://Stackoverflow.com/users/22364",
"pm_score": 0,
"selected": false,
"text": "Pattern: /(<_char(?=(?:\\s+\\w+=\"[^\"]*\")*?\\s+font_name=\"[^\"]*?ITC Stone Serif Std Bold[^\"]*\")(?:\\s+\\w+=\"[^\"]*\")*?\\s+italic=\")true(?=\")/\nReplacement: '$1false'\n"
},
{
"answer_id": 207422,
"author": "Brad Gilbert",
"author_id": 1337,
"author_profile": "https://Stackoverflow.com/users/1337",
"pm_score": 0,
"selected": false,
"text": "s(\n <_char \\s* [^>]*? \\K (?: (?&font) \\s+ (?&italic) | (?&italic) \\s+ (?&font) )\n (?(DEFINE)\n (?<font>font_name=\"/ITC[ ]Stone[ ]Serif[ ]Std[ ]Bold\")\n (?<italic>italic=\"true\")\n )\n){\n $+{font} . 'italic=\"false\"'\n}xge\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/305/"
] |
197,759
|
<p>I'm not exactly sure how to ask this question really, and I'm no where close to finding an answer, so I hope someone can help me. </p>
<p>I'm writing a Python app that connects to a remote host and receives back byte data, which I unpack using Python's built-in struct module. My problem is with the strings, as they include multiple character encodings. Here is an example of such a string:</p>
<p>"^LThis is an example ^Gstring with multiple ^Jcharacter encodings"</p>
<p>Where the different encoding starts and ends is marked using special escape chars:</p>
<ul>
<li>^L - Latin1</li>
<li>^E - Central Europe</li>
<li>^T - Turkish</li>
<li>^B - Baltic</li>
<li>^J - Japanese</li>
<li>^C - Cyrillic</li>
<li>^G - Greek</li>
</ul>
<p>And so on... I need a way to convert this sort of string into Unicode, but I'm really not sure how to do it. I've read up on Python's codecs and string.encode/decode, but I'm none the wiser really. I should mention as well, that I have no control over how the strings are outputted by the host.</p>
<p>I hope someone can help me with how to get started on this.</p>
|
[
{
"answer_id": 197846,
"author": "Glyph",
"author_id": 13564,
"author_profile": "https://Stackoverflow.com/users/13564",
"pm_score": 3,
"selected": true,
"text": "latin1 = \"latin-1\"\njapanese = \"Shift-JIS\"\n\ncontrol_l = \"\\x0c\"\ncontrol_j = \"\\n\"\n\nencodingMap = {\n control_l: latin1,\n control_j: japanese}\n\ndef funkyDecode(s, initialCodec=latin1):\n output = u\"\"\n accum = \"\"\n currentCodec = initialCodec\n for ch in s:\n if ch in encodingMap:\n output += accum.decode(currentCodec)\n currentCodec = encodingMap[ch]\n accum = \"\"\n else:\n accum += ch\n output += accum.decode(currentCodec)\n return output\n"
},
{
"answer_id": 197982,
"author": "dF.",
"author_id": 3002,
"author_profile": "https://Stackoverflow.com/users/3002",
"pm_score": 2,
"selected": false,
"text": "import re\n\nencs = {\n 'L': 'latin1',\n 'G': 'iso8859-7',\n ...\n}\n\ndecoded = ''.join(substr[2:].decode(encs[substr[1]])\n for substr in re.findall('\\^[%s][^^]*' % ''.join(encs.keys()), st))\n"
},
{
"answer_id": 197990,
"author": "zellyn",
"author_id": 23582,
"author_profile": "https://Stackoverflow.com/users/23582",
"pm_score": 3,
"selected": false,
"text": "# -*- coding: utf-8 -*-\nimport re\n\n# Test Data\nENCODING_RAW_DATA = (\n ('latin_1', 'L', u'Hello'), # Latin 1\n ('iso8859_2', 'E', u'dobrý večer'), # Central Europe\n ('iso8859_9', 'T', u'İyi akşamlar'), # Turkish\n ('iso8859_13', 'B', u'Į sveikatą!'), # Baltic\n ('shift_jis', 'J', u'今日は'), # Japanese\n ('iso8859_5', 'C', u'Здравствуйте'), # Cyrillic\n ('iso8859_7', 'G', u'Γειά σου'), # Greek\n)\n\nCODE_TO_ENCODING = dict([(chr(ord(code)-64), encoding) for encoding, code, text in ENCODING_RAW_DATA])\nEXPECTED_RESULT = u''.join([line[2] for line in ENCODING_RAW_DATA])\nENCODED_DATA = ''.join([chr(ord(code)-64) + text.encode(encoding) for encoding, code, text in ENCODING_RAW_DATA])\n\nFIND_RE = re.compile('[\\x00-\\x1A][^\\x00-\\x1A]*')\n\ndef decode_single(bytes):\n return bytes[1:].decode(CODE_TO_ENCODING[bytes[0]])\n\nresult = u''.join([decode_single(bytes) for bytes in FIND_RE.findall(ENCODED_DATA)])\n\nassert result==EXPECTED_RESULT, u\"Expected %s, but got %s\" % (EXPECTED_RESULT, result)\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27059/"
] |
197,769
|
<p>I'm writing some JavaScript code to parse user-entered functions (for spreadsheet-like functionality). Having parsed the formula I <em>could</em> convert it into JavaScript and run <code>eval()</code> on it to yield the result.</p>
<p>However, I've always shied away from using <code>eval()</code> if I can avoid it because it's evil (and, rightly or wrongly, I've always thought it is even more evil in JavaScript, because the code to be evaluated might be changed by the user).</p>
<p>So, when it is OK to use it?</p>
|
[
{
"answer_id": 197797,
"author": "John Topley",
"author_id": 1450,
"author_profile": "https://Stackoverflow.com/users/1450",
"pm_score": 0,
"selected": false,
"text": "eval"
},
{
"answer_id": 197798,
"author": "swilliams",
"author_id": 736,
"author_profile": "https://Stackoverflow.com/users/736",
"pm_score": 4,
"selected": false,
"text": "eval() setTimeout() setTimeout(function() {\n alert('hi');\n}, 1000);\n"
},
{
"answer_id": 197823,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 6,
"selected": false,
"text": "eval() eval()"
},
{
"answer_id": 536672,
"author": "yfeldblum",
"author_id": 12349,
"author_profile": "https://Stackoverflow.com/users/12349",
"pm_score": 1,
"selected": false,
"text": "eval obj[\"prop\"] obj.prop"
},
{
"answer_id": 1201623,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "javascript:alert(\"hello\");\n <html>\n <body>\n <textarea id=\"output\"></textarea><br/>\n <input type=\"text\" id=\"input\" />\n <button id=\"button\" onclick=\"execute()\">eval</button>\n\n <script type=\"text/javascript\">\n var execute = function(){\n var inputEl = document.getElementById('input');\n var toEval = inputEl.value;\n var outputEl = document.getElementById('output');\n var output = \"\";\n\n try {\n output = eval(toEval);\n }\n catch(err){\n for(var key in err){\n output += key + \": \" + err[key] + \"\\r\\n\";\n }\n }\n outputEl.value = output;\n }\n </script>\n <body>\n</html>\n"
},
{
"answer_id": 10325344,
"author": "Tomas",
"author_id": 684229,
"author_profile": "https://Stackoverflow.com/users/684229",
"pm_score": -1,
"selected": false,
"text": "google.maps.ImageMapType zoom coord my_func({\n name: \"OSM\",\n tileURLexpr: '\"http://tile.openstreetmap.org/\"+b+\"/\"+a.x+\"/\"+a.y+\".png\"',\n ...\n});\n\nfunction my_func(opts)\n{\n return new google.maps.ImageMapType({\n getTileUrl: function (coord, zoom) {\n var b = zoom;\n var a = coord;\n return eval(opts.tileURLexpr);\n },\n ....\n });\n}\n"
},
{
"answer_id": 16102369,
"author": "Akash Kava",
"author_id": 85597,
"author_profile": "https://Stackoverflow.com/users/85597",
"pm_score": 3,
"selected": false,
"text": "var a = eval(\"3 + 5\");\n var f = eval(\"(function(a,b) { return a + b; })\");\n\nvar a = f(3,5);\n \"FirstName + ' ' + LastName\"\n \"LastName + ' ' + FirstName\"\n"
},
{
"answer_id": 16294053,
"author": "Yaroslav",
"author_id": 1351319,
"author_profile": "https://Stackoverflow.com/users/1351319",
"pm_score": 0,
"selected": false,
"text": "eval var components = require('components');\nvar Button = components.Button;\nvar ComboBox = components.ComboBox;\nvar CheckBox = components.CheckBox;\n...\n// That quickly gets very boring\n eval var components = require('components');\neval(importable('components', 'Button', 'ComboBox', 'CheckBox', ...));\n importable function importable(path) {\n var name;\n var pkg = eval(path);\n var result = '\\n';\n\n for (name in pkg) {\n result += 'if (name !== undefined) throw \"import error: name already exists\";\\n'.replace(/name/g, name);\n }\n\n for (name in pkg) {\n result += 'var name = path.name;\\n'.replace(/name/g, name).replace('path', path);\n }\n return result;\n}\n"
},
{
"answer_id": 17809716,
"author": "Benjamin",
"author_id": 1859442,
"author_profile": "https://Stackoverflow.com/users/1859442",
"pm_score": 3,
"selected": false,
"text": "eval() (function () {\n var eval = function (arg) {\n };\n\n function evalTest() {\n var used = \"used\";\n var unused = \"not used\";\n\n (function () {\n used.toString(); // Variable \"unused\" is visible in debugger\n eval(\"1\");\n })();\n }\n\n evalTest();\n})();\n\n(function () {\n var eval = function (arg) {\n };\n\n function evalTest() {\n var used = \"used\";\n var unused = \"not used\";\n\n (function () {\n used.toString(); // Variable \"unused\" is NOT visible in debugger\n var noval = eval;\n noval(\"1\");\n })();\n }\n\n evalTest();\n})();\n\n(function () {\n var noval = function (arg) {\n };\n\n function evalTest() {\n var used = \"used\";\n var unused = \"not used\";\n\n (function () {\n used.toString(); // Variable \"unused\" is NOT visible in debugger\n noval(\"1\");\n })();\n }\n\n evalTest();\n})();\n eval() eval() var noval = eval; noval(expression); expression"
},
{
"answer_id": 40842651,
"author": "Wikened",
"author_id": 5678694,
"author_profile": "https://Stackoverflow.com/users/5678694",
"pm_score": 0,
"selected": false,
"text": "eval() eval() <div>\n {{#each names}}\n <span>{{this}}</span>\n {{/each}}\n</div>\n (function (state) {\n var Runtime = Hyperbars.Runtime;\n var context = state;\n return h('div', {}, [Runtime.each(context['names'], context, function (context, parent, options) {\n return [h('span', {}, [options['@index'], context])]\n })])\n}.bind({}))\n eval()"
},
{
"answer_id": 48761866,
"author": "MichaelC",
"author_id": 3917517,
"author_profile": "https://Stackoverflow.com/users/3917517",
"pm_score": 2,
"selected": false,
"text": "{\n \"568ff113-abcd-f123-84c5-871fe2007cf0\": {\n \"msg_enum\": \"quest/registration\",\n \"timely\": \"all_times\",\n \"scope\": [\n \"quest/daily-active\"\n ],\n \"query\": \"`SELECT COUNT(point) AS valid from \\\"${userId}/dump/quest/daily-active\\\" LIMIT 1`\",\n \"validator\": \"valid > 0\",\n \"reward_external\": \"ewallet\",\n \"reward_external_payload\": \"`{\\\"token\\\": \\\"${token}\\\", \\\"userId\\\": \\\"${userId}\\\", \\\"amountIn\\\": 1, \\\"conversionType\\\": \\\"quest/registration:silver\\\", \\\"exchangeProvider\\\":\\\"provider/achievement\\\",\\\"exchangeType\\\":\\\"payment/quest/registration\\\"}`\"\n },\n \"efdfb506-1234-abcd-9d4a-7d624c564332\": {\n \"msg_enum\": \"quest/daily-active\",\n \"timely\": \"daily\",\n \"scope\": [\n \"quest/daily-active\"\n ],\n \"query\": \"`SELECT COUNT(point) AS valid from \\\"${userId}/dump/quest/daily-active\\\" WHERE time >= '${today}' ${ENV.DAILY_OFFSET} LIMIT 1`\",\n \"validator\": \"valid > 0\",\n \"reward_external\": \"ewallet\",\n \"reward_external_payload\": \"`{\\\"token\\\": \\\"${token}\\\", \\\"userId\\\": \\\"${userId}\\\", \\\"amountIn\\\": 1, \\\"conversionType\\\": \\\"quest/daily-active:silver\\\", \\\"exchangeProvider\\\":\\\"provider/achievement\\\",\\\"exchangeType\\\":\\\"payment/quest/daily-active\\\"}`\"\n }\n}"
},
{
"answer_id": 57484565,
"author": "Steven Spungin",
"author_id": 5093961,
"author_profile": "https://Stackoverflow.com/users/5093961",
"pm_score": 3,
"selected": false,
"text": "eval eval eval eval"
},
{
"answer_id": 59792697,
"author": "jemiloii",
"author_id": 630496,
"author_profile": "https://Stackoverflow.com/users/630496",
"pm_score": 2,
"selected": false,
"text": "{myParam} const params = { id: 5 };\n\nconst route = '/api/user/{id}';\nroute.replace(/{/g, '${params.');\n\n// use eval(route); to do something\n\n"
},
{
"answer_id": 70807626,
"author": "Peter Moore",
"author_id": 4467670,
"author_profile": "https://Stackoverflow.com/users/4467670",
"pm_score": 1,
"selected": false,
"text": "eval"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12559/"
] |
197,782
|
<p>I am trying to open a report in Crystal Report 11 Designer (product version 11.5.8.826), but it seems to freeze up. This report use to work fine, but today the client could not load the report.</p>
<p>I also tried to open the report on another developer's workstation, with the same result.</p>
<p>Has this happened to anyone else?</p>
|
[
{
"answer_id": 1239880,
"author": "Developer",
"author_id": 81250,
"author_profile": "https://Stackoverflow.com/users/81250",
"pm_score": 0,
"selected": false,
"text": "ReportDocument rpDoc = new ReportDocument()\nrpDoc.Load(Server.MapPath(@\"reportname.rpt\"));\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
197,793
|
<p>I'm building my first flex app and am currently bussy splitting it up in multiple components to make it maintainable.
I have a screen which holds a list that is displayed and filled after a succesfull login attempt:</p>
<p>Part of the main app:</p>
<pre><code><mx:ViewStack id="vsAdmin" height="100%" width="100%">
<mx:TabNavigator id="adminTabs" width="100%" height="100%" historyManagementEnabled="false">
<myComp:compBeheerdersAdmin id="beheerdersViewstackA"/>
</mx:TabNavigator>
</mx:ViewStack>
</code></pre>
<p>In the component compBeheerdersAdmin there is a function requestBeheerdersList() that gets the data from the server and Binds it to the list through a handler.</p>
<p>After login the following code from the main app:</p>
<pre><code>mainViewstack.selectedChild = vsAdmin;
//beheerdersViewstackA.createComponentsFromDescriptors();
beheerdersViewstackA.requestBeheerdersList();
</code></pre>
<p>The function requestBeheerdersList() does nothing (is not reached, i put a alert as first statement in the function but that is not displayed) when i login after a fresh load of the swf, but when i logout and login again, then the function is reached and the alert is displayed and the list is filled with the data from the server.
Any ideas?</p>
|
[
{
"answer_id": 198034,
"author": "Brandon",
"author_id": 23133,
"author_profile": "https://Stackoverflow.com/users/23133",
"pm_score": 1,
"selected": false,
"text": "private function doThisFirst():void{\n mainViewstack.selectedChild = vsAdmin;\n vsAdmin.addEventListener(FlexEvent.CREATION_COMPLETE,doThis);\n}\n\n\nprivate function doThis():void{\n beheerdersViewstackA.requestBeheerdersList();\n}\n"
},
{
"answer_id": 233168,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<mx:Canvas ... creationComplete=\"onCreationComplete()\">\n\n<mx:Script>\n <![CDATA[\n private function onCreationComplete():void {\n requestBeheerdersList()\n }\n ]]>\n</mx:Script>\n <mx:Canvas ... creationComplete=\"requestBeheerdersList()\">\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21238/"
] |
197,802
|
<p>I have an Access DB that I would like to extract the source code from so I can put it into Source control. </p>
<p>I have tried to extract the data using the Primary Interop Assemblies(PIA), but I am getting issues as it is not picking up all of the modules and forms. </p>
<p>There are 140 Forms and Modules in the code(Don't ask, it's a legacy system I have inherited) but the PIA code is only picking up 91 of them. </p>
<p>Here is the code I am using. </p>
<pre><code>using System;
using Microsoft.Office.Interop.Access;
namespace GetAccesSourceFiles
{
class Program
{
static void Main(string[] args)
{
ApplicationClass appClass = new ApplicationClass();
try
{
appClass.OpenCurrentDatabase("C:\\svn\\projects\\db.mdb",false,"");
Console.WriteLine(appClass.Version);
Console.WriteLine(appClass.Modules.Count.ToString());
Console.WriteLine(appClass.Modules.Parent.ToString());
int NumOfLines = 0;
for (int i = 0; i < appClass.Modules.Count; i++)
{
Console.WriteLine(appClass.Modules[i].Name + " : " + appClass.Modules[i].CountOfLines);
NumOfLines += appClass.Modules[i].CountOfLines;
}
Console.WriteLine("Number of Lines : " + NumOfLines);
Console.ReadKey();
}
catch(Exception ex)
{
Console.WriteLine(ex.Message + "\r\n" +ex.StackTrace);
}
finally
{
appClass.CloseCurrentDatabase();
appClass.Quit(AcQuitOption.acQuitSaveNone);
}
}
}
}
</code></pre>
<p>Any suggestions on what that code might be missing? or on a product/tool out there that will do this for me?</p>
<p>Edit:
I should also mention that this needs to script to disk, integration with VSS is not an option as our source system is SVN. Thanks.</p>
|
[
{
"answer_id": 197868,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 1,
"selected": false,
"text": " Sub AllCodeToDesktop()\n 'The reference for the FileSystemObject Object is Windows Script Host Object Model\n 'but it not necessary to add the reference for this procedure.\n\n Dim fs As Object\n Dim f As Object\n Dim strMod As String\n Dim mdl As Object\n Dim i As Integer\n\n Set fs = CreateObject(\"Scripting.FileSystemObject\")\n\n 'Set up the file.\n Set f = fs.CreateTextFile(SpFolder(\"Desktop\") & \"\\\" _\n & Replace(CurrentProject.Name, \".\", \"\") & \".txt\")\n\n 'For each component in the project ...\n For Each mdl In VBE.ActiveVBProject.VBComponents\n 'using the count of lines ...\n i = VBE.ActiveVBProject.VBComponents(mdl.Name).CodeModule.CountOfLines\n 'put the code in a string ...\n If VBE.ActiveVBProject.VBComponents(mdl.Name).codemodule.CountOfLines > 0 Then\n strMod = VBE.ActiveVBProject.VBComponents(mdl.Name).codemodule.Lines(1, i)\n End If\n 'and then write it to a file, first marking the start with\n 'some equal signs and the component name.\n f.writeline String(15, \"=\") & vbCrLf & mdl.Name _\n & vbCrLf & String(15, \"=\") & vbCrLf & strMod\n Next\n\n 'Close eveything\n f.Close\n Set fs = Nothing\n End Sub\n\n Function SpFolder(SpName As String)\n 'Special folders\n SpFolder = CreateObject(\"WScript.Shell\").SpecialFolders(SpName)\n End Function \n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2806/"
] |
197,834
|
<p>In particular from this web.config:</p>
<pre><code><configuration>
<configSections>
<section name="RStrace" type="Microsoft.ReportingServices.Diagnostics.RSTraceSectionHandler,Microsoft.ReportingServices.Diagnostics" />
</configSections>
<system.diagnostics>
<switches>
<add name="DefaultTraceSwitch" value="3" />
</switches>
</system.diagnostics>
<RStrace>
<add name="FileName" value="ReportServerService_" />
<add name="FileSizeLimitMb" value="32" />
<add name="KeepFilesForDays" value="14" />
<add name="Prefix" value="appdomain, tid, time" />
<add name="TraceListeners" value="file" />
<add name="TraceFileMode" value="unique" />
<add name="Components" value="all:3" />
</RStrace>
<runtime>
<alwaysFlowImpersonationPolicy enabled="true"/>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.ReportingServices.Interfaces"
publicKeyToken="89845dcd8080cc91"
culture="neutral" />
<bindingRedirect oldVersion="8.0.242.0"
newVersion="10.0.0.0"/>
<bindingRedirect oldVersion="9.0.242.0"
newVersion="10.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
<gcServer enabled="true" />
</runtime>
</configuration>
</code></pre>
|
[
{
"answer_id": 197906,
"author": "Dean Hill",
"author_id": 3106,
"author_profile": "https://Stackoverflow.com/users/3106",
"pm_score": 1,
"selected": false,
"text": "<section name=\"runtime\" type=\"your-datatype\"/>\n"
},
{
"answer_id": 50462056,
"author": "Mohammed Arabiat",
"author_id": 2542468,
"author_profile": "https://Stackoverflow.com/users/2542468",
"pm_score": 2,
"selected": false,
"text": "machine.config C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\Config machine.config.defaults machine.config machine.config %temp% setupverifier_errors machine.config machine.config"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11604/"
] |
197,835
|
<p>I start a .Net server side program on my local workstation, but soon it throws a security exception. I searched the web for answers, but no quick fix was found / worked. I just want to run my program. How do I get rid of the exception? I fully trust the program, because its mine.</p>
<p>Edit: Oh, yes, I do run the program from a mapped folder that is mapped to my own local drive for the sake of clarity of folder structures. Thanks for the answers, I try tomorrow to run it directly from my drive.</p>
<p>Edit: When I use directly my drive, it works.</p>
|
[
{
"answer_id": 197949,
"author": "Martin",
"author_id": 1529,
"author_profile": "https://Stackoverflow.com/users/1529",
"pm_score": 0,
"selected": false,
"text": "caspol -s off\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16663/"
] |
197,839
|
<p>This question was inspired by a similar question: <a href="https://stackoverflow.com/questions/197675/how-does-delete-know-the-size-of-the-operand-array">How does delete[] “know” the size of the operand array?</a></p>
<p>My question is a little different: <strong>Is there any way to determine the size of a C++ array programmatically? And if not, why?</strong> Every function I've seen that takes an array also requires an integer parameter to give it the size. But as the linked question pointed out, <code>delete[]</code> must know the size of the memory to be deallocated.</p>
<p>Consider this C++ code:</p>
<pre><code>int* arr = new int[256];
printf("Size of arr: %d\n", sizeof(arr));
</code></pre>
<p>This prints "<code>Size of arr: 4</code>", which is just the size of the pointer. It would be nice to have some function which prints 256, but I don't think one exists in C++. (Again, part of the question is why it doesn't exist.)</p>
<p><strong>Clarification</strong>: I know that if I declared the array on the stack instead of the heap (i.e. "<code>int arr[256];</code>") that the <code>sizeof</code> operator would return 1024 (array length * sizeof(int)).</p>
|
[
{
"answer_id": 197857,
"author": "Doug T.",
"author_id": 8123,
"author_profile": "https://Stackoverflow.com/users/8123",
"pm_score": 3,
"selected": false,
"text": "int main()\n{\n std::vector<int> v(256);\n printf(\"size of v is %i capacity is %i\\n\", sizeof(int) * v.size(), sizeof(int) * v.capacity());\n}\n const int arrSize = 256;\nint main()\n{\n int array[arrSize];\n printf(\"Size of array is %i\", sizeof(int) * arrSize);\n}\n"
},
{
"answer_id": 197865,
"author": "Greg Rogers",
"author_id": 5963,
"author_profile": "https://Stackoverflow.com/users/5963",
"pm_score": 1,
"selected": false,
"text": "std::vector"
},
{
"answer_id": 197900,
"author": "Dima",
"author_id": 13313,
"author_profile": "https://Stackoverflow.com/users/13313",
"pm_score": 7,
"selected": true,
"text": "delete [] sizeof() \nint *arr = new int[256];\nint *p = &arr[100];\nprintf(\"Size: %d\\n\", sizeof(p));\n p new new new delete"
},
{
"answer_id": 197901,
"author": "MSalters",
"author_id": 15416,
"author_profile": "https://Stackoverflow.com/users/15416",
"pm_score": 1,
"selected": false,
"text": "void foo(int* arr);\n\nint arr[100] = {0};\n\nfoo(arr+1); // Calls foo with a pointer to 100-1 elements.\n delete [] (1+new int[5]);"
},
{
"answer_id": 197914,
"author": "James Rose",
"author_id": 9703,
"author_profile": "https://Stackoverflow.com/users/9703",
"pm_score": 1,
"selected": false,
"text": "int a[50] sizeof(a) int *p = a sizeof(p)"
},
{
"answer_id": 198018,
"author": "Mykelyk",
"author_id": 27456,
"author_profile": "https://Stackoverflow.com/users/27456",
"pm_score": 2,
"selected": false,
"text": "string* p = new string[5];\ndelete[5] p;\n size_t* p = new size_t[10];\ncout << p[-1] << endl;\n// Or\ncout << p[11] << endl;\n"
},
{
"answer_id": 206381,
"author": "MSN",
"author_id": 6210,
"author_profile": "https://Stackoverflow.com/users/6210",
"pm_score": 0,
"selected": false,
"text": "delete[] operator new[] new[]"
},
{
"answer_id": 419928,
"author": "SMeyers",
"author_id": 28954,
"author_profile": "https://Stackoverflow.com/users/28954",
"pm_score": 0,
"selected": false,
"text": "char *ar = new char[100] \n"
},
{
"answer_id": 12502434,
"author": "MessyCode",
"author_id": 1565515,
"author_profile": "https://Stackoverflow.com/users/1565515",
"pm_score": 0,
"selected": false,
"text": "char* chars=new char[100];\nprintf(\"%d\",*((int*)chars-1));\n delete[] new[] int count;\nObjectType* data; //This value is returned when using new[]\n"
},
{
"answer_id": 17014793,
"author": "Zingam",
"author_id": 1474291,
"author_profile": "https://Stackoverflow.com/users/1474291",
"pm_score": 2,
"selected": false,
"text": "template <typename T, size_t S>\ninline\nsize_t array_size(const T (&v)[S]) \n{ \n return S; \n}\n template<typename T, size_t S>\nconstexpr \nauto array_size(const T (&)[S]) -> size_t\n{ \n return S; \n}\n"
},
{
"answer_id": 20436733,
"author": "Brent Faust",
"author_id": 225240,
"author_profile": "https://Stackoverflow.com/users/225240",
"pm_score": 2,
"selected": false,
"text": "#include <array>\n\nint main (int argc, char** argv)\n{\n std::array<int, 256> arr;\n printf(\"Size of arr: %ld\\n\", arr.size());\n}\n <type, #elements>"
},
{
"answer_id": 27894696,
"author": "user4443767",
"author_id": 4443767,
"author_profile": "https://Stackoverflow.com/users/4443767",
"pm_score": 0,
"selected": false,
"text": "int intarray[100];\nprintf (\"Size of the array %d\\n\", (sizeof(intarray) / sizeof(intarray[0]));\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18511/"
] |
197,845
|
<p>I'm trying to show/hide a movieclip (or graphic) symbol that is on a layer of a button symbol using actionscript 2. Here's what I tried</p>
<p>in the actions for the button:</p>
<pre><code>on (release) {
this.button_name.movieclip_name._alpha = 0;
trace(this.button_name.movieclip_name);
}
</code></pre>
<p>and the trace returns <strong><em>undefined</em></strong>... so I think I've got a problem understanding how to address the child element. However I am not a flash programmer... just hacking on it at the moment for a side project, so I probably just don't understand how it works.</p>
<p>Thanks, Jim :)</p>
|
[
{
"answer_id": 199979,
"author": "fenomas",
"author_id": 10651,
"author_profile": "https://Stackoverflow.com/users/10651",
"pm_score": 2,
"selected": true,
"text": "myMC.onRollOver = function() { gotoAndPlay(\"show\"); }\nmyMC.onRollOut = myMC.onReleaseOutside = function() { gotoAndPlay(\"hide\"); }\nmyMC.onRelease = function() {\n // do something....\n}\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2908/"
] |
197,855
|
<p>I have 2 columns in a Grid. When I click a button, I want the first column to animate to the left from it's current position to 0. So, in effect, it collapses and I'm left with just viewing a single column.</p>
|
[
{
"answer_id": 197935,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "<Page xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\n WindowTitle=\"Opacity Animation Example\" \n Background=\"White\">\n <StackPanel Margin=\"20\">\n <Grid Name=\"MyGrid\" Width=\"200\" HorizontalAlignment=\"Left\">\n <Grid.RowDefinitions>\n <RowDefinition Height=\"100\"/>\n </Grid.RowDefinitions>\n <Grid.ColumnDefinitions>\n <ColumnDefinition Width=\"*\"/>\n <ColumnDefinition Width=\"100\"/>\n </Grid.ColumnDefinitions>\n <Rectangle HorizontalAlignment=\"Stretch\" \n VerticalAlignment=\"Stretch\" \n Grid.Column=\"0\" Fill=\"Red\"/>\n <Rectangle HorizontalAlignment=\"Stretch\" \n VerticalAlignment=\"Stretch\" \n Grid.Column=\"1\" Fill=\"Blue\"/>\n </Grid>\n\n <Button Name=\"hideButton\">\n <Button.Triggers>\n <EventTrigger RoutedEvent=\"Button.Click\">\n <BeginStoryboard>\n <Storyboard>\n <DoubleAnimation \n Storyboard.TargetName=\"MyGrid\"\n Storyboard.TargetProperty=\"(Grid.Width)\" \n From=\"200\" To=\"100\" \n Duration=\"0:0:2\" \n AutoReverse=\"True\" /> \n </Storyboard>\n </BeginStoryboard>\n </EventTrigger>\n </Button.Triggers>\n </Button>\n </StackPanel>\n</Page>\n"
},
{
"answer_id": 12629636,
"author": "Aaron Hoffman",
"author_id": 47226,
"author_profile": "https://Stackoverflow.com/users/47226",
"pm_score": 3,
"selected": false,
"text": "public class GridLengthAnimation : AnimationTimeline\n{\n public GridLengthAnimation()\n {\n // no-op\n }\n\n public GridLength From\n {\n get { return (GridLength)GetValue(FromProperty); }\n set { SetValue(FromProperty, value); }\n }\n\n public static readonly DependencyProperty FromProperty =\n DependencyProperty.Register(\"From\", typeof(GridLength), typeof(GridLengthAnimation));\n\n public GridLength To\n {\n get { return (GridLength)GetValue(ToProperty); }\n set { SetValue(ToProperty, value); }\n }\n\n public static readonly DependencyProperty ToProperty =\n DependencyProperty.Register(\"To\", typeof(GridLength), typeof(GridLengthAnimation));\n\n public override Type TargetPropertyType\n {\n get { return typeof(GridLength); }\n }\n\n protected override Freezable CreateInstanceCore()\n {\n return new GridLengthAnimation();\n }\n\n public override object GetCurrentValue(object defaultOriginValue, object defaultDestinationValue, AnimationClock animationClock)\n {\n double fromValue = this.From.Value;\n double toValue = this.To.Value;\n\n if (fromValue > toValue)\n {\n return new GridLength((1 - animationClock.CurrentProgress.Value) * (fromValue - toValue) + toValue, this.To.IsStar ? GridUnitType.Star : GridUnitType.Pixel);\n }\n else\n {\n return new GridLength((animationClock.CurrentProgress.Value) * (toValue - fromValue) + fromValue, this.To.IsStar ? GridUnitType.Star : GridUnitType.Pixel);\n }\n }\n}\n <Window.Resources>\n <Storyboard x:Key=\"ColumnAnimation\">\n <Animations:GridLengthAnimation\n BeginTime=\"0:0:0\"\n Duration=\"0:0:0.1\"\n From=\"0*\"\n Storyboard.TargetName=\"ColumnToAnimate\"\n Storyboard.TargetProperty=\"Width\"\n To=\"10*\" />\n </Storyboard>\n\n</Window.Resources>\n\n<Grid>\n <Grid.ColumnDefinitions>\n <ColumnDefinition Width=\"10*\" />\n <ColumnDefinition Width=\"Auto\" />\n <ColumnDefinition x:Name=\"ColumnToAnimate\" Width=\"0*\" />\n </Grid.ColumnDefinitions>\n</Grid>\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3047/"
] |
197,864
|
<p>OK, so instead of writing a whole bunch of access control specs, and duplicating them across many of my spec files, I'm looking to create a custom matcher. So instead of this:</p>
<pre><code>describe "access control" do
it "should prevent access by non-logged-in users"
it "should prevent access by normal users"
it "should prevent access by editor users"
it "should prevent access by admin users"
it "should allow access by super admin users"
end
</code></pre>
<p>I want do something like this:</p>
<pre><code>lambda do
get :index
end.should have_access_control(:allowed => [:super_admin], :disallowed => [:admin, :editor, :user])
</code></pre>
<p>Are there any examples or suggestions of how I can go about doing something like this?</p>
|
[
{
"answer_id": 200595,
"author": "Codebeef",
"author_id": 12037,
"author_profile": "https://Stackoverflow.com/users/12037",
"pm_score": 3,
"selected": true,
"text": "def access_control (code, options={})\n options = {:allow => [], :disallow => []}.merge(options)\n\n options[:allow].each do |user|\n it \"#{code} should allow #{user.to_s}\" do\n login_as(user)\n eval code\n response.should_not redirect_to(login_path)\n end\n end\n\n options[:disallow].each do |user|\n it \"#{code} should disallow #{user.to_s}\" do\n login_as(user)\n eval code\n response.should redirect_to(login_path)\n end\n end\nend\n access_control(\"get :index\", {:allow => [:super_admin], :disallow => [:quentin, :admin]})\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12037/"
] |
197,867
|
<p>I'm running into a mental roadblock here and I'm hoping that I'm missing something obvious.</p>
<p>Anyway, assume I have a table that looks like this:</p>
<pre>
ID LookupValue SortOrder
============================================
1 A 1000
2 B 2000
3 B 2000
4 C 3000
5 C 4000
</pre>
<p>I'm trying to find, using Linq, places where the <code>LookupValue</code> is the same, but the sort order is different (the <code>ID</code> is a PK on my Database table and is irrelevant to this exercise).</p>
<p>I thought the easiest way would be to group by the <code>LookupValue</code> and the <code>SortOrder</code> and then find places where the <code>LookupValue</code> appears more than twice in the result.</p>
<p>Right now, my code to get the grouped table looks like this:</p>
<pre><code>Dim KeySortPairs = From d In MyDataTable _
Group By Key = d(LookupValue).ToString(), SortOrder = d(SortOrder).ToString() _
Into Group _
Select Key, SortOrder
</code></pre>
<p>Looking in the debug output, the above code produces this result (which is correct):</p>
<pre>
Key SortOrder
================
A 1000
B 2000
C 3000
C 4000
</pre>
<p>To get the duplicate <code>Key</code>'s then, I'm looking through the results like this:</p>
<pre><code>For Each Entry In KeySortPairs.Where(Function(t) t.Key.Count() > 1)
'Multiple Sort Orders!!'
Next
</code></pre>
<p>In this code, however, <em>every</em> entry in the grouped result gets returned. Am I missing something, or shouldn't that count only give me the entries where the <code>Key</code> appears more than once? I assume I'm making a trivial mistake due to my low-level of comfort with VB.NET, but I can't figure it out -- I've tried moving the <code>Count()</code> into a <code>WHERE</code> clause on the Linq expression, but that gave me the same thing.</p>
|
[
{
"answer_id": 197930,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 3,
"selected": true,
"text": "Select Key, SortOrder, Group\n KeySortPairs.Where(Function(t) t.Group.Count() > 1)\n KeySortPairs.Where(Function(t) t.Group.Skip(1).Any())\n"
},
{
"answer_id": 197932,
"author": "brien",
"author_id": 4219,
"author_profile": "https://Stackoverflow.com/users/4219",
"pm_score": 0,
"selected": false,
"text": "For Each Entry in KeySortPairs.GroupBy(expression).Where(\n"
},
{
"answer_id": 31189170,
"author": "gmail user",
"author_id": 344394,
"author_profile": "https://Stackoverflow.com/users/344394",
"pm_score": 0,
"selected": false,
"text": " Dim tests As New List(Of test)() From { _\n New test() With { _\n Key.LookUp = \"A\", _\n Key.SortOrder1 = 1000 _\n }, _\n New test() With { _\n Key.LookUp = \"B\", _\n Key.SortOrder1 = 2000 _\n }, _\n New test() With { _\n Key.LookUp = \"B\", _\n Key.SortOrder1 = 2000 _\n }, _\n New test() With { _\n Key.LookUp = \"C\", _\n Key.SortOrder1 = 3000 _\n }, _\n New test() With { _\n Key.LookUp = \"C\", _\n Key.SortOrder1 = 4000 _\n } _\n }\n\n Dim query = From g In From t In testsGroup t By t.LookUpLet firstsortorder = g.First() Where g.Count() > 1 AndAlso g.Any(Function(t1) firstsortorder.SortOrder1 <> t1.SortOrder1)New With { _\n g.Key, _\n Key .result = g _\n}\n\n For Each item As var In query\n Console.WriteLine(\"key \" + item.Key)\n For Each item1 As var In item.result\n Console.WriteLine(vbTab & vbTab & \"sort order \" + item1.SortOrder1)\n Next\n Next\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1108/"
] |
197,876
|
<p>How do I uninstall a .NET Windows Service if the service files do not exist anymore?</p>
<p>I installed a .NET Windows Service using InstallUtil. I have since deleted the files but forgot to run</p>
<pre><code> InstallUtil /u
</code></pre>
<p>first, so the service is still listed in the Services MMC.</p>
<p>Do I have to go into the registry? Or is there a better way?</p>
|
[
{
"answer_id": 197885,
"author": "Dean Hill",
"author_id": 3106,
"author_profile": "https://Stackoverflow.com/users/3106",
"pm_score": 7,
"selected": false,
"text": "sc delete <service-name>\n sc delete \"<service-name>\"\n"
},
{
"answer_id": 197941,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 11,
"selected": true,
"text": "sc delete <service-name>\n DESCRIPTION:\n SC is a command line program used for communicating with the\n NT Service Controller and services.\n\ndelete----------Deletes a service (from the registry).\n HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\n"
},
{
"answer_id": 18962814,
"author": "Robin French",
"author_id": 2312370,
"author_profile": "https://Stackoverflow.com/users/2312370",
"pm_score": 5,
"selected": false,
"text": "sc delete <service-name> sc query type= service sc delete <service-name> >> C:\\test.txt SERVICE_NAME sc delete <service-name>"
},
{
"answer_id": 24238952,
"author": "user1208639",
"author_id": 1208639,
"author_profile": "https://Stackoverflow.com/users/1208639",
"pm_score": 3,
"selected": false,
"text": "Start a command prompt window using run as administrator\n\nsc query type= service >t.txt\n sc delete Tomcat7\n"
},
{
"answer_id": 27856090,
"author": "Amarjit Singh Chaudhary",
"author_id": 3891385,
"author_profile": "https://Stackoverflow.com/users/3891385",
"pm_score": 0,
"selected": false,
"text": "cd\\ \n\ncd C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319(or version in which you developed your service) \n\ninstallutil c:\\\\xxx.exe(physical path of your service) -d\n"
},
{
"answer_id": 41048256,
"author": "barclay",
"author_id": 187423,
"author_profile": "https://Stackoverflow.com/users/187423",
"pm_score": 0,
"selected": false,
"text": "sc_delete regedit"
},
{
"answer_id": 49002662,
"author": "Ayse Özbek",
"author_id": 9417045,
"author_profile": "https://Stackoverflow.com/users/9417045",
"pm_score": 0,
"selected": false,
"text": "-Windows+r -sc YourSeviceName -Uninstal \"YourService Path\""
},
{
"answer_id": 70626100,
"author": "Ioannis Batsios",
"author_id": 12839230,
"author_profile": "https://Stackoverflow.com/users/12839230",
"pm_score": 1,
"selected": false,
"text": "sc query type= service sc query state= all sc query state= inactive sc query state= inactive > C:\\servicesStopped.txt"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8547/"
] |
197,893
|
<p>A curious thing happens in Java when you use an abstract class to implement an interface: some of the interface's methods can be completely missing (i.e. neither an abstract declaration or an actual implementation is present), but the compiler does not complain.</p>
<p>For example, given the interface:</p>
<pre><code>public interface IAnything {
void m1();
void m2();
void m3();
}
</code></pre>
<p>the following abstract class gets merrily compiled without a warning or an error:</p>
<pre><code>public abstract class AbstractThing implements IAnything {
public void m1() {}
public void m3() {}
}
</code></pre>
<p>Can you explain why?</p>
|
[
{
"answer_id": 197902,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 7,
"selected": false,
"text": "AbstractThing m2"
},
{
"answer_id": 29528866,
"author": "Grateful",
"author_id": 3534132,
"author_profile": "https://Stackoverflow.com/users/3534132",
"pm_score": 3,
"selected": false,
"text": "//Filename: Sports.java\npublic interface Sports\n{\n public void setHomeTeam(String name);\n public void setVisitingTeam(String name);\n}\n\n//Filename: Football.java\npublic interface Football extends Sports\n{\n public void homeTeamScored(int points);\n public void visitingTeamScored(int points);\n public void endOfQuarter(int quarter);\n}\n"
},
{
"answer_id": 40320804,
"author": "James Grey",
"author_id": 3728901,
"author_profile": "https://Stackoverflow.com/users/3728901",
"pm_score": 2,
"selected": false,
"text": "abstract class X implements Y { \n // implements all but one method of Y\n}\n class XX extends X { \n // implements the remaining method in Y \n} \n"
},
{
"answer_id": 45646320,
"author": "sharhp",
"author_id": 1500831,
"author_profile": "https://Stackoverflow.com/users/1500831",
"pm_score": 3,
"selected": false,
"text": "public interface IAnything {\n int i;\n void m1();\n void m2();\n void m3();\n}\n public interface IAnything {\n public static final int i;\n public abstract void m1();\n public abstract void m2();\n public abstract void m3();\n}\n abstract abstract abstract implement interface interface class class abstract abstract class implement interface class abstract"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22904/"
] |
197,904
|
<p>I'm in a Microsoft IE environment, but I want to use cygwin for a number of quick scripting tasks.</p>
<p>How would I configure it to use my windows proxy information? Ruby gems, ping, etc are all trying to make direct connections. How can I get them to respect the proxy information that IE and firefox use?</p>
|
[
{
"answer_id": 197934,
"author": "Steve Moyer",
"author_id": 17008,
"author_profile": "https://Stackoverflow.com/users/17008",
"pm_score": 3,
"selected": false,
"text": "export http_proxy=http://www.myproxy.com:3128\n"
},
{
"answer_id": 197947,
"author": "Bruno De Fraine",
"author_id": 6918,
"author_profile": "https://Stackoverflow.com/users/6918",
"pm_score": 5,
"selected": false,
"text": "gem .bashrc proxy=http://host.com:port/\nexport http_proxy=$proxy\nexport HTTP_PROXY=$proxy\n"
},
{
"answer_id": 5807110,
"author": "Vlax",
"author_id": 164374,
"author_profile": "https://Stackoverflow.com/users/164374",
"pm_score": 7,
"selected": true,
"text": "export http_proxy=http://username:password@host:port/\n"
},
{
"answer_id": 35634635,
"author": "ian0411",
"author_id": 4388883,
"author_profile": "https://Stackoverflow.com/users/4388883",
"pm_score": 3,
"selected": false,
"text": "export http_proxy=http://yourusername:yourpassword@host:port/ export http_proxy=http://yourusername:yourpassword@host:port/\nexport https_proxy=$http_proxy\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13774/"
] |
197,929
|
<p>What do you think of this kind of code-to-files-mapping?</p>
<pre><code>~/proj/MyClass.ext
~/proj/MyClass:constructors.ext
~/proj/MyClass:properties.ext
~/proj/MyClass:method-one.ext
~/proj/MyClass:method-two:int.ext
~/proj/MyClass:method-two:string.ext
</code></pre>
<p>In a language which is more functional-oriented:</p>
<pre><code>~/proj/definitions.ext
~/proj/function-one.ext
~/proj/function-two:int.ext
~/proj/function-two:string.ext
...
</code></pre>
<p>The point would be that when we are working on our project, we don't <em>see</em> this multiplicity of files.</p>
<p>We might either have some kind of daemon process that keeps a mirror <code>MyClass.ext</code> file perfectly in sync with this bunch of files, or our favorite code editor sees them all but shows them as their logical aggregation, or this kind of conversion only happens as a set of pre+post-commit hooks.</p>
<p>Now, since we wouldn't be interested in this idea's implementation if it's not a good idea, let's not bother ourselves with its implementation details (the how); let's suppose we've got the perfect implementation that would make this idea to <em>work well</em> for us.</p>
<p><strong>What I would like for us to find together is a good list of pros & cons to this <em>approach</em>, both at a high level and at more specific low levels of your concern.</strong></p>
<p>When we'll be done brainstorming this and seeing each answer's votes, we should see easily if this is a good idea or not. <strong>Therefore, please write one pro/con per answer.</strong></p>
<p><strong>EDIT</strong></p>
<p>From all the answers and especially Scott's, I derived that <strong>the only real way my idea might be useful, would be to be able to bring automatic listing of changed <code>class:method</code> couples in the detailed part of each commit-to-vcs message.</strong> This could much more easily be achieved by small scripts run before commits, to update the message template accordingly. </p>
|
[
{
"answer_id": 198824,
"author": "Jimmy",
"author_id": 4435,
"author_profile": "https://Stackoverflow.com/users/4435",
"pm_score": 2,
"selected": false,
"text": "#region"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197929",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25167/"
] |
197,933
|
<p>Ideally, something cross-platform.</p>
|
[
{
"answer_id": 197953,
"author": "zigdon",
"author_id": 4913,
"author_profile": "https://Stackoverflow.com/users/4913",
"pm_score": 5,
"selected": true,
"text": "require Term::Screen::Uni;\nmy $scr = new Term::Screen::Uni;\n\n$scr->clrscr()\n"
},
{
"answer_id": 197956,
"author": "Sec",
"author_id": 20555,
"author_profile": "https://Stackoverflow.com/users/20555",
"pm_score": 3,
"selected": false,
"text": "perl -MCurses -e '$win=new Curses;$win->clear()'\n"
},
{
"answer_id": 197984,
"author": "tsee",
"author_id": 13164,
"author_profile": "https://Stackoverflow.com/users/13164",
"pm_score": 4,
"selected": false,
"text": "use Term::ANSIScreen qw(cls);\ncls();\n"
},
{
"answer_id": 251441,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": false,
"text": "print \"\\033[2J\"; #clear the screen\nprint \"\\033[0;0H\"; #jump to 0,0\n"
},
{
"answer_id": 2020830,
"author": "brian d foy",
"author_id": 2766176,
"author_profile": "https://Stackoverflow.com/users/2766176",
"pm_score": 3,
"selected": false,
"text": "use Term::ANSIScreen qw(cls);\nmy $clear_screen = cls();\n\nprint $clear_screen;\n use Term::Cap;\n\n$terminal = Term::Cap->Tgetent( { OSPEED => 9600 } );\n$clear_string = $terminal->Tputs('cl');\n\nprint $clear_screen;\n use Win32::Console;\n\n$OUT = Win32::Console->new(STD_OUTPUT_HANDLE);\n$OUT->Cls;\n $clear_string = `clear`;\n\nprint $clear_string;\n"
},
{
"answer_id": 11715174,
"author": "Sebastian M",
"author_id": 1561859,
"author_profile": "https://Stackoverflow.com/users/1561859",
"pm_score": 3,
"selected": false,
"text": "system(\"clear\");\n system(\"cls\");\n"
},
{
"answer_id": 66672998,
"author": "haxa",
"author_id": 15414604,
"author_profile": "https://Stackoverflow.com/users/15414604",
"pm_score": 1,
"selected": false,
"text": "#!/usr/bin/perl -w\nuse strict;\n\nmy\n( $over, $cleaning );\n( $cleaning ) = qq([J\\033[H\\033[J);\n( $over ) = <<EOF;\n 1. Connecting additional modules = Increase the attack surface.\n 2. Reduce the Amount of Running Code.\n 3. Code refactoring.\nEOF\n\nprint ($cleaning.$over);\n\n__END__\n"
},
{
"answer_id": 67618579,
"author": "Sean Lin",
"author_id": 7624776,
"author_profile": "https://Stackoverflow.com/users/7624776",
"pm_score": 2,
"selected": false,
"text": "system($^O eq 'MSWin32'?'cls':'clear');\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197933",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7598/"
] |
197,940
|
<p>I can't seem to find an easy to use, .net native way to get Comboboxes on .net winforms to display one value and return another based on the selection without creating my own helper class, with the knowledge that winforms is going to display the ToString method on the object that you put in it.</p>
<p>This is how I'm doing it now, very generically. First, create the helper class.</p>
<pre><code> Public Class ListItem
Public Value As Object
Public DisplayString As String
Public Sub New(ByVal NewValue As Object, ByVal NewDisplayString As String)
Value = NewValue
DisplayString = NewDisplayString
End Sub
Public Overrides Function ToString() As String
Return DisplayString
End Function
End Class
</code></pre>
<p>then, to load the combobox from a collection or whatever.</p>
<pre><code> For Each o as WhateverObject In CollectionIwantToaddItemsFrom
li = New ListItem(o.ValueToReturn, o.ValueToDisplay)
Me.ComboBox1.Items.Add(li)
Next
</code></pre>
<p>and finally, to use the object</p>
<pre><code>Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles ComboBox1.SelectedIndexChanged
if me.combobox1.selecteditem is nothing then exit sub
Dim li As ListItem = me.ComboBox1.SelectedItem
Dim o as object = li.value
'do stuff with o.
end sub
</code></pre>
<p>I'm sure there is something I'm better to use in the framework that I'm over looking. What is it?</p>
|
[
{
"answer_id": 198014,
"author": "Sam Meldrum",
"author_id": 16005,
"author_profile": "https://Stackoverflow.com/users/16005",
"pm_score": 4,
"selected": true,
"text": " var list = new List<System.Collections.DictionaryEntry>();\n list.Add(new System.Collections.DictionaryEntry(\"one\", 1));\n list.Add(new System.Collections.DictionaryEntry(\"two\", 2));\n list.Add(new System.Collections.DictionaryEntry(\"three\", 3));\n\n comboBox1.DataSource = list;\n comboBox1.DisplayMember = \"Key\";\n comboBox1.ValueMember = \"Value\";\n Dim list As List(Of DictionaryEntry)\n\nlist = New List(Of DictionaryEntry)\nlist.Add(New DictionaryEntry(\"One\", 1))\nlist.Add(New DictionaryEntry(\"Two\", 2))\nlist.Add(New DictionaryEntry(\"Three\", 3))\n\nComboBox1.DataSource = list\nComboBox1.DisplayMember = \"Key\"\nComboBox1.ValueMember = \"Value\"\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15769/"
] |
197,948
|
<p>I'm using GDI+ in a C++/MFC application and I just can't seem to avoid flickering whenever the window is resized.</p>
<p>I have already tried these steps:</p>
<ul>
<li>returned TRUE on <code>OnEraseBkGnd()</code>;</li>
<li>returned NULL on <code>OnCtlColor()</code>;</li>
<li>used double buffering according to this code:</li>
</ul>
<p></p>
<pre><code>void vwView::OnDraw(CDC* pDC)
{
CRect rcClient;
GetClientRect(rcClient);
Bitmap bmp(rcClient.Width(), rcClient.Height());
Graphics graphics(&bmp);
graphics.DrawImage(m_image, rcClient.left, rcClient.top);
Graphics grph(pDC->m_hDC);
grph.DrawImage(&bmp, 0, 0);
}
</code></pre>
<p>Am I doing something wrong? Or is there another way to achieve this?</p>
|
[
{
"answer_id": 199526,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 6,
"selected": true,
"text": "Graphics::DrawImage() BitBlt() Bitmap CreateCompatibleBitmap()"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4880/"
] |
197,951
|
<p>I have a need to work with Windows executables which are made for x86, x64, and IA64. I'd like to programmatically figure out the platform by examining the files themselves.</p>
<p>My target language is PowerShell but a C# example will do. Failing either of those, if you know the logic required that would be great.</p>
|
[
{
"answer_id": 198005,
"author": "ICR",
"author_id": 214,
"author_profile": "https://Stackoverflow.com/users/214",
"pm_score": 3,
"selected": false,
"text": "Assembly assembly = Assembly.LoadFile(Path.GetFullPath(\"ConsoleApplication1.exe\"));\nModule manifestModule = assembly.ManifestModule;\nPortableExecutableKinds peKind;\nImageFileMachine machine;\nmanifestModule.GetPEKind(out peKind, out machine);\n"
},
{
"answer_id": 885481,
"author": "Andrew",
"author_id": 15127,
"author_profile": "https://Stackoverflow.com/users/15127",
"pm_score": 6,
"selected": true,
"text": "public enum MachineType {\n Native = 0, I386 = 0x014c, Itanium = 0x0200, x64 = 0x8664\n}\n\npublic static MachineType GetMachineType(string fileName)\n{\n const int PE_POINTER_OFFSET = 60; \n const int MACHINE_OFFSET = 4;\n byte[] data = new byte[4096];\n using (Stream s = new FileStream(fileName, FileMode.Open, FileAccess.Read)) {\n s.Read(data, 0, 4096);\n }\n // dos header is 64 bytes, last element, long (4 bytes) is the address of the PE header\n int PE_HEADER_ADDR = BitConverter.ToInt32(data, PE_POINTER_OFFSET);\n int machineUint = BitConverter.ToUInt16(data, PE_HEADER_ADDR + MACHINE_OFFSET);\n return (MachineType)machineUint;\n}\n"
},
{
"answer_id": 4719567,
"author": "Keith Hill",
"author_id": 153982,
"author_profile": "https://Stackoverflow.com/users/153982",
"pm_score": 5,
"selected": false,
"text": "dumpbin.exe Get-PEHeader machine (x86) machine (x64) PE32 PE32+"
},
{
"answer_id": 38806690,
"author": "Kraang Prime",
"author_id": 3504007,
"author_profile": "https://Stackoverflow.com/users/3504007",
"pm_score": 0,
"selected": false,
"text": "// the enum of known pe file types\npublic enum FilePEType : ushort\n{\n IMAGE_FILE_MACHINE_UNKNOWN = 0x0,\n IMAGE_FILE_MACHINE_AM33 = 0x1d3,\n IMAGE_FILE_MACHINE_AMD64 = 0x8664,\n IMAGE_FILE_MACHINE_ARM = 0x1c0,\n IMAGE_FILE_MACHINE_EBC = 0xebc,\n IMAGE_FILE_MACHINE_I386 = 0x14c,\n IMAGE_FILE_MACHINE_IA64 = 0x200,\n IMAGE_FILE_MACHINE_M32R = 0x9041,\n IMAGE_FILE_MACHINE_MIPS16 = 0x266,\n IMAGE_FILE_MACHINE_MIPSFPU = 0x366,\n IMAGE_FILE_MACHINE_MIPSFPU16 = 0x466,\n IMAGE_FILE_MACHINE_POWERPC = 0x1f0,\n IMAGE_FILE_MACHINE_POWERPCFP = 0x1f1,\n IMAGE_FILE_MACHINE_R4000 = 0x166,\n IMAGE_FILE_MACHINE_SH3 = 0x1a2,\n IMAGE_FILE_MACHINE_SH3DSP = 0x1a3,\n IMAGE_FILE_MACHINE_SH4 = 0x1a6,\n IMAGE_FILE_MACHINE_SH5 = 0x1a8,\n IMAGE_FILE_MACHINE_THUMB = 0x1c2,\n IMAGE_FILE_MACHINE_WCEMIPSV2 = 0x169,\n}\n\n// pass the path to the file and check the return\npublic static FilePEType GetFilePE(string path)\n{\n FilePEType pe = new FilePEType();\n pe = FilePEType.IMAGE_FILE_MACHINE_UNKNOWN;\n if(File.Exists(path))\n {\n using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))\n {\n byte[] data = new byte[4096];\n fs.Read(data, 0, 4096);\n ushort result = BitConverter.ToUInt16(data, BitConverter.ToInt32(data, 60) + 4);\n try\n {\n pe = (FilePEType)result;\n } catch (Exception)\n {\n pe = FilePEType.IMAGE_FILE_MACHINE_UNKNOWN;\n }\n }\n }\n return pe;\n}\n string myfile = @\"c:\\windows\\explorer.exe\"; // the file\nFilePEType pe = GetFilePE( myfile );\n\nSystem.Diagnostics.WriteLine( pe.ToString() );\n"
},
{
"answer_id": 49110144,
"author": "default",
"author_id": 1069238,
"author_profile": "https://Stackoverflow.com/users/1069238",
"pm_score": 3,
"selected": false,
"text": "PE L d"
},
{
"answer_id": 50471830,
"author": "Jiminion",
"author_id": 2587816,
"author_profile": "https://Stackoverflow.com/users/2587816",
"pm_score": 1,
"selected": false,
"text": "// Determines if DLL is 32-bit or 64-bit.\n#include <stdio.h>\n\nint sGetDllType(const char *dll_name);\n\nint main()\n{\n int ret;\n const char *fname = \"sample_32.dll\";\n //const char *fname = \"sample_64.dll\";\n ret = sGetDllType(fname);\n}\n\nstatic int sGetDllType(const char *dll_name) {\n const int PE_POINTER_OFFSET = 60;\n const int MACHINE_TYPE_OFFSET = 4;\n FILE *fp;\n unsigned int ret = 0;\n int peoffset;\n unsigned short machine;\n\n fp = fopen(dll_name, \"rb\");\n unsigned char data[4096];\n ret = fread(data, sizeof(char), 4096, fp);\n fclose(fp);\n if (ret == 0)\n return -1;\n\n if ( (data[0] == 'M') && (data[1] == 'Z') ) {\n // Initial magic header is good\n peoffset = data[PE_POINTER_OFFSET + 3];\n peoffset = (peoffset << 8) + data[PE_POINTER_OFFSET + 2];\n peoffset = (peoffset << 8) + data[PE_POINTER_OFFSET + 1];\n peoffset = (peoffset << 8) + data[PE_POINTER_OFFSET];\n\n // Check second header\n if ((data[peoffset] == 'P') && (data[peoffset + 1] == 'E')) {\n machine = data[peoffset + MACHINE_TYPE_OFFSET];\n machine = (machine)+(data[peoffset + MACHINE_TYPE_OFFSET + 1] << 8);\n\n if (machine == 0x014c)\n return 32;\n if (machine == 0x8664)\n return 64;\n\n return -1;\n }\n return -1;\n }\n else\n return -1;\n}\n"
},
{
"answer_id": 51278133,
"author": "Saad Saadi",
"author_id": 1111249,
"author_profile": "https://Stackoverflow.com/users/1111249",
"pm_score": 2,
"selected": false,
"text": "dumpbin.exe bin .lib .dll dumpbin.exe /headers *.dll |findstr machine\n dumpbin.exe /headers *.lib |findstr machine\n"
},
{
"answer_id": 66548864,
"author": "John Matthews",
"author_id": 8771014,
"author_profile": "https://Stackoverflow.com/users/8771014",
"pm_score": 1,
"selected": false,
"text": "#include \"stdafx.h\"\n\nint _tmain(int argc, TCHAR* argv[], TCHAR* envp[])\n{\n int nRetCode = 0;\n int nrd;\n\n IMAGE_DOS_HEADER idh;\n IMAGE_NT_HEADERS inth;\n IMAGE_FILE_HEADER ifh;\n\n // initialize MFC and print and error on failure\n if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))\n {\n _tprintf(_T(\"Fatal Error: MFC initialization failed\\n\"));\n nRetCode = 1;\n return 1;\n }\n if (argc != 2) {\n _ftprintf(stderr, _T(\"Usage: %s filename\\n\"), argv[0]);\n return 1;\n }\n // Try to open the file\n CFile ckf;\n CFileException ex;\n DWORD flags = CFile::modeRead | CFile::shareDenyNone;\n\n if (!ckf.Open(argv[1], flags, &ex)) {\n TCHAR szError[1024];\n ex.GetErrorMessage(szError, 1024);\n _tprintf_s(_T(\"Couldn't open file: %1024s\"), szError);\n return 2;\n }\n\n // The following is adapted from:\n // https://stackoverflow.com/questions/495244/how-can-i-test-a-windows-dll-file-to-determine-if-it-is-32-bit-or-64-bit\n // https://stackoverflow.com/questions/46024914/how-to-parse-exe-file-and-get-data-from-image-dos-header-structure-using-c-and\n // Seek to beginning of file\n ckf.Seek(0, CFile::begin);\n\n // Read DOS header\n int nbytes = sizeof(IMAGE_DOS_HEADER);\n nrd = ckf.Read(&idh, nbytes);\n\n // The idh.e_lfanew member is the offset to the NT_HEADERS structure\n ckf.Seek(idh.e_lfanew, CFile::begin);\n\n // Read NT headers\n nbytes = sizeof(IMAGE_NT_HEADERS);\n nrd = ckf.Read(&inth, nbytes);\n\n ifh = inth.FileHeader;\n\n _ftprintf(stdout, _T(\"File machine type: \"));\n switch (ifh.Machine) {\n case IMAGE_FILE_MACHINE_I386:\n _ftprintf(stdout, _T(\"I386\\n\"));\n break;\n case IMAGE_FILE_MACHINE_IA64:\n _ftprintf(stdout, _T(\"IA64\\n\"));\n break;\n case IMAGE_FILE_MACHINE_AMD64:\n _ftprintf(stdout, _T(\"AMD64\\n\"));\n break;\n default:\n _ftprintf(stdout, _T(\"Unknown (%d = %X)\\n\"), ifh.Machine, ifh.Machine);\n break;\n }\n\n // Write characteristics (see WinNT.h)\n _ftprintf(stdout, _T(\"Characteristics:\\n\"));\n _ftprintf(stdout, _T(\"RELOCS_STRIPPED Relocation info stripped from file: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_RELOCS_STRIPPED ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"EXECUTABLE_IMAGE File is executable (i.e. no unresolved externel references): %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_EXECUTABLE_IMAGE ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"LINE_NUMS_STRIPPED Line nunbers stripped from file: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_LINE_NUMS_STRIPPED ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"LOCAL_SYMS_STRIPPED Local symbols stripped from file: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_LOCAL_SYMS_STRIPPED ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"AGGRESIVE_WS_TRIM Agressively trim working set: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_AGGRESIVE_WS_TRIM ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"LARGE_ADDRESS_AWARE App can handle >2gb addresses: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_LARGE_ADDRESS_AWARE ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"BYTES_REVERSED_LO Bytes of machine word are reversed: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_BYTES_REVERSED_LO ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"32BIT_MACHINE 32 bit word machine: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_32BIT_MACHINE ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"DEBUG_STRIPPED Debugging info stripped from file in .DBG file: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_DEBUG_STRIPPED ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"REMOVABLE_RUN_FROM_SWAP If Image is on removable media, copy and run from the swap file: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"NET_RUN_FROM_SWAP If Image is on Net, copy and run from the swap file: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_NET_RUN_FROM_SWAP ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"SYSTEM System File: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_SYSTEM ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"DLL File is a DLL: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_DLL ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"UP_SYSTEM_ONLY File should only be run on a UP machine: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_UP_SYSTEM_ONLY ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"BYTES_REVERSED_HI Bytes of machine word are reversed: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_BYTES_REVERSED_HI ? _T('Y') : _T('N')));\n\n\n ckf.Close();\n\n return nRetCode;\n}\n"
},
{
"answer_id": 67739487,
"author": "risingballs",
"author_id": 1177068,
"author_profile": "https://Stackoverflow.com/users/1177068",
"pm_score": 0,
"selected": false,
"text": "// Fri May 28, 2021 -two\n\n#include <stdio.h>\n#include <io.h>\n#include <stdint.h>\n#include <iostream.h>\nusing namespace std;\n\nbool queryExeMachineType( const char *filename )\n{\n FILE *fp = fopen( filename, \"rb\" );\n\n if (fp == NULL)\n return false;\n\n // DOS header is 64 bytes\n const uint32_t fsize = filelength( fileno( fp ) );\n char magic[ 2 ] = { 0 };\n uint32_t offset = 0;\n uint16_t machine = 0;\n\n if (fread( magic, 1, 2, fp ) != 2 || magic[ 0 ] != 'M' || magic[ 1 ] != 'Z')\n {\n cerr << \"not an executable file\" << endl;\n fclose( fp );\n return false;\n }\n fseek( fp, 60, SEEK_SET );\n fread( &offset, 1, 4, fp );\n\n if (offset >= fsize)\n {\n cerr << \"invalid pe offset\" << endl;\n fclose( fp );\n return false;\n }\n fseek( fp, offset, SEEK_SET );\n\n if (fread( magic, 1, 2, fp ) != 2 || magic[ 0 ] != 'P' || magic[ 1 ] != 'E')\n {\n cerr << \"not a pe executable\" << endl;\n fclose( fp );\n return false;\n }\n fread( magic, 1, 2, fp );\n fread( &machine, 1, 2, fp );\n\n switch (machine)\n {\n case 0x014c:\n cout << \"i386\" << endl; // x86\n break;\n\n case 0x8664:\n cout << \"amd64\" << endl; // x86_64\n break;\n\n case 0x0200:\n cout << \"ia64\" << endl; // itanium\n break;\n\n default:\n cerr << \"unknown machine 0x\" << hex << machine << endl;\n break;\n }\n fclose( fp );\n return true;\n}\n\nint main( int argc, char *argv[] )\n{\n const char *fn = (argc > 1) ? argv[ 1 ] : \"test.dll\";\n\n if (queryExeMachineType( fn ))\n cerr << \"succeeded\" << endl;\n else\n cerr << \"failed\" << endl;\n\n return 0;\n}\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6637/"
] |
197,957
|
<p>Hoi!</p>
<p>I have a form I wish to submit, but I need to add the PHPSESSID, because some clients allow no cookies.</p>
<p>There are several javascript functions on my page which displays a list of users (search, sort, open details), the page is generated by PHP.</p>
<p>Now I am looking for an elegant way to have the PHPSESSID included in every submit of my form - this needs to be done on several pages, so I hope for an easy solution. Adding the PHPSESSID to the action or into a hidden field does not work properly.</p>
<p>Or is this problem located elsewhere? It could be the client is behind a too restrictive firewall or something. Any ideas (especially with solutions ;-) ) in that direction are also welcome!</p>
<p>Example code (extremely simplified):</p>
<pre><code><form name="userlist" method="POST" action="./myuserlist.php">
[...some formfields and stuff..]
</form>
<script>
//one example function, there are several on my page
function next_page()
{
//set some hidden field to get the next page
document.forms[0].submit();
}
</script>
</code></pre>
<p>Thanks in advance!</p>
<p>Bye,
Basty</p>
<p><strong>[EDIT]</strong>
session.use_trans_sid is set to true</p>
|
[
{
"answer_id": 198005,
"author": "ICR",
"author_id": 214,
"author_profile": "https://Stackoverflow.com/users/214",
"pm_score": 3,
"selected": false,
"text": "Assembly assembly = Assembly.LoadFile(Path.GetFullPath(\"ConsoleApplication1.exe\"));\nModule manifestModule = assembly.ManifestModule;\nPortableExecutableKinds peKind;\nImageFileMachine machine;\nmanifestModule.GetPEKind(out peKind, out machine);\n"
},
{
"answer_id": 885481,
"author": "Andrew",
"author_id": 15127,
"author_profile": "https://Stackoverflow.com/users/15127",
"pm_score": 6,
"selected": true,
"text": "public enum MachineType {\n Native = 0, I386 = 0x014c, Itanium = 0x0200, x64 = 0x8664\n}\n\npublic static MachineType GetMachineType(string fileName)\n{\n const int PE_POINTER_OFFSET = 60; \n const int MACHINE_OFFSET = 4;\n byte[] data = new byte[4096];\n using (Stream s = new FileStream(fileName, FileMode.Open, FileAccess.Read)) {\n s.Read(data, 0, 4096);\n }\n // dos header is 64 bytes, last element, long (4 bytes) is the address of the PE header\n int PE_HEADER_ADDR = BitConverter.ToInt32(data, PE_POINTER_OFFSET);\n int machineUint = BitConverter.ToUInt16(data, PE_HEADER_ADDR + MACHINE_OFFSET);\n return (MachineType)machineUint;\n}\n"
},
{
"answer_id": 4719567,
"author": "Keith Hill",
"author_id": 153982,
"author_profile": "https://Stackoverflow.com/users/153982",
"pm_score": 5,
"selected": false,
"text": "dumpbin.exe Get-PEHeader machine (x86) machine (x64) PE32 PE32+"
},
{
"answer_id": 38806690,
"author": "Kraang Prime",
"author_id": 3504007,
"author_profile": "https://Stackoverflow.com/users/3504007",
"pm_score": 0,
"selected": false,
"text": "// the enum of known pe file types\npublic enum FilePEType : ushort\n{\n IMAGE_FILE_MACHINE_UNKNOWN = 0x0,\n IMAGE_FILE_MACHINE_AM33 = 0x1d3,\n IMAGE_FILE_MACHINE_AMD64 = 0x8664,\n IMAGE_FILE_MACHINE_ARM = 0x1c0,\n IMAGE_FILE_MACHINE_EBC = 0xebc,\n IMAGE_FILE_MACHINE_I386 = 0x14c,\n IMAGE_FILE_MACHINE_IA64 = 0x200,\n IMAGE_FILE_MACHINE_M32R = 0x9041,\n IMAGE_FILE_MACHINE_MIPS16 = 0x266,\n IMAGE_FILE_MACHINE_MIPSFPU = 0x366,\n IMAGE_FILE_MACHINE_MIPSFPU16 = 0x466,\n IMAGE_FILE_MACHINE_POWERPC = 0x1f0,\n IMAGE_FILE_MACHINE_POWERPCFP = 0x1f1,\n IMAGE_FILE_MACHINE_R4000 = 0x166,\n IMAGE_FILE_MACHINE_SH3 = 0x1a2,\n IMAGE_FILE_MACHINE_SH3DSP = 0x1a3,\n IMAGE_FILE_MACHINE_SH4 = 0x1a6,\n IMAGE_FILE_MACHINE_SH5 = 0x1a8,\n IMAGE_FILE_MACHINE_THUMB = 0x1c2,\n IMAGE_FILE_MACHINE_WCEMIPSV2 = 0x169,\n}\n\n// pass the path to the file and check the return\npublic static FilePEType GetFilePE(string path)\n{\n FilePEType pe = new FilePEType();\n pe = FilePEType.IMAGE_FILE_MACHINE_UNKNOWN;\n if(File.Exists(path))\n {\n using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))\n {\n byte[] data = new byte[4096];\n fs.Read(data, 0, 4096);\n ushort result = BitConverter.ToUInt16(data, BitConverter.ToInt32(data, 60) + 4);\n try\n {\n pe = (FilePEType)result;\n } catch (Exception)\n {\n pe = FilePEType.IMAGE_FILE_MACHINE_UNKNOWN;\n }\n }\n }\n return pe;\n}\n string myfile = @\"c:\\windows\\explorer.exe\"; // the file\nFilePEType pe = GetFilePE( myfile );\n\nSystem.Diagnostics.WriteLine( pe.ToString() );\n"
},
{
"answer_id": 49110144,
"author": "default",
"author_id": 1069238,
"author_profile": "https://Stackoverflow.com/users/1069238",
"pm_score": 3,
"selected": false,
"text": "PE L d"
},
{
"answer_id": 50471830,
"author": "Jiminion",
"author_id": 2587816,
"author_profile": "https://Stackoverflow.com/users/2587816",
"pm_score": 1,
"selected": false,
"text": "// Determines if DLL is 32-bit or 64-bit.\n#include <stdio.h>\n\nint sGetDllType(const char *dll_name);\n\nint main()\n{\n int ret;\n const char *fname = \"sample_32.dll\";\n //const char *fname = \"sample_64.dll\";\n ret = sGetDllType(fname);\n}\n\nstatic int sGetDllType(const char *dll_name) {\n const int PE_POINTER_OFFSET = 60;\n const int MACHINE_TYPE_OFFSET = 4;\n FILE *fp;\n unsigned int ret = 0;\n int peoffset;\n unsigned short machine;\n\n fp = fopen(dll_name, \"rb\");\n unsigned char data[4096];\n ret = fread(data, sizeof(char), 4096, fp);\n fclose(fp);\n if (ret == 0)\n return -1;\n\n if ( (data[0] == 'M') && (data[1] == 'Z') ) {\n // Initial magic header is good\n peoffset = data[PE_POINTER_OFFSET + 3];\n peoffset = (peoffset << 8) + data[PE_POINTER_OFFSET + 2];\n peoffset = (peoffset << 8) + data[PE_POINTER_OFFSET + 1];\n peoffset = (peoffset << 8) + data[PE_POINTER_OFFSET];\n\n // Check second header\n if ((data[peoffset] == 'P') && (data[peoffset + 1] == 'E')) {\n machine = data[peoffset + MACHINE_TYPE_OFFSET];\n machine = (machine)+(data[peoffset + MACHINE_TYPE_OFFSET + 1] << 8);\n\n if (machine == 0x014c)\n return 32;\n if (machine == 0x8664)\n return 64;\n\n return -1;\n }\n return -1;\n }\n else\n return -1;\n}\n"
},
{
"answer_id": 51278133,
"author": "Saad Saadi",
"author_id": 1111249,
"author_profile": "https://Stackoverflow.com/users/1111249",
"pm_score": 2,
"selected": false,
"text": "dumpbin.exe bin .lib .dll dumpbin.exe /headers *.dll |findstr machine\n dumpbin.exe /headers *.lib |findstr machine\n"
},
{
"answer_id": 66548864,
"author": "John Matthews",
"author_id": 8771014,
"author_profile": "https://Stackoverflow.com/users/8771014",
"pm_score": 1,
"selected": false,
"text": "#include \"stdafx.h\"\n\nint _tmain(int argc, TCHAR* argv[], TCHAR* envp[])\n{\n int nRetCode = 0;\n int nrd;\n\n IMAGE_DOS_HEADER idh;\n IMAGE_NT_HEADERS inth;\n IMAGE_FILE_HEADER ifh;\n\n // initialize MFC and print and error on failure\n if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))\n {\n _tprintf(_T(\"Fatal Error: MFC initialization failed\\n\"));\n nRetCode = 1;\n return 1;\n }\n if (argc != 2) {\n _ftprintf(stderr, _T(\"Usage: %s filename\\n\"), argv[0]);\n return 1;\n }\n // Try to open the file\n CFile ckf;\n CFileException ex;\n DWORD flags = CFile::modeRead | CFile::shareDenyNone;\n\n if (!ckf.Open(argv[1], flags, &ex)) {\n TCHAR szError[1024];\n ex.GetErrorMessage(szError, 1024);\n _tprintf_s(_T(\"Couldn't open file: %1024s\"), szError);\n return 2;\n }\n\n // The following is adapted from:\n // https://stackoverflow.com/questions/495244/how-can-i-test-a-windows-dll-file-to-determine-if-it-is-32-bit-or-64-bit\n // https://stackoverflow.com/questions/46024914/how-to-parse-exe-file-and-get-data-from-image-dos-header-structure-using-c-and\n // Seek to beginning of file\n ckf.Seek(0, CFile::begin);\n\n // Read DOS header\n int nbytes = sizeof(IMAGE_DOS_HEADER);\n nrd = ckf.Read(&idh, nbytes);\n\n // The idh.e_lfanew member is the offset to the NT_HEADERS structure\n ckf.Seek(idh.e_lfanew, CFile::begin);\n\n // Read NT headers\n nbytes = sizeof(IMAGE_NT_HEADERS);\n nrd = ckf.Read(&inth, nbytes);\n\n ifh = inth.FileHeader;\n\n _ftprintf(stdout, _T(\"File machine type: \"));\n switch (ifh.Machine) {\n case IMAGE_FILE_MACHINE_I386:\n _ftprintf(stdout, _T(\"I386\\n\"));\n break;\n case IMAGE_FILE_MACHINE_IA64:\n _ftprintf(stdout, _T(\"IA64\\n\"));\n break;\n case IMAGE_FILE_MACHINE_AMD64:\n _ftprintf(stdout, _T(\"AMD64\\n\"));\n break;\n default:\n _ftprintf(stdout, _T(\"Unknown (%d = %X)\\n\"), ifh.Machine, ifh.Machine);\n break;\n }\n\n // Write characteristics (see WinNT.h)\n _ftprintf(stdout, _T(\"Characteristics:\\n\"));\n _ftprintf(stdout, _T(\"RELOCS_STRIPPED Relocation info stripped from file: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_RELOCS_STRIPPED ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"EXECUTABLE_IMAGE File is executable (i.e. no unresolved externel references): %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_EXECUTABLE_IMAGE ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"LINE_NUMS_STRIPPED Line nunbers stripped from file: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_LINE_NUMS_STRIPPED ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"LOCAL_SYMS_STRIPPED Local symbols stripped from file: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_LOCAL_SYMS_STRIPPED ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"AGGRESIVE_WS_TRIM Agressively trim working set: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_AGGRESIVE_WS_TRIM ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"LARGE_ADDRESS_AWARE App can handle >2gb addresses: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_LARGE_ADDRESS_AWARE ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"BYTES_REVERSED_LO Bytes of machine word are reversed: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_BYTES_REVERSED_LO ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"32BIT_MACHINE 32 bit word machine: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_32BIT_MACHINE ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"DEBUG_STRIPPED Debugging info stripped from file in .DBG file: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_DEBUG_STRIPPED ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"REMOVABLE_RUN_FROM_SWAP If Image is on removable media, copy and run from the swap file: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"NET_RUN_FROM_SWAP If Image is on Net, copy and run from the swap file: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_NET_RUN_FROM_SWAP ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"SYSTEM System File: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_SYSTEM ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"DLL File is a DLL: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_DLL ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"UP_SYSTEM_ONLY File should only be run on a UP machine: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_UP_SYSTEM_ONLY ? _T('Y') : _T('N')));\n _ftprintf(stdout, _T(\"BYTES_REVERSED_HI Bytes of machine word are reversed: %c\\n\"),\n (ifh.Characteristics & IMAGE_FILE_BYTES_REVERSED_HI ? _T('Y') : _T('N')));\n\n\n ckf.Close();\n\n return nRetCode;\n}\n"
},
{
"answer_id": 67739487,
"author": "risingballs",
"author_id": 1177068,
"author_profile": "https://Stackoverflow.com/users/1177068",
"pm_score": 0,
"selected": false,
"text": "// Fri May 28, 2021 -two\n\n#include <stdio.h>\n#include <io.h>\n#include <stdint.h>\n#include <iostream.h>\nusing namespace std;\n\nbool queryExeMachineType( const char *filename )\n{\n FILE *fp = fopen( filename, \"rb\" );\n\n if (fp == NULL)\n return false;\n\n // DOS header is 64 bytes\n const uint32_t fsize = filelength( fileno( fp ) );\n char magic[ 2 ] = { 0 };\n uint32_t offset = 0;\n uint16_t machine = 0;\n\n if (fread( magic, 1, 2, fp ) != 2 || magic[ 0 ] != 'M' || magic[ 1 ] != 'Z')\n {\n cerr << \"not an executable file\" << endl;\n fclose( fp );\n return false;\n }\n fseek( fp, 60, SEEK_SET );\n fread( &offset, 1, 4, fp );\n\n if (offset >= fsize)\n {\n cerr << \"invalid pe offset\" << endl;\n fclose( fp );\n return false;\n }\n fseek( fp, offset, SEEK_SET );\n\n if (fread( magic, 1, 2, fp ) != 2 || magic[ 0 ] != 'P' || magic[ 1 ] != 'E')\n {\n cerr << \"not a pe executable\" << endl;\n fclose( fp );\n return false;\n }\n fread( magic, 1, 2, fp );\n fread( &machine, 1, 2, fp );\n\n switch (machine)\n {\n case 0x014c:\n cout << \"i386\" << endl; // x86\n break;\n\n case 0x8664:\n cout << \"amd64\" << endl; // x86_64\n break;\n\n case 0x0200:\n cout << \"ia64\" << endl; // itanium\n break;\n\n default:\n cerr << \"unknown machine 0x\" << hex << machine << endl;\n break;\n }\n fclose( fp );\n return true;\n}\n\nint main( int argc, char *argv[] )\n{\n const char *fn = (argc > 1) ? argv[ 1 ] : \"test.dll\";\n\n if (queryExeMachineType( fn ))\n cerr << \"succeeded\" << endl;\n else\n cerr << \"failed\" << endl;\n\n return 0;\n}\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/371953/"
] |
197,976
|
<p>I'm trying to write a Windows cmd script to perform several tasks in series.
However, it always stops after the first command in the script.</p>
<p>The command it stops after is a maven build (not sure if that's relevant).</p>
<p>How do I make it carry on and run each task in turn please?</p>
<p>Installing any software or configuring the registry etc is completely out of the question - it has to work on a vanilla Windows XP installation I'm afraid.</p>
<p>Ideally I'd like the script to abort if any of the commands failed, but that's a "nice to have", not essential.</p>
<p>Thanks.</p>
|
[
{
"answer_id": 197997,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 8,
"selected": true,
"text": "call otherCommand.bat\n"
},
{
"answer_id": 198042,
"author": "Gulzar Nazim",
"author_id": 4337,
"author_profile": "https://Stackoverflow.com/users/4337",
"pm_score": 5,
"selected": false,
"text": "start cmd.exe /C 1.bat \nstart cmd.exe /C 2.bat\n"
},
{
"answer_id": 4437001,
"author": "Pulendar Vadde",
"author_id": 541635,
"author_profile": "https://Stackoverflow.com/users/541635",
"pm_score": 1,
"selected": false,
"text": "cd \"Script location\"\nschtasks /run /tn \"TASK1\"\nschtasks /run /tn \"TASK2\"\nschtasks /run /tn \"TASK3\"\nexit\n"
},
{
"answer_id": 7848054,
"author": "mhollander38",
"author_id": 595807,
"author_profile": "https://Stackoverflow.com/users/595807",
"pm_score": 5,
"selected": false,
"text": "rem run a maven clean install\ncd C:\\rbe-ui-test-suite \ncall mvn clean install\nrem now run through all the test scripts\ncall mvn clean install -Prun-integration-tests -Dpattern=tc-login\ncall mvn clean install -Prun-integration-tests -Dpattern=login-1\n"
},
{
"answer_id": 46384998,
"author": "JSON C11",
"author_id": 1244127,
"author_profile": "https://Stackoverflow.com/users/1244127",
"pm_score": 3,
"selected": false,
"text": "cd Desktop/project-directory && atom .\n cd Desktop/project-directory & atom .\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/151/"
] |
197,983
|
<p>I'm a kinda newbie developer with a few years under my belt. Recently I interviewed at a game company and was asked "have you done any multi-threading?" I told them about having a C# app with a few Threads... and then I said a bit about transactions and locking etc in Sql. The interviewer politely told me that this was too high-level and they are looking for someone with experience doing multi-threading in C++.</p>
<p>So what is a basic example of "low-level" multi-threading in C++ ?</p>
|
[
{
"answer_id": 198109,
"author": "Mark Baker",
"author_id": 11815,
"author_profile": "https://Stackoverflow.com/users/11815",
"pm_score": 2,
"selected": false,
"text": "int main( void )\n{\n pthread_t reader, writer;\n void *arg;\n\n // [... initialisation ...]\n\n // Spawn threads\n if( pthread_create( &reader, NULL, reader_func, arg ) ||\n pthread_create( &writer, NULL, writer_func, arg ) )\n {\n perror( \"pthread_create\" );\n return EX_OSERR;\n }\n\n // Wait while threads run\n pthread_join( reader, &arg );\n pthread_join( writer, &arg );\n\n return EX_OK;\n}\n\nvoid *reader_func( void *arg )\n{\n // [... do some stuff ...]\n return NULL;\n}\n\nvoid *writer_func( void *arg )\n{\n // [... do some different stuff ...]\n return NULL;\n}\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22471/"
] |
197,986
|
<p>For example:</p>
<pre><code>javac Foo.java
Note: Foo.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
</code></pre>
|
[
{
"answer_id": 197993,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 10,
"selected": true,
"text": "Arraylist() ArrayList<String>() List myList = new ArrayList();\n List<String> myList = new ArrayList<String>();\n List<String> myList = new ArrayList<>();\n"
},
{
"answer_id": 197998,
"author": "Matt",
"author_id": 20630,
"author_profile": "https://Stackoverflow.com/users/20630",
"pm_score": 3,
"selected": false,
"text": "List<String> getNames()\n\n\nList names = obj.getNames();\n List<String> names = obj.getNames();\n"
},
{
"answer_id": 198000,
"author": "Ryan",
"author_id": 17917,
"author_profile": "https://Stackoverflow.com/users/17917",
"pm_score": 3,
"selected": false,
"text": "ArrayList foo = new ArrayList(); ArrayList<String> foo = new ArrayList<String>();"
},
{
"answer_id": 198053,
"author": "Dan Dyer",
"author_id": 5171,
"author_profile": "https://Stackoverflow.com/users/5171",
"pm_score": 8,
"selected": false,
"text": "@SuppressWarnings(\"unchecked\")\npublic void myMethod()\n{\n //...\n}\n"
},
{
"answer_id": 23908919,
"author": "Suganthan Madhavan Pillai",
"author_id": 2534236,
"author_profile": "https://Stackoverflow.com/users/2534236",
"pm_score": 4,
"selected": false,
"text": "-Xlint:unchecked \n javac YourFile.java -Xlint:unchecked\n\nMain.java:7: warning: [unchecked] unchecked cast\n clone.mylist = (ArrayList<String>)this.mylist.clone();\n ^\n required: ArrayList<String>\n found: Object\n1 warning\n"
},
{
"answer_id": 25913061,
"author": "Julius",
"author_id": 3942879,
"author_profile": "https://Stackoverflow.com/users/3942879",
"pm_score": 1,
"selected": false,
"text": "<> ArrayList<File> File curfolder = new File( \"C:\\\\Users\\\\username\\\\Desktop\");\nFile[] file = curfolder.listFiles();\nArrayList filename = Arrays.asList(file);\n ArrayList File curfolder = new File( \"C:\\\\Users\\\\username\\\\Desktop\");\nFile[] file = curfolder.listFiles();\nArrayList<File> filename = Arrays.asList(file);\n ArrayList"
},
{
"answer_id": 29502285,
"author": "Michael Levy",
"author_id": 90236,
"author_profile": "https://Stackoverflow.com/users/90236",
"pm_score": 2,
"selected": false,
"text": "import java.io.Serializable;\n\npublic class SimpleGenericClass<T> implements Serializable {\n\n public Serializable getInstance() {\n return this;\n }\n\n // @SuppressWarnings(\"unchecked\")\n public static void main() {\n\n SimpleGenericClass<String> original = new SimpleGenericClass<String>();\n\n // java: unchecked cast\n // required: SimpleGenericClass<java.lang.String>\n // found: java.io.Serializable\n SimpleGenericClass<String> returned =\n (SimpleGenericClass<String>) original.getInstance();\n }\n}\n"
},
{
"answer_id": 53265164,
"author": "Borzh",
"author_id": 1223728,
"author_profile": "https://Stackoverflow.com/users/1223728",
"pm_score": 5,
"selected": false,
"text": "allprojects {\n\n gradle.projectsEvaluated {\n tasks.withType(JavaCompile) {\n options.compilerArgs << \"-Xlint:unchecked\"\n }\n }\n\n // ...\n}\n"
},
{
"answer_id": 57107212,
"author": "Mayukh Datta",
"author_id": 7936081,
"author_profile": "https://Stackoverflow.com/users/7936081",
"pm_score": 0,
"selected": false,
"text": "// list 2 is made generic and can store any type of Object\nArrayList<Object> list2 = new ArrayList<Object>();\n ArrayList Object"
},
{
"answer_id": 58098917,
"author": "Oskar",
"author_id": 2534288,
"author_profile": "https://Stackoverflow.com/users/2534288",
"pm_score": 3,
"selected": false,
"text": "allprojects {\n\n gradle.projectsEvaluated {\n tasks.withType(JavaCompile) {\n options.compilerArgs << \"-Xlint:unchecked\"\n }\n }\n\n}\n @SuppressWarnings(\"unchecked\")\npublic void myMethod()\n{\n //...\n}\n"
},
{
"answer_id": 59188558,
"author": "Mahadi Hasan",
"author_id": 9471958,
"author_profile": "https://Stackoverflow.com/users/9471958",
"pm_score": 0,
"selected": false,
"text": "new HashMap() new ArrayList() new HashMap() => Map<String,Object> map = new HashMap<String,Object>()\nnew HashMap() => Map<String,Object> map = new HashMap<>()\n\nnew ArrayList() => List<String,Object> map = new ArrayList<String,Object>()\nnew ArrayList() => List<String,Object> map = new ArrayList<>()\n"
},
{
"answer_id": 61384313,
"author": "CoolMind",
"author_id": 2914140,
"author_profile": "https://Stackoverflow.com/users/2914140",
"pm_score": 0,
"selected": false,
"text": "ArrayList<Map<String, Object>> items = (ArrayList<Map<String, Object>>) value; value @SuppressWarnings(\"unchecked\")\nArrayList<Map<String, Object>> items = (ArrayList<Map<String, Object>>) value;\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23987/"
] |
197,987
|
<p>I have a main frame with a splitter. On the left I have my (imaginatively named) CAppView_Leftand on the right I have CAppView_Right_1and CAppView_Right_2. Through the following code I initialise the two primary views correctly:</p>
<pre><code>if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
}
else
if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CAppView_Left), CSize(300, 200), pContext))
{
TRACE0("Failed to create left pane\n");
return FALSE;
}
else
if (!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CAppView_Right_1), CSize(375, 200), pContext))
{
TRACE0("Failed to create first right pane\n");
return FALSE;
}
</code></pre>
<p>...</p>
<p>What I would like to do is create a second view inside the right frame, however when I try to add this:</p>
<pre><code>if (!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CAppView_Right_2), CSize(375, 200), pContext))
{
TRACE0("Failed to create first right pane\n");
return FALSE;
}
</code></pre>
<p>VS compiles but fails to run the application, raising an exception telling me I have already defined the view.</p>
<p>Can someone suggest how I do this? Also, how to change between the views from either a view or the document class?</p>
|
[
{
"answer_id": 198142,
"author": "SmacL",
"author_id": 22564,
"author_profile": "https://Stackoverflow.com/users/22564",
"pm_score": 0,
"selected": false,
"text": "m_wndSplitter.CreateStatic(this, 1, 2) \n m_wndSplitter.CreateStatic(this, 1, 3)\n if (!m_wndSplitter.CreateView(0, 2, RUNTIME_CLASS(CAppView_Right_2), CSize(375, 200), pContext))\n{ \nTRACE0(\"Failed to create first right pane\\n\"); \n return FALSE;\n}\n m_wndSplitter2.CreateStatic(m_View2, 2, 1)\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/197987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18664/"
] |
198,006
|
<p>I need a way to do key-value lookups across (potentially) hundreds of GB of data. Ideally something based on a distributed hashtable, that works nicely with Java. It should be fault-tolerant, and open source.</p>
<p>The store should be persistent, but would ideally cache data in memory to speed things up.</p>
<p>It should be able to support concurrent reads and writes from multiple machines (reads will be 100X more common though). Basically the purpose is to do a quick initial lookup of user metadata for a web-service.</p>
<p>Can anyone recommend anything?</p>
|
[
{
"answer_id": 247624,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": true,
"text": "java.util.Map map = Hazelcast.getMap (\"mymap\");\nmap.put (\"key1\", \"value1\");\n"
},
{
"answer_id": 21073621,
"author": "Nikita Koksharov",
"author_id": 764206,
"author_profile": "https://Stackoverflow.com/users/764206",
"pm_score": 0,
"selected": false,
"text": "Redisson redisson = Redisson.create();\n\nConcurrentMap<String, SomeObject> map = redisson.getMap(\"anyMap\");\nmap.put(\"123\", new SomeObject());\nmap.putIfAbsent(\"323\", new SomeObject());\nmap.remove(\"123\");\n\n...\n\nredisson.shutdown();\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16050/"
] |
198,007
|
<p>I'm using the PHP function imagettftext() to convert text into a GIF image. The text I am converting has Unicode characters including Japanese. Everything works fine on my local machine (Ubuntu 7.10), but on my webhost server, the Japanese characters are mangled. What could be causing the difference? Everything should be encoded as UTF-8.</p>
<p>Broken Image on webhost server:
<a href="http://www.ibeni.net/flashcards/imagetest.php" rel="noreferrer">http://www.ibeni.net/flashcards/imagetest.php</a></p>
<p>Copy of correct image from my local machine:
<a href="http://www.ibeni.net/flashcards/imagetest.php.gif" rel="noreferrer">http://www.ibeni.net/flashcards/imagetest.php.gif</a></p>
<p>Copy of phpinfo() from my local machine:
<a href="http://www.ibeni.net/flashcards/phpinfo.php.html" rel="noreferrer">http://www.ibeni.net/flashcards/phpinfo.php.html</a></p>
<p>Copy of phpinfo() from my webhost server:
<a href="http://example5.nfshost.com/phpinfo" rel="noreferrer">http://example5.nfshost.com/phpinfo</a></p>
<p>Code:</p>
<pre><code>mb_language('uni');
mb_internal_encoding('UTF-8');
header('Content-type: image/gif');
$text = '日本語';
$font = './Cyberbit.ttf';
// Create the image
$im = imagecreatetruecolor(160, 160);
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
// Create some colors
imagefilledrectangle($im, 0, 0, 159, 159, $white);
// Add the text
imagettftext($im, 12, 0, 20, 20, $black, $font, $text);
imagegif($im);
imagedestroy($im);
</code></pre>
|
[
{
"answer_id": 198054,
"author": "Treb",
"author_id": 22114,
"author_profile": "https://Stackoverflow.com/users/22114",
"pm_score": 0,
"selected": false,
"text": "$text = '日本語';"
},
{
"answer_id": 201787,
"author": "gerdemb",
"author_id": 27478,
"author_profile": "https://Stackoverflow.com/users/27478",
"pm_score": 5,
"selected": true,
"text": "$text = \"你好\";\n// Convert UTF-8 string to HTML entities\n$text = mb_convert_encoding($text, 'HTML-ENTITIES',\"UTF-8\");\n// Convert HTML entities into ISO-8859-1\n$text = html_entity_decode($text,ENT_NOQUOTES, \"ISO-8859-1\");\n// Convert characters > 127 into their hexidecimal equivalents\n$out = \"\";\nfor($i = 0; $i < strlen($text); $i++) {\n $letter = $text[$i];\n $num = ord($letter);\n if($num>127) {\n $out .= \"&#$num;\";\n } else {\n $out .= $letter;\n }\n}\n 日本語\n ç\n"
},
{
"answer_id": 1956361,
"author": "amphetamachine",
"author_id": 237955,
"author_profile": "https://Stackoverflow.com/users/237955",
"pm_score": 4,
"selected": false,
"text": "$_GET $item_text = $_GET['text'];\n\n# detect if the string was passed in as unicode\n$text_encoding = mb_detect_encoding($item_text, 'UTF-8, ISO-8859-1');\n# make sure it's in unicode\nif ($text_encoding != 'UTF-8') {\n $item_text = mb_convert_encoding($item_text, 'UTF-8', $text_encoding);\n}\n\n# html numerically-escape everything (&#[dec];)\n$item_text = mb_encode_numericentity($item_text,\n array (0x0, 0xffff, 0, 0xffff), 'UTF-8');\n imagettftext"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27478/"
] |
198,023
|
<p>Are there any tools to assist with the internationalization of Strings within JSP files?</p>
<p>Most IDEs (for example, <a href="http://www.netbeans.org" rel="nofollow noreferrer">NetBeans</a>) offer such a feature for Java code. However, in the case of NetBeans, no such feature exists for JSP files.</p>
<p>With <a href="http://www.gnu.org/software/gettext/" rel="nofollow noreferrer">gettext</a>, for example, there is are various tools out there that assist with extracting text Strings from code. Something similar for JSP would be great!</p>
|
[
{
"answer_id": 805704,
"author": "seanf",
"author_id": 14379,
"author_profile": "https://Stackoverflow.com/users/14379",
"pm_score": 2,
"selected": false,
"text": "${messages[\"Hello {0}\"][username]}"
},
{
"answer_id": 2715909,
"author": "cdauth",
"author_id": 242365,
"author_profile": "https://Stackoverflow.com/users/242365",
"pm_score": 0,
"selected": false,
"text": "xgettext PHP"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198023",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3789/"
] |
198,024
|
<p>How do I go about doing this with jQuery?</p>
<p>Basically the structure:</p>
<pre><code><form id="myForm">
<iframe>
<!-- Normal HTML headers omitted -->
<input type=radio name="myRadio" value=1>First
<input type=radio name="myRadio" value=2>Second
<input type=radio name="myRadio" value=3>Third
</iframe>
<input type=button value="Submit" />
</form>
</code></pre>
<p>I tried various examples from the net such as </p>
<pre><code>$("input[@type=radio][@checked]");
</code></pre>
<p>But failed. Even with jQuery form plugin's <a href="http://malsup.com/jquery/form/#fields" rel="nofollow noreferrer">.fieldValue()</a> failed.</p>
|
[
{
"answer_id": 198094,
"author": "redsquare",
"author_id": 6440,
"author_profile": "https://Stackoverflow.com/users/6440",
"pm_score": 5,
"selected": true,
"text": "$('#myForm iframe').contents().find('input[name=myradio]').val()"
},
{
"answer_id": 198211,
"author": "eyelidlessness",
"author_id": 17964,
"author_profile": "https://Stackoverflow.com/users/17964",
"pm_score": 0,
"selected": false,
"text": "var frameDocument = $('#myForm iframe').contentDocument || $('#myForm iframe').contentWindow.document;\n$(frameDocument).find('input[type=radio][checked]');\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198024",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15345/"
] |
198,041
|
<p>Is there a way to tell the debugger to stop just before returning, on whichever statement exits from the method, be it return, exception, or fall out the bottom? I am inspired by the fact that the Java editor shows me all the places that my method <em>can</em> exit - it highlights them when you click on the return type of the method declaration, (Mark Occurrences enabled).</p>
<p>[eclipse 3.4]</p>
|
[
{
"answer_id": 198072,
"author": "MBCook",
"author_id": 18189,
"author_profile": "https://Stackoverflow.com/users/18189",
"pm_score": 0,
"selected": false,
"text": "public void method(Object stuff) {\n try {\n /* normal code */\n } finally {\n int x = 0;\n }\n}\n"
},
{
"answer_id": 198218,
"author": "idrosid",
"author_id": 17876,
"author_profile": "https://Stackoverflow.com/users/17876",
"pm_score": 6,
"selected": true,
"text": "public void myMethod() {\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14749/"
] |
198,045
|
<p>I've got a spreadsheet with plenty of graphs in it and one sheet with loads of data feeding those graphs.</p>
<p>I've plotted the data on each graph using </p>
<pre><code>=Sheet1!$C5:$C$3000
</code></pre>
<p>This basically just plots the values in C5 to C3000 on a graph.</p>
<p>Regularly though I just want to look at a subset of the data i.e. I might just want to look at the first 1000 rows for example. Currently to do this I have to modify the formula in each of my graphs which takes time.</p>
<p>Would you know a way to simplify this? Ideally if I could just have a cell on single sheet that it reads in the row number from and plots all the graphs from C5 to C 'row number' would be best.</p>
<p>Any help would be much appreciated.</p>
|
[
{
"answer_id": 198118,
"author": "Dave DuPlantis",
"author_id": 8174,
"author_profile": "https://Stackoverflow.com/users/8174",
"pm_score": 1,
"selected": false,
"text": "Private Sub Worksheet_Change(ByVal Target as Range)\n Select Case Target \n Case Cells(14, 2)\n Sheet1.ChartObjects(1).Chart.SetSourceData Range(\"$C5:$C$\" & Cells(14,2))\n ...\n End Select\nEnd Sub\n"
},
{
"answer_id": 199587,
"author": "Robert Mearns",
"author_id": 5050,
"author_profile": "https://Stackoverflow.com/users/5050",
"pm_score": 2,
"selected": false,
"text": "=OFFSET(Sheet1!$A$1,0,0,Sheet1!$D$1,3)\n Private Sub Worksheet_Change(ByVal Target As Range)\n\n If Target.Address <> \"$D$1\" Then Exit Sub\n 'Change $D$1 to the cell where you have entered the number of rows\n 'When the sheet changes, code checks to see if the cell $D$1 has changed\n\n ThisWorkbook.Sheets(\"Sheet1\").ChartObjects(1).Chart.SetSourceData _\n Source:=ThisWorkbook.Sheets(\"Sheet1\").Range(\"MyRange\")\n ' ThisWorkbook.Sheets(\"Chart1\").SetSourceData _\n Source:=ThisWorkbook.Sheets(\"Sheet1\").Range(\"MyRange\")\n 'The first line of code assumes that chart is embedded into Sheet1\n 'The second line assumes that the chart is in its own chart sheet\n 'Uncomment and change as required\n\n 'Add more code here to update all the other charts\n\nEnd Sub\n =Sheet1!$A$1:INDEX(Sheet1!$1:$65536,Sheet1!$D$1,2)\n"
},
{
"answer_id": 49717489,
"author": "Shai Alon",
"author_id": 1852977,
"author_profile": "https://Stackoverflow.com/users/1852977",
"pm_score": 0,
"selected": false,
"text": "=COUNTIF(A:A,\"<>\"&\"\") =OFFSET(Sheet1!$A$1, 0, 0,Sheet1!$D$1,3) Sheet1!$A$1 0 0 Sheet1!$D$1 3 =Sheet1!DataRange =Sheet1!DataRange"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4014/"
] |
198,047
|
<p>Can anyone suggest a tutorial or sample code that implements a nested set (or similar ordered tree structure) with associated Javascript that facilitates drag and drop? I'm looking for both the display code (view) as well as the AJAX backend controller which writes the tree to the database on change.</p>
<p>I want it to represent a multi-layer menu where the ordering and depth of items is important.</p>
|
[
{
"answer_id": 199458,
"author": "SchizoDuckie",
"author_id": 18077,
"author_profile": "https://Stackoverflow.com/users/18077",
"pm_score": -1,
"selected": false,
"text": "window.addEvent('domready', function()\n {\n document.Treeview = new TreeView();\n });\n\n\nTreeView = new Class({\n\n initialize: function()\n {\n treeObj = new JSDragDropTree();\n treeObj.setTreeId('treeview');\n treeObj.initTree();\n treeObj.showHideNode(true, 'node0');\n $$('.hiddennode').each(function(elm) { elm.setStyle('display','none'); });\n this.currentItem = false;\n },\n\n saveValues: function() \n {\n saveString = treeObj.getNodeOrders();\n new Ajax('./menuitem/save', {postBody: 'order='+saveString, onComplete:function(){window.Growl(this.transport.responseText)}, multiple:false}).request();\n },\n\n addItem: function()\n {\n new Ajax('./menuitem/add', {update:'editPanel'}).request(); \n },\n\n loadMenuItem: function(id)\n {\n this.currentItem = id;\n new Ajax('./menuitem/edit/'+id, {update:'editPanel', onComplete:function(){new ScrollDing('editPanel');}}).request();\n },\n\n removeItem: function()\n {\n if(!this.currentItem)\n {\n alert('please select a menu item to delete.');\n }\n else\n {\n if(confirm('Are you sure you want to delete this menu item?'))\n { \n // multiple: true is my little extension to mootools's Ajax class. \n // It expects a JSON object with keys corresponding to element ID's\n // and updates their innerHTML\n new Ajax('./menuitem/delete/'+this.currentItem, {multiple:true}).request();\n this.currentItem = false;\n }\n }\n }\n\n});\n /**\n * \n * @package Pork\n * @author SchizoDuckie\n * @copyright SchizoDuckie 2008\n */\nclass TreeMenu\n{\n private $menuItems, $output;\n function __construct()\n {\n global $db;\n\n $input = $db->fetchAll(\"SELECT * FROM menu ORDER BY intparent, intOrder\");\n for ($i=0; $i<sizeof($input); $i++)\n {\n $array = $input[$i];\n $this->menuItems[ $array->intParent ][ ] = $array;\n }\n }\n\n function hasSubItems($node)\n {\n return (array_key_exists($node, $this->menuItems) && sizeof($this->menuItems[$node]) > 0) ? true : false;\n } \n\n function displaytree($start=0, $noSiblings=false)\n {\n $output .= \"<ul>\";\n for ($i=0; $i<sizeof($this->menuItems[$start]); $i++)\n {\n\n $item = $this->menuItems[$start][$i];\n $siblings = ($noSiblings) ? \" \" : '';\n $output .= \"<li id='node{$item->ID_Menu}'{$siblings}><a href='#' onclick='Treeview.loadMenuItem({$item->ID_Menu});return false;'>{$item->strMenuItem}</a>\";\n if ($this->hasSubItems($item->ID_Menu))\n {\n $output .= $this->displayTree($item->ID_Menu, $noSiblings);\n }\n $output .= \"</li>\";\n } \n $output .= \"</ul>\";\n return($output);\n }\n\n function getTreeInnerHTML()\n {\n return(\"<li id='node0' noDrag='true' noSiblings='true'><a href='#' onclick='return false'>Root</a>{$this->displaytree()}</li>\");\n\n\n function display()\n {\n global $_TPL;\n\n $_TPL['styles'][] = './includes/drag-drop-folder-tree.css';\n $_TPL['scripts'][]= './includes/drag-drop-folder-tree.js';\n $_TPL['scripts'][]= './includes/pork.foldertree.js';\n\n return (\"<div id='treebuttons'>\n <input type='button' onclick='Treeview.saveValues()' value='Save order'>\n <input type='button' onclick='Treeview.addItem()' value='Add'>\n <input type='button' onclick='Treeview.removeItem()' value='Remove'>\n </div>\n <ul id='treeview'>{$this->getTreeInnerHTML()}</ul>\n <div id='msgDiv'></div>\n\n <div id='editPanel'></div>\n \");\n }\n\n}\n $tv = new TreeView();\n$_TPL['menu'] = $tv->display();\n <?\nglobal $_URI;\n\nswitch ($_URI[0])\n{\n case 'menuitem':\n switch ($_URI[1])\n {\n case 'add':\n $item = new menuItem();\n die($item->displayEditor('Add Menu Item', \"multiple:true\"));\n break;\n case 'edit':\n $item = new menuItem($_URI[2]);\n $_SESSION['currentMenuItem'] = $_URI[2];\n die($item->displayEditor('Edit MenuItem', 'multiple:true'));\n break;\n case 'delete':\n $item = new menuItem($_URI[2]);\n $item->deleteYourSelf();\n $js = new jsObject();\n $js->editPanel = 'Menu Item '.$item->menuItem.' has been deleted.';\n\n $menu = new Menu();\n $js->treeview = $menu->getTreeInnerHTML();\n $js->script = \"document.Treeview = new TreeView();\"; \n $js->display();\n break;\n case 'save':\n $items = explode(\",\",$_POST['order']);\n for($i=0;$i<sizeof($items);$i++)\n {\n $tokens = explode(\"|\",$items[$i]);\n $db->query(\"update menu set intParent='{$tokens[1]}', intOrder='{$i}' where ID_Menu='{$tokens[0]}'\");\n }\n die('Saved the new order!');\n break;\n }\n break;\n}\n\n?>\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198047",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17453/"
] |
198,049
|
<p>So I made some timers for a quiz. The thing is, I just realized when I put </p>
<pre><code>javascript: alert("blah");
</code></pre>
<p>in the address, the popup alert box <strong>pauses</strong> my timer. Which is very unwanted in a quiz.</p>
<p>I don't think there is any way to stop this behaviour... but I'll ask anyway.</p>
<p>If there is not, mind suggesting what should I do?</p>
|
[
{
"answer_id": 198160,
"author": "eyelidlessness",
"author_id": 17964,
"author_profile": "https://Stackoverflow.com/users/17964",
"pm_score": 4,
"selected": true,
"text": "// Preserve native alert() if you need it for something special\nwindow.nativeAlert = window.alert;\n\nwindow.alert = function(msg) {\n // Do something with msg here. I always write mine to console.log,\n // but then I have rarely found a use for a real modal dialog,\n // and most can be handled by the browser (like window.onbeforeunload).\n};\n"
},
{
"answer_id": 198915,
"author": "micahwittman",
"author_id": 11181,
"author_profile": "https://Stackoverflow.com/users/11181",
"pm_score": 2,
"selected": false,
"text": "var beginDate = new Date();\n\nfunction myTimeout(milsecs){\n do { curDate = new Date(); }\n while((curDate-beginDate) < milsecs);\n}\n\nfunction putDownYourPencils(milsecs){\n myTimeout(milsecs);\n var seconds = milsecs / 1000;\n alert('Your ' + seconds + ' seconds are up. Quiz is over.');\n}\n\nputDownYourPencils(3000);\n"
},
{
"answer_id": 199343,
"author": "Christopher Parker",
"author_id": 27583,
"author_profile": "https://Stackoverflow.com/users/27583",
"pm_score": 2,
"selected": false,
"text": "var timer = {\n startDatetime: null,\n startSec: 0,\n variance: 1,\n exitOnPause: true,\n count: function (config) {\n var that = this;\n\n if (typeof config == \"object\" && typeof parseInt(config.seconds) == \"number\" && !isNaN(parseInt(config.seconds)))\n {\n if (typeof parseFloat(config.variance) == \"number\" && !isNaN(parseFloat(config.variance))) this.variance = config.variance;\n if (typeof config.exitOnPause == \"boolean\") this.exitOnPause = config.exitOnPause;\n\n if (config.seconds > 0)\n {\n if (!this.startSec) this.startSec = config.seconds;\n if (!this.startDatetime) this.startDatetime = new Date();\n var currentDatetime = new Date();\n\n if (currentDatetime.getTime() - this.startDatetime.getTime() > (this.startSec - config.seconds) * this.variance * 1000)\n {\n if (typeof config.onPause == \"function\") config.onPause();\n\n if (!this.exitOnPause)\n {\n this.startDatetime = new Date();\n this.startSec = config.seconds--;\n window.setTimeout(function () { that.count(config); }, 1000);\n }\n }\n else\n {\n config.seconds--;\n window.setTimeout(function () { that.count(config); }, 1000);\n }\n }\n else\n {\n if (typeof config.onFinish == \"function\") config.onFinish();\n }\n }\n }\n};\n timer.count({\n seconds: 10,\n onPause: function () { alert(\"You cheated!\"); window.location.replace(\"cheatersAreBad.html\"); },\n onFinish: function () { alert(\"Time's up!\"); },\n variance: 2.5\n});\n timer.count({\n seconds: 10,\n exitOnPause: false,\n onPause: function () { recordCheaterViaAjax(); },\n onFinish: function () { alert(\"Time's up!\"); },\n variance: 2.5\n});\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15345/"
] |
198,051
|
<p>I was always wondering if there is operator for deleting multi dimensional arrays in the standard C++ language.</p>
<p>If we have created a pointer to a single dimensional array</p>
<pre><code>int *array = new int[size];
</code></pre>
<p>the delete looks like:</p>
<pre><code>delete [] array;
</code></pre>
<p>That's great. But if we have two dimension array, we can not do</p>
<pre><code>delete [][] twoDimenstionalArray;
</code></pre>
<p>Instead, we should loop and delete the items, like in <a href="http://eli.thegreenplace.net/2003/07/23/allocating-multi-dimensional-arrays-in-c/" rel="noreferrer">this</a> example.</p>
<p>Can anybody explain why?</p>
|
[
{
"answer_id": 198064,
"author": "shsteimer",
"author_id": 292,
"author_profile": "https://Stackoverflow.com/users/292",
"pm_score": 2,
"selected": false,
"text": "int ** mArr = new int*[10];\nfor(int i=0;i<10;i++)\n{\n mArr[i]=new int[10];\n}\n"
},
{
"answer_id": 198070,
"author": "Greg Rogers",
"author_id": 5963,
"author_profile": "https://Stackoverflow.com/users/5963",
"pm_score": 4,
"selected": false,
"text": "int **array = new int[dim1][dim2];\n delete [][] new int[dim1][dim2] dim1 int[dim2] dim2"
},
{
"answer_id": 198105,
"author": "James Rose",
"author_id": 9703,
"author_profile": "https://Stackoverflow.com/users/9703",
"pm_score": 3,
"selected": false,
"text": "delete [][]"
},
{
"answer_id": 200133,
"author": "user27732",
"author_id": 27732,
"author_profile": "https://Stackoverflow.com/users/27732",
"pm_score": 0,
"selected": false,
"text": "new[] new[]...[]"
},
{
"answer_id": 5784429,
"author": "Adam",
"author_id": 686534,
"author_profile": "https://Stackoverflow.com/users/686534",
"pm_score": 2,
"selected": false,
"text": "delete[][] array; int array[ROWS][COLS]; int array[ROWS*COLS]; COLS ROWS array[x][y] = 45 [x][y] [COLS*x + y] [x][y] array = new int[ROWS][COLS] delete[][] array; new array_2D"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/446104/"
] |
198,058
|
<p>I'd like to show a div that has a background-color with the height and width set to 100% but no content. Is it possible to do that without putting a &nbsp; inside?</p>
<p>Edit: Thanks to Mark Biek for pointing out that empty div with width and height styles shows how I'd expect. My div is in a table cell, where it does not show.</p>
<pre><code><table style="width:100%">
<tr>
<th>Header</th>
<td><div id="foo"></div></td>
</tr>
</table>
</code></pre>
|
[
{
"answer_id": 198083,
"author": "Mark Biek",
"author_id": 305,
"author_profile": "https://Stackoverflow.com/users/305",
"pm_score": 4,
"selected": true,
"text": "<html>\n <head>\n <style>\n #foo{\n background: #ff0000;\n width: 100%;\n height: 100%;\n border: 2px dashed black;\n }\n </style>\n </head>\n <body onload=\"\">\n <div id=\"foo\"></div>\n </body>\n</html>\n"
},
{
"answer_id": 202707,
"author": "GameFreak",
"author_id": 26659,
"author_profile": "https://Stackoverflow.com/users/26659",
"pm_score": 0,
"selected": false,
"text": "#foo {empty-cells: show;} <td>"
},
{
"answer_id": 540184,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": -1,
"selected": false,
"text": " "
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23427/"
] |
198,079
|
<p>Does anyone know a good resource to concisely explain the different types of lists available in C# and when their usage is appropriate?</p>
<p>For example, List, Hashtable, Dictionaries etc.</p>
<p>I'm never quite sure when I should be using what.</p>
|
[
{
"answer_id": 198091,
"author": "Robert S.",
"author_id": 7565,
"author_profile": "https://Stackoverflow.com/users/7565",
"pm_score": 2,
"selected": false,
"text": "Hashtable"
},
{
"answer_id": 198093,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": -1,
"selected": false,
"text": "System.collections.Generic. System.Collections.ObjectModel."
},
{
"answer_id": 198132,
"author": "Isak Savo",
"author_id": 8521,
"author_profile": "https://Stackoverflow.com/users/8521",
"pm_score": 3,
"selected": false,
"text": "Array int[] myArray ArrayList Object List<T> Hashtable Dictionary<T> Stack<T> Queue<T> List<T> IEnumerable<int> ICollection<int> IList<int>"
},
{
"answer_id": 198136,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 6,
"selected": true,
"text": "object"
},
{
"answer_id": 209563,
"author": "Marcus Griep",
"author_id": 28645,
"author_profile": "https://Stackoverflow.com/users/28645",
"pm_score": 3,
"selected": false,
"text": "CircularQueue<T> cq[0] ArrayList LinkedList ArrayList<T> System.Collections.Generic (SCG) List<T> LinkedList<T> SCG.LinkedList<T> HashedArrayList<T> ArrayList<T> HashedLinkedList<T> LinkedList<T> WrappedArray<T> ArrayList<T> C5.IList<T> IsFixedSize Add Remove Insert Sort Shuffle Reverse SortedArray<T> ArrayList<T> TreeSet<T> TreeBag<T> TreeSet<T> TreeBag<T> HashSet<T> BucketCostDistribution() HashBag<T> HashSet<T> IntervalHeap<T> HashDictionary<H,K> SCG.Dictionary<H,K> BucketCostDistribution() HashSet<T> TreeDictionary<H,K> SCG.SortedDictionary<H,K> using C5;\nusing SCG = System.Collections.Generic;\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1127460/"
] |
198,082
|
<p>How to find out size of session in ASP.NET from web application?</p>
|
[
{
"answer_id": 198158,
"author": "Rafe",
"author_id": 27497,
"author_profile": "https://Stackoverflow.com/users/27497",
"pm_score": 0,
"selected": false,
"text": "<trace enabled=\"true\" requestLimit=\"10\" pageOutput=\"true\" traceMode=\"SortByTime\" \n localOnly=\"true\"/>\n"
},
{
"answer_id": 198386,
"author": "ddc0660",
"author_id": 16027,
"author_profile": "https://Stackoverflow.com/users/16027",
"pm_score": 6,
"selected": true,
"text": "long totalSessionBytes = 0;\nBinaryFormatter b = new BinaryFormatter();\nMemoryStream m;\nforeach(var obj in Session) \n{\n m = new MemoryStream();\n b.Serialize(m, obj);\n totalSessionBytes += m.Length;\n}\n"
},
{
"answer_id": 5330435,
"author": "David",
"author_id": 663115,
"author_profile": "https://Stackoverflow.com/users/663115",
"pm_score": 5,
"selected": false,
"text": "private void ShowSessionSize()\n{\n Page.Trace.Write(\"Session Trace Info\");\n\n long totalSessionBytes = 0;\n System.Runtime.Serialization.Formatters.Binary.BinaryFormatter b = \n new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();\n System.IO.MemoryStream m;\n foreach (string key in Session)\n {\n var obj = Session[key];\n m = new System.IO.MemoryStream();\n b.Serialize(m, obj);\n totalSessionBytes += m.Length;\n\n Page.Trace.Write(String.Format(\"{0}: {1:n} kb\", key, m.Length / 1024));\n }\n\n Page.Trace.Write(String.Format(\"Total Size of Session Data: {0:n} kb\", \n totalSessionBytes / 1024));\n}\n"
},
{
"answer_id": 64385604,
"author": "cederlof",
"author_id": 198953,
"author_profile": "https://Stackoverflow.com/users/198953",
"pm_score": 0,
"selected": false,
"text": "// <KEY, SIZE(kB)>\nvar dict = new Dictionary<string, decimal>();\n\nBinaryFormatter b = new BinaryFormatter();\nMemoryStream m;\nforeach(string key in Session.Keys) \n{\n var obj = Session[key];\n if (obj == null)\n {\n dict.Add(key, -1);\n }\n else\n {\n m = new MemoryStream();\n b.Serialize(m, obj);\n \n //save the key and size in kB (rounded to two decimals)\n dict.Add(key, Math.Round(Convert.ToDecimal(m.Length) / 1024, 2)); \n }\n}\n\n//return dict\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23280/"
] |
198,087
|
<p>
We recently switched our Windows software packages from RPM (cygwin) to MSI (wix). Having a native packaging is a much welcome change and we intend to stick with it. However, MSI feels overly complicated for what it does and doesn't seem to provide some basic abilities. But I'm probably mistaken.
</p>
<p>
Is there a way to list all installed MSI from the command line ?
</p>
|
[
{
"answer_id": 198130,
"author": "Node",
"author_id": 7190,
"author_profile": "https://Stackoverflow.com/users/7190",
"pm_score": 5,
"selected": true,
"text": "strComputer = \".\"\n\nSet objWMIService = GetObject(\"winmgmts:\" & _\n \"{impersonationLevel=impersonate}!\\\\\" & _\n strComputer & _\n \"\\root\\cimv2\")\n\nSet colSoftware = objWMIService.ExecQuery _\n (\"SELECT * FROM Win32_Product\") \n\nIf colSoftware.Count > 0 Then\n\n Set objFSO = CreateObject(\"Scripting.FileSystemObject\")\n Set objTextFile = objFSO.CreateTextFile( _\n \"c:\\SoftwareList.txt\", True)\n\n For Each objSoftware in colSoftware\n objTextFile.WriteLine objSoftware.Caption & vbtab & _\n objSoftware.Version\n Next\n\n objTextFile.Close\n\nElse\n WScript.Echo \"Cannot retrieve software from this computer.\"\n\nEnd If\n"
},
{
"answer_id": 198185,
"author": "Ferruccio",
"author_id": 4086,
"author_profile": "https://Stackoverflow.com/users/4086",
"pm_score": 3,
"selected": false,
"text": "REG QUERY HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\n"
},
{
"answer_id": 13498298,
"author": "knut",
"author_id": 93360,
"author_profile": "https://Stackoverflow.com/users/93360",
"pm_score": 4,
"selected": false,
"text": "Get-WmiObject -Class win32_product\n Get-WmiObject PS C:\\Users\\knut> Get-WmiObject -Class win32_product |\n>> select -First 1 | ft Name, Version, Vendor -AutoSize\n>>\n\nName Version Vendor\n---- ------- ------\nAWS SDK for .NET 1.2.0200 Amazon Web Services Developer Relations\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11892/"
] |
198,114
|
<p>To do an unattended installation of any MSI package, one can simply use the following command:</p>
<pre><code>msiexec /qn /i package.msi
</code></pre>
<p>However, this triggers an asynchronous installation: if you happen to chain 2 dependent installations, you will have to wait somehow for the 1st installation to complete.</p>
<p>Is there a way to do this from the command line ?</p>
|
[
{
"answer_id": 13939918,
"author": "Ben Mosher",
"author_id": 344143,
"author_profile": "https://Stackoverflow.com/users/344143",
"pm_score": 3,
"selected": false,
"text": "start /wait msiexec /i MyInstaller.msi ...\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11892/"
] |
198,119
|
<p>I have a flash project that I'm trying to export as a single SWF. There's a main SWF file that loads about 6 other SWFs, and both the main and the child SWFs reference other external assets (images, sounds, etc). I'd like to package everything as a single .swf file so I don't have to tote the other assets around with the .swf. </p>
<p>All the coding is done in the timeline, but the assets haven't been imported into the Flash Authoring environment and I don't have time to do that right now (there are too many references to them everywhere). I'm hoping that there's just an option I'm missing that allows this sort of packaged export, but I haven't found anything like that.</p>
<p>I don't have access to Flex or mxmlc (and as the AS is timeline-based, they wouldn't necessarily help me). Any thoughts?</p>
<p>Thanks!</p>
<p>PS...if there's no way of doing exactly what I'm saying, I could deal with having all the assets in a "assets" folder or something like that, so I'd just be toting around main.swf and an assets folder. The problem here is that all the references to the assets assume that they're in the same folder as the main.swf file, so everything's assumed to be local...is there a way to change the scope of all external references in Flash (so, for example, all local references in the code are actually searched in /assets)?</p>
|
[
{
"answer_id": 1413991,
"author": "nikaji",
"author_id": 171185,
"author_profile": "https://Stackoverflow.com/users/171185",
"pm_score": 2,
"selected": false,
"text": "var realLoadMovie:Function = MovieClip.prototype.loadMovie;\n\nMovieClip.prototype.loadMovie = function(url:String, method:String) {\n return realLoadMovie(\"assets/\" + url, method);\n}\n\nvar test:MovieClip = createEmptyMovieClip(\"testclip\", getNextHighestDepth());\ntest.loadMovie(\"test.swf\");\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
198,122
|
<p>I have a server written in Java that runs as a Windows service (thanks to Install4J). I want this service to be able to download the latest version of the JAR file it runs from, and start running the new code. The stitch is that I don't want the Windows service to fully exit.</p>
<p>Ideally, I would accomplish this by a unix-style exec() call to stop the current version and run the new one. How can I best accomplish this?</p>
|
[
{
"answer_id": 198184,
"author": "Powerlord",
"author_id": 15880,
"author_profile": "https://Stackoverflow.com/users/15880",
"pm_score": 1,
"selected": false,
"text": "Runtime.exec ProcessBuilder"
},
{
"answer_id": 198268,
"author": "gnud",
"author_id": 27204,
"author_profile": "https://Stackoverflow.com/users/27204",
"pm_score": -1,
"selected": false,
"text": "import java.io.BufferedInputStream;\nimport java.util.Arrays;\n\npublic class ProcessSpawner { \npublic static void main(String[] args) {\n //You can change env variables and working directory, and\n //have better control over arguments.\n //See [ProcessBuilder javadocs][1]\n ProcessBuilder builder = new ProcessBuilder(\"ls\", \"-l\");\n\n try {\n Process p = builder.start();\n //here we just echo stdout from the process to java's stdout.\n //of course, this might not be what you're after.\n BufferedInputStream stream = \n new BufferedInputStream(p.getInputStream());\n byte[] b = new byte[80];\n while(stream.available() > 0) { \n stream.read(b);\n String s = new String(b);\n System.out.print(s);\n Arrays.fill(b, (byte)0);\n }\n //exit with the exit code of the spawned process.\n System.exit(p.waitFor());\n\n } catch(Exception e) {\n System.err.println(\"Exception: \"+e.getMessage());\n System.exit(1);\n }\n }\n}\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/420/"
] |
198,135
|
<p>Which is faster? someCondition has the same probability of being true as it has of being false.</p>
<p>Insertion:</p>
<pre><code>arrayList = Array("apple", "pear","grape")
if someCondition then
' insert "banana" element
end if
</code></pre>
<p>Deletion:</p>
<pre><code>arrayList = Array("apple","banana","pear","grape")
if not someCondition then
' remove "banana" element
end if
</code></pre>
<p>It looks like it depends purely on the implementation of Insert and Remove. So which, in general, is faster? I'm leaning toward insertion because I've read that one can use CopyMemory to insert without looping. Is this the same for deletion? Does anyone have an example?</p>
<p>Edit:
This is VB6, not VB.NET.
For display reasons, I have to use insert rather than append.</p>
|
[
{
"answer_id": 198144,
"author": "ilitirit",
"author_id": 9825,
"author_profile": "https://Stackoverflow.com/users/9825",
"pm_score": 0,
"selected": false,
"text": "Public Sub RemoveArrayElement_Str(AryVar() As String, ByVal _\n RemoveWhich As Long)\n '// The size of the array elements\n '// In the case of string arrays, they are\n '// simply 32 bit pointers to BSTR's.\n Dim byteLen As Byte\n\n '// String pointers are 4 bytes\n byteLen = 4\n\n '// The copymemory operation is not necessary unless\n '// we are working with an array element that is not\n '// at the end of the array\n If RemoveWhich < UBound(AryVar) Then\n '// Copy the block of string pointers starting at\n ' the position after the\n '// removed item back one spot.\n CopyMemory ByVal VarPtr(AryVar(RemoveWhich)), ByVal _\n VarPtr(AryVar(RemoveWhich + 1)), (byteLen) * _\n (UBound(AryVar) - RemoveWhich)\n End If\n\n '// If we are removing the last array element\n '// just deinitialize the array\n '// otherwise chop the array down by one.\n If UBound(AryVar) = LBound(AryVar) Then\n Erase AryVar\n Else\n ReDim Preserve AryVar(UBound(AryVar) - 1)\n End If\nEnd Sub\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9825/"
] |
198,141
|
<p>I have a postgres table. I need to delete some data from it. I was going to create a temporary table, copy the data in, recreate the indexes and the delete the rows I need. I can't delete data from the original table, because this original table is the source of data. In one case I need to get some results that depends on deleting X, in another case, I'll need to delete Y. So I need all the original data to always be around and available.</p>
<p>However it seems a bit silly to recreate the table and copy it again and recreate the indexes. Is there anyway in postgres to tell it "I want a complete separate copy of this table, including structure, data and indexes"?</p>
<p>Unfortunately PostgreSQL does not have a "CREATE TABLE .. LIKE X INCLUDING INDEXES'</p>
|
[
{
"answer_id": 198192,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "create table mynewone as select * from myoldone where ...\nmess (re-create) with indexes after the table swap.\n"
},
{
"answer_id": 198833,
"author": "WolfmanDragon",
"author_id": 13491,
"author_profile": "https://Stackoverflow.com/users/13491",
"pm_score": 6,
"selected": false,
"text": "[CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name\n [ (column_name [, ...] ) ]\n [ WITH ( storage_parameter [= value] [, ... ] ) | WITH OIDS | WITHOUT OIDS ]\n [ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ]\n [ TABLESPACE tablespace ]\n AS query][1] \n CREATE TABLE films_recent AS\n SELECT * FROM films WHERE date_prod >= '2002-01-01';\n CREATE TABLE films_recent (LIKE films INCLUDING INDEXES); \n\n INSERT INTO films_recent\n SELECT *\n FROM books\n WHERE date_prod >= '2002-01-01'; \n"
},
{
"answer_id": 198919,
"author": "Alan",
"author_id": 5878,
"author_profile": "https://Stackoverflow.com/users/5878",
"pm_score": 2,
"selected": false,
"text": "delete from yourtable\nwhere <condition(s)>\n"
},
{
"answer_id": 1079166,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 7,
"selected": false,
"text": "# select version();\n version\n-------------------------------------------------------------------------------------------------\n PostgreSQL 8.3.7 on x86_64-pc-linux-gnu, compiled by GCC cc (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu3)\n(1 row)\n # create table x1 (id serial primary key, x text unique);\nNOTICE: CREATE TABLE will create implicit sequence \"x1_id_seq\" for serial column \"x1.id\"\nNOTICE: CREATE TABLE / PRIMARY KEY will create implicit index \"x1_pkey\" for table \"x1\"\nNOTICE: CREATE TABLE / UNIQUE will create implicit index \"x1_x_key\" for table \"x1\"\nCREATE TABLE\n # \\d x1\n Table \"public.x1\"\n Column | Type | Modifiers\n--------+---------+-------------------------------------------------\n id | integer | not null default nextval('x1_id_seq'::regclass)\n x | text |\nIndexes:\n \"x1_pkey\" PRIMARY KEY, btree (id)\n \"x1_x_key\" UNIQUE, btree (x)\n # create table x2 ( like x1 INCLUDING DEFAULTS INCLUDING CONSTRAINTS INCLUDING INDEXES );\nNOTICE: CREATE TABLE / PRIMARY KEY will create implicit index \"x2_pkey\" for table \"x2\"\nNOTICE: CREATE TABLE / UNIQUE will create implicit index \"x2_x_key\" for table \"x2\"\nCREATE TABLE\n # \\d x2\n Table \"public.x2\"\n Column | Type | Modifiers\n--------+---------+-------------------------------------------------\n id | integer | not null default nextval('x1_id_seq'::regclass)\n x | text |\nIndexes:\n \"x2_pkey\" PRIMARY KEY, btree (id)\n \"x2_x_key\" UNIQUE, btree (x)\n => pg_dump -t x2 | sed 's/x2/x3/g' | psql\nSET\nSET\nSET\nSET\nSET\nSET\nSET\nSET\nCREATE TABLE\nALTER TABLE\nALTER TABLE\nALTER TABLE\n # \\d x3\n Table \"public.x3\"\n Column | Type | Modifiers\n--------+---------+-------------------------------------------------\n id | integer | not null default nextval('x1_id_seq'::regclass)\n x | text |\nIndexes:\n \"x3_pkey\" PRIMARY KEY, btree (id)\n \"x3_x_key\" UNIQUE, btree (x)\n"
},
{
"answer_id": 56692379,
"author": "Ringtail",
"author_id": 5465064,
"author_profile": "https://Stackoverflow.com/users/5465064",
"pm_score": 2,
"selected": false,
"text": "CREATE TABLE new_table (LIKE original_table INCLUDING ALL);\n"
},
{
"answer_id": 59285499,
"author": "oshai",
"author_id": 411965,
"author_profile": "https://Stackoverflow.com/users/411965",
"pm_score": 4,
"selected": false,
"text": "create table NEW ( like ORIGINAL including all);\ninsert into NEW select * from ORIGINAL\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/161922/"
] |
198,153
|
<pre><code><html>
<head>
<style type="text/css">
div {
border:1px solid #000;
min-width: 50%;
}
</style>
</head>
<body>
<div>This is some text. </div>
</body>
</html>
</code></pre>
<p>I believe the div should be 50 percent of the page, unless, for some reason, the text inside the div makes it larger. However, the border around the div stretches across the entire page width. This occurs in both IE and Firefox.</p>
<p>Suggestions?</p>
|
[
{
"answer_id": 198165,
"author": "Chris Serra",
"author_id": 13435,
"author_profile": "https://Stackoverflow.com/users/13435",
"pm_score": 4,
"selected": true,
"text": "absolute 50% min-width min-height 50%"
},
{
"answer_id": 198188,
"author": "eyelidlessness",
"author_id": 17964,
"author_profile": "https://Stackoverflow.com/users/17964",
"pm_score": 2,
"selected": false,
"text": "width min-width"
},
{
"answer_id": 198305,
"author": "buti-oxa",
"author_id": 2515,
"author_profile": "https://Stackoverflow.com/users/2515",
"pm_score": 3,
"selected": false,
"text": "min-width display:block min-width display absolute float left min-width"
},
{
"answer_id": 198947,
"author": "David Kolar",
"author_id": 3283,
"author_profile": "https://Stackoverflow.com/users/3283",
"pm_score": 4,
"selected": false,
"text": "min-width min-width: 50%; 50% min-width {width: 100%; min-width: 250px;}"
},
{
"answer_id": 273591,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "print(\"width:expression(document.body.clientWidth < 1024? \"50%\" : \"100%\");\");\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/572/"
] |
198,155
|
<p>I am trying to run xcopy that copies files excluding .obj, etc.
What I am seeing is that Microsoft.Practices.ObjectBuilder.dll is not copied when my excludes.txt file contains .obj as an extension. When .obj is removed, I Microsoft.Practices.ObjectBuilder.dll is copied correctly. This does not happen to other dlls though.</p>
<p>Does anyone have any idea why this would happen?</p>
<p>Thanks!</p>
<p>Lenik</p>
|
[
{
"answer_id": 198167,
"author": "gizmo",
"author_id": 9396,
"author_profile": "https://Stackoverflow.com/users/9396",
"pm_score": -1,
"selected": false,
"text": "xcopy /?\n"
},
{
"answer_id": 198282,
"author": "Hafthor",
"author_id": 4489,
"author_profile": "https://Stackoverflow.com/users/4489",
"pm_score": 3,
"selected": false,
"text": "dir /b *.obj >excludes.txt\nxcopy * /exclude:excludes.txt targetdir\n dir /s /b *.obj >excludes.txt\nxcopy c:\\sourcedir\\* /exclude:excludes.txt \\targetdir\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2341/"
] |
198,157
|
<p>I'm trying to verify if a schema matches the objects I'm initializing.</p>
<p>Is there a way to get the TableName of a class other than simply reflecting the class name?</p>
<p>I am using some class with explicit TableNames</p>
<p>Edit: using Joe's solution I added the case where you don't specify the table name, it could probably use a constraint</p>
<pre><code>public string find_table_name(object obj)
{
object[] attribs = obj.GetType().GetCustomAttributes(typeof(Castle.ActiveRecord.ActiveRecordAttribute), false);
if (attribs != null)
{
ActiveRecordAttribute attrib = (Castle.ActiveRecord.ActiveRecordAttribute) attribs[0];
if (attrib.Table != null)
return attrib.Table;
return obj.GetType().Name;
}
return null;
}
</code></pre>
|
[
{
"answer_id": 198263,
"author": "user27529",
"author_id": 27529,
"author_profile": "https://Stackoverflow.com/users/27529",
"pm_score": 3,
"selected": true,
"text": "[ActiveRecord(Table = \"NewsMaster\")]\npublic class Article\n{\n [PrimaryKey(Generator = PrimaryKeyType.Identity)]\n public int NewsId { get; set; }\n\n [Property(Column = \"NewsHeadline\")]\n public string Headline { get; set; }\n\n [Property(Column = \"EffectiveStartDate\")]\n public DateTime StartDate { get; set; }\n\n [Property(Column = \"EffectiveEndDate\")]\n public DateTime EndDate { get; set; }\n\n [Property]\n public string NewsBlurb { get; set; }\n}\n [Test]\n public void Can_get_table_name()\n {\n var attribs = typeof(Article).GetCustomAttributes(typeof(Castle.ActiveRecord.ActiveRecordAttribute), false);\n\n if (attribs != null)\n {\n var attrib = (Castle.ActiveRecord.ActiveRecordAttribute) attribs[0];\n Assert.AreEqual(\"NewsMaster\", attrib.Table);\n }\n }\n"
},
{
"answer_id": 325635,
"author": "Mauricio Scheffer",
"author_id": 21239,
"author_profile": "https://Stackoverflow.com/users/21239",
"pm_score": 2,
"selected": false,
"text": "ActiveRecordModel.GetModel(typeof(Article)).ActiveRecordAtt.Table\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/253/"
] |
198,196
|
<p>I'm curious to know how people are using table aliases. The other developers where I work always use table aliases, and always use the alias of a, b, c, etc.</p>
<p>Here's an example:</p>
<pre><code>SELECT a.TripNum, b.SegmentNum, b.StopNum, b.ArrivalTime
FROM Trip a, Segment b
WHERE a.TripNum = b.TripNum
</code></pre>
<p>I disagree with them, and think table aliases should be use more sparingly. </p>
<p>I think they should be used when including the same table twice in a query, or when the table name is very long and using a shorter name in the query will make the query easier to read. </p>
<p>I also think the alias should be a descriptive name rather than just a letter. In the above example, if I felt I needed to use 1 letter table alias I would use t for the Trip table and s for the segment table.</p>
|
[
{
"answer_id": 198214,
"author": "BoltBait",
"author_id": 20848,
"author_profile": "https://Stackoverflow.com/users/20848",
"pm_score": 4,
"selected": false,
"text": "SELECT t.TripNum, s.SegmentNum, s.StopNum, s.ArrivalTime \nFROM Trip t, Segment s \nWHERE t.TripNum = s.TripNum\n"
},
{
"answer_id": 198228,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 0,
"selected": false,
"text": "select PartNumber, I.InventoryTypeId, InventoryTypeDescription\nfrom dbo.Inventory I\n inner join dbo.InventoryType IT on IT.InventoryTypeId = I.InventoryTypeId\n select *\nfrom (\n select field1, field2, sum(field3) as total\n from someothertable\n) X\n"
},
{
"answer_id": 198246,
"author": "mattruma",
"author_id": 1768,
"author_profile": "https://Stackoverflow.com/users/1768",
"pm_score": 3,
"selected": false,
"text": "SELECT TripNum, TripSegment.SegmentNum, TripSegment.StopNum, TripSegment.ArrivalTime \nFROM Trip, Segment TripSegment \nWHERE TripNum = TripSegment.TripNum\n"
},
{
"answer_id": 198298,
"author": "Milan Babuškov",
"author_id": 14690,
"author_profile": "https://Stackoverflow.com/users/14690",
"pm_score": 2,
"selected": false,
"text": "select col1, col2\nfrom tab1\njoin tab2 on tab1.col3 = tab2.col3\n"
},
{
"answer_id": 1229380,
"author": "Erv",
"author_id": 149519,
"author_profile": "https://Stackoverflow.com/users/149519",
"pm_score": 1,
"selected": false,
"text": "SELECT SUM(a.VALUE) \n FROM Domesticvalues a, Foreignvalues b \n WHERE a.Value>b.Value\n AND a.Something ...\n select SUM(DVAL.Value) \n from DomesticValues DVAL, ForeignValues FVAL \n where DVAL.Value > FVAL.Value\n and DVAL.Something ...\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28281/"
] |
198,199
|
<p>How do you reverse a string in C or C++ without requiring a separate buffer to hold the reversed string?</p>
|
[
{
"answer_id": 198200,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "#include <cstdio>\n#include <cstdlib>\n#include <string>\n\nvoid strrev(char *str)\n{\n if( str == NULL )\n return;\n\n char *end_ptr = &str[strlen(str) - 1];\n char temp;\n while( end_ptr > str )\n {\n temp = *str;\n *str++ = *end_ptr;\n *end_ptr-- = temp;\n }\n}\n\nint main(int argc, char *argv[])\n{\n char buffer[32];\n\n strcpy(buffer, \"testing\");\n strrev(buffer);\n printf(\"%s\\n\", buffer);\n\n strcpy(buffer, \"a\");\n strrev(buffer);\n printf(\"%s\\n\", buffer);\n\n strcpy(buffer, \"abc\");\n strrev(buffer);\n printf(\"%s\\n\", buffer);\n\n strcpy(buffer, \"\");\n strrev(buffer);\n printf(\"%s\\n\", buffer);\n\n strrev(NULL);\n\n return 0;\n}\n gnitset\na\ncba\n"
},
{
"answer_id": 198210,
"author": "Greg Rogers",
"author_id": 5963,
"author_profile": "https://Stackoverflow.com/users/5963",
"pm_score": 9,
"selected": false,
"text": "#include <algorithm>\nstd::reverse(str.begin(), str.end());\n"
},
{
"answer_id": 198264,
"author": "Anders Eurenius",
"author_id": 1421,
"author_profile": "https://Stackoverflow.com/users/1421",
"pm_score": 8,
"selected": true,
"text": "char void strrev(char *head)\n{\n if (!head) return;\n char *tail = head;\n while(*tail) ++tail; // find the 0 terminator, like head+strlen\n --tail; // tail points to the last real char\n // head still points to the first\n for( ; head < tail; ++head, --tail) {\n // walk pointers inwards until they meet or cross in the middle\n char h = *head, t = *tail;\n *head = t; // swapping as we go\n *tail = h;\n }\n}\n // test program that reverses its args\n#include <stdio.h>\n\nint main(int argc, char **argv)\n{\n do {\n printf(\"%s \", argv[argc-1]);\n strrev(argv[argc-1]);\n printf(\"%s\\n\", argv[argc-1]);\n } while(--argc);\n\n return 0;\n}\n tail = start + length - 1 *p *q #include <bits/types.h>\n#include <stdio.h>\n\n#define SWP(x,y) (x^=y, y^=x, x^=y)\n\nvoid strrev(char *p)\n{\n char *q = p;\n while(q && *q) ++q; /* find eos */\n for(--q; p < q; ++p, --q) SWP(*p, *q);\n}\n\nvoid strrev_utf8(char *p)\n{\n char *q = p;\n strrev(p); /* call base case */\n\n /* Ok, now fix bass-ackwards UTF chars. */\n while(q && *q) ++q; /* find eos */\n while(p < --q)\n switch( (*q & 0xF0) >> 4 ) {\n case 0xF: /* U+010000-U+10FFFF: four bytes. */\n SWP(*(q-0), *(q-3));\n SWP(*(q-1), *(q-2));\n q -= 3;\n break;\n case 0xE: /* U+000800-U+00FFFF: three bytes. */\n SWP(*(q-0), *(q-2));\n q -= 2;\n break;\n case 0xC: /* fall-through */\n case 0xD: /* U+000080-U+0007FF: two bytes. */\n SWP(*(q-0), *(q-1));\n q--;\n break;\n }\n}\n\nint main(int argc, char **argv)\n{\n do {\n printf(\"%s \", argv[argc-1]);\n strrev_utf8(argv[argc-1]);\n printf(\"%s\\n\", argv[argc-1]);\n } while(--argc);\n\n return 0;\n}\n $ ./strrev Räksmörgås ░▒▓○◔◑◕●\n\n░▒▓○◔◑◕● ●◕◑◔○▓▒░\n\nRäksmörgås sågrömskäR\n\n./strrev verrts/.\n"
},
{
"answer_id": 198275,
"author": "Chris Conway",
"author_id": 1412,
"author_profile": "https://Stackoverflow.com/users/1412",
"pm_score": 5,
"selected": false,
"text": "char #include <stddef.h>\n#include <string.h>\n\n/* PRE: str must be either NULL or a pointer to a \n * (possibly empty) null-terminated string. */\nvoid strrev(char *str) {\n char temp, *end_ptr;\n\n /* If str is NULL or empty, do nothing */\n if( str == NULL || !(*str) )\n return;\n\n end_ptr = str + strlen(str) - 1;\n\n /* Swap the chars */\n while( end_ptr > str ) {\n temp = *str;\n *str = *end_ptr;\n *end_ptr = temp;\n str++;\n end_ptr--;\n }\n}\n"
},
{
"answer_id": 198527,
"author": "Eclipse",
"author_id": 8701,
"author_profile": "https://Stackoverflow.com/users/8701",
"pm_score": 5,
"selected": false,
"text": "char * std::wstring std::string void strrev(char *str)\n{\n if (str == NULL)\n return;\n std::reverse(str, str + strlen(str));\n}\n"
},
{
"answer_id": 199891,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 7,
"selected": false,
"text": "#include <string.h>\n\nvoid reverse(char s[])\n{\n int length = strlen(s) ;\n int c, i, j;\n\n for (i = 0, j = length - 1; i < j; i++, j--)\n {\n c = s[i];\n s[i] = s[j];\n s[j] = c;\n }\n}\n"
},
{
"answer_id": 5315651,
"author": "Rob",
"author_id": 386102,
"author_profile": "https://Stackoverflow.com/users/386102",
"pm_score": 2,
"selected": false,
"text": "#include <stdio.h>\n#include <string.h>\n#include <stdlib.h>\n\nchar *reverse(char *str) {\n if( str == NULL || !(*str) ) return NULL;\n int i, j = strlen(str)-1;\n char *sallocd;\n sallocd = malloc(sizeof(char) * (j+1));\n for(i=0; j>=0; i++, j--) {\n *(sallocd+i) = *(str+j);\n }\n return sallocd;\n}\n\nint main(void) {\n char *s = \"a man a plan a canal panama\";\n char *sret = reverse(s);\n printf(\"%s\\n\", reverse(sret));\n free(sret);\n return 0;\n}\n"
},
{
"answer_id": 6560310,
"author": "karlphillip",
"author_id": 176769,
"author_profile": "https://Stackoverflow.com/users/176769",
"pm_score": 5,
"selected": false,
"text": "char input[] = \"moc.wolfrevokcats\";\n\nint length = strlen(input);\nint last_pos = length-1;\nfor(int i = 0; i < length/2; i++)\n{\n char tmp = input[i];\n input[i] = input[last_pos - i];\n input[last_pos - i] = tmp;\n}\n\nprintf(\"%s\\n\", input);\n"
},
{
"answer_id": 9393226,
"author": "Simon Peverett",
"author_id": 6063,
"author_profile": "https://Stackoverflow.com/users/6063",
"pm_score": 2,
"selected": false,
"text": "#include <stdio.h>\n\n/* Store the each value and move to next char going down\n * the stack. Assign value to start ptr and increment \n * when coming back up the stack (return).\n * Neat code, horrible stack usage.\n *\n * val - value of current pointer.\n * s - start pointer\n * n - next char pointer in string.\n */\nchar *reverse_r(char val, char *s, char *n)\n{\n if (*n)\n s = reverse_r(*n, s, n+1);\n *s = val;\n return s+1;\n}\n\n/*\n * expect the string to be passed as argv[1]\n */\nint main(int argc, char *argv[])\n{\n char *aString;\n\n if (argc < 2)\n {\n printf(\"Usage: RSIP <string>\\n\");\n return 0;\n }\n\n aString = argv[1];\n printf(\"String to reverse: %s\\n\", aString );\n\n reverse_r(*aString, aString, aString+1); \n printf(\"Reversed String: %s\\n\", aString );\n\n return 0;\n}\n"
},
{
"answer_id": 10955108,
"author": "Mike Marrotte",
"author_id": 1445312,
"author_profile": "https://Stackoverflow.com/users/1445312",
"pm_score": 0,
"selected": false,
"text": "#include <stdio.h>\n#include <strings.h>\n\nint main(int argc, char **argv) {\n\n char *reverse = argv[argc-1];\n char *left = reverse;\n int length = strlen(reverse);\n char *right = reverse+length-1;\n char temp;\n\n while(right-left>=1){\n\n temp=*left;\n *left=*right;\n *right=temp;\n ++left;\n --right;\n\n }\n\n printf(\"%s\\n\", reverse);\n\n}\n"
},
{
"answer_id": 12640695,
"author": "pprzemek",
"author_id": 212149,
"author_profile": "https://Stackoverflow.com/users/212149",
"pm_score": 3,
"selected": false,
"text": "str = std::string(str.rbegin(), str.rend());\n char* reverse(char* s)\n{\n char* beg = s, *end = s, tmp;\n while (*end) end++;\n while (end-- > beg)\n { \n tmp = *beg; \n *beg++ = *end; \n *end = tmp;\n }\n return s;\n} // fixed: check history for details, as those are interesting ones\n"
},
{
"answer_id": 19674312,
"author": "masakielastic",
"author_id": 531320,
"author_profile": "https://Stackoverflow.com/users/531320",
"pm_score": 0,
"selected": false,
"text": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdbool.h>\n\nunsigned char * utf8_reverse(const unsigned char *, int);\nvoid assert_true(bool);\n\nint main(void)\n{\n unsigned char str[] = \"mañana mañana\";\n unsigned char *ret = utf8_reverse(str, strlen((const char *) str) + 1);\n\n printf(\"%s\\n\", ret);\n assert_true(0 == strncmp((const char *) ret, \"anãnam anañam\", strlen(\"anãnam anañam\") + 1));\n\n free(ret);\n\n return EXIT_SUCCESS;\n}\n\nunsigned char * utf8_reverse(const unsigned char *str, int size)\n{\n unsigned char *ret = calloc(size, sizeof(unsigned char*));\n int ret_size = 0;\n int pos = size - 2;\n int char_size = 0;\n\n if (str == NULL) {\n fprintf(stderr, \"failed to allocate memory.\\n\");\n exit(EXIT_FAILURE);\n }\n\n while (pos > -1) {\n\n if (str[pos] < 0x80) {\n char_size = 1;\n } else if (pos > 0 && str[pos - 1] > 0xC1 && str[pos - 1] < 0xE0) {\n char_size = 2;\n } else if (pos > 1 && str[pos - 2] > 0xDF && str[pos - 2] < 0xF0) {\n char_size = 3;\n } else if (pos > 2 && str[pos - 3] > 0xEF && str[pos - 3] < 0xF5) {\n char_size = 4;\n } else {\n char_size = 1;\n }\n\n pos -= char_size;\n memcpy(ret + ret_size, str + pos + 1, char_size);\n ret_size += char_size;\n } \n\n ret[ret_size] = '\\0';\n\n return ret;\n}\n\nvoid assert_true(bool boolean)\n{\n puts(boolean == true ? \"true\" : \"false\");\n}\n"
},
{
"answer_id": 19717084,
"author": "Michael Haephrati",
"author_id": 1592639,
"author_profile": "https://Stackoverflow.com/users/1592639",
"pm_score": 2,
"selected": false,
"text": "CString CString::MakeReverse()"
},
{
"answer_id": 23706832,
"author": "Stephen J",
"author_id": 1028958,
"author_profile": "https://Stackoverflow.com/users/1028958",
"pm_score": -1,
"selected": false,
"text": "void showReverse(char s[], int length)\n{\n printf(\"Reversed String without storing is \");\n //could use another variable to test for length, keeping length whole.\n //assumes contiguous memory\n for (; length > 0; length--)\n {\n printf(\"%c\", *(s+ length-1) );\n }\n printf(\"\\n\");\n}\n"
},
{
"answer_id": 65927657,
"author": "Cameron Lowell Palmer",
"author_id": 410867,
"author_profile": "https://Stackoverflow.com/users/410867",
"pm_score": 0,
"selected": false,
"text": "void StringReverser(std::string *original)\n{\n int eos = original->length() - 1;\n while (eos > 0) {\n char c = (*original)[0];\n int characterBytes;\n switch( (c & 0xF0) >> 4 ) {\n case 0xC:\n case 0xD: /* U+000080-U+0007FF: two bytes. */\n characterBytes = 2;\n break;\n case 0xE: /* U+000800-U+00FFFF: three bytes. */\n characterBytes = 3;\n break;\n case 0xF: /* U+010000-U+10FFFF: four bytes. */\n characterBytes = 4;\n break;\n default:\n characterBytes = 1;\n break;\n }\n\n for (int i = 0; i < characterBytes; i++) {\n original->insert(eos+i, 1, (*original)[i]);\n }\n original->erase(0, characterBytes);\n eos -= characterBytes;\n }\n}\n"
},
{
"answer_id": 66070496,
"author": "RobinSingh",
"author_id": 866614,
"author_profile": "https://Stackoverflow.com/users/866614",
"pm_score": 0,
"selected": false,
"text": "void reverseString(vector<char>& s) {\n int l = s.size();\n char ch ;\n int i = 0 ;\n int j = l-1;\n while(i < j){\n s[i] = s[i]^s[j];\n s[j] = s[i]^s[j];\n s[i] = s[i]^s[j];\n i++;\n j--;\n }\n for(char c : s)\n cout <<c ;\n cout<< endl;\n}\n"
},
{
"answer_id": 69962399,
"author": "Kateridzhe",
"author_id": 14200717,
"author_profile": "https://Stackoverflow.com/users/14200717",
"pm_score": -1,
"selected": false,
"text": "#include <algorithm>\n#include <string>\n\nvoid backwards(vector<string> &inputs_ref) {\n for (auto i = inputs_ref.begin(); i != inputs_ref.end(); ++i) {\n reverse(i->begin(), i->end());\n }\n}\n"
},
{
"answer_id": 73584850,
"author": "Driver",
"author_id": 19091624,
"author_profile": "https://Stackoverflow.com/users/19091624",
"pm_score": 0,
"selected": false,
"text": "std::string reverse_string(std::string &str)\n{ \n const char*buf = str.c_str();\n char *start = const_cast<char*>(buf);\n char *end = start + strlen(buf) - 1;\n char t;\n\n while(start < end)\n {\n t = *start;\n *start = *end;\n *end = t;\n start ++;\n end --;\n }\n str = buf;\n return str;\n}\n std::string md1 = \"abcdefghijklmnopqrstuvwxyz0123456789\";\nstd::cout << reverse_string(md1) << std::endl;\n\n//9876543210zyxwvutsrqponmlkjihgfedcba\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
198,215
|
<pre><code>int main()
{
HandPhone A,B;
A>>B;//overloading operator>> to simulate sending sms to another handphone(object)
return 0;
}
</code></pre>
<p>How should I declare the istream operator to simulate sending sms to another handphone(object)?</p>
|
[
{
"answer_id": 198227,
"author": "luke",
"author_id": 16434,
"author_profile": "https://Stackoverflow.com/users/16434",
"pm_score": 2,
"selected": false,
"text": "class A;\nclass B;\n\nA operator << (A& a, const B& b) // a << b; sends b to a.\n{\n a.sendMessage(b);\n return a;\n}\n"
},
{
"answer_id": 198539,
"author": "Martin York",
"author_id": 14065,
"author_profile": "https://Stackoverflow.com/users/14065",
"pm_score": 3,
"selected": false,
"text": "void operator >> (HandPhone& a, HandPhone& b)\n{\n // Add code here.\n}\n B.sendMessageTo(A,Message(\"PLOP\"));\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
198,233
|
<p>How can I make my window not have a title bar but appear in the task bar with some descriptive text?
If you set the Form's .Text property then .net gives it a title bar, which I don't want.</p>
<pre><code> this.ControlBox = false;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.ShowInTaskbar = true;
this.Text = "My title for task bar";
</code></pre>
<p>I've found a partial solution, to override CreateParams: </p>
<pre><code> protected override System.Windows.Forms.CreateParams CreateParams
{
get
{
System.Windows.Forms.CreateParams cp = base.CreateParams;
cp.Style &= ~0x00C00000; // WS_CAPTION
return cp;
}
}
</code></pre>
<p>However this causes my window to be resized as if they have a title bar, ie it's taller than it should be. Is there any good solution to this?</p>
|
[
{
"answer_id": 198287,
"author": "amcoder",
"author_id": 26898,
"author_profile": "https://Stackoverflow.com/users/26898",
"pm_score": 2,
"selected": false,
"text": "this.FormBorderStyle = FormBorderStyle.None;\n"
},
{
"answer_id": 198290,
"author": "Jon Schneider",
"author_id": 12484,
"author_profile": "https://Stackoverflow.com/users/12484",
"pm_score": 4,
"selected": true,
"text": "FormBorderStyle Form None FixedDialog"
},
{
"answer_id": 3162167,
"author": "LorenzCK",
"author_id": 3118,
"author_profile": "https://Stackoverflow.com/users/3118",
"pm_score": 3,
"selected": false,
"text": "FormBorderStyle = FormBorderStyle.SizableToolWindow CreateParams protected override System.Windows.Forms.CreateParams CreateParams\n{\n get\n {\n var parms = base.CreateParams;\n parms.Style &= ~0x00C00000; // remove WS_CAPTION\n parms.Style |= 0x00040000; // include WS_SIZEBOX\n return parms;\n }\n}\n"
}
] |
2008/10/13
|
[
"https://Stackoverflow.com/questions/198233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8479/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.