qid int64 4 19.1M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
427,262 | <p>Am I allowed to add whatever attributes I want to HTML tags such that I can retrieve their value later on using javascript? For example:</p>
<pre><code><a href="something.html" hastooltip="yes" tipcolour="yellow">...</a>
</code></pre>
<p>If that's not going to work, how would you store arbitrary pieces of information like this?</p>
<p><strong>Edit:</strong> Since it appears that making up HTML attributes isn't technically valid, I've rephrased the second part of this question into its own question here: <a href="https://stackoverflow.com/questions/432174/">How to store arbitrary data for some HTML tags</a></p>
| [
{
"answer_id": 427282,
"author": "bandi",
"author_id": 49388,
"author_profile": "https://Stackoverflow.com/users/49388",
"pm_score": 5,
"selected": false,
"text": "<a href=\"...\" class=\"class-one class-two has-tooltip\">\n <a href=\"...\" class=\"has-tooltip common-tooltip\">\n<a href=... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
427,264 | <p>When my ASP.Net session times out (and forms authentication as well) and I try to hit a page, I am automatically redirected to my default login.aspx page. </p>
<p>Before the page loads I need to determine whether this is a timeout situation and if so - redirect to timeout.aspx.</p>
<p>The articles below specify that if IsNewSession is true, and a sessionID cookie exists - then you have a timeout situation.</p>
<p>However in my testing I have the situation where I timeout and try to log back in again and IsNewSession is equal to true and the sessionId cookie is still hanging around (because it stays for a entire browser session), therefore it says I've timed-out again when I'm just trying to log back in.</p>
<p>Is there a better way to do all this?</p>
<p>Technique is decribed <a href="http://www.eggheadcafe.com/articles/20051228.asp" rel="noreferrer">here</a> and <a href="http://blogs.msdn.com/nikhiln/archive/2007/06/21/detecting-session-timeout-in-asp-net-2-0-web-applications.aspx" rel="noreferrer">here</a>.</p>
<p>In my 'global.asax' file I have:</p>
<pre><code>void Application_PreRequestHandlerExecute(object sender, EventArgs e)
{
// Check if session state is enabled in web.config
if (Context.Session == null) return;
if (Session["user"] == null)
{
if (Session.IsNewSession)
{
HttpCookie sessionCookie = Request.Cookies["ASP.NET_SessionId"];
if ((null != sessionCookie) && !string.IsNullOrEmpty(sessionCookie.Value))
{
/* Session Timeout! */
FormsAuthentication.SignOut(); //just in case not done yet
Session.Abandon();
Response.Redirect("timeout.aspx");
}
else
{
// Cookie didn't exist - must be a brand new login
return;
}
}
else
{
// If there is no session data and the session is not new then it must be the postback of the login screen.
if ((HttpContext.Current.Request.Path.ToLower().LastIndexOf("/login.aspx") >= 0) && (Request.HttpMethod == "POST"))
{
return;
}
}
}
}
</code></pre>
| [
{
"answer_id": 427518,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": "https://Stackoverflow.com/users/17516",
"pm_score": 3,
"selected": false,
"text": "IsNewSession"
},
{
"answer_id": 882577,
"author": "Community",
"author_id": -1,
"author_profile"... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
427,266 | <p>Seem to be having an issue with std::auto_ptr and assignment, such that the object referenced seems to get trashed for some reason.</p>
<pre><code>std::auto_ptr<AClass> someVar = new AClass(); // should work, but mangles content
std::auto_ptr<AClass> someVar( new AClass() ); // works fine.
std::auto_ptr<AClass> someVar = std::auto_ptr<AClass>(new AClass()); // works fine.
std::auto_ptr<AClass> someVar;
someVar.reset( new AClass() ); // works fine.
</code></pre>
<p>I've traced it through, and it appears (via watching the values in the debugger) that the problem occurs in the transfer of the pointer from the temporary std::auto_ptr_byref() that is created to wrap the rhs pointer. That is the value contained in _Right on entering the auto_ptr(auto_ptr_ref<_Ty> _Right) function is correct, but the value in _Myptr on leaving is junk.</p>
<pre><code>template<class _Ty>
struct auto_ptr_ref
{ // proxy reference for auto_ptr copying
auto_ptr_ref(void *_Right)
: _Ref(_Right)
{ // construct from generic pointer to auto_ptr ptr
}
void *_Ref; // generic pointer to auto_ptr ptr
};
template<class _Ty>
class auto_ptr
{ // wrap an object pointer to ensure destruction
public:
typedef _Ty element_type;
explicit auto_ptr(_Ty *_Ptr = 0) _THROW0()
: _Myptr(_Ptr)
{ // construct from object pointer
}
auto_ptr(auto_ptr<_Ty>& _Right) _THROW0()
: _Myptr(_Right.release())
{ // construct by assuming pointer from _Right auto_ptr
}
auto_ptr(auto_ptr_ref<_Ty> _Right) _THROW0()
{ // construct by assuming pointer from _Right auto_ptr_ref
_Ty **_Pptr = (_Ty **)_Right._Ref;
_Ty *_Ptr = *_Pptr;
*_Pptr = 0; // release old
_Myptr = _Ptr; // reset this
}
auto_ptr<_Ty>& operator=(auto_ptr_ref<_Ty> _Right) _THROW0()
{ // assign compatible _Right._Ref (assume pointer)
_Ty **_Pptr = (_Ty **)_Right._Ref;
_Ty *_Ptr = *_Pptr;
*_Pptr = 0; // release old
reset(_Ptr); // set new
return (*this);
}
</code></pre>
<p>At first I thought it was messing up the inheritance and slicing off interfaces, however this happens even if the class only has one parent class.</p>
<p>We can avoid doing = new if we remember, either by using brackets or changing to have a explicit std::auto_ptr temp on the rhs, this is of course error prone.</p>
<p>Is it just this version of the library being broken, or some underlying thing I'm just not getting?</p>
<p>We also noticed a similar issue with assigning a std::auto_ptr to a boot::shared_ptr though we removed that entirely now and I don't recall which syntax caused the issue.</p>
| [
{
"answer_id": 427273,
"author": "Jesse Pepper",
"author_id": 43058,
"author_profile": "https://Stackoverflow.com/users/43058",
"pm_score": 0,
"selected": false,
"text": "reset"
},
{
"answer_id": 427279,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": ... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37558/"
] |
427,272 | <p>I've read in JSF docs that <a href="http://docs.oracle.com/javaee/7/api/javax/faces/render/ResponseStateManager.html" rel="noreferrer"><code>ResponseStateManager</code></a> has a <a href="http://docs.oracle.com/javaee/7/api/javax/faces/render/ResponseStateManager.html#isPostback%28javax.faces.context.FacesContext%29" rel="noreferrer"><code>isPostBack()</code></a> method. How (and where) can I have an instance of <code>ResponseStateManager</code>?</p>
| [
{
"answer_id": 5266223,
"author": "bravocharlie",
"author_id": 190675,
"author_profile": "https://Stackoverflow.com/users/190675",
"pm_score": 2,
"selected": false,
"text": "public static boolean isPostback(){\n FacesContext context = FacesContext.getCurrentInstance();\n return con... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27789/"
] |
427,284 | <p>The following jQuery code works just fine for me with Safari, Opera, FF2, and FF3. It positions a busy DIV (with an animated busy GIF) on top of a FORM element on my web page. The problem is that in IE6 and IE7, it gets width and height properly, but doesn't seem to get top and left properly. What's the catch?</p>
<pre><code>var nH = $('#' + sForm).attr('offsetHeight');
var nW = $('#' + sForm).attr('offsetWidth');
var nT = $('#' + sForm).attr('offsetTop');
var nL = $('#' + sForm).attr('offsetLeft');
$('#busy')
.css('position','absolute')
.css('height', nH + 'px')
.css('width', nW + 'px')
.css('top', nT + 'px')
.css('left', nL + 'px')
.show();
</code></pre>
<p>Note that on my page I have multiple FORM elements. (The reason for the busy GIF is because I'm doing an AJAX post in the background when a form is submitted.)</p>
<p>Note I also tried the jQuery Dimensions Plugin 1.2's <code>.position()</code> value for top and left, and that helped, but seemed to have the <code>top</code> value become more off the further I moved down in the page.</p>
| [
{
"answer_id": 427480,
"author": "brian",
"author_id": 53224,
"author_profile": "https://Stackoverflow.com/users/53224",
"pm_score": 0,
"selected": false,
"text": "$('#busy')\n .css({'position':'absolute',\n 'height': nH + 'px',\n 'width', nW + 'px',\n 'top'... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
427,289 | <p>Both:</p>
<ul>
<li>CLSID</li>
<li>IID</li>
</ul>
<p>Having specified the above, and using:</p>
<ul><li>CoCreateInstance()</li></ul>
<p>To returning a single uninitialised object of the class specified by the CLSID above.</p>
<p>How can I then access an Interface's method from C++?
Without:</p>
<ul>
<li>ATL</li>
<li>MFC</li>
<li>Just plain C++</li>
</ul>
<p>Afterwards, I use CreateInstance()</p>
<p>I'm having trouble, using CreateInstance() - with the last parameter - ppv </p>
<p>Using oleview, I can see methods of the specified IIDabove IID above, such as:</p>
<pre><code>interface IS8Simulation : IDispatch {
HRESULT Open([in] BSTR FileName);
};
</code></pre>
<p>How can I then access the above? Examples/guidance - please</p>
<p>Regards</p>
| [
{
"answer_id": 427310,
"author": "Aamir",
"author_id": 30341,
"author_profile": "https://Stackoverflow.com/users/30341",
"pm_score": 4,
"selected": true,
"text": "\nIUnknown* pUnk = NULL;\nHRESULT hr = ::CoCreateInstance(clsid,NULL,CLSCTX_ALL,__uuidof(IUnknown),(void**)&pUnk);\n\nIS8Simu... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51078/"
] |
427,306 | <p>Certain methods in Java will block until they can do something, like ServerSocket.accept() and InputStream.read(), but how it does this is not easy for me to find. The closest thing I can think of is a while() loop with a Thread.sleep() each time through, but the longer the sleep period, the less responsive the blocking, and the shorter the sleep, the more spinning that occurs. </p>
<p>I have two questions:</p>
<ol>
<li><p>How do various standard functions, like the ones above, block? Native code? while() loops? Something else? </p></li>
<li><p>How should I implement methods that block?</p></li>
</ol>
| [
{
"answer_id": 427313,
"author": "MandyK",
"author_id": 52717,
"author_profile": "https://Stackoverflow.com/users/52717",
"pm_score": 3,
"selected": false,
"text": "Object.wait() Object.notify() wait() notify()"
}
] | 2009/01/09 | [
"https://Stackoverflow.com/questions/427306",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34910/"
] |
427,326 | <p>I am trying to write a C# http server for a personal project, i am wondering how i can change the returned server header from Microsoft-HTTPAPI/2.0, to something else?</p>
<pre><code> public class HttpWebServer
{
private HttpListener Listener;
public void Start()
{
Listener = new HttpListener();
Listener.Prefixes.Add("http://*:5555/");
Listener.Start();
Listener.BeginGetContext(ProcessRequest, Listener);
Console.WriteLine("Connection Started");
}
public void Stop()
{
Listener.Stop();
}
private void ProcessRequest(IAsyncResult result)
{
HttpListener listener = (HttpListener)result.AsyncState;
HttpListenerContext context = listener.EndGetContext(result);
string responseString = "<html>Hello World</html>";
byte[] buffer = Encoding.UTF8.GetBytes(responseString);
context.Response.ContentLength64 = buffer.Length;
System.IO.Stream output = context.Response.OutputStream;
output.Write(buffer, 0, buffer.Length);
output.Close();
Listener.BeginGetContext(ProcessRequest, Listener);
}
}
</code></pre>
| [
{
"answer_id": 427365,
"author": "Elijah Glover",
"author_id": 53238,
"author_profile": "https://Stackoverflow.com/users/53238",
"pm_score": 1,
"selected": false,
"text": "private void ProcessRequest(IAsyncResult result)\n {\n HttpListener listener = (HttpListener)resul... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53238/"
] |
427,329 | <p>I have a multi-threaded Windows C++ app written in Visual Studio 6.</p>
<p>Within the app 2 threads are running each trying to read UDP packets on different ports. If I protect the reading from the socket with a critical section then all the date read is fine. Without that protection data is lost from both sockets.</p>
<p>Is reading from a socket not thread safe? I've written many socket apps in the past and don't remember having to use this sort of thread protection.</p>
| [
{
"answer_id": 428796,
"author": "Mr.Ree",
"author_id": 37946,
"author_profile": "https://Stackoverflow.com/users/37946",
"pm_score": 3,
"selected": true,
"text": "int newBufferSize = 128 * 1024; // 128k\nsetsockopt( readSocketFd, SOL_SOCKET, SO_RCVBUF, (char *) & newBufferSize );\n"
... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15669/"
] |
427,332 | <p>Coming from a Perl background, I have to say I prefer <code>cpan Foo::Bar</code> to the having to start sbcl, <code>(require :asdf-install)</code> and finally <code>(asdf-install:install :foo-bar)</code>. Is there anything more convenient than this around?</p>
| [
{
"answer_id": 427333,
"author": "jrockway",
"author_id": 8457,
"author_profile": "https://Stackoverflow.com/users/8457",
"pm_score": 3,
"selected": true,
"text": "http://common-lisp.net/project/clbuild/\n function asdf_install {\n sbcl --eval \"(asdf:operate 'asdf:load-op :asdf-insta... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8457/"
] |
427,335 | <p>I have a console application. A class (let's say Worker) does some work in a separate thread and throws an event when it finishes. But this never happens because the execution ends instantly. How can I wait for the thread to finish and handle the event after it throws?</p>
<pre><code>static void Main(string[] args)
{
Worker worker = new Worker();
worker.WorkCompleted += PostProcess;
worker.DoWork();
}
static void PostProcess(object sender, EventArgs e) { // Cannot see this happening }
</code></pre>
<p><strong>Edit:</strong> Corrected the order of the statements but that was not the problem.</p>
| [
{
"answer_id": 427339,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 2,
"selected": false,
"text": "static void Main(string[] args)\n{\n Worker worker = new Worker();\n worker.WorkCompleted += PostProcess;\n wo... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31505/"
] |
427,346 | <p>How can I get C# to distinguish between ambiguous class types without having to specify the full <code>HtmlAgilityPack.HtmlDocument</code> name every time (it is ambiguous compared to <code>System.Windows.Forms.HtmlDocument</code>)?</p>
<p>Is there a way to make C# know that I am ALWAYS talking about one class or the other, and thus not have to specify it each time I use it?</p>
| [
{
"answer_id": 427350,
"author": "Hosam Aly",
"author_id": 41283,
"author_profile": "https://Stackoverflow.com/users/41283",
"pm_score": 7,
"selected": true,
"text": "using HapHtmlDocument = HtmlAgilityPack.HtmlDocument;\nusing WfHtmlDocument = System.Windows.Forms.HtmlDocument;\n"
},
... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47630/"
] |
427,351 | <p>I'm currently working on a web application (ASP.NET) and some of the pages that are included were created by other programmers, what I noticed is, they are not using "Me(VB.NET)" keyword to access controls, while on my side I used it in every page that I've created. Just to give further information, the web application runs on a .NET Framework 2.0. Does anyone out there who will help me understand is it required to use Me or not? What are the advantages and disadvantages in the whole code if you're using Me? Can it improve the performance of the application? </p>
<p>Any help is highly appreciated. Thanks in advance.</p>
| [
{
"answer_id": 427368,
"author": "lc.",
"author_id": 44853,
"author_profile": "https://Stackoverflow.com/users/44853",
"pm_score": 4,
"selected": false,
"text": "DoSomething(MyString As String) String MyString MyString Me.MyString Me.MyString = MyString"
},
{
"answer_id": 427378,... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427351",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48581/"
] |
427,362 | <p>I need a table to store the state of a financial transaction.
The state of this transaction can be roughly modelled by this class.</p>
<pre><code>class FinancialTransaction
{
Integer txId,
Money oldLimit,
Money newLimit,
Money oldBalance,
Money newBalance,
Date txDate
}
class Money
{
Currency curr,
BigDecimal amount
}
</code></pre>
<p>My initial design of the schema looks like this:</p>
<pre><code>CREATE TABLE tx
(
txId bigint(20) unsigned NOT NULL,
oldlimit_currency varchar(3) NULL,
oldlimit_amount decimal(7,5) default 0.00,
newlimit_currency varchar(3) NULL,
newlimit_amount decimal(7,5) default 0.00,
----snipped----
PRIMARY KEY (txId)
)
</code></pre>
<p>Two things worry me:</p>
<ol>
<li>Each transaction occurs based on one Currency. I haven't thought far enough as to whether I might need to support transactions that may happen in multiple currencies. Assuming that it doesn't change; then isn't it more space-efficient to just maintain one currency column ? Will I regret this simplistic solution ?</li>
<li>Since each Money item is a value object, should I instead save all Money objects into a separate Money table and have the original table use moneyIds as foreign keys to the Money table ?</li>
</ol>
<p>That is,</p>
<pre><code>CREATE TABLE tx
(
txId bigint(20) unsigned NOT NULL,
oldlimit_money_id int NOT NULL,
newlimit_money_id int NOT NULL,
----snipped----
PRIMARY KEY (txId),
FOREIGN KEY (oldlimit_money_id) REFERENCES MONEY(id) ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY (newlimit_money_id) REFERENCES MONEY(id) ON DELETE NO ACTION ON UPDATE NO ACTION
)
</code></pre>
<p>Are there alternative designs ?</p>
<p>Thanks lazyweb.</p>
| [
{
"answer_id": 427396,
"author": "Aleris",
"author_id": 20417,
"author_profile": "https://Stackoverflow.com/users/20417",
"pm_score": 3,
"selected": true,
"text": "CREATE TABLE tx\n(\n id bigint(20) unsigned primary key,\n old_limit_currency_id int not null references CURRENCY(id),... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24457/"
] |
427,363 | <p>If I have two objects on the heap referring to each other but they are not linking to any reference variable then are those objects eligible for garbage collection?</p>
| [
{
"answer_id": 427369,
"author": "Hosam Aly",
"author_id": 41283,
"author_profile": "https://Stackoverflow.com/users/41283",
"pm_score": 3,
"selected": false,
"text": "java.lang.ref.WeakReference"
}
] | 2009/01/09 | [
"https://Stackoverflow.com/questions/427363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40933/"
] |
427,389 | <p>My page deals with many "Store" objects, each of them has a field called 'data'. However, this data is fetched via AJAX requests which may be parallely going on.</p>
<pre><code>function Store(id){
this.id = id;
this.queryparam = 'blah';
this.items = null;
}
Store.prototype.fetch = function(){
$.get("/get_items",{q:this.quaryparam},function(data,status){
// how to store the received data in this particular store object? Being
// a callback function, I don't have a reference to this object as 'this'
// this.data = data; //will not work
});
}
</code></pre>
<p>In the callback function I tried defining a default parameter to the calling objects as following:</p>
<pre><code>$.get("/get_items",{q:this.quaryparam},function(data,status, ref = this) ...
</code></pre>
<p>But turns out that javascript does not support default argument values like this. <strong>Can I somehow get jquery to pass a reference to 'this' store in the callback function?</strong></p>
<p>I thought of a couple of other approaches but none of them work:</p>
<p>I could set the store data using synchronous requests but then thats not the point of AJAX, is it?</p>
<p>Another way for me could be, to send the store id also in the requests which will come back in the response. For eg:</p>
<pre><code>// in Store.fetch()
$.get("/get_items",{q:this.quaryparam,id:this.id},function(responsetext,status){
var response = eval(responsetext);
stores[response.id].data = response.data;
});
</code></pre>
<p>I do not like this approach because this pollutes the response just because the client-side code was unable to keep track of which request was sent by which object.</p>
<p>Moreover, since store.id is client-specific, it will also mess up caching at the server. A different request URL will be used for two different stores even though they have the same query parameters. </p>
<p>Is there any other way to achieve what I want?</p>
| [
{
"answer_id": 427407,
"author": "Ricardo Vega",
"author_id": 53246,
"author_profile": "https://Stackoverflow.com/users/53246",
"pm_score": 2,
"selected": false,
"text": "Store.prototype.fetch = function(){\n var that = this;\n $.get(\"/get_items\",{q:this.quaryparam},function(resp... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
427,395 | <p>I'm trying to get the Poll tutorial working at my Dreamhost account (I don't have any prior experience of deploying Django). I downloaded the script I found here (<a href="http://gabrielfalcao.com/2008/12/02/hosting-and-deploying-django-apps-on-dreamhost/" rel="nofollow noreferrer">http://gabrielfalcao.com/2008/12/02/hosting-and-deploying-django-apps-on-dreamhost/</a>) at my home directory and executed it. Now I have Python 2.5 and Django in ~/.myroot/ and my Django projects directory is ~/projects/</p>
<p>Here's the content of ~/projects/ directory (I copied the polls/ and and templates/polls/ directories myself).</p>
<pre><code>projects/
|-- admin_media -> /home/imran2140/.myroot/usr/lib/python2.5/site-packages/django/contrib/admin/media
|-- dispatch.fcgi
|-- polls
| |-- __init__.py
| |-- __init__.pyc
| |-- admin.py
| |-- admin.pyc
| |-- models.py
| |-- models.pyc
| |-- polls.db
| |-- urls.py
| |-- urls.pyc
| |-- views.py
| `-- views.pyc
|-- script_templates
| |-- dispatch.template
| `-- htaccess.template
`-- templates
`-- polls
|-- detail.html
|-- index.html
`-- results.html
5 directories, 17 files
</code></pre>
<p>Now what should I do to get the Polls app working?</p>
<p><strong>Update</strong></p>
<p>I finally got a "Hello World" Django app working with Passanger WSGI. It worked fine with both Server's default Python 2.3.5 and my installed Python 2.5.2.</p>
<p><a href="http://wiki.dreamhost.com/Passenger_WSGI" rel="nofollow noreferrer">Passanger WSGI - Django</a> at Dreamhost Wiki</p>
| [
{
"answer_id": 427401,
"author": "sastanin",
"author_id": 25450,
"author_profile": "https://Stackoverflow.com/users/25450",
"pm_score": 1,
"selected": false,
"text": ".htaccess"
}
] | 2009/01/09 | [
"https://Stackoverflow.com/questions/427395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1897/"
] |
427,400 | <p>I'm a newbie to python and the app engine.</p>
<p>I have this code that sends an email based on request params after some auth logic. in my Unit tests (i'm using <a href="http://code.google.com/p/gaeunit/" rel="nofollow noreferrer">GAEUnit</a>), how do I confirm an email with specific contents were sent? - i.e. how do I mock the emailer with a fake emailer to verify send was called?</p>
<pre><code>class EmailHandler(webapp.RequestHandler):
def bad_input(self):
self.response.set_status(400)
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write("<html><body>bad input </body></html>")
def get(self):
to_addr = self.request.get("to")
subj = self.request.get("subject")
msg = self.request.get("body")
if not mail.is_email_valid(to_addr):
# Return an error message...
# self.bad_input()
pass
# authenticate here
message = mail.EmailMessage()
message.sender = "my.company@gmail.com"
message.to = to_addr
message.subject = subj
message.body = msg
message.send()
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write("<html><body>success!</body></html>")
</code></pre>
<p>And the unit tests,</p>
<pre><code>import unittest
from webtest import TestApp
from google.appengine.ext import webapp
from email import EmailHandler
class SendingEmails(unittest.TestCase):
def setUp(self):
self.application = webapp.WSGIApplication([('/', EmailHandler)], debug=True)
def test_success(self):
app = TestApp(self.application)
response = app.get('http://localhost:8080/send?to=vijay.santhanam@gmail.com&body=blah_blah_blah&subject=mySubject')
self.assertEqual('200 OK', response.status)
self.assertTrue('success' in response)
# somehow, assert email was sent
</code></pre>
| [
{
"answer_id": 1411769,
"author": "JJ Geewax",
"author_id": 81019,
"author_profile": "https://Stackoverflow.com/users/81019",
"pm_score": 2,
"selected": false,
"text": "_GenerateLog mail_stub from google.appengine.api import apiproxy_stub_map, mail_stub\n\n__all__ = ['MailTestCase']\n\nc... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/209/"
] |
427,433 | <p>I have a C# project building "winexe" that startup without console window.</p>
<p>However, I want to dispaly the console window and write stdout/stderr by giving a cmd line parameter. If it close, the application shutdown. For example: <em>eclipse.exe -debug</em></p>
<p>How can it be done?</p>
<p>PS. I am using Visual Studio 2005</p>
| [
{
"answer_id": 427461,
"author": "peSHIr",
"author_id": 50846,
"author_profile": "https://Stackoverflow.com/users/50846",
"pm_score": 0,
"selected": false,
"text": "System.Console cmd System.Diagnostics.Process stdin stdout stderr"
}
] | 2009/01/09 | [
"https://Stackoverflow.com/questions/427433",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40214/"
] |
427,436 | <p>To count Activex controls from MS-Access forms using vb.net I am using the connection as follws..</p>
<p>oDBEngine = oAccess.DBEngine
oDB = oDBEngine.OpenDatabase(Name:=strFullFileName, Options:=False, ReadOnly:=False, Connect:="")</p>
<p>and Openning the forms in <strong>Design mode</strong>, as there is a user input prompt form which prevents us to run the application further if we open it in Default view. </p>
<p>oAccess.DoCmd.OpenForm(FormName:=objForms.Name, View:=AcFormView.acDesign)</p>
<p>Now the problem is:</p>
<p>The DataBase gets opens and along with that all the forms open up while running the application. Is there anyway we just prevent to open the database and forms, while reading the forms.</p>
<p>Thank you.</p>
| [
{
"answer_id": 427460,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 1,
"selected": false,
"text": "SELECT MsysObjects.Name\nFROM MsysObjects IN 'C:\\docs\\LTD.mdb'\nWHERE MsysObjects.Type=-32768\n strSQL = \"SELECT MsysOb... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45255/"
] |
427,447 | <p>Let say there is a table:</p>
<pre><code>TableA:Field1, Field2, Field3
</code></pre>
<p>and associated JPA entity class</p>
<pre><code>@Entity
@Table(name="TableA")
public class TableA{
@Id
@Column(name="Field1")
private Long id;
@Column(name="Field2")
private Long field2;
@Column(name="Field3")
private Long field3;
//... more associated getter and setter...
}
</code></pre>
<p>Is there any way to construct a JPQL statement that loosely translated to this SQL, ie how to translated the case expression to JPQL?</p>
<pre><code>select field1,
case
when field2 = 1 then 'One'
when field2 = 2 then 'Two'
else 'Other number'
end,
field3
from tableA;
</code></pre>
| [
{
"answer_id": 517493,
"author": "aledbf",
"author_id": 53078,
"author_profile": "https://Stackoverflow.com/users/53078",
"pm_score": 2,
"selected": false,
"text": "@Entity\n@Table(name = \"TableA\")\npublic class TableA {\n\n @Id\n @Column(name = \"Field1\")\n private Long id;\... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29669/"
] |
427,448 | <p>Hi I have following data in the table:</p>
<p>ID-----startDate----endDate<br>
5549 2008-05-01 4712-12-31<br>
<strong>5567 2008-04-17 2008-04-30 1<br>
5567 2008-05-01 2008-07-31 1<br>
5567 2008-09-01 4712-12-31 2</strong><br>
5569 2008-05-01 2008-08-31<br>
5569 2008-09-01 4712-12-31<br>
5589 2008-04-18 2008-04-30<br>
5589 2008-05-01 4712-12-31<br>
5667 2008-05-01 4712-12-31<br>
5828 2008-06-03 4712-12-31<br>
5867 2008-06-03 4712-12-31<br>
6167 2008-11-01 4712-12-31<br>
6207 2008-07-01 4712-12-31<br>
6228 2008-07-01 4712-12-31<br>
6267 2008-07-14 4712-12-31</p>
<p>I am looking for I way to group the continuous time intervals for each id to return:</p>
<p>ID,
min(startDate),
max(endDate),</p>
<p>to have something like this in result for the bolded ID 5567 </p>
<p>5567 2008-04-17 2008-07-31<br>
5567 2008-09-01 4712-12-31 </p>
<p>PL/SQL is also an option here :)</p>
<p>Thanks,</p>
| [
{
"answer_id": 427484,
"author": "Dheer",
"author_id": 17266,
"author_profile": "https://Stackoverflow.com/users/17266",
"pm_score": 0,
"selected": false,
"text": "Create or Replace someproc\nDeclare\n Cursore someCur AS\n Select * from someTable\n Order by ID,StartDate\n\n I... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3515/"
] |
427,451 | <p>I have a unit test (example is modified <a href="http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit.html" rel="noreferrer">Test::Unit documentation</a>)</p>
<pre><code>require 'test/unit'
class TC_MyTest < Test::Unit::TestCase
def test_something
assert(true)
end
end
</code></pre>
<p>When I execute it, I get:</p>
<pre><code>Loaded suite C:/test
Started
.
Finished in 0.0 seconds.
1 tests, 1 assertions, 0 failures, 0 errors
</code></pre>
<p>I would like to get something like this (<code>test_something</code> is outputted):</p>
<pre><code>Loaded suite C:/test
Started
test_something
.
Finished in 0.0 seconds.
1 tests, 1 assertions, 0 failures, 0 errors
</code></pre>
| [
{
"answer_id": 427475,
"author": "Željko Filipin",
"author_id": 17469,
"author_profile": "https://Stackoverflow.com/users/17469",
"pm_score": 4,
"selected": true,
"text": "test.rb -v v\n test.rb --verbose=verbose\n Loaded suite C:/test\nStarted\ntest_something(TC_MyTest): .\n\nFinished i... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17469/"
] |
427,452 | <p>In the following setup, does method B run in a (new) transaction?</p>
<p>An EJB, having two methods, method A and method B</p>
<pre><code>public class MyEJB implements SessionBean
public void methodA() {
doImportantStuff();
methodB();
doMoreImportantStuff();
}
public void methodB() {
doDatabaseThing();
}
}
</code></pre>
<p>The EJB is container managed, with methodB in requires_new transaction, and method A in required transaction. thus:</p>
<pre><code><container-transaction id="MethodTransaction_1178709616940">
<method id="MethodElement_1178709616955">
<ejb-name>MyName</ejb-name>
<method-name>*</method-name>
<trans-attribute>Required</trans-attribute>
</method>
<method id="MethodElement_1178709616971">
<ejb-name>MyName</ejb-name>
<method-name>methodB</method-name>
</method>
<trans-attribute>RequiresNew</trans-attribute>
</container-transaction>
</code></pre>
<p>Now let another EJB call methodA with an EJB method call.
methodA now runs in an transaction. Will the subsequent call to methodB from methodA run in the same transaction, or does it run in a new transaction?
(mind, it's the actual code here. There is no explicit ejb-call to method B)</p>
| [
{
"answer_id": 427582,
"author": "david a.",
"author_id": 44355,
"author_profile": "https://Stackoverflow.com/users/44355",
"pm_score": 5,
"selected": false,
"text": "methodB() this"
},
{
"answer_id": 12330628,
"author": "DrAhmedJava",
"author_id": 1656654,
"author_pr... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
427,453 | <p>Suppose I have a Python function as defined below:</p>
<pre><code>def foo(arg1,arg2):
#do something with args
a = arg1 + arg2
return a
</code></pre>
<p>I can get the name of the function using <code>foo.func_name</code>. How can I programmatically get its source code, as I typed above?</p>
| [
{
"answer_id": 427504,
"author": "runeh",
"author_id": 2906,
"author_profile": "https://Stackoverflow.com/users/2906",
"pm_score": 8,
"selected": false,
"text": "inspect.getsource(foo) import inspect\n\ndef foo(arg1,arg2):\n #do something with args\n a = arg1 + arg2\n return a\n... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
427,472 | <p>my Python program can be launched with a range of different options (or subcommands) like:</p>
<pre><code>$ myProgram doSomething
$ myProgram doSomethingElse
$ myProgram nowDoSomethingDifferent
</code></pre>
<p>I want it to use auto-completion with so that if i type "myProgram d" it returns "myProgram doSomething" and if i type "myProgram n" it renders "myProgram nowDoSomethingDifferent". This is similar to the average use of the module <em>rlcompleter</em>, but it does not pick possible completion options from the filesystem (or from history) but from a custom set of strings (that correspond to the available options for my program)</p>
<p>Any idea on how to implement this?</p>
<p>I'm aware of the variable PYTHONSTARTUP (that should point to a file I don't know how to write).</p>
<p>As a working example, django-admin (from the django package) has the same exact feature i'm looking for</p>
| [
{
"answer_id": 427490,
"author": "sastanin",
"author_id": 25450,
"author_profile": "https://Stackoverflow.com/users/25450",
"pm_score": 2,
"selected": false,
"text": "rlcompleter readline $ ./myscript.py\nMy Script version 3.1415.\nEnter your commands:\nmyscript> B<TAB>egin\nmyscript> E<... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42636/"
] |
427,477 | <p>Is there a more efficient way to clamp real numbers than using if statements or ternary operators?
I want to do this both for doubles and for a 32-bit fixpoint implementation (16.16). I'm <strong>not</strong> asking for code that can handle both cases; they will be handled in separate functions.</p>
<p>Obviously, I can do something like:</p>
<pre><code>double clampedA;
double a = calculate();
clampedA = a > MY_MAX ? MY_MAX : a;
clampedA = a < MY_MIN ? MY_MIN : a;
</code></pre>
<p>or</p>
<pre><code>double a = calculate();
double clampedA = a;
if(clampedA > MY_MAX)
clampedA = MY_MAX;
else if(clampedA < MY_MIN)
clampedA = MY_MIN;
</code></pre>
<p>The fixpoint version would use functions/macros for comparisons.</p>
<p>This is done in a performance-critical part of the code, so I'm looking for an as efficient way to do it as possible (which I suspect would involve bit-manipulation) </p>
<p>EDIT: It has to be standard/portable C, platform-specific functionality is not of any interest here. Also, <code>MY_MIN</code> and <code>MY_MAX</code> are the same type as the value I want clamped (doubles in the examples above).</p>
| [
{
"answer_id": 427491,
"author": "abelenky",
"author_id": 34824,
"author_profile": "https://Stackoverflow.com/users/34824",
"pm_score": 0,
"selected": false,
"text": "clampedA = (a > MY_MAX)? MY_MAX : (a < MY_MIN)? MY_MIN : a;\n int b = (int)a;\nclampedA = (b > MY_MAX)? (double)MY_MAX : ... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15323/"
] |
427,479 | <p>I'm trying to "force" Safari or IE7 to open a new page <em>using a new tab</em>.</p>
<p>Programmatically I mean something like:</p>
<pre><code>window.open('page.html','newtaborsomething');
</code></pre>
| [
{
"answer_id": 427515,
"author": "Eineki",
"author_id": 29125,
"author_profile": "https://Stackoverflow.com/users/29125",
"pm_score": 7,
"selected": false,
"text": "<a href=\"some url\" target=\"_newtab\">content of the anchor</a>\n window.open('page.html','_newtab');\n"
},
{
"an... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53246/"
] |
427,482 | <p>I have this simple Jsp page:</p>
<pre><code><%@ page language="java" import="java.awt.Color"%> <%
Color background = Color.white;
%>
</code></pre>
<p>Which fails with following error:</p>
<pre><code>java.lang.NoClassDefFoundError
at _text__jsp._jspService(/text.jsp:3)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.subservice(Page.java:506)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
at com.caucho.server.http.Invocation.service(Invocation.java:315)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:346)
at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:274)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:534)
</code></pre>
<p>I'm running it on Resin 2.1.13.</p>
<p>Any idea what's causing this?</p>
| [
{
"answer_id": 427506,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": -1,
"selected": false,
"text": "java.awt.Color\n"
},
{
"answer_id": 17693407,
"author": "Sprooose",
"author_id": 383369,
"author_pro... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9789/"
] |
427,485 | <p>Suppose I start two threads like this:</p>
<pre><code>// Start first thread
Thread loaderThread1 = new Thread(loader.Load);
loaderThread1.Name = "Rope";
loaderThread1.Start();
// Start second thread
Thread loaderThread2 = new Thread(loader.Load);
loaderThread2.Name = "String";
loaderThread2.Start();
</code></pre>
<p>Is there any way I can enumerate the threads by using their Name property?</p>
<p>I want to be ablie to check if a thread with a specific name is still running. </p>
<p>Each thread I create works with a named set of data, the name of the data set is used as the name for the thread working with the data. Before starting a worker thread I want to see if any previous thread for the same set of data is already running.</p>
<p>The threads I get when using <code>System.Diagnostics.GetCurrentProcess().Threads</code> are of type <code>ProcessThread</code>, not <code>Thread</code>!</p>
| [
{
"answer_id": 427502,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "Dictionary<string,Thread> Thread"
},
{
"answer_id": 427703,
"author": "Oliver Friedrich",
"author_id"... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7174/"
] |
427,488 | <p>I have a csv file of 1.2 million records of text. The alphanumeric fields are wrapped in quotation marks, the date/time or numeric fields are not.</p>
<p>For example
"Fred","Smith",01/07/1967,2,"7, The High Street","Anytown","Anycounty","LS1 7AA"</p>
<p>What I want do is write some VBA in Excel (more or less the only tool available to me that I am reasonably proficient in the use of) that reads the CSV record by record, performs a check (as it happens on the last field, the post code) and then outputs a small subset of the 1.2m records to a new output file.</p>
<p>I understand how to open the two files, read the record, do what I need to do with the data and write it out (I will just output the input record with a prefix denoting an exception type)</p>
<p>What I don't know is how to parse the CSV in VBA properly. I can't do a simple text scan and search for commas as the text sometimes has commas in (hence why the text fields are text delimited)</p>
<p>Is there a fantastic command that would let me quicky get the data from the nth field in my record?</p>
<p>What I want is
s_work = field(s_input_record,5) where 5 is the field number in my CSV....</p>
<p>Many thanks,
C</p>
| [
{
"answer_id": 427511,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 3,
"selected": false,
"text": "Set cn = CreateObject(\"ADODB.Connection\")\n\n'Note HDR=Yes, that is, first row contains field names '\n'and FMT delimted... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
427,517 | <p>I need to get the interface name by providing an IP address. There is no system call to get this.</p>
<p>I need an implementation for this in C or C++</p>
<p>Already the reverse of this is available on Stack Overflow, <em><a href="https://stackoverflow.com/questions/259389/finding-an-ip-from-an-interface-name">Finding an IP address from an interface name</a></em>.</p>
| [
{
"answer_id": 427530,
"author": "Paul Dixon",
"author_id": 6521,
"author_profile": "https://Stackoverflow.com/users/6521",
"pm_score": 4,
"selected": false,
"text": " netstat -ie | grep -B1 \"192.168.21.10\"\n eth0 Link encap:Ethernet HWaddr 00:13:72:79:65:23\n inet addr:... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427517",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
427,549 | <p>I've two tables: TableA and TableB, joined by TableA.TableA_Id->1..n<-TableB.TableA_Id. A simple PK-FK.</p>
<p>I need to extract <strong>distinct</strong> TableA records given a certain condition on TableB. Here's my 1st approach:</p>
<p>SELECT * FROM TableA A INNER JOIN TableB B ON A.idA = B.IdA AND B.Date = '2009-01-10' ORDER BY A.Id;</p>
<p>This is nice, but it doesn't give me "distinct" records. Some records on table B may be duplicate and hence I could get the same records more than once.</p>
<p>So I decided to perform a subselect (performance is not an issue given that the subselect will probably end up with 20/30 records max):</p>
<p>SELECT * FROM TableA WHERE TableA.Id IN ( SELECT DISTINCT IdA FROM TableB WHERE Date = '20090110' ) ORDER BY TableA.IdA;</p>
<p>This works fine.</p>
<p>Now the question is: how can I use the Inner Join and still get the distinct values? Is this possible in one pass or the nested query is a must? What am I missing?</p>
| [
{
"answer_id": 428182,
"author": "HLGEM",
"author_id": 9034,
"author_profile": "https://Stackoverflow.com/users/9034",
"pm_score": 3,
"selected": true,
"text": "SELECT * FROM TableA \nJOIN\n(SELECT DISTINCT IdA FROM TableB WHERE Date = '20090110') a\nON a.IDA = TAbleA.IDA\nORDER BY Table... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2684/"
] |
427,586 | <p>Can anyone please provide me a sample build file demostrating the use of the task of nant-contrib for creating an installer of a web application project.</p>
| [
{
"answer_id": 1048250,
"author": "Damien Carol",
"author_id": 129298,
"author_profile": "https://Stackoverflow.com/users/129298",
"pm_score": 3,
"selected": true,
"text": "<?xml version=\"1.0\"?> \n<project name=\"Scanner\" xmlns=\"http://nant.sf.net/release/0.85/nant.xsd\" xmlns:xsi=\"... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53270/"
] |
427,589 | <p>Supposing to have something like this:</p>
<pre><code>#include <map>
int main(){
std::map<int,int> m;
m[1] = 2;
m[2] = 4;
return 0;
}
</code></pre>
<p>I would like to be able to inspect the contents of the map running the program from gdb.<br>
If I try using the subscript operator I get: </p>
<pre><code>(gdb) p m[1]
Attempt to take address of value not located in memory.
</code></pre>
<p>Using the find method does not yield better results:</p>
<pre><code>(gdb) p m.find(1)
Cannot evaluate function -- may be inlined
</code></pre>
<p>Is there a way to accomplish this? </p>
| [
{
"answer_id": 430224,
"author": "Mr.Ree",
"author_id": 37946,
"author_profile": "https://Stackoverflow.com/users/37946",
"pm_score": 5,
"selected": false,
"text": "#define SHOW(X) cout << # X \" = \" << (X) << endl\n\nvoid testPrint( map<int,int> & m, int i )\n{\n SHOW( m[i] );\n SHOW... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15622/"
] |
427,590 | <p>I hava a web application. In that i have a link called "Home". When the user clicks the starting page of the web application that is index.jsp should be displayed in the same page. How can i do that. It should work in internet explorer. </p>
<p>I have the following html page.</p>
<pre><code><html>
<body bgcolor="#FFF8DC">
<a href="index.jsp" target="parent" >HOME</a>
</body>
</html>
</code></pre>
<p>But it is not working.</p>
| [
{
"answer_id": 427644,
"author": "Ian G",
"author_id": 31765,
"author_profile": "https://Stackoverflow.com/users/31765",
"pm_score": 0,
"selected": false,
"text": "`target=\"_parent\"`\n _ _parent"
},
{
"answer_id": 540670,
"author": "Aron Rotteveel",
"author_id": 11568,
... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48094/"
] |
427,594 | <p>I have an array which contains a list of nibbles:</p>
<pre><code>{0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, ...}
</code></pre>
<p>I want to combine adjacent nibbles into single bytes by left-shifting the upper nibble and concatenating it with the lower one. The output should look as follows:</p>
<pre><code>{0xab, 0xcd, 0xef, ...}
</code></pre>
<p>How can I accomplish this in C?</p>
| [
{
"answer_id": 427610,
"author": "ChrisN",
"author_id": 3853,
"author_profile": "https://Stackoverflow.com/users/3853",
"pm_score": 3,
"selected": false,
"text": "unsigned int Nibble1 = 0x0A;\nunsigned int Nibble2 = 0x0B;\n\nunsigned int Result = (Nibble1 << 4) | Nibble2; // Result = 0xA... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
427,597 | <p>I have a spec in my current project that requires us to advise the user which browsers are best to use the web application. If their current browser version they are using is not in our list of "ideal" browsers we want to display a message.</p>
<p>What is the best way to check a specific version of the users browser. I am aware of the following using jQuery but this doesn't help with specific versions. </p>
<pre><code>$(document).ready(function() {
var b = '';
$.each($.browser, function(i, val) {
if (i=='safari' && val==true) { b = 'safari'; }
if (i=='opera' && val==true) { b = 'opera'; }
if (i=='msie' && val==true) { b = 'msie'; }
if (i=='mozilla' && val==true) {b = 'mozilla'; }
});
//Do Something With b, Like $('#dis').html(b);
});
</code></pre>
<p>We want to be able to say is your browser Firexfox 2 or greater or IE6 or greater etc?</p>
| [
{
"answer_id": 28339420,
"author": "Asanka Siriwardena",
"author_id": 3660710,
"author_profile": "https://Stackoverflow.com/users/3660710",
"pm_score": 0,
"selected": false,
"text": " //MSStream object supported only for IE 10 and 11 (hope this will work for above IE 11 too .. )\n ... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32021/"
] |
427,598 | <p>My Controller class is decorated with an AuthorizeAttribute to protect the actions:</p>
<pre><code>[Authorize(Roles = "User Level 2")]
public class BuyController : Controller
{
...
}
</code></pre>
<p>Anytime an action is invoked, but the user is not in at least the role "User Level 2", the user is automatically redirected to the login page with a URL like this:</p>
<p><a href="http://localhost:1436/Account/Login?ReturnUrl=%2fBuy" rel="nofollow noreferrer">http://localhost:1436/Account/Login?ReturnUrl=%2fBuy</a></p>
<p>If the user is already logged in, but doesn't have the right security level, this is not an optimal behavior! It would make more sense to display a page which informs the user about the missing level instead of showing the login page.</p>
<p>What can I do to customize this behavior?</p>
<p>Is it possible to pass the required user level to the Login action somehow?</p>
| [
{
"answer_id": 428266,
"author": "Trevor de Koekkoek",
"author_id": 41783,
"author_profile": "https://Stackoverflow.com/users/41783",
"pm_score": 6,
"selected": true,
"text": "public class ClubAuthorizeAttribute : AuthorizeAttribute\n{\npublic override void OnAuthorization(AuthorizationC... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2374/"
] |
427,604 | <p>I've been tinkering with Yahoo Pipes and the <a href="http://docs.aws.amazon.com/AWSECommerceService/latest/DG/" rel="nofollow noreferrer">Amazon Product Advertising API (formerly ECS) SDK</a> to retrieve my wishlist.</p>
<p>The problem is that although I can get all the items on my wishlist just fine, it seems to include items that I've deleted too.</p>
<p>Has anyone else used this API and noticed this? Is there a way around it?</p>
<p>UPDATE:</p>
<p>Requested additional information in comments...</p>
<p>Here is the URL I use to fetch the wishlist XML:</p>
<pre><code>http://webservices.amazon.co.uk/onca/xml?SubscriptionId=[my subs id]&Service=AWSECommerceService&ResponseGroup=ListItems&ProductPage=1&ProductGroup=Book&Operation=ListLookup&ListType=WishList&ListId=[my list id]
</code></pre>
<p>And here is the relevant part of the XML response:</p>
<pre><code><ListId>[my list id]</ListId>
<ListName>Wishlist</ListName>
<TotalItems>132</TotalItems>
<TotalPages>14</TotalPages>
<ListItem>
<ListItemId>EPIE5559HKT391</ListItemId>
<DateAdded>2003-11-17</DateAdded>
<QuantityDesired>1</QuantityDesired>
<QuantityReceived>0</QuantityReceived>
<Item>
<ASIN>5557205521</ASIN>
<ItemAttributes>
<Title>Horton hears a who</Title>
</ItemAttributes>
</Item>
</ListItem>
...
</code></pre>
<p>The rest of the XML is just either more list items like that, or information about the request at the top of the response.</p>
| [
{
"answer_id": 428266,
"author": "Trevor de Koekkoek",
"author_id": 41783,
"author_profile": "https://Stackoverflow.com/users/41783",
"pm_score": 6,
"selected": true,
"text": "public class ClubAuthorizeAttribute : AuthorizeAttribute\n{\npublic override void OnAuthorization(AuthorizationC... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/974/"
] |
427,607 | <p><a href="http://www.mono-project.com/" rel="nofollow noreferrer">Mono</a> claims to be compatible with .NET. </p>
<p>Have you tried it? </p>
<p>Can you share any tips or guidelines for making a running .NET application compatible with mono?</p>
| [
{
"answer_id": 427622,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "NotImplementedException [Obsolete] NotImplementedException"
}
] | 2009/01/09 | [
"https://Stackoverflow.com/questions/427607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40441/"
] |
427,609 | <p>I am trying to write a javascript class that loads script files as they are needed. I have most of this working. It is possible to use the library with the following Syntax:</p>
<pre><code>var scriptResource = new ScriptResource('location/of/my/script.js');
scriptResource.call('methodName', arg1, arg2);
</code></pre>
<p>I would like to add some additional syntactic sugar so you could write</p>
<pre><code>var scriptResource = new ScriptResource('location/of/my/script.js');
scriptResource.methodName(arg1, arg2);
</code></pre>
<p>I'm almost certain that this isnt possible but there may be an inventive solution. I guess what there need to be is some sort of methodCall event. SO the following could work</p>
<pre><code>ScriptResource = function(scriptLocation)
{
this.onMethodCall = function(methodName)
{
this.call(arguments);
}
}
</code></pre>
<p>This code is obviously very incomplete but I hope it gives an idea of what I am trying to do</p>
<p>Is something like this even remotely possible? </p>
| [
{
"answer_id": 427735,
"author": "Rene Saarsoo",
"author_id": 15982,
"author_profile": "https://Stackoverflow.com/users/15982",
"pm_score": 0,
"selected": false,
"text": "var methods = [\"foo\", \"bar\", \"baz\"];\nfor (var i=0; i<methods.length; i++) {\n var method_name = methods[i];... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28882/"
] |
427,642 | <p>During our initial development we haven't worried about scaling concerns, just getting the bare bones of the system working as a cohesive whole.</p>
<p>We are now looking at refining screens where the quantity of records will become too large to be displayed. For example, we have page for displaying the details of a <code>Parent</code> which currently involves displaying all the <code>Child</code> records. This is done by calling the <code>Children</code> property on the <code>Parent</code> object (we are trying to develop a rich domain). We want to change this to be <code>RecentChildren</code>.</p>
<p>The problem is that I can't find a way to limit the records returned by an <code>EntitySet</code> in any way. You can do a query against the <code>EntitySet</code> but it retrieves all the <code>Children</code> from the database and then uses LINQ to Objects to filter it. Obviously this is very inefficient.</p>
<p>We could restructure the code to remove the mapping of the <code>Children</code> property and retrieve them from a service instead but we would like to keep the association in the domain if at all possible.</p>
<p>Is there any way round this or would we have to look at a different ORM such as NHibernate?</p>
| [
{
"answer_id": 427701,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 1,
"selected": false,
"text": "int id = parent.ParentID;\nvar qry = from child in db.Children\n where child.ParentID = id && child.Date > w... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6369/"
] |
427,648 | <p>In an HTML page, if I align some <code><div></code>s with "right: 0px", they all look very nice, as I expect. However, if I make the browser window smaller and the horizontal scroll bar appears, when I scroll the page to the right, I see an unexpected white space (instead of the background colors of my <code><div></code>s). It seems that my <code><div></code>s are aligned relative to the visible area of the page. See the sample code below:</p>
<pre><code><html>
<head>
<style>
<!--
#parent {
position: absolute;
left: 0px;
right: 0px;
top: 0px;
bottom: 0px;
background-color: yellow;
}
#child {
position: absolute;
left: 100px;
top: 300px;
width: 1000px;
height: 400px;
background-color: blue;
}
-->
</style>
</head>
<body>
<div id="parent"><div id="child">some text here</div></div>
</body>
</html>
</code></pre>
<p>Is there any way to make the "right: 0px" property align the controls relative to the size of the entire page, not only the visible area?</p>
<p>Thanks. </p>
| [
{
"answer_id": 427681,
"author": "meouw",
"author_id": 12161,
"author_profile": "https://Stackoverflow.com/users/12161",
"pm_score": 0,
"selected": false,
"text": "html{ border: 3px solid red }\n"
},
{
"answer_id": 427740,
"author": "Xn0vv3r",
"author_id": 42475,
"aut... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11384/"
] |
427,651 | <p>I'm planning a distributed system of applications that will communicate with different types of RDBMS. One of the requirements is consistent handling of DateTimes across all RDBMS types. All DateTime values must be at millisecond precision, include the TimeZone info and be stored in a single column.</p>
<p>Since different RDBMS's handle dates and times differently, I'm worried I can't rely on their native column types in this case and so I'll have to come up with a different solution. (If I'm wrong here, you're welcome to show me the way.)</p>
<p>The solution, whatever it may be, should ideally allow for easy sorting and comparisons on the SQL level. Other aspects, such as readability and ability to use SQL datetime functions, are not important, since this will all be handled by a gateway service.</p>
<p>I'm toying with an idea of storing my DateTime values in an unsigned largeint column type (8 bytes). I haven't made sure if all RDBMS's in question (MSSQL, Oracle, DB2, PostgreSQL, MySQL, maybe a few others) actually /have/ such a type, but at this point I just assume they do.</p>
<p>As for the storage format... For example, 2009-01-01T12:00:00.999+01:00 could be stored similar to ?20090101120000999??, which falls in under 8 bytes.</p>
<p>The minimum DateTime I'd be able to store this way would be 0001-01-01T00:00:00.000+xx:xx, and the maximum would be 8000-12-31T23:59:59.999+xx:xx, which gives me more than enough of a span.</p>
<p>Since maximum unsigned largeint value is 18446744073709551615, this leaves me with the following 3 digits (marked by A and BB) to store the TimeZone info: AxxxxxxxxxxxxxxxxxBB.</p>
<p>Taking into account the maximum year span of 0001..8000, A can be either 0 or 1, and BB can be anywhere from 00 to 99.</p>
<p>And now the questions:</p>
<ul>
<li><p>What do you think about my proposed solution? Does it have merit or is it just plain stupid?</p></li>
<li><p>If no better way exists, how do you propose the three remaining digits be used for TimeZone info best?</p></li>
</ul>
| [
{
"answer_id": 62184690,
"author": "Basil Bourque",
"author_id": 642706,
"author_profile": "https://Stackoverflow.com/users/642706",
"pm_score": 3,
"selected": true,
"text": "Continent/Region TIMESTAMP WITH TIME ZONE TIMESTAMP WITHOUT TIME ZONE DATE TIME TIME WITH TIME ZONE Z"
}
] | 2009/01/09 | [
"https://Stackoverflow.com/questions/427651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/82121/"
] |
427,652 | <p>I've got a django project that contain some apps. The main urls.py includes the urls.py from the apps I've enabled, and all is good.</p>
<p>Now I want to configure the project so that when you go to <a href="http://testsite/" rel="nofollow noreferrer">http://testsite/</a>, you'll get the same page that you get when you go to <a href="http://testsite/app/" rel="nofollow noreferrer">http://testsite/app/</a>.</p>
<p>I can do this by duplicating the corresponding line in the apps urls.py in the projects urls.py, but this feels dirty.</p>
<p>Anyone know a better way?</p>
| [
{
"answer_id": 427685,
"author": "bruno desthuilliers",
"author_id": 41316,
"author_profile": "https://Stackoverflow.com/users/41316",
"pm_score": 4,
"selected": true,
"text": "from django.conf.urls.defaults import patterns, url, include\nfrom django.views.generic.simple import redirect_... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11682/"
] |
427,653 | <p>I often find myself confused with how the terms 'arguments' and 'parameters' are used. They seem to be used interchangeably in the programming world.</p>
<p>What's the correct convention for their use?</p>
| [
{
"answer_id": 427657,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 9,
"selected": true,
"text": "void foo(int bar) { ... }\n\nfoo(baz);\n bar foo baz foo"
},
{
"answer_id": 427660,
"author": "Hank Gay",
"auth... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47036/"
] |
427,654 | <p>Is there any implementation of regex that allow to replace group in regex with lowercase version of it? </p>
| [
{
"answer_id": 427664,
"author": "Hank Gay",
"author_id": 4203,
"author_profile": "https://Stackoverflow.com/users/4203",
"pm_score": 2,
"selected": false,
"text": "$string =~ tr/[A-Z]/[a-z]/;\n"
},
{
"answer_id": 427709,
"author": "j_random_hacker",
"author_id": 47984,
... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
427,659 | <p>With the latest additions to our dependency injection framework (annotations in spring), the marginal cost of creating DI-managed components seems to have hit some critical new threshold. While there previously was an overhead associated with spring (tons of XML and additional indirections), dependency injection seems to have started going where lots of patterns go; they go under the hood and "disappear".</p>
<p>The consequence of this is that the conceptual overhead associated with a <a href="http://www4.java.no/web/show.do?page=205" rel="noreferrer"><em>large number</em></a> of components becomes acceptable. It's arguable that we could make a system where most classes only expose
one single public method and build the whole system by just aggregating these pieces like crazy. In our case a few things are given; the user interface of your application has some functional requirements that shape the topmost services. And the back-end systems control the lower part. But in between these two, everything is up for grabs.</p>
<p>Our constant discussion is really <em>why are we grouping things in classes</em> and <em>what should the principles be</em> ? A couple of things are certain; the facade pattern is dead and buried. Any service containing multiple unrelated features also tend to get split up. "Unrelated feature" is interpreted in an extremely much stricter sense than I have ever done earlier. </p>
<p>In our team there are two prevailing trains of thought here: Implementation dependencies restrict grouping; any functionality in a single class should preferably be a client of <em>all</em> injected dependencies. We are a DDD project and the other fraction thinks the domain restricts grouping (CustomerService or finer grained CustomerProductService, CustomerOrderService) - normalized usage of injected dependencies is unimportant.</p>
<p>So in the loosely coupled DI universe, why are we grouping logic in classes ? </p>
<p>edit: duffymo point out that this may be moving towards a functional style of programming; which brings up the issue of state. We have quite a few "State" objects that represent (small) pieces of relevant application state. We inject these into any service that has a legitimate need for this state. (The reason we use "State" objects instead of regular domain objects is that spring construct these at an unspecified time. I see this as a slight workaround or alternate solution to letting spring manage the actual creation of domain objects. There may be better solutions here).</p>
<p>So for instance any service that needs OrderSystemAccessControlState can just inject this, and the scope of this data is not readily known to the consumer. Some of the security-relate state is typically used at a lot of different levels but totally invisible on the levels in-between. I really think this violates fundamentally with functional principles. I even had a hard time adjusting to this concept form an OO perspective - but as long as the injected state is precise and strongly type then the <em>need</em> is legit aka the use case is proper.</p>
| [
{
"answer_id": 5290124,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "* The functionality embedded in a class, accessed through its methods,\n have little in common.\n* Methods carry out many va... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23691/"
] |
427,689 | <p>What I want to do is very simple but I'm trying to find the best or most elegant way to do this. The Rails application I'm building now will have a schedule of daily classes. For each class the fields relevant to this question are:</p>
<ul>
<li>Day of the week</li>
<li>Starting time</li>
<li>Ending time</li>
</ul>
<p>A single entry could be something such as:</p>
<ul>
<li>day of week: Wednesday</li>
<li>starting time: 10:00 am</li>
<li>ending time: Noon </li>
</ul>
<p>Also I must mention that it's a bi-lingual Rails 2.2 app and I'm using the native i18n Rails feature. I actually have several questions.</p>
<p>Regarding the day of the week, should I create an extra table with list of days, or is there a built-in way to create that list on the fly? Keep in mind these days of the week will have to be rendered in English or Spanish in the schedule view depending on the locale variable.</p>
<p>While querying the schedule I will need to group and order the results by weekday, from Monday to Sunday, and of course order the classes within each day by starting time.</p>
<p>Regarding the starting time and ending time of each class would you use datetime fields or integer fields? If the latter how would you implement this exactly?</p>
<p>Looking forward to read the different suggestions you guys will come up with.</p>
| [
{
"answer_id": 427813,
"author": "DanSingerman",
"author_id": 43965,
"author_profile": "https://Stackoverflow.com/users/43965",
"pm_score": 2,
"selected": false,
"text": "t.strftime('%A')\n daily_class.find(:all, :conditions => ['whatever'], :order => :starting_time)\n find_by_sql date_t... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19893/"
] |
427,693 | <p>For example: I'm on MS DOS, I have a source code in the folder C:\Documents and Settings\Programs. Can i make my source code use a program (for example gnuplot) that is in a random folder?</p>
| [
{
"answer_id": 427706,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 2,
"selected": false,
"text": "#ifndef DIRECTORYLIST_H_INCLUDED\n#define DIRECTORYLIST_H_INCLUDED\n#define BOOST_FILESYSTEM_NO_DEPRECATED\n\n#inclu... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52011/"
] |
427,697 | <p>I'm trying to open a password protected package in SQL Server BIDs and I keep getting the following error message each time I pu in the correct password: </p>
<p><code>Failed to remove package protection with error 0x80131940 "(null)"</code></p>
<p>This occurs in the <code>CPaqckage::LoadFromXML</code> method.</p>
<p>Any Ideas?</p>
| [
{
"answer_id": 9493451,
"author": "Gordo",
"author_id": 1238990,
"author_profile": "https://Stackoverflow.com/users/1238990",
"pm_score": 2,
"selected": false,
"text": "wrong password wrong password"
}
] | 2009/01/09 | [
"https://Stackoverflow.com/questions/427697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
427,717 | <p>I have a table that's generated by a normal PHP loop. What I want to do is create a form in the first column of each row that's hidden by default but appears when you click a toggle link in that row. </p>
<p>I can make a normal toggle-able div by creating a CSS id called hidden and setting <code>display: none;</code>. Unfortunately I can't keep creating divs with <code>id=hidden</code> that are automatically associated with the preceding link. </p>
<p>I am pretty inexperienced with both Javascript and CSS, so I've mostly tried to do this by patching together examples but I'm coming up empty. I've read in some places that you can't put divs inside of a table, so maybe I'm going about this all wrong. </p>
<p>Here's an example of what the code does and how I wish it worked, but of course it does not.</p>
<pre><code><script language="JavaScript" type="text/javascript">
function toggle(id) {
var state = document.getElementById(id).style.display;
if (state == 'block') {
document.getElementById(id).style.display = 'none';
} else {
document.getElementById(id).style.display = 'block';
}
}
</script>
<?php
while($array = mysql_fetch_array($sql))
{
?>
<tr>
<td>
<?php
echo $array['some_data'];
?>
<a href="#" onclick="toggle('hidden');">Toggle</a>
<div id="hidden"><?php echo $array['hidden_thing']; ?></div>
</td>
<td>
<?php echo $array['some_other_data']; ?>
</td>
</tr>
<?php
}
?>
</code></pre>
| [
{
"answer_id": 427731,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 2,
"selected": false,
"text": "this.nextSibling() function toggle(ctl) {\n var state = ctl.style.display;\n if (state == 'block') {\n ... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30098/"
] |
427,721 | <p>Does anyone have a suggestion for creating paragraph-type line spaces within a <code><li></code> tag that includes a hovered pop-up pseudo-class?</p>
<p>I have a <code><span></code> that pops up on <code>a:hover</code> and I want the text that pops up to be broken into 2 paragraphs. It works with <code><br></code> in FF but I want to do the right thing (now that I've discovered it's wrong!)...</p>
<p>html: </p>
<pre><code><div id="rightlist">
<ul>
<li><a href="">List item
<span>
words words words that are "paragraph" 1 of List item
<br><br>
different words that make up "paragraph" 2 of List item
</span></a></li>
</code></pre>
<p>css:</p>
<pre><code>#rightlist {
margin-top: 10px; margin-right: 5px; width: 387px ; height: 239px ;
background-color: #7EBB11 ;
display: table-cell;
z-index: 100 ;
float: right ;
}
#rightlist ul {
text-align: left;
margin: 0;
margin-top: 6px;
font-family: sans-serif;
font-size: 20px ;
color: black ;
}
#rightlist a
{
display: table-cell;
text-decoration: none; color: black;
background: #7EBB11 ;
}
/*appearance of the <a> item (but before the <span> tag) on hover*/
#rightlist a:hover {
color: white;
}
/*appearance of the spanned content within <a></a> tags when not hovered */
/* %%%%% important - keep position:absolute in this div %%%%% */
#rightlist a span {
display: none;
position: absolute ;
margin-left: -412px;
top: -10px; left: 10px; padding: 10px ;
z-index: 100;
width: 380px; height: 222px;
color: white; background-color: #7EBB11;
font: 0.75em Verdana, sans-serif; font-size: 13px ; color: black;
text-align: left;
}
/*appearance of spanned content within <a> tags when hovered*/
#rightlist a:hover span {
display: table-cell ;
}
</code></pre>
| [
{
"answer_id": 427738,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 1,
"selected": false,
"text": " <li><a href=\"\">List item\n <span>\n <span>words words words that are \"paragraph\" 1 of List item</span>\n ... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
427,725 | <p>I've got a function creating some XmlDocument:</p>
<pre><code>public string CreateOutputXmlString(ICollection<Field> fields)
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.Encoding = Encoding.GetEncoding("windows-1250");
StringBuilder builder = new StringBuilder();
XmlWriter writer = XmlWriter.Create(builder, settings);
writer.WriteStartDocument();
writer.WriteStartElement("data");
foreach (Field field in fields)
{
writer.WriteStartElement("item");
writer.WriteAttributeString("name", field.Id);
writer.WriteAttributeString("value", field.Value);
writer.WriteEndElement();
}
writer.WriteEndElement();
writer.Flush();
writer.Close();
return builder.ToString();
}
</code></pre>
<p>I set an encoding but after i create XmlWriter it does have utf-16 encoding. I know it's because strings (and StringBuilder i suppose) are encoded in utf-16 and you can't change it.<br>
So how can I easily create this xml with the encoding attribute set to "windows-1250"? it doesn't even have to be encoded in this encoding, it just has to have the specified attribute.</p>
<p>edit: it has to be in .Net 2.0 so any new framework elements cannot be used.</p>
| [
{
"answer_id": 427737,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 7,
"selected": true,
"text": "public sealed class StringWriterWithEncoding : StringWriter\n{\n private readonly Encoding encoding;\n\n public Str... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40872/"
] |
427,726 | <p>I am trying to show the current date in my JSP page using JSTL. below is the code I am using.</p>
<pre><code><jsp:useBean id="now" class="java.util.Date" scope="request" />
<fmt:formatDate value="${now}" pattern="MM.dd.yyyy" />
</code></pre>
<p>But the above code is not producing any results? Am I missing anything here or is there any better approach for this? I am using JSTL 1.1.</p>
| [
{
"answer_id": 1229988,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "scope=page"
}
] | 2009/01/09 | [
"https://Stackoverflow.com/questions/427726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42372/"
] |
427,728 | <p>I'm using the <strong><a href="http://nvelocity.sourceforge.net/" rel="nofollow noreferrer">NVelocity Templating engine</a></strong> to produce a <strong>fixed-length</strong> field output - you know the kind of thing:</p>
<pre><code>Field Start Pos Field Length Notes
---------- --------- ------------ ---------
Supplier 1 7 Leading Zeros
GRN 8 9 -
...
e.g.
>0001234 123A<
</code></pre>
<p>The problem is <strong>I'm trying to call String.PadRight() with the overload to specify the leading zero, and NVelocity is having none of it..</strong></p>
<p><strong>This works:</strong></p>
<pre><code>$Document.SupplierCode.PadRight(7)
</code></pre>
<p><strong>But this doesn't:</strong></p>
<pre><code>$Document.SupplierCode.PadRight(7,"0")
</code></pre>
<p><strong>I've tried:</strong></p>
<ul>
<li><p>Single Quotes (<code>'0'</code>)</p></li>
<li><p>Double Single-Quotes (<code>''0''</code>)</p></li>
<li><p>Double Quotes (<code>"0"</code>)</p></li>
<li><p>Double Double-Quotes (<code>""0""</code>)</p></li>
<li><p>Escaping the quotes for all of the above (<code>\"0\"</code>)</p></li>
<li><p>No Quotes!</p></li>
</ul>
<p>All I've found to work from is the <a href="http://nvelocity.sourceforge.net/" rel="nofollow noreferrer">NVelocity Homepage</a>, and the <a href="http://velocity.apache.org/engine/releases/velocity-1.5/vtl-reference-guide.html" rel="nofollow noreferrer">Velocity Templating Language Reference page</a>, niether are pointing me at a solution.</p>
<p>Sorry I'm unable to supply or point you somewhere where you can test out your ideas for yourself, but any suggestions you may have will be most welcome!</p>
<p>Thanks for your help ;o)</p>
| [
{
"answer_id": 427982,
"author": "Andrew",
"author_id": 5662,
"author_profile": "https://Stackoverflow.com/users/5662",
"pm_score": 1,
"selected": true,
"text": "Public ReadOnly Property SupplierCodeFormatted() As String\n Get\n Return Supplier.Code.PadLeft(7, \"0\")\n End G... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5662/"
] |
427,730 | <p>I have a RDLC report and I am displaying it on the Report Viewer Control in my front end application. I am able to view the report perfectly.</p>
<p>But the problem arises when I try to export the report to a PDF (using the built-in option).</p>
<p>I print the report in 3 pages whereas my client wants it to be in a single page. I can't figure out the reason for it as in my report viewer I see only one page but in a PDF there are 3 pages.</p>
<p>Can something be done about it so that I can control the size of the report?</p>
| [
{
"answer_id": 7749918,
"author": "user985595",
"author_id": 985595,
"author_profile": "https://Stackoverflow.com/users/985595",
"pm_score": 3,
"selected": false,
"text": " =iif(len(Fields!RepGroupName.Value) > 25, \"6pt\",\"8pt\")\n"
}
] | 2009/01/09 | [
"https://Stackoverflow.com/questions/427730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
427,736 | <p>I'm trying to make the following code smaller. Is this possible?</p>
<pre><code>select a.*
from table1 a
WHERE a."cola1" = 'valuea1'
UNION ALL
select a.*
from tablea1 a
inner join tablea2 b on a."cola2" = b."colb2"
WHERE a."cola1" = 'valuea2'
and b."colb3" = 'valueb3'
</code></pre>
<p>In effect I'm looking for records from table1 for value1 or value2, but for records matching value2 I want to apply 1 extra condition which involves a join to a 2nd table
Can this be done without a UNION clause?</p>
<p>A skeleton or what I'm trying to code is below....but it's not working naturally.</p>
<pre><code>select a.*
from table1 a
inner join table2 b on a."cola1" = b."COLb1"
WHERE a."cola2" IN ('valuea1','valuea2')
and
CASE
WHEN a."cola2" = 'valuea2' THEN b."colb1" = 'valueb3'
ELSE 1=1
END CASE
</code></pre>
| [
{
"answer_id": 427762,
"author": "Hosam Aly",
"author_id": 41283,
"author_profile": "https://Stackoverflow.com/users/41283",
"pm_score": 3,
"selected": false,
"text": "CASE select *\n from table1 a\n where a.cola1 = 'valuea1'\n or (a.cola1 = 'valuea2'\n and Exists(select 1\n ... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427736",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
427,744 | <p>In my application (Main form is TTntForm, C++Builder 2006):</p>
<pre><code>void __fastcall TForm1::Button1Click(TObject *Sender)
{
Caption=L"1st caption"; // This works.
Form1->Caption=L"2nd caption"; // But this doesn't work,
// Caption of the form remains "1st caption".
}
</code></pre>
<p>What might be the cause of this problem?</p>
<p><strong>Edited:</strong>
Thank you all for your answers. I found the bug. There was a twice form creation in project file:</p>
<pre><code>Application->CreateForm(__classid(TForm1), &Form1);
Application->CreateForm(__classid(TForm1), &Form1);
</code></pre>
| [
{
"answer_id": 427778,
"author": "Roddy",
"author_id": 1737,
"author_profile": "https://Stackoverflow.com/users/1737",
"pm_score": 2,
"selected": false,
"text": "if (this != Form1)\n ShowMessage(\"Whoops. Didn't expect that...\");\n Application->CreateForm(__classid(TForm1), &Form1);\... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38856/"
] |
427,746 | <p>I'm building a questionnaire mvc webapp, and i cant figure out how to pass an unknown number of arguments to the controller from the form.</p>
<p>My form is something like:</p>
<pre><code><% using (Html.BeginForm())
{ %>
<div id="Content">
<% foreach (var group in ViewData.Model.QuestionGroups)
{ %>
<div class="Group">
<%=group.Description %>
<% foreach (var question in group.Questions)
{%>
<div class="Question">
<div class="QuestionTitle">
<%=question.Title %>
</div>
<%=Html.Hidden("Id", question.ID) %>
<div class="QuestionText">
<%switch (question.TypeAsEnum)
{
case QuestionTypeEnum.Text:%>
<%=Html.TextBox("somename") %>
<% break;
case QuestionTypeEnum.Number:%>
<%=Html.TextBox("somename") %>
<% break;
case QuestionTypeEnum.PhoneNumber:%>
<%=Html.TextBox("somename")%>
<% break;
case QuestionTypeEnum.Email:%>
<%=Html.TextBox("somename")%>
<% break;
case QuestionTypeEnum.Date:%>
<%=Html.TextBox("somename")%>
<% break;
case QuestionTypeEnum.YesNo:%>
<%=Html.RadioButton("somename", true)%>
<%=Html.RadioButton("somename", false)%>
<% break;
case QuestionTypeEnum.Alternative:%>
<%=Html.DropDownList("somename", question.Answers)%>
<% break;
}%>
</div>
</div>
<% } %>
</div>
<% } %>
</div>
<div id="submittButton">
<%=Html.SubmitButton()%></div>
<% } %>
</code></pre>
<p>Now what i need in my controller is List< ResponseAnswer >,
where ResponseAnswer has the properties:</p>
<p>string questionID,
string AnswerText,
bool AnswerBool,
number AnswerNumber,
...</p>
<p>So how can i pass an unknown number of items containing questionID, AnswerType and Answer to the controller.
In webforms i solved this by rendering the form with repeaters instead of foreach, and then iterating through the question repeater checking the control id, each repeater item containing a hidden questionid element and a input with id=AnswerType.
But this will seriously break Separation of concern in mvc? </p>
<p>So is there any way of getting my controller to accept List< ResultAnswer > and somehow build this list without breaking soc, and if not, how do i pass the entire formresult back to the controller so i can do the iteration of the form data there instead of in the view.</p>
| [
{
"answer_id": 427785,
"author": "Garry Shutler",
"author_id": 6369,
"author_profile": "https://Stackoverflow.com/users/6369",
"pm_score": 3,
"selected": false,
"text": "public ActionResult MyAction(FormCollection form)\n form"
},
{
"answer_id": 427845,
"author": "Morph",
... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53293/"
] |
427,750 | <p>I've been a fan of EasyMock for many years now, and thanks to SO I came across references to PowerMock and it's ability to mock Constructors and static methods, both of which cause problems when retrofitting tests to a legacy codebase. </p>
<p>Obviously one of the huge benefits of unit testing (and TDD) is the way it leads to (forces?) a much cleaner design, and it seems to me that the introduction of PowerMock may detract from that. I would see this mostly manifesting itself as:</p>
<ol>
<li>Going back to initialising collaborators rather than injecting them</li>
<li>Using statics rather than making the method be owned by a collaborator</li>
</ol>
<p>In addition to this, something doesn't quite sit right with me about my code being bytecode manipulated for the test. I can't really give a concrete reason for this, just that it makes me feel a little uneasy as it's just for the test and not for production.</p>
<p>At my current gig we're really pushing for the unit tests as a way for people to improve their coding practices and it feels like introducing PowerMock into the equation may let people skip that step somewhat and so I'm loathe to start using it. Having said that, I can really see where making use of it can cut down on the amount of refactoring that needs to be done to <em>start</em> testing a class.</p>
<p>I guess my question is, what are peoples experiences of using PowerMock (or any other similar library) for these features, would you make use of them and how much overall do you want your tests influencing your design?</p>
| [
{
"answer_id": 1056229,
"author": "Rogério",
"author_id": 2326914,
"author_profile": "https://Stackoverflow.com/users/2326914",
"pm_score": 4,
"selected": false,
"text": "final final"
},
{
"answer_id": 39692358,
"author": "Nitin Labhishetty",
"author_id": 2136312,
"au... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51577/"
] |
427,755 | <p>Before asking question, let me explain the current setup:</p>
<p>I have an service interface, say Service, and one implementation, say ServiceImpl. This ServiceImpl uses some other services. All the services are loaded as bean by spring.</p>
<p>Now, I want to write junit test cases for the ServiceImpl. For the same, I use the applicationContext to get the Service bean and then call different methods on it to test them.</p>
<p>All looks fine for the public methods but how do I write test cases for private methods? Because we might not have the same private methods for different implementations?</p>
<p>Can anyone help me here on what should be preferred way of writing test cases?</p>
| [
{
"answer_id": 427937,
"author": "joel.neely",
"author_id": 3525,
"author_profile": "https://Stackoverflow.com/users/3525",
"pm_score": 3,
"selected": false,
"text": "CapitalAsset {\n Money getPurchaseCost();\n Money getCurrentValue();\n Date whenPurchased();\n ...\n}\n\nPeo... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4406/"
] |
427,756 | <p>Why are we not able to override an instance variable of a super class in a subclass? </p>
| [
{
"answer_id": 427795,
"author": "Markus Lausberg",
"author_id": 39062,
"author_profile": "https://Stackoverflow.com/users/39062",
"pm_score": 0,
"selected": false,
"text": "public class A {\n protected int mIndex;\n\n public void counter(){\n mIndex++;\n }\n\n}\n\npublic clas... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40933/"
] |
427,760 | <p>Why you would want to use a <code>switch</code> block over a series of <code>if</code> statements?</p>
<p><code>switch</code> statements seem to do the same thing but take longer to type.</p>
| [
{
"answer_id": 427792,
"author": "tddmonkey",
"author_id": 51577,
"author_profile": "https://Stackoverflow.com/users/51577",
"pm_score": 8,
"selected": true,
"text": "int value = // some value\nif (value == 1) {\n doThis();\n} else if (value == 2) {\n doThat();\n} else {\n doThe... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52381/"
] |
427,761 | <p>I've seen a class which is a class which is defined like this..</p>
<pre><code>class StringChild : public StringBase
{
public:
//some non-virtual functions
static StringChild* CreateMe(int size);
private:
unsigned char iBuf[1];
};
</code></pre>
<p>The static factory function has the following implementation..</p>
<pre><code>return new(malloc(__builtin_offsetof(StringChild ,iBuf[size]))) StringChild();
</code></pre>
<p>So as far as I understand it this function is using placement new to extend this class. </p>
<p>Is this safe only because there is only 1 member and it's allocated on the heap?</p>
| [
{
"answer_id": 427830,
"author": "jpalecek",
"author_id": 51831,
"author_profile": "https://Stackoverflow.com/users/51831",
"pm_score": 2,
"selected": false,
"text": "return new(malloc(__builtin_offsetof(StringChild ,iBuf[size]))) StringChild();\n obj->~StringChild();\nfree(obj);\n ::ope... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16177/"
] |
427,775 | <p>How can I have my Wix package to download the required .NET Framework when it's not yet installed in the client's machine? I already have the condition to check for the installed .NET version but I'm not sure how to have it downloaded and installed when not found.</p>
<p>ClickOnce does this automatically by checking the pre-requisites in the properties pages. I just need to have it done in Wix due to some other requirements.</p>
<p>Thanks!</p>
| [
{
"answer_id": 15526769,
"author": "Fetchez la vache",
"author_id": 786103,
"author_profile": "https://Stackoverflow.com/users/786103",
"pm_score": 3,
"selected": false,
"text": "<PackageGroupRef Id=\"NetFx40Web\"/>\n"
}
] | 2009/01/09 | [
"https://Stackoverflow.com/questions/427775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18413/"
] |
427,781 | <p>How would I retrieve all files from the repository, along with the folder structure, changed in a range of revisions, say from 1000-1920?</p>
| [
{
"answer_id": 427807,
"author": "JesperE",
"author_id": 13051,
"author_profile": "https://Stackoverflow.com/users/13051",
"pm_score": 4,
"selected": false,
"text": "svn log -r1000:1920 -q -v | grep \" M\" | sort -u\n svn log -r1000:1920 --xml > log1000-1920.xml\n"
},
{
"answer... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47437/"
] |
427,789 | <p>I work on a Flex app that loads external Flash resources created in CS3. I've just been reading about how I can use the Flex mx.managers.CursorManager class to change the mouse cursor explicitly. But what I'd ideally like to do is to set a mouse cursor property on some elements in the loaded Flash SWF, so as the cursor passes over this element the cursor automatically changes without me having to respond to mouse events.</p>
<p>Is it possible? Does Flash support this in DisplayObject or something?</p>
<p>It seems the Flash SWF is overriding me. Some objects automatically display the hand cursor with mouse-over, and I can't see a way to turn this off on a DisplayObject?</p>
| [
{
"answer_id": 428279,
"author": "Yaba",
"author_id": 7524,
"author_profile": "https://Stackoverflow.com/users/7524",
"pm_score": 2,
"selected": false,
"text": " <mx:VBox \n useHandCursor=\"true\"\n mouseChildren=\"false\"\n buttonMode=\"true\">\n"
}
] | 2009/01/09 | [
"https://Stackoverflow.com/questions/427789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13220/"
] |
427,796 | <p>What is the best way to approximate a cubic Bezier curve? Ideally I would want a function y(x) which would give the exact y value for any given x, but this would involve solving a cubic equation for every x value, which is too slow for my needs, and there may be numerical stability issues as well with this approach.</p>
<p>Would <a href="http://antigrain.com/research/adaptive_bezier/index.html" rel="noreferrer">this</a> be a good solution?</p>
| [
{
"answer_id": 431490,
"author": "Die in Sente",
"author_id": 40756,
"author_profile": "https://Stackoverflow.com/users/40756",
"pm_score": 4,
"selected": true,
"text": "u^^6 + q u^^3 == p^^3 /27 q u^^3 == p^^3 /27 p / 3u == (fabs(u) >= somesmallvalue) ? (p / u / 3.0) : cuberoot (q)\n"
... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50129/"
] |
427,799 | <p><b>Duplicate</b>: <a href="https://stackoverflow.com/questions/420275/">C# Accessing data in System.Object[]</a></p>
<hr>
<p>When I run the following code:</p>
<pre><code> foreach (object bar in list)
{
Console.WriteLine = bar;
}
</code></pre>
<p>I get the following output:</p>
<blockquote>
<p>System.Collections.DictionaryEntry</p>
<p>System.Collections.DictionaryEntry</p>
<p>System.Collections.DictionaryEntry</p>
<p>System.Collections.DictionaryEntry</p>
<p>System.Collections.DictionaryEntry</p>
<p>System.Collections.DictionaryEntry</p>
<p>System.Collections.DictionaryEntry</p>
</blockquote>
<p>But how do I write out the contents of each line above?</p>
| [
{
"answer_id": 427801,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "foreach (DictionaryEntry entry in list)\n{\n Console.WriteLine(\"{0}={1}\", entry.Key, entry.Value);\n}\n"
},
{
... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427799",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
427,821 | <p>I'm currently setting up a commercial SFTP server and I'm just looking for some of your opinions on the set-up I'm currently thinking of implementing, as well as a recommendation as to what commercial Secure FTP server software would be best to suit. Bear in mind that the data i'm responsible for is highly sensitive so any comments/feedback is much appreciated.</p>
<p>Here's the scenario:</p>
<p>1) Before file upload, files are compressed & encrypted using AES 256 with a salt.</p>
<p>2) Files uploaded from the clients' server over SFTP (port 22) to our SFTP server.</p>
<p>3) Files are then downloaded over HTTPS by our other client using one time password verification (strong 10 char alphanumeric password)</p>
<p>The specifics of the implementation I'm thinking of are:</p>
<p>For part (2) above, the connection is opened using host key matching, public key authentication and a user name/password combination. The firewall at both sides is restricted to only allow the static IP of the client server to connect.</p>
<p>For part (3), the other client is supplied with a user name/password on a per user basis (for auditing) to log into their jailed account on the server. the encryption password for the file itself is supplied on a per file basis, so i'm trying to apply two modes of encryption at all times here (except when the files are resting on the server).</p>
<p>Along with dedicated firewalls on both sides, Access control on the SFTP server will be configured to block IP addresses with a certain number of failed attempts over a short time, invalid passwords attempts will lock out users, password policies will be implemented etc.</p>
<p>I like to think that I've covered as much as possible but I'd love to hear what you guys think about this implementation?</p>
<p>For the commercial server side of things, I've narrowed it down to GloalSCAPE SFTP w/ SSH & HTTP module or JSCAPE Secure FTP server - I'll be assessing the suitability of each over the weekend but if any of you have any experience with either i'd love to hear about it also.</p>
| [
{
"answer_id": 427934,
"author": "frankodwyer",
"author_id": 42404,
"author_profile": "https://Stackoverflow.com/users/42404",
"pm_score": 1,
"selected": false,
"text": "Before file upload, files are compressed & encrypted using AES 256 with a salt.\n"
}
] | 2009/01/09 | [
"https://Stackoverflow.com/questions/427821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52063/"
] |
427,825 | <p>I want cscope to open files in MacVim instead of vim, so I'm trying to have the path to MacVim as the Value of the EDITOR environment variable which is used by cscope:</p>
<pre>$ export EDITOR=/Applications/MacVim.app/Contents/MacOS/MacVim</pre>
<p>If I'm now trying to edit a file from within ctags, it won't work and throws this error message:</p>
<pre>$ MacVim[8384:10b] No Info.plist file in application bundle or no NSPrincipalClass in the Info.plist file, exiting</pre>
<p>Calling MacVim from the commandline with</p>
<pre>$ /Applications/MacVim.app/Contents/MacOS/MacVim</pre>
<p>works, though.</p>
<p>How can I fix this?</p>
| [
{
"answer_id": 731251,
"author": "Nicholas Riley",
"author_id": 6372,
"author_profile": "https://Stackoverflow.com/users/6372",
"pm_score": 0,
"selected": false,
"text": "<plug> open % launch -ni com.apple.safari\n/Applications/Safari.app\n launch </plug>"
}
] | 2009/01/09 | [
"https://Stackoverflow.com/questions/427825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53305/"
] |
427,837 | <p>I have a problem with my web module classpath in Websphere v6.1. </p>
<p>In my WEB-INF/lib I have a largish number of jar files which include xercesImpl.jar and xmlparserv2.jar. I need both jars to be present, but they appear to confict with each other. Specifically, each jar contains a META-INF/services directory so, when we try to get an instance of a DocumentBuilderFactory via JAXP, which instance we get depends upon the order in which these two jars appear in the classpath.</p>
<p>I <b>always</b> want to use the xerces instance of the DocumentBuildFactory, so I want to push xercesImpl.jar to the front of the classpath. I've tried to do this by specifying a Class-Path section in the Manifest file for the war file, but the class path that I actually get in my WAS Module Compound CLass Loader in is very strange. I seem to get some standard stuff that WAS puts on, followed by the contents of WEB-INF lib in alphabetical order, followed by the classpath specified by the Manifest file.</p>
<p>If I don't put a manifest file into the war at all, I get the standard stuff followed by the contents of WEB-INF/lib but in an arbitrary order.</p>
<p>What am I missing? Is there a way in which I can set the class path up to be exactly what I want?</p>
<p>Dave</p>
| [
{
"answer_id": 2357538,
"author": "Ivan",
"author_id": 283777,
"author_profile": "https://Stackoverflow.com/users/283777",
"pm_score": 1,
"selected": false,
"text": "javax.xml.parsers.DocumentBuilderFactory D:\\books\\XMLJAVA>java -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xer... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53300/"
] |
427,850 | <p>Our Windows CE 5.0 application has a problem with our wildcard SSL certificate (*.domain.com) - it won't accept it as valid.</p>
<p>I understand that Windows Mobile 6.0 has support for wildcard certificates (earlier versions don't) and that is built on WinCE 5 which suggests it should be possible to change WinCE 5 to accept wildcard certificates (EDIT - apparently this shows my limited understanding of the environment and isn't a valid presumption!).</p>
<p>Can anyone suggest how we go about this? The change needs to be programmatic so that we can roll it out to hundreds of existing clients.</p>
<p>Help!</p>
| [
{
"answer_id": 430521,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "public class TrustAllCertificatePolicy : System.Net.ICertificatePolicy\n{\n public TrustAllCertificatePolicy()\n { }\n\n... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1456/"
] |
427,851 | <p>I have a table with the columns employee, address, city, state and zipcode. I have merged address, city, state, zipcode to a single column 'address' separating each field by comma. </p>
<p>My issue is, if one of the fields is null, an extra comma will be inserted. For example if <code>city</code> is null the resulting value will be like <code>address,,state,zipcode</code>. I need to remove this extra comma. How to do this? Please help.</p>
| [
{
"answer_id": 427860,
"author": "splattne",
"author_id": 6461,
"author_profile": "https://Stackoverflow.com/users/6461",
"pm_score": 4,
"selected": false,
"text": "case when ... = case when city is null then '' else city + ',' end\n UPDATE tableX SET address= replace(address, ',,'... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
427,853 | <p>In C, is there a difference between writing "struct foo" instead of just "foo" if foo is a struct?</p>
<p>For example:</p>
<pre><code>struct sockaddr_in sin;
struct sockaddr *sa;
// Are these two lines equivalent?
sa = (struct sockaddr*)&sin;
sa = (sockaddr*)&sin;
</code></pre>
<p>Thanks /Erik</p>
| [
{
"answer_id": 427863,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 5,
"selected": true,
"text": "struct typedef struct foo { ... } bar;\n bar struct foo"
},
{
"answer_id": 427865,
"author": "Avi",
"author_id"... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/276/"
] |
427,858 | <p>I'd like to create a list and be able to toggle the display of children items on click. Should be simple but i can't get it to work. Any thoughts?</p>
<pre><code><script>
$(document).ready(function(){
$("dt a").click(function(e){
$(e.target).children("dd").toggle();
});
});
</script>
<style>
dd{display:none;}
</style>
<pre>
<dl>
<dt><a href="/">jQuery</a></dt>
<dd>
<ul>
<li><a href="/src/">Download</a></li>
<li><a href="/docs/">Documentation</a></li>
<li><a href="/blog/">Blog</a></li>
</ul>
</dd>
<dt><a href="/discuss/">Community</a></dt>
<dd>
<ul>
<li><a href="/discuss/">Mailing List</a></li>
<li><a href="/tutorials/">Tutorials</a></li>
<li><a href="/demos/">Demos</a></li>
<li><a href="/plugins/">Plugins</a></li>
</ul>
</dd>
</dl>
</pre>
</code></pre>
| [
{
"answer_id": 427886,
"author": "Robin Minto",
"author_id": 1456,
"author_profile": "https://Stackoverflow.com/users/1456",
"pm_score": 0,
"selected": false,
"text": "$(document).ready(function() {\n $(\"dt a\").click(function(e) {\n $(e.target).parent().next().toggle();\n ... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
427,859 | <p>I have models (simplified example):</p>
<pre><code>class Group(models.Model):
name = models.CharField(max_length = 32)
class Person(models.Model):
group = models.ForeignKey(Group)
class Task(models.Model):
group = models.ForeignKey(Group)
people = models.ManyToManyField(Person)
def save(self, **kwargs):
ppl = Person.objects.all().filter(group = self.group)
for p in ppl:
self.people.add(p)
super(Task, self).save(**kwargs)
</code></pre>
<p>I want to assign the task to some group of people and add all persons who belong to that group as well, as some other people later (or remove particular person from the task). Obviously save won't be performed because object has no id when it wants to add many-to-many relationship objects. How to handle such situation? I tried saving just before adding people to task and then saving again but that didn't work.<br /><br />
regards<br />
chriss</p>
| [
{
"answer_id": 430136,
"author": "Daniel Naab",
"author_id": 32638,
"author_profile": "https://Stackoverflow.com/users/32638",
"pm_score": 1,
"selected": false,
"text": "class Person(models.Model):\n name = models.CharField(max_length=64)\n\nclass Group(models.Model):\n name = mode... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36832/"
] |
427,861 | <p>I'm trying to create a small and basic "ajax" based multiplayer game. Coordinates of objects are being given by a PHP "handler". This handler.php file is being polled every 200MS, by using ajax.</p>
<p>Since there is no need to poll when nothing happens, I wonder, is there something that could do the same thing without frequent polling? Eg. Comet, though I heard that you need to configure server side applications for Comet. It's a shared webserver, so I can't do that.</p>
<p>Maybe prevent the handler.php file from even returning a response if nothing has to be changed at the client, is that possible? Then again you'd still have the client uselessly asking for a response even though something hasn't changed yet. Basically, it should only use bandwidth and sever resources if something needs to be told to the client, eg. the change of an object's coordinates.</p>
| [
{
"answer_id": 428371,
"author": "hsivonen",
"author_id": 18721,
"author_profile": "https://Stackoverflow.com/users/18721",
"pm_score": 3,
"selected": false,
"text": "<eventsource> <eventsource> <event-source>"
}
] | 2009/01/09 | [
"https://Stackoverflow.com/questions/427861",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45974/"
] |
427,880 | <p>I am wrestling with a binding problem in WPF/Silverlight. I have a Listview witch is filled by a DataContext form an EF linq query. In the same usercontrol are textboxes. When changing their values, the listview gets refresht and the data is changed in de db bij .SaveChanges. The problem is that if I use a combobox the data is saved but de listview isn't updated.</p>
<p>Can you be of help????
Here is the xaml</p>
<pre><code> <ListView Grid.Row="1" Grid.Column="0" Margin="4,4,4,0" x:Name="controlsListBox" Grid.RowSpan="7" ItemsSource="{Binding}" SelectedValuePath="ID" LostFocus="controlsListBox_LostFocus">
<ListView.View>
<GridView>
<GridViewColumn Width="25" Header="Rw" DisplayMemberBinding="{Binding RowNr}"/>
<GridViewColumn Width="25" Header="Cl" DisplayMemberBinding="{Binding ColumnNr}"/>
<GridViewColumn Width="100" Header="Name" DisplayMemberBinding="{Binding Name}"/>
<GridViewColumn Width="25" Header="Tb" DisplayMemberBinding="{Binding TabIndex}"/>
<GridViewColumn Width="100" Header="Type" DisplayMemberBinding="{Binding ControlTypes.Name}"/>
<GridViewColumn Width="100" Header="Text" DisplayMemberBinding="{Binding TextResources.Text}"/>
</GridView>
</ListView.View>
</ListView>
<Label Grid.Row="2" Grid.Column="5" Height="23" Margin="4,4,4,0" x:Name="rowSpanLabel" VerticalAlignment="Top"
Content="RowNr"/>
<TextBox Grid.Row="2" Grid.Column="6" Height="23" Margin="4,4,4,0" x:Name="rowSpanTextBox" VerticalAlignment="Top"
Text="{Binding Path=SelectedItem.RowNr, ElementName=controlsListBox}"/>
<Label Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" Height="23" Margin="4,4,4,0" x:Name="controlTypeLabel" VerticalAlignment="Top"
Content="Type"/>
<ComboBox Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="5" Height="23" Margin="4,4,4,0" x:Name="controlTypeComboBox" VerticalAlignment="Top"
DataContext="{Binding Path=ControlTypes, ElementName=controlsListBox}" IsSynchronizedWithCurrentItem="True" DisplayMemberPath="Name"
SelectedItem="{Binding Path=SelectedItem.ControlTypes, ElementName=controlsListBox, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
/>
</code></pre>
<p>And here the C# code:
_controlProperties.Clear();
var data = (from x in _dataContext.ControlProperties
where x.FormProperties.ID == 1
orderby x.RowNr, x.ColumnNr, x.Name
select x);
foreach (var item in data)
{
item.TextResourcesReference.Load();
_controlProperties.Add(item);
}
// DataContext must first be set to null for good result.
controlsListBox.DataContext = null;
controlsListBox.DataContext = _controlProperties;</p>
<pre><code> controlTypeComboBox.DataContext = (from c in _dataContext.ControlTypes
orderby c.Name
select c).ToList();
</code></pre>
| [
{
"answer_id": 428371,
"author": "hsivonen",
"author_id": 18721,
"author_profile": "https://Stackoverflow.com/users/18721",
"pm_score": 3,
"selected": false,
"text": "<eventsource> <eventsource> <event-source>"
}
] | 2009/01/09 | [
"https://Stackoverflow.com/questions/427880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
427,887 | <p>Can I add new Silverlight 2.0 projects to my ASP.NET 2.0 web app and still target .NET Framework 2.0 in Visual Studio 2008?</p>
<p>ScottGu doesn't mention Silverlight <a href="http://weblogs.asp.net/scottgu/archive/2007/06/20/vs-2008-multi-targeting-support.aspx" rel="nofollow noreferrer">in his post on multi-targeting</a>.</p>
<p>Michael Scwartz's posts on <a href="http://weblogs.asp.net/mschwarz/archive/2007/06/04/silverlight-with-visual-studio-net-2005.aspx" rel="nofollow noreferrer">Silverlight with Visual Studio .NET 2005</a> and <a href="http://weblogs.asp.net/mschwarz/archive/2007/06/05/how-to-create-silverlight-applications-with-notepad.aspx" rel="nofollow noreferrer">How to create Silverlight Applications with Notepad</a> refer to VS2005 or to Silverlight 1.1 (i.e. pre-RTM).</p>
<p>Has anyone else tried this yet?</p>
<p><strong>[UPDATE]</strong></p>
<p>Now that I've upgraded the web project I started using the Silverlight control...</p>
| [
{
"answer_id": 428711,
"author": "Michael S. Scherotter",
"author_id": 27306,
"author_profile": "https://Stackoverflow.com/users/27306",
"pm_score": 1,
"selected": false,
"text": "<object width=\"300\" height=\"300\"\n data=\"data:application/x-silverlight,\" \n type=\"application/... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5351/"
] |
427,888 | <p><a href="http://msdn.microsoft.com/en-us/library/cc645984.aspx" rel="noreferrer">Here</a>, it is said that Sql Server Compact allows up to 256 connections.</p>
<p>But when I try to open 2 connections, I receive a file sharing error. How can I solve this?</p>
<pre><code>SqlCeConnection c1 = new SqlCeConnection("Data Source=testDB.sdf;Encrypt Database=True;Password=test;File Mode=shared read;Persist Security Info=False;");
SqlCeConnection c2 = new SqlCeConnection("Data Source=testDB.sdf;Encrypt Database=True;Password=test;File Mode=shared read;Persist Security Info=False;");
c1.Open();
c2.Open(); // throws SqlCeException
c1.Close();
c2.Close();
</code></pre>
<p><em>There is a file sharing violation. A different process might be using the file. [ testDB.sdf ]</em></p>
| [
{
"answer_id": 438485,
"author": "Serhat Ozgel",
"author_id": 31505,
"author_profile": "https://Stackoverflow.com/users/31505",
"pm_score": 4,
"selected": true,
"text": "File Mode=Read Write\n"
},
{
"answer_id": 15875553,
"author": "AechoLiu",
"author_id": 419348,
"au... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31505/"
] |
427,902 | <p>Building on what has been written in SO question <a href="https://stackoverflow.com/questions/70689/best-singleton-implementation-in-java">Best Singleton Implementation In Java</a> - namely about using an enum to create a singleton - what are the differences/pros/cons between (constructor omitted)</p>
<pre><code>public enum Elvis {
INSTANCE;
private int age;
public int getAge() {
return age;
}
}
</code></pre>
<p>and then calling <code>Elvis.INSTANCE.getAge()</code></p>
<p>and</p>
<pre><code>public enum Elvis {
INSTANCE;
private int age;
public static int getAge() {
return INSTANCE.age;
}
}
</code></pre>
<p>and then calling <code>Elvis.getAge()</code></p>
| [
{
"answer_id": 428146,
"author": "Nicolas",
"author_id": 1730,
"author_profile": "https://Stackoverflow.com/users/1730",
"pm_score": 6,
"selected": false,
"text": "public enum Elvis implements HasAge {\n INSTANCE;\n private int age;\n\n @Override\n public int getAge() {\n ... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427902",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3898/"
] |
427,909 | <p>I need to store the first byte of data read from the network stream as a string, so I can call it back later.</p>
<pre><code>prinf(" While 1
Dim tcpListener As New TcpListener(IPAddress.Any, 80) ' Listen to port given
Console.WriteLine("Waiting for connection...")
tcpListener.Start()
'Accept the pending client connection and return 'a TcpClient initialized for communication.
Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient()
Console.WriteLine("Connection accepted.")
' Get the stream
Dim networkStream As NetworkStream = tcpClient.GetStream()
' Read the stream into a byte array
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
' Return the data received from the client to the console.
Dim clientdata As String = Encoding.ASCII.GetString(bytes)
Console.WriteLine(("Client Sent: " + clientdata))
' Return the data received from the client to the console.
Dim responseString As String = "Hello"
'Dim chat_name As String = "Name"
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(responseString)
networkStream.Write(sendBytes, 0, sendBytes.Length)
Console.WriteLine(("Response: " + responseString))
tcpClient.Close() 'Close TcpListener and TcpClient
tcpListener.Stop()
End While");
</code></pre>
<p>Thats my server ^ everything works fine, but I need the 1st piece of data read to be stored, such as if I get "Name" it should be stored in an array</p>
<p>Thanks</p>
| [
{
"answer_id": 535739,
"author": "Jim Counts",
"author_id": 36737,
"author_profile": "https://Stackoverflow.com/users/36737",
"pm_score": 0,
"selected": false,
"text": "Dim strFirstByte as string = vbNullString\nWhile 1\n ' ... Your code ...\n\n Dim bytes(tcpClient.ReceiveBufferSize... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
427,954 | <p>I cannot figure out how to enable per-session instances for my WCF service while using HTTPS. (I'm not an ASP.NET expert but don't want to use ASP.NET session state if possible.) I am using .NET Framework 3.0.</p>
<p>I have arrived at the following contradiction and am hoping that someone can tell me where there is a flaw in the logic.</p>
<p>1) The service must be hosted on IIS 6 due to client mandate.</p>
<p>2) The service needs to maintain state between calls, including SqlConnection and SqlTransaction instances (ugly but necessary due to project constraints).</p>
<p>3) Therefore I need to use the wsHttpBinding.</p>
<p>4) The service needs to be able to access user authentication info from HttpContext.Current.User.Identity (e.g. using Windows security in IIS).</p>
<p>5) HTTPS is therefore required.</p>
<p>6) Transport-level security must therefore be configured on the binding.</p>
<p>7) Configuring the service to require sessions means I have to configure the wsHttpBinding to use Reliable Sessions.</p>
<p>8) This requires that message-level security is configured on the binding.</p>
<p>I.e. (6) and (8) are mutually exclusive.</p>
<p>It seems that using WCF sessions requires that I use message-level security, which prevents me from using HTTPS.</p>
<p>What am I missing?</p>
| [
{
"answer_id": 441095,
"author": "Enrico Campidoglio",
"author_id": 26396,
"author_profile": "https://Stackoverflow.com/users/26396",
"pm_score": 5,
"selected": true,
"text": "<system.serviceModel>\n <bindings>\n <wsHttpBinding>\n <binding name=\"SecurityEnabledWsHtt... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5816/"
] |
427,957 | <p>Although the <a href="http://en.wikipedia.org/wiki/Adobe_Flex" rel="nofollow noreferrer">Flex</a> command-line compiler (mxmlc) can compile <a href="http://en.wikipedia.org/wiki/MXML" rel="nofollow noreferrer">MXML</a>+<a href="http://en.wikipedia.org/wiki/ActionScript" rel="nofollow noreferrer">ActionScript</a> files into <a href="http://en.wikipedia.org/wiki/SWF" rel="nofollow noreferrer">SWFs</a>, I need specific insights into its capabilities, via the command-line switches.</p>
<ul>
<li>Configure which <strong>language</strong> you're writing in, <em>ActionScript 2 / 3</em></li>
<li>Configure which <strong><a href="http://en.wikipedia.org/wiki/Adobe_Flash_Player" rel="nofollow noreferrer">Flash Player</a></strong> version you're targetting, <em>7 / 8 / 9 / 10</em></li>
<li>Configure what <strong>frames</strong> of the movie, contain what ActionScript code.</li>
</ul>
<p>An <a href="http://disruption.ca/archives/actionscript-and-mxmlc/" rel="nofollow noreferrer">article covering Mxmlc</a>, an <a href="http://www.gamedev.net/reference/programming/features/flex/" rel="nofollow noreferrer">intro to the Flex SDK.</a></p>
| [
{
"answer_id": 429505,
"author": "Josh Tynjala",
"author_id": 10768,
"author_profile": "https://Stackoverflow.com/users/10768",
"pm_score": 2,
"selected": false,
"text": "-strict=false -as3=false -es=true\n"
}
] | 2009/01/09 | [
"https://Stackoverflow.com/questions/427957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41021/"
] |
427,960 | <p>I'm developing an user control that I need for a project, the control have around 13 rows, 7 columns of textboxes, comboboxes... everything on a form autoscrollable.
The problem is that in execution time when scrolling the content refreshing is very very slow.
Some idea?</p>
<p>Using a datagridview is not an option.</p>
<p>Edit:</p>
<p>I should be more specific, the 13 row controls are in the usercontrol.
I have changed the uc's doublebuferred property to true, I can't change the child controls because all them are standard text and comboboxes, so there isn't such property.
In the main form I'm creating around 7 of this usercontrols dynamically inside of an autoscrollable panel, the problem comes scrolling the panel, the refresh is extremely slow.
And yes, I neither can believe that the winforms could be so bad.</p>
<p>Regards.</p>
| [
{
"answer_id": 429505,
"author": "Josh Tynjala",
"author_id": 10768,
"author_profile": "https://Stackoverflow.com/users/10768",
"pm_score": 2,
"selected": false,
"text": "-strict=false -as3=false -es=true\n"
}
] | 2009/01/09 | [
"https://Stackoverflow.com/questions/427960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22672/"
] |
427,966 | <p>We have a bunch of VB6 apps at our company. We are trying to debug a random SQL timeout error and did a trace with SQL Server Profiler on the Audit Login event. We noticed that the connections were coming in as nonpooled. We use the SQLOLEDB provider with SQL Server 2000 & 2005. I searched the internet and everything I come across says that connections are pooled by default in the SQLOLEDB provider, but we are not seeing this. Below is the code we use to connect to the database. We really need to have these connections pooled because we think this may be the problem with our random timeout error. Could any one shine some light on why connection pooling isn't working and any way to make it work? Thanks.</p>
<pre><code>Dim cnn As New ADODB.Connection
cnn.ConnectionString = "Provider=SQLOLEDB;Data Source=xxx;Catalog=xxx;User ID=xxx Password=xxx;"
Call cnn.Open
Dim cmd As New ADODB.Command
Set cmd.ActiveConnection = cnn
cmd.CommandText = "SELECT * FROM [Table]"
Dim rs As New ADODB.RecordSet
Call rs.Open(cmd, , adOpenStatic, adLockOptimistic)
While Not rs.eof
'Do stuff
Call rs.MoveNext
Wend
'Close and Dispose connection here
</code></pre>
| [
{
"answer_id": 429404,
"author": "Marc Bernier",
"author_id": 23569,
"author_profile": "https://Stackoverflow.com/users/23569",
"pm_score": 0,
"selected": false,
"text": "Cnn.CursorLocation=ADODB.adUseServer\n adUseClient adUseServer Cnn.CommandTimeout=0\n open() CommandTimeout Recordset... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36383/"
] |
427,979 | <p>How to extract a text part by regexp in linux shell? Lets say, I have a file where in every line is an IP address, but on a different position. What is the simplest way to extract those IP addresses using common unix command-line tools?</p>
| [
{
"answer_id": 427985,
"author": "PolyThinker",
"author_id": 47707,
"author_profile": "https://Stackoverflow.com/users/47707",
"pm_score": 0,
"selected": false,
"text": "#!/usr/bin/perl -w\nuse strict;\n\nwhile (<>) {\n if (/(\\d+\\.\\d+\\.\\d+\\.\\d+)/) {\n print \"$1\\n\";\n ... | 2009/01/09 | [
"https://Stackoverflow.com/questions/427979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53319/"
] |
428,001 | <p>I have a Gridview in which i have two templatefields of dropdownlist. I bound them on runtime with same list item.</p>
<pre><code>li = new listitem ("1","1");
dl1.items.add(li);
dl2.items.add(li);
li = new listitem ("2","2");
dl1.items.add(li);
dl2.items.add(li);
li = new listitem ("3","3");
dl1.items.add(li);
dl2.items.add(li);
dl1.selectedvalue = "2";
dl2.selectedvalue = "3";
</code></pre>
<p>After executing above, dl1 & dl2 both show me "3" as selected value. Why?</p>
<p>I know the work around of using 2 different listitems while binding but i wanna know why the above happens?</p>
| [
{
"answer_id": 428008,
"author": "Ali Ersöz",
"author_id": 4215,
"author_profile": "https://Stackoverflow.com/users/4215",
"pm_score": 2,
"selected": false,
"text": "ListItem li1 = new ListItem(\"1\",\"1\");\ndl1.items.add(li1);\n\nListItem li2 = new ListItem(\"1\", \"1\");\ndl2.items.ad... | 2009/01/09 | [
"https://Stackoverflow.com/questions/428001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29515/"
] |
428,004 | <p>I get numerous "method redefined" warnings while running an application under Merb 0.9.3. Of course, I get this only when I run my script using the ruby -w option. Is there any way to get rid of the methods getting redefined (repeated loading of files) again and again?</p>
<p>Has this been resolved in Merb 1?</p>
| [
{
"answer_id": 428008,
"author": "Ali Ersöz",
"author_id": 4215,
"author_profile": "https://Stackoverflow.com/users/4215",
"pm_score": 2,
"selected": false,
"text": "ListItem li1 = new ListItem(\"1\",\"1\");\ndl1.items.add(li1);\n\nListItem li2 = new ListItem(\"1\", \"1\");\ndl2.items.ad... | 2009/01/09 | [
"https://Stackoverflow.com/questions/428004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33581/"
] |
428,012 | <p>When it comes to writing custom MySQL database-driven PHP session management for a VERY dynamic website, what is the best (fastest read/write access) structure for your session table?</p>
<p>Bad Example (Not Optimized):</p>
<pre>
CREATE TABLE `session` (
`session_id` VARCHAR(32) NOT NULL,
`session_data` TEXT NOT NULL,
`t_created` DATETIME NOT NULL,
`t_updated` DATETIME NOT NULL,
PRIMARY KEY (`session_id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
</pre>
<p>I assume that using the Memory Engine would be better/faster, but I'm not sure. I can't think of a good way to explain everything in English, so I've made a list of requirements/details that I think are important:</p>
<p>Details:</p>
<ul>
<li>Category: Optimization</li>
<li>Sub Category: MySQL Query Performance</li>
<li>Goal: Fastest Random Access Table Schema and Single Row Query</li>
<li>Common Uses: Custom Session Management, Temporary Storage</li>
<li>Operating System: *nix, more specifically: Centos 5+ (on x86_64)</li>
<li>Database: MySQL Version: 5+ (Community Version)</li>
</ul>
<p>Outcomes:</p>
<ul>
<li>SQL Query: Create Table</li>
<li>SQL Query: Select Single Row by Random Key (e.g. PHP session id)</li>
<li>SQL Query: Insert Single Row with Random Key (e.g. PHP session id)</li>
<li>SQL Query: Update Single Row by Random Key (e.g. session id)</li>
<li>SQL Query: Delete Multiple Rows by Timestamp (garbage collection, e.g. expired sessions)</li>
</ul>
<p>Expected Row Lifespan (e.g. session durations):</p>
<ul>
<li>30%: 0s-30s</li>
<li>20%: 30s-5m</li>
<li>30%: 5m-1h</li>
<li>20%: 1h-8h</li>
</ul>
<p>Expected Row Count (e.g. active sessions):</p>
<ul>
<li>Low: 128</li>
<li>Medium: 1024</li>
<li>High: 100000</li>
</ul>
<p>If anyone can think of a better way to phrase all this, please feel free to edit.</p>
| [
{
"answer_id": 430230,
"author": "Ry Biesemeyer",
"author_id": 53098,
"author_profile": "https://Stackoverflow.com/users/53098",
"pm_score": 2,
"selected": true,
"text": "CREATE TABLE session (\n id CHAR(32) NOT NULL,\n data BLOB NOT NULL,\n t_created TIMESTAMP NOT NULL DEFAULT CURREN... | 2009/01/09 | [
"https://Stackoverflow.com/questions/428012",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53303/"
] |
428,013 | <p>I've got a bunch of strings like:</p>
<pre><code>"Hello, here's a test colon&#58;. Here's a test semi-colon&#59;"
</code></pre>
<p>I would like to replace that with</p>
<pre><code>"Hello, here's a test colon:. Here's a test semi-colon;"
</code></pre>
<p>And so on for all <a href="http://www.w3schools.com/tags/ref_ascii.asp" rel="noreferrer">printable ASCII values</a>.</p>
<p>At present I'm using <a href="http://www.boost.org/doc/libs/1_37_0/libs/regex/doc/html/boost_regex/ref/regex_search.html" rel="noreferrer"><code>boost::regex_search</code></a> to match <code>&#(\d+);</code>, building up a string as I process each match in turn (including appending the substring containing no matches since the last match I found).</p>
<p>Can anyone think of a better way of doing it? I'm open to non-regex methods, but regex seemed a reasonably sensible approach in this case.</p>
<p>Thanks,</p>
<p>Dom</p>
| [
{
"answer_id": 428043,
"author": "PEZ",
"author_id": 44639,
"author_profile": "https://Stackoverflow.com/users/44639",
"pm_score": 2,
"selected": false,
"text": "s = \"Hello, here's a test colon:. Here's a test semi-colon;\"\nre.sub(r'&#(1?\\d\\d);', lambda match: chr(int(match.g... | 2009/01/09 | [
"https://Stackoverflow.com/questions/428013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20972/"
] |
428,021 | <p>While looking for a light-weight Scala development environment, I came upon an <a href="http://github.com/djspiewak/jedit-modes/tree/master/scala.xml" rel="noreferrer">Scala edit mode</a> for jEdit. I don't know how to put it to use, though. How does one put a new edit mode in jEdit?</p>
| [
{
"answer_id": 428155,
"author": "Daniel C. Sobral",
"author_id": 53013,
"author_profile": "https://Stackoverflow.com/users/53013",
"pm_score": 4,
"selected": true,
"text": "<?xml version=\"1.0\"?>\n<!DOCTYPE MODES SYSTEM \"catalog.dtd\">\n\n<MODES>\n\n<!-- Add lines like the following, ... | 2009/01/09 | [
"https://Stackoverflow.com/questions/428021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53013/"
] |
428,022 | <p>Are there any good CSS coding style/standards?</p>
| [
{
"answer_id": 428038,
"author": "Kezzer",
"author_id": 39693,
"author_profile": "https://Stackoverflow.com/users/39693",
"pm_score": 0,
"selected": false,
"text": "/* =div a comment about my div */\ndiv#mydiv {\n border:1px solid #000;\n}\n"
},
{
"answer_id": 428052,
"aut... | 2009/01/09 | [
"https://Stackoverflow.com/questions/428022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48625/"
] |
428,041 | <p>I am trying to turn a table 90 degrees: make columns rows. No PIVOT is allowed since PIVOT requires aggregate functions. </p>
<p>Example:
I have a table with the columns:<br>
ID int,<br>
ISO char(2),<br>
Text varchar(255). </p>
<p>So I have this:</p>
<pre>
ID ISO Text
-- --- ----
1 DE Auto
2 EN Car
</pre>
<p>I'd like to get the following:</p>
<pre>
ID EN DE
-- --- ----
1 Car Auto
</pre>
<p>How do you accomplish that?</p>
| [
{
"answer_id": 428244,
"author": "splattne",
"author_id": 6461,
"author_profile": "https://Stackoverflow.com/users/6461",
"pm_score": 0,
"selected": false,
"text": "declare @temp table ([ID] int, [de] varchar(255), [en] varchar(255)) -- add ISOs if necessary\n\nINSERT @temp \nSELECT dist... | 2009/01/09 | [
"https://Stackoverflow.com/questions/428041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53332/"
] |
428,065 | <p>When I say simple, I mean, within an expression, so that I can stick it in as a value in a hash without preparing it first. I'll post my solution but I'm looking for a better one that reminds me less of VB. :)</p>
| [
{
"answer_id": 428077,
"author": "Kev",
"author_id": 16777,
"author_profile": "https://Stackoverflow.com/users/16777",
"pm_score": 0,
"selected": false,
"text": "substr($s, 0, index($s, $/) > -1 ? index($s, $/) || () )\n"
},
{
"answer_id": 428115,
"author": "innaM",
"auth... | 2009/01/09 | [
"https://Stackoverflow.com/questions/428065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16777/"
] |
428,066 | <p>I'm wondering what the easiest/most elegant way of selecting attributes from join models in has_many :through associations is.</p>
<p>Lets say we have Items, Catalogs, and CatalogItems with the following Item class:</p>
<pre><code>class Item < ActiveRecord::Base
has_many :catalog_items
has_many :catalogs, :through => :catalog_items
end
</code></pre>
<p>Additionally, lets say that CatalogueItems has a position attribute and that there is only one CatalogueItem between any catalog and any item. </p>
<p>The most obvious but slightly frustrating way to retrieve the position attribute is:</p>
<pre><code>@item = Item.find(4)
@catalog = @item.catalogs.first
@cat_item = @item.catalog_items.first(:conditions => {:catalog_id => @catalog.id})
position = @cat_item.position
</code></pre>
<p>This is annoying because it seems that we should be able to do @item.catalogs.first.position since we have completely specified which position we want: the one that corresponds to the first of @item's catalogs. </p>
<p>The only way I've found to get this is:</p>
<pre><code>class Item < ActiveRecord::Base
has_many :catalog_items
has_many :catalogs, :through => :catalog_items, :select => "catalogue_items.position, catalogs.*"
end
</code></pre>
<p>Now I can do Item.catalogs.first.position. However, this seems like a bit of a hack - I'm adding an extra attribute onto a Catalog instance. It also opens up the possibility of trying to use a view in two different situations where I populate @catalogs with a Catalog.find or with a @item.catalogs. In one case, the position will be there, and in the other, it won't. </p>
<p>Does anyone have a good solution to this?</p>
<p>Thanks.</p>
| [
{
"answer_id": 428231,
"author": "Milan Novota",
"author_id": 26123,
"author_profile": "https://Stackoverflow.com/users/26123",
"pm_score": 0,
"selected": false,
"text": "# which is basically same as your \"frustrating way\" of doing it\n@item.catalog_items.find_by_catalogue_id(@item.cat... | 2009/01/09 | [
"https://Stackoverflow.com/questions/428066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52932/"
] |
428,068 | <pre><code>procedure matrixvector(n:integer);
var i,j:integer;
begin
for i<-1 to n do begin
B[i] = 0;
C[i] = 0;
for j<-1 to i do
B[i]<- B[i]+ A[i,j];
for j<-n down to i+1 do
C[i]<-C[i] + A[i,j]
end
end;
</code></pre>
| [
{
"answer_id": 71805214,
"author": "Deepthi Tabitha Bennet",
"author_id": 17112163,
"author_profile": "https://Stackoverflow.com/users/17112163",
"pm_score": 2,
"selected": false,
"text": "procedure matrixvector(n : integer);\nvar i, j : integer;\nbegin\n for i<-1 to n do begin // O... | 2009/01/09 | [
"https://Stackoverflow.com/questions/428068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.