qid int64 4 19.1M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
393,204 | <p>I have 2 classes, main and extended. I need to use main vars in extended class.</p>
<pre><code><?php
class Main {
public $vars = array();
}
$main = new Main;
$main->vars['key'] = 'value';
class Extended extends Main { }
$other = new Extended;
var_dump($other->vars);
?>
</code></pre>
<p>Who I can do it?</p>
<p>No valid for example:</p>
<pre><code><?php
class Extended extends Main {
function __construct ($main) {
foreach ($main as $k => $v) {
$this->$k = $v;
}
}
}
?>
</code></pre>
<p>I need some solution more transparent and efficient :)</p>
| [
{
"answer_id": 393207,
"author": "OIS",
"author_id": 36175,
"author_profile": "https://Stackoverflow.com/users/36175",
"pm_score": 3,
"selected": true,
"text": "<?php\nclass Config {\n protected $_vars = array();\n\n protected static $_instance;\n\n private function __construct(... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49114/"
] |
393,208 | <p>When I'm writing C - code I solely use an editor and gcc. I was wondering if anyone could suggest a good and simple tool that will find unused variables, function declarations and possibly make some optimisations.</p>
<p>Does anybody know a good tool?</p>
| [
{
"answer_id": 393330,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 6,
"selected": true,
"text": "--combine --help --help=optimizers --help=warnings -Wunused This switch lacks documentation\n-W... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43960/"
] |
393,212 | <p>It would seem natural to me that HTML would support this:</p>
<pre><code><div id="comment1">
<div id="helpText">...</div>
</div>
<div id="comment2">
<div id="helpText">...</div>
</div>
<div id="comment3">
<div id="helpText">...</div>
</div>
#comment1#helpText
#comment2#helpText
#comment3#helpText
</code></pre>
<p>But since HTML ids must be unique, I need to do this:</p>
<pre><code><div id="comment1">
<div id="helpText1">...</div>
</div>
<div id="comment2">
<div id="helpText2">...</div>
</div>
<div id="comment3">
<div id="helpText3">...</div>
</div>
#comment1#helpText1
#comment2#helpText2
#comment3#helpText3
</code></pre>
<p>This seems to be unnecessarily redundant, especially when I have multiple nested DIVs:</p>
<pre><code><div id="comment1">
<div id="header1">...</div>
<div id="introduction1">...</div>
<div id="helpText1">...</div>
<div id="footer1">...</div>
</div>
<div id="comment2">
<div id="header2">...</div>
<div id="introduction2">...</div>
<div id="helpText2">...</div>
<div id="footer2">...</div>
</div>
<div id="comment3">
<div id="header3">...</div>
<div id="introduction3">...</div>
<div id="helpText3">...</div>
<div id="footer3">...</div>
</div>
</code></pre>
<p>Can anyone give me some background as to why this is the case and perhaps some workarounds for getting HTML ids to work more along the lines of a namespace metaphor?</p>
| [
{
"answer_id": 393218,
"author": "strager",
"author_id": 39992,
"author_profile": "https://Stackoverflow.com/users/39992",
"pm_score": 5,
"selected": true,
"text": "class id id Class class /* CSS */\n#comment1 .header\n#comment3 .helpText\n\n<!-- (X)HTML -->\n<div id=\"comment1\">\n <... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] |
393,234 | <p>Does anybody have a good Ruby script for finding books (or other products) on Amazon using their API?</p>
| [
{
"answer_id": 393246,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 3,
"selected": false,
"text": "response = r.keyword_search\n('ruby programming', 'books')\n"
},
{
"answer_id": 394396,
"author": "Thibaut Barrère"... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6805/"
] |
393,241 | <p>I am continue to build two simple processes throwing class objects one to another (see my previous post) through simple (anonymous) pipes. Now I revealed for myself boost::serialization (thanks answered people) and have tried to make some class be serialized through ::WriteFile::ReadFile. So - what I am doing wrong?</p>
<hr>
<p>1) I created some class</p>
<pre><code> #pragma once
#include "wtypes.h"
#include <boost\archive\binary_oarchive.hpp>
#include <boost\archive\binary_iarchive.hpp>
#include <boost\serialization\binary_object.hpp>
class CTextContainer
{
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & m_sText;
ar & m_dwCRC;
ar & m_dwSize;
}
public:
CTextContainer() : m_dwCRC(0), m_dwSize(0)
{
ZeroMemory(m_sText, sizeof(m_sText));
m_dwSize = sizeof(*this);
}
CTextContainer(LPCTSTR sText) : m_dwCRC(0), m_dwSize(0)
{
ZeroMemory(m_sText, sizeof(m_sText));
wcsncpy_s(m_sText, 1024, sText, wcslen(sText));
m_dwSize = sizeof(*this);
}
virtual ~CTextContainer(){}
LPTSTR GetText() const{return (LPTSTR) m_sText;}
protected:
DWORD m_dwCRC;
DWORD m_dwSize;
TCHAR m_sText[1024];
}; //end of class
</code></pre>
<p>2) And now I am trying to read from this class into binary archive and to write its content to one end of pipe... </p>
<pre><code>boost::archive::binary_oarchive oa(ofs);
oa << tc;
::WriteFile(hPipe, &oa, dwRead, &dwWritten, NULL) == FALSE
</code></pre>
<p>It won't work in that way, right? So, how it will?</p>
<p>3) Same operation on other side?</p>
| [
{
"answer_id": 428422,
"author": "Tony",
"author_id": 34101,
"author_profile": "https://Stackoverflow.com/users/34101",
"pm_score": 0,
"selected": false,
"text": "std::ofstream ofs(\"filename\");\n{\n boost:archive::binary_oarchive oa(ofs);\n oa << tc;\n}\n\n// Set up your pipe and... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7003/"
] |
393,248 | <p>How could I go about keeping track of the number of times a word appears in a textfile? I would like to do this for every word.</p>
<p>For example, if the input is something like:</p>
<p>"the man said hi to the boy."</p>
<p>Each of "man said hi to boy" would have an occurrence of 1.</p>
<p>"the" would have an occurence of 2.</p>
<p>I was thinking of keeping a dictionary with word/occurrence pairs but I'm not sure how to implement this in C. A link to any similar or related problems with a solution would be great.</p>
<hr>
<p>EDIT: To avoid rolling out my own hash table I decided to learn how to use glib. Along the way I found an excellent tutorial which walks through a similar problem. <a href="http://bo.majewski.name/bluear/gnu/GLib/ch03s03.html" rel="nofollow noreferrer">http://bo.majewski.name/bluear/gnu/GLib/ch03s03.html</a></p>
<p>I am awestruck by the number of different approaches, and in particular the simplicity and elegance of the Ruby implementation.</p>
| [
{
"answer_id": 393266,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "#include <stdio.h>\n\nstruct LLNode\n{\n LLNode* Next; \n char* Word;\n int Count;\n};\n\nvoid PushWord(LLNo... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45620/"
] |
393,252 | <p>Here's what I've been trying to do, in a nutshell:</p>
<pre><code>class example <T extends Number>
{
private int function(T number)
{
int x = (int) number;
...
}
...
}
</code></pre>
<p>Basically, I'm trying to make it so that T is a number so I can convert it to an int inside that function. The problem is that I'm getting an "incovertible types" error, so I must be doing something wrong.</p>
| [
{
"answer_id": 393257,
"author": "Lawrence Dol",
"author_id": 8946,
"author_profile": "https://Stackoverflow.com/users/8946",
"pm_score": 1,
"selected": false,
"text": "x=number.intValue();\n"
},
{
"answer_id": 393258,
"author": "VonC",
"author_id": 6309,
"author_prof... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
393,276 | <p>I'm trying to implement a socket with a recv timeout of 1 Second: </p>
<pre><code>int sockfd;
struct sockaddr_in self;
struct sockaddr_in client_addr;
int addrlen=sizeof(client_addr);
ssize_t nBytes;
sockfd = socket(AF_INET, SOCK_STREAM, 0);
self.sin_family = AF_INET;
self.sin_port = htons(PORT);
self.sin_addr.s_addr = INADDR_ANY;
int on = 1;
setsockopt( sockfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on);
// 1 Sec Timeout
tv.tv_sec = 1;
tv.tv_usec = 0;
setsockopt( sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv);
bind(sockfd, (struct sockaddr*)&self, sizeof(self));
listen(sockfd, 20);
clientfd = accept(sockfd, (struct sockaddr*)&client_addr, &addrlen);
nBytes = recv(clientfd, buffer, MAXBUF-1, 0);
</code></pre>
<p>Without 'setsockopt( sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv);' the calls to accept and recv work, but recv blocks.</p>
<p>With 'setsockopt( sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv);' the call to accept produces the error 'Resource temporarily unavailable'.</p>
<p>Can somebody please tell me what is wrong with this approach?</p>
| [
{
"answer_id": 393287,
"author": "Jeff",
"author_id": 15797,
"author_profile": "https://Stackoverflow.com/users/15797",
"pm_score": 2,
"selected": false,
"text": "select FD_ZERO(&masterfds);\nFD_SET(sockfd,&masterfds);\nmemcpy(&readfds,&masterfds,sizeof(fd_set));\ntimeout.tv_sec = 2;\nti... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
393,286 | <p>This is what I'm trying to do:</p>
<pre><code>import java.lang.reflect.*;
class exampleOuter <T extends Number>
{
private exampleInner<T>[] elements;
public exampleOuter(Class<T> type, int size)
{
elements = (exampleInner<T>[]) Array.newInstance(type, size);
}
}
</code></pre>
<p>I was told that if I wanted to create generic arrays of type T, I should use </p>
<pre><code>elements = (T[]) Array.newInstance(type,size);
</code></pre>
<p>So I tried to extend that to my custom class and got a ClassCastException (Ljava.lang.Double; cannot be cast to L<em>mypackagename</em>.exampleInner; I'm declaring the class in main like this:</p>
<pre><code>exampleOuter<Double> test = new exampleOuter(Double.class,15);
</code></pre>
<p>I can declare the inner class just fine and I can also declare arrays that aren't generic of the innerClass, so I imagine it's something in the constructor of the outerClass. Any ideas?</p>
<p>EDIT:
I understand what the problem is. When I create a new instance of the array, I create an array of doubles, not of exampleInner. I think. If that's right, I need to find a way to create an array of exampleInner while passing just Double.class to the function.</p>
<p>EDIT 2:
I realize generic arrays are not typesafe, but I have to use them anyway because my teacher demands that we use them.</p>
<p>EDIT 3:
I was told that to use generic arrays I had to allocate them that way, and to do so I need reflections, I think. The compiler tells me the class is using unsafe or unchecked operations, but I have to use generic arrays and that's the way I know to do it. If there's a better way I'll change the code.</p>
| [
{
"answer_id": 393292,
"author": "Tom Hawtin - tackline",
"author_id": 4725,
"author_profile": "https://Stackoverflow.com/users/4725",
"pm_score": 0,
"selected": false,
"text": "T T[] exampleInner<T>[] T extends Number T[] Number[] exampleInner<T>[] exampleInner[]"
},
{
"answer_i... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
393,306 | <p>I am just getting started with NHibernate (for the 15th time it would seem) and am having the following problem.</p>
<p>The following table:</p>
<pre><code>Table Facility
Column FACILITY_ID integer
Column NAME varchar2(50)
Column MONTH varchar2(5)
</code></pre>
<p>For whatever reason, month is a string instead of a native Date type and looks like this:</p>
<pre><code>"200811" represents 11/01/2008
"200307" represents 07/01/2003
you get the idea
</code></pre>
<p>I would like to map it to the following class</p>
<pre><code>public class Facility {
int Id {get; set;}
string Name {get; set;}
DateTime Month {get; set;}
}
</code></pre>
<p>I would like to map the MONTH column to the Month property but don't quite know how to approach the situation. Obviously, I could have a protected property string MonthString and have the Month property Parse that column, but that seems icky. Is there a better solution?</p>
| [
{
"answer_id": 404488,
"author": "Matt Hinze",
"author_id": 2676,
"author_profile": "https://Stackoverflow.com/users/2676",
"pm_score": 0,
"selected": false,
"text": "IUserType"
}
] | 2008/12/26 | [
"https://Stackoverflow.com/questions/393306",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] |
393,316 | <p>Good evening; I am writing a bit of code that solves the following equation. </p>
<p>X is size of device
Y is quantity of device
A is the denominator
Z is the total diversified value</p>
<p>(X * Y)/A = Z</p>
<p>Here is the part I don't know how to accomplish. The value of A is found by the amount of Y. If Y is between 3 and 6 than A = .7, if Y is between 6 and 9 than A = .6; and so on. </p>
<p>What function should I use to accomplish the above?
Any help is greatly appreciated.</p>
<p>Regards,</p>
<p>Greg Rutledge</p>
| [
{
"answer_id": 393320,
"author": "Jules",
"author_id": 40078,
"author_profile": "https://Stackoverflow.com/users/40078",
"pm_score": 1,
"selected": false,
"text": "if(Y <= 3.0) A = ...; \nelse if(Y <= 6.0) A = 0.7; \nelse if(Y <= 9.0) A = 0.6;\n...\n"
},
{
"answer_id": 39333... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45151/"
] |
393,322 | <p>I do most of programming work on the Windows terminals in my university. However, my computer is a Mac and, for some reason, the javac command throws up an error when I use UserInput methods. Is there anything to install or an alternative command to use to make this compile properly?</p>
| [
{
"answer_id": 393320,
"author": "Jules",
"author_id": 40078,
"author_profile": "https://Stackoverflow.com/users/40078",
"pm_score": 1,
"selected": false,
"text": "if(Y <= 3.0) A = ...; \nelse if(Y <= 6.0) A = 0.7; \nelse if(Y <= 9.0) A = 0.6;\n...\n"
},
{
"answer_id": 39333... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49128/"
] |
393,346 | <p>In the Fibonacci sequence, I have seen conventional implementations which recursively call the same method twice:</p>
<pre><code>public void fibonacci(int i)
{
fibonacci(1) + fibonacci(2);
}
</code></pre>
<p>Now this method is not the exact copy of what I have seen or the right way of solving the problem, but I've seen the two methods added together like above. So the method isn't recursively called, but recursively called twice. What exactly happens when writing code like this in C#? Are the two methods run on seperate threads? What is happening under the hood?</p>
| [
{
"answer_id": 393350,
"author": "biozinc",
"author_id": 30698,
"author_profile": "https://Stackoverflow.com/users/30698",
"pm_score": 0,
"selected": false,
"text": "fibonacci(1) fibonacci(2)"
},
{
"answer_id": 393377,
"author": "Charlie Martin",
"author_id": 35092,
"... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32484/"
] |
393,363 | <p>I have some text with the following structure:</p>
<pre><code>Round 1
some multiline text ...
Round 2
some multiline text ...
...
Round N
some multiline text ...
</code></pre>
<p>I'd like to match rounds with their multiline text.</p>
<p>None of the expressions produces correct result:</p>
<p>(Round\s\d+)((?!Round).*?)</p>
<p>(Round\s\d+)(.*?)</p>
<p>Could someone help me?</p>
<p>Thank you in advance.</p>
| [
{
"answer_id": 393369,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 1,
"selected": false,
"text": ". s /(Round\\s\\d+)(.*?)(Round\\s\\d+|$)/s\n s"
},
{
"answer_id": 393456,
"author": "Alan Moore",
"author_... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
393,366 | <p>I created a Linked List, with insert, search and remove functions. I also created a iterator for it. Now, suppose I do this:</p>
<pre><code>myList<Integer> test = new myList();
test.insert(30);
test.insert(20);
test.insert(10);
myList.iterator it = test.search(20);
if(it.hasNext())
System.out.println(it.next());
</code></pre>
<p>And voila, it works (it prints the value of the element at the node, in this case 20). Now, if I do this:</p>
<pre><code>myList<Double> test = new myList();
test.insert(30.1);
test.insert(20.1);
test.insert(10.1);
myList.iterator it = test.search(20.1);
if(it.hasNext())
System.out.println(it.next());
</code></pre>
<p>It doesn't, because the iterator is pointing to null. Here is the implementation of the search function:</p>
<pre><code>public iterator search(T data)
{
no<T> temp = first;
while( (temp != null) && (temp.data != data) )
temp = temp.next;
return (new iterator(temp));
}
</code></pre>
<p>Here's how I know there's something fishy with the comparisons: If I change part of the above code like this:</p>
<pre><code>while( (temp != null) && (temp.data != data) )
System.out.println(temp.data + " " + data);
temp = temp.next;
</code></pre>
<p>I can see it printing the numbers in the list. It prints, at one point, "20.1 20.1" (for example). So how can I fix this? The function appears to be right, but it just seems as if Java isn't comparing the numbers correctly.</p>
<p>EDIT: wth, BigDecimal gave me the same kind of problem too.</p>
<p>EDIT 2: equals() worked, didn't realize something else was amiss. Sorry.</p>
| [
{
"answer_id": 393374,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 3,
"selected": true,
"text": ".equals() public iterator search(T data)\n{\n no<T> temp = first;\n while (!data.equals(temp.data)) {\n temp = ... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
393,376 | <p>Okay so I've read the documentation, and I'm not quite sure what the arguments being passed are. I'm looking at the the listed example request:</p>
<p><code>$facebook->api_client->profile_setFBML(NULL, 128009, 'profile', NULL, 'mobile_profile', 'profile_main');</code></p>
<p>and thinking, where are they getting these arguments and what do they do?</p>
<p>Anybody have an explanation?</p>
| [
{
"answer_id": 393382,
"author": "Toby Hede",
"author_id": 14971,
"author_profile": "https://Stackoverflow.com/users/14971",
"pm_score": 3,
"selected": true,
"text": "$facebook->api_client->profile_setFBML(session_key, uid, 'profile', 'profile_action', 'mobile_profile', 'profile_main');\... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36545/"
] |
393,378 | <p>I have a servlet S which handles callbacks from a 3rd party site. </p>
<p>The callback invocations happen in a specific order. Thus, I need to queue them. </p>
<p>I propose to use an in-memory queue like </p>
<pre><code>java.util.ConcurrentLinkedQueue
</code></pre>
<p>So the logic looks like this:</p>
<ul>
<li>Servlet S receives a callback & queues the received item into queue Q.</li>
<li>By this time, the thread that hosted an instance of servlet S would have terminated.</li>
<li>A consumer thread reads from Q and processes each one serially.</li>
</ul>
<p>As I understand it, each instance of Servlet S is executed in its own Thread.</p>
<p>How do I create a single Consumer Thread for the whole webapp (war) that will service a Queue ? Basically I need singleton instances of:</p>
<ol>
<li>Threadpool</li>
<li>ConcurrentLinkedQueue</li>
</ol>
| [
{
"answer_id": 393389,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 4,
"selected": true,
"text": "init() destroy() LinkedBlockingQueue"
},
{
"answer_id": 55790154,
"author": "Archimedes Trajano",
"author_id... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24457/"
] |
393,381 | <p>I'm upsizing an existing MS Access backend to SQL Server 2008 and, because we want to use <a href="http://msdn.microsoft.com/en-us/library/ms151329.aspx" rel="nofollow noreferrer">SQL Server Merge replication</a>, I'll have to change all current primary keys (currently standard autoincrement integers) to GUID.</p>
<p>So here are the questions:</p>
<ul>
<li>Any recommendation on doing the change of primary keys from integer to GUID?</li>
<li>Any recommendation on using and manipulating the GUID from code from within Access clients?</li>
<li>Which SQL Server GUID type should I use?</li>
</ul>
| [
{
"answer_id": 393522,
"author": "Philippe Grondier",
"author_id": 11436,
"author_profile": "https://Stackoverflow.com/users/11436",
"pm_score": 3,
"selected": true,
"text": "rowguid ? myForm.myControl\n?????\n\n? myForm.recordset.fields(\"myFieldName\")\n{000581EB-9CBF-418C-A2D9-5A7141A... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393381",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3811/"
] |
393,395 | <p>I've pretty much tried everything, but it seems impossible to use
expire_fragment from models? I know you're not supposed to and it's
non-MVC, but surely there much be some way to do it. </p>
<p>I created a module in lib/cache_helper.rb with all my expire helpers,
within each are just a bunch of expire_fragment calls. I have all my
cache sweepers setup under /app/sweepers and have an "include
CacheHelper" in my application controller so expiring cache within the
app when called via controllers works fine. </p>
<p>Then things is I have some external daemons and especially some
recurring cron tasks which call a rake task that calls a certain
method. This method does some processing and inputs entries into the
model, after which I need to expire cache. </p>
<p>What's the best way to do this as I can't specify cache sweeper within the model.
Straight up observers seem to be the best solution but then it
complains about expire_fragment being undefined etc etc, I've even
tried including the ActionController caching classes into the observer
but that didn't work. I'd love some ideas of how to create a solution
for this. Thanks. </p>
| [
{
"answer_id": 393425,
"author": "maurycy",
"author_id": 48541,
"author_profile": "https://Stackoverflow.com/users/48541",
"pm_score": 3,
"selected": false,
"text": " require 'action_controller/test_process'\n\n sweepers = [ApartmentSweeper]\n\n ActiveRecord::Base.observers = sweepers... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1609611/"
] |
393,406 | <p>What other caching frameworks are available for .NET besides the project codenamed Velocity. What are the ALT.NET options? </p>
| [
{
"answer_id": 393425,
"author": "maurycy",
"author_id": 48541,
"author_profile": "https://Stackoverflow.com/users/48541",
"pm_score": 3,
"selected": false,
"text": " require 'action_controller/test_process'\n\n sweepers = [ApartmentSweeper]\n\n ActiveRecord::Base.observers = sweepers... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] |
393,438 | <p>Lots of websites in the wild seem to abuse their visitors by automatically starting flash based advertisements / trailers and the like. What are the defenses modern browsers offer, for example,</p>
<ol>
<li>Disallow automatic playing for a specific URL / site/ domain</li>
<li>Disallow speaker use [flash does not allow this to be configured and I'm especially annoyed with speaker abuse]?</li>
</ol>
<p>Of course, removing flash altogether is not an option :)</p>
<p>Ideas?</p>
<p>Update:
A clarification: I visit the sites in question because they've useful content... but I don't care for them hogging my speaker... Bandwidth sacrifice I can live with...
IE does have a "Play sounds on web pages" option but it's not per page/site. I do need flash per se [for watching podcasts etc.].</p>
| [
{
"answer_id": 393710,
"author": "Rob Kam",
"author_id": 25093,
"author_profile": "https://Stackoverflow.com/users/25093",
"pm_score": 0,
"selected": false,
"text": "[HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Internet Explorer\\ActiveX Compatibility\\{D27CDB6E-AE6D-11CF-96B8-444553540000}... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393438",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28413/"
] |
393,479 | <p>So I have an array of records retreived from a database. The array is in the format;</p>
<pre><code>$rows[0]['id']=1;
$rows[0]['title']='Abc';
$rows[0]['time_left']=200;
$rows[1]['id']=2;
$rows[1]['title']='XYZ';
$rows[1]['time_left']=300;
//And so on upto 10-20 rows
</code></pre>
<p>What's the best way of transferring this array over to my javascript code? I'd like the javascript to be able to loop through all of the records, and using the 'id' attribute, update the div with that id with some information. </p>
<p>My javascript code is in an external .js file, but i'm able to execute php code in the HTML code of my page. So I could do something like this:</p>
<p><strong>In my_file.js:</strong></p>
<pre><code>var rows=New Array();
</code></pre>
<p><strong>In HTML code:</strong></p>
<pre><code><html>
<head>
<script type="text/javascript" src="js/my_file.js"></script>
<script type="text/javascript">
<? foreach ($rows as $row):?>
<? extract($row);?>
rows[<?=$id;?>]['title']="<?=$title;?>";
//And so on
<? endforeach;?>
</script>
</code></pre>
| [
{
"answer_id": 393497,
"author": "barfoon",
"author_id": 1390354,
"author_profile": "https://Stackoverflow.com/users/1390354",
"pm_score": 6,
"selected": true,
"text": "json_encode($data); <DIV>"
},
{
"answer_id": 393513,
"author": "barfoon",
"author_id": 1390354,
"au... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49153/"
] |
393,492 | <p>I'm interested in what tools and methods are used for diagnosing flaws in large scale functional programs. What tools are useful? My current understanding is that 'printf' debugging (e.g. add logging and redeploy) is what is typically used. </p>
<p>If you've done debugging of a functional system what was different about it then debugging a system built with an OO or procedural language?</p>
| [
{
"answer_id": 393585,
"author": "Norman Ramsey",
"author_id": 41661,
"author_profile": "https://Stackoverflow.com/users/41661",
"pm_score": 5,
"selected": true,
"text": "printf"
}
] | 2008/12/26 | [
"https://Stackoverflow.com/questions/393492",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3892/"
] |
393,495 | <p>I need to convert the unicode characters to ansi characters</p>
<pre><code>byte[] encode = Encoding.Convert(Encoding.Unicode, Encoding.Default, report);
</code></pre>
<p>I use this piece of code. While I am viewing this I found that extra ? character is added
in the first part</p>
<p>?FF EE 20 12</p>
| [
{
"answer_id": 648325,
"author": "bzlm",
"author_id": 7724,
"author_profile": "https://Stackoverflow.com/users/7724",
"pm_score": 1,
"selected": false,
"text": "EncoderReplacementFallback Encoding"
}
] | 2008/12/26 | [
"https://Stackoverflow.com/questions/393495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22162/"
] |
393,509 | <p>When is it appropriate to use CoTaskMemAlloc? Can someone give an example?</p>
| [
{
"answer_id": 393753,
"author": "Jason S",
"author_id": 44330,
"author_profile": "https://Stackoverflow.com/users/44330",
"pm_score": 5,
"selected": true,
"text": "CoTaskMemAlloc IMalloc SHGetMalloc CoGetMalloc CoTaskMemAlloc IMalloc malloc() malloc() new"
},
{
"answer_id": 5007... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36130/"
] |
393,529 | <p>When using Google Chrome, I receive the following error message:</p>
<p>Error:</p>
<pre><code>Uncaught SyntaxError: Unexpected token <
</code></pre>
<p>It occurs directly after my doctype declaration at the top of my HTML page</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
</code></pre>
<p>Any ideas what this JavaScript error message is? It only seems to occur with Google Chrome (works fine in Safari, Firfox and IE)</p>
| [
{
"answer_id": 393573,
"author": "orip",
"author_id": 37020,
"author_profile": "https://Stackoverflow.com/users/37020",
"pm_score": 1,
"selected": false,
"text": "text/html application/xhtml+xml"
},
{
"answer_id": 2342234,
"author": "Matthew O'Riordan",
"author_id": 13960... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
393,532 | <p>Using XAMPP 1.6.7 I installed the community version of Magento. But there seems to be a problem. I am getting the error message 'extension file "curl" is must be loaded'. In another computer, everything seems fine.</p>
<p>(the other computer)<br>
intel(R) Pentium(R) Dual CPU, E2140 @ 1.60Hz,<br>
1.60 GHz. 504 MB of RAM<br>
and XP professional 2002 sp2</p>
<p>My computer is less powerful (Inet Pentium 4 1.6 GHz. with sp2.)</p>
<p>Please help me, thanks.</p>
| [
{
"answer_id": 1021646,
"author": "pm.",
"author_id": 100382,
"author_profile": "https://Stackoverflow.com/users/100382",
"pm_score": 1,
"selected": false,
"text": ";extension=php_curl.dll\n extension=php_curl.dll\n ;"
},
{
"answer_id": 5945608,
"author": "Razibul Hassan",
... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
393,544 | <p>I am trying to write simple Visual Studio Add-In for code generation. In my solution explorer window there is a database connection an I want to get table names from this active connection.How can I do this?</p>
| [
{
"answer_id": 1021646,
"author": "pm.",
"author_id": 100382,
"author_profile": "https://Stackoverflow.com/users/100382",
"pm_score": 1,
"selected": false,
"text": ";extension=php_curl.dll\n extension=php_curl.dll\n ;"
},
{
"answer_id": 5945608,
"author": "Razibul Hassan",
... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36474/"
] |
393,554 | <p>I have a Python program that uses the "threading" module. Once every second, my program starts a new thread that fetches some data from the web, and stores this data to my hard drive. I would like to use sqlite3 to store these results, but I can't get it to work. The issue seems to be about the following line:</p>
<pre><code>conn = sqlite3.connect("mydatabase.db")
</code></pre>
<ul>
<li>If I put this line of code inside each thread, I get an OperationalError telling me that the database file is locked. I guess this means that another thread has mydatabase.db open through a sqlite3 connection and has locked it.</li>
<li>If I put this line of code in the main program and pass the connection object (conn) to each thread, I get a ProgrammingError, saying that SQLite objects created in a thread can only be used in that same thread.</li>
</ul>
<p>Previously I was storing all my results in CSV files, and did not have any of these file-locking issues. Hopefully this will be possible with sqlite. Any ideas?</p>
| [
{
"answer_id": 393737,
"author": "James Brady",
"author_id": 29903,
"author_profile": "https://Stackoverflow.com/users/29903",
"pm_score": 0,
"selected": false,
"text": "OperationalError"
},
{
"answer_id": 2578401,
"author": "Robert Krolik",
"author_id": 309201,
"auth... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38146/"
] |
393,556 | <p>I use a lot of lists and arrays but I have yet to come across a scenario in which the array list couldn't be used just as easily as, if not easier than, the linked list. I was hoping someone could give me some examples of when the linked list is notably better.</p>
| [
{
"answer_id": 37100403,
"author": "Emil Albert",
"author_id": 5992975,
"author_profile": "https://Stackoverflow.com/users/5992975",
"pm_score": 0,
"selected": false,
"text": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\n\nnamespace ConsoleApplication1\n{\... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33911/"
] |
393,595 | <p>I have a query like this - select * from tbl where ... and colname in (2,3,4) </p>
<p>When I prepare the query (... ' colname in (?)' ) using a PreparedStatement in Java, what setter method should I call to set these integers ? The integers are available in an int array and the size varies. If it matters, the database is MySQL and the column in question is of int type. </p>
| [
{
"answer_id": 393610,
"author": "Learning",
"author_id": 18275,
"author_profile": "https://Stackoverflow.com/users/18275",
"pm_score": 2,
"selected": false,
"text": "WHERE colname = ANY (?)\n"
}
] | 2008/12/26 | [
"https://Stackoverflow.com/questions/393595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27474/"
] |
393,603 | <p>How do I generate UML diagram based on existing classes in PHP?</p>
| [
{
"answer_id": 591527,
"author": "kguest",
"author_id": 71480,
"author_profile": "https://Stackoverflow.com/users/71480",
"pm_score": 5,
"selected": false,
"text": "$ pear install pear/php_uml $ pear install pear/php_uml-alpha $ phpuml -o project.xmi"
},
{
"answer_id": 8501445,
... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5742/"
] |
393,623 | <p>I'm using FCKEditor in that when "Browse Server" button is clicked the following error is thrown.</p>
<blockquote>
<p>The server didn't send back a proper
XML response. Please contact your
system administrator.</p>
<p>XML Request error: Not Found(404)</p>
<p>Requested URL:</p>
<p>/fckeditor/editor/filemanager/connectors/asp/connector.asp?Command=....</p>
</blockquote>
<p>I'm developing and testing my website on IIS7 with .NET.</p>
| [
{
"answer_id": 395474,
"author": "Zhaph - Ben Duguid",
"author_id": 33051,
"author_profile": "https://Stackoverflow.com/users/33051",
"pm_score": 2,
"selected": false,
"text": "// The following value defines which File Browser connector and Quick Upload\n// \"uploader\" to use. It is val... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35700/"
] |
393,627 | <p>The following snippet of code is used to find the PID of a user's terminal, by using ptree and grabbing the <strong>third</strong> PID from the results it returns. All terminal PID's are stored in a hash with the user's login as the key.</p>
<pre><code> ## If process is a TEMINAL.
## The command ptree is used to get the terminal's process ID.
## The user can then use this ID to peek the user's terminal.
if ($PID =~ /(\w+)\s+(\d+) .+basic/) {
$user = $1;
if (open(PTREE, "ptree $2 |")) {
while ($PTREE = <PTREE>) {
if ($PTREE =~ /(\d+)\s+-pksh-ksh/) {
$terminals{$user} = $terminals{$user} . " $1";
last;
}
next;
}
close(PTREE);
}
next;
}
</code></pre>
<p>Below is a sample ptree execution:</p>
<pre><code>ares./home_atenas/lmcgra> ptree 29064
485 /usr/lib/inet/inetd start
23054 /usr/sbin/in.telnetd
23131 -pksh-ksh
26107 -ksh
29058 -ksh
29064 /usr/ob/bin/basic s=61440 pgm=/usr/local/etc/logon -q -nr trans
412 sybsrvr
</code></pre>
<p>I'd like to know if there is a better way to code this. This is the part of the script that takes longest to run.</p>
<p>Note: this code, along with other snippets, are inside a loop and are executed a couple of times.</p>
| [
{
"answer_id": 393729,
"author": "JoelFan",
"author_id": 16012,
"author_profile": "https://Stackoverflow.com/users/16012",
"pm_score": 3,
"selected": false,
"text": "$terminals{$user} = $terminals{$user} . \" $1\";\n $terminals{$user} .= \" $1\";\n"
},
{
"answer_id": 393796,
... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15884/"
] |
393,633 | <p>I want to flip an imageView (left/right), but I can not find a UIView (or UIImageView) method to do that? any idea?</p>
<p>thanks!</p>
| [
{
"answer_id": 393645,
"author": "diclophis",
"author_id": 32678,
"author_profile": "https://Stackoverflow.com/users/32678",
"pm_score": 0,
"selected": false,
"text": "- (void)loadFlipsideViewController {\n\n FlipsideViewController *viewController = [[FlipsideViewController alloc] ini... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47936/"
] |
393,635 | <p>I wish to pass many small PNG files as base64 encoded URIs within an XML response, but there seems to be no way to make flex present these images. I was thinking of the data uri scheme, but it appears not to be supported.</p>
<h2>Proposed solutions</h2>
<ol>
<li>Use Loader.LoadBytes</li>
</ol>
<p>Tried it and it doesn't seem to work (none of the events are triggered).</p>
<pre><code><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="1276" height="849" creationComplete="drawImage()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.utils.Base64Decoder;
private function loaderCompleteHandler(event:Event):void {
Alert.show("loader done");
}
private function errorHandler(e:IOErrorEvent):void {
Alert.show("error" + e.toString());
}
public function drawImage() : void
{
var b64png : String = "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IAAAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1JREFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jqch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0vr4MkhoXe0rZigAAAABJRU5ErkJggg==";
var l : Loader = new Loader();
var decoder : Base64Decoder = new Base64Decoder();
decoder.decode(b64png);
var bytes : ByteArray = decoder.flush();
l.addEventListener(Event.COMPLETE, loaderCompleteHandler);
l.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
l.loadBytes(bytes);
}
]]>
</mx:Script>
<mx:Image x="10" y="10" width="155" height="118" id="image1"/>
</mx:Application>
</code></pre>
<p>Can someone please tell me what I did wrong?</p>
| [
{
"answer_id": 408647,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": -1,
"selected": false,
"text": " <?xml version=\"1.0\" encoding=\"utf-8\"?>\n<mx:Application xmlns:mx=\"http://www.adobe.com/2006/mxml\" layout=\"vertical... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11208/"
] |
393,637 | <p>I'm running a Django application. Had it under Apache + mod_python before, and it was all OK. Switched to Lighttpd + FastCGI. Now I randomly get the following exception (neither the place nor the time where it appears seem to be predictable). Since it's random, and it appears only after switching to FastCGI, I assume it has something to do with some settings.</p>
<p>Found a few results when googleing, but they seem to be related to setting maxrequests=1. However, I use the default, which is 0.</p>
<p>Any ideas where to look for?</p>
<p>PS. I'm using PostgreSQL. Might be related to that as well, since the exception appears when making a database query.</p>
<pre><code> File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 86, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.6/site-packages/django/contrib/admin/sites.py", line 140, in root
if not self.has_permission(request):
File "/usr/lib/python2.6/site-packages/django/contrib/admin/sites.py", line 99, in has_permission
return request.user.is_authenticated() and request.user.is_staff
File "/usr/lib/python2.6/site-packages/django/contrib/auth/middleware.py", line 5, in __get__
request._cached_user = get_user(request)
File "/usr/lib/python2.6/site-packages/django/contrib/auth/__init__.py", line 83, in get_user
user_id = request.session[SESSION_KEY]
File "/usr/lib/python2.6/site-packages/django/contrib/sessions/backends/base.py", line 46, in __getitem__
return self._session[key]
File "/usr/lib/python2.6/site-packages/django/contrib/sessions/backends/base.py", line 172, in _get_session
self._session_cache = self.load()
File "/usr/lib/python2.6/site-packages/django/contrib/sessions/backends/db.py", line 16, in load
expire_date__gt=datetime.datetime.now()
File "/usr/lib/python2.6/site-packages/django/db/models/manager.py", line 93, in get
return self.get_query_set().get(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 304, in get
num = len(clone)
File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 160, in __len__
self._result_cache = list(self.iterator())
File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 275, in iterator
for row in self.query.results_iter():
File "/usr/lib/python2.6/site-packages/django/db/models/sql/query.py", line 206, in results_iter
for rows in self.execute_sql(MULTI):
File "/usr/lib/python2.6/site-packages/django/db/models/sql/query.py", line 1734, in execute_sql
cursor.execute(sql, params)
OperationalError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
</code></pre>
| [
{
"answer_id": 1691350,
"author": "slav0nic",
"author_id": 2201031,
"author_profile": "https://Stackoverflow.com/users/2201031",
"pm_score": 0,
"selected": false,
"text": "SESSION_ENGINE = \"django.contrib.sessions.backends.cache\"\n"
},
{
"answer_id": 2503925,
"author": "hca... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5475/"
] |
393,639 | <p>MySQL column > sdate, edate ( its 2 column).</p>
<p>sdate is start date for project starting and edate is end date for project ending.</p>
<p>so i need to make search between them..</p>
<pre><code><strong>Search</strong><br />
<form method="post" action="search.php">
Start Report Date : <input type="text" name="sdate" />
End Report Date : <input type="text" name="edate" />
<input type="submit" name="Submit" value="Search" />
</form>
This is example data in mysql
sdate Project Name edate
22 December 2008 project 1 23 December 2008
25 December 2008 project 2 26 December 2008
24 December 2008 project 3 27 December 2008
1 January 2008 project 4 20 January 2008
10 December 2008 project 5 12 December 2008
</code></pre>
<p>so let say a user entered sdate ( eg, 22 December 2008 ) and edate ( eg, 30 December 2008 ).</p>
<p>It should display</p>
<pre><code>22 December 2008 project 1 23 December 2008
25 December 2008 project 2 26 December 2008
24 December 2008 project 3 27 December 2008
</code></pre>
<p>So i need a php code sql query which should display entries lies between those 2 dates..</p>
<p>Please help me.. </p>
<p>Thanks very much..</p>
| [
{
"answer_id": 393650,
"author": "Assaf Lavie",
"author_id": 11208,
"author_profile": "https://Stackoverflow.com/users/11208",
"pm_score": 0,
"selected": false,
"text": "select sdate, name, edate \nfrom your_table \nwhere sdate >= '22 December 2008' and edate <= '30 December 2008'\n"
}... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
393,644 | <p>I've got a table of student information in MySQL that looks like this (simplified):</p>
<pre><code>| age : int | city : text | name : text |
-----------------------------------------------------
| | | |
</code></pre>
<p>I wish to select all student names and ages within a given city, and also, per student, how many other students in his age group (that is, how many students share his age value).</p>
<p>I managed to do this with a sub-query; something like:</p>
<pre><code>select
name,
age as a,
(select
count(age)
from
tbl_students
where
age == a)
from
tbl_students
where
city = 'ny'
</code></pre>
<p>But it seems a bit slow, and I'm no SQL-wiz, so I figure I'd ask if there's a smarter way of doing this. The table is indexed by age and city.</p>
| [
{
"answer_id": 393648,
"author": "Frans Bouma",
"author_id": 44991,
"author_profile": "https://Stackoverflow.com/users/44991",
"pm_score": 4,
"selected": true,
"text": "select \n t1.name, \n t1.age as a, \n count(t2.age) NumberSameAge\nfrom \n tbl_students t1 inner join tbl_st... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11208/"
] |
393,647 | <p>I need to send a CSV file in HTTP response. How can I set the output response as CSV format?</p>
<p>This is not working:</p>
<pre><code>Response.ContentType = "application/CSV";
</code></pre>
| [
{
"answer_id": 393651,
"author": "ibz",
"author_id": 5475,
"author_profile": "https://Stackoverflow.com/users/5475",
"pm_score": 6,
"selected": false,
"text": "text/csv"
},
{
"answer_id": 393696,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": "https:... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22162/"
] |
393,654 | <p>Consider that i have connected to multiple shares of a remote machine( \\machineA\share1, \\machineA\share2....) along with shares on other remote machines.</p>
<p>Now my question is how to find only those shares which are connected to a particular machine. For eg, only those shares which are connected to machineA.</p>
<p>I already came across WNetOpenEnum and WNetEnumResource. But these are highly inefficient that they will return all shares which are connected to my machine and then i will have to search through the results for the shares connected to machineA:(</p>
<p>I need to know if there is some other function, using which i can find the share.</p>
<p>I am working on VC++ 6.0.</p>
<p><strong><em>edit:</em></strong> Hey guys having another trouble. Whenever i try to connect to a share on the machine i get the following error:
<strong>"The referenced account is currently locked out and may not be logged on to"</strong>
Has anyone encountered this problem and how was it solved</p>
| [
{
"answer_id": 394259,
"author": "tsilb",
"author_id": 11112,
"author_profile": "https://Stackoverflow.com/users/11112",
"pm_score": 0,
"selected": false,
"text": "foreach (string systemName in systemNames)\n System.IO.Directory.GetDirectories(\"\\\\\"+systemName+\"\\\");\n"
}
] | 2008/12/26 | [
"https://Stackoverflow.com/questions/393654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41518/"
] |
393,661 | <p>.NET XSLT engine allows passing objects to the XSLT processing engine through the AddExtensionObject method.</p>
<p>Can someone comment on the performance of using this to retrieve localized strings to be used in the XSLT?</p>
| [
{
"answer_id": 393702,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "XslCompiledTransform <script>"
},
{
"answer_id": 394277,
"author": "Dimitre Novatchev",
"author_id": ... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40498/"
] |
393,662 | <p>This question has spawned out of this <a href="https://stackoverflow.com/questions/393151/whats-the-easiest-way-to-create-an-array-of-structs">one.</a> Working with lists of structs in cocoa is not simple. Either use NSArray and encode/decode, or use a C type array and lose the commodities of NSArray. Structs are supposed to be simple, but when a list is needed, one would tend to build a class instead.</p>
<p>When does using lists of structs make sense in cocoa?</p>
<p>I know there are already many questions regarding structs vs classes, and I've read users argue that it's the same answer for every language, but at least cocoa should have its own specific answers to this, if only because of KVC or bindings (as Peter suggested on the first question).</p>
| [
{
"answer_id": 414033,
"author": "wisequark",
"author_id": 33159,
"author_profile": "https://Stackoverflow.com/users/33159",
"pm_score": 1,
"selected": false,
"text": "NSPoint"
},
{
"answer_id": 449843,
"author": "robottobor",
"author_id": 10184,
"author_profile": "ht... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36182/"
] |
393,669 | <p>Is there a way to disable or override the excel and pdf export function in SQL Server Reporting Services. I want to my own custom excel export.</p>
| [
{
"answer_id": 8472053,
"author": "vishal parate",
"author_id": 1093392,
"author_profile": "https://Stackoverflow.com/users/1093392",
"pm_score": 0,
"selected": false,
"text": "RSReportDesigner.config visible = false"
}
] | 2008/12/26 | [
"https://Stackoverflow.com/questions/393669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1688440/"
] |
393,675 | <p>When I am making methods with return values, I usually try and set things up so that there is never a case when the method is called in such a way that it would have to return some default value. When I started I would often write methods that did something, and would either return what they did or, if they failed to do anything, would return null. But I hate having ugly <code>if(!null)</code> statements all over my code,</p>
<p>I'm reading a re-guide to ruby that I read many moons ago, by the pragmatic programmers, and I notice that they often return <code>self</code> (ruby's <code>this</code>) when they wouldn't normally return anything. This is, they say, in order to be able to chain method calls, as in this example using setters that return the object whose attributes they set.</p>
<pre><code>tree.setColor(green).setDecor(gaudy).setPractical(false)
</code></pre>
<p>Initially I find this sort of thing attractive. There have been a couple of times when I have rejoiced at being able to chain method calls, like <code>Player.getHand().getSize()</code> but this is somewhat different in that the object of the method call changes from step to step. </p>
<p>What does Stack Overflow think about return values? Are there any patterns or idioms that come to mind warmly when you think of return values? Any great ways to avoid frustration and increase beauty?</p>
| [
{
"answer_id": 393692,
"author": "Jules",
"author_id": 40078,
"author_profile": "https://Stackoverflow.com/users/40078",
"pm_score": 0,
"selected": false,
"text": "tree color: green;\n decor: gaudy;\n practical: false.\n"
},
{
"answer_id": 393693,
"author": "mstrobl",... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29182/"
] |
393,678 | <p>I'm storing a simple java.util.date in an Oracle XE database via hibernate.</p>
<p>When testing with JUnit if I can retrieve the correct value, I get an error like this:</p>
<pre><code>junit.framework.AssertionFailedError:
expected:<Sun Dec 28 11:20:27 CET 2008>
but was:<2008-12-28 11:20:27.0>
</code></pre>
<p>The value is stored in an Oracle Date column (which should have a second-precision) which looks okay to me. Also, I'm surprised that 11:20:27 is not equal to 11:20:27.0. Or does this have to do with timezones?</p>
<p>Any help is welcome.</p>
<p>Thorsten</p>
| [
{
"answer_id": 394089,
"author": "davetron5000",
"author_id": 3029,
"author_profile": "https://Stackoverflow.com/users/3029",
"pm_score": 0,
"selected": false,
"text": "java.util.Date java.sql.Date equals(Object) java.util.Date.getTime()"
}
] | 2008/12/26 | [
"https://Stackoverflow.com/questions/393678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25320/"
] |
393,679 | <pre><code> MERGE INTO PAGEEDITCONTROL A
USING (SELECT
'1585' AS PAGEID
,'admin' AS EDITUSER
,sysdate AS EDITDATE
FROM DUAL) B
ON (A.PAGEID = B.PAGEID)
WHEN MATCHED THEN
UPDATE SET
A.EDITUSER = B.EDITUSER
,A.EDITDATE = B.EDITDATE
WHEN NOT MATCHED THEN
INSERT (
A.PAGEID
,A.EDITUSER
,A.EDITDATE
)VALUES(
B.PAGEID
,B.EDITUSER
,B.EDITDATE
)
</code></pre>
| [
{
"answer_id": 394992,
"author": "Henning",
"author_id": 7034,
"author_profile": "https://Stackoverflow.com/users/7034",
"pm_score": 1,
"selected": false,
"text": "INSERT ... ON DUPLICATE KEY UPDATE"
},
{
"answer_id": 15875387,
"author": "laksys",
"author_id": 978136,
... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
393,681 | <p>I have a situation where i need to debug a Windows CE application in both Vs.NET 2008 as well as VS.NET 2005.</p>
<p>After I switch between the emulators in these 2 environments a few times, i get the error:</p>
<blockquote>
<p>A fatal error has occurred and debugging needs to be terminated. HRESULT=0x8013110e. Error code=0x0.</p>
</blockquote>
<p>Why should it happen only after switching back and forth? The task manager shows sufficient memory and I am not able to debug this.</p>
<p>What could be the problem ?</p>
<p>Regards,
Chak</p>
| [
{
"answer_id": 394992,
"author": "Henning",
"author_id": 7034,
"author_profile": "https://Stackoverflow.com/users/7034",
"pm_score": 1,
"selected": false,
"text": "INSERT ... ON DUPLICATE KEY UPDATE"
},
{
"answer_id": 15875387,
"author": "laksys",
"author_id": 978136,
... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49189/"
] |
393,686 | <p>I was wondering how can I change currency format from US ($) to EURO (€) for a specific TextBox in Microsoft ReportViewer? </p>
<p>Because it always displays a dollar sign in front and the format is ##,###.## and as for euro it must be like ##.###,##</p>
| [
{
"answer_id": 18227804,
"author": "Mark",
"author_id": 1135965,
"author_profile": "https://Stackoverflow.com/users/1135965",
"pm_score": 2,
"selected": false,
"text": "<Language>en-gb</Language>\n <Report xmlns:rd=\"http://schemas.microsoft.com/SQLServer/reporting/reportdesigner\" xmlns... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22637/"
] |
393,687 | <p>I would like to add attributes to Linq 2 Sql classes properties. Such as this Column is browsable in the UI or ReadOnly in the UI and so far.</p>
<p>I've thought about using templates, anybody knows how to use it? or something different?</p>
<p>Generally speaking, would do you do to address this issue with classes being code-generated?</p>
| [
{
"answer_id": 393695,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 1,
"selected": false,
"text": "TypeDescriptionProvider PropertyDescriptor PropertyGrid DataGridView PropertyGrid TypeConverter TypeDescriptionProvid... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11659/"
] |
393,701 | <p>Suppose we have following type:</p>
<pre><code>struct MyNullable<T> where T : struct
{
T Value;
public bool HasValue;
public MyNullable(T value)
{
this.Value = value;
this.HasValue = true;
}
public static implicit operator T(MyNullable<T> value)
{
return value.HasValue ? value.Value : default(T);
}
}
</code></pre>
<p>And try to compile following code snippet:</p>
<pre><code>MyNullable<int> i1 = new MyNullable<int>(1);
MyNullable<int> i2 = new MyNullable<int>(2);
int i = i1 + i2;
</code></pre>
<p>This snipped compiled well and without errors. i1 and i2 casts to integer and addition evaluated.</p>
<p>But if we have following type:</p>
<pre><code>struct Money
{
double Amount;
CurrencyCodes Currency; /*enum CurrencyCode { ... } */
public Money(double amount, CurrencyCodes currency)
{
Amount = amount;
Currency = currency;
}
public static Money operator + (Money x, Money y)
{
if (x.Currency != y.Currency)
// Suppose we implemented method ConvertTo
y = y.ConvertTo(x.Currency);
return new Money(x.Amount + y.Amount, x.Currency);
}
}
</code></pre>
<p>Try to compile another code snippet:</p>
<pre><code>MyNullable<Money> m1 =
new MyNullable<Money>(new Money(10, CurrenciesCode.USD));
MyNullable<Money> m2 =
new MyNullable<Money>(new Money(20, CurrenciesCode.USD));
Money m3 = m1 + m2;
</code></pre>
<p>And now the question, why compiler generate "<em>error CS0019: Operator '+' cannot be applied to operands of type 'MyNullable<Money>' and 'MyNullable<Money>'</em>"?</p>
| [
{
"answer_id": 393714,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": false,
"text": "Decimal TimeSpan float Money m3 = (Money)m1 + (Money)m2;\n Nullable<T> Nullable<T> MyNullable<T> Nullable<T> x + y =>... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31090/"
] |
393,707 | <p>In XML documentaiton comments for C#, is there a way to mark two or more functions to be overloads of each other, so that they reference each other automatically? Ideally, they'd also be grouped in the sandcastle-generated documentation somehow.</p>
<p>Purpose: Often, I want to link to this group of functions, e.g. in a list of utility functions, just mention one of the overloads, and make the others easily discoverable from there.</p>
<p>Currently I am adding links, but that's tedious.</p>
| [
{
"answer_id": 393718,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": "https://Stackoverflow.com/users/17516",
"pm_score": 2,
"selected": false,
"text": "see seealso ///See <see cref=\"M:AnotherMethod(System.String)\">\n ///See <see cref=\"M:MyCompany.Myapp.MyClass.Anot... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393707",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31317/"
] |
393,708 | <p>I have a legacy VB6 program which installs an Access file in a sub-directory of the common data folder (CSIDL_COMMON_APPDATA). I have now installed this program on a 64-bit Vista system, and the program works fine and accesses the file at C:\ProgramData\Wow\WowCat.mdb, but this file does not show in Windows Explorer.</p>
<p>I want to overwrite this database, with a later version, taken from my old PC, but using Explorer I can't see the file in C:\ProgramData\Wow\ (I am showing all hidden and system files). If I go ahead and copy the new WowCat.mdb anyway, the program still works with the old one.</p>
<p>Stepping the code in VB, it is definately opening the file at: C:\ProgramData\Wow\WowCat.mdb. Searching the C: drive only shows the new copy, so where is the one that the program is accessing?</p>
| [
{
"answer_id": 393719,
"author": "Vegard Larsen",
"author_id": 1606,
"author_profile": "https://Stackoverflow.com/users/1606",
"pm_score": 3,
"selected": true,
"text": "C:\\ProgramData>dir /aL\n Volume in drive C has no label.\n Volume Serial Number is 74DB-58F8\n\n Directory of C:\\Prog... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27863/"
] |
393,738 | <p>I want to scrape the contents of a webpage. The contents are produced after a form on that site has been filled in and submitted. </p>
<p>I've read on how to scrape the end result content/webpage - but how to I programmatically submit the form? </p>
<p>I'm using python and have read that I might need to get the original webpage with the form, parse it, get the form parameters and then do X? </p>
<p>Can anyone point me in the rigth direction?</p>
| [
{
"answer_id": 393749,
"author": "Joao da Silva",
"author_id": 46329,
"author_profile": "https://Stackoverflow.com/users/46329",
"pm_score": -1,
"selected": false,
"text": "<form name='myform' ...\n <script language=\"JavaScript\">\nfunction submitform()\n{\ndocument.myform.submit();\n}\... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
393,742 | <p>I have a Deplhi based Windows Service that, on installation, parses some command line arguments. I want those arguments to be added to the services command line (ImagePath value on the registry) so that the service is always started with them.</p>
<p>How can I accomplish this?</p>
<p>I want the regedit look like this:<br>
at registry key HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\MyService </p>
<ul>
<li><code>ImagePath = C:\Path\to\my\service.exe <strong>-some -arguments</strong></code></li>
</ul>
<p>Thanks</p>
<p>Update: The installation is done with <code>>MyService.exe /install -some -arguments</code>. Those arguments are the ones I want to persist in the command line.</p>
<p>Update: I found a solution by writing directly to the registry (see <a href="https://stackoverflow.com/questions/393742/delphi-windows-services-command-line-arguments#394493">here</a>), but I'd still like a more elegant solution, like using some TService property or something of that sort. Thanks!</p>
| [
{
"answer_id": 394493,
"author": "Pablo Venturino",
"author_id": 16732,
"author_profile": "https://Stackoverflow.com/users/16732",
"pm_score": 4,
"selected": true,
"text": "uses Registry;\nprocedure MyService.AfterInstall(Sender: TObject) ;\nvar\n reg:TRegistry;\nbegin\n reg := TRegist... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16732/"
] |
393,757 | <p>It has been said that C# can be regarded as a functional programming language, even though it is widely recognized as a OO programming language.</p>
<p>So, what feature set makes C# a functional programming language?</p>
<p>I can only think of:</p>
<ol>
<li>delegates (even without anonymous methods and lambda expressions)</li>
<li>closures</li>
</ol>
<p>Anything else?</p>
| [
{
"answer_id": 393781,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": false,
"text": "var sum = data.Sum(x=>x.SomeProp);\n"
}
] | 2008/12/26 | [
"https://Stackoverflow.com/questions/393757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26349/"
] |
393,785 | <p>Is it possible in opengl to setup blending to achieve additive color overlays?</p>
<p>Red + green = yellow, cyan + magenta = white, etc.. (see <a href="http://en.wikipedia.org/wiki/File:AdditiveColor.svg" rel="noreferrer">diagram</a>)</p>
| [
{
"answer_id": 393825,
"author": "schnaader",
"author_id": 34065,
"author_profile": "https://Stackoverflow.com/users/34065",
"pm_score": 5,
"selected": true,
"text": "glEnable(GL_BLEND);\nglBlendFunc(GL_SRC_ALPHA, GL_ONE);\n"
}
] | 2008/12/26 | [
"https://Stackoverflow.com/questions/393785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36182/"
] |
393,786 | <p>I have a piece of code here that i really could use some help with refactoring. I need the different methods for adding relational data in a form in rails. The code is taken from <a href="http://railscasts.com/episodes/75-complex-forms-part-3" rel="nofollow noreferrer">http://railscasts.com/episodes/75-complex-forms-part-3</a>, my problem is that i need to have the methods fro both the Material model and the Answer model. So i need the exact same code twice with "materials" replaced by "answers".</p>
<p>It seems this should be solved with some dynamic programming? But I have no experience at all with that.</p>
<p>How is this solved?</p>
<pre><code>after_update :save_materials
after_update :save_answers
def new_material_attributes=(material_attributes)
material_attributes.each do |attributes|
materials.build(attributes)
end
end
def existing_material_attributes=(material_attributes)
materials.reject(&:new_record?).each do |material|
attributes = material_attributes[material.id.to_s]
if attributes
material.attributes = attributes
else
materials.delete(material)
end
end
end
def save_materials
materials.each do |material|
material.save(false)
end
end
</code></pre>
| [
{
"answer_id": 393869,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": false,
"text": "answers materials answers materials save_ after_update :save_materials\nafter_update :save_answers \n\n// Public metho... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9191/"
] |
393,803 | <p>I am writing a cocoa application in which I want to download a file from a webserver. What will be the most convenient method to go about doing this? Should I go in for NSSockets or a NSUrlRequest? Or is there any other easier way to achieve this?</p>
| [
{
"answer_id": 394009,
"author": "Marc Charbonneau",
"author_id": 35136,
"author_profile": "https://Stackoverflow.com/users/35136",
"pm_score": 3,
"selected": false,
"text": "initWithURL:"
}
] | 2008/12/26 | [
"https://Stackoverflow.com/questions/393803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
393,813 | <p>I am making a popup window using jqModal, and I have one main popup window. After clicking OK, I have to close that window and open another popup window. How do I achieve this?</p>
<p>Here my problem is that the click event is not working. While I am pressing a button {#b}, more than this onclick of the button I have to open another popup window.</p>
<h3>My code</h3>
<pre><code><html>
<head>
<script src="jquery-latest.js" type="text/javascript"></script>
<script src="jqModal.js" type="text/javascript"></script>
<script type="text/javascript">
$().ready(function() {
$('#ex3a').jqm(
{ trigger: '#ex3aTrigger',
overlay: 30,
overlayClass: 'Overlay'}) .jqDrag('.jqDrag');
$('input.jqmdX') .hover( function(){ $(this).addClass('jqmdXFocus'); },
function(){ $(this).removeClass('jqmdXFocus'); })
.focus( function(){ this.hideFocus=true;
$(this).addClass('jqmdXFocus'); })
.blur( function(){ $(this).removeClass('jqmdXFocus'); });
$("#b").click(function () {
alert("hello"); });
});
</script>
</head>
<body>
<a href="#" id="ex3aTrigger">
view</a> dialog
<div id="ex3a" class="jqmDialog">
<div class="jqmdTL">
<div class="jqmdTR">
<div class="jqmdTC jqDrag">[Dialog Title] </div>
</div>
</div>
<div class="jqmdBL">
<div class="jqmdBR">
<div class="jqmdBC">
<div class="jqmdMSG"> Welcome Page <br/> <br/>
<div id="b"> <button> OK </button>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
</code></pre>
| [
{
"answer_id": 394246,
"author": "Mauricio Scheffer",
"author_id": 21239,
"author_profile": "https://Stackoverflow.com/users/21239",
"pm_score": 1,
"selected": false,
"text": "$(\"#b\").click"
}
] | 2008/12/26 | [
"https://Stackoverflow.com/questions/393813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44984/"
] |
393,824 | <p>I need to use git over SSH (it's a self-imposed limitation, but one I am loathe to break). If my laptop is sitting on my home network, it all works great. When I'm at work or logged in via VPN, however, I would need to use corkscrew to access my remote repository, which I can set up without problems. </p>
<p>I would like to remain lazy and not specify where I am pulling from/pushing to each time, if possible, so my question is: how can I configure SSH to only use corkscrew when needed (based on, for example, current IP address)? Alternately, is there a way I can have git detect whether or not to pull from/push to a particular host based on IP address?</p>
<p>Thanks!</p>
| [
{
"answer_id": 71558879,
"author": "Joe Casadonte",
"author_id": 45978,
"author_profile": "https://Stackoverflow.com/users/45978",
"pm_score": 1,
"selected": true,
"text": ".ssh/config Match Match exec 0 ProxyCommand ProxyCommand Match host external-host.example.com exec /home/joe/bin/ne... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45978/"
] |
393,840 | <p>I need to locate the node within an xml file by its value using XPath.
The problem araises when the node to find contains value with whitespaces inside.
F.e.:</p>
<pre><code><Root>
<Child>value</Child>
<Child>value with spaces</Child>
</Root>
</code></pre>
<p>I can not construct the XPath locating the second Child node.</p>
<p>Simple XPath /Root/Child perfectly works for both children, but /Root[Child=value with spaces] returns an empty collection.</p>
<p>I have already tried masking spaces with <strong>%20</strong>, <strong>& #20;</strong>, <strong>& nbsp;</strong> and using quotes and double quotes.</p>
<p>Still no luck.</p>
<p>Does anybody have an idea?</p>
| [
{
"answer_id": 393867,
"author": "kdgregory",
"author_id": 42126,
"author_profile": "https://Stackoverflow.com/users/42126",
"pm_score": 3,
"selected": false,
"text": "/Root/Child[normalize-space(text())=value without spaces]\n /Root/Child[contains(text(),value without spaces)]\n /Root/C... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1596171/"
] |
393,843 | <p>I need to delete some Unicode symbols from the string 'بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ'</p>
<p>I know they exist here for sure. I tried:</p>
<pre><code>re.sub('([\u064B-\u0652\u06D4\u0670\u0674\u06D5-\u06ED]+)', '', 'بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ')
</code></pre>
<p>but it doesn't work. String stays the same. What am I doing wrong?</p>
| [
{
"answer_id": 393856,
"author": "ʞɔıu",
"author_id": 41613,
"author_profile": "https://Stackoverflow.com/users/41613",
"pm_score": 8,
"selected": true,
"text": "re.sub(ur'[\\u064B-\\u0652\\u06D4\\u0670\\u0674\\u06D5-\\u06ED]+', '', ...)\n"
},
{
"answer_id": 393915,
"author":... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49206/"
] |
393,845 | <p>I have several independent executable Perl, PHP CLI scripts and C++ programs for which I need to develop an exit error code strategy. These programs are called by other programs using a wrapper class I created to use <code>exec()</code> in PHP. So, I will be able to get an error code back. Based on that error code, the calling script will need to do something. </p>
<p>I have done a little bit of research and it seems like anything in the 1-254 (or maybe just 1-127) range could be fair game to user-defined error codes. </p>
<p>I was just wondering how other people have approached error handling in this situation.</p>
| [
{
"answer_id": 393989,
"author": "James Brady",
"author_id": 29903,
"author_profile": "https://Stackoverflow.com/users/29903",
"pm_score": 2,
"selected": false,
"text": "0000 : 0 (no error)\n0001 : 1 (error)\n0010 : 2 (I/O error)\n0100 : 4 (user input error)\n1000 : 8 (permission error)\... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28714/"
] |
393,852 | <p>I wonder if you anyone can construct a regular expression that can detect if a person searches for something like "site:cnn.com" or "site:www.globe.com.ph/". I've been having the most difficult time figuring it out. Thanks a lot in advance!</p>
<p>Edit: Sorry forgot to mention my script is in PHP.</p>
| [
{
"answer_id": 393875,
"author": "ʞɔıu",
"author_id": 41613,
"author_profile": "https://Stackoverflow.com/users/41613",
"pm_score": 0,
"selected": false,
"text": "http://www.google.com/search?client=safari&rls=en-us&q=whatever+site:foo.com&ie=UTF-8&oe=UTF-8\n \\bsite(?:\\:|%3[aA])(?:(?!(... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47947/"
] |
393,853 | <p>I have a class called DataSet with various constructors, each specifying a different type of variable. It might look a bit like this:</p>
<pre><code>public class DataSet
{
private HashSet Data;
public DataSet( DataObject obj )
{
Data = new <DataObject>HashSet();
Data.add( obj );
}
public DataSet( ObjectRelationship rel )
{
Data = new <ObjectRelationship>HashSet();
Data.add( rel );
}
// etc.
</code></pre>
<p>Note: I haven't yet gotten to test that code due to incomplete parts (which I'm building right now).</p>
<p>In a function that I'm currently building, <code>getDataObjects()</code>, I need to return all DataObject objects that this set represents. In the case of constructors that initiate the class's HashSet, <code>Data</code> with types other than <code>DataObject</code> (such as the above <code>ObjectRelationship</code>), there obviously won't be any DataObjects stored within. In this case, I need to be able to detect the type that the HashSet 'Data' was initiated with (like, to tell if it's 'ObjectRelationship' or not, I mean). How do I do this?
<br />
<br />
<br />
<br />
<strong>tl;dr</strong>: How do I tell the type that a Collection (in this case, a HashSet) was initiated with in my code (like with an 'if' or 'switch' statement or something)?</p>
| [
{
"answer_id": 393857,
"author": "duffymo",
"author_id": 37213,
"author_profile": "https://Stackoverflow.com/users/37213",
"pm_score": 0,
"selected": false,
"text": "import java.util.HashSet;\nimport java.util.Set;\nimport java.util.Arrays;\n\npublic class DataSet\n{\n private Set<Dat... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19825/"
] |
393,868 | <p>I know how to show and hide hidden files in the Terminal - but is there a way to hide certain files like .DS_STORE when showing hidden files? Make certain files super-hidden, so to speak?</p>
| [
{
"answer_id": 393905,
"author": "ibz",
"author_id": 5475,
"author_profile": "https://Stackoverflow.com/users/5475",
"pm_score": 1,
"selected": false,
"text": "alias lv=\"ls -al | grep -v .DS_Store\"\n"
},
{
"answer_id": 393914,
"author": "tvanfosson",
"author_id": 12950,... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24218/"
] |
393,871 | <p><br/>
I'd like to include <strong>Python scripting</strong> in one of my applications, that is written in Python itself. </p>
<p>My application must be able to call external Python functions (written by the user) as <strong>callbacks</strong>. There must be some control on code execution; for example, if the user provided code with syntax errors, the application must signal that.</p>
<p>What is the best way to do this?
<br/>Thanks.</p>
<p><em>edit</em>: question was unclear. I need a mechanism similar to events of VBA, where there is a "declarations" section (where you define global variables) and events, with scripted code, that fire at specific points.</p>
| [
{
"answer_id": 393897,
"author": "ibz",
"author_id": 5475,
"author_profile": "https://Stackoverflow.com/users/5475",
"pm_score": 4,
"selected": true,
"text": "__import__ try..except __import__ m = None\ntry:\n m = __import__(\"external_module\")\nexcept:\n # invalid module - show e... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23034/"
] |
393,881 | <p>Hey, im doing a little app for my smart phone, using Windows Mobile 6. I'm trying to get all currently running processec, but method CreateToolhelp32Snapshot always returns -1. So now im stuck. I tried to get error with invoking GetLastError() method, but that method returns 0 value.
Here is a snippet of my code.</p>
<pre><code>private const int TH32CS_SNAPPROCESS = 0x00000002;
[DllImport("toolhelp.dll")]
public static extern IntPtr CreateToolhelp32Snapshot(uint flags,
uint processid);
public static Process[] GetProcesses()
{
ArrayList procList = new ArrayList();
IntPtr handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if ((int)handle > 0)
{
try
{
PROCESSENTRY32 peCurr;
PROCESSENTRY32 pe32 = new PROCESSENTRY32();
// get byte array to pass to API call
byte[] peBytes = pe32.ToByteArray();
// get the first process
int retval = Process32First(handle, peBytes);
</code></pre>
| [
{
"answer_id": 32725605,
"author": "dquadros",
"author_id": 4843677,
"author_profile": "https://Stackoverflow.com/users/4843677",
"pm_score": 1,
"selected": false,
"text": "CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);\n private const int TH32CS_SNAPNOHEAPS = 0x40000000;\nCreateToolhe... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19600/"
] |
393,882 | <p>Saving and auto-filing of username/password is a feature of most modern browsers. And the user can generally choose to disable this feature on a per domain basis. But is there a standard way for the site itself to prevent password caching?</p>
<p>The emphasis here is cross-browser, so I would employ multiple parallel mechanisms if necessary.</p>
<p>(I have seen caching be effectively disabled in the presence of non-standard login fields, eg, an extra hidden password field. But I'd rather not depend on <em>side-effects</em> whose behavior could unexpectedly change in the future.)</p>
<p>Conversely, are there browsers/versions out there that implement password caching without any disable feature?</p>
| [
{
"answer_id": 393938,
"author": "ceejayoz",
"author_id": 1902010,
"author_profile": "https://Stackoverflow.com/users/1902010",
"pm_score": 5,
"selected": true,
"text": "autocomplete=\"off\" <input>"
},
{
"answer_id": 34819929,
"author": "RetroCoder",
"author_id": 487328,... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14749/"
] |
393,885 | <p>Simple question - In c++, what's the neatest way of getting which of two numbers (u0 and u1) is the smallest positive number? (that's still efficient)</p>
<p>Every way I try it involves big if statements or complicated conditional statements.</p>
<p>Thanks,
Dan</p>
<p>Here's a simple example:</p>
<pre><code>bool lowestPositive(int a, int b, int& result)
{
//checking code
result = b;
return true;
}
lowestPositive(5, 6, result);
</code></pre>
| [
{
"answer_id": 393906,
"author": "antik",
"author_id": 1625,
"author_profile": "https://Stackoverflow.com/users/1625",
"pm_score": 2,
"selected": false,
"text": "unsigned int minUnsigned( unsigned int a, unsigned int b )\n{\n return ( a < b ) ? a : b;\n}\n\nbool lowestPositive( int a, ... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393885",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18909/"
] |
393,886 | <h2>Exact Duplicate of: <a href="https://stackoverflow.com/questions/390800/is-there-a-way-to-do-object-with-its-attributes-serializing-to-xml">Is there a way to do object (with its attributes) serializing to xml?</a></h2>
<p>Quite Ironically, it's a duplicate of the poster's previous question.</p>
<hr />
<p>I want create an object, it contains some Validate application block attributes like:
[Serializable]
public class FormElement:IValidated
{</p>
<pre><code> [StringLengthValidator(1, 50, MessageTemplate = "The Name must be between 1 and 50 characters")]
public String username
{
get;
set;
}
[RangeValidator(2007,RangeBoundaryType.Inclusive,6000,RangeBoundaryType.Inclusive,MessageTemplate="input should be in 2007 to 6000")]
public int sequencenumber
{
get;
set;
}
[RegexValidator(@"^\d*\.{0,1}\d+$", MessageTemplate = "input value can not be empty or negative")]
public string medicalvalue
{
get;
set;
}
}
</code></pre>
<p>how do I serialize those attributes to xml? thanks</p>
| [
{
"answer_id": 393969,
"author": "Yossi Dahan",
"author_id": 43541,
"author_profile": "https://Stackoverflow.com/users/43541",
"pm_score": 1,
"selected": false,
"text": "//Create serializer instance, passing in the type of the class \nXmlSerializer serializer = \n new XmlSerializer(type... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48824/"
] |
393,895 | <p>I am using jQuery and Ajax, and my <code>Ajax.php</code> file returns the following field into the main file. While I am clicking in Mozilla and Chrome, it is working fine and gives an alert, but when I use Internet Explorer 7 (version 7.0.5730.13), it wasn't supported. Do I need to do anything on browser side or do I have to modify it?</p>
<p>Here is what my <code>Ajax.php</code> file has:</p>
<pre><code>echo " <a href='#' onclick=\"javascript:alert('hello')\ "> link</a>";
</code></pre>
<p>It returns to the main .html file. There I didn't get an alert in Internet Explorer 7.</p>
| [
{
"answer_id": 393904,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": true,
"text": "echo \" <a href='#' onclick=\\\"javascript:alert('hello'); return false;\\\"> link</a>\";\n"
},
{
"answer_id": 3... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44984/"
] |
393,950 | <p>Can someone please give me a simple example on how to add three rows to a ListField so that the list shows something like this?</p>
<p>Item 1</p>
<p>Item 2</p>
<p>Item 3</p>
<p>I just want to show a list in which the user can select one of the items and the program would do something depending on the item selected.</p>
<p>I've search all over the internet but it seems impossible to find a simple example on how to do this (most examples I found are incomplete) and the blackberry documentation is terrible.</p>
<p>Thanks!</p>
| [
{
"answer_id": 401557,
"author": "roryf",
"author_id": 270,
"author_profile": "https://Stackoverflow.com/users/270",
"pm_score": 5,
"selected": true,
"text": "MainScreen screen = new MainScreen();\nscreen.setTitle(\"my test\");\n\nfinal ObjectListField list = new ObjectLIstField();\nStri... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49229/"
] |
393,954 | <p>I'm trying to write a program which takes an <code>SDL_Surface</code>, converts it to an <code>IplImage</code>, uses the cvBlobsLib to find blobs, paints the blobs as spots back over the image, then converts the output <code>IplImage</code> back to an <code>SDL_Surface</code>.</p>
<p>I'm almost done: only converting the <code>IplImage</code> back to an <code>SDL_Surface</code> hasn't been done yet. This IplImage has 3 image channels and is 8 bits per pixel. I think I have two calls I can use:</p>
<pre><code>SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
</code></pre>
<p>I'm currently trying with <code>SDL_CreateRGBsurfaceFrom</code>. I have no idea, however, what the correct values of pitch, Rmask, Gmask and Bmask are. (Amask is 0, because there is no alpha channel.)</p>
<p>Could anybody help me out by explaining how to do this?</p>
<p>Thanks!</p>
<p><b>Edit</b>: For example, this is code I tried to use:</p>
<pre><code>SDL_Surface *ipl_to_surface (IplImage *opencvimg)
{
int pitch = opencvimg->nChannels*opencvimg->width;
printf("Depth %d, nChannels %d, pitch %d\n", opencvimg->depth,
opencvimg->nChannels, pitch);
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom((void*)opencvimg->imageData,
opencvimg->width,
opencvimg->height,
opencvimg->depth,
pitch,
0x0000ff, 0x00ff00, 0xff0000, 0
);
return surface;
}
</code></pre>
<p>(SDL Documentation writes "Pitch is the size of the scanline of the surface, in bytes, i.e. widthInPixels*bytesPerPixel.")
This outputs "Depth 8, nChannels 3, pitch 1920" and displays a completely red image.
I <em>think</em> a solution would be to convert my 8-bits image to 24-bits (1 byte per channel), but I don't know how to do that. Any ideas?</p>
| [
{
"answer_id": 395408,
"author": "sgielen",
"author_id": 13104,
"author_profile": "https://Stackoverflow.com/users/13104",
"pm_score": 5,
"selected": true,
"text": "8 * 3 = 24 SDL_Surface *surface = SDL_CreateRGBSurfaceFrom((void*)opencvimg->imageData,\n opencvimg->width,\... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13104/"
] |
393,968 | <p>That is, if I had two or more sets, and I wanted to return a new set containing either:</p>
<ol>
<li>All of the elements each set has in common (AND).</li>
<li>All of the elements total of each set (OR).</li>
<li>All of the elements unique to each set. (XOR).</li>
</ol>
<p>Is there an easy, pre-existing way to do that?</p>
<p><strong>Edit:</strong> That's the wrong terminology, isn't it?</p>
| [
{
"answer_id": 393993,
"author": "Jason S",
"author_id": 44330,
"author_profile": "https://Stackoverflow.com/users/44330",
"pm_score": 2,
"selected": false,
"text": "s1 s2 s1 s3 s1.removeAll(s2); s2.removeAll(s3); s1.addAll(s2);"
},
{
"answer_id": 393994,
"author": "Ari Ronen... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19825/"
] |
393,980 | <p>I'm looking for ways to restrict the number of C symbols exported to a Linux static library (archive). I'd like to limit these to only those symbols that are part of the official API for the library. I already use 'static' to declare most functions as static, but this restricts them to file scope. I'm looking for a way to restrict to scope to the library.</p>
<p>I can do this for shared libraries using the techniques in Ulrich Drepper's <a href="http://people.redhat.com/drepper/dsohowto.pdf" rel="noreferrer">How to Write Shared Libraries</a>, but I can't apply these techniques to static archives. In his earlier <a href="http://people.redhat.com/drepper/goodpractice.pdf" rel="noreferrer">Good Practices in Library Design</a> paper, he writes:</p>
<blockquote>
<p>The only possibility is to combine all object files which need
certain internal resources into one using 'ld -r' and then restrict the symbols
which are exported by this combined object file. The GNU linker has options to
do just this.</p>
</blockquote>
<p>Could anyone help me discover what these options might be? I've had some success with 'strip -w -K prefix_*', but this feels brutish. Ideally, I'd like a solution that will work with both GCC 3 and 4.</p>
<p>Thanks!</p>
| [
{
"answer_id": 394188,
"author": "tpgould",
"author_id": 32161,
"author_profile": "https://Stackoverflow.com/users/32161",
"pm_score": 4,
"selected": false,
"text": "{ global: foo; bar; local: *; };\n"
},
{
"answer_id": 415840,
"author": "Employed Russian",
"author_id": 5... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
394,005 | <p>How the variables can be transferred between the Winforms? Example customer id</p>
<p>Thanks</p>
| [
{
"answer_id": 394008,
"author": "Jim Anderson",
"author_id": 42439,
"author_profile": "https://Stackoverflow.com/users/42439",
"pm_score": 2,
"selected": false,
"text": "frmTwo.CustomerId = frmOne.CustomerId\n"
},
{
"answer_id": 394015,
"author": "Jab",
"author_id": 2967... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49238/"
] |
394,020 | <p>How accurate is <strong>System.Diagnostics.Stopwatch</strong>? I am trying to do some metrics for different code paths and I need it to be exact. Should I be using stopwatch or is there another solution that is more accurate.</p>
<p>I have been told that sometimes stopwatch gives incorrect information.</p>
| [
{
"answer_id": 33767765,
"author": "user3308241",
"author_id": 3308241,
"author_profile": "https://Stackoverflow.com/users/3308241",
"pm_score": 3,
"selected": false,
"text": "var watch = new Stopwatch();\nwatch.Start();\n... (perform a set of operations)\nwatch.Stop();\nvar wrongDate = ... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] |
394,033 | <p>Can anybody recommend a decent C# <a href="http://martinfowler.com/eaaCatalog/dataMapper.html" rel="nofollow noreferrer">Mapper Pattern</a> code generation template that plays nicely with SQL stored procedures? I'm looking for something that generates <a href="https://stackoverflow.com/questions/250001/define-poco">POCO</a> style entity objects, with a static mapper class for transferring data to/from the database through entity objects.</p>
<p>I understand that NHibernate can generate POCO style entity objects; however, NHibernate looses its appeal when you have a strong dependency on SQL stored procedures (which is a requirement of this project).</p>
<p>Bonus points awarded if you can also recommend a template that also generates the CRUD stored procs! ;-)</p>
<p><strong>Edit:</strong> For this particular project, I am definitely not interested in any templates that generate Active Record pattern code (e.g, Subsonic, Linq to SQL, Entity Framework, etc.).</p>
| [
{
"answer_id": 33767765,
"author": "user3308241",
"author_id": 3308241,
"author_profile": "https://Stackoverflow.com/users/3308241",
"pm_score": 3,
"selected": false,
"text": "var watch = new Stopwatch();\nwatch.Start();\n... (perform a set of operations)\nwatch.Stop();\nvar wrongDate = ... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10792/"
] |
394,053 | <p>I am doing windows appliction in vb.net. i have customer object contains save method. how do i generate insert query?</p>
<p>I need to save the object in relational database (SQL server). I need to know which is the correct way of doing the insertion ie,. Inside the save method i have written the SQL statement to save the object. Is it the correct way?</p>
<p>Thanks</p>
| [
{
"answer_id": 394154,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": false,
"text": "INSERT INTO [tablename] ( [column1], [column2], ... ) VALUES ( [value1], [value2], ...)\n Public Class Customer\n P... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
394,061 | <p>I`m writing a chat using WinSock2 and WinAPI functions. And I have a little trouble.<br>
I store the std::vector of client connections on server. When new client connects, new thread starts and all work with the client is done in this new thread. I do not use classes (I know it is not very good) so this list of connections is just defined as global variable. <br>
It seems to me that it can be a situation when several threads try to access this list simultaneously. Though I have not noticed that there are any problems with that, do I need to do something like this:</p>
<pre><code>
template
class SharedVector {
std::vector vect;
CRITICAL_SECTION cs;
SharedVector(const SharedVector& rhs) {}
public:
SharedVector();
explicit SharedVector(const CRITICAL_SECTION& CS);
void PushBack(const T& value);
void PopBack();
unsigned int size();
T& operator[](int index);
virtual ~SharedVector();
};
template
SharedVector::SharedVector() {
InitializeCriticalSection(&cs);
}
template
SharedVector::SharedVector(const CRITICAL_SECTION& r): cs(r) {
InitializeCriticalSection(&cs);
}
template
void SharedVector::PushBack(const T& value) {
EnterCriticalSection(&cs);
vect.push_back(value);
LeaveCriticalSection(&cs);
}
template
void SharedVector::PopBack() {
EnterCriticalSection(&cs);
vect.pop_back();
LeaveCriticalSection(&cs);
}
</code></pre>
<p>So, does my situation require using CRITICAL_SECTION and am I just the lucky guy who did not find a mistake?</p>
| [
{
"answer_id": 394151,
"author": "Evgeny Lazin",
"author_id": 42371,
"author_profile": "https://Stackoverflow.com/users/42371",
"pm_score": 2,
"selected": false,
"text": "unsigned int size();\nT& operator[](int index);\n value = shared_vector[shared_vector.size() - 1];\n shared_vector.Po... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28298/"
] |
394,063 | <p>I want to take two variables (in and in2) and put them together, for example:</p>
<pre><code>in = 1;
in2 = 3;
pin = in.in2; // I want this to set pin to 13
</code></pre>
<p>The arduino IDE tells me that in is not a class, so what syntax would I use to accomplish this?</p>
<p>EDIT: I figured out a different way to do it, you can just take <code>in</code>. multiply it by 10 and then set <code>pin</code> to the sum of <code>in</code> plus <code>in2</code></p>
| [
{
"answer_id": 394073,
"author": "Russ Bradberry",
"author_id": 48450,
"author_profile": "https://Stackoverflow.com/users/48450",
"pm_score": 0,
"selected": false,
"text": "pin = int.Parse((string)in + (string)in2);\n"
},
{
"answer_id": 587105,
"author": "Ed James",
"auth... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29291/"
] |
394,081 | <p>I need function in c++ that allows me to retrieve and store the system date. I have a class for storing dates.</p>
| [
{
"answer_id": 394091,
"author": "jason",
"author_id": 45914,
"author_profile": "https://Stackoverflow.com/users/45914",
"pm_score": 3,
"selected": false,
"text": "time.h struct tm {\n int tm_sec; /* seconds after the minute - [0,59] */\n int tm_min; /* minutes after the ho... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
394,127 | <pre><code>private HashMap<DataObject, HashSet> AllDataObjects;
...
/** Returns all DataObject elements that are NOT in the specified set. */
private DataObject[] invert( HashSet<DataObject> set )
{
HashSet<DataObject> keys = (HashSet) AllDataObjects.keySet();
keys = (HashSet) keys.clone();
keys.removeAll( set );
return (DataObject[]) keys.toArray();
}
</code></pre>
<p>Note that I don't want to alter <code>AllDataObjects</code> through this process. I casted the set of <code>AllDataObjects</code>' keys (which are the <code>DataObject</code>s I want the <code>set</code> parameter to subtract from) into a HashSet to use clone, which supposedly returns a shallow copy that I can then remove <code>set</code> from without affecting <code>AllDataObjects</code>.</p>
<p>Does this look right to you?</p>
| [
{
"answer_id": 394129,
"author": "iny",
"author_id": 27067,
"author_profile": "https://Stackoverflow.com/users/27067",
"pm_score": 5,
"selected": true,
"text": "private DataObject[] invert( Set<DataObject> set ){\n Set<DataObject> keys = new HashSet<DataObject>(AllDataObjects.keySet()... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19825/"
] |
394,133 | <p>I'm a beginner programmer and I'm learning my first language, C. </p>
<p>I'm learning mostly from Deitel and Deitel's C How to Program book, but also using example tasks and things from the university, however I am stuck on one.</p>
<p>I have a very very basic understanding of pointers - adding & in front of a variable makes it print an address and * uses a pointer to use the value stored at that address or such.</p>
<p>The piece of code I've written is for calculating the greatest (largest?) common denominator of two numbers and doesn't actually need or involve pointers at all. It uses two functions and the logic is all correct because it prints out the correct answer to the screen if I do it from the second function, rather than returning it to the main. This is where the problem lies. </p>
<p>When the second function returns the answer value, for some reason it returns what I can only assume is a pointer. I have no idea why it does this. I would be able to work with this and convert it to look up the value - however it seems to be a pointer local the second function and is written over. Nothing on the web that I could find or in my book gave me any idea how to solve the problem.</p>
<p>Thanks if you've read this far. I've rambled far too much.</p>
<p>Here is my code and output. Any help or pointers (excuse the pun) would be greatly appreciated. I know I could just have it print in the second function but I would prefer to know how and why it doesn't return the value like I would like it to.</p>
<p><strong>Code</strong></p>
<pre><code>#include <stdio.h>
int greatestCD (int num1, int num2);
int main(void)
{
int a=0, b=0;
int result;
printf("Please enter two numbers to calculate the greatest common denominator from\n");
scanf("%d%d", &a, &b);
result = greatestCD (a,b);
printf("Using the correct in main way:\nThe greatest common denominator of %d and %d is %d\n",a,b, result);
}
int greatestCD (int num1 ,int num2)
{
if (num2==0){
printf("Using the cheaty in gcd function way:\nThe greatest common denominator is %d\n",num1);
return num1;
} else {
greatestCD(num2,(num1%num2));
}
}
</code></pre>
<p><strong>Output (using 12 and 15 - the answer should be 3)</strong></p>
<pre><code>C:\Users\Sam\Documents\C programs>gcd
Please enter two numbers to calculate the greatest common denominator from
12
15
Using the cheaty in gcd function way:
The greatest common denominator is 3
Using the correct in main way:
The greatest common denominator of 12 and 15 is 2293524
</code></pre>
<p>Such a simple solution from frankodwyer. It's tiny things like that I either can't spot or don't know about. So what was being returned wasn't a pointer and was just junk?</p>
<p>Thanks a million.</p>
| [
{
"answer_id": 394141,
"author": "frankodwyer",
"author_id": 42404,
"author_profile": "https://Stackoverflow.com/users/42404",
"pm_score": 4,
"selected": true,
"text": "greatestCD(num2,(num1%num2));\n return greatestCD(num2,(num1%num2));\n"
},
{
"answer_id": 394161,
"author":... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49262/"
] |
394,144 | <p>According to Wikipedia, a <a href="http://en.wikipedia.org/wiki/Monkey_patch" rel="noreferrer">monkey patch</a> is:</p>
<blockquote>
<p>a way to extend or modify the runtime
code of dynamic languages [...]
without altering the original source
code.</p>
</blockquote>
<p>The following statement from the same entry confused me:</p>
<blockquote>
<p>In Ruby, the term monkey patch was
misunderstood to mean any dynamic
modification to a class and is often
used as a synonym for dynamically
modifying any class at runtime.</p>
</blockquote>
<p>I would like to know <strong>the exact meaning of monkey patching in Ruby.</strong> Is it doing something like the following, or is it something else?</p>
<pre><code>class String
def foo
"foo"
end
end
</code></pre>
| [
{
"answer_id": 394168,
"author": "Robert K",
"author_id": 24950,
"author_profile": "https://Stackoverflow.com/users/24950",
"pm_score": 2,
"selected": false,
"text": "class Float\n def self.times(&block)\n self.to_i.times { |i| yield(i) }\n remainder = self - self.to_i\n yield(... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1173/"
] |
394,153 | <p>I wrote the following function that works about 95% of the time, but I need it to work 100% (obviously):</p>
<pre><code>Public Shared Function getPassedVars() As String
Const keyCount As Integer = 54 ' 54 seems to be the number of parameter keys passed by default (for this web_app).
' there are more if there is a form involved (ie. from search page)
Dim oParams As String = ""
Try
With HttpContext.Current
If .Request.Params.AllKeys.Count > keyCount Then
For i As Integer = 0 To (.Request.Params.AllKeys.Count - (keyCount + 1))
oParams &= String.Format("{0}={1}{2}", .Request.Params.Keys.Item(i), .Request.Params(i), IIf(i < .Request.Params.AllKeys.Count - (keyCount + 1), ";", ""))
Next
End If
End With
Return oParams
Catch ex As Exception
Return Nothing
End Try
End Function
</code></pre>
<p>It scrubs the <code>Request.Params</code> object for passed variables, which are in the beginning of the array (the remaining ones are ASP parameters). I am pretty sure I've seen a different way to get these parameters, but I haven't been able to figure it out. Any suggestions?</p>
<h2>EDIT</h2>
<p>So it looks like I can use the <code>Request.URL.Query</code> to achieve this, I will investigate this and post back. </p>
<p>Here is what I came up with:</p>
<pre><code>Public Shared Function getPassedVars() As String
Dim oParams As String = ""
Dim qString As String = ""
Dim oSplit As New List(Of String)
Try
With HttpContext.Current
qString = .Request.Url.Query
If qString.Length > 0 Then 'do we have any passed variables?
If qString.StartsWith("?") Then qString = qString.Remove(0, 1) 'remove leading ? from querystring if it is there
oSplit.AddRange(qString.Split("&"))
For i As Integer = 0 To oSplit.Count - 1
oParams &= String.Format("{0}{1}", oSplit.Item(i), IIf(i < oSplit.Count - 1, ";", ""))
Next
Return oParams
Else
Return Nothing
End If
End With
Catch ex As Exception
Return Nothing
End Try
End Function
</code></pre>
<p>So far so good.</p>
| [
{
"answer_id": 394159,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 1,
"selected": false,
"text": "Dim myParamValue as String = Request.Form(\"MyKeyName\")\n"
},
{
"answer_id": 394209,
"author": "Adam ... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25515/"
] |
394,162 | <p>I'm trying to write a function that is able to determine whether a string contains a real or an integer value.</p>
<p>This is the simplest solution I could think of:</p>
<pre><code>int containsStringAnInt(char* strg){
for (int i =0; i < strlen(strg); i++) {if (strg[i]=='.') return 0;}
return 1;
}
</code></pre>
<p>But this solution is really slow when the string is long... Any optimization suggestions?
Any help would really be appreciated!</p>
| [
{
"answer_id": 394182,
"author": "Adarsha",
"author_id": 28373,
"author_profile": "https://Stackoverflow.com/users/28373",
"pm_score": 3,
"selected": true,
"text": "int containsStringAnInt(char* strg){ \n\n for (int i =0;strg[i]!='\\0'; i++) {\n if (strg[i]=='.') return 0;} \n r... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43960/"
] |
394,176 | <p>I am using Visual Studio 2008 to create a web based report viewing page. Its working fine locally, but when i deploy it to client's web server it does not run and it gives error that crystal reports 10.5 components are missing. Client told me that server have crystal reports 11 installed.</p>
<p>Now my question is, is there a way i can change assembly version from web.config to use version 11 of crystal reports?</p>
| [
{
"answer_id": 467216,
"author": "Rowland Shaw",
"author_id": 50447,
"author_profile": "https://Stackoverflow.com/users/50447",
"pm_score": 0,
"selected": false,
"text": "C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\Bootstrapper\\Packages"
}
] | 2008/12/26 | [
"https://Stackoverflow.com/questions/394176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
394,184 | <p>I have a table in SQL Server 2005 which has three columns: </p>
<pre><code>id (int),
message (text),
timestamp (datetime)
</code></pre>
<p>There is an index on timestamp and id.</p>
<p>I am interested in doing a query which retrieves all messages for a given date, say '12/20/2008'. However I know that simply doing where timestamp='12/20/2008' won't give me the correct result because the field is a datetime field. </p>
<p>Somebody had recommended using the DATEPART function and pulling the year, month, and day out of timestamp and verifying that these are equal to 2008, 12, and 20, respectively. It looks like this would not use the index I have on timestamp and would end up doing a full table scan.</p>
<p>So what is the best way to construct my query so that I am taking advantage of the index that I have created? </p>
| [
{
"answer_id": 394190,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": true,
"text": "-- avoid re-calculating @MyDate +1 for every row\nDECLARE @NextDay DateTime\nSet @NextDay = @MyDate + 1\n\nSELECT \n ... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/324/"
] |
394,192 | <p>What is the source (url) for Rails Engines that works with rails 2.2.2?</p>
| [
{
"answer_id": 394190,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": true,
"text": "-- avoid re-calculating @MyDate +1 for every row\nDECLARE @NextDay DateTime\nSet @NextDay = @MyDate + 1\n\nSELECT \n ... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19224/"
] |
394,201 | <p>Suppose I have the following:</p>
<ul>
<li>A region defined by minimum and maximum latitude and longitude (commonly a 'lat-long rect', though it's not actually rectangular except in certain projections).</li>
<li>A circle, defined by a center lat/long and a radius</li>
</ul>
<p>How can I determine:</p>
<ol>
<li>Whether the two shapes overlap?</li>
<li>Whether the circle is entirely contained within the rect?</li>
</ol>
<p>I'm looking for a complete formula/algorithm, rather than a lesson in the math, per-se.</p>
| [
{
"answer_id": 394346,
"author": "Jason S",
"author_id": 44330,
"author_profile": "https://Stackoverflow.com/users/44330",
"pm_score": 2,
"selected": false,
"text": "InsideCircle(P) InsideCircle(P) = sign(R-D) PANG(x) PANG(x) InsideCircle() InsideCircle(P) InsideCircle(P)"
},
{
"... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12030/"
] |
394,214 | <p>I am hoping that there is a standard class/php script that we can use for the "forgot password" functionality. It seems almost every website has one, and I'd like to reduce the development time on it.</p>
<p>It appears that a common approach is:</p>
<ol>
<li>click on Forgot password</li>
<li>User receives via email a "reset password" link</li>
<li>Click on the link allows typing in "new password" "retype password"</li>
<li>life is good</li>
</ol>
<p>I don't want to do it from scratch, hoping someone who has thought through any nuances can point me to pre-existing code. It would seem that this is a pretty standardized.</p>
<p>All: got some responses, but I'm hoping perhaps someone can recommend a pretty standard class or CMS that meets generally accepted security guidelines.</p>
| [
{
"answer_id": 394292,
"author": "Stacey Richards",
"author_id": 1142,
"author_profile": "https://Stackoverflow.com/users/1142",
"pm_score": 4,
"selected": false,
"text": "// query is my own SQLite3 wrapper function which ensures I have a valid database connection then executes the SQL.\... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43980/"
] |
394,227 | <p>I have a lengthy number-crunching process which takes advantage of quite abit of OpenGL off-screen rendering. It all works well but when I leave it to work on its own while I go make a sandwich I would usually find that it crashed while I was away.<br>
I was able to determine that the crash occurs very close to the moment The laptop I'm using decides to turn off the screen to conserve energy. The crash itself is well inside the NVIDIA dlls so there is no hope to know what's going on.</p>
<p>The obvious solution is to turn off the power management feature that turns the screen and video card off but I'm looking for something more user friendly.
Is there a way to do this programatically?<br>
I know there's a SETI@home implementation which takes advantage of GPU processing. How does it keep the video card from going to sleep?</p>
| [
{
"answer_id": 394286,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 3,
"selected": false,
"text": "#!/usr/bin/python\nimport dbus\nimport time\nbus = dbus.Bus(dbus.Bus.TYPE_SESSION)\ndevobj = bus.get_object('org.freedes... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9611/"
] |
394,230 | <p>I would like to keep my <code>.bashrc</code> and <code>.bash_login</code> files in version control so that I can use them between all the computers I use. The problem is I have some OS specific aliases so I was looking for a way to determine if the script is running on Mac OS X, Linux or <a href="http://en.wikipedia.org/wiki/Cygwin" rel="noreferrer">Cygwin</a>.</p>
<p>What is the proper way to detect the operating system in a <a href="http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29" rel="noreferrer">Bash</a> script?</p>
| [
{
"answer_id": 394235,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 8,
"selected": false,
"text": "OSTYPE linux-gnu"
},
{
"answer_id": 394238,
"author": "Joao da Silva",
"author_id": 46329,
... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19839/"
] |
394,260 | <p>With regards to OOP, how would you describe an interface?</p>
<p>What I mean is, sub-classing can be described as <em>"Has-A"</em>, and inheritance could be <em>"Is-A"</em>. A member method could be <em>"Can-Do"</em>.</p>
<p>Is there any way this could be extended (no pun intended) to describe what an interface does?</p>
| [
{
"answer_id": 394282,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 4,
"selected": true,
"text": "Serializable"
}
] | 2008/12/26 | [
"https://Stackoverflow.com/questions/394260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19731/"
] |
394,298 | <p>In an HTML file on My Computer, I'm trying to use the Scripting.FileSystemObject in a script. How can I disable the popup saying "Any ActiveX control on this page may be unsafe for scripting"?</p>
<p>The "Internet Options" Security pane allows one to set "Initialize and script ActiveX controls not marked as safe for scripting" to Enabled for various zones, but files on the local computer don't appear to be in any of the listed zones.</p>
<p>So I guess the alternate question is "How can I edit the security options for local files?"</p>
<p>System:
Windows XP SP3<br>
Internet Explorer 7</p>
| [
{
"answer_id": 394359,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "[HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\0]\n\"1201\"=dword:00000000\n"
}... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
394,299 | <p>I have an object tree that looks something like</p>
<pre><code> Ball
/ \
LegalBall IllegalBall
</code></pre>
<p>And I have 2 methods:</p>
<pre><code>class o {
AddBall(LegalBall l)
AddBall(IllegalBall i)
}
</code></pre>
<p>in another class I'd like to do the following:</p>
<pre><code>o.AddBall(myBall);
</code></pre>
<p>where myBall is of type Ball.
And get it to call the correct method depending on the subtype.
Apparently I can't do this... the arguments are not applicable.</p>
<p>Does anyone know how I can achieve what I want? Or if there is a good work around</p>
<p>Thanks</p>
<p>EDIT : the application I'm trying to build is a Cricket scorecard type thing. So depending on the type of ball that is bowled various other elements should change.</p>
<p>my original intention was to be able to specify the ball type and runs scored from some form of UI and then create an appropriate type ball from a BallFactory and then for example when I send a no ball to the team score it will add the value onto the team score but also add the value to the no balls counter. But when i give the same ball to the Batsmens Analysis to deal with it should only score value-1 to the batsmens total..</p>
<p>I hope thats not too bad an explanation of my original intention.</p>
| [
{
"answer_id": 394306,
"author": "Federico A. Ramponi",
"author_id": 18770,
"author_profile": "https://Stackoverflow.com/users/18770",
"pm_score": 2,
"selected": false,
"text": "class o {\nAddBall(Ball b)\n}\n"
},
{
"answer_id": 394308,
"author": "Tom Hawtin - tackline",
... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394299",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47026/"
] |
394,316 | <p>I want to write a script in Ruby to clean up some messed up keys in several copies of the same MySQL schema. I'd like to do something like SHOW CREATE TABLE, then look at what comes back and delete keys if they exist.</p>
<p>I know in the Rails environment you can do this...</p>
<pre><code>ActiveRecord::Base.connection.execute( some sql )
</code></pre>
<p>But what you get back is a "Result" object. For this task I need a String so I can analyze it and act accordingly.</p>
| [
{
"answer_id": 394376,
"author": "Keltia",
"author_id": 16143,
"author_profile": "https://Stackoverflow.com/users/16143",
"pm_score": 2,
"selected": false,
"text": "require \"dbi\"\nrequire \"dbi/dbrc\"\n\n# == Configuration\n\nDB = \"sympa\"\nHOST = \"saphir\"\n\ncnt = 0\ndup = 0\n\n# =... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42595/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.