qid int64 4 19.1M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
391,969 | <p>I really like how Consolas looks with ClearType enabled but unfortunately it makes everything else look terrible. Is there any way to enable this on a per app basis? I noticed that putty (the terminal emulator) has options for ClearType separate from the display setting.</p>
| [
{
"answer_id": 392346,
"author": "Mark Heath",
"author_id": 7532,
"author_profile": "https://Stackoverflow.com/users/7532",
"pm_score": 4,
"selected": true,
"text": "INotifyPropertyChanged interface MyInterface : INotifyPropertyChanged\n{\n string Text { get; set; }\n}\n\nclass MyView... | 2008/12/24 | [
"https://Stackoverflow.com/questions/391969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/327/"
] |
391,979 | <p>I need to somehow retrieve the client's IP address using JavaScript; no server side code, not even SSI.</p>
<p>However, I'm not against using a free 3rd party script/service.</p>
| [
{
"answer_id": 410887,
"author": "Cyril Gupta",
"author_id": 33052,
"author_profile": "https://Stackoverflow.com/users/33052",
"pm_score": 4,
"selected": false,
"text": "<div style=\"display:none;visibility:hidden\" id=\"uip\"><%= Request.UserHostAddress %></div>\n var ip = $get(\"uip\")... | 2008/12/24 | [
"https://Stackoverflow.com/questions/391979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] |
391,989 | <p>To the best of my knowledge, creating a dynamic Java proxy requires that one have an interface to work against for the proxy. Yet, Hibernate seems to manage its dynamic proxy generation without requiring that one write interfaces for entity classes. How does it do this? The only clue from the Hibernate documentation refers to the fact that classes must have at minimum a package-visible constructor for proxy generation.</p>
<p>Is Hibernate doing runtime bytecode engineering with a custom classloader? The documentation suggests that this is not the case. So how do they create their proxy wrappers around the concrete entity objects? Do they just create a proxy of some trivial interface without concern for type safety and then cast it as desired?</p>
| [
{
"answer_id": 3383772,
"author": "Maciek Kreft",
"author_id": 203459,
"author_profile": "https://Stackoverflow.com/users/203459",
"pm_score": 2,
"selected": false,
"text": "hibernate.properties hibernate.bytecode.provider=javassist\n"
}
] | 2008/12/24 | [
"https://Stackoverflow.com/questions/391989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/390636/"
] |
391,991 | <p>Well I am almost done finalizing the auditing portion of my application that I discussed <a href="https://stackoverflow.com/questions/390567/form-level-event-for-when-data-is-changed-on-a-msaccess-form">here</a>. The way I am doing it is looping through all text fields, drop down boxes and checkboxes and storing their values in the form_load event. Then I am doing the same thing in the form_afterUpdate event and comparing the two. If there is a difference I am logging it, if not I move on. Here is the code:</p>
<pre><code>Dim strValues(1 To 32) As String
Private Sub Form_AfterUpdate()
Dim strCurrentValue, strSQL As String
Dim intCurrentField As Integer
intCurrentField = 1
For Each C In Forms!frmVendorsManageVendors.Controls
Select Case C.ControlType
Case acTextBox, acComboBox, acCheckBox
//Doing this because I don't want a NULL as it won't concatenate in the SQL query and don't want 0 or -1 for the boolean fields
strCurrentValue = IIf(IsNull(C), "", IIf(C = vbTrue Or C = vbFalse, IIf(C = vbTrue, "Yes", "No"), C))
If strValues(intCurrentField) <> strCurrentValue Then
strSQL = "INSERT INTO changesTable (change_time,user_affected,field_affected,old_value,new_value) VALUES (NOW()," & [id] & ",'" & C.ControlSource & "','" & strValues(intCurrentField) & "','" & strCurrentValue & "')"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
//InputBox "", "", strSQL
strSQL = "WEEEE"
DoCmd.SetWarnings True
strValues(intCurrentField) = strCurrentValue
End If
intCurrentField = intCurrentField + 1
End Select
Next
End Sub
Private Sub Form_Open(Cancel As Integer)
Call btnLock_Click
Dim intCurrentField As Integer
intCurrentField = 1
For Each C In Forms!frmVendorsManageVendors.Controls
Select Case C.ControlType
Case acTextBox, acComboBox, acCheckBox
//Doing this because I don't want a NULL as it won't concatenate in the SQL query and don't want 0 or -1 for the boolean fields
strValues(intCurrentField) = IIf(IsNull(C), "", IIf(C = vbTrue Or C = vbFalse, IIf(C = vbTrue, "Yes", "No"), C))
intCurrentField = intCurrentField + 1
End Select
Next
End Sub
</code></pre>
<p>As you can see there is a commented out line where I insert into the changesTable that will put up the query in an input box so I can copy/paste it and look at it. When I uncomment that line everything is fine. If it is commented it generates the first change fine, but then won't change it for the other controls. So if I change field1 and field2 it will insert the field 1 change twice.</p>
<p>It is quite confusing and I have NO CLUE as to why this is happening.</p>
<p>Also I know I am using the wrong comment syntax but if I use the correct syntax the SO "code color"er doesn't display properly.</p>
| [
{
"answer_id": 496853,
"author": "BIBD",
"author_id": 685,
"author_profile": "https://Stackoverflow.com/users/685",
"pm_score": 0,
"selected": false,
"text": "Dim db As DAO.Database 'Inside the transaction.\nSet db = CurrentDB\nstrSQL = \"INSERT INTO changesTable (change_time, user_af... | 2008/12/24 | [
"https://Stackoverflow.com/questions/391991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428190/"
] |
392,001 | <p>Does anyone know of a program, a utility, or some programmatic library, preferably for Linux, that takes an unformatted SQL string and pretty prints it?</p>
<p>For example I would like the following</p>
<pre><code>select * from users where name = 'Paul'
</code></pre>
<p>be changed to something like this</p>
<pre><code>select *
from users
where
name = 'Paul'
</code></pre>
<p>The exact formatting is not important.
I just need something to take a large SQL string and break it up into something more readable.</p>
| [
{
"answer_id": 18322855,
"author": "Wayne Walker",
"author_id": 448831,
"author_profile": "https://Stackoverflow.com/users/448831",
"pm_score": 4,
"selected": false,
"text": "☺ [wwalker@speedy:~] \n$ echo \"select f1, f2, fname, lName from tblName where f1 = true and fname is not null o... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3045/"
] |
392,011 | <p>We use MS Access as a front-end to Oracle tables, via ODBC, and it has been working well.
But we're trying to use the DEFAULT constraint in an Oracle table. When we open the linked table in Access, we see existing data just fine, but when we try to add a row, without keying any value into column(s) that have an Oracle DEFAULT (expecting the default to be used) we see #Deleted in each column and the row does not get added to the table. Any ideas? I can supply more details if it would help, just let me know.</p>
| [
{
"answer_id": 392074,
"author": "BQ.",
"author_id": 4632,
"author_profile": "https://Stackoverflow.com/users/4632",
"pm_score": 1,
"selected": false,
"text": "insert into customers (cust_id, name, balance) values (1, \"Bob\", 50.25);\n insert into customers (cust_id, name, balance) valu... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
392,022 | <p>I want to kill a whole process tree. What is the best way to do this using any common scripting languages? I am looking for a simple solution.</p>
| [
{
"answer_id": 392111,
"author": "brad.lane",
"author_id": 48774,
"author_profile": "https://Stackoverflow.com/users/48774",
"pm_score": 3,
"selected": false,
"text": "for child in $(ps -o pid,ppid -ax | \\\n awk \"{ if ( \\$2 == $pid ) { print \\$1 }}\")\ndo\n echo \"Killing child pr... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26658/"
] |
392,024 | <p>(I've tried this in MySql)</p>
<p>I believe they're semantically equivalent. Why not identify this trivial case and speed it up?</p>
| [
{
"answer_id": 392922,
"author": "Eric Sabine",
"author_id": 1493157,
"author_profile": "https://Stackoverflow.com/users/1493157",
"pm_score": 3,
"selected": false,
"text": "create table test1 (col1 int)\ngo\ninsert test1 values(3)\nbegin tran\ntruncate table test1\nselect * from test1\n... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392024",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11236/"
] |
392,034 | <p>I'm going nuts here, trying to get my system configured. </p>
<p>I have a laptop at home and a workstation at work. I use mutt and sendmail. I have a home ISP that is on a lot of blacklists, so that any email I send from my laptop through my ISP is frequently blocked as spam by the receiver. I can SSH to my workstation and use mutt there interactively, but it is slow and tedious. I download my email from the work server to the laptop with fetchmail. </p>
<p>I've tried to get the laptop to send mail through the work mailer using </p>
<pre><code>ssh -L 25:workstation.work.com:25 workstation.work.com
</code></pre>
<p>but it seems that sendmail cannot be running when I do this. When I try to fetchmail from workstation to the laptop sendmail must be running on the laptop for the mail to be delivered locally at the laptop. When mail does go through it gets rejected because the hostname is not recognised. I've tried changing the hostname in mutt. This appears not to affect anything.</p>
<p>So I'm confused about how to configure mutt, sendmail and SSH on my laptop, so that I can compose and send emails from my laptop such that they get delivered, yet I also want to get my emails from the server with fetchmail and have it delivered locally.</p>
<p>Any help appreciated.</p>
| [
{
"answer_id": 392067,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 4,
"selected": true,
"text": "relayhost=[127.0.0.1]:2526 ssh -N -L 2526:localhost:25 ptomblin@myserver"
}
] | 2008/12/24 | [
"https://Stackoverflow.com/questions/392034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48915/"
] |
392,041 | <p>I'm using the python optparse module in my program, and I'm having trouble finding an easy way to parse an option that contains a list of values.</p>
<p>For example:</p>
<pre><code>--groups one,two,three.
</code></pre>
<p>I'd like to be able to access these values in a list format as <code>options.groups[]</code>. Is there an optparse option to convert comma separated values into a list? Or do I have to do this manually?</p>
| [
{
"answer_id": 392061,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 6,
"selected": true,
"text": "optarg.split(',')"
},
{
"answer_id": 392258,
"author": "Can Berk Güder",
"author_id": 2119,
"author_prof... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48810/"
] |
392,042 | <p>I'm new to PHP and have installed on Linux to boot (also a newbie).
Anyway, PHP is working...</p>
<pre><code><?
$myVar = "test";
echo($myVar);
?>
</code></pre>
<p>... works just fine.</p>
<p>But...</p>
<pre><code><?
$dbhost = "localhost";
$dbuser = "myuser";
$dbpass = "mypass";
$dbname = "mydb";
echo($dbhost . "-" . $dbuser . "-" . $dbpass . "-" . $dbname);
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to connect to MySQL");
print $conn;
mysql_close($conn);
phpInfo();
?>
</code></pre>
<p>... does nothing. Nor errors, nothing. Its as if the code isn't even there.</p>
<p>Any help?</p>
| [
{
"answer_id": 392055,
"author": "Paolo Bergantino",
"author_id": 16417,
"author_profile": "https://Stackoverflow.com/users/16417",
"pm_score": 1,
"selected": false,
"text": "error_reporting(E_ALL);\n$conn = mysql_connect(\"localhost\", \"myusername\", \"mypassword\");\nif(!$conn) {\n ... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26121/"
] |
392,043 | <p>I see on the web there are a lot of questions about caching ASP.Net, but not a lot of discussion on caching options for a Smart Client Application and their databases.</p>
<p>What are the data caching options that are available for Smart Client Application on the .Net framework, and how are any of you using them?</p>
<hr>
<p><strong>Edit</strong></p>
<p>Enterprise Framework was mentioned below, thoughts?</p>
| [
{
"answer_id": 392054,
"author": "amazedsaint",
"author_id": 45956,
"author_profile": "https://Stackoverflow.com/users/45956",
"pm_score": 3,
"selected": true,
"text": " using Microsoft.Practices.EnterpriseLibrary.Caching;\n //Later \n CacheManager cache= CacheFactory.GetCacheManag... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13502/"
] |
392,088 | <p>Is there any way to have PHP automatically call a function, before a script outputs any HTTP headers?</p>
<p>I'm looking for something like <a href="http://us.php.net/register-shutdown-function" rel="nofollow noreferrer">register-shutdown-function</a>, but to register a function that's called <strong>before</strong> the output is already sent, not after. I want my function to send a header, so I need something that's called earlier.</p>
| [
{
"answer_id": 392129,
"author": "charlesbridge",
"author_id": 22738,
"author_profile": "https://Stackoverflow.com/users/22738",
"pm_score": 4,
"selected": true,
"text": "ob_start ob_end_flush"
}
] | 2008/12/24 | [
"https://Stackoverflow.com/questions/392088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4321/"
] |
392,098 | <p>I do not want the user to be able to change the value displayed in the combobox. I have been using <code>Enabled = false</code> but it grays out the text, so it is not very readable. I want it to behave like a textbox with <code>ReadOnly = true</code>, where the text is displayed normally, but the user can't edit it.</p>
<p>Is there is a way of accomplishing this?</p>
| [
{
"answer_id": 392113,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": false,
"text": "DropDownStyle DropDownList"
},
{
"answer_id": 392197,
"author": "Dan Williams",
"author_id": 4230,
... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18169/"
] |
392,100 | <p>I've been working with python for a while now and am just starting to learn wxPython. After creating a few little programs, I'm having difficulty understanding how to create objects that can be shared between dialogs.</p>
<p>Here's some code as an example (apologies for the length - I've tried to trim):</p>
<pre><code>import wx
class ExampleFrame(wx.Frame):
"""The main GUI"""
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(200,75))
mainSizer = wx.BoxSizer(wx.VERTICAL)
# Setup buttons
buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
playerButton = wx.Button(self, wx.ID_ANY, "Player number", wx.DefaultPosition, wx.DefaultSize, 0)
buttonSizer.Add(playerButton, 1, wx.ALL | wx.EXPAND, 0)
nameButton = wx.Button(self, wx.ID_ANY, "Player name", wx.DefaultPosition, wx.DefaultSize, 0)
buttonSizer.Add(nameButton, 1, wx.ALL | wx.EXPAND, 0)
# Complete layout and add statusbar
mainSizer.Add(buttonSizer, 1, wx.EXPAND, 5)
self.SetSizer(mainSizer)
self.Layout()
# Deal with the events
playerButton.Bind(wx.EVT_BUTTON, self.playerButtonEvent)
nameButton.Bind(wx.EVT_BUTTON, self.nameButtonEvent)
self.Show(True)
return
def playerButtonEvent(self, event):
"""Displays the number of game players"""
playerDialog = PlayerDialogWindow(None, -1, "Player")
playerDialogResult = playerDialog.ShowModal()
playerDialog.Destroy()
return
def nameButtonEvent(self, event):
"""Displays the names of game players"""
nameDialog = NameDialogWindow(None, -1, "Name")
nameDialogResult = nameDialog.ShowModal()
nameDialog.Destroy()
return
class PlayerDialogWindow(wx.Dialog):
"""Displays the player number"""
def __init__(self, parent, id, title):
wx.Dialog.__init__(self, parent, id, title, size=(200,120))
# Setup layout items
self.SetAutoLayout(True)
mainSizer = wx.BoxSizer(wx.VERTICAL)
dialogPanel = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL)
dialogSizer = wx.BoxSizer(wx.VERTICAL)
# Display player number
playerNumber = "Player number is %i" % gamePlayer.number
newLabel = wx.StaticText(dialogPanel, wx.ID_ANY, playerNumber, wx.DefaultPosition, wx.DefaultSize, 0)
dialogSizer.Add(newLabel, 0, wx.ALL | wx.EXPAND, 5)
# Setup buttons
buttonSizer = wx.StdDialogButtonSizer()
okButton = wx.Button(dialogPanel, wx.ID_OK)
buttonSizer.AddButton(okButton)
buttonSizer.Realize()
dialogSizer.Add(buttonSizer, 1, wx.EXPAND, 5)
# Complete layout
dialogPanel.SetSizer(dialogSizer)
dialogPanel.Layout()
dialogSizer.Fit(dialogPanel)
mainSizer.Add(dialogPanel, 1, wx.ALL | wx.EXPAND, 5)
self.SetSizer(mainSizer)
self.Layout()
# Deal with the button events
okButton.Bind(wx.EVT_BUTTON, self.okClick)
return
def okClick(self, event):
"""Deals with the user clicking the ok button"""
self.EndModal(wx.ID_OK)
return
class NameDialogWindow(wx.Dialog):
"""Displays the player name"""
def __init__(self, parent, id, title):
wx.Dialog.__init__(self, parent, id, title, size=(200,120))
# Setup layout items
self.SetAutoLayout(True)
mainSizer = wx.BoxSizer(wx.VERTICAL)
dialogPanel = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL)
dialogSizer = wx.BoxSizer(wx.VERTICAL)
# Display player number
playerNumber = "Player name is %s" % gamePlayer.name
newLabel = wx.StaticText(dialogPanel, wx.ID_ANY, playerNumber, wx.DefaultPosition, wx.DefaultSize, 0)
dialogSizer.Add(newLabel, 0, wx.ALL | wx.EXPAND, 5)
# Setup buttons
buttonSizer = wx.StdDialogButtonSizer()
okButton = wx.Button(dialogPanel, wx.ID_OK)
buttonSizer.AddButton(okButton)
buttonSizer.Realize()
dialogSizer.Add(buttonSizer, 1, wx.EXPAND, 5)
# Complete layout
dialogPanel.SetSizer(dialogSizer)
dialogPanel.Layout()
dialogSizer.Fit(dialogPanel)
mainSizer.Add(dialogPanel, 1, wx.ALL | wx.EXPAND, 5)
self.SetSizer(mainSizer)
self.Layout()
# Deal with the button events
okButton.Bind(wx.EVT_BUTTON, self.okClick)
return
def okClick(self, event):
"""Deals with the user clicking the ok button"""
self.EndModal(wx.ID_OK)
return
class Player(object):
"""A game player"""
def __init__(self, number, name):
self.number = number
self.name = name
return
def main():
# Start GUI
global gamePlayer
gamePlayer = Player(1, "John Smith")
app = wx.App(redirect=False)
frame = ExampleFrame(None, -1, "Example frame")
frame.Show(True)
app.MainLoop()
return 0
if __name__ == '__main__':
main()
</code></pre>
<p>So, I want both of the dialogs to access the gamePlayer object. At the moment, the only way I can think of doing it is to create the gamePlayer object as a global object, but these are normally frowned upon - is there a better way to do this?</p>
<p>There is a method of passing objects in event bindings in <a href="https://stackoverflow.com/questions/173687?sort=votes">this question</a>, but it doesn't feel quite right.</p>
<p>Is learning to implement the MVC pattern the way forward here?</p>
<p>Thanks.</p>
| [
{
"answer_id": 392125,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 3,
"selected": true,
"text": "__init__ def __init__(self, parent, id, title, gamePlayer ):\n ...etc...\n"
}
] | 2008/12/24 | [
"https://Stackoverflow.com/questions/392100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40429/"
] |
392,120 | <p>Does anyone know why typedefs of class names don't work like class names for the friend declaration?</p>
<pre><code>class A
{
public:
};
class B : public A
{
public:
typedef A SUPERCLASS;
};
typedef A X;
class C
{
public:
friend class A; // OK
friend class X; // fails
friend class B::SUPERCLASS; // fails
};
</code></pre>
| [
{
"answer_id": 392136,
"author": "sergtk",
"author_id": 13441,
"author_profile": "https://Stackoverflow.com/users/13441",
"pm_score": 1,
"selected": false,
"text": "...\nclass C\n{\npublic:\n friend class A; \n friend X; \n friend B::SUPERCLASS; \n};\n...\n"
},
{... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392120",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48956/"
] |
392,122 | <p>FieldInfo has an IsStatic member, but PropertyInfo doesn't. I assume I'm just overlooking what I need. </p>
<pre><code>Type type = someObject.GetType();
foreach (PropertyInfo pi in type.GetProperties())
{
// umm... Not sure how to tell if this property is static
}
</code></pre>
| [
{
"answer_id": 392141,
"author": "ctacke",
"author_id": 13154,
"author_profile": "https://Stackoverflow.com/users/13154",
"pm_score": 3,
"selected": false,
"text": "type.GetProperties(BindingFlags.Static)\n"
},
{
"answer_id": 45484579,
"author": "relatively_random",
"auth... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16260/"
] |
392,135 | <p>I understand one uses the "bless" keyword in Perl inside a class's "new" method:</p>
<pre><code>sub new {
my $self = bless { };
return $self;
}
</code></pre>
<p>But what exactly is "bless" doing to that hash reference ? </p>
| [
{
"answer_id": 392146,
"author": "Gordon Wilson",
"author_id": 23071,
"author_profile": "https://Stackoverflow.com/users/23071",
"pm_score": 8,
"selected": true,
"text": "bless package MyClass;\nmy $object = { };\nbless $object, \"MyClass\";\n $object sub new { \n my $class = shift; \n ... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47145/"
] |
392,142 | <p>How do I determine whether a function exists within a library, or list out the functions in a compiled library?</p>
| [
{
"answer_id": 392148,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 6,
"selected": true,
"text": "nm -g -C <libMylib.a>\n"
},
{
"answer_id": 392151,
"author": "Luca Tettamanti",
"author_id": 42448,
"... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18352/"
] |
392,160 | <p>I have a friend who likes to use metaclasses, and regularly offers them as a solution.</p>
<p>I am of the mind that you almost never need to use metaclasses. Why? because I figure if you are doing something like that to a class, you should probably be doing it to an object. And a small redesign/refactor is in order.</p>
<p>Being able to use metaclasses has caused a lot of people in a lot of places to use classes as some kind of second rate object, which just seems disastrous to me. Is programming to be replaced by meta-programming? The addition of class decorators has unfortunately made it even more acceptable.</p>
<p>So please, I am desperate to know your valid (concrete) use-cases for metaclasses in Python. Or to be enlightened as to why mutating classes is better than mutating objects, sometimes.</p>
<p>I will start:</p>
<blockquote>
<p>Sometimes when using a third-party
library it is useful to be able to
mutate the class in a certain way.</p>
</blockquote>
<p>(This is the only case I can think of, and it's not concrete)</p>
| [
{
"answer_id": 392232,
"author": "Kenan Banks",
"author_id": 43089,
"author_profile": "https://Stackoverflow.com/users/43089",
"pm_score": 3,
"selected": false,
"text": "# Both the photo type and the flickr.photos.search API method \n# are generated at \"run-time\"\nfor photo in flickr.p... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28380/"
] |
392,169 | <p>Is there a way to play a Christmas tune on a PC or Mac without having a pre-recorded sound file? (No .mp3 or .wav or whatever-sound file)</p>
<p>I remember on my TI 99/4A and Apple II sounds (resembling music) could be played. Not sure if modern computers have these abilities (aside from <em>beep</em>).</p>
| [
{
"answer_id": 392183,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 2,
"selected": false,
"text": "PLAY \"e4 e4 e2 e4 e4 e2 e4 g4 c4 d4 e2\"\n"
},
{
"answer_id": 392228,
"author": "friol",
"author_id": 230... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21826/"
] |
392,173 | <p>I'm trying to do some parameter estimation and want to choose parameter estimates that minimize the square error in a predicted equation <strong>over about 30 variables</strong>. If the equation were linear, I would just compute the 30 partial derivatives, set them all to zero, and use a linear-equation solver. But unfortunately <strong>the equation is nonlinear</strong> and so are its derivatives.</p>
<p>If the equation were over a single variable, I would just use <a href="http://en.wikipedia.org/wiki/Newton-Raphson#Nonlinear_systems_of_equations" rel="noreferrer">Newton's method</a> (also known as Newton-Raphson). The Web is rich in examples and code to implement Newton's method <em>for functions of a single variable</em>.</p>
<p>Given that I have about 30 variables, <strong>how can I program a numeric solution to this problem using Newton's method</strong>? I have the equation in closed form and can compute the first and second derivatives, but I don't know quite how to proceed from there. I have found a large number of treatments on the web, but they quickly get into heavy matrix notation. I've found <a href="http://en.wikipedia.org/wiki/Newton-Raphson#Nonlinear_systems_of_equations" rel="noreferrer">something moderately helpful</a> on Wikipedia, but I'm having trouble translating it into code.</p>
<p>Where I'm worried about breaking down is in the matrix algebra and matrix inversions. I can invert a matrix with a linear-equation solver but I'm worried about getting the right rows and columns, avoiding transposition errors, and so on.</p>
<p>To be quite concrete:</p>
<ul>
<li><p>I want to work with tables mapping variables to their values. I can write a function of such a table that returns the square error given such a table as argument. I can also create functions that return a partial derivative with respect to any given variable.</p></li>
<li><p>I have a reasonable starting estimate for the values in the table, so I'm not worried about convergence.</p></li>
<li><p>I'm not sure how to write the loop that uses an estimate (table of value for each variable), the function, and a table of partial-derivative functions to produce a new estimate.</p></li>
</ul>
<p>That last is what I'd like help with. Any direct help or pointers to good sources will be warmly appreciated.</p>
<hr>
<p>Edit: Since I have the first and second derivatives in closed form, I would like to take advantage of them and avoid more slowly converging methods like simplex searches.</p>
| [
{
"answer_id": 425824,
"author": "Norman Ramsey",
"author_id": 41661,
"author_profile": "https://Stackoverflow.com/users/41661",
"pm_score": 2,
"selected": false,
"text": "__doc.findzero = [[function(functions, partials, point, [epsilon, steps]) returns table, boolean\nWhere\n point ... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41661/"
] |
392,176 | <p>I am retrieving three different sets of data (or what should be "unique" rows). In total, I expect 3 different unique sets of rows because I have to complete different operations on each set of data. I am, however, retrieving more rows than there are in total in the table, meaning that I must be retrieving duplicate rows somewhere. Here is an example of my three sets of queries:</p>
<pre><code>SELECT DISTINCT t1.*
FROM table1 t1
INNER JOIN table2 t2
ON t2.ID = t1.ID
AND t2.NAME = t1.NAME
AND t2.ADDRESS <> t1.ADDRESS
SELECT DISTINCT t1.*
FROM table1 t1
INNER JOIN table2 t2
ON t2.ID = t1.ID
AND t2.NAME <> t1.NAME
AND t2.ADDRESS <> t1.ADDRESS
SELECT DISTINCT t1.*
FROM table1 t1
INNER JOIN table2 t2
ON t2.ID <> t1.ID
AND t2.NAME = t1.NAME
AND t2.ADDRESS <> t1.ADDRESS
</code></pre>
<p>As you can see, I am selecting (in order of queries)</p>
<ul>
<li>Set of data where the id AND name match</li>
<li>Set of data where the id matches but the name does NOT</li>
<li>Set of data where the id does not match but name DOES</li>
</ul>
<p>I am retrieving MORE rows than exist in T1 when adding up the number of results returned from all three queries which I don't think is logically possible, plus this means I must be duplicating rows (if it is logically possible) somewhere which prevents me from executing different commands against each set (since a row would have another command executed on it).</p>
<p>Can someone find where I'm going wrong here?</p>
| [
{
"answer_id": 392184,
"author": "Eric Rosenberger",
"author_id": 41624,
"author_profile": "https://Stackoverflow.com/users/41624",
"pm_score": 1,
"selected": false,
"text": "SELECT DISTINCT t1.*\n FROM table1 t1\n INNER JOIN table2 t2\n ON t2.ID = t1.ID\n AND... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16631/"
] |
392,198 | <p>If I start copying a huge file tree from one position to another or if some other process starts doing lots of disk activity, the foreground app (GUI) slows way down. For example, take a 2gb file tree with 100k files in it. Open a console and do cp -r bigtree bigtree2. Then go to firefox and start browsing. Firefox is almost unusable. Even if I set firefox's nice level to really high priority (-20), it's still super slow with huge delays.</p>
<p>I remember some years ago when I worked on a Solaris box, the system behaved much better in similar circumstances.</p>
<p>My HD is using DMA, not PIO. It's SATA. Not mounted with the atime flag.</p>
| [
{
"answer_id": 392387,
"author": "Zan Lynx",
"author_id": 13422,
"author_profile": "https://Stackoverflow.com/users/13422",
"pm_score": 4,
"selected": false,
"text": "vm.dirty_writeback_centisecs = 100\nvm.dirty_expire_centisecs = 9000\nvm.dirty_background_ratio = 4\nvm.dirty_ratio = 80\... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2033811/"
] |
392,215 | <p>I thought this would be simple, but its not working .. in both the object/embed code, i try to load a .swf via a url but nothing loads.
ex:
name="movie"value="http://localhost/mySite/Flash/Flash.swf"</p>
<p>If i run the pages locally from the flash folder and ref via:
name="movie"value="Flash.swf"
... it works fine</p>
<p>I thought it might be a security issue so i tried to change name="allowScriptAccess" value="always", but that didnt help.</p>
<p>Any help is appreciated - thank you.</p>
| [
{
"answer_id": 392246,
"author": "Russ Bradberry",
"author_id": 48450,
"author_profile": "https://Stackoverflow.com/users/48450",
"pm_score": 0,
"selected": false,
"text": "<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockw... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26685/"
] |
392,216 | <p>According to the <a href="http://java.sun.com/docs/books/jls/third_edition/html/exceptions.html" rel="nofollow noreferrer">Java Language Specification</a>:</p>
<blockquote>
<p>If there are any enclosing try statements whose try blocks contain the throw statement, then any finally clauses of those try statements are executed as control is transferred outward, until the thrown value is caught. Note that <strong>abrupt completion of a finally clause</strong> can disrupt the transfer of control initiated by a throw statement.</p>
</blockquote>
<p>Other than returning inside a finally block, what other ways are there?</p>
| [
{
"answer_id": 392219,
"author": "Michael Myers",
"author_id": 13531,
"author_profile": "https://Stackoverflow.com/users/13531",
"pm_score": 4,
"selected": true,
"text": "finally"
},
{
"answer_id": 392222,
"author": "Charlie Martin",
"author_id": 35092,
"author_profil... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2644/"
] |
392,234 | <p>I have a regex created from a list in a database to match names for types of buildings in a game. The problem is typos, sometimes those writing instructions for their team in the game will misspell a building name and obviously the regex will then not pick it up (i.e. spelling "University" and "Unversity").</p>
<p>Are there any suggestions on making a regex match misspellings of 1 or 2 letters?</p>
<p>The regex is dynamically generated and run on a local machine that's able to handle a lot more load so I have as a last resort to algorithmically create versions of each word with a letter missing and then another with letters added in.</p>
<p>I'm using PHP but I'd hope that any solution to this issue would not be PHP specific.</p>
| [
{
"answer_id": 392413,
"author": "Norman Ramsey",
"author_id": 41661,
"author_profile": "https://Stackoverflow.com/users/41661",
"pm_score": 2,
"selected": false,
"text": "agrep agrep agrep"
}
] | 2008/12/24 | [
"https://Stackoverflow.com/questions/392234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] |
392,235 | <p>I would like to test my ActionMailer class, but don't have an smtp server. I would like to use gmail to send such emails. Could someone provide a sample with all the necessary configurations both on google and whatever config files in the app?</p>
| [
{
"answer_id": 392446,
"author": "Otto",
"author_id": 9594,
"author_profile": "https://Stackoverflow.com/users/9594",
"pm_score": 2,
"selected": false,
"text": "apt-get install ssmtp #\n# Config file for sSMTP sendmail\n#\n# The person who gets all mail for userids < 1000\n# Make this em... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48968/"
] |
392,257 | <p>I have a picture box on my form, which I add a picture to. This picture has a transparent background, but unfortunately, it seems lost in the picture box... I'm guessing that's because the picture box's background colour property is set to grey (the default). I can't see any option for "transparent" though.</p>
<p>Any idea how I can do it?</p>
| [
{
"answer_id": 31250648,
"author": "DMC",
"author_id": 3026615,
"author_profile": "https://Stackoverflow.com/users/3026615",
"pm_score": 1,
"selected": false,
"text": "PictureBox2.Parent = PictureBox1\n"
},
{
"answer_id": 52620916,
"author": "Rex Mallari Oliveros",
"autho... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48970/"
] |
392,273 | <p>Pursuant to the advice given in <a href="https://stackoverflow.com/questions/385156/how-do-i-retrofit-a-gui-to-an-existing-c-program">this question</a> I have written a little gui to take the options for a command line C program and pass them on to said C program which is already set up to process them. It displays just like I wanted.</p>
<p>However, I would like to verify that the values stored in the variables are correct. <strong>Getting the values to print out is giving me a lot of grief</strong> (I can't test <em>in vivo</em> right now due to some hardware issues). What am I missing?</p>
<ol>
<li>Prepending the variable name with '$' gives me '$variableName' rather than the <em>value</em> of the variable. </li>
<li>Adding these variables to an array and calling <code>array get arr</code> is supposed to print the index and the array value; I get variable names.</li>
<li>I tried <em>pathName</em> <code>cget</code> <em>option</em>, but apparently <code>-value</code> isn't an option, and leaving off the option doesn't give me a list of valid options. </li>
</ol>
<p>Here's all the code with the various things that didn't work (from option #1, which is the most straightforward way; the others were just me trying workarounds). They all produce
errors along the lines of: "can't read "::": no such variable" or "can't read
"colorimetric": no such variable".</p>
<pre><code>#!/opt/ActiveTcl-8.5/bin/wish8.5
wm title . "Gretag"
ttk::frame .f -borderwidth 5 -relief sunken -padding "5 10"
# next line part of the "puts" tests at the bottom
global colorimetric
ttk::label .f.dataLabel -text "Data Type"
ttk::label .f.colorimetricLabel -text "Colorimetric"
ttk::checkbutton .f.colorimetric -onvalue "-c" -offvalue "" -command getFilename1
ttk::label .f.spectralLabel -text "Spectral"
ttk::checkbutton .f.spectral -onvalue "-s" -offvalue "" -command getFilename2
ttk::label .f.gretagNumLabel -text "Gretag #"
ttk::label .f.gretagLabel0 -text "1"
ttk::radiobutton .f.gretagRadio0 -variable gretagNum -value "/dev/ttyS0"
ttk::label .f.gretagLabel1 -text "2"
ttk::radiobutton .f.gretagRadio1 -variable gretagNum -value "/dev/ttyS1"
ttk::label .f.gretagLabel2 -text "3"
ttk::radiobutton .f.gretagRadio2 -variable gretagNum -value "/dev/ttyS2"
ttk::label .f.gretagLabel3 -text "4"
ttk::radiobutton .f.gretagRadio3 -variable gretagNum -value "/dev/ttyS3"
ttk::label .f.gretagLabel4 -text "5"
ttk::radiobutton .f.gretagRadio4 -variable gretagNum -value "/dev/ttyS4"
ttk::label .f.sampleSize -text "Sample Size"
ttk::label .f.samplex -text "X"
ttk::label .f.sampley -text "Y"
ttk::entry .f.x -textvariable x -width 5
ttk::entry .f.y -textvariable y -width 5
ttk::label .f.filterLabel -text "Filter Type"
ttk::label .f.filterLabel0 -text "D50"
ttk::radiobutton .f.filterRadio0 -variable filter -value "-d50"
ttk::label .f.filterLabel1 -text "D65"
ttk::radiobutton .f.filterRadio1 -variable filter -value "-d65"
ttk::label .f.filterLabel2 -text "Unfiltered"
ttk::radiobutton .f.filterRadio2 -variable filter -value "-U"
ttk::label .f.filterLabel3 -text "Polarized"
ttk::radiobutton .f.filterRadio3 -variable filter -value "-p"
ttk::label .f.baudLabel -text "Baud Rate"
ttk::label .f.baudLabel0 -text "4800"
ttk::radiobutton .f.baudRadio0 -variable baud -value "B4800"
ttk::label .f.baudLabel1 -text "9600"
ttk::radiobutton .f.baudRadio1 -variable baud -value "B9600"
ttk::label .f.baudLabel2 -text "19200"
ttk::radiobutton .f.baudRadio2 -variable baud -value "B19200"
ttk::label .f.baudLabel3 -text "38400"
ttk::radiobutton .f.baudRadio3 -variable baud -value "B38400"
ttk::label .f.baudLabel4 -text "57600"
ttk::radiobutton .f.baudRadio4 -variable baud -value "B57600"
ttk::button .f.submitBtn -text "Submit" -command finish
grid columnconfigure . 0 -weight 1
grid rowconfigure . 0 -weight 1
grid .f -column 0 -row 0 -columnspan 11 -rowspan 5
grid .f.dataLabel -column 0 -row 0 -sticky we
grid .f.colorimetricLabel -column 1 -row 0 -sticky e
grid .f.colorimetric -column 2 -row 0 -sticky w
grid .f.spectralLabel -column 3 -row 0 -sticky e
grid .f.spectral -column 4 -row 0 -sticky w
grid .f.gretagNumLabel -column 0 -row 1 -sticky we
grid .f.gretagLabel0 -column 1 -row 1 -sticky e
grid .f.gretagRadio0 -column 2 -row 1 -sticky w
grid .f.gretagLabel1 -column 3 -row 1 -sticky e
grid .f.gretagRadio1 -column 4 -row 1 -sticky w
grid .f.gretagLabel2 -column 5 -row 1 -sticky e
grid .f.gretagRadio2 -column 6 -row 1 -sticky w
grid .f.gretagLabel3 -column 7 -row 1 -sticky e
grid .f.gretagRadio3 -column 8 -row 1 -sticky w
grid .f.gretagLabel4 -column 9 -row 1 -sticky e
grid .f.gretagRadio4 -column 10 -row 1 -sticky w
grid .f.sampleSize -column 0 -row 2 -sticky we
grid .f.samplex -column 1 -row 2 -sticky e
grid .f.x -column 2 -row 2 -sticky w
grid .f.sampley -column 3 -row 2 -sticky e
grid .f.y -column 4 -row 2 -sticky w
grid .f.filterLabel -column 0 -row 3 -sticky we
grid .f.filterLabel0 -column 1 -row 3 -sticky e
grid .f.filterRadio0 -column 2 -row 3 -sticky w
grid .f.filterLabel1 -column 3 -row 3 -sticky e
grid .f.filterRadio1 -column 4 -row 3 -sticky w
grid .f.filterLabel2 -column 5 -row 3 -sticky e
grid .f.filterRadio2 -column 6 -row 3 -sticky w
grid .f.filterLabel3 -column 7 -row 3 -sticky e
grid .f.filterRadio3 -column 8 -row 3 -sticky w
grid .f.baudLabel -column 0 -row 4 -sticky we
grid .f.baudLabel0 -column 1 -row 4 -sticky e
grid .f.baudRadio0 -column 2 -row 4 -sticky w
grid .f.baudLabel1 -column 3 -row 4 -sticky e
grid .f.baudRadio1 -column 4 -row 4 -sticky w
grid .f.baudLabel2 -column 5 -row 4 -sticky e
grid .f.baudRadio2 -column 6 -row 4 -sticky w
grid .f.baudLabel3 -column 7 -row 4 -sticky e
grid .f.baudRadio3 -column 8 -row 4 -sticky w
grid .f.baudLabel4 -column 9 -row 4 -sticky e
grid .f.baudRadio4 -column 10 -row 4 -sticky w
grid .f.submitBtn -column 1 -row 5 -columnspan 7 -sticky we
foreach w [winfo children .f] {grid configure $w -padx 5 -pady 5}
focus .f.colorimetric
.f.colorimetric state selected
.f.filterRadio1 state selected
.f.baudRadio1 state selected
bind . <Return> {finish}
proc getFilename1 {} {
set filename1 [tk_getSaveFile]
}
proc getFilename2 {} {
set filename2 [tk_getSaveFile]
}
proc finish {} {
.f.x insert 0 "-x"
.f.y insert 0 "-y"
# Pick one
# puts $colorimetric
# puts colorimetric
# puts "$colorimetric"
# puts $::colorimetric
# puts .f.colorimetric
# puts $.f.colorimetric
# puts $::.f.colorimetric
# puts "$::colorimetric"
exec ./gretag .f.colorimetric filename1 .f.spectral filename2 .f.gretagNum .f.x .f.y .f.filter .f.baud
}
</code></pre>
<hr>
<p><strong>Edit:</strong>
I've posted all the code rather than just part, and in the next to last line are the various syntaxes from option #1 that I've tried in order to view the values of the variables before they're passed to the next program. None of these are working and I don't understand why or how to fix it. I'm hoping another set of eyes will catch what's wrong.</p>
| [
{
"answer_id": 392313,
"author": "ConcernedOfTunbridgeWells",
"author_id": 15401,
"author_profile": "https://Stackoverflow.com/users/15401",
"pm_score": 0,
"selected": false,
"text": "[nigel@rose ~]$ wish\n% set foo /dev/ttys0\n/dev/ttys0\n% puts $foo\n/dev/ttys0\n% puts \"$foo\"\n/dev/t... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30924/"
] |
392,277 | <p>I'm trying to change the border color of an image using its id with jquery
( photo['id'] is passed in from a previous function )
the ids of the photos are of the form 'photo239839'</p>
<pre><code> $('#photo'+photo['id']+'').click(function(){
$('#photo'+photo['id']+'').css('border-color','#777');
});
</code></pre>
<p>When I try to use this same code using its class it works,
but I can't use this method since there are multiple images on the same
page with the same class</p>
<pre><code>$('img.flickr_photo').click(function() {
$("this.flickr_photo").css('border-color','#777');
});
</code></pre>
| [
{
"answer_id": 392293,
"author": "Andreas Grech",
"author_id": 44084,
"author_profile": "https://Stackoverflow.com/users/44084",
"pm_score": 4,
"selected": false,
"text": "$('img.flickr_photo').click(function(){ \n $(this).css('border-color','#777');\n});\n"
},
{
"answer_i... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48973/"
] |
392,283 | <p>What are your thoughts on using Windows Live Writer communicating with your website as the content editing system?</p>
<p>Windows Live Writer supports multiple category blogs (i.e. can be news, articles, and blogs), multiple category pages, tagging, XHTML WYSIWYG editing, image and file uploading via services or ftp, and the client has a "Insert HTML" plug-in library with a lot of already developed plug-ins for popular sites.</p>
<p>The trickiest part is implementing all of the XmlRpc methods in your services, but some digging with Reflector has exposed them as being pretty simple to implement the features.</p>
| [
{
"answer_id": 392293,
"author": "Andreas Grech",
"author_id": 44084,
"author_profile": "https://Stackoverflow.com/users/44084",
"pm_score": 4,
"selected": false,
"text": "$('img.flickr_photo').click(function(){ \n $(this).css('border-color','#777');\n});\n"
},
{
"answer_i... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392283",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13502/"
] |
392,304 | <p>Is there a way to test the quality of a hash function? I want to have a good spread when used in the hash table, and it would be great if this is verifyable in a unit test.</p>
<p><strong>EDIT</strong>: For clarification, my problem was that I have used <code>long</code> values in Java in such a way that the first 32 bit encoded an ID and the second 32 bit encoded another ID. Unfortunately Java's hash of long values just XORs the first 32 bit with the second 32 bits, which in my case led to very poor performance when used in a <code>HashMap</code>. So I need a different hash, and would like to have a Unit Test so that this problem cannot creep in any more.</p>
| [
{
"answer_id": 393143,
"author": "joel.neely",
"author_id": 3525,
"author_profile": "https://Stackoverflow.com/users/3525",
"pm_score": 0,
"selected": false,
"text": "HashMap<Long,String>"
}
] | 2008/12/24 | [
"https://Stackoverflow.com/questions/392304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48181/"
] |
392,314 | <p>I'm wondering if there's a way to save window configurations across emacs sessions. I know desktop-save is fantastic for preserving buffers and whatnot and the emacs manual demonstrates storing a window configuration into a register but this doesn't persist across sessions.</p>
<p>Of course this doesn't seem like it would be too hard to implement myself...</p>
| [
{
"answer_id": 30154472,
"author": "pors",
"author_id": 562267,
"author_profile": "https://Stackoverflow.com/users/562267",
"pm_score": 2,
"selected": false,
"text": "desktop-save-mode"
}
] | 2008/12/24 | [
"https://Stackoverflow.com/questions/392314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32797/"
] |
392,315 | <p>I want to use an IFrame in my ASP.Net MVC application, yet I want to retain the layout when the internal pages are navigated via direct access (Search Engine).</p>
<p>How would I switch the master page based on whether the View was in an IFrame, or a top level window?</p>
| [
{
"answer_id": 394413,
"author": "Eran Kampf",
"author_id": 1228206,
"author_profile": "https://Stackoverflow.com/users/1228206",
"pm_score": 3,
"selected": true,
"text": "if (isInIFrame)\n{\n ViewResult result = View();\n result.MasterName = \"IFrameMaster\";\n return result;\n... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13502/"
] |
392,324 | <p>I have an array of <code>int</code> pixels in my C# program and I want to convert it into an image. The problem is I am converting Java source code for a program into equivalent C# code. In java the line reads which displays the array of int pixels into image:</p>
<pre><code>Image output = createImage(new MemoryImageSource(width, height, orig, 0, width));
</code></pre>
<p><strong>can someone tell me the C# equivalent?</strong></p>
<p>Here orig is the array of <code>int</code> pixels. I searched the Bitmap class and there is a method called <code>SetPixel</code> but the problem is it takes a x,y coordinate number. But what I have in my code is an array of <code>int</code> pixels. Another weird thing is my orig array has negative number and they are way far away from 255. In Java this is the same case (meaning both the array in C# and Java have equivalent value) and the values is working fine in Java.</p>
<p>But I can't get that line translated into C#. Please help.</p>
| [
{
"answer_id": 392336,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 1,
"selected": false,
"text": "SetPixel"
},
{
"answer_id": 392342,
"author": "Frank Krueger",
"author_id": 338,
"author_profile"... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
392,327 | <p>How do I obtain a stack trace of addresses on Windows without using dbghelp.dll?</p>
<p>I don't need to know what the symbols or function names associated with the addresses, I just want the list of addresses -- something similar to <strong><a href="http://www.gnu.org/software/libtool/manual/libc/Backtraces.html" rel="nofollow noreferrer">backtrace of *nix systems</a></strong>. </p>
<p>Thanks!</p>
| [
{
"answer_id": 392350,
"author": "Kris Kumler",
"author_id": 4281,
"author_profile": "https://Stackoverflow.com/users/4281",
"pm_score": 3,
"selected": false,
"text": "USHORT WINAPI CaptureStackBackTrace(\n __in ULONG FramesToSkip,\n __in ULONG FramesToCapture,\n __out ... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19129/"
] |
392,332 | <p>I have a repository which I have <em>already</em> cloned from Subversion. I've been doing some work in this repository in its Git form and I would hate to lose that structure by cloning again.</p>
<p>However, when I originally cloned the repository, I failed to correctly specify the <code>svn.authors</code> property (or a semantically-similar option).</p>
<p>Is there any way I can specify the SVN author mappings now that the repository is fully Git-ified?</p>
<p>Preferably, I would like to correct all of the old commit authors to represent the Git author rather than the raw SVN username.</p>
| [
{
"answer_id": 392345,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": false,
"text": "git-filter-branch --commit-filter"
},
{
"answer_id": 392356,
"author": "Jörg W Mittag",
"author_id": 2988... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9815/"
] |
392,349 | <p>Is there any way to modify the bound value of one of the variables inside a closure? Look at the example to understand it better.</p>
<pre><code>def foo():
var_a = 2
var_b = 3
def _closure(x):
return var_a + var_b + x
return _closure
localClosure = foo()
# Local closure is now "return 2 + 3 + x"
a = localClosure(1) # 2 + 3 + 1 == 6
# DO SOME MAGIC HERE TO TURN "var_a" of the closure into 0
# ...but what magic? Is this even possible?
# Local closure is now "return 0 + 3 + x"
b = localClosure(1) # 0 + 3 +1 == 4
</code></pre>
| [
{
"answer_id": 392360,
"author": "titaniumdecoy",
"author_id": 18091,
"author_profile": "https://Stackoverflow.com/users/18091",
"pm_score": 0,
"selected": false,
"text": "def foo(var_a = 2, var_b = 3):\n def _closure(x):\n return var_a + var_b + x\n return _closure\n\nlocal... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4381/"
] |
392,371 | <p>Hi sorry for being annoying by rephrasing my question but I am just on the point of discovering my answer.</p>
<p>I have an array of <code>int</code> composed of RGB values, I need to decompose that <code>int</code> array into a byte array, but it should be in BGR order.</p>
<p>The array of int composed of RGB values is being created like so:</p>
<pre><code>pix[index++] = (255 << 24) | (red << 16) | blue;
</code></pre>
| [
{
"answer_id": 392379,
"author": "Can Berk Güder",
"author_id": 2119,
"author_profile": "https://Stackoverflow.com/users/2119",
"pm_score": 1,
"selected": false,
"text": "#define N something\nunsigned char bytes[N*3];\nunsigned int ints[N];\n\nfor(int i=0; i<N; i++) {\n bytes[i*3] ... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
392,375 | <p>I have two simple while loops in my program that I feel ought to be math equations, but I'm struggling to convert them:</p>
<pre><code>float a = someValue;
int b = someOtherValue;
int c = 0;
while (a <= -b / 2) {
c--;
a += b;
}
while (a >= b / 2) {
c++;
a -= b;
}
</code></pre>
<p>This code works as-is, but I feel it could be simplified into math equations. The idea here being that this code is taking an offset (someValue) and adjusting a coordinate (c) to minimize the distance from the center of a tile (of size someOtherValue). Any help would be appreciated.</p>
| [
{
"answer_id": 392382,
"author": "Dave L.",
"author_id": 3093,
"author_profile": "https://Stackoverflow.com/users/3093",
"pm_score": 1,
"selected": false,
"text": "c = ((int) a + b / 2 * sign(a)) / b\n"
},
{
"answer_id": 392388,
"author": "paranoidgeek",
"author_id": 4827... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43496/"
] |
392,376 | <p>I’m trying to publish an InfoPath form to a SharePoint document library, and have the form be viewable in a web browser.</p>
<p>The problem is that in the InfoPath publishing wizard tells me that although the form is browser compatible, that it cannot be browser enabled because of one of the following:</p>
<ul>
<li><p>The Server is not running InfoPath forms services </p></li>
<li><p>The necessary features are not available on the site collection</p></li>
<li><p>The policy setting on the server does not allow a user to browser enable forms.</p></li>
</ul>
<p>Well, I’ve verified that the SiteCollection has an active feature called “Office SharePoint Server Enterprise Site Collection features”, which includes Form Services, so I assume that the first two issues are not the cause</p>
<p>Also, I’ve verified in Central Admin that the Forms Services are configured to allow browser-compatible forms to be viewable in the web browser. So the 3rd reason doesn’t seem to make sense either. </p>
<p>I've tried applying different Security levels to the form: Restricted/Domain/Full Trust, but that doesn't seem to have an effect. I have been able to publish this form to a different SharePoint site, so I'm assuming that the issue is with the configuration of the SharePoint site, not the InfoPath form</p>
<p>Does anyone have any other ideas as to why this might not be working?</p>
<p>Thanks for any help you can provide!!</p>
| [
{
"answer_id": 392382,
"author": "Dave L.",
"author_id": 3093,
"author_profile": "https://Stackoverflow.com/users/3093",
"pm_score": 1,
"selected": false,
"text": "c = ((int) a + b / 2 * sign(a)) / b\n"
},
{
"answer_id": 392388,
"author": "paranoidgeek",
"author_id": 4827... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
392,397 | <p>As I was programming, I haven't seen an instance where an array is better for storing information than another form thereof. I had indeed figured the added "features" in programming languages had improved upon this and by that replaced them. I see now that they aren't replaced but rather given new life, so to speak.</p>
<p>So, basically, what's the point of using arrays? </p>
<p>This is not so much why do we use arrays from a computer standpoint, but rather why would we use arrays from a programming standpoint (a subtle difference). What the computer does with the array was not the point of the question.</p>
| [
{
"answer_id": 392426,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 10,
"selected": false,
"text": " MyArray [5]\n ^ ^\n Pointer Offset\n =====================================\n| 6 | 4 | 2 | 3 | 1 |... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48214/"
] |
392,416 | <p>When loaded a shared library is opened via the function <code>dlopen()</code>, is there a way for it to call functions in main program?</p>
| [
{
"answer_id": 392419,
"author": "hhafez",
"author_id": 42303,
"author_profile": "https://Stackoverflow.com/users/42303",
"pm_score": 2,
"selected": false,
"text": "/* in main app */\n\n/* define your function */\n\nint do_it( char arg1, char arg2);\n\nint do_it( char arg1, char arg2){\n... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392416",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46431/"
] |
392,425 | <p>I have got a byte array of pixels in BGR order and I want to create an image out of it in C#. Can anyone offer code or advice?</p>
| [
{
"answer_id": 392445,
"author": "user21826",
"author_id": 21826,
"author_profile": "https://Stackoverflow.com/users/21826",
"pm_score": 1,
"selected": false,
"text": "\n private Bitmap createImage(int width, int height, byte[] image)\n {\n int index = 0;\n ... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
392,431 | <p>In C#, if I want to serialize an instance with <code>XmlSerializer</code>, the object's type doesn't have to be marked with <code>[Serializable]</code> attribute. However, for other serialization approaches, such as <code>DataContractSerializer</code>, needs the class be marked as <code>[Serializable]</code> or <code>[DataContract]</code>.</p>
<p>Is there any standard or pattern about serialization requirement?</p>
| [
{
"answer_id": 393619,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": false,
"text": "XmlSerializer DataContractSerializer Parent [XmlSerializer [DataContractSerializer] [Serializable] [DataContract] [IX... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26349/"
] |
392,438 | <p>i'm relatively new to jquery and javascript and am trying to pass
a unique id (number) into a flickr search function (jquery.flickr-1.0-js) like so, (number is the variable where i'm storing the unique id)</p>
<pre><code><script type="text/javascript" src="javascripts/jquery.flickr-1.0.js"></script>
<script type="text/javascript">
jQuery(function(){
jQuery(".btnRefresh").click(function(){
var number = $(this).attr("id");
$('#gallery_flickr_'+number+'').show();
jQuery('#gallery_flickr_'+number+'').html("").flickr({
api_key: "XXXXXXXXXXXXXXXXXXXXXXX",
per_page: 15
});
});
});
</script>
</code></pre>
<p>When i try to pass it in to the flickr-1.0.js function like so (abbreviated)</p>
<pre>
(function($) {
$.fn.flickr = function(o){
var s = {
text: $('input#flickr_search_'+number+'').val(),
};
};
})(jQuery);
</pre>
<p>i get a error</p>
<p>number is not defined
[Break on this error] text: $('input#flickr_search_'+numbe...] for type=='search' free text search</p>
<p>please help, what do i need to do to pass the variable between the two scripts?</p>
<p>Thanks,</p>
| [
{
"answer_id": 392459,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": true,
"text": " ...\n jQuery('#gallery_flickr_'+number+'').html(\"\").flickr({ \n api_key: \"XXXXXXX... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392438",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48973/"
] |
392,449 | <p>I recently found out about <a href="http://en.wikipedia.org/wiki/Livecoding#Live_coding" rel="noreferrer">livecoding</a> where someone will program something on the fly to make music. Apparently there are special languages and libraries for this sort of thing. So I'd like to know if anyone has any experience with it and if they have any languages, libraries or tools to suggest.</p>
| [
{
"answer_id": 41822282,
"author": "Bruno",
"author_id": 1253735,
"author_profile": "https://Stackoverflow.com/users/1253735",
"pm_score": 2,
"selected": false,
"text": "loop do\n sample :perc_bell, rate: (rrand 0.125, 1.5)\n sleep rrand(0, 2)\nend\n"
}
] | 2008/12/25 | [
"https://Stackoverflow.com/questions/392449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25680/"
] |
392,455 | <p>Suppose I have a Linked List I created myself. It has its own destructor, which frees the memory. This Linked List does not overload new or delete.</p>
<p>Now, I'm trying to create an array of said linked lists (open hashing, if I understand correctly). Then I allocate the necessary memory inside the constructor of this open hashing class. The new operator being called inside the constructor is enough to correctly allocate the memory for the array, right? I'm not sure because I haven't overloaded new for the Linked List class.</p>
<p>Also, assuming my array of Linked Lists is called elements, could I just write "delete[] elements" in the destructor? Would that call the destructor for each element in the array and correctly free the memory?</p>
<p>Finally, if both my assumptions are correct (ie, I don't have to overload new and delete to use them with my custom class), what is the point of overloading such operators?</p>
| [
{
"answer_id": 392457,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 3,
"selected": false,
"text": "elements = new LinkedList[N];\n elements[i]->push(....);\n delete[] elements;\n ....\nprivate:\n MyHashM... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
392,464 | <p>I'd like to do <code>base64</code> encoding and decoding, but I could not find any support from the iPhone <code>SDK</code>. How can I do <code>base64</code> encoding and decoding with or without a library?</p>
| [
{
"answer_id": 800976,
"author": "Alex Reynolds",
"author_id": 19410,
"author_profile": "https://Stackoverflow.com/users/19410",
"pm_score": 7,
"selected": false,
"text": "#import <Foundation/NSString.h>\n\n@interface NSString (NSStringAdditions)\n\n+ (NSString *) base64StringFromData:(N... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32096/"
] |
392,473 | <p>The issue is simple really. Instead of creating folders in Visual Studio, I create a directory structure for my project on the file system. How do I include all the folders and files in a project, keeping the structure?</p>
<p>If I "Add Existing File" on a folder named Services and navigate to a file in the directory structure .. Services > AccountManagement > CreateAccount.cs, it appears in Visual Studio like so: Services > CreateAccount.cs. I do not want this.</p>
<p>I have an entire directory structure worked out already, as I am mimicking our client developers using the same structure for organization. How do I add all the folders and files to the project in Visual Studio? Or do I have to do what most Microsoft users do and "put up with it" and recreate each and every folder through Visual Studio?</p>
| [
{
"answer_id": 35632703,
"author": "Yuchen",
"author_id": 1035008,
"author_profile": "https://Stackoverflow.com/users/1035008",
"pm_score": 6,
"selected": false,
"text": "<Content Include=\"Path\\To\\Folder\\**\" />\n <Content Include=\"Path\\To\\Folder\\*.*\" />\n <Content Include=\"Pat... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392473",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/580/"
] |
392,493 | <blockquote>
<p>SQLite3::SQLException: SQL logic error
or missing database</p>
</blockquote>
<p>error when do insert, update and delete operation to tables from browser( that means the create, update and destroy action is failed but the show action is fine ), the same operation in console is OK. I googled this problem and found most of the solutions is to remove duplication in the fixtures, so I removed all the test data from the fixture and restart the server, and it failed again:(<br>
Any advise is appreciated.</p>
| [
{
"answer_id": 392536,
"author": "eric2323223",
"author_id": 44512,
"author_profile": "https://Stackoverflow.com/users/44512",
"pm_score": 3,
"selected": true,
"text": "\"sudo script/server\""
},
{
"answer_id": 59991823,
"author": "Peter Beecken",
"author_id": 10352180,
... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44512/"
] |
392,513 | <p>I've created an interface called Initializable, but according to <a href="http://dictionary.reference.com/browse/initializable" rel="noreferrer">Dictionary.com</a> this is not a word. Searching <a href="http://www.google.ca/search?q=initializable" rel="noreferrer">Google</a> only gives about 30k results and they are mostly API references.</p>
<p>Is there another word to describe something that can be initialized (which <strong>is</strong> a word)?</p>
<p><strong>Edit:</strong></p>
<p>Thanks for the questions about it being in the constructor, that may be a better way. Right now they are static classes (as static as can be in Ruby) that get loaded dynamically and have some initilization stuff to do.</p>
| [
{
"answer_id": 392521,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 2,
"selected": false,
"text": "Initializable Initializable"
},
{
"answer_id": 392523,
"author": "Kev",
"author_id": 419,
"author... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32465/"
] |
392,539 | <p>How to download a file via web service ? And how the client application accept this?
I write down the code as below in the client app, it throws an exception "Access Denied"</p>
<pre><code>wsDownload.wsDownloadFile downFile = new wsDownload.wsDownloadFile();
byte[] file = downFile.DownloadFile(strFileName, "", "", "");
MemoryStream mStream = new MemoryStream(file);
</code></pre>
<p>any response is appreciated.</p>
| [
{
"answer_id": 392521,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 2,
"selected": false,
"text": "Initializable Initializable"
},
{
"answer_id": 392523,
"author": "Kev",
"author_id": 419,
"author... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
392,540 | <p>I'm currently trying to make a small application that performs different duties. Right now I have a console app pop up and ask what I want to do, but sometimes I would rather just launch it with something like MyApp.exe -printdocuments or some such thing. </p>
<p>Are there any tutorials out there that can show me a simple example of this?</p>
| [
{
"answer_id": 392548,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 4,
"selected": true,
"text": "main() argc argv argc argv argc #include <stdio.h>\n\nint main(int argc, char *argv[])\n{\n for (int i = 0; i < argc; i... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49000/"
] |
392,550 | <p>I used pole display(E POS) in my POS c# application.I have two major problem in that,
1. I can't clear the display perfectly.
2. I can't set the cursor position.</p>
<pre><code> I used some dirty tricks to do these.But I am not satisfied with that code.The following code i used.
</code></pre>
<p>Code :-</p>
<pre><code>class PoleDisplay : SerialPort
{
private SerialPort srPort = null;
public PoleDisplay()
{
try
{
srPort = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
if (!srPort.IsOpen) srPort.Open();
}
catch { }
}
~PoleDisplay()
{
srPort.Close();
}
//To clear Display.....
public void ClearDisplay()
{
srPort.Write(" ");
srPort.WriteLine(" ");
}
//Display Function
//'line' 1 for First line and 0 For second line
public void Display(string textToDisplay, int line)
{
if (line == 0)
srPort.Write(textToDisplay);
else
srPort.WriteLine(textToDisplay);
}
}
</code></pre>
| [
{
"answer_id": 392548,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 4,
"selected": true,
"text": "main() argc argv argc argv argc #include <stdio.h>\n\nint main(int argc, char *argv[])\n{\n for (int i = 0; i < argc; i... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49001/"
] |
392,594 | <p>This is something of a rant, as well as a question.</p>
<p>There are some sites, like Facebook, where you would only want to be logged into one account at a time. </p>
<p>But everything from blogging sites to email always force you to logout before you can login to another account.</p>
<p>And I understand the security implications, and how it would make cookie-based sessions a little more complex, but why don't we see more of this? </p>
<p>Why would multiple users from a single client at once be a bad idea? </p>
| [
{
"answer_id": 392603,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 2,
"selected": false,
"text": "foo.bar?thread=2 thread=1"
}
] | 2008/12/25 | [
"https://Stackoverflow.com/questions/392594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9106/"
] |
392,626 | <p>I had a Dataset with some data in it. When I tried to write this DataSet into a file, everything was OK. But When I tried to write it into a MemoryStream, the XML file declaration was lost.
The code looks like:</p>
<pre><code>DataSet dSet = new DataSet();
//load schema, fill data in
dSet.WriteXML("testFile.xml");
MemoryStream stream = new MemoryStream();
dSet.WriteXML(stream);
stream.Seek(0,SeekOrigin.Begin);
</code></pre>
<p>When I opened file testFile.xml, I got:</p>
<pre><code><?xml version="1.0" standalone="yes"?>
//balabala
</code></pre>
<p>But When I open the stream with StreamReader, I only got:</p>
<pre><code>//balabala
</code></pre>
<p>Somebody said I can insert XML file declaration in my stream manually. It works but seems so ugly. Do you know why it dropped the first line and any more simple solution?</p>
| [
{
"answer_id": 688487,
"author": "Kenneth Cochran",
"author_id": 71200,
"author_profile": "https://Stackoverflow.com/users/71200",
"pm_score": 3,
"selected": true,
"text": "MemoryStream stream = new MemoryStream();\nvar writer = XmlWriter.Create(stream);\nwriter.WriteStartDocument(true);... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40029/"
] |
392,630 | <p>one of my php page returns data like this:</p>
<pre><code><?php
//...
echo "json string";
?>
</code></pre>
<p>but someone else use file_get_contents() to get my data and use in other website.</p>
<p>can anybody tell me what can i do to prevent such thing happen. </p>
<p>i consider if i can get the request's domain name to echo something else.but i dont know </p>
<p>the function to get request's domain name.and if the request is sent by a server,that </p>
<p>will be unhelpful. My English is poor, to express doubts, please bear with.</p>
| [
{
"answer_id": 392680,
"author": "Pim Jager",
"author_id": 35197,
"author_profile": "https://Stackoverflow.com/users/35197",
"pm_score": 1,
"selected": false,
"text": "<?php\n $allowedFiles[] = 'somefile.php';\n $allowedFiles[] = 'someotherFile.php';\n $allowedFiles[] = 'jsonReturnFile.p... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
392,643 | <p>I would like to do the following:</p>
<pre><code>$find = "start (.*) end";
$replace = "foo \1 bar";
$var = "start middle end";
$var =~ s/$find/$replace/;
</code></pre>
<p>I would expect $var to contain "foo middle bar", but it does not work. Neither does:</p>
<pre><code>$replace = 'foo \1 bar';
</code></pre>
<p>Somehow I am missing something regarding the escaping.</p>
| [
{
"answer_id": 392649,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 4,
"selected": false,
"text": "$find = 'start (.*) end';\n$replace = \"foo \\cA bar\";\n$var = 'start middle end';\n$var =~ s/$find/$replace/;\n /$... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2133/"
] |
392,654 | <p>I am using 2 500K bitmaps in to display images on my WiX dialogs.</p>
<p>They dramatically increase the size of the installation package, and what is worse - it looks there's no way to package them as a part of a .cab file since they're <code><binary></code>-es in the WiX terms.</p>
<p>So, I thught, is there any way to use other file formats for bitmaps or WiX is tethered with BMP? Ideally it would be greate if there's a way to use .png format since it comes with a looseless compression option.</p>
| [
{
"answer_id": 38578388,
"author": "ahmd0",
"author_id": 670017,
"author_profile": "https://Stackoverflow.com/users/670017",
"pm_score": 1,
"selected": false,
"text": ".jpeg PNG BMPs .bmp"
}
] | 2008/12/25 | [
"https://Stackoverflow.com/questions/392654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48829/"
] |
392,657 | <p>In borland delphi 7 and even in delphi 2007 everything worked, but in delphi 2009 it just returns the wrong hash!</p>
<p>I use wcrypt2 script (<a href="http://pastebin.com/m2f015cfd" rel="noreferrer">http://pastebin.com/m2f015cfd</a>)</p>
<p>Just have a look:</p>
<p>string : "123456"</p>
<p>hash:</p>
<p>Delphi 7 : "e10adc3949ba59abbe56e057f20f883e" - real hash. <br>
Delphi 2007 : "e10adc3949ba59abbe56e057f20f883e" - real hash too.<br>
And...
Delphi 2009 : "5fa285e1bebe0a6623e33afc04a1fbd5" - WTF??</p>
<p>I've tried a lot of md5 scripts, but delphi 2009 does the same with all of them. Any help? Thanks.</p>
| [
{
"answer_id": 392681,
"author": "Mihai Limbășan",
"author_id": 14444,
"author_profile": "https://Stackoverflow.com/users/14444",
"pm_score": 0,
"selected": false,
"text": "PAnsiChar(AnsiString('123456'))\n"
},
{
"answer_id": 392745,
"author": "Jim McKeeth",
"author_id": ... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
392,668 | <p>I'm trying to model a basic scenario involving a Person and a Seat. A Person has a Status property: Sitting or Standing. A seat has a Seated property that specifies the Person that is currently sitting in it. Also, a Seat is <em>special</em> in that it only "accepts" certain people to sit in it. I know it sounds strange for a Seat to "accept" someone, but just imagine it prefers certain people over others.</p>
<p>Following "<a href="http://www.pragprog.com/articles/tell-dont-ask" rel="noreferrer">Tell, Don't Ask</a>," How should I design the Person and Seat objects so that a Person can sit down in a Seat only when the Seat "accepts" him and also have his status changed to Sitting. My first thought was that a Person should have a SitDown method as follows:</p>
<pre><code>Person.SitDown(Seat seat);
</code></pre>
<p>But this seems like it would require the Person class to inspect the state of the Seat before sitting in it, as well as having to update the Seat's Seated property (instead of the Seat updating the property itself):</p>
<pre><code>// inside the Person class
void SitDown(Seat seat) {
if (seat.AcceptsPlayer(this)) {
seat.Seated = this;
this.Status = Sitting;
}
}
</code></pre>
<p>It seems better to have the Seat class handle seating a person:</p>
<pre><code>Seat.SeatPerson(Person person);
// inside Seat class
void SeatPerson(Person person) {
if (IsAccepted(person)) {
this.Seated = person;
person.Status = Sitting;
}
}
</code></pre>
<p>But this still requires the Seat to change the person's status. Is this the way that the person's status should be updated? Should only a Person be able to change his status? How would you model this simple scenario?</p>
| [
{
"answer_id": 392677,
"author": "Brann",
"author_id": 47341,
"author_profile": "https://Stackoverflow.com/users/47341",
"pm_score": -1,
"selected": false,
"text": "//inside Person class\n public bool TrySeat(Seat seat)\n {\n if (seat.TrySeat(this))\n ... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49027/"
] |
392,678 | <p>I've some questions .. and I really need your help.</p>
<ol>
<li><p>I have an application. </p>
<p>First I display a splash screen, a form, and this splash would call another form. </p>
<p><strong>Problem</strong>: When the splash form is displayed, if I then open another application on the top of the splash, and then minimize this newly opened application window, the splash screen becomes white. How do I avoid this? I want my splash to be displayed clearly and not affected by any application.</p></li>
<li><p>I'm using a DropDownList but I realized that there is 2 types of it . I found "Dropdown" which makes the text inside the DDL editable, and "DropDownList" which doesn't. </p>
<p><strong>Problem</strong>: when I tried to use DropDownList control it doesn't allow me to add a default text while DropDown does so I want a DropDownList control which prevent modifying on the text and allow a default text .. what property should I use?</p></li>
<li><p>Can I add "?" which denotes to Help button to the FormBorder (with the minimization, maximization, and close buttons )</p></li>
<li><p>Can I change the colour of the Formborder from its default colour (blue) ?</p></li>
<li><p>One of my application functionality is to copy files from server to phone into a certain folder in memory card.</p>
<p><strong>Problem</strong> : can I determine the free size of the MMC to notify the user if it's full while copying.</p></li>
</ol>
| [
{
"answer_id": 392684,
"author": "Ed S.",
"author_id": 1053,
"author_profile": "https://Stackoverflow.com/users/1053",
"pm_score": 1,
"selected": false,
"text": "dropDownList.SelectedIndex = 0;\n"
}
] | 2008/12/25 | [
"https://Stackoverflow.com/questions/392678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42782/"
] |
392,721 | <p>What's difference between <strong>shadowing</strong> and <strong>overriding</strong> a method in C#?</p>
| [
{
"answer_id": 392727,
"author": "Stormenet",
"author_id": 2090,
"author_profile": "https://Stackoverflow.com/users/2090",
"pm_score": 8,
"selected": true,
"text": "class A {\n public int Foo(){ return 5;}\n public virtual int Bar(){return 5;}\n}\nclass B : A{\n public new int Foo(... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35425/"
] |
392,728 | <p>I have a function that returns a float from 0 to 255. I would like to make a gradient in red color from this, but I need a string in "#FFFFFF" format. Is there a function for that?</p>
| [
{
"answer_id": 392732,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 5,
"selected": true,
"text": "\"#%02X0000\" % x\n"
},
{
"answer_id": 392976,
"author": "edef",
"author_id": 49047,
"author_profile":... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25459/"
] |
392,733 | <p>For those of you experienced in both Haskell and some flavor of Lisp, I'm curious how "pleasant" (to use a horrid term) it is to write code in Haskell vs. Lisp.</p>
<p>Some background: I'm learning Haskell now, having earlier worked with Scheme and CL (and a little foray into Clojure). Traditionally, you could consider me a fan of dynamic languages for the succinctness and rapidity they provide. I quickly fell in love with Lisp macros, as it gave me yet another way to avoid verbosity and boilerplate.</p>
<p>I'm finding Haskell <strong>incredibly</strong> interesting, as it's introducing me to ways of coding I didn't know existed. It definitely has some aspects that seem like they would aid in achieving agility, like ease of writing partial functions. However, I'm a bit concerned about losing Lisp macros (I assume I lose them; truth be told I may have just not learned about them yet?) and the static typing system.</p>
<p>Would anyone who has done a decent amount of coding in both worlds mind commenting on how the experiences differ, which you prefer, and if said preference is situational?</p>
| [
{
"answer_id": 2322552,
"author": "Hibou57",
"author_id": 279335,
"author_profile": "https://Stackoverflow.com/users/279335",
"pm_score": 3,
"selected": false,
"text": "(defmacro doif (x y) `(if ,x ,y))\n doif x y = if x then (Just y) else Nothing\n"
}
] | 2008/12/25 | [
"https://Stackoverflow.com/questions/392733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38803/"
] |
392,749 | <p>Code auto-generated by Xcode seems to have the opening brace on the same line by default:</p>
<pre><code>@interface Controller : NSObject {
}
</code></pre>
<p>I'd like the opening brace on a line of its own, like this:</p>
<pre><code>@interface Controller : NSObject
{
}
</code></pre>
<p>This applies in general to any method / class auto-generated by Xcode. In Xcode preferences I have "Indent solo { by" set to 0:
<a href="https://i.stack.imgur.com/XOVVe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XOVVe.png" alt="alt text"></a>
</p>
<p>How can I fix this?</p>
| [
{
"answer_id": 393020,
"author": "Mike Shields",
"author_id": 29030,
"author_profile": "https://Stackoverflow.com/users/29030",
"pm_score": 3,
"selected": false,
"text": " XCCodeSenseFormattingOptions = {\n BlockSeparator = \"\\\\n\";\n PreMethodDeclSpacing = \"\";\n};\n"
... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2288585/"
] |
392,775 | <p>How can I indicate syntax errors (e.g. an illegal sequence of tokens) in an eclipse editor plugin just like in the eclipse Java editor, i.e. by red wriggly underlines, a red marker on the scrollbar that you can jump to, and an explanatory message when you hover over either one?</p>
<p>I'm writing an eclipse editor plugin for a custom file format (specifically, the "snake file format" of the Shark3D game engine). I have implemented a scanner to get syntax highlighting, and an outline. </p>
<ul>
<li>For the underlines, do I simply have the scanner return an <code>IToken</code> with a "wriggly underline" <code>TextAttribute</code> instead of the normal one, or is there a specific mechanism for marking syntax errors? </li>
<li>How do I implement the scrollbar markers? Is <code>IAnnotationModel</code> the relevant interface here? If so, where do I register the implementation so that the markers appear? </li>
<li>I've only found <code>SourceViewerConfiguration.getAnnotationHover()</code>, which would allow me to implement the hover behaviour, but only for the "annotation", which I suppose means the scrollbar markers - how do I implement the hover behaviour for the text itself?</li>
</ul>
<p>I'd be happy specific advice as well as an URL of a tutorial that covers this - the eclipse help documents and examples don't seem to.</p>
<p><strong>Edit:</strong>
Markers are the best solutions to this. A working example of how to use them can be found in the plugin example code in <code>org.eclipse.ui.examples.readmetool.AddReadmeMarkerAction</code></p>
| [
{
"answer_id": 393326,
"author": "Michael Rutherfurd",
"author_id": 33889,
"author_profile": "https://Stackoverflow.com/users/33889",
"pm_score": 4,
"selected": true,
"text": "<extension point=\"org.eclipse.core.resources.markers\" \n id=\"snakesyntax\" \n name=\"... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16883/"
] |
392,784 | <p>I have two completely different forms in one template. How to process them in one view? How can I distinguish which of the forms was submitted? How can I use prefix to acomplish that? Or maybe it's better to write separate views?<br /><br />
regards<br />
chriss</p>
| [
{
"answer_id": 392801,
"author": "Aaron Maenpaa",
"author_id": 2603,
"author_profile": "https://Stackoverflow.com/users/2603",
"pm_score": 4,
"selected": true,
"text": "<form action=\"/blog/\" method=\"POST\">\n {{ blog_form.as_p }}\n <input type=\"hidden\" name=\"form-type\" value... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36832/"
] |
392,787 | <p>I have an application. </p>
<p>First I display a splash screen, a form, and this splash would call another form. </p>
<p>Problem: When the splash form is displayed, if I then open another application on the top of the splash, and then minimize this newly opened application window, the splash screen becomes white. How do I avoid this? I want my splash to be displayed clearly and not affected by any application.</p>
| [
{
"answer_id": 392800,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "Application.Run(splash)"
},
{
"answer_id": 393866,
"author": "Hans Passant",
"author_id": 17034,
"aut... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42782/"
] |
392,789 | <p>I got into Perl years ago and always found it a fun and expressive language to work with.</p>
<p>I found that programming in Perl makes me quite productive thanks to its low overhead and the outstanding amount of ready-made solutions to common problems on CPAN.</p>
<p>If you're new to Perl, what got you into it?</p>
| [
{
"answer_id": 396515,
"author": "Gaurav",
"author_id": 27310,
"author_profile": "https://Stackoverflow.com/users/27310",
"pm_score": 4,
"selected": true,
"text": "if($expr) { $statement; } $statement if $expr; sub doSomething {\n my($toObject, $argument) = @_;\n\n die \"No object ... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3811/"
] |
392,794 | <p>I'm trying to deploy my WCF web service to a free host to test it, but it gives me the following error:</p>
<blockquote>
<p><strong>The Binding with name WSDualHttpBinding failed validation because the Binding type System.ServiceModel.WSDualHttpBinding is not supported in partial trust. Consider using BasicHttpBinding or WSHttpBinding, or hosting your application in a full-trust environment.</strong></p>
</blockquote>
<p>Any ideas how can I set my hosting environment to Full-Trust or any other ways to solve this?</p>
| [
{
"answer_id": 30617155,
"author": "JD-V",
"author_id": 3664961,
"author_profile": "https://Stackoverflow.com/users/3664961",
"pm_score": 0,
"selected": false,
"text": " <configuration> \n <system.web> \n <trust level=\"Full\" /> \n </system.web> \n </configuration>\n"
}
] | 2008/12/25 | [
"https://Stackoverflow.com/questions/392794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34623/"
] |
392,796 | <p>I understand (I think) that XmlHttpRequest objects adhere to the "same-domain" policy. However, I want to create a simple (POC) local html file that downloads XML from a web server and does something with it (let's start with a simple "alert()").</p>
<p>Is it possible at all? Do I need a special Firefox config option?</p>
<p>The server from which I'm trying to download is <strong>not</strong> under my control (it's actually a Google API).</p>
<p>My simple attempt is the code from <a href="https://developer.mozilla.org/En/Using_XMLHttpRequest#Example.3a.c2.a0Synchronous_request" rel="nofollow noreferrer">Mozilla's "Using XMLHttpRequest" page</a>. It returns an error I don't really understand from the "send" method.</p>
<p>Disclaimer: I'm mainly a C/C++ developer - never done any serious JS programming, never tried using these APIs.</p>
| [
{
"answer_id": 392803,
"author": "Bullines",
"author_id": 27870,
"author_profile": "https://Stackoverflow.com/users/27870",
"pm_score": 1,
"selected": false,
"text": "<script type=\"text/javascript\" src=\"http://www.google.com/jsapi?key=your_google_api_key\"></script>\n <script type=\"t... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38557/"
] |
392,797 | <p>How do I add a badge to the Dock icon for my app using Cocoa? Is there any roughly "standardized" way to do this? </p>
<p>(I'm referring to the kind of badges that show up in Mail, iChat etc. to indicate the number of unread messages and the like.)</p>
<p>Cocoa Touch does provide one such method, but I haven't been able to find any equivalent for a regular Cocoa application.</p>
| [
{
"answer_id": 393449,
"author": "Ashley Clark",
"author_id": 4556,
"author_profile": "https://Stackoverflow.com/users/4556",
"pm_score": 5,
"selected": false,
"text": "-setApplicationIconImage: dockTile NSDockTile *tile = [[NSApplication sharedApplication] dockTile];\n[tile setBadgeLabe... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2288585/"
] |
392,806 | <p>The project currently I am working in requires a lot of searhing/filtering pages. For example I have a comlex search page to get Issues by data,category,unit,...</p>
<p>Issue Domain Class is complex and contains lots of value objects and child objects.</p>
<p>.I am wondering how people deal with Searching/Filtering/Reporting for UI. As far As I know I have 3 options but none of them make me happier.</p>
<p>1.) Send parameters to Repository/DAO to Get DataTable and Bind DataTable to UI Controls.For Example to ASP.NET GridView</p>
<pre><code>DataTable dataTable =issueReportRepository.FindBy(specs);
.....
grid.DataSource=dataTable;
grid.DataBind();
</code></pre>
<p>In this option I can simply by pass the Domain Layer and query database for given specs. And I dont have to get fully constructed complex Domain Object. No need for value objects,child objects,.. Get data to displayed in UI in DataTable directly from database and show in the UI.</p>
<p>But If have have to show a calculated field in UI like method return value I have to do this in the DataBase because I don't have fully domain object. I have to duplicate logic and DataTable problems like no intellisense etc...</p>
<p>2.)Send parameters to Repository/DAO to Get DTO and Bind DTO to UI Controls.</p>
<pre><code>IList<IssueDTO> issueDTOs =issueReportRepository.FindBy(specs);
....
grid.DataSource=issueDTOs;
grid.DataBind();
</code></pre>
<p>In this option is same as like above but I have to create anemic DTO objects for every search page. Also For different Issue search pages I have to show different parts of the Issue Objects.IssueSearchDTO, CompanyIssueTO,MyIssueDTO....</p>
<p>3.) Send parameters to Real Repository class to get fully constructed Domain Objects.</p>
<pre><code>IList<Issue> issues =issueRepository.FindBy(specs);
//Bind to grid...
</code></pre>
<p>I like Domain Driven Design and Patterns. There is no DTO or duplication logic in this option.but in this option I have to create lot's of child and value object that will not shown in the UI.Also it requires lot's ob join to get full domain object and performance cost for needles child objects and value objects.</p>
<p>I don't use any ORM tool Maybe I can implement Lazy Loading by hand for this version but It seems a bit overkill.</p>
<p>Which one do you prefer?Or Am I doing it wrong? Are there any suggestions or better way to do this?</p>
| [
{
"answer_id": 486442,
"author": "ssmith",
"author_id": 13729,
"author_profile": "https://Stackoverflow.com/users/13729",
"pm_score": 3,
"selected": true,
"text": "private Foo _foo;\npublic Foo Foo\n{ \n get { \n if(_foo == null)\n {\n _foo = _repository.Get... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36474/"
] |
392,812 | <p>Normally, I run Linux in a VM, however, most of my VMs are on an external HDD and I might or might not have one with me. I figure Cygwin would be a good alternative for lightweight functionality when I need something Linux like and don't have a VM on my laptop. But I'm having trouble getting the configuration right - I want the bare minimum for development + X11. Has anyone used Cygwin in this manner? If so, what suggestions do you have?</p>
| [
{
"answer_id": 29291849,
"author": "dimo414",
"author_id": 113632,
"author_profile": "https://Stackoverflow.com/users/113632",
"pm_score": 5,
"selected": false,
"text": "apt-cyg apt-cyg bash-completion lynx apt-cyg wget curl vim hg git svn git-svn diffutils patchutils python python3"
}... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/572/"
] |
392,818 | <p>I use this code to open refresh save and close excel file:</p>
<pre><code>Application excelFile = new Application();
Workbook theWorkbook = excelFile.Workbooks._Open(Environment.CurrentDirectory + "/WebGate", 0, false, 5, System.Reflection.Missing.Value, System.Reflection.Missing.Value, false, System.Reflection.Missing.Value, System.Reflection.Missing.Value, true, false, System.Reflection.Missing.Value, false);
Sheets sheets = (Sheets)theWorkbook.Worksheets;
theWorkbook.RefreshAll();
theWorkbook.Save();
excelFile.Quit();
</code></pre>
<p>the problem is that there is a conflict between the refresh and save commands because the file is been save while the refresh is been done in the background (I guess)
can anyone help me with this? i need to know how can I know when the refresh proccess is done or any other indication that will help my to decide when should I save the file without harm the refresh proccess </p>
| [
{
"answer_id": 394268,
"author": "Adarsha",
"author_id": 28373,
"author_profile": "https://Stackoverflow.com/users/28373",
"pm_score": 2,
"selected": false,
"text": "Dim oPivot As PivotTable\nset oPivot=worksheets(\"xyz\").PivotTables(\"Pivot1\") \noPivot.PivotCache.BackgroundQuery = Fal... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
392,832 | <p>I am new to C# and .NET programming. I want to design an application that opens up with a small login screen and when user presses the "Login" button, my program should close the login form and pass to a new form. How can I achieve this simple process? </p>
<p>Thanks.</p>
| [
{
"answer_id": 392854,
"author": "Ali Ersöz",
"author_id": 4215,
"author_profile": "https://Stackoverflow.com/users/4215",
"pm_score": 4,
"selected": true,
"text": "public bool IsLoggedIn { get; private set;}\npublic void LoginButton_Click(object sender, EventArgs e)\n{\n IsLoggedIn = D... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49057/"
] |
392,859 | <p>How to create the condition of stack overflow in GNU/linux?</p>
| [
{
"answer_id": 392866,
"author": "Jason",
"author_id": 10639,
"author_profile": "https://Stackoverflow.com/users/10639",
"pm_score": 4,
"selected": false,
"text": "void stack_overflow()\n{\n stack_overflow();\n}\n"
},
{
"answer_id": 392867,
"author": "cletus",
"author_i... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
392,864 | <p>I still have a problem with the splash screen. I don't want to use the property <code>SC.TopMost=true</code>.</p>
<p>Now my application scenario is as follows:</p>
<p><strong>in progeram.cs:</strong></p>
<pre><code>[STAThread]
static void Main()
{
new SplashScreen(_tempAL);// where _tempAL is an arrayList
Application.Run(new Form1(_tempAL));
}
</code></pre>
<p><strong>in SplashScreen class:</strong></p>
<pre><code>public SplashScreen(ArrayList _Data)
{
DisplaySplash()
}
private void DisplaySplash()
{
this.Show();
this.TopMost = true;
this.CenterToScreen();
this.SetTopLevel(true);
_allServerNarrators = new string[10];
for (int i = 0; i < _allServerNarrators.Length; i++)
_allServerNarrators[i] = null;
GetFromServer();
this.Hide();
_serverData = new ArrayList();
_thisData.Add(_allServerNarrators);
_thisData.Add(_serverNarrators);
}
private void GetFromServer()
{
_serverNarrators = new ArrayList();
string _file = "Suras.serverNar";
if (!Directory.Exists("c:\\ASGAQuraan"))
Directory.CreateDirectory("c:\\ASGAQuraan");
while (counter < 4 && _serverFiles == null)
{
if (Download("c:\\ASGAQuraan", _ftpServerIP, _file))
{
StreamReader _strReader = new StreamReader
("c:\\ASGAQuraan\\"+_file,System.Text.Encoding.Default);
string _line = _strReader.ReadLine();
string _word;
while (true)
{
while (_line != null)
{
_word = _line.Substring(0, _line.IndexOf("*"));
int _narId = Convert.ToInt32(_word);
_line = _line.Substring(2);
int k = 0;
_serverNarratorNode = new ArrayList();
while (true)
{
int ind = _line.IndexOf("*");
if (ind > 0 && ind < _line.Length)
{
string str = _line.Substring(0, (ind));
if (k == 0)
{
_allServerNarrators[_narId] = str;
_serverNarratorNode.Add(str);
}
else
{
_serverNarratorNode.Add(str);
}
_line = _line.Substring(ind + 1);
k++;
}
else
{
_line = null;
break;
}
}
_serverNarrators.Add(_serverNarratorNode);
_serverFiles = "added";
}
_line = _strReader.ReadLine();
if (_line == null)
{
break;
}
}
}
else
counter++;
}
}
</code></pre>
<p>What I want is something in the splash screen class which waits until the thread finishes.</p>
<p>For more details, please tell me what I need to tell you.</p>
| [
{
"answer_id": 392905,
"author": "lc.",
"author_id": 44853,
"author_profile": "https://Stackoverflow.com/users/44853",
"pm_score": 1,
"selected": false,
"text": "GetFromServer() BackgroundWorker this.Hide();\n _serverData = new ArrayList();\n _thisData.Add(_allServerNarrators);... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42782/"
] |
392,931 | <p>I have a few procedures, for simplicity sake, look like the following:</p>
<pre><code>public string FetchValueAsString(string key)
public int FetchValueAsInteger(string key)
public bool FetchValueAsBoolean(string key)
public DateTime FetchValueAsDateTime(string key)
</code></pre>
<p>I know I could just have one method that returns and object type and just do a conversion, but I'm wondering if there is a way I can just have one method called, and somehow use generics to determine the return value ... possible?</p>
| [
{
"answer_id": 392948,
"author": "Corin Blaikie",
"author_id": 1736,
"author_profile": "https://Stackoverflow.com/users/1736",
"pm_score": 5,
"selected": true,
"text": "public static T FetchValue<T>(string key)\n{\n string value; \n // logic to set value here \n // ... \n ... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] |
392,932 | <p>I've always wondered how to write the <strong><code>"A ? B : C"</code></strong> syntax in a C++ compatible language.</p>
<p>I think it works something like: <em>(Pseudo code)</em></p>
<pre><code>If A > B
C = A
Else
C = B
</code></pre>
<p><em>Will any veteran C++ programmer please help me out?</em></p>
| [
{
"answer_id": 392938,
"author": "Mykroft",
"author_id": 2191,
"author_profile": "https://Stackoverflow.com/users/2191",
"pm_score": 2,
"selected": false,
"text": "C = A > B ? A : B;\n"
},
{
"answer_id": 392943,
"author": "magcius",
"author_id": 48063,
"author_profile... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41021/"
] |
392,960 | <p>How can I get my device name (using WinCE) in C# code ?</p>
<p>It gives me only "WindowsCE" how can i get the type on name of the device ? (ex. symbol or datalogic or mio...)</p>
| [
{
"answer_id": 11775895,
"author": "JanSkalicky",
"author_id": 609915,
"author_profile": "https://Stackoverflow.com/users/609915",
"pm_score": -1,
"selected": false,
"text": "Environment.MachineName\n"
},
{
"answer_id": 26186961,
"author": "Cristian Boldisteanu",
"author_... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43907/"
] |
392,980 | <p>My team at work is considering to use a framework for developing web sites and applications. Some of the seniors are convinced we should use the Zend Framework because it is easier to pick-and-choose the features so the framework we will be light-weight. </p>
<p>I'm afraid however that they are only looking at the technical advantages that a lightweight framework will have. In my opinion it is better to have a full-stack framework (and I am a proponent of Symfony) because </p>
<ol>
<li>It will also provide us with a standard way of working without writing new documentation.</li>
<li>If we would like to use new features we would only have to read the documentation to see how it can be used instead of having to build it into our setup of Zend first.</li>
</ol>
<p>I don't expect all my questions to be answered by everybody but this is what I am looking for in the answer: </p>
<ul>
<li>Do I have a point here? </li>
<li>Have you been in a similar situation and how did you handle that? </li>
<li>Do you have more arguments that I could use OR could make me reconsider my own opinion? </li>
</ul>
<p>The context:
I work at a small shop with about 10 programmers. We mostly program PHP. We use a really simple inhouse developed framework and ORM library that are practically undocumented and lack anything but the most basic features (no validators, no transactions, no caching, no authentication)</p>
| [
{
"answer_id": 406677,
"author": "marshallcooper",
"author_id": 50871,
"author_profile": "https://Stackoverflow.com/users/50871",
"pm_score": 4,
"selected": false,
"text": " static public function registerZend()\n{\n if (self::$zendLoaded)\n {\n return;\n }\n\n sfTo... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
392,981 | <p>How can I convert string to double in C++?
I want a function that returns 0 when the string is not numerical.</p>
| [
{
"answer_id": 392986,
"author": "Evgeny Lazin",
"author_id": 42371,
"author_profile": "https://Stackoverflow.com/users/42371",
"pm_score": 5,
"selected": false,
"text": "double value;\ntry\n{\n value = boost::lexical_cast<double>(my_string);\n}\ncatch (boost::bad_lexical_cast const&)... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
393,005 | <p>Is there a standard .Net matrix class? I cannot find it if there is.</p>
<p>If not, why not? It sounds like something people would need very frequently. Are there any non-standard libs you could recommend?</p>
| [
{
"answer_id": 393056,
"author": "splattne",
"author_id": 6461,
"author_profile": "https://Stackoverflow.com/users/6461",
"pm_score": 0,
"selected": false,
"text": "using Lydos.Matlab;\nusing System;\n\npublic class Example\n{\n static void Main()\n {\n Engine e = new Engine... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
393,017 | <p>Is there anything like <code>Collections.max</code> which finds the maximal value in an array for regular arrays in the standard java runtime library?</p>
| [
{
"answer_id": 393103,
"author": "eljenso",
"author_id": 30316,
"author_profile": "https://Stackoverflow.com/users/30316",
"pm_score": 2,
"selected": true,
"text": "public static <T> T max(Collection<? extends T> coll, Comparator<? super T> comp) {\n if (comp==null)\n return (T... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
393,041 | <p>I want to make some variables I generate in b available in c:</p>
<pre><code>a : b c { ...some code...}
</code></pre>
<p>A simple example:</p>
<pre><code>b : X { int result = 0; }
| Y { int result = 1; }
</code></pre>
<p>so I can, later on in c say:</p>
<pre><code>c : D { printf(result + 1); }
| E { printf(result + 2); }
</code></pre>
<p>Is there any chance to do that? Any help would really be appreciated!</p>
| [
{
"answer_id": 393048,
"author": "Can Berk Güder",
"author_id": 2119,
"author_profile": "https://Stackoverflow.com/users/2119",
"pm_score": 2,
"selected": true,
"text": "result %{\n int result;\n%}\n int result = 0 int result = 1 result = 0 result = 1"
},
{
"answer_id": 393127... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43960/"
] |
393,053 | <p>Python provides a nice method for getting length of an eager iterable, <code>len(x)</code> that is. But I couldn't find anything similar for lazy iterables represented by generator comprehensions and functions. Of course, it is not hard to write something like:</p>
<pre><code>def iterlen(x):
n = 0
try:
while True:
next(x)
n += 1
except StopIteration: pass
return n
</code></pre>
<p>But I can't get rid of a feeling that I'm reimplementing a bicycle.</p>
<p>(While I was typing the function, a thought struck my mind: maybe there really is no such function, because it "destroys" its argument. Not an issue for my case, though).</p>
<p>P.S.: concerning the first answers - yes, something like <code>len(list(x))</code> would work too, but that drastically increases the usage of memory.</p>
<p>P.P.S.: re-checked... Disregard the P.S., seems I made a mistake while trying that, it works fine. Sorry for the trouble.</p>
| [
{
"answer_id": 393059,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 6,
"selected": true,
"text": "def fib():\n a, b = 0, 1\n while True:\n a, b = b, a + b\n yield a\n next()"
},
{
"answer... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
393,061 | <p>How do I create my own primitive? For example an integer that has a range of to 1-10.</p>
<p>EDIT: This came from a task on Rosetta Code. </p>
<blockquote>
<p>Defining Primitive Data Types: Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10.</p>
</blockquote>
<p>I added it here because I thought it might be useful to others. </p>
| [
{
"answer_id": 393064,
"author": "Jonathan Allen",
"author_id": 5274,
"author_profile": "https://Stackoverflow.com/users/5274",
"pm_score": 4,
"selected": true,
"text": "Structure LimitedInt\n Implements IComparable(Of LimitedInt)\n Implements IEquatable(Of LimitedInt)\n\n Private m_V... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5274/"
] |
393,110 | <p>I'm trying to add a CSS class to the Control that will get the focus, once a page is rendered. While the SetFocus() method of the Page class lets me set the Control, there is no corresponding GetFocus() method.</p>
<p>According to the .Net sources, the information is stored in the private member _focusedControl of the Page class. The property FocusedControl is marked internal. </p>
<p>Is there a way to get the value of the private member or internal property by using Reflection?</p>
<p>Any help would be greatly appreciated.</p>
<p><strong>Clarification:</strong>
Here is why I want to add a CssClass server side: I'm trying to apply the following
JQuery script, that changes the background of the focused element:</p>
<pre><code>$(document).ready(function() {
var elements = jQuery("textarea, select, multi-select, :text, :password, :file");
elements.bind
(
'focus',
function() {
jQuery(this).addClass('highlightinput');
}
);
elements.bind
(
'blur',
function() {
jQuery(this).removeClass('highlightinput');
}
);
})
</code></pre>
<p>This works fine as long as I don't specifically set a focused control in my aspx.vb. If I do set a focused control (I think due to a timing issue), the focus is set before my handlers are attached to the input fields and thus, the input is not highlighted. So my approach would be to add the highlightinput class to the focused control before rendering the page.</p>
| [
{
"answer_id": 394760,
"author": "cfbarbero",
"author_id": 2218,
"author_profile": "https://Stackoverflow.com/users/2218",
"pm_score": 2,
"selected": false,
"text": ":focus{ background-color: yellow;}"
},
{
"answer_id": 394769,
"author": "Shawn",
"author_id": 26,
"aut... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18877/"
] |
393,118 | <p>While developing a C# application (my first C# app.):</p>
<ul>
<li>gets login information from the user (id, pass),</li>
<li>opens a new <code>HttpWebRequest</code> connection to a ASP.NET web page</li>
<li>tries to login to this page with the obtained [id,pass] tuple. If login is successful, my <code>HttpWebRequest</code> object contains a cookie which will be used to login to another page.</li>
</ul>
<p>Before requesting the second (protected) page, I want to be sure that first login is successful. First I thought that server sends a cookie if only if the login is successful. But it is not. :)</p>
<p>Is it possible to understand from the received cookie object that my login is successful?
Or are there any other methods that you can propose for me to solve this issue?</p>
| [
{
"answer_id": 393302,
"author": "fantoman",
"author_id": 49057,
"author_profile": "https://Stackoverflow.com/users/49057",
"pm_score": 2,
"selected": false,
"text": "Set-Cookie: ASP.NET_SessionId=ah0b2kj40oi0vuufv0mmot35; path=/; HttpOnly\\r\\n\n //In LoginForm.cs\nif (((HttpWebResponse... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49057/"
] |
393,121 | <p>I have a file containing several lines similar to:</p>
<pre><code>Name: Peter
Address: St. Serrano número 12, España
Country: Spain
</code></pre>
<p>And I need to extract the address using a regular expression, taking into account that it can contain dots, special characters (ñ, ç), áéíóú...</p>
<p>The current code works, but it looks quite ugly:.</p>
<pre><code>Pattern p = Pattern.compile("^(.+?)Address: ([a-zA-Z0-9ñÑçÇáéíóú., ]+)(.+?)$",
Pattern.MULTILINE | Pattern.DOTALL);
Matcher m = p.matcher(content);
if (m.matches()) { ... }
</code></pre>
<p><strong>Edit: The Address field could also be divided into multiple lines</strong></p>
<pre><code>Name: Peter
Address: St. Serrano número 12,
Madrid
España
Country: Spain
</code></pre>
<p>Edit: I can't use a Properties object or a YAML parser, as the file contains other kind of information, too.</p>
| [
{
"answer_id": 393131,
"author": "cnu",
"author_id": 1448,
"author_profile": "https://Stackoverflow.com/users/1448",
"pm_score": 0,
"selected": false,
"text": "\"Address: (.*)$\""
},
{
"answer_id": 393137,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profil... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12388/"
] |
393,151 | <p>What's the easiest way to create an array of structs in Cocoa?</p>
| [
{
"answer_id": 393181,
"author": "Rich Catalano",
"author_id": 4103,
"author_profile": "https://Stackoverflow.com/users/4103",
"pm_score": 4,
"selected": false,
"text": "struct foo{\n int bar;\n};\n\nint main (int argc, const char * argv[]) {\n struct foo foobar[3];\n foobar[0].... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36182/"
] |
393,152 | <p>Many people ask me why, and I don`t have a good answer for them.</p>
<p>Obviously there is a good reason. Does anyone know it?</p>
<p>I searched here and found <a href="https://stackoverflow.com/questions/127233/does-class-need-to-implement-ienumerable-to-use-foreach">this question</a>. It explains how it works, but not why.</p>
| [
{
"answer_id": 393179,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": true,
"text": "IEnumerable<int> IEnumerable foreach foreach IEnumerable<T>"
}
] | 2008/12/25 | [
"https://Stackoverflow.com/questions/393152",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39281/"
] |
393,166 | <p>I use Javascript to click a link in the webbrowser control. But I don't want to hear IE's "click" sound. </p>
<p>Is there any way to do this?</p>
<p>P.S. </p>
<ul>
<li>I don't want to change system settings.</li>
<li>I've seen this one (<a href="https://stackoverflow.com/q/10456">HowTo Disable WebBrowser 'Click Sound' in your app only</a>) but <code>Document.Write</code> is not an option for me.</li>
</ul>
| [
{
"answer_id": 737280,
"author": "James Crowley",
"author_id": 33682,
"author_profile": "https://Stackoverflow.com/users/33682",
"pm_score": 7,
"selected": true,
"text": "int feature = FEATURE_DISABLE_NAVIGATION_SOUNDS;\nCoInternetSetFeatureEnabled(feature, SET_FEATURE_ON_PROCESS, true);... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40322/"
] |
393,168 | <p>I am looking for a control to be able to embed the functionality of the FileOpenDialog without the idea of using a modal dialog. Does something like this exist already? (ideally within .Net 2.0 framework, C#). </p>
| [
{
"answer_id": 393417,
"author": "lc.",
"author_id": 44853,
"author_profile": "https://Stackoverflow.com/users/44853",
"pm_score": 1,
"selected": false,
"text": "DataGridView"
}
] | 2008/12/25 | [
"https://Stackoverflow.com/questions/393168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
393,176 | <p>The (command line) interface I have in mind is like so:</p>
<pre><code>watching FILE+ do COMMAND [ARGS] (and COMMAND [ARGS])*
</code></pre>
<p>Where any occurrence of "<code>{}</code>" in <code>COMMAND</code> is replaced with the name of the file that changed. And note that "<code>do</code>" and "<code>and</code>" are keywords.</p>
<p>For example:</p>
<pre><code>> watching foo.txt bar.txt do scp {} somewhere.com:. and echo moved {} to somewhere
</code></pre>
<p>Or:</p>
<pre><code>> watching foo.c do gcc foo.c and ./a.out
</code></pre>
<p>I'm not wedded to that interface though. I'll add my script that does that as an answer and see if anyone has anything better or ways to improve it.</p>
| [
{
"answer_id": 393177,
"author": "dreeves",
"author_id": 4234,
"author_profile": "https://Stackoverflow.com/users/4234",
"pm_score": 3,
"selected": true,
"text": "#!/usr/bin/perl\n# Run some commands whenever any of a set of files changes (see USAGE below).\n# Example:\n# ./watching.pl f... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4234/"
] |
393,191 | <p>Spotlight indexes at the file level, so a file containing a complicated data structure may need to be split into a set of files for Spotlight to index it in a useful way.</p>
<p>Can you use MacFUSE to achieve this more dynamically?</p>
<p>Will Spotlight index a MacFUSE volume?</p>
<p>Can MacFUSE handle the necessary per-file metadata?</p>
<p>Can a MacFUSE process notify Spotlight when attributes of a file change?</p>
| [
{
"answer_id": 393202,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 2,
"selected": false,
"text": "sudo mdutil -i on /Volumes/SomeVolume\n"
}
] | 2008/12/25 | [
"https://Stackoverflow.com/questions/393191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11002/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.