qid
int64 4
22.2M
| question
stringlengths 18
48.3k
| answers
list | date
stringlengths 10
10
| metadata
list |
|---|---|---|---|---|
82,550
|
<p>I have a template class that I serialize (call it C), for which I want to specify a version for boost serialization. As BOOST_CLASS_VERSION does not work for template classes. I tried this:</p>
<pre><code>namespace boost {
namespace serialization {
template< typename T, typename U >
struct version< C<T,U> >
{
typedef mpl::int_<1> type;
typedef mpl::integral_c_tag tag;
BOOST_STATIC_CONSTANT(unsigned int, value = version::type::value);
};
}
}
</code></pre>
<p>but it does not compile. Under VC8, a subsequent call to BOOST_CLASS_VERSION gives this error:</p>
<p><code>error C2913: explicit specialization; 'boost::serialization::version' is not a specialization of a class template</code></p>
<p>What is the correct way to do it?</p>
|
[
{
"answer_id": 83616,
"author": "James Hopkin",
"author_id": 11828,
"author_profile": "https://Stackoverflow.com/users/11828",
"pm_score": 5,
"selected": true,
"text": "#include <boost/serialization/version.hpp>\n"
},
{
"answer_id": 37660167,
"author": "dlabs",
"author_id": 2000886,
"author_profile": "https://Stackoverflow.com/users/2000886",
"pm_score": 2,
"selected": false,
"text": "error C2988: unrecognizable template declaration/definition\nerror C2143: syntax error: missing ';' before '<'\nerror C2913: explicit specialization; 'Romer::RDS::Settings::boost::serialization::version' is not a specialization of a class template\nerror C2059: syntax error: '<'\nerror C2143: syntax error: missing ';' before '{'\nerror C2447: '{': missing function header (old-style formal list?)\n"
},
{
"answer_id": 70143058,
"author": "alfC",
"author_id": 225186,
"author_profile": "https://Stackoverflow.com/users/225186",
"pm_score": 0,
"selected": false,
"text": "namespace boost {\nnamespace serialization {\n\ntemplate<typename T> struct version;\n\n} // end namespace serialization\n} // end namespace boost\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14443/"
] |
82,607
|
<p>I get DNS records from a Python program, using <a href="http://www.dnspython.org/" rel="nofollow noreferrer">DNS
Python</a></p>
<p>I can get various DNSSEC-related records:</p>
<pre><code>>>> import dns.resolver
>>> myresolver = dns.resolver.Resolver()
>>> myresolver.use_edns(1, 0, 1400)
>>> print myresolver.query('sources.org', 'DNSKEY')
<dns.resolver.Answer object at 0xb78ed78c>
>>> print myresolver.query('ripe.net', 'NSEC')
<dns.resolver.Answer object at 0x8271c0c>
</code></pre>
<p>But no RRSIG records:</p>
<pre><code>>>> print myresolver.query('sources.org', 'RRSIG')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/dns/resolver.py", line 664, in query
answer = Answer(qname, rdtype, rdclass, response)
File "/usr/lib/python2.5/site-packages/dns/resolver.py", line 121, in __init__
raise NoAnswer
</code></pre>
<p>I tried several signed domains like absolight.fr or ripe.net.</p>
<p>Trying with dig, I see that there are indeed RRSIG records.</p>
<p>Checking with tcpdump, I can see that DNS Python sends the correct
query and receives correct replies (here, eight records):</p>
<pre><code>16:09:39.342532 IP 192.134.4.69.53381 > 192.134.4.162.53: 22330+ [1au] RRSIG? sources.org. (40)
16:09:39.343229 IP 192.134.4.162.53 > 192.134.4.69.53381: 22330 8/5/6 RRSIG[|domain]
</code></pre>
<p>DNS Python 1.6.0 -
Python 2.5.2 (r252:60911, Aug 8 2008, 09:22:44)
[GCC 4.3.1] on linux2</p>
|
[
{
"answer_id": 82868,
"author": "Cetra",
"author_id": 15087,
"author_profile": "https://Stackoverflow.com/users/15087",
"pm_score": 0,
"selected": false,
"text": "print myresolver.query('sources.org', 'ANY', 'RRSIG')\n"
},
{
"answer_id": 84448,
"author": "bortzmeyer",
"author_id": 15625,
"author_profile": "https://Stackoverflow.com/users/15625",
"pm_score": 2,
"selected": false,
"text": ">>> print myresolver.query('sources.org', 'RRSIG', 'ANY')\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\n File \"/usr/lib/python2.5/site-packages/dns/resolver.py\", line 664, in query\n answer = Answer(qname, rdtype, rdclass, response)\n File \"/usr/lib/python2.5/site-packages/dns/resolver.py\", line 121, in __init__\n raise NoAnswer\ndns.resolver.NoAnswer\n"
},
{
"answer_id": 37234210,
"author": "Babak Farrokhi",
"author_id": 5711389,
"author_profile": "https://Stackoverflow.com/users/5711389",
"pm_score": 0,
"selected": false,
"text": "raise_on_no_answer=False"
},
{
"answer_id": 42237591,
"author": "Abhinandan Dubey",
"author_id": 5102599,
"author_profile": "https://Stackoverflow.com/users/5102599",
"pm_score": 1,
"selected": false,
"text": "myresolver.query('sources.org', 'RRSIG')\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15625/"
] |
82,612
|
<p>How can I figure out, how many files needs to be recompiled <em>before</em> I start the build process.</p>
<p>Sometimes I don't remember how many basic header files I changed so a Rebuild All would be better than a simple build. There seams to be no option for this, but IMHO it must be possible (f.e. XCode give me this information).</p>
<p><strong>Update:</strong></p>
<p>My problem is not, that Visual Studio doesn't know what to compile. I need to know how much it <em>will</em> compile so that I can decide if I can make a quick test with my new code or if I should write more code till I start the "expensive" build process. Or if my boss ask "When can I have the new build?" the best answer is not "It is done when it is done!".</p>
<p>It's really helpful when the IDE can say <em>"compile 200 of 589 files"</em> instead of <em>"compile x,y, ..."</em></p>
|
[
{
"answer_id": 82868,
"author": "Cetra",
"author_id": 15087,
"author_profile": "https://Stackoverflow.com/users/15087",
"pm_score": 0,
"selected": false,
"text": "print myresolver.query('sources.org', 'ANY', 'RRSIG')\n"
},
{
"answer_id": 84448,
"author": "bortzmeyer",
"author_id": 15625,
"author_profile": "https://Stackoverflow.com/users/15625",
"pm_score": 2,
"selected": false,
"text": ">>> print myresolver.query('sources.org', 'RRSIG', 'ANY')\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\n File \"/usr/lib/python2.5/site-packages/dns/resolver.py\", line 664, in query\n answer = Answer(qname, rdtype, rdclass, response)\n File \"/usr/lib/python2.5/site-packages/dns/resolver.py\", line 121, in __init__\n raise NoAnswer\ndns.resolver.NoAnswer\n"
},
{
"answer_id": 37234210,
"author": "Babak Farrokhi",
"author_id": 5711389,
"author_profile": "https://Stackoverflow.com/users/5711389",
"pm_score": 0,
"selected": false,
"text": "raise_on_no_answer=False"
},
{
"answer_id": 42237591,
"author": "Abhinandan Dubey",
"author_id": 5102599,
"author_profile": "https://Stackoverflow.com/users/5102599",
"pm_score": 1,
"selected": false,
"text": "myresolver.query('sources.org', 'RRSIG')\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15757/"
] |
82,645
|
<p>By default tomcat will create a session cookie for the current domain.</p>
<p>If you are on www.example.com, your cookie will be created for www.example.com (will only work on www.example.com). Whereas for example.com it will be created for .example.com (desired behaviour, will work on any subdomain of example.com as well as example.com itself).</p>
<p>I've seen a few Tomcat valves which seem to intercept the creation of session cookies and create a replacement cookie with the correct .example.com domain, however none of them seem to work flawlessly and they all appear to leave the existing cookie and just create a new one. This means that two JSESSIONID cookies are being sent with each request.</p>
<p>I was wondering if anybody has a definitive solution to this problem.</p>
|
[
{
"answer_id": 633468,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "configureSessionCookie(Cookie cookie)\n"
},
{
"answer_id": 2902605,
"author": "Jason Butler",
"author_id": 349654,
"author_profile": "https://Stackoverflow.com/users/349654",
"pm_score": 3,
"selected": false,
"text": "Header edit Set-Cookie \"(JSESSIONID\\s?=[^;,]+?)((?:;\\s?(?:(?i)Comment|Max-Age|Path|Version|Secure)[^;,]*?)*)(;\\s?(?:(?i)Domain\\s?=)[^;,]+?)?((?:;\\s?(?:(?i)Comment|Max-Age|Path|Version|Secure)[^;,]*?)*)(,|$)\" \"$1$2; Domain=.example.com$4$5\"\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82645",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15687/"
] |
82,653
|
<p>Is there any list of blog engines, written in Django?</p>
|
[
{
"answer_id": 21028758,
"author": "Akshar Raaj",
"author_id": 839549,
"author_profile": "https://Stackoverflow.com/users/839549",
"pm_score": 1,
"selected": false,
"text": "django-blogango"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/70293/"
] |
82,654
|
<p>I have seen examples of printing from a windows application but I have not been able to find a good example of any way of doing this. </p>
|
[
{
"answer_id": 82741,
"author": "Ilya Kochetov",
"author_id": 15329,
"author_profile": "https://Stackoverflow.com/users/15329",
"pm_score": 0,
"selected": false,
"text": "window.print()"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12255/"
] |
82,661
|
<p>I want to clear the list of projects on the start page...how do I do this? I know I can track it down in the registry, but is there an approved route to go?</p>
|
[
{
"answer_id": 84797,
"author": "Dusty Campbell",
"author_id": 2174,
"author_profile": "https://Stackoverflow.com/users/2174",
"pm_score": 7,
"selected": true,
"text": "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\<version>\\ProjectMRUList\n"
},
{
"answer_id": 31514199,
"author": "Riegardt Steyn",
"author_id": 1904753,
"author_profile": "https://Stackoverflow.com/users/1904753",
"pm_score": 2,
"selected": false,
"text": "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\14.0\\MRUItems"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15778/"
] |
82,721
|
<p>In a SQL server database, I have a table which contains a TEXT field which is set to allow NULLs. I need to change this to not allow NULLs. I can do this no problem via Enterprise Manager, but when I try to run the following script, <strong>alter table dbo.[EventLog] Alter column [Message] text Not null</strong>, I get an error:</p>
<p><em>Cannot alter column 'ErrorMessage' because it is 'text'.</em></p>
<p>Reading SQL Books Online does indeed reveal you are not allow to do an ALTER COLUMN on TEXT fields. I really need to be able to do this via a script though, and not manually in Enterprise Manager. What are the options for doing this in script then?</p>
|
[
{
"answer_id": 82862,
"author": "Sixto Saez",
"author_id": 9711,
"author_profile": "https://Stackoverflow.com/users/9711",
"pm_score": 3,
"selected": true,
"text": " /* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/\nBEGIN TRANSACTION\nSET QUOTED_IDENTIFIER ON\nSET ARITHABORT ON\nSET NUMERIC_ROUNDABORT OFF\nSET CONCAT_NULL_YIELDS_NULL ON\nSET ANSI_NULLS ON\nSET ANSI_PADDING ON\nSET ANSI_WARNINGS ON\nCOMMIT\nBEGIN TRANSACTION\nGO\nCREATE TABLE dbo.Tmp_TestTable\n (\n tableKey int NOT NULL,\n Description varchar(50) NOT NULL,\n TextData text NOT NULL\n ) ON [PRIMARY]\n TEXTIMAGE_ON [PRIMARY]\nGO\nIF EXISTS(SELECT * FROM dbo.TestTable)\n EXEC('INSERT INTO dbo.Tmp_TestTable (tableKey, Description, TextData)\n SELECT tableKey, Description, TextData FROM dbo.TestTable WITH (HOLDLOCK TABLOCKX)')\nGO\nDROP TABLE dbo.TestTable\nGO\nEXECUTE sp_rename N'dbo.Tmp_TestTable', N'TestTable', 'OBJECT' \nGO\nALTER TABLE dbo.TestTable ADD CONSTRAINT\n PK_TestTable PRIMARY KEY CLUSTERED \n (\n tableKey\n ) ON [PRIMARY]\n\nGO\nCOMMIT\n"
},
{
"answer_id": 82976,
"author": "cheeves",
"author_id": 15826,
"author_profile": "https://Stackoverflow.com/users/15826",
"pm_score": 1,
"selected": false,
"text": "CREATE TABLE tmp1( col1 INT identity ( 1, 1 ), col2 TEXT ) \nGO \n\nINSERT \nINTO tmp1 \nSELECT NULL \n\nGO 10 \n\nSELECT * \nFROM tmp1 \n\nUPDATE tmp1 \nSET col2 = '' \nWHERE col2 IS NULL \n\nALTER TABLE tmp1 \nALTER COLUMN col2 TEXT NOT NULL \n\nSELECT *\nFROM tmp1 \n\nDROP TABLE tmp1 \n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7585/"
] |
82,726
|
<p>If I open files I created in Windows, the lines all end with <code>^M</code>.<br />
How do I delete these characters all at once?</p>
|
[
{
"answer_id": 82740,
"author": "mercutio",
"author_id": 1951,
"author_profile": "https://Stackoverflow.com/users/1951",
"pm_score": 4,
"selected": false,
"text": ":%s/\\r\\+//g\n"
},
{
"answer_id": 82742,
"author": "Rob Wells",
"author_id": 2974,
"author_profile": "https://Stackoverflow.com/users/2974",
"pm_score": 2,
"selected": false,
"text": ":g/Ctrl-v Ctrl-m/s///\n"
},
{
"answer_id": 82743,
"author": "pjz",
"author_id": 8002,
"author_profile": "https://Stackoverflow.com/users/8002",
"pm_score": 11,
"selected": true,
"text": ":%s/^M//g"
},
{
"answer_id": 82751,
"author": "JayG",
"author_id": 5823,
"author_profile": "https://Stackoverflow.com/users/5823",
"pm_score": 2,
"selected": false,
"text": ":%s/^V^M//g"
},
{
"answer_id": 82755,
"author": "David Webb",
"author_id": 3171,
"author_profile": "https://Stackoverflow.com/users/3171",
"pm_score": 3,
"selected": false,
"text": ":%s/^M$//g\n"
},
{
"answer_id": 82803,
"author": "Sylvain Defresne",
"author_id": 5353,
"author_profile": "https://Stackoverflow.com/users/5353",
"pm_score": 7,
"selected": false,
"text": ":set fileformat=unix\n"
},
{
"answer_id": 82809,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": ":set fileformat=unix"
},
{
"answer_id": 95650,
"author": "Ludvig A. Norin",
"author_id": 16909,
"author_profile": "https://Stackoverflow.com/users/16909",
"pm_score": 8,
"selected": false,
"text": ":e ++ff=dos\n:e ++ff=mac\n:e ++ff=unix\n"
},
{
"answer_id": 1203971,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 7,
"selected": false,
"text": ":%s/\\r/\\r/g\n"
},
{
"answer_id": 1205562,
"author": "dsm",
"author_id": 7780,
"author_profile": "https://Stackoverflow.com/users/7780",
"pm_score": 0,
"selected": false,
"text": "dos2unix"
},
{
"answer_id": 1907154,
"author": "Venkataramesh Kommoju",
"author_id": 229608,
"author_profile": "https://Stackoverflow.com/users/229608",
"pm_score": 3,
"selected": false,
"text": "dos2unix"
},
{
"answer_id": 9336644,
"author": "ajitomatix",
"author_id": 159698,
"author_profile": "https://Stackoverflow.com/users/159698",
"pm_score": 3,
"selected": false,
"text": ":e ++ff=dos Edit file again, using dos file format ('fileformats' is ignored).[A 1]\n:setlocal ff=unix This buffer will use LF-only line endings when written.[A 2]\n:w Write buffer using Unix (LF-only) line endings.\n"
},
{
"answer_id": 10730977,
"author": "Michael Douma",
"author_id": 797092,
"author_profile": "https://Stackoverflow.com/users/797092",
"pm_score": 3,
"selected": false,
"text": "tr -d '\\15\\32' < winfile.txt > unixfile.txt\n"
},
{
"answer_id": 11475637,
"author": "Dannid",
"author_id": 1231241,
"author_profile": "https://Stackoverflow.com/users/1231241",
"pm_score": 3,
"selected": false,
"text": ":%s/Ctrl-V Ctrl-M/\\r/g\n"
},
{
"answer_id": 20872386,
"author": "Sparkida",
"author_id": 1934975,
"author_profile": "https://Stackoverflow.com/users/1934975",
"pm_score": 3,
"selected": false,
"text": "find $(pwd) -type f -name \"*.ext\" | while read file; do sed -e 's/^M//g' -i \"$file\"; done;\n"
},
{
"answer_id": 28496179,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "for file in *.sh; do awk '{ sub(\"\\r$\", \"\"); print }' $file >luxubutmp; cp -f luxubutmp $file; rm -f luxubutmp ;done\n"
},
{
"answer_id": 35276349,
"author": "loadaverage",
"author_id": 1971057,
"author_profile": "https://Stackoverflow.com/users/1971057",
"pm_score": 0,
"selected": false,
"text": "%s/\\r\\+$//g\n"
},
{
"answer_id": 36958439,
"author": "Stefan Sjöberg",
"author_id": 6275842,
"author_profile": "https://Stackoverflow.com/users/6275842",
"pm_score": 3,
"selected": false,
"text": "nano file.txt"
},
{
"answer_id": 37692061,
"author": "Thomas PABST",
"author_id": 6437949,
"author_profile": "https://Stackoverflow.com/users/6437949",
"pm_score": 0,
"selected": false,
"text": "autocmd BufWrite * :set ff=unix\n"
},
{
"answer_id": 41165066,
"author": "Christy Wald",
"author_id": 7109320,
"author_profile": "https://Stackoverflow.com/users/7109320",
"pm_score": 2,
"selected": false,
"text": "vim somefile.txt +\"%s/\\r/\\r/g\" +wq\n"
},
{
"answer_id": 42174679,
"author": "user3379574",
"author_id": 3379574,
"author_profile": "https://Stackoverflow.com/users/3379574",
"pm_score": 0,
"selected": false,
"text": "perl -pi.bak -e 's/\\x0d/\\n/g' excel_created.txt\n"
},
{
"answer_id": 45855010,
"author": "Santle Camilus",
"author_id": 6680821,
"author_profile": "https://Stackoverflow.com/users/6680821",
"pm_score": 0,
"selected": false,
"text": "dos2unix filename.ext\n"
},
{
"answer_id": 46918174,
"author": "Albaro Pereyra",
"author_id": 4696986,
"author_profile": "https://Stackoverflow.com/users/4696986",
"pm_score": 0,
"selected": false,
"text": "tr -d \\\\r < dosfile > newfile\n -- Originally by Dru <genesis@istar.ca>\n"
},
{
"answer_id": 48302445,
"author": "Tallak Tveide",
"author_id": 1388584,
"author_profile": "https://Stackoverflow.com/users/1388584",
"pm_score": 1,
"selected": false,
"text": ":w !dos2unix %\n"
},
{
"answer_id": 52856156,
"author": "CBuzatu",
"author_id": 1274699,
"author_profile": "https://Stackoverflow.com/users/1274699",
"pm_score": 3,
"selected": false,
"text": "vim file.txt +\"set ff=unix\" +wq\n"
},
{
"answer_id": 65125795,
"author": "Victor S.",
"author_id": 7676971,
"author_profile": "https://Stackoverflow.com/users/7676971",
"pm_score": 4,
"selected": false,
"text": ":e ++ff=dos | set ff=unix | w!\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15482/"
] |
82,814
|
<p>The following code is causing an intermittent crash on a Vista machine.</p>
<pre><code>using (SoundPlayer myPlayer = new SoundPlayer(Properties.Resources.BEEPPURE))
myPlayer.Play();
</code></pre>
<p>I highly suspect it is this code because the program crashes mid-beep or just before the beep is played every time. I have top-level traps for all <code>ThreadExceptions</code>, <code>UnhandledExceptions</code> in my app domain, and a <code>try-catch</code> around <code>Application.Run</code>, none of which trap this crash.</p>
<p>Any ideas?</p>
<hr>
<p>EDIT:</p>
<p>The Event Viewer has the following information:</p>
<blockquote>
<p>Faulting application [xyz].exe, version 4.0.0.0, time stamp
0x48ce5a74, faulting module msvcrt.dll, version 7.0.6001.18000, time
stamp 0x4791a727, exception code 0xc0000005, fault offset 0x00009b30,
process id 0x%9, application start time 0x%10.</p>
</blockquote>
<p>Interestingly, the <code>HRESULT 0xc0000005</code> has the message: </p>
<blockquote>
<p>"Reading or writing to an inaccessible memory location."
(STATUS_ACCESS_VIOLATION)</p>
</blockquote>
|
[
{
"answer_id": 163516,
"author": "MusiGenesis",
"author_id": 14606,
"author_profile": "https://Stackoverflow.com/users/14606",
"pm_score": 0,
"selected": false,
"text": "using (SoundPlayer myPlayer = new SoundPlayer(BEEPPURE))\n{ \n myPlayer.Play();\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1490/"
] |
82,831
|
<p>How do I check whether a file exists or not, without using the <a href="https://docs.python.org/3.6/reference/compound_stmts.html#try" rel="noreferrer"><code>try</code></a> statement?</p>
|
[
{
"answer_id": 82836,
"author": "Paul",
"author_id": 215086,
"author_profile": "https://Stackoverflow.com/users/215086",
"pm_score": 10,
"selected": false,
"text": "import os\n\nif os.path.isfile(filepath):\n print(\"File exists\")\n"
},
{
"answer_id": 82841,
"author": "benefactual",
"author_id": 6445,
"author_profile": "https://Stackoverflow.com/users/6445",
"pm_score": 8,
"selected": false,
"text": "import os\nos.path.exists(path) # Returns whether the path (directory or file) exists or not\nos.path.isfile(path) # Returns whether the file exists or not\n"
},
{
"answer_id": 82846,
"author": "PierreBdR",
"author_id": 7136,
"author_profile": "https://Stackoverflow.com/users/7136",
"pm_score": 11,
"selected": false,
"text": "os.path.exists"
},
{
"answer_id": 82852,
"author": "rslite",
"author_id": 15682,
"author_profile": "https://Stackoverflow.com/users/15682",
"pm_score": 13,
"selected": false,
"text": "if file_exists: open_it()"
},
{
"answer_id": 83012,
"author": "zgoda",
"author_id": 12138,
"author_profile": "https://Stackoverflow.com/users/12138",
"pm_score": 5,
"selected": false,
"text": "os.access()"
},
{
"answer_id": 84173,
"author": "bortzmeyer",
"author_id": 15625,
"author_profile": "https://Stackoverflow.com/users/15625",
"pm_score": 10,
"selected": false,
"text": "isfile()"
},
{
"answer_id": 4799818,
"author": "philberndt",
"author_id": 589765,
"author_profile": "https://Stackoverflow.com/users/589765",
"pm_score": 6,
"selected": false,
"text": "try:\n # http://effbot.org/zone/python-with-statement.htm\n # 'with' is safer to open a file\n with open('whatever.txt') as fh:\n # Do something with 'fh'\nexcept IOError as e:\n print(\"({})\".format(e))\n"
},
{
"answer_id": 7201731,
"author": "Jesvin Jose",
"author_id": 604511,
"author_profile": "https://Stackoverflow.com/users/604511",
"pm_score": 3,
"selected": false,
"text": "import os\npath = /path/to/dir\n\nroot,dirs,files = os.walk(path).next()\nif myfile in files:\n print \"yes it exists\"\n"
},
{
"answer_id": 8876254,
"author": "Yugal Jindle",
"author_id": 731963,
"author_profile": "https://Stackoverflow.com/users/731963",
"pm_score": 9,
"selected": false,
"text": "os.path.isfile()"
},
{
"answer_id": 17344732,
"author": "un33k",
"author_id": 103734,
"author_profile": "https://Stackoverflow.com/users/103734",
"pm_score": 7,
"selected": false,
"text": "import os\nfname = \"foo.txt\"\nif os.path.isfile(fname):\n print(\"file does exist at this time\")\nelse:\n print(\"no such file exists at this time\")\n"
},
{
"answer_id": 18994918,
"author": "chad",
"author_id": 225730,
"author_profile": "https://Stackoverflow.com/users/225730",
"pm_score": 6,
"selected": false,
"text": "isfile()"
},
{
"answer_id": 21641213,
"author": "Cody Piersall",
"author_id": 1612701,
"author_profile": "https://Stackoverflow.com/users/1612701",
"pm_score": 8,
"selected": false,
"text": "import pathlib\np = pathlib.Path('path/to/file')\nif p.is_file(): # or p.is_dir() to see if it is a directory\n # do stuff\n"
},
{
"answer_id": 21688350,
"author": "Chris",
"author_id": 476266,
"author_profile": "https://Stackoverflow.com/users/476266",
"pm_score": 4,
"selected": false,
"text": "try:"
},
{
"answer_id": 23826292,
"author": "Zaheer",
"author_id": 3197473,
"author_profile": "https://Stackoverflow.com/users/3197473",
"pm_score": 3,
"selected": false,
"text": "file = open(inputFile, 'r')\nfile.close()\n"
},
{
"answer_id": 26335110,
"author": "bergercookie",
"author_id": 2843583,
"author_profile": "https://Stackoverflow.com/users/2843583",
"pm_score": 5,
"selected": false,
"text": "with open('somefile', 'xt') as f: # Using the x-flag, Python 3.3 and above\n f.write('Hello\\n')\n\nif not os.path.exists('somefile'): \n with open('somefile', 'wt') as f:\n f.write(\"Hello\\n\")\nelse:\n print('File already exists!')\n"
},
{
"answer_id": 26433646,
"author": "Hanson",
"author_id": 3901280,
"author_profile": "https://Stackoverflow.com/users/3901280",
"pm_score": 3,
"selected": false,
"text": "from sys import argv\n\nfrom os.path import exists\nscript, filename = argv\ntarget = open(filename)\nprint \"file exists: %r\" % exists(filename)\n"
},
{
"answer_id": 27581592,
"author": "Pradip Das",
"author_id": 2230891,
"author_profile": "https://Stackoverflow.com/users/2230891",
"pm_score": 4,
"selected": false,
"text": ">>> import os\n>>> os.path.exists(\"C:\\\\Users\\\\####\\\\Desktop\\\\test.txt\") \nTrue\n>>> os.path.exists(\"C:\\\\Users\\\\####\\\\Desktop\\\\test.tx\")\nFalse\n"
},
{
"answer_id": 27661444,
"author": "Zizouz212",
"author_id": 4293417,
"author_profile": "https://Stackoverflow.com/users/4293417",
"pm_score": 6,
"selected": false,
"text": "try"
},
{
"answer_id": 29909391,
"author": "Pedro Lobito",
"author_id": 797495,
"author_profile": "https://Stackoverflow.com/users/797495",
"pm_score": 5,
"selected": false,
"text": "if os.path.isfile(path_to_file):\n try:\n open(path_to_file)\n pass\n except IOError as e:\n print \"Unable to open file\"\n"
},
{
"answer_id": 30444116,
"author": "karlzafiris",
"author_id": 4141689,
"author_profile": "https://Stackoverflow.com/users/4141689",
"pm_score": 7,
"selected": false,
"text": "import os\n#Your path here e.g. \"C:\\Program Files\\text.txt\"\n#For access purposes: \"C:\\\\Program Files\\\\text.txt\"\nif os.path.exists(\"C:\\...\"):\n print \"File found!\"\nelse:\n print \"File not found!\"\n"
},
{
"answer_id": 31824912,
"author": "Khaled.K",
"author_id": 2128327,
"author_profile": "https://Stackoverflow.com/users/2128327",
"pm_score": 4,
"selected": false,
"text": "import os.path\n\ndef isReadableFile(file_path, file_name):\n full_path = file_path + \"/\" + file_name\n try:\n if not os.path.exists(file_path):\n print \"File path is invalid.\"\n return False\n elif not os.path.isfile(full_path):\n print \"File does not exist.\"\n return False\n elif not os.access(full_path, os.R_OK):\n print \"File cannot be read.\"\n return False\n else:\n print \"File can be read.\"\n return True\n except IOError as ex:\n print \"I/O error({0}): {1}\".format(ex.errno, ex.strerror)\n except Error as ex:\n print \"Error({0}): {1}\".format(ex.errno, ex.strerror)\n return False\n#------------------------------------------------------\n\npath = \"/usr/khaled/documents/puzzles\"\nfileName = \"puzzle_1.txt\"\n\nisReadableFile(path, fileName)\n"
},
{
"answer_id": 31932925,
"author": "Russia Must Remove Putin",
"author_id": 541136,
"author_profile": "https://Stackoverflow.com/users/541136",
"pm_score": 7,
"selected": false,
"text": "Path"
},
{
"answer_id": 32288118,
"author": "Love and peace - Joe Codeswell",
"author_id": 601770,
"author_profile": "https://Stackoverflow.com/users/601770",
"pm_score": 4,
"selected": false,
"text": "python -c \"import os.path; print os.path.isfile('/path_to/file.xxx')\"\n"
},
{
"answer_id": 35602588,
"author": "KaiBuxe",
"author_id": 5968477,
"author_profile": "https://Stackoverflow.com/users/5968477",
"pm_score": 6,
"selected": false,
"text": "os.path.isfile"
},
{
"answer_id": 37050053,
"author": "Mike McKerns",
"author_id": 2379433,
"author_profile": "https://Stackoverflow.com/users/2379433",
"pm_score": 4,
"selected": false,
"text": "Popen"
},
{
"answer_id": 37702905,
"author": "iPhynx",
"author_id": 5489173,
"author_profile": "https://Stackoverflow.com/users/5489173",
"pm_score": 3,
"selected": false,
"text": "import os\nif 'file.ext' in os.listdir('dirpath'):\n #code\n"
},
{
"answer_id": 38793323,
"author": "Marcel Wilson",
"author_id": 2532408,
"author_profile": "https://Stackoverflow.com/users/2532408",
"pm_score": 4,
"selected": false,
"text": "file_path"
},
{
"answer_id": 39932496,
"author": "Tom Fuller",
"author_id": 5177604,
"author_profile": "https://Stackoverflow.com/users/5177604",
"pm_score": 7,
"selected": false,
"text": "os.path.isfile()"
},
{
"answer_id": 40926284,
"author": "Taufiq Rahman",
"author_id": 5401681,
"author_profile": "https://Stackoverflow.com/users/5401681",
"pm_score": 4,
"selected": false,
"text": "import os\nos.path.isfile('./file.txt') # Returns True if exists, else False\n"
},
{
"answer_id": 44661513,
"author": "CristiFati",
"author_id": 4788546,
"author_profile": "https://Stackoverflow.com/users/4788546",
"pm_score": 8,
"selected": false,
"text": "os.path.isfile"
},
{
"answer_id": 45605450,
"author": "durjoy",
"author_id": 6291574,
"author_profile": "https://Stackoverflow.com/users/6291574",
"pm_score": 5,
"selected": false,
"text": "pathlib"
},
{
"answer_id": 47629576,
"author": "AbstProcDo",
"author_id": 7301792,
"author_profile": "https://Stackoverflow.com/users/7301792",
"pm_score": 6,
"selected": false,
"text": "import os\n\nos.path.isfile('~/file.md') # Returns True if exists, else False\n\n# Additionally, check a directory\nos.path.isdir('~/folder') # Returns True if the folder exists, else False\n\n# Check either a directory or a file\nos.path.exists('~/file')\n"
},
{
"answer_id": 49092615,
"author": "Ali Hallaji",
"author_id": 3043331,
"author_profile": "https://Stackoverflow.com/users/3043331",
"pm_score": 4,
"selected": false,
"text": "os.path.isfile"
},
{
"answer_id": 53084404,
"author": "Vimal Maheedharan",
"author_id": 3682968,
"author_profile": "https://Stackoverflow.com/users/3682968",
"pm_score": 3,
"selected": false,
"text": "import os\n\n# For testing purposes the arguments defaulted to the current folder and file.\n# returns True if file found\ndef file_exists(FOLDER_PATH='../', FILE_NAME=__file__):\n return os.path.isdir(FOLDER_PATH) \\\n and os.path.isfile(os.path.join(FOLDER_PATH, FILE_NAME))\n"
},
{
"answer_id": 59923701,
"author": "Gopinath",
"author_id": 6571165,
"author_profile": "https://Stackoverflow.com/users/6571165",
"pm_score": 3,
"selected": false,
"text": "# File name: check-if-file-exists.py\n\nfrom pathlib import Path\n\nfilePath = Path(input(\"Enter path of the file to be found: \"))\n\nif filePath.exists() and filePath.is_file():\n print(\"Success: File exists\")\nelse:\n print(\"Error: File does not exist\")\n"
},
{
"answer_id": 61754517,
"author": "Devbrat Shukla",
"author_id": 6487422,
"author_profile": "https://Stackoverflow.com/users/6487422",
"pm_score": 3,
"selected": false,
"text": "def fileAtLocation(filename,path):\n return os.path.exists(path + filename)\n \n\nfilename=\"dummy.txt\"\npath = \"/home/ie/SachinSaga/scripts/subscription_unit_reader_file/\"\n\n\nif fileAtLocation(filename,path):\n print('file found at location..')\nelse:\n print('file not found at location..')\n"
},
{
"answer_id": 65857751,
"author": "Memin",
"author_id": 2234161,
"author_profile": "https://Stackoverflow.com/users/2234161",
"pm_score": 7,
"selected": false,
"text": "pathlib"
},
{
"answer_id": 66993660,
"author": "IsraelW",
"author_id": 13950438,
"author_profile": "https://Stackoverflow.com/users/13950438",
"pm_score": 2,
"selected": false,
"text": "import os\nif 'foo.txt' in os.listdir():\n # Do things\n"
},
{
"answer_id": 73083229,
"author": "Ban_Midou",
"author_id": 3035075,
"author_profile": "https://Stackoverflow.com/users/3035075",
"pm_score": 0,
"selected": false,
"text": "# This script concatenates JavaScript files into a unified JavaScript file to reduce server round-trips\n\nimport os\nimport string\nimport math\nimport ntpath\nimport sys\n\n#import pyodbc\n\nimport gzip\nimport shutil\n\nimport hashlib\n\n# BUF_SIZE is totally arbitrary, change for your app!\nBUF_SIZE = 65536 # Let’s read stuff in 64 kilobyte chunks\n\n# Iterate over all JavaScript files in the folder and combine them\nfilenames = []\nshortfilenames = []\n\nimgfilenames = []\nimgshortfilenames = []\n\n# Get a unified path so we can stop dancing with user paths.\n# Determine where files are on this machine (%TEMP% directory and application installation directory)\nif '.exe' in sys.argv[0]: # if getattr(sys, 'frozen', False):\n RootPath = os.path.abspath(os.path.join(__file__, \"..\\\\\"))\n\nelif __file__:\n RootPath = os.path.abspath(os.path.join(__file__, \"..\\\\\"))\n\nprint (\"\\n storage of image files RootPath: %s\\n\" %RootPath)\n\nFolderPath = \"D:\\\\TFS-FARM1\\\\StoneSoup_STS\\\\SDLC\\\\Build\\\\Code\\\\StoneSoup_Refactor\\\\StoneSoupUI\\\\Images\"\nprint (\"\\n storage of image files in folder to search: %s\\n\" %FolderPath)\n\nfor root, directories, filenames2 in os.walk(FolderPath):\n for filename in filenames2:\n fullname = os.path.join(root, filename)\n filenames.append(fullname)\n shortfilenames.append(filename)\n\nfor i, fname in enumerate(shortfilenames):\n print(\"%s - %s\" % (i+1, fname))\n\nfor root, directories, filenames2 in os.walk(RootPath):\n for filename in filenames2:\n fullname = os.path.join(root, filename)\n imgfilenames.append(fullname)\n imgshortfilenames.append(filename)\n\nfor i, fname in enumerate(imgshortfilenames):\n print(\"%s - %s\" % (i+1, fname))\n\nfor i, fname in enumerate(imgshortfilenames):\n if fname in shortfilenames:\n print(\"%s - %s exists\" % (i+1, fname))\n else:\n print(\"%s - %s ABSENT\" % (i+1, fname))\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15616/"
] |
82,847
|
<p>If I am in a function in the code behind, and I want to implement displaying a "Loading..." in the status bar the following makes sense, but as we know from WinForms is a NoNo:</p>
<pre><code>StatusBarMessageText.Text = "Loading Configuration Settings...";
LoadSettingsGridData();
StatusBarMessageText.Text = "Done";
</code></pre>
<p>What we all now from WinForms Chapter 1 class 101, is the form won't display changes to the user until after the Entire Function completes... meaning the "Loading" message will never be displayed to the user. The following code is needed.</p>
<pre><code>Form1.SuspendLayout();
StatusBarMessageText.Text = "Loading Configuration Settings...";
Form1.ResumeLayout();
LoadSettingsGridData();
Form1.SuspendLayout();
StatusBarMessageText.Text = "Done";
Form1.ResumeLayout();
</code></pre>
<p>What is the best practice for dealing with this fundamental issue in WPF?</p>
|
[
{
"answer_id": 83216,
"author": "Abe Heidebrecht",
"author_id": 9268,
"author_profile": "https://Stackoverflow.com/users/9268",
"pm_score": -1,
"selected": false,
"text": "StatusBarMessageText.Text = \"Loading Configuration Settings...\";\nthis.Dispatcher.BeginInvoke(new Action(LoadSettingsGridData), DispatcherPriority.Render);\nthis.Dispatcher.BeginInvoke(new Action(() => StatusBarMessageText.Text = \"Done\"), DispatcherPriority.Render);\n"
},
{
"answer_id": 89053,
"author": "mrbradleyt",
"author_id": 2744,
"author_profile": "https://Stackoverflow.com/users/2744",
"pm_score": 0,
"selected": false,
"text": "BackgroundWorker _backgroundWorker = new BackgroundWorker();\n\n...\n\n// Set up the Background Worker Events\n_backgroundWorker.DoWork += _backgroundWorker_DoWork;\nbackgroundWorker.RunWorkerCompleted += \n _backgroundWorker_RunWorkerCompleted;\n\n// Run the Background Worker\n_backgroundWorker.RunWorkerAsync(5000);\n\n...\n\n// Worker Method\nvoid _backgroundWorker_DoWork(object sender, DoWorkEventArgs e)\n{\n // Do something\n}\n\n// Completed Method\nvoid _backgroundWorker_RunWorkerCompleted(\n object sender, \n RunWorkerCompletedEventArgs e)\n{\n if (e.Cancelled)\n {\n statusText.Text = \"Cancelled\";\n }\n else if (e.Error != null) \n {\n statusText.Text = \"Exception Thrown\";\n }\n else \n {\n statusText.Text = \"Completed\";\n }\n}\n"
},
{
"answer_id": 3383010,
"author": "Ernest",
"author_id": 408037,
"author_profile": "https://Stackoverflow.com/users/408037",
"pm_score": 5,
"selected": false,
"text": "using(var d = Dispatcher.DisableProcessing())\n{\n /* your work... Use dispacher.begininvoke... */\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2744/"
] |
82,872
|
<p>I have a old website that generate its own RSS everytime a new post is created. Everything worked when I was on a server with PHP 4 but now that the host change to PHP 5, I always have a "bad formed XML". I was using xml_parser_create() and xml_parse(...) and fwrite(..) to save everything.</p>
<p>Here is the example when saving (I read before save to append old RSS line of course).</p>
<pre><code>function SaveXml()
{
if (!is_file($this->getFileName()))
{
//Création du fichier
$file_handler = fopen($this->getFileName(),"w");
fwrite($file_handler,"");
fclose($file_handler);
}//Fin du if
//Header xml version="1.0" encoding="utf-8"
$strFileData = '<?xml version="1.0" encoding="iso-8859-1" ?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>'.$this->getProjectName().'</title><link>http://www.mywebsite.com</link><description>My description</description><lastBuildDate>' . date("r"). '</lastBuildDate>';
//Data
reset($this->arrData);
foreach($this->arrData as $i => $value)
{
$strFileData .= '<item>';
$strFileData .= '<title>'. $this->GetNews($i,0) . '</title>';
$strFileData .= '<pubDate>'. $this->GetNews($i,1) . '</pubDate>';
$strFileData .= '<dc:creator>'. $this->GetNews($i,2) . '</dc:creator>';
$strFileData .= '<description><![CDATA['. $this->GetNews($i,3) . ']]> </description>';
$strFileData .= '<link><![CDATA['. $this->GetNews($i,4) . ']]></link>';
$strFileData .= '<guid>'. $this->GetNews($i,4) . '</guid>';
//$strFileData .= '<category>'. $this->GetNews($i,5) . '</category>';
$strFileData .= '<category>Mycategory</category>';
$strFileData .= '</item>';
}//Fin du for i
$strFileData .= '</channel></rss>';
if (file_exists($this->getFileName()))//Détruit le fichier
unlink($this->getFileName());
$file_handler = fopen($this->getFileName(),"w");
fwrite($file_handler,$strFileData);
fclose($file_handler);
}//Fin de SaveXml
</code></pre>
<p>My question is : how do you create and fill up your RSS in PHP?</p>
|
[
{
"answer_id": 82904,
"author": "Andrew Taylor",
"author_id": 1776,
"author_profile": "https://Stackoverflow.com/users/1776",
"pm_score": 0,
"selected": false,
"text": "SimpleXML"
},
{
"answer_id": 84601,
"author": "Veynom",
"author_id": 11670,
"author_profile": "https://Stackoverflow.com/users/11670",
"pm_score": 3,
"selected": true,
"text": "function feed_simnews() {\n $objRSS = new UniversalFeedCreator();\n $objRSS->title = 'My News';\n $objRSS->link = 'http://link.to/news.php';\n $objRSS->description = 'daily news from me';\n $objRSS->xsl = 'http://link.to/feeds/feedxsl.xsl';\n $objRSS->language = 'en';\n $objRSS->copyright = 'Copyright: Mine!';\n $objRSS->webmaster = 'webmaster@somewhere.com';\n $objRSS->syndicationURL = 'http://link.to/news/simnews.php';\n $objRSS->ttl = 180;\n\n $objImage = new FeedImage();\n $objImage->title = 'my logo';\n $objImage->url = 'http://link.to/feeds/logo.jpg';\n $objImage->link = 'http://link.to';\n $objImage->description = 'Feed provided by link.to. Click to visit.';\n $objImage->width = 120;\n $objImage->height = 60;\n $objRSS->image = $objImage;\n\n //Function retrieving an array of your news from date start to last week\n $colNews = getYourNews(array('start_date' => 'Last week'));\n\n foreach($colNews as $p) {\n $objItem = new FeedItem();\n $objItem->title = $p->title;\n $objItem->description = $p->body;\n $objItem->link = $p->link;\n $objItem->date = $p->date;\n $objItem->author = $p->author;\n $objItem->guid = $p->guid;\n\n $objRSS->addItem($objItem);\n }\n\n $objRSS->saveFeed('RSS2.0', 'http://link.to/feeds/news.xml', false);\n};\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13913/"
] |
82,875
|
<p>What SQL can be used to list the tables, and the rows within those tables in an SQLite database file - once I have attached it with the <code>ATTACH</code> command on the SQLite 3 command line tool?</p>
|
[
{
"answer_id": 82889,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 9,
"selected": false,
"text": "SELECT * FROM dbname.sqlite_master WHERE type='table';\n"
},
{
"answer_id": 82899,
"author": "Mark Janssen",
"author_id": 15828,
"author_profile": "https://Stackoverflow.com/users/15828",
"pm_score": 10,
"selected": false,
"text": ".tables\n"
},
{
"answer_id": 82917,
"author": "Rafał Dowgird",
"author_id": 12166,
"author_profile": "https://Stackoverflow.com/users/12166",
"pm_score": 5,
"selected": false,
"text": "SELECT name FROM sqlite_master\nWHERE type='table';\n"
},
{
"answer_id": 82930,
"author": "Christian Davén",
"author_id": 12534,
"author_profile": "https://Stackoverflow.com/users/12534",
"pm_score": 8,
"selected": false,
"text": "SELECT name FROM sqlite_master WHERE type = \"table\"\n"
},
{
"answer_id": 82935,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 6,
"selected": false,
"text": ".tables ?PATTERN? List names of tables matching a LIKE pattern\n"
},
{
"answer_id": 83195,
"author": "Anthony Williams",
"author_id": 5597,
"author_profile": "https://Stackoverflow.com/users/5597",
"pm_score": 10,
"selected": true,
"text": ".tables"
},
{
"answer_id": 494643,
"author": "Noah",
"author_id": 12113,
"author_profile": "https://Stackoverflow.com/users/12113",
"pm_score": 4,
"selected": false,
"text": ".dump"
},
{
"answer_id": 2986841,
"author": "Luiz Geron",
"author_id": 142548,
"author_profile": "https://Stackoverflow.com/users/142548",
"pm_score": 5,
"selected": false,
"text": "PRAGMA table_info(table-name);"
},
{
"answer_id": 7252488,
"author": "Antony.H",
"author_id": 822864,
"author_profile": "https://Stackoverflow.com/users/822864",
"pm_score": 6,
"selected": false,
"text": ".help"
},
{
"answer_id": 14623907,
"author": "Alix Axel",
"author_id": 89771,
"author_profile": "https://Stackoverflow.com/users/89771",
"pm_score": 4,
"selected": false,
"text": "SHOW TABLES;"
},
{
"answer_id": 25734826,
"author": "pepper",
"author_id": 2146169,
"author_profile": "https://Stackoverflow.com/users/2146169",
"pm_score": 4,
"selected": false,
"text": ".fullschema\n"
},
{
"answer_id": 31763337,
"author": "GameLoading",
"author_id": 563848,
"author_profile": "https://Stackoverflow.com/users/563848",
"pm_score": 5,
"selected": false,
"text": "SELECT name FROM sqlite_master WHERE type='table'\n"
},
{
"answer_id": 33097341,
"author": "Mrityunjay Singh",
"author_id": 1590898,
"author_profile": "https://Stackoverflow.com/users/1590898",
"pm_score": 3,
"selected": false,
"text": "import sqlite3\n\nTABLE_LIST_QUERY = \"SELECT * FROM sqlite_master where type='table'\"\n"
},
{
"answer_id": 40031557,
"author": "openwonk",
"author_id": 4259761,
"author_profile": "https://Stackoverflow.com/users/4259761",
"pm_score": 4,
"selected": false,
"text": "union all"
},
{
"answer_id": 47247535,
"author": "Klaas-Z4us-V",
"author_id": 1869683,
"author_profile": "https://Stackoverflow.com/users/1869683",
"pm_score": 3,
"selected": false,
"text": "SELECT distinct tbl_name from sqlite_master order by 1;\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/974/"
] |
82,881
|
<p>Lets say I have a Dictionary object:</p>
<pre><code>Dictionary myDictionary<int, SomeObject> = new Dictionary<string, SomeObject>();
</code></pre>
<p>Now I want to iterate through the dictionary in reverse order. I can't use a simple for loop because I don't know the keys of the dictionary. A <em>foreach</em> is easy:</p>
<pre><code>foreach (SomeObject object in myDictionary.Values)
{
// Do stuff to object
}
</code></pre>
<p>But how can I perform this in reverse?</p>
|
[
{
"answer_id": 82925,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "Dictionary<int, SomeObject> myDictionary"
},
{
"answer_id": 82927,
"author": "Chris Wenham",
"author_id": 5548,
"author_profile": "https://Stackoverflow.com/users/5548",
"pm_score": 4,
"selected": false,
"text": "foreach (object o in myDictionary.Values.Reverse())\n{\n // Do stuff to object\n}\n"
},
{
"answer_id": 82931,
"author": "Stormenet",
"author_id": 2090,
"author_profile": "https://Stackoverflow.com/users/2090",
"pm_score": 1,
"selected": false,
"text": "Dictionary<int, object> d;\nList<object> tmplist;\nforeach (object o in d.Values) tmplist.Add(s);\ntmplist.Reverse();\nforeach (object o in tmplist) {\n //Do stuff\n}\n"
},
{
"answer_id": 82968,
"author": "OwenP",
"author_id": 2547,
"author_profile": "https://Stackoverflow.com/users/2547",
"pm_score": 2,
"selected": false,
"text": "foreach"
},
{
"answer_id": 83041,
"author": "Aaron Powell",
"author_id": 11388,
"author_profile": "https://Stackoverflow.com/users/11388",
"pm_score": 0,
"selected": false,
"text": "for"
},
{
"answer_id": 83055,
"author": "Jonathan",
"author_id": 6910,
"author_profile": "https://Stackoverflow.com/users/6910",
"pm_score": 5,
"selected": true,
"text": "SortedList sCol = new SortedList();\n\nsCol.Add(\"bee\", \"Some extended string matching bee\");\nsCol.Add(\"ay\", \"value matching ay\");\nsCol.Add(\"cee\", \"Just a standard cee\");\n\n// Go through it backwards.\nfor (int i = sCol.Count - 1; i >=0 ; i--)\n Console.WriteLine(\"sCol[\" + i.ToString() + \"] = \" + sCol.GetByIndex(i));\n\n// Reference By Key\nforeach (string i in sCol.Keys)\n Console.WriteLine(\"sCol[\" + i + \"] = \" + sCol[i]);\n\n// Enumerate all values\nforeach (string i in sCol.Values)\n Console.WriteLine(i);\n"
},
{
"answer_id": 83125,
"author": "Dave Van den Eynde",
"author_id": 455874,
"author_profile": "https://Stackoverflow.com/users/455874",
"pm_score": 2,
"selected": false,
"text": "static IEnumerable<T> CreateReverseIterator<T>(IList<T> list)\n{\n int count = list.Count;\n for (int i = count - 1; i >= 0; --i)\n {\n yield return list[i];\n }\n}\n"
},
{
"answer_id": 83467,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 1,
"selected": false,
"text": "Dictionary<int, SomeObject> myDictionary = new Dictionary<int, SomeObject>();\n\nforeach (var pair in myDictionary.OrderByDescending(i => i.Key))\n{\n //Observe pair.Key\n //Do stuff to pair.Value\n}\n"
},
{
"answer_id": 83683,
"author": "Joe",
"author_id": 13087,
"author_profile": "https://Stackoverflow.com/users/13087",
"pm_score": 2,
"selected": false,
"text": "public static IEnumerable<T> Reverse<T>(IEnumerable<T> items)\n{\n IList<T> list = items as IList<T>;\n if (list == null) list = new List<T>(items);\n for (int i = list.Count - 1; i >= 0; i-- )\n {\n yield return list[i];\n }\n}\n"
},
{
"answer_id": 12224766,
"author": "Marvin",
"author_id": 1640001,
"author_profile": "https://Stackoverflow.com/users/1640001",
"pm_score": -1,
"selected": false,
"text": "foreach (Sample in Samples)\n\ntry the following:\n\nInt32 nEndingSample = Samples.Count - 1;\n\nfor (i = nEndingSample; i >= 0; i--)\n{\n x = Samples[i].x;\n y = Samples[i].y;\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2273/"
] |
82,914
|
<p>I don't think this is possible just using the color setting in SpriteBatch, so I'm trying to work out a simple shader that would take every pixel and make it white, while respecting the alpha value of the pixel.</p>
<p>The answer Joel Martinez gave looks right, but how do I incorporate that when I draw the sprite with SpriteBatch?</p>
|
[
{
"answer_id": 83306,
"author": "Joel Martinez",
"author_id": 5416,
"author_profile": "https://Stackoverflow.com/users/5416",
"pm_score": 2,
"selected": false,
"text": "sampler2D baseMap;\n\nstruct PS_INPUT \n{\n float2 Texcoord : TEXCOORD0;\n\n};\n\nfloat4 ps_main( PS_INPUT Input ) : COLOR0\n{\n float4 color = tex2D( baseMap, Input.Texcoord );\n return float4(1.0f, 1.0f, 1.0f, color.w);\n}\n"
},
{
"answer_id": 122769,
"author": "finalman",
"author_id": 20522,
"author_profile": "https://Stackoverflow.com/users/20522",
"pm_score": 1,
"selected": false,
"text": "spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None);\n\ntintWhiteEffect.Begin();\ntintWhiteEffect.CurrentTechnique.Passes[0].Begin();\n\n // DRAW SPRITES HERE USING SPRITEBATCH\n\ntintWhiteEffect.CurrentTechnique.Passes[0].End();\ntintWhiteEffect.End();\n\nspriteBatch.End();\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11911/"
] |
82,929
|
<p>I have a PHP application that displays a list of options to a user. The list is generated from a simple query against SQL 2000. What I would like to do is have a specific option at the top of the list, and then have the remaining options sorted alphabetically.</p>
<p>For example, here's the options if sorted alphabetically: </p>
<pre><code>Calgary
Edmonton
Halifax
Montreal
Toronto
</code></pre>
<p>What I would like the list to be is more like this: </p>
<pre><code>**Montreal**
Calgary
Edmonton
Halifax
Toronto
</code></pre>
<p>Is there a way that I can do this using a single query? Or am I stuck running the query twice and appending the results?</p>
|
[
{
"answer_id": 82944,
"author": "mercutio",
"author_id": 1951,
"author_profile": "https://Stackoverflow.com/users/1951",
"pm_score": 2,
"selected": false,
"text": "SELECT name FROM options ORDER BY name = \"Montreal\", name;\n"
},
{
"answer_id": 82955,
"author": "Garry Shutler",
"author_id": 6369,
"author_profile": "https://Stackoverflow.com/users/6369",
"pm_score": 0,
"selected": false,
"text": "create table Places (\n add Name varchar(30),\n add Priority bit\n)\n\nselect Name\nfrom Places\norder by Priority desc,\n Name\n"
},
{
"answer_id": 82984,
"author": "Matt Rogish",
"author_id": 2590,
"author_profile": "https://Stackoverflow.com/users/2590",
"pm_score": 4,
"selected": true,
"text": "SELECT name\nFROM locations\nORDER BY\n CASE\n WHEN name = 'Montreal' \n THEN 0\n ELSE 1\n END, name\n"
},
{
"answer_id": 58755206,
"author": "Deepstop",
"author_id": 11606193,
"author_profile": "https://Stackoverflow.com/users/11606193",
"pm_score": 0,
"selected": false,
"text": "SELECT name\nFROM locations\nLEFT JOIN (VALUES ('Toronto', 1), ('Montreal', 2)) city (name, rank)\n ON locations.name = city.name\nORDER BY city.rank, locations.name;\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82929",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37/"
] |
82,943
|
<p>Is it possible in c# to initialize an array in, for example, subindex 1?</p>
<p>I'm working with Office interop, and every property is an object array that starts in 1 (I assume it was originally programed in VB.NET), and you cannot modify it, you have to set the entire array for it to accept the changes.</p>
<p>As a workaround I am cloning the original array, modifying that one, and setting it as a whole when I'm done.</p>
<p>But, I was wondering if it was possible to create a new non-zero based array</p>
|
[
{
"answer_id": 82987,
"author": "expedient",
"author_id": 4248,
"author_profile": "https://Stackoverflow.com/users/4248",
"pm_score": 4,
"selected": true,
"text": "Array.CreateInstance"
},
{
"answer_id": 83022,
"author": "xan",
"author_id": 15667,
"author_profile": "https://Stackoverflow.com/users/15667",
"pm_score": 0,
"selected": false,
"text": "myArrayObject[1]; //would return the zeroth element.\n"
},
{
"answer_id": 83660,
"author": "James Boother",
"author_id": 16030,
"author_profile": "https://Stackoverflow.com/users/16030",
"pm_score": 4,
"selected": false,
"text": "// Construct an array containing ints that has a length of 10 and a lower bound of 1\nArray lowerBoundArray = Array.CreateInstance(typeof(int), new int[1] { 10 }, new int[1] { 1 });\n\n// insert 1 into position 1\nlowerBoundArray.SetValue(1, 1);\n\n//insert 2 into position 2\nlowerBoundArray.SetValue(2, 2);\n\n// IndexOutOfRangeException the lower bound of the array \n// is 1 and we are attempting to write into 0\nlowerBoundArray.SetValue(1, 0);\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1782/"
] |
82,949
|
<p>I'm trying to preform setup and teardown for a set of integration tests, using jUnit 4.4 to execute the tests. The teardown needs to be run reliably. I'm having other problems with TestNG, so I'm looking to port back to jUnit. What hooks are available for execution before any tests are run and after all tests have completed?</p>
<p>Note: we're using maven 2 for our build. I've tried using maven's <code>pre-</code> & <code>post-integration-test</code> phases, but, if a test fails, maven stops and doesn't run <code>post-integration-test</code>, which is no help.</p>
|
[
{
"answer_id": 83223,
"author": "Jroc",
"author_id": 12200,
"author_profile": "https://Stackoverflow.com/users/12200",
"pm_score": 3,
"selected": false,
"text": "import org.junit.*;\nimport static org.junit.Assert.*;\nimport java.util.*;\n\nclass SomethingUnitTest {\n @BeforeClass\n public static void runBeforeClass()\n {\n\n }\n\n @AfterClass\n public static void runAfterClass()\n { \n\n }\n\n @Before \n public void setUp()\n {\n\n }\n\n @After\n public void tearDown()\n {\n\n }\n\n @Test\n public void testSomethingOrOther()\n {\n\n }\n\n}\n"
},
{
"answer_id": 83428,
"author": "Jroc",
"author_id": 12200,
"author_profile": "https://Stackoverflow.com/users/12200",
"pm_score": 0,
"selected": false,
"text": "import junit.framework.Test; \nimport junit.framework.TestResult; \nimport junit.framework.TestSuite; \n\npublic class AllTests { \n public static Test suite() { \n TestSuite suite = new TestSuite(\"TestEverything\"); \n //$JUnit-BEGIN$ \n suite.addTestSuite(TestOne.class); \n suite.addTestSuite(TestTwo.class); \n suite.addTestSuite(TestThree.class); \n //$JUnit-END$ \n } \n\n public static void main(String[] args) \n { \n AllTests test = new AllTests(); \n Test testCase = test.suite(); \n TestResult result = new TestResult(); \n setUp(); \n testCase.run(result); \n tearDown(); \n } \n public void setUp() {} \n public void tearDown() {} \n} \n"
},
{
"answer_id": 177069,
"author": "Julie",
"author_id": 8217,
"author_profile": "https://Stackoverflow.com/users/8217",
"pm_score": 7,
"selected": false,
"text": "package com.test;\n\nimport org.junit.AfterClass;\nimport org.junit.BeforeClass;\nimport org.junit.runner.RunWith;\nimport org.junit.runners.Suite;\nimport org.junit.runners.Suite.SuiteClasses;\n\n@RunWith(Suite.class)\n@SuiteClasses({Test1.class, Test2.class})\npublic class TestSuite {\n\n @BeforeClass\n public static void setUp() {\n System.out.println(\"setting up\");\n }\n\n @AfterClass\n public static void tearDown() {\n System.out.println(\"tearing down\");\n }\n\n}\n"
},
{
"answer_id": 3104103,
"author": "Anurag Sharma",
"author_id": 374494,
"author_profile": "https://Stackoverflow.com/users/374494",
"pm_score": 0,
"selected": false,
"text": " <plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-surefire-plugin</artifactId>\n <version>2.5</version>\n <configuration>\n <includes>\n <include>**/*Suite.java</include>\n </includes>\n <excludes>\n <exclude>**/*Test.java</exclude>\n <exclude>**/*Tests.java</exclude>\n </excludes>\n </configuration>\n </plugin>\n"
},
{
"answer_id": 7572021,
"author": "christophe blin",
"author_id": 808697,
"author_profile": "https://Stackoverflow.com/users/808697",
"pm_score": 2,
"selected": false,
"text": "public class AbstractTest {\n private static int nbTests = listClassesIn(<package>).size();\n private static int curTest = 0;\n\n @BeforeClass\n public static void incCurTest() { curTest++; }\n\n @AfterClass\n public static void closeTestSuite() {\n if (curTest == nbTests) { /*cleaning*/ } \n }\n}\n\npublic class Test1 extends AbstractTest {\n @Test\n public void check() {}\n}\npublic class Test2 extends AbstractTest {\n @Test\n public void check() {}\n}\n"
},
{
"answer_id": 40250880,
"author": "FredBoutin",
"author_id": 5930242,
"author_profile": "https://Stackoverflow.com/users/5930242",
"pm_score": 0,
"selected": false,
"text": "public class BaseTestClass\n{\n private static int testClassToRun = 0;\n\n // Counting the classes to run so that we can do the tear down only once\n static {\n try {\n Field field = ClassLoader.class.getDeclaredField(\"classes\");\n field.setAccessible(true);\n\n @SuppressWarnings({ \"unchecked\", \"rawtypes\" })\n Vector<Class> classes = (Vector<Class>) field.get(BlockJUnit4ClassRunner.class.getClassLoader());\n for (Class<?> clazz : classes) {\n if (clazz.getName().endsWith(\"Test\")) {\n testClassToRun++;\n }\n }\n } catch (Exception ignore) {\n }\n }\n\n // Setup that needs to be done only once\n static {\n // one time set up\n }\n\n @AfterClass\n public static void baseTearDown() throws Exception\n {\n if (--testClassToRun == 0) {\n // one time clean up\n }\n }\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4893/"
] |
82,971
|
<p>Is it possible to configure Visual Studio 2008 to automatically remove whitespace characters at the end of each line when saving a file? There doesn't seem to be a built-in option, so are there any extensions available to do this?</p>
|
[
{
"answer_id": 83043,
"author": "oglester",
"author_id": 2017,
"author_profile": "https://Stackoverflow.com/users/2017",
"pm_score": 6,
"selected": false,
"text": ":Zs#$"
},
{
"answer_id": 698243,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": false,
"text": "Private saved As Boolean = False\nPrivate Sub DocumentEvents_DocumentSaved(ByVal document As EnvDTE.Document) _\n Handles DocumentEvents.DocumentSaved\n If Not saved Then\n Try\n DTE.Find.FindReplace(vsFindAction.vsFindActionReplaceAll, _\n \"\\t\", _\n vsFindOptions.vsFindOptionsRegularExpression, _\n \" \", _\n vsFindTarget.vsFindTargetCurrentDocument, , , _\n vsFindResultsLocation.vsFindResultsNone)\n\n ' Remove all the trailing whitespaces.\n DTE.Find.FindReplace(vsFindAction.vsFindActionReplaceAll, _\n \":Zs+$\", _\n vsFindOptions.vsFindOptionsRegularExpression, _\n String.Empty, _\n vsFindTarget.vsFindTargetCurrentDocument, , , _\n vsFindResultsLocation.vsFindResultsNone)\n\n saved = True\n document.Save()\n Catch ex As Exception\n MsgBox(ex.Message, MsgBoxStyle.OkOnly, \"Trim White Space exception\")\n End Try\n Else\n saved = False\n End If\nEnd Sub\n"
},
{
"answer_id": 1712824,
"author": "Jeff Muir",
"author_id": 208363,
"author_profile": "https://Stackoverflow.com/users/208363",
"pm_score": -1,
"selected": false,
"text": " Private Sub DocumentEvents_DocumentSaved(ByVal document As EnvDTE.Document) _\n Handles DocumentEvents.DocumentSaved\n Dim result As vsFindResult\n 'Dim nameresult As String\n\n Try\n document.Activate()\n\n ' Remove all the trailing whitespaces.\n result = DTE.Find.FindReplace(vsFindAction.vsFindActionReplaceAll, _\n \":Zs+$\", _\n vsFindOptions.vsFindOptionsRegularExpression, _\n String.Empty, _\n vsFindTarget.vsFindTargetCurrentDocument, , , _\n vsFindResultsLocation.vsFindResultsNone)\n\n 'nameresult = document.Name & \" \" & Str$(result)\n\n 'MsgBox(nameresult, , \"Filename and result\")\n\n If result = vsFindResult.vsFindResultReplaced Then\n 'MsgBox(\"Document Saved\", MsgBoxStyle.OkOnly, \"Saved Macro\")\n document.Save()\n Else\n 'MsgBox(\"Document Not Saved\", MsgBoxStyle.OkOnly, \"Saved Macro\")\n End If\n\n Catch ex As Exception\n MsgBox(ex.Message, MsgBoxStyle.OkOnly, \"Trim White Space exception\")\n End Try\n\nEnd Sub\n"
},
{
"answer_id": 2280683,
"author": "David Abella",
"author_id": 275239,
"author_profile": "https://Stackoverflow.com/users/275239",
"pm_score": 2,
"selected": false,
"text": "Private Sub DocumentEvents_DocumentSaved(ByVal document As EnvDTE.Document) Handles DocumentEvents.DocumentSaved\n Dim result As vsFindResult\n Try\n If (document.ActiveWindow Is Nothing) Then\n Return\n End If\n If (document.Name.ToLower().EndsWith(\".cs\")) Then\n document.Activate()\n result = DTE.Find.FindReplace(vsFindAction.vsFindActionReplaceAll, \":Zs+$\", vsFindOptions.vsFindOptionsRegularExpression, String.Empty, vsFindTarget.vsFindTargetCurrentDocument, , , vsFindResultsLocation.vsFindResultsNone)\n If result = vsFindResult.vsFindResultReplaced Then\n document.Save()\n End If\n End If\n Catch ex As Exception\n MsgBox(ex.Message & Chr(13) & \"Document: \" & document.FullName, MsgBoxStyle.OkOnly, \"Trim White Space exception\")\n End Try\nEnd Sub\n"
},
{
"answer_id": 2415210,
"author": "Jeff Muir",
"author_id": 208363,
"author_profile": "https://Stackoverflow.com/users/208363",
"pm_score": -1,
"selected": false,
"text": "' Remove all the carriage returns.\nresult = DTE.Find.FindReplace(vsFindAction.vsFindActionReplaceAll, _\n \"\\x000d\\x000a\", _\n vsFindOptions.vsFindOptionsRegularExpression, _\n \"\\x000a\", _\n vsFindTarget.vsFindTargetCurrentDocument, , , _\n vsFindResultsLocation.vsFindResultsNone)\n"
},
{
"answer_id": 2867100,
"author": "Michael Urman",
"author_id": 89999,
"author_profile": "https://Stackoverflow.com/users/89999",
"pm_score": 0,
"selected": false,
"text": "FindReplace"
},
{
"answer_id": 4705503,
"author": "ChrisN",
"author_id": 3853,
"author_profile": "https://Stackoverflow.com/users/3853",
"pm_score": 3,
"selected": false,
"text": "Private Sub DocumentEvents_DocumentSaved(ByVal document As EnvDTE.Document) _\n Handles DocumentEvents.DocumentSaved\n Dim fileName As String\n Dim result As vsFindResult\n\n Try\n fileName = document.Name.ToLower()\n\n If fileName.EndsWith(\".cs\") _\n Or fileName.EndsWith(\".cpp\") _\n Or fileName.EndsWith(\".c\") _\n Or fileName.EndsWith(\".h\") Then\n ' Remove trailing whitespace\n result = DTE.Find.FindReplace( _\n vsFindAction.vsFindActionReplaceAll, _\n \"{:b}+$\", _\n vsFindOptions.vsFindOptionsRegularExpression, _\n String.Empty, _\n vsFindTarget.vsFindTargetFiles, _\n document.FullName, _\n \"\", _\n vsFindResultsLocation.vsFindResultsNone)\n\n If result = vsFindResult.vsFindResultReplaced Then\n ' Triggers DocumentEvents_DocumentSaved event again\n document.Save()\n End If\n End If\n Catch ex As Exception\n MsgBox(ex.Message, MsgBoxStyle.OkOnly, \"Trim White Space exception\")\n End Try\nEnd Sub\n"
},
{
"answer_id": 5776064,
"author": "Julian",
"author_id": 723357,
"author_profile": "https://Stackoverflow.com/users/723357",
"pm_score": 0,
"selected": false,
"text": "Private Sub DocumentEvents_DocumentSaved( _\n ByVal document As EnvDTE.Document) _\n Handles DocumentEvents.DocumentSaved\n ' See if we're saving a text file\n Dim textDocument As EnvDTE.TextDocument = _\n TryCast(document.Object(), EnvDTE.TextDocument)\n\n If textDocument IsNot Nothing Then\n ' Perform search/replace on the text document directly\n ' Convert tabs to spaces\n Dim convertedTabs = textDocument.ReplacePattern(\"\\t\", \" \", _\n vsFindOptions.vsFindOptionsRegularExpression)\n\n ' Remove trailing whitespace from each line\n Dim removedTrailingWS = textDocument.ReplacePattern(\":Zs+$\", \"\", _\n vsFindOptions.vsFindOptionsRegularExpression)\n\n ' Re-save the document if either replace was successful\n ' (NOTE: Should recurse only once; the searches will fail next time)\n If convertedTabs Or removedTrailingWS Then\n document.Save()\n End If\n End If\nEnd Sub\n"
},
{
"answer_id": 6923965,
"author": "Evgenii",
"author_id": 297131,
"author_profile": "https://Stackoverflow.com/users/297131",
"pm_score": 2,
"selected": false,
"text": "Edit"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3853/"
] |
82,981
|
<p>The problem is that I have several "h2" tags that have a <code>display:inline</code> attribute, and on Microsoft's wonderful browsers the space between them doesn't appear. Is there a workaround?</p>
<p>I know there is a "non-breaking space" <code>&nbsp;</code> in HTML but I was wondering if one can make a space that may be a "breaking space".</p>
<p>--- edit ---</p>
<p>The website is <a href="http://newstoday.ro" rel="nofollow noreferrer">http://newstoday.ro</a> and the behaviour is in the footer. If the site is opened in IE the list is continuous, even though there is a space between the words. Please don't comment the rest of the code as I am just the plumber in this situation. Also there is a must for the headings as the client thinks it is better for SEO.</p>
|
[
{
"answer_id": 83032,
"author": "Chris Marasti-Georg",
"author_id": 96,
"author_profile": "https://Stackoverflow.com/users/96",
"pm_score": 0,
"selected": false,
"text": "<html>\n <head><title>Blah</title></head>\n <body>\n <h2 style=\"display:inline;\">Something</h2>\n \n <h2 style=\"display:inline;\">Something Else</h2>\n </body>\n</html>\n"
},
{
"answer_id": 83309,
"author": "Peter Boughton",
"author_id": 9360,
"author_profile": "https://Stackoverflow.com/users/9360",
"pm_score": 0,
"selected": false,
"text": "margin: 0 0.5em"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3718/"
] |
82,993
|
<p>We need to programatically burn files to CD in a C\C++ Windows XP/Vista application we are developing using Borlands Turbo C++.</p>
<p>What is the simplest and best way to do this? We would prefer a native windows API (that doesnt rely on MFC) so as not to rely on any third party software/drivers if one is available.</p>
|
[
{
"answer_id": 85166,
"author": "selwyn",
"author_id": 16314,
"author_profile": "https://Stackoverflow.com/users/16314",
"pm_score": 5,
"selected": true,
"text": "#include <stdio.h>\n#include <imapi.h>\n#include <windows.h>\n\nstruct MEDIAINFO {\n BYTE nSessions;\n BYTE nLastTrack;\n ULONG nStartAddress;\n ULONG nNextWritable;\n ULONG nFreeBlocks;\n};\n//==============================================================================\n// Description: CD burning on Windows XP\n//==============================================================================\n#define CSIDL_CDBURN_AREA 0x003b\nSHSTDAPI_(BOOL) SHGetSpecialFolderPathA(HWND hwnd, LPSTR pszPath, int csidl, BOOL fCreate);\nSHSTDAPI_(BOOL) SHGetSpecialFolderPathW(HWND hwnd, LPWSTR pszPath, int csidl, BOOL fCreate);\n#ifdef UNICODE\n#define SHGetSpecialFolderPath SHGetSpecialFolderPathW\n#else\n#define SHGetSpecialFolderPath SHGetSpecialFolderPathA\n#endif\n//==============================================================================\n// Interface IDiscMaster\nconst IID IID_IDiscMaster = {0x520CCA62,0x51A5,0x11D3,{0x91,0x44,0x00,0x10,0x4B,0xA1,0x1C,0x5E}};\nconst CLSID CLSID_MSDiscMasterObj = {0x520CCA63,0x51A5,0x11D3,{0x91,0x44,0x00,0x10,0x4B,0xA1,0x1C,0x5E}};\n\ntypedef interface ICDBurn ICDBurn;\n// Interface ICDBurn\nconst IID IID_ICDBurn = {0x3d73a659,0xe5d0,0x4d42,{0xaf,0xc0,0x51,0x21,0xba,0x42,0x5c,0x8d}};\nconst CLSID CLSID_CDBurn = {0xfbeb8a05,0xbeee,0x4442,{0x80,0x4e,0x40,0x9d,0x6c,0x45,0x15,0xe9}};\n\nMIDL_INTERFACE(\"3d73a659-e5d0-4d42-afc0-5121ba425c8d\")\nICDBurn : public IUnknown\n{\npublic:\n virtual HRESULT STDMETHODCALLTYPE GetRecorderDriveLetter(\n /* [size_is][out] */ LPWSTR pszDrive,\n /* [in] */ UINT cch) = 0;\n\n virtual HRESULT STDMETHODCALLTYPE Burn(\n /* [in] */ HWND hwnd) = 0;\n\n virtual HRESULT STDMETHODCALLTYPE HasRecordableDrive(\n /* [out] */ BOOL *pfHasRecorder) = 0;\n};\n//==============================================================================\n// Description: Get burn pathname\n// Parameters: pathname - must be at least MAX_PATH in size\n// Returns: Non-zero for an error\n// Notes: CoInitialize(0) must be called once in application\n//==============================================================================\nint GetBurnPath(char *path)\n{\n ICDBurn* pICDBurn;\n int ret = 0;\n\n if (SUCCEEDED(CoCreateInstance(CLSID_CDBurn, NULL,CLSCTX_INPROC_SERVER,IID_ICDBurn,(LPVOID*)&pICDBurn))) {\n BOOL flag;\n if (pICDBurn->HasRecordableDrive(&flag) == S_OK) {\n if (SHGetSpecialFolderPath(0, path, CSIDL_CDBURN_AREA, 0)) {\n strcat(path, \"\\\\\");\n }\n else {\n ret = 1;\n }\n }\n else {\n ret = 2;\n }\n pICDBurn->Release();\n }\n else {\n ret = 3;\n }\n return ret;\n}\n//==============================================================================\n// Description: Get CD pathname\n// Parameters: pathname - must be at least 5 bytes in size\n// Returns: Non-zero for an error\n// Notes: CoInitialize(0) must be called once in application\n//==============================================================================\nint GetCDPath(char *path)\n{\n ICDBurn* pICDBurn;\n int ret = 0;\n\n if (SUCCEEDED(CoCreateInstance(CLSID_CDBurn, NULL,CLSCTX_INPROC_SERVER,IID_ICDBurn,(LPVOID*)&pICDBurn))) {\n BOOL flag;\n WCHAR drive[5];\n if (pICDBurn->GetRecorderDriveLetter(drive, 4) == S_OK) {\n sprintf(path, \"%S\", drive);\n }\n else {\n ret = 1;\n }\n pICDBurn->Release();\n }\n else {\n ret = 3;\n }\n return ret;\n}\n//==============================================================================\n// Description: Burn CD\n// Parameters: None\n// Returns: Non-zero for an error\n// Notes: CoInitialize(0) must be called once in application\n//==============================================================================\nint Burn(void)\n{\n ICDBurn* pICDBurn;\n int ret = 0;\n\n if (SUCCEEDED(CoCreateInstance(CLSID_CDBurn, NULL,CLSCTX_INPROC_SERVER,IID_ICDBurn,(LPVOID*)&pICDBurn))) {\n if (pICDBurn->Burn(NULL) != S_OK) {\n ret = 1;\n }\n pICDBurn->Release();\n }\n else {\n ret = 2;\n }\n return ret;\n}\n//==============================================================================\nbool GetCDRecordableInfo(long *FreeSpaceSize)\n{\n bool Result = false;\n IDiscMaster *idm = NULL;\n IDiscRecorder *idr = NULL;\n IEnumDiscRecorders *pEnumDiscRecorders = NULL;\n ULONG cnt;\n long type;\n long mtype;\n long mflags;\n MEDIAINFO mi;\n\n try {\n CoCreateInstance(CLSID_MSDiscMasterObj, 0, CLSCTX_ALL, IID_IDiscMaster, (void**)&idm);\n idm->Open();\n idm->EnumDiscRecorders(&pEnumDiscRecorders);\n pEnumDiscRecorders->Next(1, &idr, &cnt);\n pEnumDiscRecorders->Release();\n\n idr->OpenExclusive();\n idr->GetRecorderType(&type);\n idr->QueryMediaType(&mtype, &mflags);\n idr->QueryMediaInfo(&mi.nSessions, &mi.nLastTrack, &mi.nStartAddress, &mi.nNextWritable, &mi.nFreeBlocks);\n idr->Release();\n\n idm->Close();\n idm->Release();\n Result = true;\n }\n catch (...) {\n Result = false;\n }\n\n if (Result == true) {\n Result = false;\n if (mtype == 0) {\n // No Media inserted\n Result = false;\n }\n else {\n if ((mflags & 0x04) == 0x04) {\n // Writable Media\n Result = true;\n }\n else {\n Result = false;\n }\n\n if (Result == true) {\n *FreeSpaceSize = (mi.nFreeBlocks * 2048);\n }\n else {\n *FreeSpaceSize = 0;\n }\n }\n }\n\n return Result;\n}\n"
},
{
"answer_id": 102170,
"author": "QAZ",
"author_id": 14260,
"author_profile": "https://Stackoverflow.com/users/14260",
"pm_score": 2,
"selected": false,
"text": "typedef HMODULE (WINAPI * SHSETFOLDERPATHA)( int , HANDLE , DWORD , LPCTSTR );\n\nint SetBurnPath( char * cpPath )\n{\n SHSETFOLDERPATHA pSHSetFolderPath;\n HANDLE hShell = LoadLibraryA( \"shell32.dll\" );\n if( hShell == NULL )\n return -2;\n\n DWORD dwOrdinal = 0x00000000 + 231;\n\n pSHSetFolderPath = (SHSETFOLDERPATHA)GetProcAddress( hShell, (LPCSTR)dwOrdinal );\n if( pSHSetFolderPath == NULL )\n return -3;\n\n if( pSHSetFolderPath( CSIDL_CDBURN_AREA, NULL, 0, cpPath ) == S_OK )\n return 0;\n\n return -1;\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/82993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14260/"
] |
83,009
|
<p>I'm currently using <a href="http://www.usysware.com/dpack/" rel="noreferrer">DPack</a> as this adds a "Collapse All Projects" option to the Solution node in Solution Explorer. It works pretty well but can take a while to execute and doesn't always collapse everything fully.</p>
<p>Are there any better alternatives? Preferably free and easy to install/setup. There are lots out there but which work best and don't have any bugs or performance issues.</p>
|
[
{
"answer_id": 267394,
"author": "Mario",
"author_id": 472,
"author_profile": "https://Stackoverflow.com/users/472",
"pm_score": 2,
"selected": false,
"text": "regpkg CoolCommands.dll /codebase\n"
},
{
"answer_id": 2340496,
"author": "Tom Robinson",
"author_id": 12124,
"author_profile": "https://Stackoverflow.com/users/12124",
"pm_score": 3,
"selected": false,
"text": "Imports System\nImports EnvDTE\nImports EnvDTE80\nImports System.Diagnostics\n\nPublic Module CollapseAll\n Sub CollapseAll()\n\n ' Get the the Solution Explorer tree\n Dim solutionExplorer As UIHierarchy\n solutionExplorer = DTE.Windows.Item(Constants.vsext_wk_SProjectWindow).Object()\n\n ' Check if there is any open solution\n If (solutionExplorer.UIHierarchyItems.Count = 0) Then\n Return\n End If\n\n ' Get the top node (the name of the solution)\n Dim rootNode As UIHierarchyItem = solutionExplorer.UIHierarchyItems.Item(1)\n\n rootNode.DTE.SuppressUI = True\n\n ' Collapse each project node\n Collapse(rootNode, solutionExplorer)\n\n ' Select the solution node, or else when you click \n ' on the solution window\n ' scrollbar, it will synchronize the open document \n ' with the tree and pop\n ' out the corresponding node which is probably not what you want.\n\n rootNode.Select(vsUISelectionType.vsUISelectionTypeSelect)\n rootNode.DTE.SuppressUI = False\n\n End Sub\n\n Sub CollapseSelected()\n\n ' Get the the Solution Explorer tree\n Dim solutionExplorer As UIHierarchy\n solutionExplorer = DTE.Windows.Item(Constants.vsext_wk_SProjectWindow).Object()\n\n ' Check if there is any open solution\n If (solutionExplorer.UIHierarchyItems.Count = 0) Then\n Return\n End If\n\n ' Get the top node (the name of the solution)\n Dim selected As Array = solutionExplorer.SelectedItems\n\n If (selected.Length = 0) Then Return\n\n Dim rootNode As UIHierarchyItem = selected(0)\n rootNode.DTE.SuppressUI = True\n\n ' Collapse each project node\n Collapse(rootNode, solutionExplorer)\n\n ' Select the solution node, or else when you click \n ' on the solution window\n ' scrollbar, it will synchronize the open document \n ' with the tree and pop\n ' out the corresponding node which is probably not what you want.\n\n rootNode.Select(vsUISelectionType.vsUISelectionTypeSelect)\n rootNode.DTE.SuppressUI = False\n\n End Sub\n\n Private Sub Collapse(ByVal item As UIHierarchyItem, ByRef solutionExplorer As UIHierarchy)\n\n For Each innerItem As UIHierarchyItem In item.UIHierarchyItems\n If innerItem.UIHierarchyItems.Count > 0 Then\n\n ' Re-cursive call\n Collapse(innerItem, solutionExplorer)\n\n ' Collapse\n If innerItem.UIHierarchyItems.Expanded Then\n innerItem.UIHierarchyItems.Expanded = False\n If innerItem.UIHierarchyItems.Expanded = True Then\n ' Bug in VS 2005\n innerItem.Select(vsUISelectionType.vsUISelectionTypeSelect)\n solutionExplorer.DoDefaultAction()\n End If\n End If\n\n End If\n Next\n\n End Sub\n\nEnd Module\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12124/"
] |
83,038
|
<p>When supplying dates to a stored procedure via a parameter I'm a little confused over which format to use for the dates. My original VBA syntax used the ADO Connection object to execute the stored procedure:</p>
<pre><code>Set SentDetailRS = Me.ADOConnectionToIntegrity.Execute("dbo.s_SelectAggregatedSentDetailList '" & fCSQLDate(EffectiveDate) & "'", , adCmdText)
</code></pre>
<p>This works fine for me using the date syntax <code>yyyy-mm-dd</code> but when another user executes the code they recieve the error: 13 'Type Mismatch'. </p>
<p>After some experimentation I found that supplying the date in the format <code>dd/mm/yyyy</code> fixes this error for the user but now gives me the error! </p>
<p>Executing the stored procedure using a command object with parameters works regardless of the format of the date (I assume ADO is taking care of the formatting behind the scenes). I thought that using the format <code>yyyy-mm-dd</code> would work universally with SQL Server? </p>
<p>I'm also perplexed as to why this problem appears to be user specific? I noticed that my default language on SQL Server is 'English' whereas the other user's default language is 'British English', could that cause the problem? </p>
<p>I'm using ADO 2.8 with Access 2003 and SQL Server 2000, SQL Server login is via Windows integrated security.</p>
|
[
{
"answer_id": 83489,
"author": "Philippe Grondier",
"author_id": 11436,
"author_profile": "https://Stackoverflow.com/users/11436",
"pm_score": 2,
"selected": true,
"text": "Public function SQLdateFormat(x_date) as string\n\nSQLDateFormat = _\n trim(str(datePart(\"yyyy\",x_date))) & _\n right(str(datePart(\"m\",date)),2) & _\n right(str(datePart(\"d\",date)),2)\n\n ''be carefull, you might get something like '2008 9 3'\nSQLDateFormat = replace(functionSQLDateFormat,\" \",\"0\")\n '' you will have the expected '20080903'\n\nEnd function\n"
},
{
"answer_id": 88598,
"author": "Mark Plumpton",
"author_id": 10422,
"author_profile": "https://Stackoverflow.com/users/10422",
"pm_score": 0,
"selected": false,
"text": "dd mmm yyyy\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
83,040
|
<p>How do I connect to a remote Oracle database instance from PHP?</p>
<p>I need to query (read only) the remote Oracle database for some information; do I need to have an Oracle Instant Client installed?</p>
<p>Is the OCI extension for PHP enough?</p>
|
[
{
"answer_id": 83115,
"author": "Jroc",
"author_id": 12200,
"author_profile": "https://Stackoverflow.com/users/12200",
"pm_score": 2,
"selected": false,
"text": "\n odbc_connect($dsn,$user,$pass);\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83040",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67775/"
] |
83,045
|
<p>I have a costumer showing Notepad with a large set of data that looks totally misaligned if word wrap is on and I want to force it off. Is there a command switch to do this?</p>
|
[
{
"answer_id": 83127,
"author": "Cetra",
"author_id": 15087,
"author_profile": "https://Stackoverflow.com/users/15087",
"pm_score": 3,
"selected": true,
"text": "Hive: HKEY_CURRENT_USER\nKey: SOFTWARE\\Microsoft\\Notepad\nName: fWrap\nType: REG_DWORD\nValue: 0\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9077/"
] |
83,050
|
<p>I had this question in mind and since I just discovered this site I decided to post it here.</p>
<p>Let's say I have a table with a timestamp and a state for a given "object" (generic meaning, not OOP object); is there an optimal way to calculate the time between a state and the next occurrence of another (or same) state (what I call a "trip") with a single SQL statement (inner SELECTs and UNIONs aren't counted)?</p>
<p>Ex: For the following, the trip time between Initial and Done would be 6 days, but between Initial and Review it would be 2 days. </p>
<blockquote>
<p>2008-08-01 13:30:00 - Initial<br>
2008-08-02 13:30:00 - Work<br>
2008-08-03 13:30:00 - Review<br>
2008-08-04 13:30:00 - Work<br>
2008-08-05 13:30:00 - Review<br>
2008-08-06 13:30:00 - Accepted<br>
2008-08-07 13:30:00 - Done</p>
</blockquote>
<p>No need to be generic, just say what <a href="https://stackoverflow.com/questions/980813/what-is-sgbd">SGBD</a> your solution is specific to if not generic.</p>
|
[
{
"answer_id": 83234,
"author": "Andy Irving",
"author_id": 8553,
"author_profile": "https://Stackoverflow.com/users/8553",
"pm_score": 0,
"selected": false,
"text": "CREATE TABLE #testing\n(\n eventdatetime datetime NOT NULL,\n state varchar(10) NOT NULL\n)\n\nINSERT INTO #testing (\n eventdatetime,\n state\n) \nSELECT '20080801 13:30:00', 'Initial' UNION ALL\nSELECT '20080802 13:30:00', 'Work' UNION ALL\nSELECT '20080803 13:30:00', 'Review' UNION ALL\nSELECT '20080804 13:30:00', 'Work' UNION ALL\nSELECT '20080805 13:30:00', 'Review' UNION ALL\nSELECT '20080806 13:30:00', 'Accepted' UNION ALL\nSELECT '20080807 13:30:00', 'Done'\n\nSELECT DATEDIFF(dd, Initial, Review)\nFROM (\nSELECT MIN(CASE WHEN state='Initial' THEN eventdatetime END) AS Initial,\n MIN(CASE WHEN state='Review' THEN eventdatetime END) AS Review\nFROM #testing\n) AS A\n\nDROP TABLE #testing\n"
},
{
"answer_id": 83244,
"author": "Damien_The_Unbeliever",
"author_id": 15498,
"author_profile": "https://Stackoverflow.com/users/15498",
"pm_score": 0,
"selected": false,
"text": "create table A (\n At datetime not null,\n State varchar(20) not null\n)\ngo\ninsert into A(At,State)\nselect '2008-08-01T13:30:00','Initial' union all\nselect '2008-08-02T13:30:00','Work' union all\nselect '2008-08-03T13:30:00','Review' union all\nselect '2008-08-04T13:30:00','Work' union all\nselect '2008-08-05T13:30:00','Review' union all\nselect '2008-08-06T13:30:00','Accepted' union all\nselect '2008-08-07T13:30:00','Done'\ngo\n--Find trip time from Initial to Done\nselect DATEDIFF(day,t1.At,t2.At)\nfrom\n A t1\n inner join\n A t2\n on\n t1.State = 'Initial' and\n t2.State = 'Review' and\n t1.At < t2.At\n left join\n A t3\n on\n t3.State = 'Initial' and\n t3.At > t1.At and\n t4.At < t2.At\n left join\n A t4\n on\n t4.State = 'Review' and\n t4.At < t2.At and\n t4.At > t1.At\nwhere\n t3.At is null and\n t4.At is null\n"
},
{
"answer_id": 83377,
"author": "pdc",
"author_id": 8925,
"author_profile": "https://Stackoverflow.com/users/8925",
"pm_score": 0,
"selected": false,
"text": "INSERT"
},
{
"answer_id": 83521,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": " -- Oracle SQl\n\n CREATE TABLE ObjectState\n (\n startdate date NOT NULL,\n state varchar2(10) NOT NULL\n );\n\n\n\n insert into ObjectState \n select to_date('01-Aug-2008 13:30:00','dd-Mon-rrrr hh24:mi:ss'),'Initial' union all\n select to_date('02-Aug-2008 13:30:00','dd-Mon-rrrr hh24:mi:ss'),'Work' union all\n select to_date('03-Aug-2008 13:30:00','dd-Mon-rrrr hh24:mi:ss'),'Review' union all\n select to_date('04-Aug-2008 13:30:00','dd-Mon-rrrr hh24:mi:ss'),'Work' union all\n select to_date('05-Aug-2008 13:30:00','dd-Mon-rrrr hh24:mi:ss'),'Review' union all\n select to_date('06-Aug-2008 13:30:00','dd-Mon-rrrr hh24:mi:ss'),'Accepted' union all\n select to_date('07-Aug-2008 13:30:00','dd-Mon-rrrr hh24:mi:ss'),'Done';\n\n-- Days in between two states\n\n select o2.startdate - o1.startdate as days\n from ObjectState o1, ObjectState o2\n where o1.state = 'Initial'\n and o2.state = 'Review';\n"
},
{
"answer_id": 83831,
"author": "Philippe Grondier",
"author_id": 11436,
"author_profile": "https://Stackoverflow.com/users/11436",
"pm_score": 0,
"selected": false,
"text": "SELECT Min(Tbl_Step.dateTimeStep) as tripBegin, _ \n Max(Tbl_Step.dateTimeStep) as tripEnd _\nFROM \n Tbl_Step \nWHERE \n id_Activity = 'AAAAAAA'\n"
},
{
"answer_id": 84175,
"author": "David Aldridge",
"author_id": 6742,
"author_profile": "https://Stackoverflow.com/users/6742",
"pm_score": 1,
"selected": false,
"text": "with data as (\nSELECT 1 trip_id, to_date('20080801 13:30:00','YYYYMMDD HH24:mi:ss') dt, 'Initial' step from dual UNION ALL\nSELECT 1 trip_id, to_date('20080802 13:30:00','YYYYMMDD HH24:mi:ss') dt, 'Work' step from dual UNION ALL\nSELECT 1 trip_id, to_date('20080803 13:30:00','YYYYMMDD HH24:mi:ss') dt, 'Review' step from dual UNION ALL\nSELECT 1 trip_id, to_date('20080804 13:30:00','YYYYMMDD HH24:mi:ss') dt, 'Work' step from dual UNION ALL\nSELECT 1 trip_id, to_date('20080805 13:30:00','YYYYMMDD HH24:mi:ss') dt, 'Review' step from dual UNION ALL\nSELECT 1 trip_id, to_date('20080806 13:30:00','YYYYMMDD HH24:mi:ss') dt, 'Accepted' step from dual UNION ALL\nSELECT 1 trip_id, to_date('20080807 13:30:00','YYYYMMDD HH24:mi:ss') dt, 'Done' step from dual )\nselect trip_id,\n step,\n dt - lag(dt) over (partition by trip_id order by dt) trip_time\nfrom data\n/\n\n\n1 Initial \n1 Work 1\n1 Review 1\n1 Work 1\n1 Review 1\n1 Accepted 1\n1 Done 1\n"
},
{
"answer_id": 103133,
"author": "user17957",
"author_id": 17957,
"author_profile": "https://Stackoverflow.com/users/17957",
"pm_score": 1,
"selected": false,
"text": "DROP TABLE ObjectState;\nCREATE TABLE ObjectState (\n object_id integer not null,--foreign key\n event_time timestamp NOT NULL,\n state varchar(10) NOT NULL,\n --Other fields \n CONSTRAINT pk_ObjectState PRIMARY KEY (object_id,event_time)\n);\n"
},
{
"answer_id": 109844,
"author": "Jonathan",
"author_id": 19272,
"author_profile": "https://Stackoverflow.com/users/19272",
"pm_score": 0,
"selected": false,
"text": "set @trip1 = 0; set @trip2 = 0;\nSELECT trip1.`date` as startdate, datediff(trip2.`date`, trip1.`date`) length_of_trip\nFROM\n(SELECT @trip1 := @trip1 + 1 as rank1, `date` from trip where state='Initial') as trip1\nINNER JOIN\n(SELECT @trip2 := @trip2 + 1 as rank2, `date` from trip where state='Done') as trip2\nON rank1 = rank2;\n"
},
{
"answer_id": 153902,
"author": "Grant Johnson",
"author_id": 12518,
"author_profile": "https://Stackoverflow.com/users/12518",
"pm_score": 0,
"selected": false,
"text": "create table contractions time_date timestamp primary key;\n\ncreate view contraction_time as\nSELECT a.time_date, max(b.prev_time) AS prev_time\n FROM contractions a, ( SELECT contractions.time_date AS prev_time\n FROM contractions) b\n WHERE b.prev_time < a.time_date\n GROUP BY a.time_date;\n\ncreate view time_between as \nSELECT contraction_time.time_date, contraction_time.prev_time, contraction_time.time_date - contraction_time.prev_time\n FROM contraction_time;\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15805/"
] |
83,058
|
<p>I have a <code>rails</code> application which is still showing the cachebusting numeric string at the end of the URL for static mode, even though I have put it into the production environment. Can someone tell me what config option I need to set to prevent this behaviour...</p>
|
[
{
"answer_id": 83363,
"author": "Dave Cheney",
"author_id": 6449,
"author_profile": "https://Stackoverflow.com/users/6449",
"pm_score": 2,
"selected": false,
"text": "ENV['RAILS_ASSET_ID'] = ''\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7473/"
] |
83,068
|
<p>I've got a load-balanced (not using Session state) ASP.Net 2.0 app on IIS5 running back to a single Oracle 10g server, using version 10.1.0.301 of the ODAC/ODP.Net drivers. After a long period of inactivity (a few hours), the application, seemingly randomly, will throw an Oracle exception:</p>
<blockquote>
<p>Exception: ORA-03113: end-of-file on communication channel at
Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32
errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx*
pOpoSqlValCtx, Object src, String procedure) at
Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery,
Boolean fillRequest, CommandBehavior behavior) at
Oracle.DataAccess.Client.OracleCommand.System.Data.IDbCommand.ExecuteReader()</p>
<p>...Oracle portion of the stack ends here...</p>
</blockquote>
<p>We are creating new connections on every request, have the open & close wrapped in a try/catch/finally to ensure proper connection closure, and the whole thing is wrapped in a using (OracleConnection yadayada) {...} block. This problem does not appear linked to the restart of the ASP.Net application after being spun down for inactivity.</p>
<p>We have yet to reproduce the problem ourselves. Thoughts, prayers, help?</p>
<hr />
<p><strong>More:</strong> Checked with IT, the firewall isn't set to kill connections between those servers.</p>
|
[
{
"answer_id": 91869,
"author": "mathewbutler",
"author_id": 2288,
"author_profile": "https://Stackoverflow.com/users/2288",
"pm_score": 5,
"selected": true,
"text": "SQLNET.EXPIRE_TIME"
},
{
"answer_id": 93802,
"author": "Ken Wren",
"author_id": 3430,
"author_profile": "https://Stackoverflow.com/users/3430",
"pm_score": 2,
"selected": false,
"text": "[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters]\n\"DeadGWDetectDefault\"=dword:00000001\n\"KeepAliveTime\"=dword:00120000\n"
},
{
"answer_id": 15364395,
"author": "Mathias Stanley",
"author_id": 2161508,
"author_profile": "https://Stackoverflow.com/users/2161508",
"pm_score": 2,
"selected": false,
"text": "select log_mode from v$database;\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35/"
] |
83,073
|
<p>It seems to be the <a href="https://stackoverflow.com/questions/82391/should-tables-be-avoided-in-html-at-any-cost#82402">general opinion</a> that tables should not be used for layout in HTML. </p>
<p>Why?</p>
<p>I have never (or rarely to be honest) seen good arguments for this. The usual answers are:</p>
<ul>
<li><p>It's good to <a href="https://stackoverflow.com/questions/82391/should-tables-be-avoided-in-html-at-any-cost#82422">separate content from layout</a><br>But this is a fallacious argument; <a href="http://www.don-lindsay-archive.org/skeptic/arguments.html#cliche" rel="nofollow noreferrer">Cliche Thinking</a>. I guess it's true that using the table element for layout has little to do with tabular data. So what? Does my boss care? Do my users care?<br><br>Perhaps me or my fellow developers who have to maintain a web page care... Is a table less maintainable? I think using a table is <a href="https://stackoverflow.com/questions/82391/should-tables-be-avoided-in-html-at-any-cost#82571">easier</a> than using divs and CSS.<br><br>By the way... why is using a div or a span good separation of content from layout and a table not? Getting a good layout with only divs often requires a lot of nested divs.</p></li>
<li><p>Readability of the code<br>I think it's the other way around. Most people understand HTML, few understand CSS.</p></li>
<li><p>It's better for SEO not to use tables<br>Why? Can anybody show some evidence that it is? Or a statement from Google that tables are discouraged from an SEO perspective?</p></li>
<li><p>Tables are slower.<br>An extra tbody element has to be inserted. This is peanuts for modern web browsers. Show me some benchmarks where the use of a table significantly slows down a page.</p></li>
<li><p>A layout overhaul is easier without tables, see <a href="http://csszengarden.com/" rel="nofollow noreferrer">css Zen Garden</a>.<br>Most web sites that need an upgrade need new content (HTML) as well. Scenarios where a new version of a web site only needs a new CSS file are not very likely. Zen Garden is a nice web site, but a bit theoretical. Not to mention its <a href="https://stackoverflow.com/questions/83073/div-vs-table#83639">misuse</a> of CSS.</p></li>
</ul>
<p>I am really interested in good arguments to use divs + CSS instead of tables.</p>
|
[
{
"answer_id": 83184,
"author": "Grad van Horck",
"author_id": 12569,
"author_profile": "https://Stackoverflow.com/users/12569",
"pm_score": 2,
"selected": false,
"text": "<div id=\"sidebar\">"
},
{
"answer_id": 83201,
"author": "Swati",
"author_id": 12682,
"author_profile": "https://Stackoverflow.com/users/12682",
"pm_score": 3,
"selected": false,
"text": "<div>"
},
{
"answer_id": 83585,
"author": "Carl Camera",
"author_id": 12804,
"author_profile": "https://Stackoverflow.com/users/12804",
"pm_score": 8,
"selected": false,
"text": "class car {\n int wheels = 4;\n string engine;\n}\n\ncar mybike = new car();\nmybike.wheels = 2;\nmybike.engine = null;\n"
},
{
"answer_id": 83647,
"author": "Rick Glos",
"author_id": 16008,
"author_profile": "https://Stackoverflow.com/users/16008",
"pm_score": 3,
"selected": false,
"text": "</table>"
},
{
"answer_id": 84986,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 10,
"selected": true,
"text": "<table>"
},
{
"answer_id": 91130,
"author": "ofaurax",
"author_id": 15209,
"author_profile": "https://Stackoverflow.com/users/15209",
"pm_score": 0,
"selected": false,
"text": "Menu | Content\n\nContent | Menu\n\nMenu\n----\nContent\n"
},
{
"answer_id": 91262,
"author": "JacquesB",
"author_id": 7488,
"author_profile": "https://Stackoverflow.com/users/7488",
"pm_score": 2,
"selected": false,
"text": "font"
},
{
"answer_id": 91396,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 4,
"selected": false,
"text": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n<head>\n <title>{DYNAMIC(TITLE)}</title>\n <meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\" />\n <meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />\n <link rel=\"stylesheet\" type=\"text/css\" href=\"./styles/base.css\" />\n</head>\n<body>\n <div id=\"header\">\n <h1><!-- Page title --></h1>\n <ol id=\"navigation\">\n <!-- Navigation items -->\n </ol>\n <div class=\"clearfix\"></div>\n </div>\n <div id=\"sidebar\">\n <!-- Sidebar content -->\n </div>\n <!-- Page content -->\n <p id=\"footer\"><!-- Footer content --></p>\n</body>\n</html>\n"
},
{
"answer_id": 107237,
"author": "AmbroseChapel",
"author_id": 242241,
"author_profile": "https://Stackoverflow.com/users/242241",
"pm_score": 2,
"selected": false,
"text": "[ picture ] [ picture ] [ picture ]\n[ caption ] [ caption ] [ caption ]\n"
},
{
"answer_id": 276900,
"author": "Petras",
"author_id": 24696,
"author_profile": "https://Stackoverflow.com/users/24696",
"pm_score": -1,
"selected": false,
"text": "<table> \n <tr><td colspan=\"3\"><div>Top content</div></td></tr>\n <tr> \n <td><div>Left navigation</div></td> \n <td><div>Main content</div></td> \n <td><div>Right navigation</div></td> \n </tr>\n <tr><td colspan=\"3\"><div>Bottom content</div></td></tr>\n</table>\n"
},
{
"answer_id": 5474481,
"author": "Chris Fletcher",
"author_id": 376632,
"author_profile": "https://Stackoverflow.com/users/376632",
"pm_score": 2,
"selected": false,
"text": "$('#myawesomediv').click(function(){\n // Do awesome stuff\n});\n"
},
{
"answer_id": 5620934,
"author": "Sylverdrag",
"author_id": 61905,
"author_profile": "https://Stackoverflow.com/users/61905",
"pm_score": 2,
"selected": false,
"text": "foreach ($comment as $key=>$value)\n{\n echo \"<tr><td>$key</td><td>$value</td></tr>\";\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3565/"
] |
83,093
|
<p>is there a solution for batch insert via hibernate in partitioned postgresql table? currently i'm getting an error like this...</p>
<pre><code>ERROR org.hibernate.jdbc.AbstractBatcher - Exception executing batch:
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46)
at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)....
</code></pre>
<p>i have found this link <a href="http://lists.jboss.org/pipermail/hibernate-dev/2007-October/002771.html" rel="nofollow noreferrer">http://lists.jboss.org/pipermail/hibernate-dev/2007-October/002771.html</a> but i can't find anywhere on the web is this problem solved or how it can be get around</p>
|
[
{
"answer_id": 90031,
"author": "alexguev",
"author_id": 436199,
"author_profile": "https://Stackoverflow.com/users/436199",
"pm_score": 3,
"selected": true,
"text": " @Override\n protected void doExecuteBatch(PreparedStatement ps) throws SQLException, HibernateException {\n if ( batchSize == 0 ) {\n log.debug( \"no batched statements to execute\" );\n }\n else {\n if ( log.isDebugEnabled() ) {\n log.debug( \"Executing batch size: \" + batchSize );\n }\n\n try {\n// checkRowCounts( ps.executeBatch(), ps );\n ps.executeBatch();\n }\n catch (RuntimeException re) {\n log.error( \"Exception executing batch: \", re );\n throw re;\n }\n finally {\n batchSize = 0;\n }\n\n }\n\n }\n"
},
{
"answer_id": 92020,
"author": "tropikalista",
"author_id": 15878,
"author_profile": "https://Stackoverflow.com/users/15878",
"pm_score": 2,
"selected": false,
"text": "BatcherFactory"
},
{
"answer_id": 26123701,
"author": "rogerdpack",
"author_id": 32453,
"author_profile": "https://Stackoverflow.com/users/32453",
"pm_score": 2,
"selected": false,
"text": "create view tablename_view as select * from tablename; -- create trivial wrapping view\n\nCREATE OR REPLACE FUNCTION partitioned_insert_trigger() -- partitioned insert trigger\nRETURNS TRIGGER AS $$\nBEGIN\n IF (NEW.partition_key>= 5500000000 AND\n NEW.partition_key < 6000000000) THEN\n INSERT INTO tablename_55_59 VALUES (NEW.*);\n ELSIF (NEW.partition_key >= 5000000000 AND\n NEW.partition_key < 5500000000) THEN\n INSERT INTO tablename_50_54 VALUES (NEW.*);\n ELSIF (NEW.partition_key >= 500000000 AND\n NEW.partition_key < 1000000000) THEN\n INSERT INTO tablename_5_9 VALUES (NEW.*);\n ELSIF (NEW.partition_key >= 0 AND\n NEW.partition_key < 500000000) THEN\n INSERT INTO tablename_0_4 VALUES (NEW.*);\n ELSE\n RAISE EXCEPTION 'partition key is out of range. Fix the trigger function';\n END IF;\n RETURN NEW; -- RETURN NEW in this case, typically you'd return NULL from this trigger, but for views we return NEW\nEND;\n$$\nLANGUAGE plpgsql;\n\nCREATE TRIGGER insert_view_trigger\n INSTEAD OF INSERT ON tablename_view\n FOR EACH ROW EXECUTE PROCEDURE partitioned_insert_trigger(); -- create \"INSTEAD OF\" trigger\n"
},
{
"answer_id": 52627573,
"author": "blov80",
"author_id": 4556112,
"author_profile": "https://Stackoverflow.com/users/4556112",
"pm_score": 0,
"selected": false,
"text": "DELETE FROM ONLY master_table;\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15878/"
] |
83,106
|
<p>How should widgets in GWT inform other widgets to refresh themselfs or perform some other action. </p>
<p>Should I use sinkEvent / onBrowserEvent?
And if so is there a way to create custom Events?</p>
|
[
{
"answer_id": 86962,
"author": "Alexandra Franks",
"author_id": 16203,
"author_profile": "https://Stackoverflow.com/users/16203",
"pm_score": 2,
"selected": false,
"text": "Class newMessageHandler {\n void update(Widget caller, Widget subscriber) {\n ...\n }\n}\n\ncustomEventHandler.addEventType(\"New Message\", newMessageHandler);\n\nWidget w;\ncustomEventHandler.subscribe(w, \"New Message\");\n\n...\nWidget caller;\n\n// Fire \"New Message\" event for all widgets which have\n// subscribed\ncustomEventHandler.fireEvent(caller, \"New Message\");\n"
},
{
"answer_id": 96991,
"author": "Drejc",
"author_id": 6482,
"author_profile": "https://Stackoverflow.com/users/6482",
"pm_score": 1,
"selected": false,
"text": "import java.util.EventObject;\nimport com.google.gwt.user.client.ui.Widget;\n\npublic class NotificationEvent extends EventObject {\n public NotificationEvent(String data) {\n super(data);\n }\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6482/"
] |
83,117
|
<p>I have a layered application in Java which has a multi thread data access layer which is invoked from different points. A single call to this layer is likely to spawn several threads to parallelize requests to the DB. </p>
<p>What I'm looking for is a logging tool that would allow me to define "activities" that are composed by various threads. Therefore, the same method in the data access layer should log different outputs depending on its caller. The ability to group different outputs to summarize the total cost of an operation is also important.</p>
<p>Although the application is in Java, language is not a restriction; what I need are the design guidelines so to eventually implement it. We are currently using log4j, but can't get this behaviour from it.</p>
|
[
{
"answer_id": 83245,
"author": "Chris Mazzola",
"author_id": 15816,
"author_profile": "https://Stackoverflow.com/users/15816",
"pm_score": 0,
"selected": false,
"text": "StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();\n"
},
{
"answer_id": 83513,
"author": "Rasmus Faber",
"author_id": 5542,
"author_profile": "https://Stackoverflow.com/users/5542",
"pm_score": 0,
"selected": false,
"text": "void debug(Activity activity, String message);\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12791/"
] |
83,132
|
<p>I thought I'd found the solution a while ago (see my <a href="https://tjrobinson.net/programming/technology/2006/09/03/cant-execute-code-from-a-freed-script.html" rel="noreferrer">blog</a>):</p>
<blockquote>
<p>If you ever get the JavaScript (or should that be JScript) error "Can't execute code from a freed script" - try moving any meta tags in the head so that they're before your script tags. </p>
</blockquote>
<p>...but based on one of the most recent blog comments, the fix I suggested may not work for everyone. I thought this would be a good one to open up to the StackOverflow community....</p>
<p>What causes the error "Can't execute code from a freed script" and what are the solutions/workarounds?</p>
|
[
{
"answer_id": 84300,
"author": "Sjoerd Visscher",
"author_id": 5852,
"author_profile": "https://Stackoverflow.com/users/5852",
"pm_score": 5,
"selected": false,
"text": "try\n{\n f();\n}\ncatch(e)\n{\n if (e.number == -2146823277)\n // f is no longer available\n ...\n}\n"
},
{
"answer_id": 1360689,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "\n// This has to be setup from the main window, not a child/etc!\nmainWindow.functionBuilder = function (func, args) {\n // trim the name, if any\n var funcStr = (\"\" + func).replace(/^function\\s+[^\\s(]+\\s*\\(/, \"function (\")\n try {\n var rebuilt\n eval(\"rebuilt = (\" + funcStr + \")\")\n return rebuilt(args)\n } catch (e) {\n alert(\"oops! \" + e.message)\n }\n}\n\n// then in the child, as an example\n// as stated above, even though function (args) looks like it's \n// a closure in the child scope, IT IS NOT. There you go :)\nvar x = {blerg: 2}\nfunctionInMainWindowContenxt = mainWindow.functionBuilder(function (args) {\n // in here args is in the bound scope -- have at the child objects! :-/\n function fn (blah) {\n return blah * args.blerg\n }\n return fn\n}, x)\n\nx.blerg = 7\nfunctionInMainWindowContext(6) // -> 42 if I did my math right\n"
},
{
"answer_id": 2806980,
"author": "aaron",
"author_id": 330176,
"author_profile": "https://Stackoverflow.com/users/330176",
"pm_score": 3,
"selected": false,
"text": "window.parent.mySpecialHandler = function() { ...work... }\n"
},
{
"answer_id": 6668743,
"author": "Tom",
"author_id": 841284,
"author_profile": "https://Stackoverflow.com/users/841284",
"pm_score": 3,
"selected": false,
"text": "rowTime = wl.rowData[a][12].getTime()"
},
{
"answer_id": 15973195,
"author": "Melanie",
"author_id": 282152,
"author_profile": "https://Stackoverflow.com/users/282152",
"pm_score": 0,
"selected": false,
"text": "if (window.parent) {\n localStorage = window.parent.localStorage;\n}\n"
},
{
"answer_id": 16844211,
"author": "wycleffsean",
"author_id": 394184,
"author_profile": "https://Stackoverflow.com/users/394184",
"pm_score": 2,
"selected": false,
"text": "// set the value on first load\nwindow.top.timestamp = new Date();\n\n// after frame reloads, try to access the value\nif(window.top.timestamp) // <--- Raises exception\n...\n"
},
{
"answer_id": 22020346,
"author": "Grzegorz Ciwoniuk",
"author_id": 1452958,
"author_profile": "https://Stackoverflow.com/users/1452958",
"pm_score": 3,
"selected": false,
"text": "var objectCopy = JSON.parse(JSON.stringify(object));\n"
},
{
"answer_id": 30230015,
"author": "panky sharma",
"author_id": 1020477,
"author_profile": "https://Stackoverflow.com/users/1020477",
"pm_score": 0,
"selected": false,
"text": " $(document).ready(function () {\n\n if (parent.dxWindowMngr == undefined) return;\n DhtmlxJS.GetCurrentWindow('wnManageConDlg').show();\n\n});\n"
},
{
"answer_id": 44517989,
"author": "Chan",
"author_id": 3247575,
"author_profile": "https://Stackoverflow.com/users/3247575",
"pm_score": 0,
"selected": false,
"text": "top.$(\"#settings\").on(\"click\",function(){\n $(\"#settings_modal\").modal(\"show\");\n}); \n"
},
{
"answer_id": 52804201,
"author": "pavan kumar",
"author_id": 9556120,
"author_profile": "https://Stackoverflow.com/users/9556120",
"pm_score": 0,
"selected": false,
"text": "<script> window.document.writeln(table) </script>\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12124/"
] |
83,147
|
<p>I remember hearing <a href="http://en.wikipedia.org/wiki/Joel_Spolsky" rel="noreferrer">Joel Spolsky</a> mention in <a href="https://stackoverflow.fogbugz.com/default.asp?W4" rel="noreferrer">podcast 014</a> that he'd barely ever used a foreign key (if I remember correctly). However, to me they seem pretty vital to avoid duplication and subsequent data integrity problems throughout your database.</p>
<p>Do people have some solid reasons as to why (to avoid a discussion in lines with Stack Overflow principles)?</p>
<p><strong>Edit:</strong> <a href="https://stackoverflow.fogbugz.com/default.asp?W13086" rel="noreferrer"><em>"I've yet to have a reason to create a foreign key, so this might be my first reason to actually set up one."</em></a></p>
|
[
{
"answer_id": 83470,
"author": "hamishmcn",
"author_id": 3590,
"author_profile": "https://Stackoverflow.com/users/3590",
"pm_score": 0,
"selected": false,
"text": "customer_type"
},
{
"answer_id": 83527,
"author": "Powerlord",
"author_id": 15880,
"author_profile": "https://Stackoverflow.com/users/15880",
"pm_score": 4,
"selected": false,
"text": "ON DELETE RESTRICT"
},
{
"answer_id": 13087596,
"author": "Nathan Long",
"author_id": 4376,
"author_profile": "https://Stackoverflow.com/users/4376",
"pm_score": 5,
"selected": false,
"text": "accounts"
},
{
"answer_id": 29644286,
"author": "Vikas Kukreti",
"author_id": 4712002,
"author_profile": "https://Stackoverflow.com/users/4712002",
"pm_score": 0,
"selected": false,
"text": "CREATE TABLE inventory_source (\ninventory_source_id int(11) NOT NULL AUTO_INCREMENT,\ndisplay_name varchar(40) NOT NULL,\nstate_id int(11) NOT NULL,\nPRIMARY KEY (inventory_source_id),\nKEY state_id (state_id),\nCONSTRAINT ba_inventory_source_state_fk FOREIGN KEY (state_id) REFERENCES ba_state (state_id)\n) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;\n\nCREATE TABLE contract_lines(\ncontract_line_id int(11) NOT NULL AUTO_INCREMENT,\ninventory_source_id int(11) NULL ,\nPRIMARY KEY (contract_line_id),\nUNIQUE KEY contract_line_id (contract_line_id),\nKEY AI_contract_line_id (contract_line_id),\nKEY contract_lines_inventory_source_fk (inventory_source_id),\nCONSTRAINT contract_lines_inventory_source_fk FOREIGN KEY (inventory_source_id) REFERENCES ba_inventory_source (inventory_source_id)\n) ENGINE=InnoDB AUTO_INCREMENT=135 DEFAULT CHARSET=utf8 ;\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3394/"
] |
83,152
|
<p>Is there an open source library that will help me with reading/parsing PDF documents in .NET/C#?</p>
|
[
{
"answer_id": 84410,
"author": "ceetheman",
"author_id": 16154,
"author_profile": "https://Stackoverflow.com/users/16154",
"pm_score": 6,
"selected": false,
"text": "using System;\nusing System.IO;\nusing iTextSharp.text.pdf;\nusing System.Text.RegularExpressions;\n\nnamespace Spider.Utils\n{\n /// <summary>\n /// Parses a PDF file and extracts the text from it.\n /// </summary>\n public class PDFParser\n {\n /// BT = Beginning of a text object operator \n /// ET = End of a text object operator\n /// Td move to the start of next line\n /// 5 Ts = superscript\n /// -5 Ts = subscript\n\n #region Fields\n\n #region _numberOfCharsToKeep\n /// <summary>\n /// The number of characters to keep, when extracting text.\n /// </summary>\n private static int _numberOfCharsToKeep = 15;\n #endregion\n\n #endregion\n\n #region ExtractText\n /// <summary>\n /// Extracts a text from a PDF file.\n /// </summary>\n /// <param name=\"inFileName\">the full path to the pdf file.</param>\n /// <param name=\"outFileName\">the output file name.</param>\n /// <returns>the extracted text</returns>\n public bool ExtractText(string inFileName, string outFileName)\n {\n StreamWriter outFile = null;\n try\n {\n // Create a reader for the given PDF file\n PdfReader reader = new PdfReader(inFileName);\n //outFile = File.CreateText(outFileName);\n outFile = new StreamWriter(outFileName, false, System.Text.Encoding.UTF8);\n\n Console.Write(\"Processing: \");\n\n int totalLen = 68;\n float charUnit = ((float)totalLen) / (float)reader.NumberOfPages;\n int totalWritten = 0;\n float curUnit = 0;\n\n for (int page = 1; page <= reader.NumberOfPages; page++)\n {\n outFile.Write(ExtractTextFromPDFBytes(reader.GetPageContent(page)) + \" \");\n\n // Write the progress.\n if (charUnit >= 1.0f)\n {\n for (int i = 0; i < (int)charUnit; i++)\n {\n Console.Write(\"#\");\n totalWritten++;\n }\n }\n else\n {\n curUnit += charUnit;\n if (curUnit >= 1.0f)\n {\n for (int i = 0; i < (int)curUnit; i++)\n {\n Console.Write(\"#\");\n totalWritten++;\n }\n curUnit = 0;\n }\n\n }\n }\n\n if (totalWritten < totalLen)\n {\n for (int i = 0; i < (totalLen - totalWritten); i++)\n {\n Console.Write(\"#\");\n }\n }\n return true;\n }\n catch\n {\n return false;\n }\n finally\n {\n if (outFile != null) outFile.Close();\n }\n }\n #endregion\n\n #region ExtractTextFromPDFBytes\n /// <summary>\n /// This method processes an uncompressed Adobe (text) object \n /// and extracts text.\n /// </summary>\n /// <param name=\"input\">uncompressed</param>\n /// <returns></returns>\n public string ExtractTextFromPDFBytes(byte[] input)\n {\n if (input == null || input.Length == 0) return \"\";\n\n try\n {\n string resultString = \"\";\n\n // Flag showing if we are we currently inside a text object\n bool inTextObject = false;\n\n // Flag showing if the next character is literal \n // e.g. '\\\\' to get a '\\' character or '\\(' to get '('\n bool nextLiteral = false;\n\n // () Bracket nesting level. Text appears inside ()\n int bracketDepth = 0;\n\n // Keep previous chars to get extract numbers etc.:\n char[] previousCharacters = new char[_numberOfCharsToKeep];\n for (int j = 0; j < _numberOfCharsToKeep; j++) previousCharacters[j] = ' ';\n\n\n for (int i = 0; i < input.Length; i++)\n {\n char c = (char)input[i];\n if (input[i] == 213)\n c = \"'\".ToCharArray()[0];\n\n if (inTextObject)\n {\n // Position the text\n if (bracketDepth == 0)\n {\n if (CheckToken(new string[] { \"TD\", \"Td\" }, previousCharacters))\n {\n resultString += \"\\n\\r\";\n }\n else\n {\n if (CheckToken(new string[] { \"'\", \"T*\", \"\\\"\" }, previousCharacters))\n {\n resultString += \"\\n\";\n }\n else\n {\n if (CheckToken(new string[] { \"Tj\" }, previousCharacters))\n {\n resultString += \" \";\n }\n }\n }\n }\n\n // End of a text object, also go to a new line.\n if (bracketDepth == 0 &&\n CheckToken(new string[] { \"ET\" }, previousCharacters))\n {\n\n inTextObject = false;\n resultString += \" \";\n }\n else\n {\n // Start outputting text\n if ((c == '(') && (bracketDepth == 0) && (!nextLiteral))\n {\n bracketDepth = 1;\n }\n else\n {\n // Stop outputting text\n if ((c == ')') && (bracketDepth == 1) && (!nextLiteral))\n {\n bracketDepth = 0;\n }\n else\n {\n // Just a normal text character:\n if (bracketDepth == 1)\n {\n // Only print out next character no matter what. \n // Do not interpret.\n if (c == '\\\\' && !nextLiteral)\n {\n resultString += c.ToString();\n nextLiteral = true;\n }\n else\n {\n if (((c >= ' ') && (c <= '~')) ||\n ((c >= 128) && (c < 255)))\n {\n resultString += c.ToString();\n }\n\n nextLiteral = false;\n }\n }\n }\n }\n }\n }\n\n // Store the recent characters for \n // when we have to go back for a checking\n for (int j = 0; j < _numberOfCharsToKeep - 1; j++)\n {\n previousCharacters[j] = previousCharacters[j + 1];\n }\n previousCharacters[_numberOfCharsToKeep - 1] = c;\n\n // Start of a text object\n if (!inTextObject && CheckToken(new string[] { \"BT\" }, previousCharacters))\n {\n inTextObject = true;\n }\n }\n\n return CleanupContent(resultString);\n }\n catch\n {\n return \"\";\n }\n }\n\n private string CleanupContent(string text)\n {\n string[] patterns = { @\"\\\\\\(\", @\"\\\\\\)\", @\"\\\\226\", @\"\\\\222\", @\"\\\\223\", @\"\\\\224\", @\"\\\\340\", @\"\\\\342\", @\"\\\\344\", @\"\\\\300\", @\"\\\\302\", @\"\\\\304\", @\"\\\\351\", @\"\\\\350\", @\"\\\\352\", @\"\\\\353\", @\"\\\\311\", @\"\\\\310\", @\"\\\\312\", @\"\\\\313\", @\"\\\\362\", @\"\\\\364\", @\"\\\\366\", @\"\\\\322\", @\"\\\\324\", @\"\\\\326\", @\"\\\\354\", @\"\\\\356\", @\"\\\\357\", @\"\\\\314\", @\"\\\\316\", @\"\\\\317\", @\"\\\\347\", @\"\\\\307\", @\"\\\\371\", @\"\\\\373\", @\"\\\\374\", @\"\\\\331\", @\"\\\\333\", @\"\\\\334\", @\"\\\\256\", @\"\\\\231\", @\"\\\\253\", @\"\\\\273\", @\"\\\\251\", @\"\\\\221\"};\n string[] replace = { \"(\", \")\", \"-\", \"'\", \"\\\"\", \"\\\"\", \"à\", \"â\", \"ä\", \"À\", \"Â\", \"Ä\", \"é\", \"è\", \"ê\", \"ë\", \"É\", \"È\", \"Ê\", \"Ë\", \"ò\", \"ô\", \"ö\", \"Ò\", \"Ô\", \"Ö\", \"ì\", \"î\", \"ï\", \"Ì\", \"Î\", \"Ï\", \"ç\", \"Ç\", \"ù\", \"û\", \"ü\", \"Ù\", \"Û\", \"Ü\", \"®\", \"™\", \"«\", \"»\", \"©\", \"'\" };\n\n for (int i = 0; i < patterns.Length; i++)\n {\n string regExPattern = patterns[i];\n Regex regex = new Regex(regExPattern, RegexOptions.IgnoreCase);\n text = regex.Replace(text, replace[i]);\n }\n\n return text;\n }\n\n #endregion\n\n #region CheckToken\n /// <summary>\n /// Check if a certain 2 character token just came along (e.g. BT)\n /// </summary>\n /// <param name=\"tokens\">the searched token</param>\n /// <param name=\"recent\">the recent character array</param>\n /// <returns></returns>\n private bool CheckToken(string[] tokens, char[] recent)\n {\n foreach (string token in tokens)\n {\n if ((recent[_numberOfCharsToKeep - 3] == token[0]) &&\n (recent[_numberOfCharsToKeep - 2] == token[1]) &&\n ((recent[_numberOfCharsToKeep - 1] == ' ') ||\n (recent[_numberOfCharsToKeep - 1] == 0x0d) ||\n (recent[_numberOfCharsToKeep - 1] == 0x0a)) &&\n ((recent[_numberOfCharsToKeep - 4] == ' ') ||\n (recent[_numberOfCharsToKeep - 4] == 0x0d) ||\n (recent[_numberOfCharsToKeep - 4] == 0x0a))\n )\n {\n return true;\n }\n }\n return false;\n }\n #endregion\n }\n}\n"
},
{
"answer_id": 5002998,
"author": "ShravankumarKumar ",
"author_id": 617652,
"author_profile": "https://Stackoverflow.com/users/617652",
"pm_score": 3,
"selected": false,
"text": "public string ReadPdfFile(object Filename, DataTable ReadLibray)\n{\n PdfReader reader2 = new PdfReader((string)Filename);\n string strText = string.Empty;\n\n for (int page = 1; page <= reader2.NumberOfPages; page++)\n {\n ITextExtractionStrategy its = new iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy();\n PdfReader reader = new PdfReader((string)Filename);\n String s = PdfTextExtractor.GetTextFromPage(reader, page, its);\n\n s = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(s)));\n strText = strText + s;\n reader.Close();\n }\n return strText;\n}\n"
},
{
"answer_id": 7985501,
"author": "Brock Nusser",
"author_id": 1026269,
"author_profile": "https://Stackoverflow.com/users/1026269",
"pm_score": 8,
"selected": true,
"text": "using iTextSharp.text.pdf;\nusing iTextSharp.text.pdf.parser;\n\nnamespace PdfParser\n{\n public static class PdfTextExtractor\n {\n public static string pdfText(string path)\n {\n PdfReader reader = new PdfReader(path);\n string text = string.Empty;\n for(int page = 1; page <= reader.NumberOfPages; page++)\n {\n text += PdfTextExtractor.GetTextFromPage(reader,page);\n }\n reader.Close();\n return text;\n } \n }\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83152",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6777/"
] |
83,156
|
<p>Ok, I have been working with Solaris for a 10+ years, and have never seen this...</p>
<p>I have a directory listing which includes both a file and subdirectory with the same name:</p>
<pre><code>-rw-r--r-- 1 root other 15922214 Nov 29 2006 msheehan
drwxrwxrwx 12 msheehan sysadmin 2048 Mar 25 15:39 msheehan
</code></pre>
<p>I use file to discover contents of the file, and I get:</p>
<pre><code>bash-2.03# file msheehan
msheehan: directory
bash-2.03# file msh*
msheehan: ascii text
msheehan: directory
</code></pre>
<p>I am not worried about the file, but I want to keep the directory, so I try rm:</p>
<pre><code>bash-2.03# rm msheehan
rm: msheehan is a directory
</code></pre>
<p>So here is my two part question:</p>
<ol>
<li>What's up with this?</li>
<li>How do I carefully delete the file?</li>
</ol>
<p>Jonathan</p>
<p>Edit:
Thanks for the answers guys, both (so far) were helpful, but piping the listing to an editor did the trick, ala:</p>
<pre><code>bash-2.03# ls -l > jb.txt
bash-2.03# vi jb.txt
</code></pre>
<p>Which contained:</p>
<pre><code>-rw-r--r-- 1 root other 15922214 Nov 29 2006 msheehab^?n
drwxrwxrwx 12 msheehan sysadmin 2048 Mar 25 15:39 msheehan
</code></pre>
<p>Always be careful with the backspace key!</p>
|
[
{
"answer_id": 83224,
"author": "Anthony Williams",
"author_id": 5597,
"author_profile": "https://Stackoverflow.com/users/5597",
"pm_score": 0,
"selected": false,
"text": "cat msh*\n"
},
{
"answer_id": 83644,
"author": "bltxd",
"author_id": 11892,
"author_profile": "https://Stackoverflow.com/users/11892",
"pm_score": 1,
"selected": false,
"text": "ruby -e 'puts Dir[\"msheehan*\"].inspect'\n"
},
{
"answer_id": 90053,
"author": "Alan H",
"author_id": 3807,
"author_profile": "https://Stackoverflow.com/users/3807",
"pm_score": 0,
"selected": false,
"text": "mv msheehan temp\nrm mshee*\nmv temp msheehan\n"
},
{
"answer_id": 196263,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 0,
"selected": false,
"text": "mv sheehan abc\nmv sheeha??n xyz\n"
},
{
"answer_id": 4207909,
"author": "itilys",
"author_id": 510706,
"author_profile": "https://Stackoverflow.com/users/510706",
"pm_score": 1,
"selected": false,
"text": "$ ls -li\ntotal 1\n20801 -rw-r--r-- 1 root root 0 2010-11-08 01:55 a?\n20802 -rw-r--r-- 1 root root 0 2010-11-08 01:55 a\\?\n$ find . -inum 20802 -exec rm {} \\;\n$ ls -li\ntotal 1\n20801 -rw-r--r-- 1 root root 0 2010-11-08 01:55 a?\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8361/"
] |
83,157
|
<p>I know there is no "right" heap size, but which heap size do you use in your applications (application type, jdk, os)?</p>
<p>The JVM Options <code>-Xms</code> (initial/minimum) and <code>-Xmx</code> (maximum) allow for controlling the heap size. What settings make sense under which circumstances? When are the defaults appropriate?</p>
|
[
{
"answer_id": 1508750,
"author": "dogbane",
"author_id": 7412,
"author_profile": "https://Stackoverflow.com/users/7412",
"pm_score": 1,
"selected": false,
"text": "-Xms250M -Xmx1500M -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC \n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1961117/"
] |
83,159
|
<p>Some API returns me XmlCursor pointing on root of XML Document. I need to insert all of this into another org.w3c.DOM represented document.</p>
<p>At start:
XmlCursor poiting on
<code></p>
<p><a>
<b>
some text
</b>
</a>
</code></p>
<p>DOM Document:
<code></p>
<p><foo></p>
<p></foo>
</code></p>
<p>At the end I want to have original DOM document changed like this:
<code></p>
<p><foo></p>
<p> <someOtherInsertedElement></p>
<p> <a>
<b>
some text
</b>
</a></p>
<p> </someOtherInsertedElement></p>
<p></foo>
</code></p>
<p>NOTE: <code>document.importNode(cursor.getDomNode())</code> doesn't work - Exception is thrown: <em>NOT_SUPPORTED_ERR: The implementation does not support the requested type of object or operation.</em></p>
|
[
{
"answer_id": 83256,
"author": "Sietse",
"author_id": 6400,
"author_profile": "https://Stackoverflow.com/users/6400",
"pm_score": 4,
"selected": true,
"text": "Node originalNode = cursor.getDomNode();\nNode importNode = document.importNode(originalNode.getFirstChild());\nNode otherNode = document.createElement(\"someOtherInsertedElement\");\notherNode.appendChild(importNode);\ndocument.appendChild(otherNode);\n"
},
{
"answer_id": 13199479,
"author": "Techky",
"author_id": 1106225,
"author_profile": "https://Stackoverflow.com/users/1106225",
"pm_score": 1,
"selected": false,
"text": "Node importNode = document.importNode(originalNode);"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1128722/"
] |
83,172
|
<p>We are using a Sony SNC-RZ30N IP-based webcam to monitor osprey nests and would like to stream the video feed via our own webserver.</p>
<p>Rather than use the built-in webserver of the camera (which requires either ActiveX or Java on the client side) to display the live feed, I would like to weed out just the live feed and display it on our campus webserver (Win2k8/IIS7). Perhaps in an iFrame or the like. </p>
<p>Unfortunately, documentation for anything other than FTP'ing a static image snapshot from this camera seems to be pretty much non-existent.</p>
<p>There are other "video surveillance" packages (ie: ProSight SMB) that will feed up a web page with the live feed on their own built-in webservers (along with controls to position the camera, which we don't want displayed) - but that is undesireable. </p>
<p>I simply want to capture the live stream from the camera and embed it a page on our website so that we can control how the page looks as well as other relevant hyperlinks.</p>
<p>Thx.</p>
|
[
{
"answer_id": 83207,
"author": "Grad van Horck",
"author_id": 12569,
"author_profile": "https://Stackoverflow.com/users/12569",
"pm_score": 0,
"selected": false,
"text": "http://<ip>/img/static.jpg"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2312/"
] |
83,225
|
<p>I've seen this done in a few sites, an example is <a href="http://www.artofadambetts.com/weblog/?p=169" rel="noreferrer">artofadambetts.com</a>. The scroll bar on the page scrolls only an element of the page, not the entire page. I looked at the source and havent't been able to figure it out yet. How is this done?</p>
|
[
{
"answer_id": 83258,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": -1,
"selected": false,
"text": "<div style=\"overflow-x: auto; overflow-y: auto;>the content</div>"
},
{
"answer_id": 83264,
"author": "apandit",
"author_id": 6128,
"author_profile": "https://Stackoverflow.com/users/6128",
"pm_score": 0,
"selected": false,
"text": "overflow: auto\n"
},
{
"answer_id": 83298,
"author": "p4bl0",
"author_id": 12043,
"author_profile": "https://Stackoverflow.com/users/12043",
"pm_score": 3,
"selected": false,
"text": "position: fixed;"
},
{
"answer_id": 83389,
"author": "Anthony Williams",
"author_id": 5597,
"author_profile": "https://Stackoverflow.com/users/5597",
"pm_score": 1,
"selected": false,
"text": "overflow: scroll"
},
{
"answer_id": 8307025,
"author": "sumit pandey",
"author_id": 1017830,
"author_profile": "https://Stackoverflow.com/users/1017830",
"pm_score": 0,
"selected": false,
"text": " <html>\n <head>\n <title>Separately Scrolled Area Demo</title>\n </head>\n <body>\n <div style=\"width: 100px; border-style: solid\">\n\n <div style=\"overflow: auto; width: 100px; height: 100px\">\n sumit..................\n amit...................\n mrinal.................\n nitesh................\n maneesh................\n raghav...................\n hitesh...................\n deshpande................\n sidarth....................\n mayank.....................\n santanu....................\n sahil......................\n malhan.....................\n rajib.....................\n </div>\n </div>\n </body>\n </html>\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5304/"
] |
83,232
|
<p>I'm looking for a key/value pair object that I can include in a web service.</p>
<p>I tried using .NET's <a href="http://msdn.microsoft.com/en-us/library/5tbh8a42.aspx" rel="noreferrer"><code>System.Collections.Generic.KeyValuePair<></code></a> class, but it does not properly serialize in a web service. In a web service, the Key and Value properties are not serialized, making this class useless, unless someone knows a way to fix this.</p>
<p>Is there any other generic class that can be used for this situation?</p>
<p>I'd use .NET's <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.pair.aspx" rel="noreferrer"><code>System.Web.UI.Pair</code></a> class, but it uses Object for its types. It would be nice to use a Generic class, if only for type safety.</p>
|
[
{
"answer_id": 83265,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 8,
"selected": true,
"text": "[Serializable]\npublic struct KeyValuePair<K,V>\n{\n public K Key {get;set;}\n public V Value {get;set;}\n}\n"
},
{
"answer_id": 83336,
"author": "Compile This",
"author_id": 4048,
"author_profile": "https://Stackoverflow.com/users/4048",
"pm_score": 5,
"selected": false,
"text": "Dictionary<>"
},
{
"answer_id": 4598558,
"author": "Peter Oehlert",
"author_id": 44656,
"author_profile": "https://Stackoverflow.com/users/44656",
"pm_score": 2,
"selected": false,
"text": "Tuple.Create(a, b)"
},
{
"answer_id": 8008789,
"author": "Saraf Talukder",
"author_id": 690310,
"author_profile": "https://Stackoverflow.com/users/690310",
"pm_score": -1,
"selected": false,
"text": "Tuple<string,object>"
},
{
"answer_id": 21933365,
"author": "GregoryBrad",
"author_id": 1017874,
"author_profile": "https://Stackoverflow.com/users/1017874",
"pm_score": 3,
"selected": false,
"text": " [Serializable]\n public class SerializableKeyValuePair<TKey, TValue>\n {\n\n public SerializableKeyValuePair()\n {\n }\n\n public SerializableKeyValuePair(TKey key, TValue value)\n {\n Key = key;\n Value = value;\n }\n\n public TKey Key { get; set; }\n public TValue Value { get; set; }\n\n }\n"
},
{
"answer_id": 49979671,
"author": "Hasse",
"author_id": 4350601,
"author_profile": "https://Stackoverflow.com/users/4350601",
"pm_score": 0,
"selected": false,
"text": " public static string GetXMLStringFromDataContract(object contractEntity)\n {\n using (System.IO.MemoryStream writer = new System.IO.MemoryStream())\n {\n var dataContractSerializer = new DataContractSerializer(contractEntity.GetType());\n dataContractSerializer.WriteObject(writer, contractEntity);\n writer.Position = 0;\n var streamReader = new System.IO.StreamReader(writer);\n return streamReader.ReadToEnd();\n }\n }\n"
},
{
"answer_id": 56067993,
"author": "Teodor Tite",
"author_id": 4469405,
"author_profile": "https://Stackoverflow.com/users/4469405",
"pm_score": 0,
"selected": false,
"text": "DataTable"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392/"
] |
83,242
|
<p>I have a RHEL 5 system with a fresh new hard drive I just dedicated to the MySQL server. To get things started, I used "mysqldump --host otherhost -A | mysql", even though I noticed the manpage never explicitly recommends trying this (mysqldump into a file is a no-go. We're talking 500G of database). </p>
<p>This process fails at random intervals, complaining that too many files are open (at which point mysqld gets the relevant signal, and dies and respawns). </p>
<p>I tried upping it at sysctl and ulimit, but the problem persists. What do I do about it? </p>
|
[
{
"answer_id": 57127322,
"author": "Mohd Abdul Mujib",
"author_id": 807104,
"author_profile": "https://Stackoverflow.com/users/807104",
"pm_score": 0,
"selected": false,
"text": "mysqldump"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15910/"
] |
83,260
|
<p>Say I've got this array:
MyArray(0)="aaa"
MyArray(1)="bbb"
MyArray(2)="aaa"</p>
<p>Is there a .net function which can give me the unique values? I would like something like this as an output of the function:
OutputArray(0)="aaa"
OutputArray(1)="bbb"</p>
|
[
{
"answer_id": 83280,
"author": "Stormenet",
"author_id": 2090,
"author_profile": "https://Stackoverflow.com/users/2090",
"pm_score": 2,
"selected": false,
"text": "string[] myarray = new string[] { \"aaa\", \"bbb\", \"aaa\" };\n Dictionary mydict = new Dictionary();\n foreach (string s in myarray) {\n if (!mydict.ContainsKey(s)) mydict.Add(s, s);\n }"
},
{
"answer_id": 83315,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 3,
"selected": false,
"text": "int[] test = { 1, 2, 1, 3, 3, 4, 5 };\nvar res = (from t in test select t).Distinct<int>();\nforeach (var i in res)\n{\n Console.WriteLine(i);\n}\n"
},
{
"answer_id": 83371,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 4,
"selected": true,
"text": "string[] OutputArray = MyArray.Distinct().ToArray();\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15928/"
] |
83,279
|
<p>I'm developing a 3-column website using a layout like this:</p>
<pre><code> <div id='left' style='left: 0; width: 150px; '> ... </div>
<div id='middle' style='left: 150px; right: 200px' > ... </div>
<div id='right' style='right: 0; width: 200px; '> ... </div>
</code></pre>
<p>But, considering the default CSS 'position' property of <code><DIV>'s</code> is 'static', my <code><DIV>'s</code> were shown one below the other, as expected.</p>
<p>So I set the CSS property 'position' to 'relative', and changed the 'top' property of the 'middle' and 'right' <code><DIV>'s</code> to -(minus) the height of the preceding <code><DIV></code>. It worked fine, but this approach brought me two problems:</p>
<p>1) Even though Internet Explorer 7 shows three columns properly, it still keeps the vertical scrollbar as if the <code><DIV>'s</code> were positioned one below the other, and there is a lot of white space after the content is over. I would'n like to have that.</p>
<p>2) The height of these elements is variable, so I don't really know which value to set for each <code><DIV></code>'s 'top' property; and I wouldn't like to hardcode it.</p>
<p>So my question is, what would be the best (simple + elegant) way to implement this layout? I would like to avoid absolute positioning , and I also to keep my design tableless.</p>
|
[
{
"answer_id": 90790,
"author": "Peter Kelley",
"author_id": 14893,
"author_profile": "https://Stackoverflow.com/users/14893",
"pm_score": 1,
"selected": false,
"text": "1 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \n2 \"http://www.w3.org/TR/html4/strict.dtd\"> \n3 <html> \n4 <head> \n5 <title>YUI Base Page</title> \n6 <link rel=\"stylesheet\" href=\"http://yui.yahooapis.com/2.5.1/build/reset-fonts-grids/reset-fonts-grids.css\" type=\"text/css\"> \n7 </head> \n8 <body> \n9 <div id=\"doc\" class=\"yui-t1\"> \n10 <div id=\"hd\"><h1>YUI: CSS Grid Builder</h1></div> \n11 <div id=\"bd\"> \n12 <div id=\"yui-main\"> \n13 <div class=\"yui-b\"> <div class=\"yui-gb\"> \n14 <div class=\"yui-u first\"> \n15 <!-- YOUR DATA GOES HERE --> \n16 </div> \n17 <div class=\"yui-u\"> \n18 <!-- YOUR DATA GOES HERE --> \n19 </div> \n20 <div class=\"yui-u\"> \n21 <!-- YOUR DATA GOES HERE --> \n22 </div> \n23 </div> \n24 </div> \n25 </div> \n26 <div class=\"yui-b\"><!-- YOUR NAVIGATION GOES HERE --></div> \n27 \n28 </div> \n29 <div id=\"ft\">Footer is here.</div> \n30 </div> \n31 </body> \n32 </html> \n"
},
{
"answer_id": 4986784,
"author": "Nqko",
"author_id": 615432,
"author_profile": "https://Stackoverflow.com/users/615432",
"pm_score": 0,
"selected": false,
"text": "<!DOCTYPE HTML PUBLIC\"-//W3C//DTD HTML 4.01//EN\">\n<html>\n <head>\n <title> Test </title>\n </head>\n <body>\n <div id=\"grad2\" style=\"width:15%; height:100%; position:fixed; top:0px; left:0px; background-color:rgb(147,81,73);\">\n <a href=\"http://abv.bg\"> Column1 </a> </div>\n <div id=\"grad4\" style=\"width:70%; height:100%; position:fixed; top:0px; left:15%; background-color:rgb(0,0,0);\">\n <font color=\"#FFFFFF\">Column 2 </font> </div>\n <div id=\"grad3\" style=\"width:100%; height:100%; position:fixed; top:0px; left:85%; background-color:rgb(60,255,4);\">\n <a href=\"http://abv.bg\"> Column 3 </a> </div>\n </body>\n</html>\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15931/"
] |
83,299
|
<p>I found this open-source library that I want to use in my Java application. The library is written in C and was developed under Unix/Linux, and my application will run on Windows. It's a library of mostly mathematical functions, so as far as I can tell it doesn't use anything that's platform-dependent, it's just very basic C code. Also, it's not that big, less than 5,000 lines.</p>
<p>What's the easiest way to use the library in my application? I know there's JNI, but that involves finding a compiler to compile the library under Windows, getting up-to-date with the JNI framework, writing the code, etc. Doable, but not that easy. Is there an easier way? Considering the small size of the library, I'm tempted to just translate it to Java. Are there any tools that can help with that?</p>
<p><BR>
<strong>EDIT</strong></p>
<p>I ended up translating the part of the library that I needed to Java. It's about 10% of the library so far, though it'll probably increase with time. C and Java are pretty similar, so it only took a few hours. The main difficulty is fixing the bugs that get introduced by mistakes in the translation.</p>
<p>Thank you everyone for your help. The proposed solutions all seemed interesting and I'll look into them when I need to link to larger libraries. For a small piece of C code, manual translation was the simplest solution.</p>
|
[
{
"answer_id": 83394,
"author": "Tuxmentat",
"author_id": 15963,
"author_profile": "https://Stackoverflow.com/users/15963",
"pm_score": -1,
"selected": false,
"text": "System.loadLibrary(\"mylibrary.dll\");\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83299",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8330/"
] |
83,319
|
<p>I'm trying to figure out why the control does not honor ZIndex.</p>
<p>Example 1 - which works fine</p>
<pre><code> <Canvas>
<Rectangle Canvas.ZIndex="1" Height="400" Width="600" Fill="Yellow"/>
<Rectangle Canvas.ZIndex="2" Height="100" Width="100" Fill="Red"/>
</Canvas>
</code></pre>
<p>Example 2 - which does not work</p>
<pre><code> <Canvas>
<WebBrowser Canvas.ZIndex="1" Height="400" Width="600" Source="http://www.stackoverflow.com"/>
<Rectangle Canvas.ZIndex="2" Height="100" Width="100" Fill="Red"/>
</Canvas>
</code></pre>
<p>Thanks,
-- Ed</p>
|
[
{
"answer_id": 19936409,
"author": "Hannish",
"author_id": 1514608,
"author_profile": "https://Stackoverflow.com/users/1514608",
"pm_score": 1,
"selected": false,
"text": "<Canvas ClipToBounds=\"False\">\n <Popup AllowsTransparency=\"True\" ClipToBounds=\"False\" IsOpen=\"True\">\n <Expander>\n <Grid x:Name=\"YourContent\"/>\n </Expander>\n <Popup>\n</Canvas>\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15921/"
] |
83,329
|
<p>I have a ~23000 line SQL dump containing several databases worth of data. I need to extract a certain section of this file (i.e. the data for a single database) and place it in a new file. I know both the start and end line numbers of the data that I want.</p>
<p>Does anyone know a Unix command (or series of commands) to extract all lines from a file between say line 16224 and 16482 and then redirect them into a new file?</p>
|
[
{
"answer_id": 83344,
"author": "Mark Janssen",
"author_id": 15828,
"author_profile": "https://Stackoverflow.com/users/15828",
"pm_score": 5,
"selected": false,
"text": ":16224,16482w!/tmp/some-file\n"
},
{
"answer_id": 83347,
"author": "boxxar",
"author_id": 15732,
"author_profile": "https://Stackoverflow.com/users/15732",
"pm_score": 11,
"selected": true,
"text": "sed -n '16224,16482p;16483q' filename > newfile\n"
},
{
"answer_id": 83348,
"author": "Cetra",
"author_id": 15087,
"author_profile": "https://Stackoverflow.com/users/15087",
"pm_score": 3,
"selected": false,
"text": " # print section of file based on line numbers\n sed -n '16224 ,16482p' # method 1\n sed '16224,16482!d' # method 2\n"
},
{
"answer_id": 83359,
"author": "mmaibaum",
"author_id": 12213,
"author_profile": "https://Stackoverflow.com/users/12213",
"pm_score": 4,
"selected": false,
"text": "perl -ne 'print if 16224..16482' file.txt > new_file.txt\n"
},
{
"answer_id": 83367,
"author": "jan.vdbergh",
"author_id": 9540,
"author_profile": "https://Stackoverflow.com/users/9540",
"pm_score": 2,
"selected": false,
"text": "head -16428 < file.in | tail -259 > file.out\n"
},
{
"answer_id": 83374,
"author": "rami",
"author_id": 9629,
"author_profile": "https://Stackoverflow.com/users/9629",
"pm_score": 3,
"selected": false,
"text": "sed -n '16224,16482p' < dump.sql"
},
{
"answer_id": 83383,
"author": "manveru",
"author_id": 8367,
"author_profile": "https://Stackoverflow.com/users/8367",
"pm_score": 7,
"selected": false,
"text": "head -16482 in.sql | tail -258 > out.sql\n"
},
{
"answer_id": 83392,
"author": "JXG",
"author_id": 15456,
"author_profile": "https://Stackoverflow.com/users/15456",
"pm_score": 8,
"selected": false,
"text": "sed -n '16224,16482 p' orig-data-file > new-file\n"
},
{
"answer_id": 83420,
"author": "JP Lodine",
"author_id": 8998,
"author_profile": "https://Stackoverflow.com/users/8998",
"pm_score": 3,
"selected": false,
"text": "cat dump.txt | head -16224 | tail -258\n"
},
{
"answer_id": 14113237,
"author": "Paddy3118",
"author_id": 10562,
"author_profile": "https://Stackoverflow.com/users/10562",
"pm_score": 2,
"selected": false,
"text": "awk 'FNR >= 16224 && FNR <= 16482' my_file > extracted.txt\n"
},
{
"answer_id": 17870039,
"author": "Robert Massaioli",
"author_id": 83446,
"author_profile": "https://Stackoverflow.com/users/83446",
"pm_score": 2,
"selected": false,
"text": "$ cat somefile | splitter 16224-16482\n"
},
{
"answer_id": 21118665,
"author": "fedorqui",
"author_id": 1983854,
"author_profile": "https://Stackoverflow.com/users/1983854",
"pm_score": 5,
"selected": false,
"text": "awk"
},
{
"answer_id": 21570310,
"author": "Chinmoy Padhi",
"author_id": 3273979,
"author_profile": "https://Stackoverflow.com/users/3273979",
"pm_score": 2,
"selected": false,
"text": "cat filename|sed 'n1,n2!d' > abc.txt\n"
},
{
"answer_id": 27406810,
"author": "DrNerdfighter",
"author_id": 2167295,
"author_profile": "https://Stackoverflow.com/users/2167295",
"pm_score": 1,
"selected": false,
"text": "#!/bin/bash\n# Display line number ranges of a file to the terminal.\n# Usage: $ pinch filename start-line end-line\n# By Evan J. Coon\n\nFILENAME=$1\nSTART=$2\nEND=$3\n\nERROR=\"[PINCH ERROR]\"\n\n# Check that the number of arguments is 3\nif [ $# -lt 3 ]; then\n echo \"$ERROR Need three arguments: Filename Start-line End-line\"\n exit 1\nfi\n\n# Check that the file exists.\nif [ ! -f \"$FILENAME\" ]; then\n echo -e \"$ERROR File does not exist. \\n\\t$FILENAME\"\n exit 1\nfi\n\n# Check that start-line is not greater than end-line\nif [ \"$START\" -gt \"$END\" ]; then\n echo -e \"$ERROR Start line is greater than End line.\"\n exit 1\nfi\n\n# Check that start-line is positive.\nif [ \"$START\" -lt 0 ]; then\n echo -e \"$ERROR Start line is less than 0.\"\n exit 1\nfi\n\n# Check that end-line is positive.\nif [ \"$END\" -lt 0 ]; then\n echo -e \"$ERROR End line is less than 0.\"\n exit 1\nfi\n\nNUMOFLINES=$(wc -l < \"$FILENAME\")\n\n# Check that end-line is not greater than the number of lines in the file.\nif [ \"$END\" -gt \"$NUMOFLINES\" ]; then\n echo -e \"$ERROR End line is greater than number of lines in file.\"\n exit 1\nfi\n\n# The distance from the end of the file to end-line\nENDDIFF=$(( NUMOFLINES - END ))\n\n# For larger files, this will run more quickly. If the distance from the\n# end of the file to the end-line is less than the distance from the\n# start of the file to the start-line, then start pinching from the\n# bottom as opposed to the top.\nif [ \"$START\" -lt \"$ENDDIFF\" ]; then\n < \"$FILENAME\" head -n $END | tail -n +$START\nelse\n < \"$FILENAME\" tail -n +$START | head -n $(( END-START+1 ))\nfi\n\n# Success\nexit 0\n"
},
{
"answer_id": 30373675,
"author": "Carl Blakeley",
"author_id": 4743018,
"author_profile": "https://Stackoverflow.com/users/4743018",
"pm_score": 2,
"selected": false,
"text": "ruby -ne 'puts \"#{$.}: #{$_}\" if $. >= 32613500 && $. <= 32614500' < GND.rdf > GND.extract.rdf\n"
},
{
"answer_id": 31920272,
"author": "potong",
"author_id": 967492,
"author_profile": "https://Stackoverflow.com/users/967492",
"pm_score": 1,
"selected": false,
"text": "sed -ne '16224,16482w newfile' -e '16482q' file\n"
},
{
"answer_id": 34204380,
"author": "ThinkBonobo",
"author_id": 2668545,
"author_profile": "https://Stackoverflow.com/users/2668545",
"pm_score": 0,
"selected": false,
"text": "cat $filename | sed \"${linenum}p;d\";\n"
},
{
"answer_id": 46988259,
"author": "KevinY",
"author_id": 2403657,
"author_profile": "https://Stackoverflow.com/users/2403657",
"pm_score": 2,
"selected": false,
"text": "sed -n \"$first\",\"$count\"p imagelist.txt >\"$imageblock\"\n"
},
{
"answer_id": 48797557,
"author": "Kemin Zhou",
"author_id": 2407363,
"author_profile": "https://Stackoverflow.com/users/2407363",
"pm_score": 1,
"selected": false,
"text": "myfile content:\n=====================\nline1 not needed\nline2 also discarded\n[Data]\nfirst data line\nsecond data line\n=====================\nsed -n '/Data/,$p' myfile\n"
},
{
"answer_id": 54692028,
"author": "Tilman Vogel",
"author_id": 119725,
"author_profile": "https://Stackoverflow.com/users/119725",
"pm_score": 4,
"selected": false,
"text": "sed -n '<first line>,$p;<last line>q' input\n"
},
{
"answer_id": 57914915,
"author": "Benjamin W.",
"author_id": 3266847,
"author_profile": "https://Stackoverflow.com/users/3266847",
"pm_score": 2,
"selected": false,
"text": "ed -s infile <<<'16224,16482p'\n"
},
{
"answer_id": 63818110,
"author": "Anselmo Blanco Dominguez",
"author_id": 6131786,
"author_profile": "https://Stackoverflow.com/users/6131786",
"pm_score": 2,
"selected": false,
"text": "# wc fo2debug.1.log\n 10421186 19448208 38795491134 fo2debug.1.log\n"
},
{
"answer_id": 66395284,
"author": "Kahiga",
"author_id": 4463830,
"author_profile": "https://Stackoverflow.com/users/4463830",
"pm_score": 0,
"selected": false,
"text": "for letter in {a..k} ; do echo $letter; done | cat -n > myfile.txt"
},
{
"answer_id": 67063978,
"author": "Tasos Papastylianou",
"author_id": 4183191,
"author_profile": "https://Stackoverflow.com/users/4183191",
"pm_score": 4,
"selected": false,
"text": "head | tail"
},
{
"answer_id": 71969197,
"author": "user2928048",
"author_id": 2928048,
"author_profile": "https://Stackoverflow.com/users/2928048",
"pm_score": 0,
"selected": false,
"text": "#!/usr/bin/bash\n\n# Usage:\n# body n m|-m\n\nfrom=$1\nto=$2\n\nif [ $to -gt 0 ]; then\n# count $from the begin of the file $to selected line\n awk \"NR >= $from && NR <= $to {print}\"\nelse\n# count $from the begin of the file skipping tailing $to lines\n awk '\n BEGIN {lines=0; from='$from'; to='$to'}\n {++lines}\n NR >= $from {line[lines]=$0}\n END {for (i = from; i < lines + to + 1; i++) {\n print line[i]\n }\n }'\nfi\n"
},
{
"answer_id": 71970867,
"author": "RARE Kpop Manifesto",
"author_id": 14672114,
"author_profile": "https://Stackoverflow.com/users/14672114",
"pm_score": 1,
"selected": false,
"text": "sed"
},
{
"answer_id": 74076800,
"author": "Du-Lacoste",
"author_id": 3600553,
"author_profile": "https://Stackoverflow.com/users/3600553",
"pm_score": 0,
"selected": false,
"text": "sed"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15676/"
] |
83,397
|
<p>In php I have open a .php file and want to evaluate certain lines. Specifically when the $table_id and $line variables are assigned a value.</p>
<p>Within the text file I have:</p>
<pre><code>...
$table_id = 'crs_class'; // table name
$screen = 'crs_class.detail.screen.inc'; // file identifying screen structure
...
</code></pre>
<p>amongst other lines. The if statement below never detects the occurance of <code>$table_id</code> or <code>$screen</code> (even without the $ prepended). I can't understand why it won't work as the strpos statement below looking for 'require' works fine.</p>
<p>So, why isn't this if statement getting a hit?</p>
<pre><code>while ($line=fgets($fh)) {
//echo "Evaluating... $line <br>";
**if ((($pos = stripos($line, '$table_id')) === true) || (($pos = stripos($line, '$screen'))===true))**
{
// TODO: Not evaluating tableid and screen lines correctly fix.
// Set $table_id and $screen variables from task scripts
eval($line);
}
if (($pos=stripos($line, 'require')) === true) {
$controller = $line;
}
}
</code></pre>
|
[
{
"answer_id": 83435,
"author": "Adam Wright",
"author_id": 1200,
"author_profile": "https://Stackoverflow.com/users/1200",
"pm_score": 2,
"selected": false,
"text": "<?php\n $foo = \"bar\";\n\n print '$foo';\n print \"$foo\";\n?>\n"
},
{
"answer_id": 83648,
"author": "scunliffe",
"author_id": 6144,
"author_profile": "https://Stackoverflow.com/users/6144",
"pm_score": 2,
"selected": false,
"text": "String.indexOf(str)\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10583/"
] |
83,405
|
<p>I am looking for a good JavaScript library for parsing XML data. It should be much easier to use than the built-in <a href="http://www.w3schools.com/Xml/xml_parser.asp" rel="nofollow noreferrer">XML DOM parsers</a> bundled with the browsers.</p>
<p>I got spoiled a bit working with JSON and am looking forward to something on similar lines for XML.</p>
|
[
{
"answer_id": 26957382,
"author": "lexicore",
"author_id": 303810,
"author_profile": "https://Stackoverflow.com/users/303810",
"pm_score": 6,
"selected": false,
"text": "QName"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4337/"
] |
83,410
|
<p>I have a large CSV file and I want to execute a stored procedure for each line.</p>
<p>What is the best way to execute a stored procedure from PowerShell?</p>
|
[
{
"answer_id": 83791,
"author": "Mark Schill",
"author_id": 9482,
"author_profile": "https://Stackoverflow.com/users/9482",
"pm_score": 7,
"selected": true,
"text": "$SqlConnection = New-Object System.Data.SqlClient.SqlConnection\n$SqlConnection.ConnectionString = \"Server=HOME\\SQLEXPRESS;Database=master;Integrated Security=True\"\n$SqlCmd = New-Object System.Data.SqlClient.SqlCommand\n$SqlCmd.CommandText = \"sp_helpdb\"\n$SqlCmd.Connection = $SqlConnection\n$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter\n$SqlAdapter.SelectCommand = $SqlCmd\n$DataSet = New-Object System.Data.DataSet\n$SqlAdapter.Fill($DataSet)\n$SqlConnection.Close()\n$DataSet.Tables[0]\n"
},
{
"answer_id": 83834,
"author": "Santiago Cepas",
"author_id": 6547,
"author_profile": "https://Stackoverflow.com/users/6547",
"pm_score": 3,
"selected": false,
"text": "function execute-Sql{\n param($server, $db, $sql )\n $sqlConnection = new-object System.Data.SqlClient.SqlConnection\n $sqlConnection.ConnectionString = 'server=' + $server + ';integrated security=TRUE;database=' + $db \n $sqlConnection.Open()\n $sqlCommand = new-object System.Data.SqlClient.SqlCommand\n $sqlCommand.CommandTimeout = 120\n $sqlCommand.Connection = $sqlConnection\n $sqlCommand.CommandText= $sql\n $text = $sql.Substring(0, 50)\n Write-Progress -Activity \"Executing SQL\" -Status \"Executing SQL => $text...\"\n Write-Host \"Executing SQL => $text...\"\n $result = $sqlCommand.ExecuteNonQuery()\n $sqlConnection.Close()\n}\n"
},
{
"answer_id": 280023,
"author": "Mike Shepard",
"author_id": 36429,
"author_profile": "https://Stackoverflow.com/users/36429",
"pm_score": 4,
"selected": false,
"text": "function exec-storedprocedure($storedProcName, \n [hashtable] $parameters=@{},\n [hashtable] $outparams=@{},\n $conn,[switch]$help){ \n\n function put-outputparameters($cmd, $outparams){\n foreach($outp in $outparams.Keys){\n $cmd.Parameters.Add(\"@$outp\", (get-paramtype $outparams[$outp])).Direction=[System.Data.ParameterDirection]::Output\n }\n }\n function get-outputparameters($cmd,$outparams){\n foreach($p in $cmd.Parameters){\n if ($p.Direction -eq [System.Data.ParameterDirection]::Output){\n $outparams[$p.ParameterName.Replace(\"@\",\"\")]=$p.Value\n }\n }\n }\n\n function get-paramtype($typename,[switch]$help){\n switch ($typename){\n 'uniqueidentifier' {[System.Data.SqlDbType]::UniqueIdentifier}\n 'int' {[System.Data.SqlDbType]::Int}\n 'xml' {[System.Data.SqlDbType]::Xml}\n 'nvarchar' {[System.Data.SqlDbType]::NVarchar}\n default {[System.Data.SqlDbType]::Varchar}\n }\n }\n if ($help){\n $msg = @\"\n Execute a sql statement. Parameters are allowed. \n Input parameters should be a dictionary of parameter names and values.\n Output parameters should be a dictionary of parameter names and types.\n Return value will usually be a list of datarows. \n\n Usage: exec-query sql [inputparameters] [outputparameters] [conn] [-help]\n \"@\n Write-Host $msg\n return\n }\n $close=($conn.State -eq [System.Data.ConnectionState]'Closed')\n if ($close) {\n $conn.Open()\n }\n\n $cmd=new-object system.Data.SqlClient.SqlCommand($sql,$conn)\n $cmd.CommandType=[System.Data.CommandType]'StoredProcedure'\n $cmd.CommandText=$storedProcName\n foreach($p in $parameters.Keys){\n $cmd.Parameters.AddWithValue(\"@$p\",[string]$parameters[$p]).Direction=\n [System.Data.ParameterDirection]::Input\n }\n\n put-outputparameters $cmd $outparams\n $ds=New-Object system.Data.DataSet\n $da=New-Object system.Data.SqlClient.SqlDataAdapter($cmd)\n [Void]$da.fill($ds)\n if ($close) {\n $conn.Close()\n }\n get-outputparameters $cmd $outparams\n\n return @{data=$ds;outputparams=$outparams}\n }\n"
},
{
"answer_id": 32723977,
"author": "Ken",
"author_id": 3047366,
"author_profile": "https://Stackoverflow.com/users/3047366",
"pm_score": 0,
"selected": false,
"text": "invoke-sqlcmd2.ps1"
},
{
"answer_id": 71036679,
"author": "Ash K",
"author_id": 8644294,
"author_profile": "https://Stackoverflow.com/users/8644294",
"pm_score": 0,
"selected": false,
"text": "CommandType"
},
{
"answer_id": 72887312,
"author": "Golden Lion",
"author_id": 4001177,
"author_profile": "https://Stackoverflow.com/users/4001177",
"pm_score": 0,
"selected": false,
"text": "function exec-query( $storedProcName,$parameters=@{},$conn,$timeout=60){\n \n $cmd=new-object system.Data.SqlClient.SqlCommand\n\n $cmd.CommandType=[System.Data.CommandType]'StoredProcedure'\n $cmd.Connection=$conn\n $cmd.CommandText=$storedProcName\n $cmd.CommandTimeout=$timeout\n foreach($p in $parameters.Keys){\n [Void] $cmd.Parameters.AddWithValue(\"@$p\",$parameters[$p])\n }\n \n #$id=$cmd.ExecuteScalar()\n $adapter=New-Object system.Data.SqlClient.SqlDataAdapter($cmd)\n $dataset=New-Object system.Data.DataSet\n\n $adapter.fill($dataset) | Out-Null\n\n #$reader = $cmd.ExecuteReader()\n\n #$results = @()\n #while ($reader.Read())\n #{\n # write-host \"reached\" -ForegroundColor Green\n #}\n\n return $dataSet.Tables[0]\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12767/"
] |
83,439
|
<p>What is the preferred way to remove spaces from a string in C++? I could loop through all the characters and build a new string, but is there a better way?</p>
|
[
{
"answer_id": 83468,
"author": "rupello",
"author_id": 635,
"author_profile": "https://Stackoverflow.com/users/635",
"pm_score": 5,
"selected": false,
"text": "string.erase(std::remove_if(string.begin(), string.end(), std::isspace), string.end());\n"
},
{
"answer_id": 83481,
"author": "Arno",
"author_id": 13685,
"author_profile": "https://Stackoverflow.com/users/13685",
"pm_score": 7,
"selected": false,
"text": "std::string::iterator end_pos = std::remove(str.begin(), str.end(), ' ');\nstr.erase(end_pos, str.end());\n"
},
{
"answer_id": 83538,
"author": "Matt Price",
"author_id": 852,
"author_profile": "https://Stackoverflow.com/users/852",
"pm_score": 9,
"selected": true,
"text": "remove_if"
},
{
"answer_id": 83744,
"author": "Nemanja Trifunovic",
"author_id": 8899,
"author_profile": "https://Stackoverflow.com/users/8899",
"pm_score": 5,
"selected": false,
"text": "erase_all(str, \" \"); \n"
},
{
"answer_id": 1754664,
"author": "Roman",
"author_id": 213596,
"author_profile": "https://Stackoverflow.com/users/213596",
"pm_score": 4,
"selected": false,
"text": "#include <boost/algorithm/string.hpp>\n\nusing namespace std;\nusing namespace boost;\n\n// ...\n\nstring str1(\" hello world! \");\ntrim(str1); // str1 == \"hello world!\"\n"
},
{
"answer_id": 8868204,
"author": "ddacot",
"author_id": 1036018,
"author_profile": "https://Stackoverflow.com/users/1036018",
"pm_score": 4,
"selected": false,
"text": "string delSpaces(string &str) \n{\n str.erase(std::remove(str.begin(), str.end(), ' '), str.end());\n return str;\n}\n"
},
{
"answer_id": 10355229,
"author": "SudoBash",
"author_id": 1361698,
"author_profile": "https://Stackoverflow.com/users/1361698",
"pm_score": 3,
"selected": false,
"text": "string replaceinString(std::string str, std::string tofind, std::string toreplace)\n{\n size_t position = 0;\n for ( position = str.find(tofind); position != std::string::npos; position = str.find(tofind,position) )\n {\n str.replace(position ,1, toreplace);\n }\n return(str);\n}\n"
},
{
"answer_id": 16011109,
"author": "user2281802",
"author_id": 2281802,
"author_profile": "https://Stackoverflow.com/users/2281802",
"pm_score": 4,
"selected": false,
"text": "#include <algorithm>\n#include <string>\nusing namespace std;\n\nstr.erase(remove(str.begin(), str.end(), char_to_remove), str.end());\n"
},
{
"answer_id": 30037563,
"author": "test c",
"author_id": 4863555,
"author_profile": "https://Stackoverflow.com/users/4863555",
"pm_score": -1,
"selected": false,
"text": "string removespace(string str)\n{ \n int m = str.length();\n int i=0;\n while(i<m)\n {\n while(str[i] == 32)\n str.erase(i,1);\n i++;\n } \n}\n"
},
{
"answer_id": 35107174,
"author": "Volomike",
"author_id": 105539,
"author_profile": "https://Stackoverflow.com/users/105539",
"pm_score": 3,
"selected": false,
"text": "#define REMOVE_SPACES(x) x.erase(std::remove(x.begin(), x.end(), ' '), x.end())\n"
},
{
"answer_id": 36694415,
"author": "RaGa__M",
"author_id": 5198101,
"author_profile": "https://Stackoverflow.com/users/5198101",
"pm_score": 2,
"selected": false,
"text": "s.erase(std::unique(s.begin(),s.end(),[](char s,char f){return (f==' '||s==' ');}),s.end());"
},
{
"answer_id": 55642878,
"author": "Crisp Apples",
"author_id": 9959106,
"author_profile": "https://Stackoverflow.com/users/9959106",
"pm_score": 2,
"selected": false,
"text": "string removeSpaces(string word) {\n string newWord;\n for (int i = 0; i < word.length(); i++) {\n if (word[i] != ' ') {\n newWord += word[i];\n }\n }\n\n return newWord;\n}\n"
},
{
"answer_id": 59053051,
"author": "Deepanshu",
"author_id": 10186641,
"author_profile": "https://Stackoverflow.com/users/10186641",
"pm_score": 2,
"selected": false,
"text": " #include <algorithm>\n using namespace std;\n\n int main() {\n .\n .\n s.erase( remove( s.begin(), s.end(), ' ' ), s.end() );\n .\n .\n }\n"
},
{
"answer_id": 61989008,
"author": "NoSenseEtAl",
"author_id": 700825,
"author_profile": "https://Stackoverflow.com/users/700825",
"pm_score": 3,
"selected": false,
"text": "std::string str = \" Hello World !\";\nstd::erase(str, ' ');\n"
},
{
"answer_id": 62207804,
"author": "AnselmRu",
"author_id": 6359258,
"author_profile": "https://Stackoverflow.com/users/6359258",
"pm_score": 2,
"selected": false,
"text": "string str = \" \\n AB cd \\t efg\\v\\n\";\nstr = regex_replace(str,regex(\"\\\\s\"),\"\");\n"
},
{
"answer_id": 62321910,
"author": "Kerim FIRAT",
"author_id": 2499808,
"author_profile": "https://Stackoverflow.com/users/2499808",
"pm_score": -1,
"selected": false,
"text": " string str = \"2C F4 32 3C B9 DE\";\n str.erase(remove(str.begin(),str.end(),' '),str.end());\n cout << str << endl;\n"
},
{
"answer_id": 64953861,
"author": "Enlico",
"author_id": 5825294,
"author_profile": "https://Stackoverflow.com/users/5825294",
"pm_score": 0,
"selected": false,
"text": "#include <boost/hana/functional/partial.hpp>\n#include <iostream>\n#include <range/v3/range/conversion.hpp>\n#include <range/v3/view/filter.hpp>\nint main() {\n using ranges::to;\n using ranges::views::filter;\n using boost::hana::partial;\n auto const& not_space = partial(std::not_equal_to<>{}, ' ');\n auto const& to_string = to<std::string>;\n\n std::string input = \"2C F4 32 3C B9 DE\";\n std::string output = input | filter(not_space) | to_string;\n assert(output == \"2CF4323CB9DE\");\n}\n"
},
{
"answer_id": 65626953,
"author": "D...",
"author_id": 7452451,
"author_profile": "https://Stackoverflow.com/users/7452451",
"pm_score": 0,
"selected": false,
"text": "\" Hello World \""
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15947/"
] |
83,471
|
<p>Working with a SqlCommand in C# I've created a query that contains a IN (list...) part in the where clause. Instead of looping through my string list generating the list I need for the query (dangerous if you think in sqlInjection). I thought that I could create a parameter like:</p>
<pre><code>SELECT blahblahblah WHERE blahblahblah IN @LISTOFWORDS
</code></pre>
<p>Then in the code I try to add a parameter like this: </p>
<pre><code>DataTable dt = new DataTable();
dt.Columns.Add("word", typeof(string));
foreach (String word in listOfWords)
{
dt.Rows.Add(word);
}
comm.Parameters.Add("LISTOFWORDS", System.Data.SqlDbType.Structured).Value = dt;
</code></pre>
<p>But this doesn't work. </p>
<p>Questions:</p>
<ul>
<li>Am I trying something impossible?</li>
<li>Did I took the wrong approach?</li>
<li>Do I have mistakes in this approach?</li>
</ul>
<p>Thanks for your time :)</p>
|
[
{
"answer_id": 83525,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": false,
"text": "SELECT * FROM [Table] WHERE ID IN (1,2,3)\n"
},
{
"answer_id": 92069,
"author": "Dani",
"author_id": 17330,
"author_profile": "https://Stackoverflow.com/users/17330",
"pm_score": 1,
"selected": false,
"text": "StringBuilder sb = new StringBuilder();\nfor (int i=0; i< listOfWords.Count; i++)\n{\n sb.AppendFormat(\"p{0},\",i);\n comm.Parameters.AddWithValue(\"p\"+i.ToString(), listOfWords[i]);\n}\n\ncomm.CommandText = string.Format(\"\"SELECT blahblahblah WHERE blahblahblah IN ({0})\", \nsb.ToString().TrimEnd(','));\n"
},
{
"answer_id": 7614448,
"author": "aarona",
"author_id": 43792,
"author_profile": "https://Stackoverflow.com/users/43792",
"pm_score": 0,
"selected": false,
"text": "FUNCTION"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15987/"
] |
83,476
|
<p>I've been studying the Google authentication API (AuthSub)... My question is, how do I get the user's account information (at least their Gmail address) after the authentication has passed? </p>
<p>Because currently, all I get back from the authentication process is a token granting me access to which ever Google service I have specified in the scope, but there's no easy way to even get the user's login id (Gmail address) as far as I can tell...</p>
<hr>
<p>If so, what Google service allows me to access the user's information?</p>
|
[
{
"answer_id": 7115414,
"author": "StasM",
"author_id": 214196,
"author_profile": "https://Stackoverflow.com/users/214196",
"pm_score": 2,
"selected": false,
"text": "https://www-opensocial.googleusercontent.com/api/people/@me/@self"
},
{
"answer_id": 14819324,
"author": "user2058632",
"author_id": 2058632,
"author_profile": "https://Stackoverflow.com/users/2058632",
"pm_score": 0,
"selected": false,
"text": " [ValidateInput(false)]\n public ActionResult Authenticate(string returnUrl)\n {\n try\n {\n logger.Info(\"\" + returnUrl + \"] LoginController : Authenticate method start \");\n var response = openid.GetResponse();\n if (response == null)\n {\n try\n {\n string discoveryuri = \"https://www.google.com/accounts/o8/id\";\n //OpenIdRelyingParty openid = new OpenIdRelyingParty();\n var fetch = new FetchRequest();// new \n var b = new UriBuilder(Request.Url) { Query = \"\" };\n var req = openid.CreateRequest(discoveryuri, b.Uri, b.Uri);\n fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);\n fetch.Attributes.AddRequired(WellKnownAttributes.Name.FullName);\n req.AddExtension(fetch);\n return req.RedirectingResponse.AsActionResult();\n }\n catch (ProtocolException ex)\n {\n logger.ErrorFormat(\" LoginController : Authenticate method has error, Exception:\" + ex.ToString());\n ViewData[\"Message\"] = ex.Message;\n return View(\"Login\");\n }\n }\n else\n {\n logger.Info(\"\" + returnUrl + \"] LoginController : Authenticate method :when responce not null \");\n switch (response.Status)\n {\n case AuthenticationStatus.Authenticated:\n logger.Info(\"\" + response.Status + \"] LoginController : Authenticate method : responce status \");\n var fetchResponse = response.GetExtension<FetchResponse>();\n string email = fetchResponse.GetAttributeValue(WellKnownAttributes.Contact.Email);\n string userIPAddress = HttpContext.Request.UserHostAddress;\n SecurityManager manager = new SecurityManager(); \n int userID = manager.IsValidUser(email);\n\n if (userID != 0)\n {\n ViewBag.IsFailed = \"False\";\n logger.Info(\"\" + userID + \"] LoginController : Authenticate method : user id id not null \");\n Session[\"FriendlyIdentifier\"] = response.FriendlyIdentifierForDisplay;\n Session[\"UserEmail\"] = email;\n\n FormsAuthentication.SetAuthCookie(email, false);\n\n WebSession.UserEmail = email;\n WebSession.UserID = userID;\n\n UserManager userManager = new UserManager();\n WebSession.AssignedSites = userManager.GetAssignedSites(userID);\n\n\n\n if (!string.IsNullOrEmpty(returnUrl))\n {\n logger.Info(\"\" + returnUrl + \"] LoginController : Authenticate method : retutn url not null then return Redirect \");\n return Redirect(returnUrl);\n }\n else\n {\n logger.Info(\"\" + returnUrl + \"] LoginController : Authenticate method : retutn url null then return RedirectToAction \");\n //\n return Redirect(\"/Home\");\n }\n }\n else\n {\n ViewBag.IsFailed = \"True\";\n logger.Info(\"\" + returnUrl + \"] LoginController : Authenticate method :user id null \");\n if (!string.IsNullOrEmpty(returnUrl))\n {\n logger.Info(\"\" + returnUrl + \"] LoginController : Authenticate method :and return Redirect \");\n return Redirect(returnUrl);\n }\n else\n {\n logger.Info(\"\" + returnUrl + \"] LoginController : Authenticate method :and return RedirectToAction \");\n\n return View(\"Index\");\n\n }\n }\n\n case AuthenticationStatus.Canceled:\n logger.Info(\"\" + response.Status + \"] LoginController : Authenticate method : AuthenticationStatus.Canceled and return view \");\n ViewData[\"Message\"] = \"Canceled at provider\";\n return View(\"Login\");\n case AuthenticationStatus.Failed:\n logger.Info(\"\" + response.Status + \"] LoginController : Authenticate method : AuthenticationStatus.Failed and return view \");\n logger.Error(response.Exception.Message);\n ViewData[\"Message\"] = response.Exception.Message;\n return View(\"Login\");\n }\n\n }\n logger.Info(\"\" + returnUrl + \"] LoginController : Authenticate method end and return EmptyResult\");\n return new EmptyResult();\n }\n catch (Exception ex)\n {\n logger.Error(\" LoginController : Authenticate method \", ex);\n throw;\n }\n }\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15974/"
] |
83,512
|
<p>I am writing a perl script to parse a mysql database schema and create C++ classes when necessary. My question is a pretty easy one, but us something I haven't really done before and don't know common practice. Any object of any of classes created will need to have "get" methods to populate this information. So my questions are twofold:</p>
<ol>
<li>Does it make sense to call all of the get methods in the constructor so that the object has data right away? Some classes will have a lot of them, so as needed might make sense too. I have two constrcutors now. One that populates the data and one that does not.</li>
<li>Should I also have a another "get" method that retrieves the object's copy of the data rather that the db copy.</li>
</ol>
<p>I could go both ways on #1 and am leaning towards yes on #2. Any advice, pointers would be much appreciated. </p>
|
[
{
"answer_id": 83702,
"author": "bmdhacks",
"author_id": 14032,
"author_profile": "https://Stackoverflow.com/users/14032",
"pm_score": 1,
"selected": false,
"text": "Artist MJ = Artist::Find(\"Michael Jackson\");\nMJ->set(\"relevant\", \"no\");\nMJ->save();\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
83,531
|
<p>I'm trying to write a stored procedure to select employees who have birthdays that are upcoming. </p>
<p><code>SELECT * FROM Employees WHERE Birthday > @Today AND Birthday < @Today + @NumDays</code></p>
<p>This will not work because the birth year is part of Birthday, so if my birthday was '09-18-1983' that will not fall between '09-18-2008' and '09-25-2008'. </p>
<p>Is there a way to ignore the year portion of date fields and just compare month/days? </p>
<p>This will be run every monday morning to alert managers of birthdays upcoming, so it possibly will span new years. </p>
<p>Here is the working solution that I ended up creating, thanks Kogus. </p>
<pre><code>SELECT * FROM Employees
WHERE Cast(DATEDIFF(dd, birthdt, getDate()) / 365.25 as int)
- Cast(DATEDIFF(dd, birthdt, futureDate) / 365.25 as int)
<> 0
</code></pre>
|
[
{
"answer_id": 83571,
"author": "Stephen Wrighton",
"author_id": 7516,
"author_profile": "https://Stackoverflow.com/users/7516",
"pm_score": -1,
"selected": false,
"text": "SELECT * FROM Employees WHERE\n DATEADD ( year, YEAR(@Today) - YEAR(@Birthday), birthday) BETWEEN @Today AND @EndDate\n"
},
{
"answer_id": 83601,
"author": "David Webb",
"author_id": 3171,
"author_profile": "https://Stackoverflow.com/users/3171",
"pm_score": 2,
"selected": false,
"text": "DAYOFYEAR"
},
{
"answer_id": 83679,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 2,
"selected": false,
"text": "select * from Employees\nwhere DATEADD (year, DatePart(year, getdate()) - DatePart(year, Birthday), Birthday)\n between convert(datetime, getdate(), 101) \n and convert(datetime, DateAdd(day, 5, getdate()), 101)\n"
},
{
"answer_id": 83688,
"author": "bastos.sergio",
"author_id": 12772,
"author_profile": "https://Stackoverflow.com/users/12772",
"pm_score": 0,
"selected": false,
"text": "DECLARE @endDate DATETIME\nDECLARE @today DATETIME\n\nSELECT @endDate = getDate()+6, @today = getDate()\n\nSELECT * FROM Employees \n WHERE \n (DATEPART (month, birthday) >= DATEPART (month, @today)\n AND DATEPART (day, birthday) >= DATEPART (day, @today))\n AND\n (DATEPART (month, birthday) < DATEPART (month, @endDate)\n AND DATEPART (day, birthday) < DATEPART (day, @endDate))\n"
},
{
"answer_id": 83783,
"author": "JosephStyons",
"author_id": 672,
"author_profile": "https://Stackoverflow.com/users/672",
"pm_score": 6,
"selected": true,
"text": "SELECT \n BRTHDATE AS BIRTHDAY\n ,FLOOR(DATEDIFF(dd,EMP.BRTHDATE,GETDATE()) / 365.25) AS AGE_NOW\n ,FLOOR(DATEDIFF(dd,EMP.BRTHDATE,GETDATE()+7) / 365.25) AS AGE_ONE_WEEK_FROM_NOW\nFROM \n \"Database name\".dbo.EMPLOYEES EMP\nWHERE 1 = (FLOOR(DATEDIFF(dd,EMP.BRTHDATE,GETDATE()+7) / 365.25))\n -\n (FLOOR(DATEDIFF(dd,EMP.BRTHDATE,GETDATE()) / 365.25))\n"
},
{
"answer_id": 83934,
"author": "Esteban Brenes",
"author_id": 14177,
"author_profile": "https://Stackoverflow.com/users/14177",
"pm_score": 0,
"selected": false,
"text": "SELECT * FROM Employees\nWHERE DATEADD(yyyy, DATEPART(yyyy, @Today)-DATEPART(yyyy, Birthday), Birthday) > @Today \nAND DATEADD(yyyy, DATEPART(yyyy, @Today)-DATEPART(yyyy, Birthday), Birthday) < DATEADD(dd, @NumDays, @Today)\n"
},
{
"answer_id": 84297,
"author": "Philippe Grondier",
"author_id": 11436,
"author_profile": "https://Stackoverflow.com/users/11436",
"pm_score": 4,
"selected": false,
"text": "ageOfThePerson = DATEDIFF(yyyy,dateOfBirth, GETDATE())"
},
{
"answer_id": 84536,
"author": "clweeks",
"author_id": 13748,
"author_profile": "https://Stackoverflow.com/users/13748",
"pm_score": 0,
"selected": false,
"text": "select (365 + datediff(d,getdate(),cast(cast(datepart(yy,getdate()) as varchar(4)) + '-' + cast(datepart(m,birthdt) as varchar(2)) + '-' + cast(datepart(d,birthdt) as varchar(2)) as datetime))) % 365\nfrom employees\nwhere (365 + datediff(d,getdate(),cast(cast(datepart(yy,getdate()) as varchar(4)) + '-' + cast(datepart(m,birthdt) as varchar(2)) + '-' + cast(datepart(d,birthdt) as varchar(2)) as datetime))) % 365 < @NumDays\n"
},
{
"answer_id": 330231,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "DECLARE @sam TABLE\n(\n EmployeeIDs int,\n dob datetime\n)\nINSERT INTO @sam (dob, EmployeeIDs)\nSELECT DOBirth, EmployeeID FROM Employee\n\nSELECT *\nFROM\n(\n SELECT *, bd_this_year = DATEADD(YEAR, DATEPART(YEAR, GETDATE()) - DATEPART(YEAR, dob), dob)\n FROM @sam s\n) d\nWHERE d.bd_this_year > DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 0)\nAND d.bd_this_year <= DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 3)\n"
},
{
"answer_id": 528623,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "select Employeename,DOB \nfrom Employeemaster\nwhere day(Dob)>day(getdate()) and month(DOB)>=month(getDate())\n"
},
{
"answer_id": 2142833,
"author": "Kyle",
"author_id": 259594,
"author_profile": "https://Stackoverflow.com/users/259594",
"pm_score": 0,
"selected": false,
"text": "SELECT DISTINCT FLOOR(DATEDIFF(dd,Birthday, @BeginDate) / 365.25) + 1 age,\nDATEADD(yyyy, FLOOR(DATEDIFF(dd,Birthday, @BeginDate) / 365.25) + 1, Birthday) nextbirthday, birthday\nFROM table\nWHERE DATEADD(yyyy, FLOOR(DATEDIFF(dd,Birthday, @BeginDate) / 365.25) + 1, Birthday) > @BeginDate \nAND DATEADD(yyyy, FLOOR(DATEDIFF(dd,Birthday, @BeginDate) / 365.25) + 1, Birthday) < DATEADD(dd, @NumDays, @BeginDate)\norder by nextbirthday\n"
},
{
"answer_id": 2425453,
"author": "Ramandeep Singh",
"author_id": 291531,
"author_profile": "https://Stackoverflow.com/users/291531",
"pm_score": 0,
"selected": false,
"text": "DECLARE @StartDate DATETIME\nDECLARE @EndDate DATETIME\n\nSELECT Member.* from vwMember AS Member \nWHERE (DATEADD(YEAR, (DATEPART(YEAR, @StartDate) -\n DATEPART(YEAR, Member.dBirthDay)), Member.dBirthDay)\nBETWEEN @StartDate AND @EndDate)\n"
},
{
"answer_id": 4142816,
"author": "strelc",
"author_id": 502970,
"author_profile": "https://Stackoverflow.com/users/502970",
"pm_score": 1,
"selected": false,
"text": "SELECT * FROM rojstni_dnevi\n WHERE (DATEDIFF (dd, \n getdate(), \n DATEADD ( yyyy, \n DATEDIFF(yyyy, rDan, getdate()),\n rDan)\n nex )\n +365) % 365 < 30\n"
},
{
"answer_id": 4352871,
"author": "Nenad SRB",
"author_id": 530324,
"author_profile": "https://Stackoverflow.com/users/530324",
"pm_score": -1,
"selected": false,
"text": "SELECT person, year(today)-year(birthdate) as years, birthdate,\n\nCASE\nWHEN MOD(year(birthdate)+((year(today)-year(birthdate))+1),4)<>0 AND MONTH(birthdate)=2 AND DAY(birthdate)=29 THEN \n CASE \n WHEN mdy(month(birthdate), 28, year(birthdate)+((year(today)-year(birthdate))+1))-today >= 365 THEN (mdy(month(birthdate), 28, year(birthdate)+((year(today)-year(birthdate))+1))-today)-365\n WHEN mdy(month(birthdate), 28, year(birthdate)+((year(today)-year(birthdate))+1))-today < 365 THEN mdy(month(birthdate), 28, year(birthdate)+((year(today)-year(birthdate))+1))-today\n END\nELSE\n CASE \n WHEN mdy(month(birthdate), day(birthdate), year(birthdate)+((year(today)-year(birthdate))+1))-today >= 365 THEN (mdy(month(birthdate), day(birthdate), year(birthdate)+((year(today)-year(birthdate))+1))-today)-365\n WHEN mdy(month(birthdate), day(birthdate), year(birthdate)+((year(today)-year(birthdate))+1))-today < 365 THEN mdy(month(birthdate), day(birthdate), year(birthdate)+((year(today)-year(birthdate))+1))-today\n END\nEND until\n\nFROM table_name\nWHERE mdy(month(birthdate), day(birthdate), 2000) >= mdy(month(today), day(today), 2000)\nAND mdy(month(birthdate), day(birthdate), 2000) <= mdy(month(today), day(today), 2000)+30\nOR\nmdy(month(birthdate), day(birthdate), 2000) <= mdy(month(today), day(today), 2000)-(365-30)\nORDER BY 4, YEAR(birthdate)\n"
},
{
"answer_id": 5732821,
"author": "Andres SK",
"author_id": 338840,
"author_profile": "https://Stackoverflow.com/users/338840",
"pm_score": 4,
"selected": false,
"text": "SELECT\n name,birthday,\n FLOOR(DATEDIFF(DATE(NOW()),birthday) / 365.25) AS age_now,\n FLOOR(DATEDIFF(DATE_ADD(DATE(NOW()),INTERVAL 30 DAY),birthday) / 365.25) AS age_future\n\nFROM user\n\nWHERE 1 = (FLOOR(DATEDIFF(DATE_ADD(DATE(NOW()),INTERVAL 30 DAY),birthday) / 365.25)) - (FLOOR(DATEDIFF(DATE(NOW()),birthday) / 365.25))\n\nORDER BY MONTH(birthday),DAY(birthday)\n"
},
{
"answer_id": 8322697,
"author": "Jovial",
"author_id": 1072876,
"author_profile": "https://Stackoverflow.com/users/1072876",
"pm_score": 1,
"selected": false,
"text": " select EmployeeID,DOB,dates.date from emp_tb_eob_employeepersonal \n cross join dbo.GetDays(Getdate(),Getdate()+7) as dates where weekofmonthnumber>0\n and month(dates.date)=month(DOB) and day(dates.date)=day(DOB)\n\n\n\nGO\n/****** Object: UserDefinedFunction [dbo].[GetDays] Script Date: 11/30/2011 13:19:17 ******/\nSET ANSI_NULLS ON\nGO\nSET QUOTED_IDENTIFIER ON\nGO\n--SELECT [dbo].[GetDays] ('02/01/2011','02/28/2011')\n\nALTER FUNCTION [dbo].[GetDays](@startDate datetime, @endDate datetime)\nRETURNS @retValue TABLE\n(Days int ,Date datetime, WeekOfMonthNumber int, WeekOfMonthDescription varchar(10), DayName varchar(10))\nAS\nBEGIN\n DECLARE @nextDay int\n DECLARE @nextDate datetime \n DECLARE @WeekOfMonthNum int \n DECLARE @WeekOfMonthDes varchar(10) \n DECLARE @DayName varchar(10) \n SELECT @nextDate = @startDate, @WeekOfMonthNum = DATEDIFF(week, DATEADD(MONTH, DATEDIFF(MONTH,0,@startDate),0),@startDate) + 1, \n @WeekOfMonthDes = CASE @WeekOfMonthNum \n WHEN '1' THEN 'First' \n WHEN '2' THEN 'Second' \n WHEN '3' THEN 'Third' \n WHEN '4' THEN 'Fourth' \n WHEN '5' THEN 'Fifth' \n WHEN '6' THEN 'Sixth' \n END, \n @DayName \n = DATENAME(weekday, @startDate)\nSET @nextDay=1\nWHILE @nextDate <= @endDate \nBEGIN \n INSERT INTO @retValue values (@nextDay,@nextDate, @WeekOfMonthNum, @WeekOfMonthDes, @DayName) \n SELECT @nextDay=@nextDay + 1 \nSELECT @nextDate = DATEADD(day,1,@nextDate), \n @WeekOfMonthNum \n = DATEDIFF(week, DATEADD(MONTH, DATEDIFF(MONTH,0, @nextDate),0), @nextDate) + 1, \n @WeekOfMonthDes \n = CASE @WeekOfMonthNum \n WHEN '1' THEN 'First' \n WHEN '2' THEN 'Second' \n WHEN '3' THEN 'Third' \n WHEN '4' THEN 'Fourth' \n WHEN '5' THEN 'Fifth' \n WHEN '6' THEN 'Sixth' \n END, \n @DayName \n = DATENAME(weekday, @nextDate) \n CONTINUE \nEND \n\nWHILE(@nextDay <=31)\nBEGIN\n\n\n INSERT INTO @retValue values (@nextDay,@nextDate, 0, '', '') \n SELECT @nextDay=@nextDay + 1\n\nEND\n\n RETURN\nEND\n"
},
{
"answer_id": 8762129,
"author": "ButterDog",
"author_id": 575085,
"author_profile": "https://Stackoverflow.com/users/575085",
"pm_score": 0,
"selected": false,
"text": "select * from `schema`.`table` where date_format(birthday,'%m%d') >= date_format(now(),'%m%d') and date_format(birthday,'%m%d') < date_format(DATE_ADD(NOW(), INTERVAL 5 DAY),'%m%d');\n"
},
{
"answer_id": 10525075,
"author": "RoMEoMusTDiE",
"author_id": 1385774,
"author_profile": "https://Stackoverflow.com/users/1385774",
"pm_score": 0,
"selected": false,
"text": "SELECT Employee_Name, DATE_OF_BIRTH\nFROM Hr_table \nWHERE \n\n/**\nfetching the original birth_date and replacing the birth year to the current but have to deduct 7 days to adjust jan 1-7 birthdate.\n**/\n\ndatediff(d,getdate(),DATEADD(year,datediff(year,DATEADD(d,-7,hr.DATE_OF_BIRTH),getdate()),hr.date_of_birth)) between 0 and 7\n\n-- current date looks ahead to 7 days for upcoming modified year birth date.\n\norder by\n\n-- sort by no of days before the birthday\ndatediff(d,getdate(),DATEADD(year,datediff(year,DATEADD(d,-7,hr.DATE_OF_BIRTH),getdate()),hr.date_of_birth))\n"
},
{
"answer_id": 10761415,
"author": "Edyn",
"author_id": 835561,
"author_profile": "https://Stackoverflow.com/users/835561",
"pm_score": 2,
"selected": false,
"text": "SELECT * FROM User \nWHERE (DATEDIFF(dd, getdate(), DATEADD(yyyy, \n DATEDIFF(yyyy, birthdate, getdate()) + 1, birthdate)) + 1) % 366 <= <number of days>\n"
},
{
"answer_id": 15727698,
"author": "The-Kido",
"author_id": 2228838,
"author_profile": "https://Stackoverflow.com/users/2228838",
"pm_score": -1,
"selected": false,
"text": "CREATE PROCEDURE [dbo].[P_EmployeesGetBirths]\n @Date Date,\n @Days int\n as\n Begin\n SET NOCOUNT ON;\n\n Declare\n @From int = Month(@Date) * 100 + Day(@Date),\n @To int = Month(DateAdd(DD, @Days, @Date)) * 100 + Day(DateAdd(DD, @Days, @Date)),\n @NeutralDate Date = Cast('1900-'+cast(Month(@Date) as nvarchar(2))+'-' + cast(Day(@Date) as nvarchar(2)) as Date)\n\n Select\n DOB,\n DATEADD(DD, DateDiff(DD, @NeutralDate, DateAdd(YY, 1900-Year(DOB), DOB)), @Date) OnDate\n From\n Employees(nolock)\n Where\n DOB is not null and\n Month(DOB) * 100 + Day(DOB) between @From and @To\n order by\n Month(DOB) * 100 + Day(DOB)\n End\n Go\n"
},
{
"answer_id": 20287262,
"author": "AjitChahal",
"author_id": 1182993,
"author_profile": "https://Stackoverflow.com/users/1182993",
"pm_score": 0,
"selected": false,
"text": "select * from users with(nolock)\nwhere date_of_birth is not null \nand \n(\n DATEDIFF(dd,\n DATEADD(yy, -(YEAR(GETDATE())-1900),GETDATE()), --Today\n DATEADD(yy, -(YEAR(date_of_birth)-1901),date_of_birth)\n ) % 365\n) = 30\n"
},
{
"answer_id": 27052958,
"author": "Danilo",
"author_id": 4276813,
"author_profile": "https://Stackoverflow.com/users/4276813",
"pm_score": 1,
"selected": false,
"text": "SELECT * FROM people WHERE MOD( DATEDIFF( CURDATE( ) , `date_birth`) /30, 12 ) <1 and (((month(`date_birth`)) = (month(curdate())) and (day(`date_birth`)) > (day (curdate() ))) or ((month(`date_birth`)) > (month(curdate())) and (day(`date_birth`)) < (day (curdate() ))))\n"
},
{
"answer_id": 31208983,
"author": "Pilso",
"author_id": 3115921,
"author_profile": "https://Stackoverflow.com/users/3115921",
"pm_score": 0,
"selected": false,
"text": "with rs (bty) as (\n SELECT DATEADD(Year, DATEPART(Year, GETDATE()) - DATEPART(Year, dob), dob) as bty FROM Employees\n),\nrs2 (nbd) as (\n select case when bty < getdate() then DATEADD(yyyy, 1, bty) else bty end as nbd from rs\n)\nselect nbd, DATEDIFF(d, getdate(), nbd) as diff from rs2 where DATEDIFF(d, getdate(), nbd) < 14 order by diff\n"
},
{
"answer_id": 31745302,
"author": "Raj Sharma",
"author_id": 5177678,
"author_profile": "https://Stackoverflow.com/users/5177678",
"pm_score": 0,
"selected": false,
"text": "DATEPART"
},
{
"answer_id": 35137197,
"author": "Fede H",
"author_id": 2718127,
"author_profile": "https://Stackoverflow.com/users/2718127",
"pm_score": 2,
"selected": false,
"text": "SELECT * FROM Employees \nWHERE \nCASE WHEN (DATEADD(yyyy,DATEDIFF(yyyy, birthdt, @fromDate),birthdt) < @fromDate )\nTHEN DATEADD(yyyy,DATEDIFF(yyyy, birthdt, @fromDate)+1,birthdt)\nELSE DATEADD(yyyy,DATEDIFF(yyyy, birthdt, @fromDate),birthdt) END\nBETWEEN @fromDate AND @toDate\n"
},
{
"answer_id": 35649323,
"author": "Bhavesh Patel",
"author_id": 3959714,
"author_profile": "https://Stackoverflow.com/users/3959714",
"pm_score": -1,
"selected": false,
"text": "SELECT * FROM tblMember m\nWHERE m.GDExpireDate != '' \nAND CONVERT(CHAR(2),CONVERT(datetime, m.dob, 103), 101) = CONVERT(CHAR(2), GETDATE(), 101) \nAND CONVERT(CHAR(2),CONVERT(datetime, m.dob, 103), 103) >= CONVERT(CHAR(2), GETDATE(), 103)\n"
},
{
"answer_id": 52299426,
"author": "Paresh Patel",
"author_id": 3667653,
"author_profile": "https://Stackoverflow.com/users/3667653",
"pm_score": 0,
"selected": false,
"text": "SELECT \n Employee.DOB,\n DATEADD(\n mm, \n (\n (\n (\n (\n DATEPART(yyyy, getdate())-DATEPART(yyyy, Employee.DOB )\n )\n +\n (\n 1-\n (\n ((DATEPART(mm, Employee.DOB)*100)+DATEPART(dd, Employee.DOB))\n /\n ((DATEPART(mm, getdate())*100) + DATEPART(dd, getdate()))\n )\n )\n )\n *12\n )\n ), \n Employee.DOB\n ) NextDOB\nFROM \n Employee \nORDER BY \n NextDOB ;\n"
},
{
"answer_id": 55558001,
"author": "smoothware",
"author_id": 3465437,
"author_profile": "https://Stackoverflow.com/users/3465437",
"pm_score": 0,
"selected": false,
"text": "SELECT\n *, \n strftime('%j', birthday) - strftime('%j', 'now') AS days_remaining\nFROM\n person\nWHERE :n_days >= CASE\n WHEN days_remaining >= 0 THEN days_remaining\n ELSE days_remaining + strftime('%j', strftime('%Y-12-31', 'now'))\n END\n;\n"
},
{
"answer_id": 69908338,
"author": "Santosh Kumar",
"author_id": 17373939,
"author_profile": "https://Stackoverflow.com/users/17373939",
"pm_score": 0,
"selected": false,
"text": "select * \nfrom tableName\nwhere DAY(convert(date,GETDATE(),105))=DAY(convert(date,DOB,105))\nand month(convert(date,GETDATE(),105))=month(convert(date,DOB,105))\n"
},
{
"answer_id": 70525916,
"author": "Renato M",
"author_id": 7530317,
"author_profile": "https://Stackoverflow.com/users/7530317",
"pm_score": 0,
"selected": false,
"text": "CREATE FUNCTION dbo.FN_NEXT_BIRTHDAY(@BIRTHDAY DATE)\nRETURNS DATE\nAS\nBEGIN\n DECLARE @ACTUAL DATE = DATEADD(YEAR, DATEDIFF(YEAR, @BIRTHDAY , GETDATE()), @BIRTHDAY);\n DECLARE @NEXT DATE = DATEADD(YEAR, DATEDIFF(YEAR, @BIRTHDAY , GETDATE())+1, @BIRTHDAY);\n\n RETURN CASE WHEN @ACTUAL > GETDATE() THEN @ACTUAL \n ELSE @NEXT \n END;\nEND;\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2460/"
] |
83,547
|
<p>I have a decimal number (let's call it <strong>goal</strong>) and an array of other decimal numbers (let's call the array <strong>elements</strong>) and I need to find all the combinations of numbers from <strong>elements</strong> which sum to goal.</p>
<p>I have a preference for a solution in C# (.Net 2.0) but may the best algorithm win irrespective.</p>
<p>Your method signature might look something like:</p>
<pre><code>public decimal[][] Solve(decimal goal, decimal[] elements)
</code></pre>
|
[
{
"answer_id": 84168,
"author": "Sam Meldrum",
"author_id": 16005,
"author_profile": "https://Stackoverflow.com/users/16005",
"pm_score": 5,
"selected": true,
"text": "public class Solver {\n\n private List<List<decimal>> mResults;\n\n public List<List<decimal>> Solve(decimal goal, decimal[] elements) {\n\n mResults = new List<List<decimal>>();\n RecursiveSolve(goal, 0.0m, \n new List<decimal>(), new List<decimal>(elements), 0);\n return mResults; \n }\n\n private void RecursiveSolve(decimal goal, decimal currentSum, \n List<decimal> included, List<decimal> notIncluded, int startIndex) {\n\n for (int index = startIndex; index < notIncluded.Count; index++) {\n\n decimal nextValue = notIncluded[index];\n if (currentSum + nextValue == goal) {\n List<decimal> newResult = new List<decimal>(included);\n newResult.Add(nextValue);\n mResults.Add(newResult);\n }\n else if (currentSum + nextValue < goal) {\n List<decimal> nextIncluded = new List<decimal>(included);\n nextIncluded.Add(nextValue);\n List<decimal> nextNotIncluded = new List<decimal>(notIncluded);\n nextNotIncluded.Remove(nextValue);\n RecursiveSolve(goal, currentSum + nextValue,\n nextIncluded, nextNotIncluded, startIndex++);\n }\n }\n }\n}\n"
},
{
"answer_id": 2629125,
"author": "guest",
"author_id": 315410,
"author_profile": "https://Stackoverflow.com/users/315410",
"pm_score": -1,
"selected": false,
"text": "public class Logic1 {\n static int val = 121;\n public static void main(String[] args)\n {\n f(new int[] {1,4,5,17,16,100,100}, 0, 0, \"{\");\n }\n\n static void f(int[] numbers, int index, int sum, String output)\n {\n System.out.println(output + \" } = \" + sum);\n //System.out.println(\"Index value1 is \"+index);\n check (sum);\n if (index == numbers.length)\n {\n System.out.println(output + \" } = \" + sum);\n return;\n }\n\n // include numbers[index]\n f(numbers, index + 1, sum + numbers[index], output + \" \" + numbers[index]);\n check (sum);\n //System.out.println(\"Index value2 is \"+index);\n // exclude numbers[index]\n f(numbers, index + 1, sum, output);\n check (sum);\n }\n\n static void check (int sum1)\n {\n if (sum1 == val)\n System.exit(0);\n }\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16005/"
] |
83,553
|
<p>I need to write a program used internally where different users will have different abilities within the program.</p>
<p>Rather than making users have a new username and password, how do I tie into an existing domain server's login system?</p>
<p>Assume .NET (C#, VB, ASP, etc)</p>
<p>-Adam</p>
|
[
{
"answer_id": 83587,
"author": "Matt Everson",
"author_id": 7300,
"author_profile": "https://Stackoverflow.com/users/7300",
"pm_score": 3,
"selected": true,
"text": "private string getWindowsUsername()\n{\n AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);\n return Thread.CurrentPrincipal.Identity.Name;\n}\n"
},
{
"answer_id": 83619,
"author": "Stephen Wrighton",
"author_id": 7516,
"author_profile": "https://Stackoverflow.com/users/7516",
"pm_score": 1,
"selected": false,
"text": "Trim(Request.ServerVariables(\"LOGON_USER\")).Replace(\"/\", \"\\\").Replace(\"'\", \"''\")\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2915/"
] |
83,593
|
<p>Having a set of (2D) points from a GIS file (a city map), I need to generate the polygon that defines the 'contour' for that map (its boundary). Its input parameters would be the points set and a 'maximum edge length'. It would then output the corresponding (probably non-convex) polygon.</p>
<p>The best solution I found so far was to generate the Delaunay triangles and then remove the external edges that are longer than the maximum edge length. After all the external edges are shorter than that, I simply remove the internal edges and get the polygon I want. The problem is, this is very time-consuming and I'm wondering if there's a better way.</p>
|
[
{
"answer_id": 83975,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "H01 = bearing from P0 to P1\nH12 = bearing from P1 to P2\nA = fmod( H12-H01+360, 360 )\n|P2-P1| <= MaxEdgeLength\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8999/"
] |
83,604
|
<p>I am wondering what makes sense in relation to what objects to expose through a WCF service - should I add WCF Serialization specifications to my business entities or should I implement a converter that maps my business entities to the DataContracts that I want to expose through my WCF service?</p>
<p>Right now I have entities on different levels: DataAccess, Business and Contract. I have converters in place that can map entities from DataAccess to Business and from Business to Contract and vice versa. Implementing and Maintaining those is time consuming and pretty tedious. What are best practices in relation to this? </p>
<p>If I were using an OR/M such as NHibernate or Entity Framework should I be exposing the entities from the ORM directly or should I abstract them the same way I am doing now?</p>
|
[
{
"answer_id": 2402961,
"author": "Raj Rao",
"author_id": 44815,
"author_profile": "https://Stackoverflow.com/users/44815",
"pm_score": 1,
"selected": false,
"text": "//Business Entity\nclass Person\n{\n public string Name{ get; set; }\n public int Age{ get; set; }\n}\n\n\n//Data transfer object\n[DataContract(Name=\"Person\")] //<-- this is what makes the WSDL look nice and clean\nclass PersonDTO\n{\n [DataMember(Name = \"Name\", Order = 0)]\n public string Name{ get; set; }\n [DataMember(Name = \"Age\", Order = 1)]\n public int Age{ get; set; }\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15771/"
] |
83,640
|
<p>For data types such as std::set and std::map where lookup occurs in logarithmic time, is the implementation required to maintain the begin and end iterators? Does accessing begin and end imply a lookup that could occur in logarithmic time?</p>
<p>I have always assumed that begin and end always occur in constant time, however I can't find any confirmation of this in Josuttis. Now that I'm working on something where I need to be anal about performance, I want to make sure to cover my bases.</p>
<p>Thanks</p>
|
[
{
"answer_id": 83682,
"author": "amo-ej1",
"author_id": 15791,
"author_profile": "https://Stackoverflow.com/users/15791",
"pm_score": 2,
"selected": false,
"text": "std::map"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8123/"
] |
83,653
|
<p>The following returns </p>
<blockquote>
<p>Type of conditional expression cannot be determined because there is no implicit conversion between 'double' and '<null>'</p>
</blockquote>
<pre><code>aNullableDouble = (double.TryParse(aString, out aDouble) ? aDouble : null)
</code></pre>
<hr>
<p>The reason why I can't just use aNullableBool instead of the roundtrip with aDouble is because aNullableDouble is a property of a generated EntityFramework class which cannot be used as an out par.</p>
|
[
{
"answer_id": 83664,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 1,
"selected": false,
"text": "aNullableDouble = (double.TryParse(aString, out aDouble)?new Nullable<double>(aDouble):null)\n"
},
{
"answer_id": 83667,
"author": "ljs",
"author_id": 3394,
"author_profile": "https://Stackoverflow.com/users/3394",
"pm_score": 4,
"selected": true,
"text": "aNullableDouble = double.TryParse(aString, out aDouble) ? (double?)aDouble : null;\n"
},
{
"answer_id": 83676,
"author": "Joel Martinez",
"author_id": 5416,
"author_profile": "https://Stackoverflow.com/users/5416",
"pm_score": 3,
"selected": false,
"text": "aNullableDouble = null;\nif (double.TryParse(aString, out aDouble))\n{\n aNullableDouble = aDouble;\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] |
83,674
|
<p>I want to find records on a combination of created_on >= some date AND name IN some list of names.</p>
<p>For ">=" I'd have to use sql condition. For "IN" I'd have to use a hash of conditions where the key is :name and the value is the array of names.</p>
<p>Is there a way to combine the two?</p>
|
[
{
"answer_id": 83736,
"author": "Laurie Young",
"author_id": 7473,
"author_profile": "https://Stackoverflow.com/users/7473",
"pm_score": 6,
"selected": true,
"text": "Class Test < ActiveRecord::Base\n named_scope :created_after_2005, :conditions => \"created_on > 2005-01-01\"\n named_scope :named_fred, :conditions => { :name => \"fred\"}\nend\n"
},
{
"answer_id": 83933,
"author": "Sixty4Bit",
"author_id": 1681,
"author_profile": "https://Stackoverflow.com/users/1681",
"pm_score": 2,
"selected": false,
"text": "class Person < ActiveRecord::Base\n named_scope :registered, lambda { |time_ago| { :conditions => ['created_at > ?', time_ago] } }\n named_scope :with_names, lambda { |names| { :conditions => { :names => names } } }\nend\n"
},
{
"answer_id": 84256,
"author": "Honza",
"author_id": 8621,
"author_profile": "https://Stackoverflow.com/users/8621",
"pm_score": 1,
"selected": false,
"text": "names = [\"dave\", \"jerry\", \"mike\"]\ndate = DateTime.now\nPerson.find(:all, :conidtions => [\"created_at > ? AND name IN ?\", date, names])\n"
},
{
"answer_id": 85781,
"author": "Josh Schwartzman",
"author_id": 16447,
"author_profile": "https://Stackoverflow.com/users/16447",
"pm_score": 3,
"selected": false,
"text": "Person.find(:all, :conditions => [\"created_at > ? AND name IN (?)\", date, names])\n"
},
{
"answer_id": 127668,
"author": "ismaSan",
"author_id": 21702,
"author_profile": "https://Stackoverflow.com/users/21702",
"pm_score": 2,
"selected": false,
"text": "class Post < ActiveRecord::Base\n named_scope :published, :conditions => {:status => 'published'}\nend\n\n@post = Post.published\n\n@posts = current_user.posts.published\n"
},
{
"answer_id": 16311941,
"author": "Sujoy Gupta",
"author_id": 634977,
"author_profile": "https://Stackoverflow.com/users/634977",
"pm_score": 2,
"selected": false,
"text": "where"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1167846/"
] |
83,687
|
<p>I have a need to display a <code>UITableView</code> containing a user's account credentials. For this, I'm using <code>UILabels</code> in <code>UITableViewCell</code>. When I display their password, I'd obviously like to just display a placeholder password character instead of their actual password, similar to a <code>UITextField</code> when it's set to secure text entry mode. In fact, I'd like to use the same character as <code>UITextField</code> uses, instead of '*'. </p>
<p>My question is, what is the character code for the password character the <code>UITextField</code> when it's in secure mode?</p>
|
[
{
"answer_id": 9304081,
"author": "Scott Gardner",
"author_id": 616764,
"author_profile": "https://Stackoverflow.com/users/616764",
"pm_score": 4,
"selected": false,
"text": "// self.password is your password string\nNSMutableString *dottedPassword = [NSMutableString new];\n\nfor (int i = 0; i < [self.password length]; i++)\n{\n [dottedPassword appendString:@\"●\"]; // BLACK CIRCLE Unicode: U+25CF, UTF-8: E2 97 8F\n}\n\ncell.detailTextLabel.text = dottedPassword;\n"
},
{
"answer_id": 44282514,
"author": "Max",
"author_id": 1471587,
"author_profile": "https://Stackoverflow.com/users/1471587",
"pm_score": 2,
"selected": false,
"text": "passwordLabel.text = String(password.characters.map { _ in return \"•\" })\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1967/"
] |
83,696
|
<p>Generally, what's the best way to tackle a layout bug in IE6? What are the most common bugs or problems that one should look for when trying to figure out why your page suddenly looks like a monkey coded it?</p>
|
[
{
"answer_id": 83733,
"author": "Alex King",
"author_id": 15813,
"author_profile": "https://Stackoverflow.com/users/15813",
"pm_score": 2,
"selected": false,
"text": "border: 1px solid red;"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11078/"
] |
83,723
|
<p>I'm working on an email validation check and we need to decided whether to allow user@localhost and user@example (notice no .anything) to be validated as a valid email address. This is for an open source project that has a number of use cases on both the web at large and intranets.</p>
<p><a href="http://www.ietf.org/rfc/rfc2822.txt" rel="nofollow noreferrer">RFC 2822</a> (Internet Message Format Standard) allows it but <a href="http://www.ietf.org/rfc/rfc2821.txt" rel="nofollow noreferrer">RFC 2821</a> (SMTP Standard) says it should fail.</p>
<p>Thoughts?</p>
|
[
{
"answer_id": 85324,
"author": "Devin Reams",
"author_id": 16248,
"author_profile": "https://Stackoverflow.com/users/16248",
"pm_score": 0,
"selected": false,
"text": "<?php \nfunction valid_email($email) { \n // First, we check that there's one @ symbol, and that the lengths are right \n if (!ereg(\"^[^@]{1,64}@[^@]{1,255}$\", $email)) { \n // Email invalid because wrong number of characters in one section, or wrong number of @ symbols.\n return false; \n }\n\n // take a given email address and split it into the username and domain. \n list($userName, $mailDomain) = split(\"@\", $email); \n if (checkdnsrr($mailDomain, \"MX\")) { \n // this is a valid email domain! \n return true;\n } \n else { \n // this email domain doesn't exist!\n return false;\n }\n} \n?>\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11910/"
] |
83,741
|
<p>I need a simple way to monitor multiple text log files distributed over a number of HP-UX servers. They are a mix of text and XML log files from several distributed legacy systems. Currently we just ssh to the servers and use <em>tail -f</em> and <em>grep</em>, but that doesn't scale when you have many logs to keep track of.</p>
<p>Since the logs are in different formats and just files in folders (automatically rotated when they reach a certain size) I need to both collect them remotely and parse each one differently.</p>
<p>My initial thought was to make a simple daemon process that I can run on each server using a custom file reader for each file type to parse it into a common format that can be exported over the network via a socket. Another viewer program running locally will connect to these sockets and show the parsed logs in some simple tabbed GUI or aggregated to a console.</p>
<p>What log format should I try to convert to if I am to implement it this way?</p>
<p>Is there some other easier way? Should I attempt to translate the log files to the log4j format to use with <a href="http://logging.apache.org/chainsaw/" rel="noreferrer">Chainsaw</a> or are there better log viewers that can connect to remote sockets? Could I use <a href="http://www.baremetalsoft.com/baretail/" rel="noreferrer">BareTail</a> as suggested in <a href="https://stackoverflow.com/questions/18632/how-to-monitor-a-text-file-in-realtime#18690">another log question</a>? This is not a <a href="https://stackoverflow.com/questions/35292/log-files-in-massively-distributed-systems">massivly distributed system</a> and changing the current logging implementations for all applications to use UDP broadcast or put messages on a JMS queue is not an option.</p>
|
[
{
"answer_id": 164003,
"author": "masukomi",
"author_id": 13973,
"author_profile": "https://Stackoverflow.com/users/13973",
"pm_score": 4,
"selected": false,
"text": "#!/bin/bash\nFILE=$1\nfor box in box1.foo.com box2.foo.com box3.foo.com box4.foo.com; do\n ssh $box tail -f $FILE &\ndone\n"
},
{
"answer_id": 3479337,
"author": "mrm",
"author_id": 1268016,
"author_profile": "https://Stackoverflow.com/users/1268016",
"pm_score": 5,
"selected": false,
"text": "dsh -Mac -- tail -f /var/log/apache/*.log\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83741",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4992/"
] |
83,756
|
<p>I need to enable/disable completely network interfaces from a script in Windows XP. I'm looking for a python solution, but any general way (eg WMI, some command-line à la netsh, some windows call) is welcome and will be adjusted. Thanks.</p>
|
[
{
"answer_id": 83800,
"author": "Matt Everson",
"author_id": 7300,
"author_profile": "https://Stackoverflow.com/users/7300",
"pm_score": 0,
"selected": false,
"text": "devcon disable (id or portion of name)\ndevcon enable (id or portion of name)\n"
},
{
"answer_id": 83890,
"author": "chrissie1",
"author_id": 2936,
"author_profile": "https://Stackoverflow.com/users/2936",
"pm_score": 0,
"selected": false,
"text": "Dim objectQuery As New ObjectQuery(\"SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionId IS NOT NULL\")\n Dim searcher As New ManagementObjectSearcher(scope, objectQuery)\n Dim os As ManagementObject\n Dim moColl As ManagementObjectCollection = searcher.Get()\n Dim _list As String = \"\"\n For Each os In moColl\n Console.WriteLine(os(\"NetConnectionId\"))\n Next os\n"
},
{
"answer_id": 84315,
"author": "tzot",
"author_id": 6899,
"author_profile": "https://Stackoverflow.com/users/6899",
"pm_score": 3,
"selected": false,
"text": ">>> import wmi; c=wmi.WMI()\n>>> o=c.query(\"select * from Win32_NetworkAdapter where NetConnectionID='wifi'\")[0]\n>>> o.EnableDevice(1)\n(-2147217407,)\n"
},
{
"answer_id": 4317191,
"author": "Warren P",
"author_id": 84704,
"author_profile": "https://Stackoverflow.com/users/84704",
"pm_score": 2,
"selected": false,
"text": "Const ssfCONTROLS = 3 \n\nsConnectionName = \"Local Area Connection\" \n\nsEnableVerb = \"En&able\" \nsDisableVerb = \"Disa&ble\" \n\nset shellApp = createobject(\"shell.application\") \nset oControlPanel = shellApp.Namespace(ssfCONTROLS) \n\nset oNetConnections = nothing \nfor each folderitem in oControlPanel.items \n if folderitem.name = \"Network Connections\" then \n set oNetConnections = folderitem.getfolder: exit for \nend if \nnext \n\nif oNetConnections is nothing then \nmsgbox \"Couldn't find 'Network Connections' folder\" \nwscript.quit \nend if \n\nset oLanConnection = nothing \nfor each folderitem in oNetConnections.items \nif lcase(folderitem.name) = lcase(sConnectionName) then \nset oLanConnection = folderitem: exit for \nend if \nnext \n\nif oLanConnection is nothing then \nmsgbox \"Couldn't find '\" & sConnectionName & \"' item\" \nwscript.quit \nend if \n\nbEnabled = true \nset oEnableVerb = nothing \nset oDisableVerb = nothing \ns = \"Verbs: \" & vbcrlf \nfor each verb in oLanConnection.verbs \ns = s & vbcrlf & verb.name \nif verb.name = sEnableVerb then \nset oEnableVerb = verb \nbEnabled = false \nend if \nif verb.name = sDisableVerb then \nset oDisableVerb = verb \nend if \nnext \n\n'debugging displays left just in case... \n' \n'msgbox s ': wscript.quit \n'msgbox \"Enabled: \" & bEnabled ': wscript.quit \n\n'not sure why, but invokeverb always seemed to work \n'for enable but not disable. \n' \n'saving a reference to the appropriate verb object \n'and calling the DoIt method always seems to work. \n' \nif bEnabled then \n' oLanConnection.invokeverb sDisableVerb \noDisableVerb.DoIt \nelse \n' oLanConnection.invokeverb sEnableVerb \noEnableVerb.DoIt \nend if \n\n'adjust the sleep duration below as needed... \n' \n'if you let the oLanConnection go out of scope \n'and be destroyed too soon, the action of the verb \n'may not take... \n' \nwscript.sleep 1000\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6899/"
] |
83,770
|
<p>I'm trying to create a server control, which inherits from TextBox, that will automatically have a <a href="http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Calendar/Calendar.aspx" rel="nofollow noreferrer">CalendarExtender</a> attached to it. Is it possible to do this, or does my new control need to inherit from CompositeControl instead? I've tried the former, but I'm not clear during which part of the control lifecycle I should create the new instance of the CalendarExtender, and what controls collection I should add it to. I don't seem to be able to add it to the Page or Form's controls collection, and if I add it to the (TextBox) control's collection, I get none of the pop-up calendar functionality.</p>
|
[
{
"answer_id": 83951,
"author": "Joseph Daigle",
"author_id": 507,
"author_profile": "https://Stackoverflow.com/users/507",
"pm_score": 3,
"selected": true,
"text": "CreateChildControls"
},
{
"answer_id": 2254764,
"author": "spot",
"author_id": 145103,
"author_profile": "https://Stackoverflow.com/users/145103",
"pm_score": 1,
"selected": false,
"text": "Imports System.Web.UI.WebControls\nImports AjaxControlToolkit\n\nPublic Class DateTextBox\n Inherits TextBox\n\n Private _dateValidator As CompareValidator\n Private _calendarExtender As CalendarExtender\n\n Protected Overrides Sub OnInit(ByVal e As System.EventArgs)\n MyBase.OnInit(e)\n\n _dateValidator = New CompareValidator\n With _dateValidator\n .ControlToValidate = ID\n Rem set your other properties\n End With\n Controls.Add(_dateValidator)\n\n _calendarExtender = New CalendarExtender\n With _calendarExtender\n .TargetControlID = ID\n End With\n Controls.Add(_calendarExtender)\n End Sub\n\n Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)\n MyBase.Render(writer)\n _dateValidator.RenderControl(writer)\n _calendarExtender.RenderControl(writer)\n End Sub\nEnd Class\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13583/"
] |
83,779
|
<p>I've used Excel PivotTable to analyze data from my database because it allows me to "slice and dice" very quickly. As we know what is in our database tables, we all can write SQL queries that do what PivotTable does. </p>
<p>But I am wondering why PivotTable can construct the queries so fast while it knows <em>nothing</em> about the data and the meanings/relationship between the data fields we give it? </p>
<p>Put the question in another way, how can we build <em>ad-hoc</em> SQL queries in such a fast and efficient way? ("Use PivotTable, of course!", yep, but what I want is a programmatic way).</p>
|
[
{
"answer_id": 84120,
"author": "Martin08",
"author_id": 8203,
"author_profile": "https://Stackoverflow.com/users/8203",
"pm_score": 0,
"selected": false,
"text": "- the Page Fields zone \n- the Column Fields zone \n- the Row Fields zone and\n- the Data zone\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8203/"
] |
83,787
|
<p>I would like to extract the date a jpg file was created. Java has the lastModified method for the File object, but appears to provide no support for extracting the created date from the file. I believe the information is stored within the file as the date I see when I hover the mouse pointer over the file in Win XP is different than what I can get by using JNI with "dir /TC" on the file in DOS.</p>
|
[
{
"answer_id": 83922,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 0,
"selected": false,
"text": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n public static void main(final String[] args) {\n try {\n // get runtime environment and execute child process\n Runtime systemShell = Runtime.getRuntime();\n BufferedReader br1=new BufferedReader(new InputStreamReader(System.in));\n System.out.println(\"Enter filename: \");\n String fname=(String)br1.readLine();\n Process output = systemShell.exec(\"cmd /c dir /a \"+fname);\n // open reader to get output from process\n BufferedReader br = new BufferedReader (new InputStreamReader(output.getInputStream()));\n\n String out=\"\";\n String line = null;\n\n int step=1;\n while((line = br.readLine()) != null ) \n {\n if(step==6)\n {\n out=line;\n }\n step++;\n } // display process output\n\n try{\n out=out.replaceAll(\" \",\"\");\n System.out.println(\"CreationDate: \"+out.substring(0,10));\n System.out.println(\"CreationTime: \"+out.substring(10,15));\n }\n catch(StringIndexOutOfBoundsException se)\n {\n System.out.println(\"File not found\");\n }\n }\n catch (IOException ioe){ System.err.println(ioe); }\n catch (Throwable t) { t.printStackTrace();}\n }\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16029/"
] |
83,807
|
<p>All I know about the constraint is it's name (<code>SYS_C003415</code>), but I want to see it's definition.</p>
|
[
{
"answer_id": 83811,
"author": "Hank Gay",
"author_id": 4203,
"author_profile": "https://Stackoverflow.com/users/4203",
"pm_score": 5,
"selected": false,
"text": "ALL_CONSTRAINTS"
},
{
"answer_id": 108376,
"author": "cagcowboy",
"author_id": 19629,
"author_profile": "https://Stackoverflow.com/users/19629",
"pm_score": 4,
"selected": true,
"text": "DBMS_METADATA.GET_DDL('CONSTRAINT', 'SYS_C003415')\n"
},
{
"answer_id": 35593947,
"author": "Rakesh",
"author_id": 5238522,
"author_profile": "https://Stackoverflow.com/users/5238522",
"pm_score": 3,
"selected": false,
"text": "Select DBMS_METADATA.GET_DDL('CONSTRAINT', 'CONSTRAINT_NAME') from dual\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4203/"
] |
83,856
|
<p>I have a string coming from a table like "can no pay{1},as your payment{2}due on {3}". I want to replace {1} with some value , {2} with some value and {3} with some value .</p>
<p>Is it Possible to replace all 3 in one replace function ? or is there any way I can directly write query and get replaced value ? I want to replace these strings in Oracle stored procedure the original string is coming from one of my table I am just doing select on that table </p>
<p>and then I want to replace {1},{2},{3} values from that string to the other value that I have from another table </p>
|
[
{
"answer_id": 83910,
"author": "hamishmcn",
"author_id": 3590,
"author_profile": "https://Stackoverflow.com/users/3590",
"pm_score": 5,
"selected": true,
"text": "replace()"
},
{
"answer_id": 28584627,
"author": "Florin Ghita",
"author_id": 319875,
"author_profile": "https://Stackoverflow.com/users/319875",
"pm_score": 3,
"selected": false,
"text": "set define off;\ndrop table fg_rulez\ncreate table fg_rulez as \n select 1 id,'<' symbol, 'less than' text from dual\n union all select 2, '>', 'great than' from dual\n union all select 3, '$', 'dollars' from dual\n union all select 4, '&', 'and' from dual;\ndrop table fg_data;\ncreate table fg_Data AS(\n SELECT 'amount $ must be < 1 & > 2' str FROM dual\n union all\n SELECT 'John is > Peter & has many $' str FROM dual\n union all\n SELECT 'Eliana is < mary & do not has many $' str FROM dual\n\n );\n\n\nWITH q(str, id) as (\n SELECT str, 0 id \n FROM fg_Data \n UNION ALL\n SELECT replace(q.str,symbol,text), fg_rulez.id\n FROM q \n JOIN fg_rulez \n ON q.id = fg_rulez.id - 1\n)\nSELECT str from q where id = (select max(id) from fg_rulez);\n"
},
{
"answer_id": 35405674,
"author": "Ricardo Arnold",
"author_id": 1197394,
"author_profile": "https://Stackoverflow.com/users/1197394",
"pm_score": 1,
"selected": false,
"text": "with Dict as\n (select '{1}' String, 'myfirstval' Repl from dual\n union all\n select '{2}' String, 'mysecondval' Repl from dual\n union all\n select '{3}' String, 'mythirdval' Repl from dual\n union all \n select '{Nth}' String, 'myNthval' Repl from dual \n\n )\n,MyStrings as\n (select 'This is the first example {1} ' Str, 1 strnum from dual\n union all\n select 'In the Second example all values are shown {1} {2} {3} {Nth} ', 2 from dual\n union all\n select '{3} Is the value for the third', 3 from dual\n union all\n select '{Nth} Is the value for the Nth', 4 from dual \n )\n,pivot as (\n Select Rownum Pnum\n From dual\n Connect By Rownum <= 100 \n )\n,StrtoRow as\n(\nSELECT rownum rn\n ,ms.strnum\n ,REGEXP_SUBSTR (Str,'[^ ]+',1,pv.pnum) TXT\n FROM MyStrings ms\n ,pivot pv\nwhere REGEXP_SUBSTR (Str,'[^ ]+',1,pv.pnum) is not null\n)\nSelect Listagg(NVL(Repl,TXT),' ') within group (order by rn) \nfrom\n(\nSelect sr.TXT, d.Repl, sr.strnum, sr.rn\n from StrtoRow sr\n ,dict d\n where sr.TXT = d.String(+) \norder by strnum, rn \n) group by strnum\n"
},
{
"answer_id": 53215573,
"author": "Olc",
"author_id": 1770247,
"author_profile": "https://Stackoverflow.com/users/1770247",
"pm_score": 1,
"selected": false,
"text": "with fg_rulez as (\n select 1 id,'<' symbol, 'less than' text from dual\n union all select 2, '>', 'greater than' from dual\n union all select 3, '$', 'dollars' from dual\n union all select 4, '+', 'and' from dual\n), fg_Data AS (\n SELECT 'amount $ must be < 1 + > 2' str FROM dual\n union all\n SELECT 'John is > Peter + has many $' str FROM dual\n union all\n SELECT 'Eliana is < mary + do not has many $' str FROM dual\n), q(str, id) as (\n SELECT str, 0 id \n FROM fg_Data \n UNION ALL\n SELECT replace(q.str,symbol,text), fg_rulez.id\n FROM q \n JOIN fg_rulez \n ON q.id = fg_rulez.id - 1\n)\nSELECT str from q where id = (select max(id) from fg_rulez);\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14299/"
] |
83,863
|
<p>I want to find a way to develop database projects quickly in Visual Studio. Any ideas?</p>
|
[
{
"answer_id": 83888,
"author": "Chris Woodruff",
"author_id": 7001,
"author_profile": "https://Stackoverflow.com/users/7001",
"pm_score": 3,
"selected": true,
"text": "/****** Object: StoredProcedure [dbo].[CustOrdersOrders] Script Date: 08/25/2007 15:22:59 ******/\nIF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CustOrdersOrders]') AND type in (N'P', N'PC'))\nDROP PROCEDURE [dbo].[CustOrdersOrders]\nGO\n/****** Object: StoredProcedure [dbo].[CustOrdersOrders] Script Date: 08/25/2007 15:22:59 ******/\nSET ANSI_NULLS ON\nGO\nSET QUOTED_IDENTIFIER ON\nGO\nIF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CustOrdersOrders]') AND type in (N'P', N'PC'))\nBEGIN\nEXEC dbo.sp_executesql @statement = N'\nCREATE PROCEDURE CustOrdersOrders @CustomerID nchar(5)\nAS\nSELECT OrderID,\n OrderDate,\n RequiredDate,\n ShippedDate\nFROM Orders\nWHERE CustomerID = @CustomerID\nORDER BY OrderID\n'\nEND\nGO\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7001/"
] |
83,887
|
<p>Below is an example class hierarchy and code. What I'm looking for is a way to determine if 'ChildClass1' or 'ChildClass2' had the static method whoAmI() called on it without re-implementing it in each child class.</p>
<pre><code><?php
abstract class ParentClass {
public static function whoAmI () {
// NOT correct, always gives 'ParentClass'
$class = __CLASS__;
// NOT correct, always gives 'ParentClass'.
// Also very round-about and likely slow.
$trace = debug_backtrace();
$class = $trace[0]['class'];
return $class;
}
}
class ChildClass1 extends ParentClass {
}
class ChildClass2 extends ParentClass {
}
// Shows 'ParentClass'
// Want to show 'ChildClass1'
print ChildClass1::whoAmI();
print "\n";
// Shows 'ParentClass'
// Want to show 'ChildClass2'
print ChildClass2::whoAmI();
print "\n";
</code></pre>
|
[
{
"answer_id": 109888,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 2,
"selected": false,
"text": "someObject.whoAmI()"
},
{
"answer_id": 1384848,
"author": "Adam Franco",
"author_id": 15872,
"author_profile": "https://Stackoverflow.com/users/15872",
"pm_score": 3,
"selected": true,
"text": "static"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15872/"
] |
83,899
|
<p>We need to capture live video and display <em>easily</em> on Linux. We need a cheap card or USB device with a simple API. Anyone want to share some experience? </p>
|
[
{
"answer_id": 109408,
"author": "Shannon Nelson",
"author_id": 14450,
"author_profile": "https://Stackoverflow.com/users/14450",
"pm_score": 2,
"selected": false,
"text": "dvgrab --size 500 --autosplit <filename>\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/842/"
] |
83,914
|
<p>I've got a new varchar(10) field in a database with 1000+ records. I'd like to update the table so I can have random data in the field. I'm looking for a SQL solution.</p>
<p>I know I can use a cursor, but that seems inelegant.</p>
<p>MS-SQL 2000,BTW</p>
|
[
{
"answer_id": 83963,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 4,
"selected": true,
"text": "update MyTable Set RandomFld = CONVERT(varchar(10), NEWID())\n"
},
{
"answer_id": 83965,
"author": "Stephen Wrighton",
"author_id": 7516,
"author_profile": "https://Stackoverflow.com/users/7516",
"pm_score": 0,
"selected": false,
"text": "UPDATE TBL SET Field = LEFT( CONVERT(varchar(255), @myid),10)\n"
},
{
"answer_id": 83978,
"author": "theo",
"author_id": 7870,
"author_profile": "https://Stackoverflow.com/users/7870",
"pm_score": 0,
"selected": false,
"text": "CAST(RAND() as varchar(10))\n"
},
{
"answer_id": 84029,
"author": "tzot",
"author_id": 6899,
"author_profile": "https://Stackoverflow.com/users/6899",
"pm_score": 1,
"selected": false,
"text": "UPDATE yourtable\nSET yourfield= CHAR(32+ROUND(RAND()*95,0));\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4230/"
] |
83,918
|
<p>We have several jobs that run concurrently that have to use the same config info for log4j. They are all dumping the logs into one file using the same appender. Is there a way to have each job dynamically name its log file so they stay seperate?</p>
<p>Thanks<BR>
Tom</p>
|
[
{
"answer_id": 84021,
"author": "Alexandre Victoor",
"author_id": 11897,
"author_profile": "https://Stackoverflow.com/users/11897",
"pm_score": 0,
"selected": false,
"text": " <category name=\"com.tom.firstbatch\">\n <appender-ref ref=\"FIRST_APPENDER\"/>\n </category>\n <category name=\"com.tom.secondtbatch\">\n <appender-ref ref=\"SECOND_APPENDER\"/>\n </category>\n"
},
{
"answer_id": 84039,
"author": "Asgeir S. Nilsen",
"author_id": 16023,
"author_profile": "https://Stackoverflow.com/users/16023",
"pm_score": 2,
"selected": false,
"text": "FileAppender appender = new FileAppender();\nappender.setFileName(...);\nappender.setLayout(...);\nLogger logger = Logger.getLogger(\"com.company.job.\"+jobName);\nlogger.addAppender(appender);\n"
},
{
"answer_id": 84044,
"author": "shadit",
"author_id": 9925,
"author_profile": "https://Stackoverflow.com/users/9925",
"pm_score": 5,
"selected": true,
"text": "java -Dmy_var=somevalue my.job.Classname\n"
},
{
"answer_id": 84072,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 1,
"selected": false,
"text": "FileAppender"
},
{
"answer_id": 84988,
"author": "18Rabbit",
"author_id": 12662,
"author_profile": "https://Stackoverflow.com/users/12662",
"pm_score": 2,
"selected": false,
"text": "public class JobLogger {\nprivate static Hashtable<String, Logger> m_loggers = new Hashtable<String, Logger>();\nprivate static String m_filename = \"...\"; // Root log directory\n\npublic static synchronized void logMessage(String jobName, String message)\n{\n Logger l = getJobLogger(jobName);\n l.info(message);\n}\n\npublic static synchronized void logException(String jobName, Exception e)\n{\n Logger l = getJobLogger(partner);\n l.info(e.getMessage(), e);\n}\n\nprivate static synchronized Logger getJobLogger(String jobName)\n{\n Logger logger = m_loggers.get(jobName);\n if (logger == null) {\n Layout layout = new PatternLayout(\"...\");\n logger = Logger.getLogger(jobName);\n m_loggers.put(jobName, logger);\n logger.setLevel(Level.INFO);\n try {\n File file = new File(m_filename);\n file.mkdirs();\n file = new File(m_filename + jobName + \".log\");\n FileAppender appender = new FileAppender(layout, file.getAbsolutePath(), false);\n logger.removeAllAppenders();\n logger.addAppender(appender);\n }\n catch (Exception e)\n { ... }\n }\n return logger;\n}\n}\n"
},
{
"answer_id": 13640828,
"author": "runaros",
"author_id": 4464,
"author_profile": "https://Stackoverflow.com/users/4464",
"pm_score": 1,
"selected": false,
"text": "sun.java.command"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5659/"
] |
83,945
|
<p>Is there any way to force a listview control to treat all clicks as though they were done through the Control key?</p>
<p>I need to replicate the functionality of using the control key (selecting an item sets and unsets its selection status) in order to allow the user to easily select multiple items at the same time.</p>
<p>Thank you in advance.</p>
|
[
{
"answer_id": 2678156,
"author": "Matthew M.",
"author_id": 27472,
"author_profile": "https://Stackoverflow.com/users/27472",
"pm_score": 2,
"selected": false,
"text": "public class MultiSelectNoCTRLKeyListView : ListView {\n public MultiSelectNoCTRLKeyListView() {\n\n }\n\n public const int WM_LBUTTONDOWN = 0x0201;\n protected override void WndProc(ref Message m) {\n switch (m.Msg) {\n case WM_LBUTTONDOWN:\n if (!this.MultiSelect)\n break;\n\n int x = (m.LParam.ToInt32() & 0xffff);\n int y = (m.LParam.ToInt32() >> 16) & 0xffff;\n\n var hitTest = this.HitTest(x, y);\n if (hitTest != null && hitTest.Item != null)\n hitTest.Item.Selected = !hitTest.Item.Selected;\n\n return;\n }\n\n base.WndProc(ref m);\n }\n}\n"
},
{
"answer_id": 16350507,
"author": "rdongart",
"author_id": 1163954,
"author_profile": "https://Stackoverflow.com/users/1163954",
"pm_score": 2,
"selected": false,
"text": "MultiSelectionLimit"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83945",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16091/"
] |
83,953
|
<pre><code>foreach ($_GET as $field => $label)
{
$datarray[]=$_GET[$field];
echo "$_GET[$field]";
echo "<br>";
}
print_r($datarray);
</code></pre>
<hr>
<p>This is the output I am getting. I see the data is there in datarray but when
I <code>echo $_GET[$field]</code> </p>
<p>I only get "Array"</p>
<p>But <code>print_r($datarray)</code> prints all the data. Any idea how I pull those values?</p>
<h2>OUTPUT</h2>
<pre><code>Array (
[0] => Array (
[0] => Grade1
[1] => ln
[2] => North America
[3] => yuiyyu
[4] => iuy
[5] => uiyui
[6] => yui
[7] => uiy
[8] => 0:0:5
)
)
</code></pre>
|
[
{
"answer_id": 84040,
"author": "Fernando Barrocal",
"author_id": 2274,
"author_profile": "https://Stackoverflow.com/users/2274",
"pm_score": 0,
"selected": false,
"text": "<pre>"
},
{
"answer_id": 84208,
"author": "jackbravo",
"author_id": 9055,
"author_profile": "https://Stackoverflow.com/users/9055",
"pm_score": 1,
"selected": false,
"text": "var_export($_GET)"
},
{
"answer_id": 84703,
"author": "SeanDowney",
"author_id": 5261,
"author_profile": "https://Stackoverflow.com/users/5261",
"pm_score": 0,
"selected": false,
"text": "foreach ($_GET as $field => $label)\n{\n $datarray[]=$_GET[$field];\n\n echo $_GET[$field]; // you don't really need quotes\n\n echo \"With quotes: {$_GET[$field]}\"; // but if you want to use them\n\n echo $field; // this is really the same thing as echo $_GET[$field], so\n\n if($label == $_GET[$field]) {\n echo \"Should always be true<br>\";\n }\n echo \"<br>\";\n}\nprint_r($datarray);\n"
},
{
"answer_id": 85833,
"author": "Aeon",
"author_id": 13289,
"author_profile": "https://Stackoverflow.com/users/13289",
"pm_score": 0,
"selected": false,
"text": " echo \"$_GET[$field]\";\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83953",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
83,962
|
<p>Test the following code:</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
main()
{
const char *yytext="0";
const float f=(float)atof(yytext);
size_t t = *((size_t*)&f);
printf("t should be 0 but is %d\n", t);
}
</code></pre>
<p>Compile it with:</p>
<pre><code>gcc -O3 test.c
</code></pre>
<p>The GOOD output should be:</p>
<pre><code>"t should be 0 but is 0"
</code></pre>
<p>But with my gcc 4.1.3, I have:</p>
<pre><code>"t should be 0 but is -1209357172"
</code></pre>
|
[
{
"answer_id": 83997,
"author": "Tobi",
"author_id": 5422,
"author_profile": "https://Stackoverflow.com/users/5422",
"pm_score": 5,
"selected": true,
"text": "size_t t = *((size_t*)&f);\n"
},
{
"answer_id": 84020,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": -1,
"selected": false,
"text": " gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts\n"
},
{
"answer_id": 84078,
"author": "nutario",
"author_id": 5334,
"author_profile": "https://Stackoverflow.com/users/5334",
"pm_score": -1,
"selected": false,
"text": "t should be 0 but is 0\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6605/"
] |
83,967
|
<p>Sometimes my Oracle database on Windows gets hosed. How do I do a manual uninstall of Oracle?</p>
|
[
{
"answer_id": 86536,
"author": "Sten Vesterli",
"author_id": 9363,
"author_profile": "https://Stackoverflow.com/users/9363",
"pm_score": 7,
"selected": true,
"text": "\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services"
},
{
"answer_id": 60243364,
"author": "anyGenericProgrammer",
"author_id": 12875015,
"author_profile": "https://Stackoverflow.com/users/12875015",
"pm_score": 0,
"selected": false,
"text": "Settings > Apps and Features"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83967",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6013/"
] |
83,983
|
<p>example:</p>
<pre><code>a_list = [1, 2, 3]
a_list.len() # doesn't work
len(a_list) # works
</code></pre>
<p>Python being (very) object oriented, I don't understand why the 'len' function isn't inherited by the object.
Plus I keep trying the wrong solution since it appears as the logical one to me</p>
|
[
{
"answer_id": 84016,
"author": "Bill Barksdale",
"author_id": 16113,
"author_profile": "https://Stackoverflow.com/users/16113",
"pm_score": 2,
"selected": false,
"text": "__len__"
},
{
"answer_id": 84019,
"author": "Nate",
"author_id": 12779,
"author_profile": "https://Stackoverflow.com/users/12779",
"pm_score": 4,
"selected": false,
"text": ">>> [1,2,3].__len__()\n\n3\n"
},
{
"answer_id": 84038,
"author": "Dave Costa",
"author_id": 6568,
"author_profile": "https://Stackoverflow.com/users/6568",
"pm_score": 2,
"selected": false,
"text": ">>> a_list = [1, 2, 3]\n>>> a_list.__len__()\n3\n"
},
{
"answer_id": 84155,
"author": "Eli Courtwright",
"author_id": 1694,
"author_profile": "https://Stackoverflow.com/users/1694",
"pm_score": 4,
"selected": false,
"text": "x + y"
},
{
"answer_id": 84205,
"author": "dF.",
"author_id": 3002,
"author_profile": "https://Stackoverflow.com/users/3002",
"pm_score": 3,
"selected": false,
"text": "__foo__"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16070/"
] |
83,990
|
<p>It's common to want browsers to cache resources - JavaScript, CSS, images, etc. until there is a new version available, and then ensure that the browser fetches and caches the new version instead.</p>
<p>One solution is to embed a version number in the resource's filename, but will placing the resources to be managed in this way in a directory with a revision number in it do the same thing? Is the whole URL to the file used as a key in the browser's cache, or is it just the filename itself and some meta-data?</p>
<p>If my code changes from fetching <code>/r20/example.js</code> to <code>/r21/example.js</code>, can I be sure that revision 20 of <code>example.js</code> was cached, but now revision 21 has been fetched instead and it is now cached?</p>
|
[
{
"answer_id": 41716206,
"author": "Leonid Vasilev",
"author_id": 2594597,
"author_profile": "https://Stackoverflow.com/users/2594597",
"pm_score": 3,
"selected": false,
"text": "URI = scheme \":\" hier-part [ \"?\" query ] [ \"#\" fragment ]\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/83990",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12559/"
] |
84,007
|
<p>Do you guys know how I can use the Curl command line to POST SOAP to test a web service?</p>
<p>I have a file (soap.xml) which has all the soap message attached to it I just don't seem to be able to properly post it.</p>
<p>Thanks!</p>
|
[
{
"answer_id": 84046,
"author": "lbz",
"author_id": 11530,
"author_profile": "https://Stackoverflow.com/users/11530",
"pm_score": 6,
"selected": true,
"text": "curl -d \"String to post\" \"http://www.example.com/target\"\n"
},
{
"answer_id": 4574519,
"author": "Kris C",
"author_id": 42234,
"author_profile": "https://Stackoverflow.com/users/42234",
"pm_score": 5,
"selected": false,
"text": "curl --header \"content-type: application/soap+xml\" --data @filetopost.xml http://domain/path\n"
},
{
"answer_id": 9366090,
"author": "Zibri",
"author_id": 236062,
"author_profile": "https://Stackoverflow.com/users/236062",
"pm_score": 5,
"selected": false,
"text": "curl \n-H 'SOAPACTION: \"urn:samsung.com:service:MainTVAgent2:1#CheckPIN\"' \n-X POST \n-H 'Content-type: text/xml' \n-d @/tmp/pinrequest.xml \n192.168.1.5:52235/MainTVServer2/control/MainTVAgent2\n"
},
{
"answer_id": 13475416,
"author": "Ahmet Karakaya",
"author_id": 1297641,
"author_profile": "https://Stackoverflow.com/users/1297641",
"pm_score": 3,
"selected": false,
"text": "curl -H \"Content-Type: text/xml; charset=utf-8\" \\\n-H \"SOAPAction:\" \\\n-d @soap.txt -X POST http://someurl\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13469/"
] |
84,034
|
<p>I have <strong>1 red polygon</strong> say and <strong>50 randomly placed blue polygons</strong> - they are situated in geographical <strong>2D space</strong>. What is the quickest/speediest algorithim to find the the shortest distance between a red polygon and its nearest blue polygon?</p>
<p>Bear in mind that it is not a simple case of taking the points that make up the vertices of the polygon as values to test for distance as they may not necessarily be the closest points.</p>
<p>So in the end - the answer should give back the closest blue polygon to the singular red one.</p>
<p>This is harder than it sounds!</p>
|
[
{
"answer_id": 1120049,
"author": "mpen",
"author_id": 65387,
"author_profile": "https://Stackoverflow.com/users/65387",
"pm_score": 2,
"selected": false,
"text": "log(log m * n)"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5175/"
] |
84,064
|
<p>I'm trying to use <code>SQLBindParameter</code> to prepare my driver for input via <code>SQLPutData</code>. The field in the database is a <code>TEXT</code> field. My function is crafted based on MS's example here:
<a href="http://msdn.microsoft.com/en-us/library/ms713824(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms713824(VS.85).aspx</a>.</p>
<p>I've setup the environment, made the connection, and prepared my statement successfully but when I call <code>SQLBindParam</code> (using code below) it consistently fails reporting: <code>[Microsoft][SQL Native Client]Invalid precision value</code></p>
<pre><code>int col_num = 1;
SQLINTEGER length = very_long_string.length( );
retcode = SQLBindParameter( StatementHandle,
col_num,
SQL_PARAM_INPUT,
SQL_C_BINARY,
SQL_LONGVARBINARY,
NULL,
NULL,
(SQLPOINTER) col_num,
NULL,
&length );
</code></pre>
<p>The above relies on the driver in use returning "N" for the <code>SQL_NEED_LONG_DATA_LEN</code> information type in <code>SQLGetInfo</code>. My driver returns "Y". How do I bind so that I can use <code>SQLPutData</code>?</p>
|
[
{
"answer_id": 89423,
"author": "antik",
"author_id": 1625,
"author_profile": "https://Stackoverflow.com/users/1625",
"pm_score": 2,
"selected": false,
"text": " SQLINTEGER length;\n RETCODE retcode = SQLBindParameter( StatementHandle,\n col_num, // position of the parameter in the query\n SQL_PARAM_INPUT,\n SQL_C_CHAR,\n SQL_VARCHAR,\n data_length, // size of our data\n NULL, // decimal precision: not used our data types\n &my_string, // SQLParamData will return this value later to indicate what data it's looking for so let's pass in the address of our std::string\n data_length,\n &length ); // it needs a length buffer\n\n // length in the following operation must still exist when SQLExecDirect or SQLExecute is called\n // in my code, I used a pointer on the heap for this.\n length = SQL_LEN_DATA_AT_EXEC( data_length ); \n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1625/"
] |
84,096
|
<p>ssh will look for its keys by default in the ~/.ssh folder. I want to force it to always look in another location.</p>
<p>The workaround I'm using is to add the keys from the non-standard location to the agent:</p>
<pre><code>ssh-agent
ssh-add /path/to/where/keys/really/are/id_rsa
</code></pre>
<p>(on Linux and MingW32 shell on Windows)</p>
|
[
{
"answer_id": 84212,
"author": "roo",
"author_id": 716,
"author_profile": "https://Stackoverflow.com/users/716",
"pm_score": 5,
"selected": false,
"text": "man ssh"
},
{
"answer_id": 84419,
"author": "Drew Frezell",
"author_id": 10954,
"author_profile": "https://Stackoverflow.com/users/10954",
"pm_score": 8,
"selected": true,
"text": "IdentityFile ~/.foo/identity\n"
},
{
"answer_id": 70339236,
"author": "Fabien Haddadi",
"author_id": 4287943,
"author_profile": "https://Stackoverflow.com/users/4287943",
"pm_score": 0,
"selected": false,
"text": "config"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6329/"
] |
84,102
|
<p>I'd be interested in some before-and-after c# examples, some non-idiomatic vs idiomatic examples. Non-c# examples would be fine as well if they get the idea across. Thanks.</p>
|
[
{
"answer_id": 84270,
"author": "Corey Goldberg",
"author_id": 16148,
"author_profile": "https://Stackoverflow.com/users/16148",
"pm_score": 8,
"selected": true,
"text": "mylist = [1, 2, 3, 4]\nnewlist = []\nfor i in mylist:\n newlist.append(i * 2)\n"
},
{
"answer_id": 84406,
"author": "JacquesB",
"author_id": 7488,
"author_profile": "https://Stackoverflow.com/users/7488",
"pm_score": 5,
"selected": false,
"text": "string content;\nStreamReader sr = null;\ntry {\n File.OpenText(path);\n content = sr.ReadToEnd();\n}\nfinally {\n if (sr != null) {\n sr.Close();\n }\n}\n"
},
{
"answer_id": 84768,
"author": "RickL",
"author_id": 7261,
"author_profile": "https://Stackoverflow.com/users/7261",
"pm_score": 3,
"selected": false,
"text": "for (int i = 0; i < itemCount; i++)\n\nfor (int i = 1; i <= itemCount; i++)\n\nfor (int i = 0; i < itemCount; ++i)\n"
},
{
"answer_id": 2553355,
"author": "jmoz",
"author_id": 68534,
"author_profile": "https://Stackoverflow.com/users/68534",
"pm_score": 3,
"selected": false,
"text": "foreach ($array as $value) {\n $trimmed[] = trim($value);\n}\nreturn $trimmed;\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13578/"
] |
84,125
|
<p>I've been writing PHP for about six years now and have got to a point where I feel I should be doing more to write better code. I know that Object Oriented code is the way to go but I can't get my head around the concept.</p>
<p>Can anyone explain in terms that any idiot can understand, OO and how it works in PHP or point me to an idiots guide tutorial?</p>
|
[
{
"answer_id": 84356,
"author": "Aquarion",
"author_id": 12696,
"author_profile": "https://Stackoverflow.com/users/12696",
"pm_score": 5,
"selected": false,
"text": "class Breakfast {\n\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6916/"
] |
84,147
|
<p>Does somebody know how to recover a never-starting eclipse when the error "org.eclipse.swt.SWTError: Item not added" is raising againg and again?</p>
<p>I'm using WebSphere Studio Site Developer (Windows) 5.1.0</p>
<p>The only stack trace in the .metadata/log file is:</p>
<p><code>SESSION ----------------------------------------------------------------------<br>
!ENTRY org.eclipse.core.launcher 4 0 sep 17, 2008 16:39:00.564<br>
!MESSAGE Exception launching the Eclipse Platform:<br>
!STACK<br>
java.lang.reflect.InvocationTargetException: java.lang.reflect.InvocationTargetException: org.eclipse.swt.SWTError: Item not added<br>
at java.lang.Throwable.<init>(Throwable.java)<br>
at java.lang.Throwable.<init>(Throwable.java)<br>
at org.eclipse.swt.SWTError.<init>(SWTError.java:82)<br>
at org.eclipse.swt.SWTError.<init>(SWTError.java:71)<br>
at org.eclipse.swt.SWT.error(SWT.java:2358)<br>
at org.eclipse.swt.SWT.error(SWT.java:2262)<br>
at org.eclipse.swt.widgets.Widget.error(Widget.java:385)<br>
at org.eclipse.swt.widgets.Menu.createItem(Menu.java:464)<br>
at org.eclipse.swt.widgets.MenuItem.<init>(MenuItem.java:77)<br>
at org.eclipse.ui.internal.AcceleratorMenu.setAccelerators(AcceleratorMenu.java:177)<br>
at org.eclipse.ui.internal.WWinKeyBindingService.updateAccelerators(WWinKeyBindingService.java:316)<br>
at org.eclipse.ui.internal.WWinKeyBindingService.clear(WWinKeyBindingService.java:175)<br>
at org.eclipse.ui.internal.WWinKeyBindingService.update(WWinKeyBindingService.java:267)<br>
at org.eclipse.ui.internal.WWinKeyBindingService$1.partActivated(WWinKeyBindingService.java:107)<br>
at org.eclipse.ui.internal.PartListenerList$1.run(PartListenerList.java:49)<br>
at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1006)<br>
at org.eclipse.core.runtime.Platform.run(Platform.java:413)<br>
at org.eclipse.ui.internal.PartListenerList.firePartActivated(PartListenerList.java:47)<br>
at org.eclipse.ui.internal.WorkbenchPage.firePartActivated(WorkbenchPage.java:1180)<br>
at org.eclipse.ui.internal.WorkbenchPage.onActivate(WorkbenchPage.java:1833)<br>
at org.eclipse.ui.internal.WorkbenchWindow$7.run(WorkbenchWindow.java:1496)<br>
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)<br>
at org.eclipse.ui.internal.WorkbenchWindow.setActivePage(WorkbenchWindow.java:1483)<br>
at org.eclipse.ui.internal.WorkbenchWindow.restoreState(WorkbenchWindow.java:1363)<br>
at org.eclipse.ui.internal.Workbench.restoreState(Workbench.java:1263)<br>
at org.eclipse.ui.internal.Workbench.access$10(Workbench.java:1223)<br>
at org.eclipse.ui.internal.Workbench$12.run(Workbench.java:1141)<br>
at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1006)<br>
at org.eclipse.core.runtime.Platform.run(Platform.java:413)<br>
at org.eclipse.ui.internal.Workbench.openPreviousWorkbenchState(Workbench.java:1093)<br>
at org.eclipse.ui.internal.Workbench.init(Workbench.java:870)<br>
at org.eclipse.ui.internal.Workbench.run(Workbench.java:1373)<br>
at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:858)<br>
at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461)<br>
at java.lang.reflect.AccessibleObject.invokeL(AccessibleObject.java:207)<br>
at java.lang.reflect.Method.invoke(Method.java:271)<br>
at org.eclipse.core.launcher.Main.basicRun(Main.java:291)<br>
at org.eclipse.core.launcher.Main.run(Main.java:747)<br>
at org.eclipse.core.launcher.Main.main(Main.java:583)</code> </p>
|
[
{
"answer_id": 4454563,
"author": "Mohammed Ali",
"author_id": 543879,
"author_profile": "https://Stackoverflow.com/users/543879",
"pm_score": 0,
"selected": false,
"text": "eclipse.ini"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16135/"
] |
84,149
|
<p>What is a good way to render data produced by a Java process in the browser? </p>
<p>I've made extensive use of JSP and the various associated frameworks (<a href="http://java.sun.com/products/jsp/jstl/" rel="nofollow noreferrer">JSTL</a>, <a href="http://struts.apache.org/" rel="nofollow noreferrer">Struts</a>, <a href="http://tapestry.apache.org/" rel="nofollow noreferrer">Tapestry</a>, etc), as well as more comprehensive frameworks not related to JSP (<a href="http://code.google.com/webtoolkit/" rel="nofollow noreferrer">GWT</a>, <a href="http://www.openlaszlo.org/" rel="nofollow noreferrer">OpenLaszlo</a>). None of the solutions have ever been entirely satisfactory - in most cases the framework is too constrained or too complex for my needs, while others would require extensive refactoring of existing code. Additionally, most frameworks seem to have performance problems.</p>
<p>Currently I'm leaning towards the solution of exposing my java data via a simple servlet that returns JSON, and then rendering the data using PHP or Ruby. This has the added benefit of instantly exposing my service as a web service as well, but I'm wondering if I'm reinventing the wheel here.</p>
|
[
{
"answer_id": 87111,
"author": "Andreas Holstenson",
"author_id": 16351,
"author_profile": "https://Stackoverflow.com/users/16351",
"pm_score": 3,
"selected": true,
"text": "@Path(\"/\")\nclass TestClass {\n @GET\n @Path(\"text\")\n @Produces(\"text/plain\")\n String getText() {\n return \"String value\";\n }\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12457/"
] |
84,163
|
<p>Here's a challenge that I was tasked with recently. I still haven't figured out the best way to do it, maybe someone else has an idea. </p>
<p>Using PHP and/or HTML, create a page that cycles through any number of other pages at a given interval.</p>
<p>For instance, we would load this page and it would take us to google for 20 seconds, then on to yahoo for 10 seconds, then on to stackoverflow for 180 seconds and so on an so forth. </p>
|
[
{
"answer_id": 84190,
"author": "Jason Cohen",
"author_id": 4926,
"author_profile": "https://Stackoverflow.com/users/4926",
"pm_score": 1,
"selected": false,
"text": "delay()"
},
{
"answer_id": 84226,
"author": "hasseg",
"author_id": 4111,
"author_profile": "https://Stackoverflow.com/users/4111",
"pm_score": 0,
"selected": false,
"text": "100% x 100%"
},
{
"answer_id": 84235,
"author": "Max Cantor",
"author_id": 16034,
"author_profile": "https://Stackoverflow.com/users/16034",
"pm_score": 0,
"selected": false,
"text": "<meta HTTP-EQUIV=\"REFRESH\" content=\"15; url=http://www.thepagecycler.com/nextpage.html\">\n"
},
{
"answer_id": 84259,
"author": "Jason Jackson",
"author_id": 13103,
"author_profile": "https://Stackoverflow.com/users/13103",
"pm_score": 0,
"selected": false,
"text": "function RefreshFrame()\n{\n parent.VisibleFrame.location.href = urlArray[i];\n i++;\n\n if(i < urlArray.length) SetTimeout(\"RefreshFrame()\", 20000);\n}\n\nvar i = 0;\nvar urlArray = ['http://google.com','http://yahoo.com', 'http://www.search.com'];\nRefreshFrame();\n"
},
{
"answer_id": 85196,
"author": "Jonny Buchanan",
"author_id": 6760,
"author_profile": "https://Stackoverflow.com/users/6760",
"pm_score": 4,
"selected": false,
"text": "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html lang=\"en\">\n<head>\n<title>Dashboard Example</title>\n<style type=\"text/css\">\nbody, html { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; }\niframe { border: none; }\n</style>\n<script type=\"text/javascript\">\nvar Dash = {\n nextIndex: 0,\n\n dashboards: [\n {url: \"http://www.google.com\", time: 5},\n {url: \"http://www.yahoo.com\", time: 10},\n {url: \"http://www.stackoverflow.com\", time: 15}\n ],\n\n display: function()\n {\n var dashboard = Dash.dashboards[Dash.nextIndex];\n frames[\"displayArea\"].location.href = dashboard.url;\n Dash.nextIndex = (Dash.nextIndex + 1) % Dash.dashboards.length;\n setTimeout(Dash.display, dashboard.time * 1000);\n }\n};\n\nwindow.onload = Dash.display;\n</script>\n</head>\n<body>\n<iframe name=\"displayArea\" width=\"100%\" height=\"100%\"></iframe>\n</body>\n</html>\n"
},
{
"answer_id": 85818,
"author": "GreenO",
"author_id": 13399,
"author_profile": "https://Stackoverflow.com/users/13399",
"pm_score": 1,
"selected": false,
"text": "<?php\n# Path the config file, full or relative.\n$configfile=\"config.conf\"; \n$tempfile=\"tmp.html\";\n# Read the file into an array\n$farray=file($configfile); \n# Count array elements\n$count=count($farray); \nif(!isset($_GET['s'])){\n $s=0;\n}else{ \n $s=$_GET['s'];\nif($s==($count-1)){ # -1 because of the offset in starting our loop at 0 instead of 1\n $s=0;\n}else{\n $s=$_GET['s']+1; # Increment the counter\n}\n}\n# Get the line from the array\n$entry=$farray[$s];\n# Break the line on the comma into 2 entries\n$arr=explode(\",\",$entry); \n# Now each line is in 2 pieces - URL and TimeDelay\n$url=strtolower($arr[0]);\n# Check our url to see if it has an HTTP prepended, if it doesn't, give it one.\n$check=strstr($url,\"http://\"); \nif($check==FALSE){\n $url=\"http://\".$url;\n } \n# Trim unwanted crap from the time\n$time=rtrim($arr[1]); \n# Get a handle to the temp file\n$tmphandle=fopen($tempfile,\"w\");\n# What does our meta refresh look like?\n$meta=\"<meta http-equiv=\\\"refresh\\\" content=\\\"\".$time.\";url=index.php?s=\".$s.\"\\\">\\n\";\n# The iframe to display\n$content=\"<iframe src =\\\"\".$url.\"\\\" height=\\\"100%\\\" width=\\\"100%\\\"></iframe>\";\n# roll up the meta and content to be written\n$str=$meta.$content;\n# Write it\nfwrite($tmphandle,$str);\n# Close the handle\nfclose($tmphandle);\n# Load the page\ndie(header(\"Location:tmp.html\")); \n?>\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13399/"
] |
84,164
|
<p>I'm working on a game (C#) that uses a <a href="http://robocode.sourceforge.net/" rel="nofollow noreferrer">Robocode-like</a> programming model: participants inherit a base Class and add strategic behaviors. The game then loads instances of participants' Classes and the competition begins. Unfortunately, participants can "cheat" by sharing static variables between instances of their competitor Class.</p>
<p>How do I prevent static variable sharing between Class instances in a .NET language? I know this is accomplished in Java by using a separate ClassLoader per instance. What's the .NET equivalent? </p>
<p>Further, my testing shows that separate AppDomains only work when loading a Class that extends MarshalByRefObject. I guess this makes sense - if you simply load a Serializable Class, the Class is copied into the current AppDomain so a second object from a different AppDomain will share its static vars. MarshalByRefObject guarantees that only a proxy is loaded into the current AppDomain and the statics stay behind in the loading AppDomain. See also: <a href="http://blogs.msdn.com/ericlippert/archive/2004/05/27/143203.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/ericlippert/archive/2004/05/27/143203.aspx</a></p>
|
[
{
"answer_id": 85148,
"author": "ddc0660",
"author_id": 16027,
"author_profile": "https://Stackoverflow.com/users/16027",
"pm_score": 2,
"selected": false,
"text": "if(typeof(CompetitorClass).GetFields(BindingFlags.Static))\n{\n // take necessary steps against cheater!\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84164",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7625/"
] |
84,165
|
<p>I am attempting to provide a general solution for the migration of data from one schema version to another. A problem arises when the column data type from the source schema does not match that of the destination. I would like to create a query that will perform a preliminary compare on the columns data types to return which columns need to be fixed before migration is possible.</p>
<p>My current approach is to return the table and column names from <code>information_schema.columns</code> where <code>DATA_TYPE</code>'s between catalogs do not match. However, querying <code>information_schema</code> directly will only return results from the catalog of the connection.</p>
<p>Has anyone written a query like this?</p>
|
[
{
"answer_id": 84469,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "syscolumns"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7287/"
] |
84,174
|
<p>I have been trying out <a href="http://www.codeplex.com/servicefactory" rel="nofollow noreferrer">Service Factory</a> and have run into some problems in regards to long filenames - surpassing the limit in Vista/XP. The problem is that when generating code from the models service factory prefixes everything with the namespace specified. Making the folder structure huge. For example starting in</p>
<p>c:\work\sftest\MyWebService</p>
<p>I create each of the models with moderate length of names in data contracts and service interface. I set the namespace to be MyCompany.SFTest.MyWebservice</p>
<p>After generating code I end up with </p>
<pre>
c:\work\sftest\MyWebService\MyCompany.SFTest.MyWebService
c:\work\sftest\MyWebService\MyCompany.SFTest.MyWebService
c:\work\sftest\MyWebService\MyCompany.SFTest.MyWebService\Source
c:\work\sftest\MyWebService\MyCompany.SFTest.MyWebService\Source\Business Logic
c:\work\sftest\MyWebService\MyCompany.SFTest.MyWebService\Source\Resource Access
c:\work\sftest\MyWebService\MyCompany.SFTest.MyWebService\Source\Service Interface
c:\work\sftest\MyWebService\MyCompany.SFTest.MyWebService\Source\Service Interface\MyCompany.SFTest.MyWebService.DataContracts
c:\work\sftest\MyWebService\MyCompany.SFTest.MyWebService\Source\Service Interface\MyCompany.SFTest.MyWebService.FaultContracts
c:\work\sftest\MyWebService\MyCompany.SFTest.MyWebService\Source\Service Interface\MyCompany.SFTest.MyWebService.MessageContracts
c:\work\sftest\MyWebService\MyCompany.SFTest.MyWebService\Source\Service Interface\MyCompany.SFTest.MyWebService.ServiceContracts
c:\work\sftest\MyWebService\MyCompany.SFTest.MyWebService\Source\Service Interface\MyCompany.SFTest.MyWebService.ServiceImplementation
c:\work\sftest\MyWebService\MyCompany.SFTest.MyWebService\Source\Tests
</pre>
<p>Under each of the folders is a project file with the same prefix </p>
<pre>
c:\work\sftest\MyWebService\MyCompany.SFTest.MyWebService\Source\Service Interface\MyCompany.SFTest.MyWebService.ServiceImplementation\MyCompany.SFTest.MyWebService.ServiceImplementation.proj
</pre>
<p>This blows up the recipe as windows can't accept filenames exceeding a specific length.</p>
<p>Is it necessary to explicitly include the namespace in each of the foldernames?
Obviously at some point I might want to branch a service to another location but for the same reason as above might be unable to.
Is there a workaround for this?</p>
|
[
{
"answer_id": 84469,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "syscolumns"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15771/"
] |
84,178
|
<p>I'm running in a windows environment with Trac / SVN and I want commits to the repository to integrate to Trac and close the bugs that were noted in the SVN Comment.</p>
<p>I know there's some post commit hooks to do that, but there's not much information about how to do it on windows.</p>
<p>Anyone done it successfully? And what were the steps you followed to achive it?</p>
<p>Here's the hook I need to put in place in SVN, but I'm not exactly sure how to do this in the Windows environment.</p>
<p><a href="http://trac.edgewall.org/browser/trunk/contrib/trac-post-commit-hook?rev=920" rel="nofollow noreferrer">Trac Post Commit Hook</a></p>
|
[
{
"answer_id": 84301,
"author": "Benjamin W. Smith",
"author_id": 1068060,
"author_profile": "https://Stackoverflow.com/users/1068060",
"pm_score": 0,
"selected": false,
"text": "C:\\Subversion\\repositories\\repo1\\hooks\\post-commit\n"
},
{
"answer_id": 85089,
"author": "Craig Boland",
"author_id": 16285,
"author_profile": "https://Stackoverflow.com/users/16285",
"pm_score": 2,
"selected": false,
"text": "@ECHO OFF\n\n:: POST-COMMIT HOOK\n::\n:: The post-commit hook is invoked after a commit. Subversion runs\n:: this hook by invoking a program (script, executable, binary, etc.)\n:: named 'post-commit' (for which this file is a template) with the \n:: following ordered arguments:\n::\n:: [1] REPOS-PATH (the path to this repository)\n:: [2] REV (the number of the revision just committed)\n::\n:: The default working directory for the invocation is undefined, so\n:: the program should set one explicitly if it cares.\n::\n:: Because the commit has already completed and cannot be undone,\n:: the exit code of the hook program is ignored. The hook program\n:: can use the 'svnlook' utility to help it examine the\n:: newly-committed tree.\n::\n:: On a Unix system, the normal procedure is to have 'post-commit'\n:: invoke other programs to do the real work, though it may do the\n:: work itself too.\n::\n:: Note that 'post-commit' must be executable by the user(s) who will\n:: invoke it (typically the user httpd runs as), and that user must\n:: have filesystem-level permission to access the repository.\n::\n:: On a Windows system, you should name the hook program\n:: 'post-commit.bat' or 'post-commit.exe',\n:: but the basic idea is the same.\n:: \n:: The hook program typically does not inherit the environment of\n:: its parent process. For example, a common problem is for the\n:: PATH environment variable to not be set to its usual value, so\n:: that subprograms fail to launch unless invoked via absolute path.\n:: If you're having unexpected problems with a hook program, the\n:: culprit may be unusual (or missing) environment variables.\n:: \n:: Here is an example hook script, for a Unix /bin/sh interpreter.\n:: For more examples and pre-written hooks, see those in\n:: the Subversion repository at\n:: http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and\n:: http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/\n\nsetlocal\n\n:: Debugging setup\n:: 1. Make a copy of this file.\n:: 2. Enable the command below to call the copied file.\n:: 3. Remove all other commands\n::call %~dp0post-commit-run.cmd %* > %1/hooks/post-commit.log 2>&1\n\n:: Call Trac post-commit hook\ncall %~dp0trac-post-commit.cmd %* || exit 1\n\nendlocal\n"
},
{
"answer_id": 110241,
"author": "Dean Poulin",
"author_id": 5462,
"author_profile": "https://Stackoverflow.com/users/5462",
"pm_score": 3,
"selected": true,
"text": "#!/usr/bin/env python\n\n# trac-post-commit-hook\n# ----------------------------------------------------------------------------\n# Copyright (c) 2004 Stephen Hansen \n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to\n# deal in the Software without restriction, including without limitation the\n# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n# sell copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in\n# all copies or substantial portions of the Software. \n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n# IN THE SOFTWARE.\n# ----------------------------------------------------------------------------\n\n# This Subversion post-commit hook script is meant to interface to the\n# Trac (http://www.edgewall.com/products/trac/) issue tracking/wiki/etc \n# system.\n# \n# It should be called from the 'post-commit' script in Subversion, such as\n# via:\n#\n# REPOS=\"$1\"\n# REV=\"$2\"\n# LOG=`/usr/bin/svnlook log -r $REV $REPOS`\n# AUTHOR=`/usr/bin/svnlook author -r $REV $REPOS`\n# TRAC_ENV='/somewhere/trac/project/'\n# TRAC_URL='http://trac.mysite.com/project/'\n#\n# /usr/bin/python /usr/local/src/trac/contrib/trac-post-commit-hook \\\n# -p \"$TRAC_ENV\" \\\n# -r \"$REV\" \\\n# -u \"$AUTHOR\" \\\n# -m \"$LOG\" \\\n# -s \"$TRAC_URL\"\n#\n# It searches commit messages for text in the form of:\n# command #1\n# command #1, #2\n# command #1 & #2 \n# command #1 and #2\n#\n# You can have more then one command in a message. The following commands\n# are supported. There is more then one spelling for each command, to make\n# this as user-friendly as possible.\n#\n# closes, fixes\n# The specified issue numbers are closed with the contents of this\n# commit message being added to it. \n# references, refs, addresses, re \n# The specified issue numbers are left in their current status, but \n# the contents of this commit message are added to their notes. \n#\n# A fairly complicated example of what you can do is with a commit message\n# of:\n#\n# Changed blah and foo to do this or that. Fixes #10 and #12, and refs #12.\n#\n# This will close #10 and #12, and add a note to #12.\n\nimport re\nimport os\nimport sys\nimport time \n\nfrom trac.env import open_environment\nfrom trac.ticket.notification import TicketNotifyEmail\nfrom trac.ticket import Ticket\nfrom trac.ticket.web_ui import TicketModule\n# TODO: move grouped_changelog_entries to model.py\nfrom trac.util.text import to_unicode\nfrom trac.web.href import Href\n\ntry:\n from optparse import OptionParser\nexcept ImportError:\n try:\n from optik import OptionParser\n except ImportError:\n raise ImportError, 'Requires Python 2.3 or the Optik option parsing library.'\n\nparser = OptionParser()\nparser.add_option('-e', '--require-envelope', dest='env', default='',\n help='Require commands to be enclosed in an envelope. If -e[], '\n 'then commands must be in the form of [closes #4]. Must '\n 'be two characters.')\nparser.add_option('-p', '--project', dest='project',\n help='Path to the Trac project.')\nparser.add_option('-r', '--revision', dest='rev',\n help='Repository revision number.')\nparser.add_option('-u', '--user', dest='user',\n help='The user who is responsible for this action')\nparser.add_option('-m', '--msg', dest='msg',\n help='The log message to search.')\nparser.add_option('-c', '--encoding', dest='encoding',\n help='The encoding used by the log message.')\nparser.add_option('-s', '--siteurl', dest='url',\n help='The base URL to the project\\'s trac website (to which '\n '/ticket/## is appended). If this is not specified, '\n 'the project URL from trac.ini will be used.')\n\n(options, args) = parser.parse_args(sys.argv[1:])\n\nif options.env:\n leftEnv = '\\\\' + options.env[0]\n rghtEnv = '\\\\' + options.env[1]\nelse:\n leftEnv = ''\n rghtEnv = ''\n\ncommandPattern = re.compile(leftEnv + r'(?P<action>[A-Za-z]*).?(?P<ticket>#[0-9]+(?:(?:[, &]*|[ ]?and[ ]?)#[0-9]+)*)' + rghtEnv)\nticketPattern = re.compile(r'#([0-9]*)')\nversionPattern = re.compile(r\"\\(version[ ]+(?P<version>([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+))\\)\")\n\nclass CommitHook:\n _supported_cmds = {'close': '_cmdClose',\n 'closed': '_cmdClose',\n 'closes': '_cmdClose',\n 'fix': '_cmdClose',\n 'fixed': '_cmdClose',\n 'fixes': '_cmdClose',\n 'addresses': '_cmdRefs',\n 're': '_cmdRefs',\n 'references': '_cmdRefs',\n 'refs': '_cmdRefs',\n 'see': '_cmdRefs'}\n\n def __init__(self, project=options.project, author=options.user,\n rev=options.rev, msg=options.msg, url=options.url,\n encoding=options.encoding):\n msg = to_unicode(msg, encoding)\n self.author = author\n self.rev = rev\n self.msg = \"(In [%s]) %s\" % (rev, msg)\n self.now = int(time.time()) \n self.env = open_environment(project)\n if url is None:\n url = self.env.config.get('project', 'url')\n self.env.href = Href(url)\n self.env.abs_href = Href(url)\n\n cmdGroups = commandPattern.findall(msg)\n\n\n tickets = {}\n\n for cmd, tkts in cmdGroups:\n funcname = CommitHook._supported_cmds.get(cmd.lower(), '')\n\n if funcname:\n\n for tkt_id in ticketPattern.findall(tkts):\n func = getattr(self, funcname)\n tickets.setdefault(tkt_id, []).append(func)\n\n for tkt_id, cmds in tickets.iteritems():\n try:\n db = self.env.get_db_cnx()\n\n ticket = Ticket(self.env, int(tkt_id), db)\n for cmd in cmds:\n cmd(ticket)\n\n # determine sequence number... \n cnum = 0\n tm = TicketModule(self.env)\n for change in tm.grouped_changelog_entries(ticket, db):\n if change['permanent']:\n cnum += 1\n\n # get the version number from the checkin... and update the ticket with it.\n version = versionPattern.search(msg)\n if version != None and version.group(\"version\") != None:\n ticket['fixed_in_ver'] = version.group(\"version\")\n\n ticket.save_changes(self.author, self.msg, self.now, db, cnum+1)\n db.commit()\n\n tn = TicketNotifyEmail(self.env)\n tn.notify(ticket, newticket=0, modtime=self.now)\n except Exception, e:\n # import traceback\n # traceback.print_exc(file=sys.stderr)\n print>>sys.stderr, 'Unexpected error while processing ticket ' \\\n 'ID %s: %s' % (tkt_id, e)\n\n\n def _cmdClose(self, ticket):\n ticket['status'] = 'closed'\n ticket['resolution'] = 'fixed'\n\n def _cmdRefs(self, ticket):\n pass\n\n\nif __name__ == \"__main__\":\n if len(sys.argv) < 5:\n print \"For usage: %s --help\" % (sys.argv[0])\n else:\n CommitHook()\n"
},
{
"answer_id": 1111147,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": ":: Modify paths here:\n\n:: -- this one must be set\nSET TRAC_ENV=d:\\trac\\MySpecialProject\n\n:: -- set if Python is not in the system path\n:: SET PYTHON_PATH=**d:\\python**\n\n:: -- set to the folder containing trac/ if installed in a non-standard location \n:: SET TRAC_PATH=**d:\\python\\Lib\\site-packages\\trac**\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5462/"
] |
84,180
|
<p>Conducting a user account cleanup accross Solaris and Redhat linux systems, many of which have a number of Samba shares. </p>
<p>What preference do people have for creating the local unix accounts for non interactive Samba users? In particular, the shell entry:</p>
<ol>
<li>noshell</li>
<li>nologin</li>
<li>blank</li>
</ol>
<p>And why?</p>
<p>JB</p>
|
[
{
"answer_id": 84344,
"author": "Alex B",
"author_id": 6180,
"author_profile": "https://Stackoverflow.com/users/6180",
"pm_score": 2,
"selected": false,
"text": "passwd"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8361/"
] |
84,209
|
<p><strong>Introduction</strong></p>
<p>I've always been searching for a way to make Visual Studio draw a line after a certain amount of characters.</p>
<p>Below is a guide to enable these so called <em>guidelines</em> for various versions of Visual Studio.</p>
<p><strong>Visual Studio 2013 or later</strong></p>
<p>Install Paul Harrington's <a href="http://visualstudiogallery.msdn.microsoft.com/da227a0b-0e31-4a11-8f6b-3a149cf2e459/view/Reviews" rel="noreferrer">Editor Guidelines extension</a>.</p>
<p><strong>Visual Studio 2010 and 2012</strong></p>
<ol>
<li>Install Paul Harrington's Editor Guidelines extension for <a href="http://visualstudiogallery.msdn.microsoft.com/0fbf2878-e678-4577-9fdb-9030389b338c" rel="noreferrer">VS 2010</a> or <a href="http://visualstudiogallery.msdn.microsoft.com/da227a0b-0e31-4a11-8f6b-3a149cf2e459?SRC=Home" rel="noreferrer">VS 2012</a>.</li>
<li>Open the registry at:
<br />VS 2010: <code>HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Text Editor</code>
<br />VS 2012: <code>HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\Text Editor</code>
<br />and add a new string called <code>Guides</code> with the value <code>RGB(100,100,100), 80</code>. The
first part specifies the color, while the other one (<code>80</code>) is the column the line will be displayed.</li>
<li>Or install the <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/7f2a6727-2993-4c1d-8f58-ae24df14ea91" rel="noreferrer">Guidelines UI</a> extension (which is also a part of the <a href="http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef/" rel="noreferrer">Productivity Power Tools</a>), which will add entries to the editor's context menu for adding/removing the entries without needing to edit the registry directly. The current disadvantage of this method is that you can't specify the column directly.</li>
</ol>
<p><strong>Visual Studio 2008 and Other Versions</strong></p>
<p>If you are using Visual Studio 2008 open the registry at <code>HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Text Editor</code> and add a new string called <code>Guides</code> with the value <code>RGB(100,100,100), 80</code>. The first part specifies the color, while the other one (<code>80</code>) is the column the line will be displayed. The vertical line will appear, when you restart Visual Studio.</p>
<p>This trick also works for various other version of Visual Studio, as long as you use the correct path:</p>
<pre><code>2003: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\7.1\Text Editor
2005: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\Text Editor
2008: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Text Editor
2008 Express: HKEY_CURRENT_USER\Software\Microsoft\VCExpress\9.0\Text Editor
</code></pre>
<p><a href="https://stackoverflow.com/a/332577/11387">This also works in SQL Server 2005 and probably other versions.</a></p>
|
[
{
"answer_id": 84325,
"author": "Rory MacLeod",
"author_id": 1016,
"author_profile": "https://Stackoverflow.com/users/1016",
"pm_score": 2,
"selected": false,
"text": "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\9.0\\Text Editor\n"
},
{
"answer_id": 84467,
"author": "Scott Dorman",
"author_id": 1559,
"author_profile": "https://Stackoverflow.com/users/1559",
"pm_score": 8,
"selected": true,
"text": "RGB(230,230,230), 4, 80\n"
},
{
"answer_id": 281333,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "HKEY_CURRENT_USER\\Software\\Microsoft\\VCExpress\\9.0\\Text Editor\n"
},
{
"answer_id": 2111416,
"author": "Noah Richards",
"author_id": 128945,
"author_profile": "https://Stackoverflow.com/users/128945",
"pm_score": 3,
"selected": false,
"text": "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\10.0\\Text Editor\n"
},
{
"answer_id": 3830406,
"author": "rony l",
"author_id": 16418,
"author_profile": "https://Stackoverflow.com/users/16418",
"pm_score": 6,
"selected": false,
"text": "Productivity Power Tools"
},
{
"answer_id": 54382823,
"author": "Pavel P",
"author_id": 468725,
"author_profile": "https://Stackoverflow.com/users/468725",
"pm_score": 2,
"selected": false,
"text": "Display"
},
{
"answer_id": 62960343,
"author": "Daniel Fisher lennybacon",
"author_id": 12679,
"author_profile": "https://Stackoverflow.com/users/12679",
"pm_score": 0,
"selected": false,
"text": "Get-ChildItem \"$($env:LOCALAPPDATA)\\Microsoft\\VisualStudio\\16.0_*\" | \nForeach-Object {\n $dir = $_;\n $regFile = \"$($dir.FullName)\\privateregistry.bin\";\n Write-Host \"Loading $($dir.BaseName) from ``$regFile``\"\n & reg load \"HKLM\\_TMPVS_\" \"$regFile\"\n New-ItemProperty -Name \"Guides\" -Path \"HKLM:\\_TMPVS_\\Software\\Microsoft\\VisualStudio\\$($dir.BaseName)\\Text Editor\" -Value \"RGB(255,0,0), 80\" -force | Out-Null;\n \n Sleep -Seconds 5; # might take some time befor the file can be unloaded\n & reg unload \"HKLM\\_TMPVS_\";\n Write-Host \"Unloaded $($dir.BaseName) from ``$regFile``\"\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11387/"
] |
84,211
|
<p>In a C# windows forms application. I have a splash screen with some multi-threaded processes happening in the background. What I would like to do is when I display the splash screen initially, I would like to have it appear to "fade in". And then, once all the processes finish, I would like it to appear as though the splash screen is "fading out". I'm using C# and .NET 2.0. Thanks.</p>
|
[
{
"answer_id": 84251,
"author": "Patrick Desjardins",
"author_id": 13913,
"author_profile": "https://Stackoverflow.com/users/13913",
"pm_score": 2,
"selected": false,
"text": "While(this.Opacity !=0)\n{\n this.Opacity -= 0.05;\n Thread.Sleep(50);//This is for the speed of the opacity... and will let the form redraw\n}\n"
},
{
"answer_id": 84379,
"author": "slyprid",
"author_id": 15969,
"author_profile": "https://Stackoverflow.com/users/15969",
"pm_score": 3,
"selected": false,
"text": " private void fadeTimer_Tick(object sender, EventArgs e)\n {\n this.Opacity -= 0.01;\n\n if (this.Opacity <= 0)\n {\n this.Close();\n } \n }\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4660/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.