qid int64 4 19.1M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
379,346 | <p>The ampoule project uses some tags in docstring, like the javadoc ones. </p>
<p>For example from <a href="http://bazaar.launchpad.net/~dialtone/ampoule/main/annotate/26?file_id=pool.py-20080501191749-jqawtxogk4i0quu3-12" rel="noreferrer">pool.py</a> line 86:</p>
<pre><code>def start(self, ampChild=None):
"""
Starts the ProcessPool with a given child protocol.
@param ampChild: a L{ampoule.child.AMPChild} subclass.
@type ampChild: L{ampoule.child.AMPChild} subclass
"""
</code></pre>
<p>What are these tags, which tool uses it.</p>
| [
{
"answer_id": 380737,
"author": "cdleary",
"author_id": 3594,
"author_profile": "https://Stackoverflow.com/users/3594",
"pm_score": 4,
"selected": false,
"text": "def start(self, ampChild=None):\n \"\"\"Starts the ProcessPool with a given child protocol.\n\n :param ampChild: a :cl... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36131/"
] |
379,352 | <p>The CherryPy web server can supposedly be deployed in the Google App Engine.</p>
<p>Who has done it, and what was the experience like?</p>
<p>What special effort was required (configuration, etc.)?</p>
<p>Would you recommend it to others?</p>
| [
{
"answer_id": 1262233,
"author": "RoutineOp",
"author_id": 4780,
"author_profile": "https://Stackoverflow.com/users/4780",
"pm_score": 2,
"selected": false,
"text": " import sys\n sys.path.insert(0, 'cherrypy.zip')\n import cherrypy\n import wsgiref.handlers \n\n class Root:... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26682/"
] |
379,353 | <p>I'm looking for a lightweight way to make my program (written in C) be able to play audio files on either windows or linux. I am currently using windows native calls, which is essentially just a single call that is passed a filename. I would like something similar that works on linux. </p>
<p>The audio files are Microsoft PCM, Single channel, 22Khz</p>
<p>Any Suggestions?</p>
| [
{
"answer_id": 396378,
"author": "quinmars",
"author_id": 18687,
"author_profile": "https://Stackoverflow.com/users/18687",
"pm_score": 5,
"selected": true,
"text": "\n#include <portaudio.h>\n#include <sndfile.h>\n\nstatic int\noutput_cb(const void * input, void * output, unsigned long f... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17324/"
] |
379,354 | <p>This one's a tough one - I have a JFrame that generates JTextFields. When I go from generating 2 JTextFields to 12 JTextfields (for example), I see some error where there is an extra differently-sized JTextField at the end. It seems to be a repaint error.</p>
<p><strong>Main.java code:</strong> </p>
<pre><code>import java.awt.*;
import javax.swing.*;
public class Main {
public static Display display = new Display();
public static void main(String[] args) {
display.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
display.setVisible(true);
}
}
</code></pre>
<p><strong>Display.java code:</strong></p>
<pre><code>import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Display extends JFrame {
final int FRAME_WIDTH = 820;
final int FRAME_HEIGHT = 700;
final int X_OFFSET = 40;
final int Y_OFFSET = 40;
final int GRAPH_OFFSETX = 35;
final int GRAPH_OFFSETY = 60;
final int GRAPH_WIDTH = 500;
final int GRAPH_HEIGHT = 500;
final int GRAPH_INTERVAL = 20;
JButton submit;
JTextField top;
JTextField bottom;
JTextField numPoint;
JPanel bpanel;
JPanel points;
int maxPoints;
public Display() {
init();
}
public void init() {
setBackground(Color.WHITE);
setLocation(X_OFFSET, Y_OFFSET);
setSize(FRAME_WIDTH, FRAME_HEIGHT);
setTitle("Geometric Transformations");
getContentPane().setLayout(null);
setDefaultLookAndFeelDecorated(true);
top = new JTextField(); // parameter is size of input characters
top.setText("1 2 3");
top.setBounds(590, 150, 120, 25);
bottom = new JTextField(); // parameter is size of input characters
bottom.setText("5 6 7");
bottom.setBounds(590, 200, 120, 25);
numPoint = new JTextField();
numPoint.setText("Number of Points?");
numPoint.setBounds(550,200,200,25);
this.add(numPoint);
SubmitButton submit = new SubmitButton("Submit");
submit.setBounds(570, 250, 170, 25);
bpanel = new JPanel(new GridLayout(2,3));
bpanel.add(top);
bpanel.add(bottom);
bpanel.add(submit);
points = new JPanel(new GridLayout(2,2));
points.setBounds(540,250,265,60);
this.add(points);
bpanel.setBounds(550,100,200,70);
this.add(bpanel, BorderLayout.LINE_START);
Component[] a = points.getComponents();
System.out.println(a.length);
repaint();
}
public void paint(Graphics g) {
super.paint(g);
g.setColor(Color.WHITE);
g.fillRect(100, 100, 20, 30);
g.setColor(Color.BLACK);
genGraph(g, GRAPH_OFFSETX, GRAPH_OFFSETY, GRAPH_WIDTH, GRAPH_HEIGHT, GRAPH_INTERVAL);
}
public void genGraph (Graphics g, int x, int y, int width, int height, int interval) {
// draw background
int border = 5;
g.setColor(Color.BLACK);
width = width - (width % interval);
height = height - (height % interval);
for (int col=x; col <= x+width; col+=interval) {
g.drawLine(col, y, col, y+height);
}
for (int row=y; row <= y+height; row+=interval) {
g.drawLine(x, row, x+width, row);
}
}
class SubmitButton extends JButton implements ActionListener {
public SubmitButton(String title){
super(title);
addActionListener(this);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
maxPoints = Integer.parseInt(numPoint.getText()) * 2;
points.removeAll();
for (int i=0; i<maxPoints; i++) {
JTextField textField = new JTextField();
points.add(textField);
}
points.validate(); // necessary when adding components to a JPanel
// http://stackoverflow.com/questions/369823/java-gui-repaint-problem-solved
// What to Check:
// Things between commas are either spaces (which will be stripped later)
// or numbers!
// Pairs must match up!
}
}
}
</code></pre>
| [
{
"answer_id": 396378,
"author": "quinmars",
"author_id": 18687,
"author_profile": "https://Stackoverflow.com/users/18687",
"pm_score": 5,
"selected": true,
"text": "\n#include <portaudio.h>\n#include <sndfile.h>\n\nstatic int\noutput_cb(const void * input, void * output, unsigned long f... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51518/"
] |
379,355 | <p>I have a custom control and it works fine...except that the control cannot be rendered on Design Time. ( I am using VS 2008)</p>
<p>I am thinking many people who develop custom controls encounter this problem...The error I get is "Error Creating Control - CustomControlName" Object reference not set to an instance of an object.</p>
<p>I want a work around. or at least debug this...(Since this is a design time issue how to debug?)</p>
<p>I have tried if( !DesignMode) code on OnInit, OnPreRender, RenderContents, CreateChildControls Methods ( I am just shooting in the dark)...</p>
<p>Help pls. I really hope this is not a VS bug! </p>
| [
{
"answer_id": 390515,
"author": "Glenn Slaven",
"author_id": 2975,
"author_profile": "https://Stackoverflow.com/users/2975",
"pm_score": 0,
"selected": false,
"text": "OnPreRender CreateChildControls if (this.Page != null)\n{\n.....\n}\n PreRender CreateChildControls"
}
] | 2008/12/18 | [
"https://Stackoverflow.com/questions/379355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
379,371 | <p>One of the items in the <a href="http://www.joelonsoftware.com/articles/fog0000000043.html" rel="noreferrer">Joel Test</a> is that a project/company should have a specification.</p>
<p>I'm wondering what makes a spec good. Some companies will write volumes of useless specification that no one ever reads, others will not write anything down because "no one will read any of it anyway". So, what do you put into your spec? What is the good balance between the two extremes? Is there something particularly important that really, really (!) should always be recorded in a specification?</p>
| [
{
"answer_id": 41989854,
"author": "thion",
"author_id": 5790233,
"author_profile": "https://Stackoverflow.com/users/5790233",
"pm_score": 1,
"selected": false,
"text": "Feature: Allow new businesses to appear on the map\n\n Scenario Outline: Businesses should provide required data\n\n ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5010/"
] |
379,380 | <p>So, I have an API that I need to implement in to an existing framework. This API manages interactions with an external server. I've been charged with coming up with a way to create an easily repeatable "pattern," so that if people are working on new projects in the given framework they have a simple solution for integrating the API. </p>
<p>My first idea was to create a class for your "main" class of the framework to extend that, would provide all the virtual functions necessary to interact with the API. However, my boss vetoed this, since the existing framework is "inheritence heavy" and he wants to avoid adding to the madness. I obviously can't incapsulate my API, because that is what the API itself is supposed to be doing, and doing so might hide functionality. </p>
<p>Short of asking futures developers to copy and paste my example, what do I do? </p>
| [
{
"answer_id": 379443,
"author": "chaos",
"author_id": 47529,
"author_profile": "https://Stackoverflow.com/users/47529",
"pm_score": 3,
"selected": true,
"text": "main->whateverapi->doWhatever() main->yourobject->originalapi"
}
] | 2008/12/18 | [
"https://Stackoverflow.com/questions/379380",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45581/"
] |
379,382 | <p>I have a collection of an object called Bookmarks which is made up of a collection of Bookmarks. This collection of bookmarks are bound to a treeview control. </p>
<p>I can get the bookmarks back out that I need, but I need a copy of the bookmarks so I can work with it and not change the original. </p>
<p>Any thoughts. </p>
<p>Thanks.</p>
| [
{
"answer_id": 379395,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": 0,
"selected": false,
"text": "dim copyOfBookMars as New List(of BookMark)(myOriginalBookMarkList)\n"
}
] | 2008/12/18 | [
"https://Stackoverflow.com/questions/379382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38349/"
] |
379,383 | <p>I have a std::vector containing a handful of numbers, which are not in any particular order, and may or may not have gaps between the numbers - for example, I may have { 1,2,3, 6 } or { 2,8,4,6 } or { 1, 9, 5, 2 }, etc.</p>
<p>I'd like a simple way to look at this vector and say 'give me the lowest number >= 1 which does <em>not</em> appear in the vector'. So, </p>
<p>for the three examples above, the answers would be 4, 1 and 3 respectively.</p>
<p>It's not performance critical, and the list is short so there aren't any issues about copying the list and sorting it, for example.</p>
<p>I am not really stuck for a way to do this, but my STL skills are seriously atrophied and I can feel that I'm about to do something inelegant - I would be interested to see what other people came up with.</p>
| [
{
"answer_id": 379416,
"author": "user7116",
"author_id": 7116,
"author_profile": "https://Stackoverflow.com/users/7116",
"pm_score": 2,
"selected": false,
"text": "std::sort(vec.begin(), vec.end());\nint lowest = 1;\nfor(size_t ii = 1; ii < vec.size(); ++ii)\n{\n if (vec[ii - 1] + 1 ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/987/"
] |
379,385 | <p>Our dev team is looking for an IDE like vi or nano or even textpad for windows that has the capability to autocomplete and error correction for bash or shell script for linux. Basically something similar to .NET autocompletion where you will be able to see if an </p>
<pre><code> if[ $# -ne 5 ]; then
</code></pre>
<p>has no space between the 5 and the ] will tell you.</p>
<p>I hope this question is simple and easy to answer. I have seen that vi in RHE use some coloring but in CentOS5 it does not shows the different colors. Non of them use error detection or auto-completion.</p>
| [
{
"answer_id": 380422,
"author": "richq",
"author_id": 4596,
"author_profile": "https://Stackoverflow.com/users/4596",
"pm_score": 3,
"selected": true,
"text": "autocmd FileType sh set makeprg=bash\\ -n\\ '%'\nautocmd FileType sh let &efm = \"%E%f:\\ line\\ %l:\\ %m,\" . &efm\n :make"
... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379385",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47222/"
] |
379,412 | <p>I have an application for entering in serial numbers to a database. A serial number has a set number of attributes that defines it and the the user must/may provide them to generate.</p>
<pre><code>public class Serial
{
public string Number {get; set;}
public string Part {get; set;}
public string MfgOrder {get; set;}
public string CusOrder {get; set;}
public string Note {get; set;}
... etc ...
}
</code></pre>
<p>Now the start point of this application asks the user for one of several pieces of information (for example a part number or manufacturing order, etc). This start point may already fill in some of the required user input. I'd like to then take those known items and alter the form based on them.</p>
<p>For example. If two of the pieces of information are Part Number and Mfg Order Number, and the user supplies the Mfg Order Number (which has a relationship to the Part Number from the database) I'd like to display these values but not allow them to be edited. If instead the user just gives me a Part Number, I want to allow the Mfg Order to be presented as a textbox with (maybe) optional or required next to it.</p>
<pre><code>public class MfgOrder
{
public string MfgOrder {get; set;}
public string Part {get; set;}
}
...
MfgOrder order = new MfgOrder(some_user_value); // queries database, returns populated object
Serial serial = new Serial() {
MfgOrder = order.MfgOrder,
Part = order.Part
};
</code></pre>
<p>This application is working right now by just having if/then conditions in the UI -- if you gave me a Mfg Order, dispaly it this way, if you gave me something else, do it this way, etc. The problem is several new options have been requested and continually chaining if/then statements is getting really ugly.</p>
<pre><code>if(serial.comes_from_mfgOrder == true)
{
%>Manufacturing Order: <%=serial.MfgOrder %><%
} else if (serial.comes_from_part_number == true) {
%>Manufacturing Order: <%=Html.Textbox("MfgOrder")%><%
} else if // continue this for way too long now ...
</code></pre>
<p>Is there a good design pattern here?</p>
<p>Thanks!</p>
| [
{
"answer_id": 380422,
"author": "richq",
"author_id": 4596,
"author_profile": "https://Stackoverflow.com/users/4596",
"pm_score": 3,
"selected": true,
"text": "autocmd FileType sh set makeprg=bash\\ -n\\ '%'\nautocmd FileType sh let &efm = \"%E%f:\\ line\\ %l:\\ %m,\" . &efm\n :make"
... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36602/"
] |
379,432 | <p>I have a listbox on an HTML form with a Submit button. The listbox has multiple selection enabled. I am able to select multiple values in the listbox, but I don't know how to figure out what values were selected when the form is submitted. Also, I am adding user generated values to the list box dynamically using JavaScript, and I would like to be able to tell two things when the form submits:</p>
<ol>
<li>What are the options added to the box by the user?</li>
<li>What values are selected in the box by the user?</li>
</ol>
<p>Is this possible? Thanks.</p>
| [
{
"answer_id": 379990,
"author": "some",
"author_id": 36866,
"author_profile": "https://Stackoverflow.com/users/36866",
"pm_score": 3,
"selected": true,
"text": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14101/"
] |
379,442 | <p>I'm looking into writing a wxWidget that displays a graphical node network, and therefore does a lot of drawing operations. I know that using Python to do it is going to be slower, but I'd rather get it working and port it later when its functional. Ideally, if the performance hit isn't too great, I'd prefer to keep the codebase in Python for easy updates.</p>
<p>What I'm wondering is how much slower should I expect things to go? I realize this is vague and open ended, but I just need a sense of what to expect. Will drawing 500 circles bog down? Will it be noticeable at all? What are your experiences?</p>
| [
{
"answer_id": 379990,
"author": "some",
"author_id": 36866,
"author_profile": "https://Stackoverflow.com/users/36866",
"pm_score": 3,
"selected": true,
"text": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46914/"
] |
379,465 | <p>For my program, I'm attempting to replace the value of a specific hash in an external file with a newly created value. The external file has the value tab-delimited from the key, and I had read the hash in from the external file. I've been looking around online, and this is the closest way I could figure out how to do it, yet it doesn't seem to work.</p>
<pre><code> open(IN, ">>$file") || die "can't read file $file";
while (<IN>) {
print IN s/$hash{$key}/$newvalue/;
}
close (IN)
</code></pre>
<p>I'm not quite sure what I'm missing in this formula.</p>
| [
{
"answer_id": 379481,
"author": "FryGuy",
"author_id": 28776,
"author_profile": "https://Stackoverflow.com/users/28776",
"pm_score": 0,
"selected": false,
"text": "open(IN, \"<<$file\") || die \"can't read file $file\";\nopen(OUT, \">>${file}.tmp\") || die \"can't open file $file\";\nwh... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
379,487 | <p>I know there is re-sharper for Visual Studio, but is there a really good refactoring tool for Eclipse that is better than the small amount of built in refactors?</p>
<p>Preferably something free.</p>
<p>(Update)</p>
<p>Looking to do things like take all string literals in a file and make them constants.<br>
Solve lots of PMD errors in some automated fashion.</p>
| [
{
"answer_id": 2826547,
"author": "ekeren",
"author_id": 287455,
"author_profile": "https://Stackoverflow.com/users/287455",
"pm_score": 2,
"selected": false,
"text": "System.out.println(\"This Line Contains a constant The 42 Constant that is stuck inside\");\n System.out.println(\"This ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45365/"
] |
379,506 | <p>I have a central authentication application on server a. Server b has one or more applications on the same domain that need to authenticate from server a. It's easy enough to set it up so that the server b apps redirect out to server a. What's not so easy is getting the ReturnURL to be absolute.</p>
<p>Here's the wrinkle. Consuming app on server b has two controllers, one public and one secured. If the [authorize] decoration is placed on an action in the public (which is the default controller), I get the proper absolute URL. However, if its in it's own controller I get a relative URL.</p>
<p>I can intercept the on pre-request event in the consuming applications, but I need some parts of the site to be public, not the whole smash.</p>
<p>Ideas?</p>
| [
{
"answer_id": 379592,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 4,
"selected": false,
"text": " public class SSOAuthorizeAttribute : AuthorizeAttribute\n {\n public override void OnAuthorization( \n ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26364/"
] |
379,512 | <p>I'm trying to write a simple routine where I pass it a URL and it goes and renders the content of the webresponse as a jpg. I found a solution somehwere in C# and ported it to vb.net, however when I run it, it throws an argumentexception "parameter is not valid" when trying to instantiate the image. Can someone take a look at the following code and let me know if I'm on the right track?</p>
<pre><code>Sub SaveUrl(ByVal aUrl As String)
Dim response As WebResponse
Dim remoteStream As Stream
Dim readStream As StreamReader
Dim request As WebRequest = WebRequest.Create(aUrl)
response = request.GetResponse
remoteStream = response.GetResponseStream
readStream = New StreamReader(remoteStream)
Dim img As System.Drawing.Image = System.Drawing.Image.FromStream(remoteStream)
img.Save(aUrl & ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
response.Close()
remoteStream.Close()
readStream.Close()
End Sub
</code></pre>
<p><strong>To Clarify:</strong> Yes, I know i need a LOT more code to accomplish what I want to do, which is to render/take a screen capture of a URL (html, images, all the markup, everything) and save it as a jpg thumbnail. </p>
<p>If you've used Google Chrome, you've seen the launch page that has thumbnails of all the sites you use frequently. Something like that.</p>
<p><strong>Update:</strong> Ok I've found commercial paid products to accomplish this, like <a href="http://www.websitesscreenshot.com/Index.html" rel="nofollow noreferrer">http://www.websitesscreenshot.com/Index.html</a> but no open source implementations. </p>
| [
{
"answer_id": 379529,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": false,
"text": ".FromStream()"
},
{
"answer_id": 379534,
"author": "Zachary Yates",
"author_id": 8360,
"author_pro... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/678/"
] |
379,530 | <p>I can, on some of my systems, get my IP address (192.68.m.n format) by doing this:</p>
<pre><code>addr = IPSocket::getAddress(Socket.gethostname())
</code></pre>
<p>...the trouble is that this only works if the name the local machine uses for itself is the name the DNS server associates with it.</p>
<p>How *&#( hard can it be for ruby to just return its primary interface's IP address? I have to do this in a platform-independant way or I'd just call ifconfig or ipconfig and parse it.</p>
| [
{
"answer_id": 379557,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 3,
"selected": true,
"text": "see Socket.getaddrinfo()"
},
{
"answer_id": 2702145,
"author": "john3exonets",
"author_id": 324622,
... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30997/"
] |
379,536 | <p>I have found <a href="http://www.sitepoint.com/dustmeselectors/" rel="nofollow noreferrer">http://www.sitepoint.com/dustmeselectors/</a> which does about the opposite of what I want, identifying selectors in CSS that aren't used in HTML.</p>
<p>I want a tool that will find elements that have a class attribute but the class isn't defined in any CSS being loaded by the page.</p>
<p>Thanks</p>
| [
{
"answer_id": 379564,
"author": "Kenan Banks",
"author_id": 43089,
"author_profile": "https://Stackoverflow.com/users/43089",
"pm_score": 0,
"selected": false,
"text": "class=\"someclass\""
}
] | 2008/12/18 | [
"https://Stackoverflow.com/questions/379536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13100/"
] |
379,546 | <p>In Haskell, is there a way to restrict a monad <code>M a</code> so that <code>a</code> satisfy a type class constraint?</p>
<p>I am translating the <a href="http://github.com/namin/spots/tree/master/probabilisticModeling/README.markdown" rel="noreferrer">probabilistic modeling example</a> from <a href="http://github.com/namin/spots/tree/master/probabilisticModeling/probabilisticModeling.fsx" rel="noreferrer">F#</a> to <a href="http://github.com/namin/spots/tree/6c5a3b78e8f5f559900bade7629fab0edcf225e8/probabilisticModeling/probabilisticModeling.hs" rel="noreferrer">Haskell</a>. However, in Haskell, I omitted <code>support</code> because it would change <code>data Distribution a</code> to <code>data (Ord a) => Distribution a</code>. With this change, I get the following error:</p>
<pre><code>...probabilisticModeling.hs:42:13:
Could not deduce (Ord a) from the context ()
arising from a use of `always'
at ...probabilisticModeling.hs:42:13-18
Possible fix:
add (Ord a) to the context of the type signature for `return'
In the expression: always
In the definition of `return': return = always
In the instance declaration for `Monad Distribution'
</code></pre>
<p>Indeed, the type of <code>always</code>/<code>return</code> is: <code>(Ord a) => a -> Distribution a</code>. Is there a way I can have a monad <code>Distribution</code>, but force the constraint <code>(Ord a)</code> on this monad? I tried:</p>
<pre><code>instance Monad Distribution where
(>>=) = bind
return :: (Ord a) => a -> Distribution a = always
</code></pre>
<p>But I get the error:</p>
<pre><code>...probabilisticModeling2.hs:48:4:
Pattern bindings (except simple variables) not allowed in instance declarations
return :: (Ord a) => a -> Distribution a = always
Failed, modules loaded: none.
</code></pre>
<p>So it there a way to have a monad <code>M a</code>, but restrict the <code>a</code> with a constraint such as <code>Ord a</code>?</p>
<p>Thanks.</p>
| [
{
"answer_id": 379608,
"author": "Gregory Higley",
"author_id": 27779,
"author_profile": "https://Stackoverflow.com/users/27779",
"pm_score": 4,
"selected": true,
"text": "(Ord a) M a"
},
{
"answer_id": 379844,
"author": "namin",
"author_id": 34596,
"author_profile": ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34596/"
] |
379,551 | <p>What's the simplest, most standard, and/or most efficient way to split a List into two sub-Lists in Java? It's OK to mutate the original List, so no copying should be necessary. The method signature could be</p>
<pre><code>/** Split a list into two sublists. The original list will be modified to
* have size i and will contain exactly the same elements at indices 0
* through i-1 as it had originally; the returned list will have size
* len-i (where len is the size of the original list before the call)
* and will have the same elements at indices 0 through len-(i+1) as
* the original list had at indices i through len-1.
*/
<T> List<T> split(List<T> list, int i);
</code></pre>
<p>[EDIT] <code>List.subList</code> returns a view on the original list, which becomes invalid if the original is modified. So <code>split</code> can't use <code>subList</code> unless it also dispenses with the original reference (or, as in Marc Novakowski's answer, uses <code>subList</code> but immediately copies the result).</p>
| [
{
"answer_id": 379584,
"author": "Marc Novakowski",
"author_id": 27020,
"author_profile": "https://Stackoverflow.com/users/27020",
"pm_score": 2,
"selected": false,
"text": "<T> List<T> split(List<T> list, int i) {\n List<T> x = new ArrayList<T>(list.subList(i, list.size()));\n // ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1412/"
] |
379,556 | <p>I have a large-ish Oracle table containing rows representing units of work, with columns for start time and end time in addition to other meta-data.</p>
<p>I need to generate usage graphs from this data, given some arbitrary filtering criteria and a reporting time period. E.g., show me a graph of all of Alice's jobs for the 24-hour period starting last Tuesday at 7:00am. Each DB row will stack vertically in the graph.</p>
<p>I could do this in a high-level language by querying all potentially relevant rows, time slicing each one into 1-minute buckets, and graphing the result. But is there an efficient way to do this time slicing in SQL? Or is there an existing Oracle technology that does this?</p>
<p>Thanks!</p>
| [
{
"answer_id": 380440,
"author": "hamishmcn",
"author_id": 3590,
"author_profile": "https://Stackoverflow.com/users/3590",
"pm_score": 4,
"selected": true,
"text": "SELECT user_name, truncate(event_time, 'YYYYMMDD HH24MI'), count(*)\nFROM job_table\nWHERE event_time > TO_DATE( some start... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16722/"
] |
379,558 | <p>Here is my scenario. For the example lets say that I need to return a list of cars based on a search criteria. I would like to have a single View to display the results since the output will be the same, but I need several ways of getting there. For instance, I may have a Form with a textbox to search by year. I may have another separate page that contains a hyperlink for all red, Toyota cars. How do I handle these multiple scenarios in the same View and Controller. My dilemma is that the search could contain several options… year, make, model, etc but I don’t know where to put them.</p>
<p>What is the best approach for this? Should I define the parameters in the routing or go with query strings, etc?</p>
| [
{
"answer_id": 379588,
"author": "Matthew",
"author_id": 20162,
"author_profile": "https://Stackoverflow.com/users/20162",
"pm_score": 0,
"selected": false,
"text": "return View(\"SearchResult\", searchResultCollection);\n"
},
{
"answer_id": 379822,
"author": "Dylan Beattie",... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47576/"
] |
379,560 | <p>By default the BinaryWriter class writes int values with the low bits on the left (e.g. (int)6 becomes 06 00 00 00 when the resulting file is viewed in a hex editor). I need the low bits on the right (e.g. 00 00 00 06). </p>
<p>How do I achieve this?</p>
<p>EDIT: Thanks strager for giving me the name for what I was looking for. I've edited the title and tags to make it easier to find.</p>
| [
{
"answer_id": 379582,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": true,
"text": " int i = 6;\n byte[] raw = new byte[4] {\n (byte)(i >> 24), (byte)(i >> 16),\n (by... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1512/"
] |
379,571 | <p>I have a GridView with a TemplateField with a checkbox. My goal is to capture the onclick event using autopostback and setting a database flag. My only problem is that the event fire's twice. The first time The Checkbox (In the sender parameter) holds the clicked value so I set it based on the click. The second time the sender parameter has a checkbox that is always checked=false. I am happy to entertain suggestions on other approached to solving this problem but my goal is to set a database flag based on the user checking a checkbox. I am targeting .NET Framework 2.0.</p>
<p>Here is the associated code:</p>
<pre><code><div style="margin-left : 1em;margin-right:1em;">
<asp:GridView ID="RouteGridView" runat="server" AllowPaging="True"
AutoGenerateColumns="False" CellPadding="4" DataKeyNames="ROUTE_NUMBER"
ForeColor="#333333" GridLines="None" style="width:100%;"
onselectedindexchanged="RouteGridView_SelectedIndexChanged"
AllowSorting="True" onpageindexchanging="RouteGridView_PageIndexChanging"
onsorting="RouteGridView_Sorting" >
<Columns>
<%-- Column one --%>
<asp:TemplateField HeaderText="Route" SortExpression="ROUTE_NUMBER">
<ItemTemplate>
<asp:LinkButton ID="HyperLink1" runat="server" CommandName="Select" CommandArgument='<%#Eval("ROUTE_NUMBER")%>'
Text='<%# Eval("ROUTE_NUMBER") %>' ></asp:LinkButton>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<%-- Column 2 this is where the problem CheckBox is--%>
<asp:TemplateField HeaderText="Read?"
SortExpression="READ_FLAG">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server"
OnCheckedChanged="ChangeReadFlag"
AutoPostBack="true"
Checked='<%# (string)DataBinder.Eval(Container.DataItem, "READ_FLAG") == "1" %>' Enabled='<%# isSelectedRow(Container) %>' />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<%-- more columns --%
<%-- more columns --%>
</Columns>
</asp:GridView>
</code></pre>
<p>Here is the event handler from the code behind:</p>
<pre><code>protected void ChangeReadFlag(object sender, EventArgs e)
{
if (RouteGridView.SelectedIndex != -1)
{
CheckBox cb = ((CheckBox)sender);
DataKey key = RouteGridView.SelectedDataKey;
//... do stuff here ...
}
}
</code></pre>
| [
{
"answer_id": 482794,
"author": "Lekim",
"author_id": 59266,
"author_profile": "https://Stackoverflow.com/users/59266",
"pm_score": 1,
"selected": false,
"text": "<asp:CheckBox ID=\"CheckBox1\" runat=\"server\" \n **OnCheckedChanged=\"ChangeReadFlag\"**\n AutoPostB... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4491/"
] |
379,574 | <p>My Java UI unexpectly terminated and dumped an <code>hs_err_pid</code> file. The file says "The crash happened outside the Java Virtual Machine in native code." JNA is the only native code we use. Does anyone know of any know issues or bugs with any JNA version that might cause this. I've included some of the contents from the error file below. </p>
<pre><code>An unexpected error has been detected by Java Runtime Environment:
EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d02bcbd, pid=312, tid=3616
Java VM: Java HotSpot(TM) Client VM (11.0-b16 mixed mode, sharing windows-x86)<br>
Problematic frame:
C [awt.dll+0x2bcbd]
If you would like to submit a bug report, please visit:
http://java.sun.com/webapps/bugreport/crash.jsp
The crash happened outside the Java Virtual Machine in native code.
See problematic frame for where to report the bug.
Current thread (0x02acf000): JavaThread "AWT-Windows" daemon [_thread_in_native, id=3616, stack(0x02eb0000,0x02f00000)]
siginfo: ExceptionCode=0xc0000005, writing address 0xe2789280
Registers:
EAX=0x234f099c, EBX=0x00001400, ECX=0x00000100, EDX=0xe2789280
ESP=0x02eff4a4, EBP=0x00000400, ESI=0x234f099c, EDI=0xe2789280
EIP=0x6d02bcbd, EFLAGS=0x00010206
Top of Stack: (sp=0x02eff4a4)
0x02eff4a4: 02eff500 00000100 02eff584 00000100
0x02eff4b4: 6d0a5697 00000400 00000400 00000100
0x02eff4c4: 00000100 02eff700 02eff500 00000000
0x02eff4d4: 00000000 00000100 041ac3a0 00000100
0x02eff4e4: 00182620 00000400 e2789280 00000000
0x02eff4f4: 00000000 00000100 00000100 00000000
0x02eff504: 00000000 00000100 00000100 00000000
0x02eff514: 00000000 00000004 00000400 00000000
Instructions: (pc=0x6d02bcbd)
0x6d02bcad: 00 00 00 8b 4c 24 14 8b e9 c1 e9 02 8b f0 8b fa
0x6d02bcbd: f3 a5 8b cd 83 e1 03 f3 a4 8b 74 24 18 8b 4c 24
Stack: [0x02eb0000,0x02f00000], sp=0x02eff4a4, free space=317k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [awt.dll+0x2bcbd]
[error occurred during error reporting (printing native stack), id 0xc0000005]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j sun.awt.windows.WToolkit.eventLoop()V+0
j sun.awt.windows.WToolkit.run()V+69
j java.lang.Thread.run()V+11
v ~StubRoutines::call_stub
</code></pre>
| [
{
"answer_id": 379814,
"author": "Lawrence Dol",
"author_id": 8946,
"author_profile": "https://Stackoverflow.com/users/8946",
"pm_score": 1,
"selected": false,
"text": "Stack: [0x02eb0000,0x02f00000], sp=0x02eff4a4, free space=317k\nNative frames: (J=compiled Java code, j=interpreted, Vv... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47508/"
] |
379,581 | <p>I have an application that I'm trying to debug a crash in. However, it is difficult to detect the problem for a few reasons:</p>
<ul>
<li>The crash happens at shutdown, meaning the offending code isn't on the stack</li>
<li>The crash only happens in release builds, meaning symbols aren't available</li>
</ul>
<p>By crash, I mean the following exception:</p>
<pre><code>0xC0000005: Access violation reading location 0x00000000.
</code></pre>
<p><strong>What strategy would you use to diagnose this problem?</strong></p>
<p>What I have done so far is remove as much code from my program until I get the bare minimum that will cause the crash. It seems to be happening in code that is statically linked to the project, so that doesn't help, either.</p>
| [
{
"answer_id": 379599,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 1,
"selected": false,
"text": "valgrind"
}
] | 2008/12/18 | [
"https://Stackoverflow.com/questions/379581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28776/"
] |
379,594 | <p>I am reading file from ResultSet and it's required to save file into Oracle Database.</p>
<pre><code>...
ResultSet rs = ...
java.sql.Blob myfile = rs.getBlob("field")
java.io.OutputStream os = ((oracle.sql.BLOB) myfile).getBinaryOutputStream();
</code></pre>
<p>I get get this error message</p>
<pre><code>java.lang.ClassCastException
</code></pre>
<p>Any one have solution to this? Thanks!</p>
| [
{
"answer_id": 379605,
"author": "Dan Vinton",
"author_id": 21849,
"author_profile": "https://Stackoverflow.com/users/21849",
"pm_score": 2,
"selected": false,
"text": "java.sql.Blob ResultSet oracle.sql.BLOB myfile.getClass()"
},
{
"answer_id": 1168936,
"author": "netic",
... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44534/"
] |
379,595 | <p>I have this structure in my app:</p>
<p>USER has_one :publicprofile, :privateprofile</p>
<p>PUBLICPROFILE has many :emails, :phonenumbers</p>
<p>PRIVATEPROFILE has many :adresses, :creditcards</p>
<p>I would like to know how to go about having a profile page for the user where I can update his nested resources (and do it in a RESTful way). I couldn't find any docs/examples on the subject (because of that confusing has_one relation).</p>
| [
{
"answer_id": 421186,
"author": "Russ Johnson",
"author_id": 52503,
"author_profile": "https://Stackoverflow.com/users/52503",
"pm_score": 2,
"selected": false,
"text": "map.resources :users do |user|\n user.resources :privateprofile\n user.resources :publicprofile\nend\n users/1/publ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47579/"
] |
379,607 | <p>What is the best way to determine which ASP.NET button was clicked on a single page using JavaScript?</p>
| [
{
"answer_id": 379616,
"author": "Craig",
"author_id": 27294,
"author_profile": "https://Stackoverflow.com/users/27294",
"pm_score": 1,
"selected": false,
"text": "Button1.Attributes.Add(\"onclick\", \"alert('You clicked me!');\");\n"
},
{
"answer_id": 379619,
"author": "Robe... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26327/"
] |
379,610 | <p>Is it possible to nest html forms like this</p>
<pre><code><form name="mainForm">
<form name="subForm">
</form>
</form>
</code></pre>
<p>so that both forms work? My friend is having problems with this, a part of the <code>subForm</code> works, while another part of it does not.</p>
| [
{
"answer_id": 379622,
"author": "Craig",
"author_id": 27294,
"author_profile": "https://Stackoverflow.com/users/27294",
"pm_score": 10,
"selected": true,
"text": "form"
},
{
"answer_id": 379630,
"author": "Jonathan Lonowski",
"author_id": 15031,
"author_profile": "ht... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27620/"
] |
379,643 | <p>Some of Oracle's analytic functions allow for a <a href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions001.htm#i97640" rel="nofollow noreferrer">windowing clause</a> to specify a subset of the current partition, using keywords like "unbounded preceding/following", "current row", or "value_expr preceding/following" where value_expr is a physical or logical offset from the current row or value (depending on whether you have specified ROW or RANGE, respectively). </p>
<p>Here is an example using scott/tiger that displays employees in dept 30, and a count of the number of employees in their dept hired before them (including themselves):</p>
<pre><code>select deptno,
empno,
hiredate,
count(*) over (partition by deptno
order by hiredate
range between unbounded preceding and current row) cnt_hired_before1,
count(*) over (partition by deptno
order by hiredate
range between unbounded preceding and 0 preceding) cnt_hired_before2
from emp
where deptno = 30
order by deptno, hiredate;
</code></pre>
<p>...can anyone provide an example or documentation where "current row" is different than "0 preceding/following"? It just seems like syntactic sugar to me...</p>
| [
{
"answer_id": 379670,
"author": "user34850",
"author_id": 34850,
"author_profile": "https://Stackoverflow.com/users/34850",
"pm_score": -1,
"selected": false,
"text": " select deptno, \n empno,\n hiredate,\n count(*) over (partition by deptno, trunc(hiredate,'mm')) ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19239/"
] |
379,648 | <p>I've received some documentation from one of our suppliers for a webservice they're publishing and they're very specific that on one of their WebMethods that an argument has the out modifier(? not sure if that's the right descriptor) for instance consider the following WebMethod signature:</p>
<pre><code>[WebMethod]
public void HelloWorld(out string strVal)
{
strVal = "Hello World";
}
</code></pre>
<p>[Obviously the actual method isn't a Hello World method] </p>
<p>Now, I'd never considered designing a WebMethod with an out/ref argument and it got me wondering why they would've used it.</p>
<p>Trying to understand an application for this design decision I threw a prototype together with a few basic Hello World style webmethods...one with a single out string argument, one with two out string arguments and one that doesn't receive any arguments but returns a string.</p>
<p>Upon trying to reference my webmethods from a separate application I notice that I have to access the method with the single out string argument exactly as if I'd defined the method to output the string so that in effect as far as the client is concerned:</p>
<pre><code>public string HelloWorld1()
{
return "Hello World";
}
</code></pre>
<p>and</p>
<pre><code>public void HelloWorld2(out string strVal)
{
strVal = "Hello World";
}
</code></pre>
<p>are exactly the same...in that I have to reference them both as such [where x is substituted for the correct method]:</p>
<pre><code>string val = HelloWorldX();
</code></pre>
<p>Having attempted to reference the methods in the way I would access them if they weren't web methods [like so]:</p>
<pre><code>string val = string.Empty;
MyService1.HelloWorld(out val);
Console.WriteLine(val);
</code></pre>
<p>which causes a compilation error stating that no method arguments accept 1 input. Why is that? There's obviously a web method that accepts one argument - I'm looking at it [HelloWorld2].</p>
<p>Upon examining the SOAP responses, I notice that the content of the response for HelloWorld1 is:</p>
<pre><code><HelloWorld1Response xmlns="http://tempuri.org/">
<HelloWorld1Result>string</HelloWorld1Result>
</HelloWorld1Response>
</code></pre>
<p>And HelloWorld2 is</p>
<pre><code><HelloWorld2Response xmlns="http://tempuri.org/">
<strVal>string</strVal>
</HelloWorld2Response>
</code></pre>
<p>Going a step further I thought, what if I have 2 ref arguments...</p>
<pre><code>public void HelloWorld3(out string strVal1, out string strVal2)
{
strVal1 = "Hello World";
strVal2 = "Hello World Again!";
}
</code></pre>
<p>This generates the SOAP content:</p>
<pre><code><HelloWorld3Response xmlns="http://tempuri.org/">
<strVal1>string</strVal1>
<strVal2>string</strVal2>
</HelloWorld3Response>
</code></pre>
<p>I thought fair enough, so theoretically [providing I can figure out a way to pass out/ref arguments to WebMethods] that means I can just pass in two arguments that can be set by the method, but when I do this:</p>
<pre><code>string val1 = string.Empty;
string val2 = string.Empty;
MyService1.HelloWorld3(out val1,out val2);
Console.WriteLine(val1);
Console.WriteLine(val2);
</code></pre>
<p>I should get the same compilation error I saw when I tried to reference the HelloWorld2 this way. With the obvious exception that it's complaining about 2 arguments instead of 1 [and in fact I do get the same exception, I tested it].</p>
<ul>
<li>What gives?</li>
<li>Is there a reason or a way to use out/ref arguments in WebMethods that I'm missing? </li>
<li>If there is, how do I reference WebMethods with multiple out/ref arguments?</li>
</ul>
| [
{
"answer_id": 380108,
"author": "BenAlabaster",
"author_id": 40650,
"author_profile": "https://Stackoverflow.com/users/40650",
"pm_score": 5,
"selected": true,
"text": "[WebMethod]\npublic string Method1()\n{\n return \"This is my return value\";\n}\n\n[WebMethod]\npublic void Method... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40650/"
] |
379,649 | <p>This code involves a recursive Stored Procedure call and a "not so great" method of avoiding cursor name collision. In the end I don't care if it uses cursors or not. Just looking for the most elegant approach. I'm mainly going to use it as a simple method to track down Stored Proc hierarchies (without buying a product). I tried cursors within "dynamic sql" and didn't have much luck. I'd like to go about 10 levels deep.</p>
<p>The desired output:</p>
<pre>
sp_Master_Proc_Name
-- sp_Child_Proc_1_Name
---- sp_Sub_Proc_1_Name
-- sp_Child_Proc_2_Name
-- sp_Child_Proc_3_Name
</pre>
<p>Its not pretty, but here is the code (and it didn't work as expected)</p>
<pre><code> CREATE PROCEDURE SP_GET_DEPENDENCIES
(
@obj_name varchar(300),
@level int
)
AS
DECLARE @sub_obj_name varchar(300)
IF @level = 1
BEGIN
PRINT @obj_name
END
IF @level = 1
BEGIN
DECLARE the_cursor_1 CURSOR FOR
SELECT DISTINCT REPLICATE('--', @level) + ' ' + c.name FROM dbo.sysdepends a
INNER JOIN dbo.sysobjects b ON a.id = b.id
INNER JOIN dbo.sysobjects c ON a.depid = c.id
WHERE b.name = @obj_name
OPEN the_cursor_1
SET @level = @level + 1
FETCH NEXT FROM the_cursor_1 INTO @sub_obj_name
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @sub_obj_name
EXEC SP_GET_DEPENDENCIES @sub_obj_name, @level
FETCH NEXT FROM the_cursor_1 INTO @sub_obj_name
END
CLOSE the_cursor_1
DEALLOCATE the_cursor_1
END
IF @level = 2
BEGIN
DECLARE the_cursor_2 CURSOR FOR
SELECT DISTINCT REPLICATE('--', @level) + ' ' + c.name FROM dbo.sysdepends a
INNER JOIN dbo.sysobjects b ON a.id = b.id
INNER JOIN dbo.sysobjects c ON a.depid = c.id
WHERE b.name = @obj_name
OPEN the_cursor_2
SET @level = @level + 1
FETCH NEXT FROM the_cursor_2 INTO @sub_obj_name
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @sub_obj_name
EXEC SP_GET_DEPENDENCIES @sub_obj_name, @level
FETCH NEXT FROM the_cursor_2 INTO @sub_obj_name
END
CLOSE the_cursor_2
DEALLOCATE the_cursor_2
END
IF @level = 3
BEGIN
DECLARE the_cursor_3 CURSOR FOR
SELECT DISTINCT REPLICATE('--', @level) + ' ' + c.name FROM dbo.sysdepends a
INNER JOIN dbo.sysobjects b ON a.id = b.id
INNER JOIN dbo.sysobjects c ON a.depid = c.id
WHERE b.name = @obj_name
OPEN the_cursor_3
SET @level = @level + 1
FETCH NEXT FROM the_cursor_3 INTO @sub_obj_name
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @sub_obj_name
EXEC SP_GET_DEPENDENCIES @sub_obj_name, @level
FETCH NEXT FROM the_cursor_3 INTO @sub_obj_name
END
CLOSE the_cursor_3
DEALLOCATE the_cursor_3
END
</code></pre>
| [
{
"answer_id": 379821,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 4,
"selected": true,
"text": "CREATE PROCEDURE uspPrintDependencies\n(\n @obj_name varchar(300),\n @level int\n)\nAS\nSET NOCOUNT ON\nDECLARE ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] |
379,650 | <p>I need to get array fragments from an array. I'm sick of using Array.Copy().
new ArraySegment(..).Array returns the original [full] array. The one below is what I came up with but I feel it's pretty lame. Is there a better way to do this?</p>
<p><code></p>
<pre><code>class Program
{
static void Main(string[] args)
{
var arr = new ArraySegment<byte>(new byte[5] { 5, 4, 3, 2, 1 }, 0, 2).ArrayFragment();
for (int i = 0; i < arr.Length; i++)
Console.WriteLine(i);
Console.Read();
}
}
static class Extensions
{
public static T[] ArrayFragment<T>(this ArraySegment<T> segment)
{
var arr = new T[segment.Count];
Array.Copy(segment.Array, segment.Offset, arr, 0, segment.Count);
return arr;
}
}
</code></pre>
<p></code></p>
<p>Thanks in advance.</p>
<p>Update:
The above was just an example.<br>
I have a method: byte [] CalculateXXX(byte [] key, byte [] message);
I do array manipulations inside this method. I want to return portion of an array.
ArraySegment does not implement IEnumerable and it does NOT return an array with just the segment new ArraySegment(arr...).Array returns the complete original array.</p>
<p><code></p>
<p>var rval = new byte[4];
//new ArraySegment(finalOutputBuffer, 0, 4).SegmentedArray();
Array.Copy(finalOutputBuffer, 0, rval, 0, 4);</p>
<p></code></p>
<p>I find I had to do the above to return a array fragment. Was just wondering if there's a better way of returning fragments of an array [as new array].</p>
| [
{
"answer_id": 379666,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 1,
"selected": false,
"text": "**** ArraySegment ArraySegment ArraySegment ArraySegment T[] IEnumerable<T> IList<T>"
}
] | 2008/12/18 | [
"https://Stackoverflow.com/questions/379650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28413/"
] |
379,652 | <p>I have a page where I combine labels, input boxes and text areas to display some content.
I would like all of them to have the same font-family and font-size.
I have played with the <em>font-family: inherit</em> style but this doesn't seem to work for the input and text areas.
What would be the easiest way to ensure the same font / size over the whole page.</p>
| [
{
"answer_id": 379658,
"author": "Gene Roberts",
"author_id": 47544,
"author_profile": "https://Stackoverflow.com/users/47544",
"pm_score": 1,
"selected": false,
"text": "*\n{\n font-family: arial;\n}\n"
},
{
"answer_id": 379679,
"author": "Drejc",
"author_id": 6482,
... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6482/"
] |
379,661 | <p>At my job, I have to implement web forms for loan applications with sometimes up to a hundred different input fields, and then save the application into the database for later retrieval.</p>
<p>The person whom I replaced created a sql table with 100s of columns where each row represents a loan application and there is a column for every field.</p>
<p>The problem with this is that I find myself having to type out the 100 fields a bunch of times, getting data from form, saving to database, retrieving from database, writing to output webform. </p>
<p>And then whenever there is a change to the application, I have to make the change in quite a few places. </p>
<p>So it can not only be cumbersome but error prone.</p>
<p>Is there a good design pattern that handles this?</p>
| [
{
"answer_id": 379726,
"author": "Geo",
"author_id": 47222,
"author_profile": "https://Stackoverflow.com/users/47222",
"pm_score": 0,
"selected": false,
"text": "internal List<string> GetFieldList(string sTableName)\n {\n tableName = sTableName;\n BuildQuery(\"*\");\n ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
379,675 | <p>First, to make my job explaining a bit easier, here's some of my code:</p>
<pre><code>JSpinner spin = new JSpinner();
JFormattedTextField text = getTextField(spin);
text.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
// Do stuff...
}
});
</code></pre>
<p>...</p>
<pre><code>private JFormattedTextField getTextField(JSpinner spinner) {
JComponent editor = spinner.getEditor();
if (editor instanceof JSpinner.DefaultEditor) {
return ((JSpinner.DefaultEditor )editor).getTextField();
} else {
System.err.println( "Unexpected editor type: "
+ spinner.getEditor().getClass()
+ " isn't a descendant of DefaultEditor" );
return null;
}
}
</code></pre>
<p>So as you can see, I got that far. And indeed, when I type in a value into the text field component of the spinner (<code>JFormattedTextField</code>), and THEN press ENTER, it works.</p>
<p>What I want now is to be able to have the text field respond to ENTER without having to manually type in a new value (which sorta defeats the purpose of making a spinner out of it). How do I do that?</p>
| [
{
"answer_id": 379787,
"author": "javamonkey79",
"author_id": 27657,
"author_profile": "https://Stackoverflow.com/users/27657",
"pm_score": 4,
"selected": true,
"text": "\n text.addKeyListener( new KeyAdapter() {\n @Override\n public void keyReleased( final KeyEv... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19825/"
] |
379,677 | <p>While reading a file (ifstream), is there any way to direct it to make a new line?</p>
<p>For instance, I would like for THIS to happen:</p>
<p>myfile>>array[1]>>array[2]>>endl;</p>
<p>Obviously, the "endl" just isn't allowed. Is there another way to do this?</p>
<p>Edit---thanks for the quick responses guys! </p>
<p>From a text file, I'm trying to store two strings from that file into arrays and then do the same with the next line (or until I desire, using a for loop)</p>
<p>Using strings is important to me as it will make my future program a lot more flexible.</p>
| [
{
"answer_id": 379702,
"author": "Zan Lynx",
"author_id": 13422,
"author_profile": "https://Stackoverflow.com/users/13422",
"pm_score": 2,
"selected": false,
"text": "myfile.ignore(8192, '\\n')"
},
{
"answer_id": 379782,
"author": "Martin York",
"author_id": 14065,
"a... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
379,682 | <p>The font used in xterms is extremely compact yet readable. What font is that? The closest I've found that I can use in other other applications is DejaVu Sans Mono or Bitstream Vera Sans Mono. Those are as compact as xterms vertically but take up more space horizontally.</p>
<p>I'd really like to switch from xterms to Terminal.app and this is the one thing holding me back.</p>
<p>(I also think that font would be much better for emacs, xcode, or whatever editor.)</p>
<p>ADDED: In Terminal.app you can adjust the character and line spacing for any font. Is this possible in other applications?</p>
<p>I'm open to any other font that is as compact and readable as the xterm font. Dina looks really nice but it doesn't seem to work for Mac.</p>
| [
{
"answer_id": 379795,
"author": "Arthur Reutenauer",
"author_id": 46495,
"author_profile": "https://Stackoverflow.com/users/46495",
"pm_score": 1,
"selected": false,
"text": "-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso8859-1 /usr/X11/lib/X11/fonts/misc/7x14-ISO8859-1.pcf.gz /usr/... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4234/"
] |
379,686 | <p>I've more than one ASP.NET 2.0 web site on IIS 6 and Windows Server 2003.
Each site reference some DLLs: design, logic and so on.
Each site is on a different ApplicationPool with default configuration about recycling techniques.</p>
<p>Every DLL is strong named (not delayed) and has a version that never changes (2.0.0.0), all DLLs are placed in GAC.</p>
<p>After I update a DLL in GAC (ie. MyLibrary.dll) that has changed in something (method, classes..) for the use in web-site "A", and after recycling only the "A" application pool, when I try to access to web-site "B" that reference the same DLL I get the common error about that DLL:</p>
<blockquote>
<p>The located assembly's manifest
definition does not match the assembly
reference. (Exception from HRESULT:
0x80131040)</p>
</blockquote>
<p>Of course nothing is changed in DLL rather than code, same strongkey, same version, culture. The error disappear over recycling "B" application pool, of course.</p>
<p>What can generate a strange, <strong>RANDOM</strong> (I've to say!), behavior? There's something more, like hashing, that it's used to compare assemblies?</p>
<h2>Addendum</h2>
<ul>
<li><a href="https://stackoverflow.com/users/37494/perpetualcoder">Perpetualcoder</a> asked me how DLLs are referenced, if with full qualified name, I think it is, here a line of web.config:</li>
</ul>
<blockquote>
<p>assembly="MyNamespace.MyComponent,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=1234567890ASDFGH"</p>
</blockquote>
| [
{
"answer_id": 379795,
"author": "Arthur Reutenauer",
"author_id": 46495,
"author_profile": "https://Stackoverflow.com/users/46495",
"pm_score": 1,
"selected": false,
"text": "-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso8859-1 /usr/X11/lib/X11/fonts/misc/7x14-ISO8859-1.pcf.gz /usr/... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47458/"
] |
379,689 | <p>I have been trying to figure out how to programmatically identify the process that has a lock on a particular file. I've searched through the Win32 API and WMI, but so far I can't find anything. I know it's possible - Sysinternals is able to list every resource accessed/locked by every process on the system.</p>
<p>Can anyone drop me a hint?</p>
| [
{
"answer_id": 14285780,
"author": "thejoshwolfe",
"author_id": 367916,
"author_profile": "https://Stackoverflow.com/users/367916",
"pm_score": 6,
"selected": true,
"text": "> handle /accepteula C:\\path\\to\\directory\n...\nprogram.exe pid: 1234 type: File 2E4: C:\... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
379,695 | <p>I am just learning php as I go along, and I'm completely lost here. I've never really used join before, and I think I need to here, but I don't know. I'm not expecting anyone to do it for me but if you could just point me in the right direction it would be amazing, I've tried reading up on joins but there are like 20 different methods and I'm just lost.</p>
<p>Basically, I hand coded a forum, and it works fine but is not efficient. </p>
<p>I have board_posts (for posts) and board_forums (for forums, the categories as well as the sections).</p>
<p>The part I'm redoing is how I get the information for the last post for the index page. The way I set it up is that to avoid using joins, I have it store the info for latest post in the table for board_forums, so say there is a section called "Off Topic" there I would have a field for "forum_lastpost_username/userid/posttitle/posttime" which I woudl update when a user posts etc. But this is bad, I'm trying to grab it all dynamically and get rid of those fields.</p>
<p>Right now my query is just like: </p>
<pre><code>`SELECT * FROM board_forums WHERE forum_parent='$forum_id''
</code></pre>
<p>And then I have the stuff where I grab the info for that forum (name, description, etc) and all the data for the last post is there:</p>
<pre><code> $last_thread_title = $forumrow["forum_lastpost_title"];
$last_thread_time = $forumrow["forum_lastpost_time"];
$lastpost_username = $forumrow["forum_lastpost_username"];
$lastpost_threadid = $forumrow["forum_lastpost_threadid"];
</code></pre>
<p>But I need to get rid of that, and get it from board_posts. The way it's set up in board_posts is that if it's a thread, post_parentpost is NULL, if it's a reply, then that field has the id of the thread (first post of the topic). So, I need to grab the latest post_date, see which user posted that, THEN see if parentpost is NULL (if it's null then the last post is a new thread, so I can get all the info of the title and user there, but if it's not, then I need to get the info (title, id) of the first post in that thread (which can be found by seeing what post_parentpost is, looking up that ID and getting the title from it.</p>
<p>Does that make any sense? If so please help me out :(</p>
<p>Any help is greatly appreciated!!!!</p>
| [
{
"answer_id": 563720,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 1,
"selected": false,
"text": "SELECT * FROM board_forums\nJOIN board_posts ON board_posts.forum_id = board_forums.id\nWHERE forum_parent = '$forum_id'... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
379,722 | <p>Unmanaged languages notwithstanding, is F# really better than C# for implementing math? And if that's the case, why?</p>
| [
{
"answer_id": 2259635,
"author": "J D",
"author_id": 13924,
"author_profile": "https://Stackoverflow.com/users/13924",
"pm_score": 4,
"selected": false,
"text": "inline System.Double float32 float System.Numerics.Complex"
}
] | 2008/12/18 | [
"https://Stackoverflow.com/questions/379722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9476/"
] |
379,748 | <p>I'm trying to set up a small app to experiment with NHibernate in visual studio but I'm not getting far. </p>
<p>The error I get is: "Could not find the dialect in the configuration".</p>
<p>I've tried specifying settings in both app.config and hibernate.cfg.xml but neither seems to work. These files are in the same directory as my app source (tried other directories too). I've tried setting the build action on hibernate.cfg.xml as "embedded resource" but that didn't help either. I get the same error message even if I completely remove these config files.</p>
<p>I've looked at various examples on the net but can't get it sorted ... Does anyone know what the problem could be?</p>
<p>Here is my application source,app.config and hibernate.cfg.xml</p>
<h2>Application Source</h2>
<pre><code>using NHibernate;
using NHibernate.Cfg;
namespace Timer
{
public partial class Form1 : Form
{
Configuration cfg;
ISessionFactory factory;
ISession session;
ITransaction transaction;
public Form1()
{
cfg = new Configuration();
//cfg.AddAssembly("Timer");
//cfg.AddFile("WorkoutSet.hbm.xml");
factory = cfg.BuildSessionFactory();
session = factory.OpenSession();
transaction = session.BeginTransaction();
InitializeComponent();
}
}
}
</code></pre>
<h2>App.Config</h2>
<pre><code><?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section
name="nhibernate"
type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
/>
<section
name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"
/>
</configSections>
<nhibernate>
<add
key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider"
/>
<add
key="hibernate.dialect"
value="NHibernate.Dialect.FirebirdDialect"
/>
<add
key="hibernate.connection.driver_class"
value="NHibernate.Driver.FirebirdClientDriver"
/>
<add
key="hibernate.connection.connection_string"
value="User=sysdba;Password=masterkey;Database=C:\X\Test\Timer\Timer.FDB;Dialect=3;ServerType=1;"
/>
</nhibernate>
<log4net debug="false">
<!-- Define some output appenders -->
<appender name="trace"
type="log4net.Appender.TraceAppender, log4net">
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern"
value="%d{ABSOLUTE} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>
<appender name="console"
type="log4net.Appender.ConsoleAppender, log4net">
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern"
value="%d{ABSOLUTE} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>
<appender name="rollingFile"
type="log4net.Appender.RollingFileAppender,log4net" >
<param name="File" value="h:\log.txt" />
<param name="AppendToFile" value="false" />
<param name="RollingStyle" value="Date" />
<param name="DatePattern" value="yyyy.MM.dd" />
<param name="StaticLogFileName" value="true" />
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern"
value="%d [%t] %-5p %c - %m%n" />
</layout>
</appender>
<!-- Setup the root category, add the appenders and set the default priority -->
<root>
<priority value="DEBUG" />
<appender-ref ref="console" />
</root>
<logger name="NHibernate">
<level value="DEBUG" />
</logger>
</log4net>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<qualifyAssembly partialName="FirebirdSql.Data.FirebirdClient"
fullName="FirebirdSql.Data.FirebirdClient, Version=2.0.1.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c" />
</assemblyBinding>
</runtime>
</configuration>
</code></pre>
<h2>hibernate.cfg.xml</h2>
<pre><code><?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section
name="nhibernate"
type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
/>
</configSections>
<nhibernate>
<add
key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider"
/>
<add
key="hibernate.dialect"
value="NHibernate.Dialect.FirebirdDialect"
/>
<add
key="hibernate.connection.driver_class"
value="NHibernate.Driver.FirebirdClientDriver"
/>
<add
key="hibernate.connection.connection_string"
value="User=sysdba;Password=masterkey;Database=C:\X\Test\Timer\Timer.FDB;Dialect=3;ServerType=1;"
/>
</nhibernate>
</configuration>
</code></pre>
| [
{
"answer_id": 380044,
"author": "Sam",
"author_id": 47636,
"author_profile": "https://Stackoverflow.com/users/47636",
"pm_score": 1,
"selected": false,
"text": "configSections <configSections>\n <section name=\"hibernate-configuration\" type=\"NHibernate.Cfg.ConfigurationSectionHan... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379748",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74652/"
] |
379,768 | <p>For example, will SQL Server warn you or does it just die?</p>
| [
{
"answer_id": 379786,
"author": "joshperry",
"author_id": 30587,
"author_profile": "https://Stackoverflow.com/users/30587",
"pm_score": 5,
"selected": true,
"text": "Server: Msg 8115, Level 16, State 1, Line 1\nArithmetic overflow error converting IDENTITY to data type int.\nArithmetic ... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/245/"
] |
379,772 | <p>I am using this example:</p>
<pre><code>char *myData[][2] =
{{"John", "j@usa.net"},
{"Erik", "erik@usa.net"},
{"Peter","peter@algonet.se"},
{"Rikard","rikard@algonet.se"},
{"Anders","anders@algonet.se"}};
char **tableData[6];
tableData[0] = myData[0];
tableData[1] = myData[1];
tableData[2] = myData[2];
tableData[3] = myData[3];
tableData[4] = myData[4];
tableData[5] = NULL;//null terminated array
</code></pre>
<p>and instead want to place my own strings for name and emails.
(trying to place string xyz into myData, then tableData)
strcpy with myData wont work. I have tried all combination's of pointers and referencing but it doesn't seem to copy the string. Any suggestions?</p>
<pre><code> ok--> strncpy(xyz, argv[i], strlen(argv[i]));
ok--> strcpy(xyz + strlen(argv[i]), "\0");
run time stops here--> strncpy(myData[i][0], xyz, strlen(xyz));
tableData[i] = myData[i];
</code></pre>
| [
{
"answer_id": 379792,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 2,
"selected": false,
"text": "myData[][] myData"
},
{
"answer_id": 379812,
"author": "Adam Pierce",
"author_id": 5324,
"author_... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46767/"
] |
379,791 | <p>I am playing movie using MPMoviePlayerController,</p>
<p>I am using TableView,what happening with my application is when I press accessory button it will display detailed view and when I press cell area it will play movie that I wanted,(the way youtube application does)</p>
<p>but when I press "DONE" while playin movie it'll navigate to a view which is not my detail view but some empty view.</p>
<p>Any idea what should I do to achieve it so that when user press "DONE" it will nevigate me to my detail view instead of some empty view.</p>
<p>I tried to push view when "movieFinishedCallback" is executed but it'll pushing one more view on that empty view.</p>
| [
{
"answer_id": 1819344,
"author": "ReinYem",
"author_id": 221292,
"author_profile": "https://Stackoverflow.com/users/221292",
"pm_score": 0,
"selected": false,
"text": "-(void)myMovieFinishedCallback:(NSNotification*)aNotification { \n MPMoviePlayerController* theMovie = [aNotificatio... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/451867/"
] |
379,797 | <p>I have <code>periodically_call_remote</code> updating a div (<code>main_div</code>) in my web app. This <code>main_div</code> contains links that the user can click that invokes an action that overwrites data within <code>main_div</code>.</p>
<p>My problem is that the timer is running on the <code>periodically_call_remote</code> function and even though the user has navigated away from the page, that function call still wants to return. If the <code>main_div</code> is present on the page the function call wipes out the data that was currently being displayed. If the <code>main_div</code> is not on the page then the javascript returns an error dialog.</p>
<p>So, my question is, when the user navigates away from the div that is periodically being updated, how do I stop the function call?</p>
| [
{
"answer_id": 381716,
"author": "salt.racer",
"author_id": 757,
"author_profile": "https://Stackoverflow.com/users/757",
"pm_score": 4,
"selected": true,
"text": "periodically_call_remote application_helper.rb PeriodicalExecutor poller.stop();"
}
] | 2008/12/19 | [
"https://Stackoverflow.com/questions/379797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/757/"
] |
379,815 | <p>I have two versions of my application, one "stage" and one "dev."</p>
<p>Right now, "stage" is exposed to the real world for beta-testing.</p>
<p>From time to time, I want an exact replica of the data to be replicated into the "dev" database.</p>
<p>Both databases are on the same hosted Linux machine.</p>
<p>Sometimes I create "dummy" data in the development environment. At this stage, I'd be fine if it needs to get written over in stage.</p>
<p>Thanks.</p>
| [
{
"answer_id": 381604,
"author": "Geo",
"author_id": 47222,
"author_profile": "https://Stackoverflow.com/users/47222",
"pm_score": 3,
"selected": true,
"text": "mysqldump -u username --password=userpass --add-drop-database --add=locks --create-options --disable-keys --extend-insert --res... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43980/"
] |
379,818 | <p>I'm compiling some C# and VB code at run time using the CodeDomProvider, CompilerInfo, and CompilerParameters. It works great, and I really like being able to add scripting support to my application, but it only seems to support .NET 2.0 syntax. For example, the var keyword isn't supported in C#, and the If(bool, string, string) expression isn't supported in VB.</p>
<p>How can I tell it to target the 3.5 framework?</p>
| [
{
"answer_id": 379819,
"author": "Don Kirkby",
"author_id": 4794,
"author_profile": "https://Stackoverflow.com/users/4794",
"pm_score": 4,
"selected": true,
"text": "<system.codedom>\n <compilers>\n <compiler\n language=\"vb;vbs;visualbasic;vbscript\"\n extension=\".vb\"\n ... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4794/"
] |
379,827 | <p>As far as I know, there's no way to use {% include %} within a dynamic JS file to include styles. But I don't want to have to make another call to the server to download styles. </p>
<p>Perhaps it would be possible by taking a stylesheet and injecting it into the head element of the document...has anyone does this before? </p>
| [
{
"answer_id": 379905,
"author": "codegy",
"author_id": 40538,
"author_profile": "https://Stackoverflow.com/users/40538",
"pm_score": 3,
"selected": true,
"text": "var style = document.createElement('link');\nstyle.setAttribute('rel', 'stylesheet');\nstyle.setAttribute('type', 'text/css'... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9106/"
] |
379,838 | <p>I've got a form with a bunch of textboxes that are disabled by default, then enabled by use of a checkbox next to each one.</p>
<p>When enabled, the values in these textboxes are required to be a valid number, but when disabled they don't need a value (obviously). I'm using the jQuery Validation plugin to do this validation, but it doesn't seem to be doing what I expect.</p>
<p>When I click the checkbox and disable the textbox, I still get the invalid field error despite the <code>depends</code> clause I've added to the rules (see code below). Oddly, what actually happens is that the error message shows for a split second then goes away.</p>
<p>Here is a sample of the list of checkboxes & textboxes:</p>
<pre><code><ul id="ItemList">
<li>
<label for="OneSelected">One</label><input id="OneSelected" name="OneSelected" type="checkbox" value="true" />
<input name="OneSelected" type="hidden" value="false" />
<input disabled="disabled" id="OneValue" name="OneValue" type="text" />
</li>
<li>
<label for="TwoSelected">Two</label><input id="TwoSelected" name="TwoSelected" type="checkbox" value="true" />
<input name="TwoSelected" type="hidden" value="false" />
<input disabled="disabled" id="TwoValue" name="TwoValue" type="text" />
</li>
</ul>
</code></pre>
<p>And here is the jQuery code I'm using</p>
<pre><code>//Wire up the click event on the checkbox
jQuery('#ItemList :checkbox').click(function(event) {
var textBox = jQuery(this).siblings(':text');
textBox.valid();
if (!jQuery(this).attr("checked")) {
textBox.attr('disabled', 'disabled');
textBox.val('');
} else {
textBox.removeAttr('disabled');
textBox[0].focus();
}
});
//Add the rules to each textbox
jQuery('#ItemList :text').each(function(e) {
jQuery(this).rules('add', {
required: {
depends: function(element) {
return jQuery(element).siblings(':checkbox').attr('checked');
}
},
number: {
depends: function(element) {
return jQuery(element).siblings(':checkbox').attr('checked');
}
}
});
});
</code></pre>
<p>Ignore the hidden field in each <code>li</code> it's there because I'm using asp.net MVC's <code>Html.Checkbox</code> method.</p>
| [
{
"answer_id": 651876,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "// Removes all values from disabled fields upon submit\n$(form).submit(function() {\n $(input[type=text][disabled=disabled])... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2975/"
] |
379,854 | <p>I have a script that did double inserts into the database with the same data. Is there a good way to do this (without scanning through, inserting every record into an array, and then deleting duplicate array entries)?</p>
| [
{
"answer_id": 379861,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 3,
"selected": false,
"text": "DELETE\nFROM t\nWHERE ID IN (\n SELECT MAX(ID)\n FROM t\n GROUP BY {Your Group Criteria Here}\n HAVING COUNT... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/144/"
] |
379,856 | <p>I'm doing some revision on an old app that is written in classic ASP/VbScript.</p>
<p>It has a feature to send out an e-mail to the members of the application, but because the member list is quite large, the server rejects new e-mails after the first hundred or so are sent.</p>
<p>I've written some code to make it send out e-mails in burst of 20, but this still doesn't work. I think that perhaps making it sleep for a second between burst might work properly.</p>
<p>However, I can't seem to find a Thread.Sleep type method in VbScript. </p>
<p>Is there one?</p>
| [
{
"answer_id": 7711368,
"author": "Jonh",
"author_id": 987489,
"author_profile": "https://Stackoverflow.com/users/987489",
"pm_score": 2,
"selected": false,
"text": "var shell = Server.CreateObject(\"WScript.Shell\");\nshell.run(\"CHOICE /C:AB /D:A /T:1 > NUL\", 1, true);\n"
},
{
... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] |
379,865 | <p>My right side bar isn't staying on top. </p>
<p>These are the two pages for example. www.cafecartel.com </p>
<p>and www.cafecartel.com.index2.php</p>
<p>Currently the way the site is written, the right side bar must be placed like this:</p>
<p>body id="Support"
div id="container1"
div id="container2"</p>
<pre><code>div id="header"
?php include("inc/header.inc"); ?
h1 Point of Sale for Restaurants, POS Retail and Inventory by Cafe Cartel/h1
/div
</code></pre>
<p>div id="wrapper"
div id="content"</p>
<pre><code>div id="sidebar"
?php include("inc/sidebar_justafew.inc"); ?
?php include("inc/sidebar_whouses.inc"); ?
/div
</code></pre>
<p>div id="maincontent"</p>
<hr>
<p>What i want is to be able place the Sidebar <strong>Beneath</strong> the Main Content. For SEO.</p>
<p>This is the CSS for the side bar:</p>
<h1>sidebar {</h1>
<pre><code>float: right;
position: relative;
left: 178px;
width: 166px;
padding-top: 5px;
margin-left: -165px;
margin-bottom: 50px;
line-height: 1.4em;
voice-family: "\"}\"";
voice-family: inherit;
width: 165px;
}
</code></pre>
<p>All help is appreciated. Thank you</p>
| [
{
"answer_id": 379994,
"author": "Michael T. Smith",
"author_id": 22292,
"author_profile": "https://Stackoverflow.com/users/22292",
"pm_score": 1,
"selected": false,
"text": "#content { clear: both; } #maincontent { float: left; } #sidebar { float: right; }"
},
{
"answer_id": 385... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
379,871 | <p>I have an ASP.NET 2.0 application that spends an excessive amount of time in garbage collection, over 40%, when load tested on a production grade server (dual quad-core, 4g).
I have been trying to isolate the problem but it is a large, complex code base making for slow going. There are no GC.Collect() calls. Which tools, techniques, etc. are helpful when trying to isolate this type of problem?</p>
| [
{
"answer_id": 379989,
"author": "Jon Limjap",
"author_id": 372,
"author_profile": "https://Stackoverflow.com/users/372",
"pm_score": 2,
"selected": false,
"text": "Dispose() GC.Collect() Dispose()"
}
] | 2008/12/19 | [
"https://Stackoverflow.com/questions/379871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44008/"
] |
379,874 | <p>How to get unique Google Gadget ID from a gadget added to a iGoogle website, with Javascript?</p>
| [
{
"answer_id": 388898,
"author": "Jordi",
"author_id": 48648,
"author_profile": "https://Stackoverflow.com/users/48648",
"pm_score": 2,
"selected": false,
"text": "/**\n * Grabs the id of a Google Gadget from an iGoogle page.\n *\n * @param name the name of the targeted Google Gadget. If... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46739/"
] |
379,900 | <p>I am trying to find a way to load a JSON page to display my content, which I currently have. But I am trying to fade in each element one after another? Is anyone familiar with a way to do that?</p>
<p>Fade in each element with a slight delay?</p>
<p>Here is an example of my code, I am using the jquery framework.</p>
<p>CODE: <a href="http://pastie.org/343896" rel="noreferrer">http://pastie.org/343896</a></p>
| [
{
"answer_id": 379913,
"author": "Genericrich",
"author_id": 39932,
"author_profile": "https://Stackoverflow.com/users/39932",
"pm_score": 5,
"selected": true,
"text": " $(\"div#foo\").fadeIn(\"fast\",function(){\n $(\"div#bar\").fadeIn(\"fast\", function(){\n // etc.\n ... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
379,906 | <ul>
<li>How can I convert a <code>str</code> to <code>float</code>?
<pre><code>"545.2222" → 545.2222
</code></pre>
</li>
<li>How can I convert a <code>str</code> to <code>int</code>?
<pre><code>"31" → 31
</code></pre>
</li>
</ul>
<hr />
<p><sub>For the reverse, see <a href="https://stackoverflow.com/questions/961632">Convert integer to string in Python</a> and <a href="https://stackoverflow.com/questions/1317558">Converting a float to a string without rounding it</a>.</sub></p>
<p><sub>Please instead use <a href="https://stackoverflow.com/questions/20449427">How can I read inputs as numbers?</a> to close duplicate questions where OP received a string <em>from user input</em> and immediately wants to convert it, or was hoping for <code>input</code> (in 3.x) to convert the type automatically.</sub></p>
| [
{
"answer_id": 379909,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 4,
"selected": false,
"text": "float(\"545.2222\") int(float(\"545.2222\"))"
},
{
"answer_id": 379910,
"author": "Harley Holcombe",
"au... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30529/"
] |
379,916 | <p><a href="https://stackoverflow.com/questions/48496/how-to-teach-a-crash-course-on-c">This post</a> reference to the One Definition Rule.</p>
<p><a href="http://en.wikipedia.org/wiki/One_Definition_Rule" rel="nofollow noreferrer">Wikipedia is pretty bad on explaining how to implement it</a></p>
<p>Where can I find good ressources about guidelines to follow in C++ .NET?</p>
| [
{
"answer_id": 379951,
"author": "FryGuy",
"author_id": 28776,
"author_profile": "https://Stackoverflow.com/users/28776",
"pm_score": 4,
"selected": true,
"text": "int square(int x); // this is a declaration\nextern int someVariable; // this is a declration\n\nvoid square(int x) // this... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6367/"
] |
379,917 | <p>I'm trying to recreate the iPhone flick / scroll event in a window using JavaScript.</p>
<p>Starting with JQuery, I'm measuring the mouse's acceleration and offset during click - drag - release events using a timer:</p>
<pre><code>var MouseY = {
init: function(context) {
var self = this;
self._context = context || window
self._down = false;
self._now = 0;
self._last = 0;
self._offset = 0;
self._timer = 0;
self._acceleration = 0;
$(self._context).mousedown(function() {self._down = true;});
$(self._context).mouseup(function() {self._down = false;});
$(self._context).mousemove(function(e) {self.move(e);});
},
move: function(e) {
var self = this;
self._timer++;
self._last = self._now;
self._now = e.clientY + window.document.body.scrollTop;
self._offset = self._now - self._last;
self._acceleration = self._offset / self._timer;
},
reset: function() {
this._offset = 0;
this._acceleration = 0;
this._timer = 0;
}
};
$(function() {
MouseY.init();
setInterval(function() {
$('#info').html(
'_acceleration:' + MouseY._acceleration + '<br />' +
'_now:' + MouseY._now + '<br />' +
'_offset:' + MouseY._offset + '<br />' +
'_timer:' + MouseY._timer + '<br />'
);
MouseY.reset();
}, 10);
});
</code></pre>
<p>Now the problem is translating that acceleration into screen movement - are there any algorithms (easing?) or animation libraries that could help me out on this? (I've looked into JQuery's .animate() but I'm unsure of how to apply it continuously during the drag events!</p>
<p><strong>Update - final solution here:</strong></p>
<p><a href="http://johnboxall.github.com/iphone.html" rel="noreferrer">http://johnboxall.github.com/iphone.html</a></p>
| [
{
"answer_id": 380006,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": true,
"text": "nn4 = (document.layers)? true:false;\nmouseLeft = mouseTop = mouseX = mouseY = 0;\nmonitor = {\n timerDelay:100,\n moveLi... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379917",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37522/"
] |
379,920 | <p>I'm writing a component and would like to insert images from the template folder.</p>
<p>How do you get the correct path to the template folder?</p>
| [
{
"answer_id": 379934,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 2,
"selected": false,
"text": "$templateDir = $mainframe->getBasePath() . \"templates/\" . $mainframe->getTemplate();\n"
},
{
"answer_id": 381360,
... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379920",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
379,930 | <p>i run Apache web server on windows in order to work on some Perl CGI scripts. in production these scripts run on a linux box, and in the source code repository they all have shebangs like: <code>#!/usr/bin/perl</code>, but on my windows machine the shebangs would be <code>#!c:\perl\bin\perl.exe</code>, so i have a conflict with the source code base.</p>
<p>enter the Apache <em>ScriptInterpreterSource</em> directive. </p>
<p>i've been trying to make it work, based on what i can google. but so far no luck. i have:</p>
<ol>
<li><p>added these things to the appropriate directive
AllowOverride None<br>
Options Indexes FollowSymLinks ExecCGI
Order allow,deny
Allow from all
ScriptInterpreterSource Registry-Strict</p></li>
<li><p>added:
AddHandler cgi-script .cgi </p></li>
<li><p>edited my registry and added a new String to </p></li>
</ol>
<blockquote>
<pre><code>HKEY_CLASSES_ROOT\.cgi\Shell\ExecCGI\Command=C:\Perl\bin\perl.exe
</code></pre>
</blockquote>
<p>now, i know that CGIs work on this server as long as they have the right shebang. </p>
<p>but when i try to access a CGI without a shebang the apache log spits out: </p>
<blockquote>
<p>No Exec CGI Verb found for files of
type '.cgi'</p>
</blockquote>
<p>any thoughts, insights, or even wild-ass guesses would be appreciated. </p>
<p>thanks.</p>
| [
{
"answer_id": 386980,
"author": "Powerlord",
"author_id": 15880,
"author_profile": "https://Stackoverflow.com/users/15880",
"pm_score": 4,
"selected": true,
"text": "HKEY_CLASSES_ROOT\\.cgi\\Shell\\ExecCGI\\Command\\(Default) => C:\\Perl\\bin\\perl.exe -wT\n"
},
{
"answer_id": 3... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46775/"
] |
379,939 | <p>Basically I want to put "todays" year, month, day into two fields ... something like the following. Tried varients of but cant get it right</p>
<blockquote>
<p>"INSERT INTO film_out (start_year, start_month, start_day), (end_year, end_month, end_day) VALUES ('$year', '$month', '$day') "</p>
</blockquote>
| [
{
"answer_id": 379943,
"author": "cLFlaVA",
"author_id": 45109,
"author_profile": "https://Stackoverflow.com/users/45109",
"pm_score": 2,
"selected": false,
"text": "\"INSERT INTO film_out (start_year, start_month, start_day, end_year, end_month, end_day)\n VALUES ('$year', '$month'... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
379,940 | <p>Is there a way to modify/tell dired to copy files asynchronously? If you mark multiple files in dired and then use 'C' to copy them, emacs locks up until every file is copied. I instead want this copy to be started, and for me to continue editing as it goes on in the background. Is there a way to get this behaviour?</p>
<p>EDIT: Actually, C calls 'dired-do-copy' in dired-aux, not in dired itself. Sorry for any confusion.</p>
| [
{
"answer_id": 21158046,
"author": "Nordlöw",
"author_id": 683710,
"author_profile": "https://Stackoverflow.com/users/683710",
"pm_score": 2,
"selected": false,
"text": "dired-do-async-shell-command"
},
{
"answer_id": 43642761,
"author": "GDP2",
"author_id": 2636454,
... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41241/"
] |
379,962 | <p>I have the following data</p>
<p><a href="https://i.stack.imgur.com/KWyXz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KWyXz.png" alt="alt text"></a>
</p>
<p>How do I transform it (with SQL Server 2005) into the following format?</p>
<p><a href="https://i.stack.imgur.com/1FVoX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1FVoX.png" alt="alt text"></a>
</p>
<p>I have a example solution that I came up with but it seems a little clunky. It smells perhaps?</p>
<pre><code>DECLARE @ProductLanguage TABLE
(
[PRODUCT_ID] int
, [LANGUAGE] varchar(50)
)
INSERT INTO @ProductLanguage ([PRODUCT_ID],[LANGUAGE]) VALUES (52035,'Czech')
INSERT INTO @ProductLanguage ([PRODUCT_ID],[LANGUAGE]) VALUES (52035,'English')
INSERT INTO @ProductLanguage ([PRODUCT_ID],[LANGUAGE]) VALUES (52035,'German')
INSERT INTO @ProductLanguage ([PRODUCT_ID],[LANGUAGE]) VALUES (54001,'Danish')
INSERT INTO @ProductLanguage ([PRODUCT_ID],[LANGUAGE]) VALUES (54001,'Spanish')
INSERT INTO @ProductLanguage ([PRODUCT_ID],[LANGUAGE]) VALUES (54001,'English')
INSERT INTO @ProductLanguage ([PRODUCT_ID],[LANGUAGE]) VALUES (70501,'Finnish')
INSERT INTO @ProductLanguage ([PRODUCT_ID],[LANGUAGE]) VALUES (70501,'Greek')
INSERT INTO @ProductLanguage ([PRODUCT_ID],[LANGUAGE]) VALUES (70501,'Hungarian')
INSERT INTO @ProductLanguage ([PRODUCT_ID],[LANGUAGE]) VALUES (52044,'Hebrew')
SELECT
PRODUCT_ID
,MAX(CASE WHEN [ROW_ID]=1 THEN LANGUAGE ELSE NULL END) As LANG_1
,MAX(CASE WHEN [ROW_ID]=2 THEN LANGUAGE ELSE NULL END) As LANG_2
,MAX(CASE WHEN [ROW_ID]=3 THEN LANGUAGE ELSE NULL END) As LANG_3
FROM
(SELECT
ROW_NUMBER() OVER (PARTITION BY [PRODUCT_ID] ORDER BY [PRODUCT_ID] ASC) AS [ROW_ID]
, [PRODUCT_ID]
, [LANGUAGE]
FROM
@ProductLanguage) AS Temp
GROUP BY
[PRODUCT_ID]
</code></pre>
<p>The interesting bit is I do not care about the specific Languages displayed in each LANG_* column. Other questions posted here seem to all refer to knowning the pivoted columns by name. But I do not want to name the columns by the languages found.</p>
<p><strong>NOTE</strong>:
I know I mention the word "pivot" but the best solution for this problem may not involve the PIVOT clause. I just used that word as my question seemed to suggest pivotting data.
Maybe a CTE would help with the solution, I do not know. I just know I am not happy about the example solution above.</p>
| [
{
"answer_id": 379986,
"author": "Charles Bretana",
"author_id": 32632,
"author_profile": "https://Stackoverflow.com/users/32632",
"pm_score": 0,
"selected": false,
"text": "Select Z.Arabic as Language1, Z.Botwanese as Language2, etc.\nFrom (Inner Pivot Query Here ) Z\n"
},
{
"a... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19377/"
] |
379,988 | <p>I'm trying to make a database and so far, I've been using strings to store my entries from a text file into an array, but this just isn't working out. Thus, I began thinking of a new way of doing it.<br/> </p>
<p>What I want to do:</p>
<p>Lets say I have a text file with the following database...</p>
<p>John Smith 00001 jsmith@email pw1<br/><br>
Rob Deniro 00002 rdeniro@email pw2<br/><br>
Al Pacino 00003 apacino@email pw3<br/> </p>
<p>Joe Pesci 00004 jpesci@email 307 pw4<br/><br>
Joaq Phoenix 00005 jphoe@email 208 pw5<br/><br>
John Madden 00006 jmadden@email 708 pw6 <br/> </p>
<p>Alright, so basically what I'm stuck at is making this "inheritance" friendly. What's the best way to go about storing each entry? Individual strings? I've been thinking that the best way is to store each individual character until a whitespace occurs and then storing it into a string, but I'm not sure how that could be done. </p>
| [
{
"answer_id": 379999,
"author": "Tamara Wijsman",
"author_id": 47064,
"author_profile": "https://Stackoverflow.com/users/47064",
"pm_score": 0,
"selected": false,
"text": "ifstream strtok string int long"
},
{
"answer_id": 380012,
"author": "Robert Gould",
"author_id": 1... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
379,995 | <p>I have one class that needs to grab an attribute that is set in another. It's not a standard data type though. Here's the code;</p>
<pre><code>class graphics:
def __init__(self, Fullscreen = False, Width = 640, Height = 480):
print "Graphics Init"
SCREEN_SIZE = (Width, Height)
pygame.init()
if Fullscreen:
self.screen = pygame.display.set_mode(SCREEN_SIZE, FULLSCREEN, 32)
print "Fullscreen Initialized"
else:
self.screen = pygame.display.set_mode(SCREEN_SIZE, 0, 32)
print "Non-Fullscreen Initialized"
</code></pre>
<p>What I need to do is reference the screen attribute, which I can set with self.screen and be readable within that class...but from another class I have to set</p>
<pre><code>screen = ?
</code></pre>
<p>under</p>
<pre><code>class graphics:
</code></pre>
<p>What does that question mark need to be? I've tried 0, None, ""...nothing seems to work, I have no idea what data type that pygame call would be. :S</p>
| [
{
"answer_id": 380001,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 0,
"selected": false,
"text": "object self.screen = object()\n"
},
{
"answer_id": 380018,
"author": "Stephen Belanger",
"author_id": 46... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46981/"
] |
380,011 | <p>Does anybody know any fine open source cube browser?</p>
<p>Ideally, it would be something built with plain javascript.</p>
<p>Does it even exists?</p>
<p>I'm planing to use it with classic asp agains a SQL database.</p>
| [
{
"answer_id": 10442096,
"author": "xn.",
"author_id": 120731,
"author_profile": "https://Stackoverflow.com/users/120731",
"pm_score": 3,
"selected": false,
"text": "var data = [{\"time\":1331773202,\"facts\":{\"name\":\"Super Mario Bros. 2\",\"platform\":\"Nintendo\",\"staring\":\"Mario... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47633/"
] |
380,014 | <p>I have a 100% valid Ajax model written in Javascript with a few inputs I use being, Get or Post method, What page to communicate with, What String to send to that page and What element on my own page I might be fiddling with when I receive my response.
The problem is that, should I set the request to Asynchronous (Hence Ajax), IE returns the error "The Data Necessary to Complete This Operation is Not Yet Available" in the onreadystatechange event where all I do is check if the readystate is 4 and the status is 200. The error doesn't come up in Firefox or Chrome as I would exepect as the Ajax is Asynchronous.</p>
<p>Heres a snippet from the Post method</p>
<pre><code>xmlhttp.open("POST", commPage, true);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
j = xmlhttp.responseText;
i.innerHTML = j;
}
}
xmlhttp.send(str);
</code></pre>
<p>Edit: I should point out that in IE, I'm using the ActiveX Control -> Msxml2.XMLHTTP or Microsoft.XMLHTTP or whichever returns true first.</p>
| [
{
"answer_id": 380032,
"author": "Supernovah",
"author_id": 36076,
"author_profile": "https://Stackoverflow.com/users/36076",
"pm_score": 1,
"selected": false,
"text": "ajaxRequest(){\n [...]\n}\nif(xmlhttp.responseText){\n myFunc();\n}\n"
}
] | 2008/12/19 | [
"https://Stackoverflow.com/questions/380014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36076/"
] |
380,024 | <p>I have an Obj-C method similar to this:</p>
<pre><code>-(void)getUserDefaults:(BOOL *)refreshDefaults
{
PostAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
if (refreshDefaults) {
[appDelegate retrieveDefaults];
}
}
</code></pre>
<p>When I call it like this I get no warning:</p>
<pre><code>[self getUserDefaults:NO];
</code></pre>
<p>When I call it like this I get a warning:</p>
<pre><code>[self getUserDefaults:YES];
</code></pre>
<p>warning: passing argument 1 of 'getUserDefaults:' makes pointer from integer without a cast</p>
<p>NOTE: I always call the method passing NO first, then sometime later I pass YES</p>
<p>Can anyone fill me in on what the issue is here? Thanks.</p>
| [
{
"answer_id": 380040,
"author": "Chris Hanson",
"author_id": 714,
"author_profile": "https://Stackoverflow.com/users/714",
"pm_score": 4,
"selected": false,
"text": "BOOL -(void)getUserDefaults:(BOOL)refreshDefaults;\n 0 NO NULL 1 YES"
},
{
"answer_id": 380045,
"author": "jo... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380024",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46540/"
] |
380,031 | <p>I read a list of SIDs from the registry, <code>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList</code>.</p>
<p>How would one resolve the display username (e.g. <code>DOMAIN\user</code>, <code>BUILT-IN\user</code>) given the SID string in C#?</p>
| [
{
"answer_id": 380048,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 5,
"selected": true,
"text": "LookupAccountSid() LookupAccountSid() BOOL LookupAccountSid(LPCTSTR lpSystemName, PSID Sid,LPTSTR Name, LPDWORD cbName,... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40214/"
] |
380,037 | <p>Does anyone have a solution for styling the borders of "select" elements in Internet Explorer using CSS?</p>
| [
{
"answer_id": 380068,
"author": "some",
"author_id": 36866,
"author_profile": "https://Stackoverflow.com/users/36866",
"pm_score": 6,
"selected": true,
"text": "<select> <select> <select> <select> <select> <select> <select id=\"something\" name=\"something\">\n <option value=\"1\">This... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40538/"
] |
380,046 | <p>Whenever I try to write graphical programs (whether a game or really any GUI app) I always wind up with one or two god classes with way too many methods (and long methods, too), and each class having far too many responsibilities. I have graphics being done at the same time as calculations and logic, and I feel like this is a really bad way to go about organizing my code. I want to get better at organizing my code and abstracting out responsibilities to different classes. Here's an example of where I'd like to start - I want to write a Minesweeper clone, just sort of as practice and to try to improve my software engineering skills. How would I go about making this nice and object-oriented? For the sake of discussion, let's just say I'm using Java (because I probably will, either that or C#). Here's some things I would think about:</p>
<ul>
<li>should each tile inherit from JButton or JComponent and handle drawing itself? </li>
<li>or should the tiles just be stored as some non-graphical MinesweeperTile object and some other class handles drawing them?</li>
<li>is the 8-segment display countdown timer (pre-Vista, at least) a separate class that handles drawing itself?</li>
<li>when the user clicks, do the tiles have mouse event listeners or does some other collision detection method loop through the tiles and check each one to see if it's been hit?</li>
</ul>
<p>I realize that there's not just one way to write a GUI application, but what are some pretty basic things I can start doing to make my code more organized, manageable, object-oriented, and just over all write better programs?</p>
<hr>
<p>edit: I guess I should add that I'm familiar with MVC, and I was originally going to incorporate that into my question, but I guess I didn't want to shoehorn myself into MVC if that's not necessarily what I need. I did searched for topics on MVC with GUI apps but didn't really find anything that answers my specific question. </p>
<hr>
<p>edit2: Thanks to everyone who answered. I wish I could accept more than one answer..</p>
| [
{
"answer_id": 380088,
"author": "lc.",
"author_id": 44853,
"author_profile": "https://Stackoverflow.com/users/44853",
"pm_score": 2,
"selected": false,
"text": "IsMine() Reveal() CountdownSegmentDigit CountDown() Set() Reset() HitZero Timer Reveal() MineExploded CountUp() HitZero CountD... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42891/"
] |
380,050 | <p>So, I got ZF MVC site and want to force SSL connection on everything under my /checkout/
I tried using mod_rewrite for that, so my .htaccess would look like this:</p>
<pre><code>RewriteEngine on
RewriteRule (\/checkout.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R]
RewriteRule !\.(js|ico|gif|jpg|png|css|swf|xml|avi|flv|mov|mp3|wav)$ index.php [L]
</code></pre>
<p>Sure enough, it does kick in SSL, but second rule, that's ZF specific and redirects everything to index.php sorta erases the protocol specification.</p>
<p>Unfortunately my level of proficiency with mod_rewrite is stupendously terrible. Maybe someone could help me out to solve this? </p>
| [
{
"answer_id": 381624,
"author": "Tim Lytle",
"author_id": 45531,
"author_profile": "https://Stackoverflow.com/users/45531",
"pm_score": 1,
"selected": false,
"text": "RewriteCond %{HTTPS} !on\nRewriteRule (\\/checkout.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [RL] \n\nRewriteRule !\\.(js|i... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35520/"
] |
380,057 | <p>I've created a table in MySQL:</p>
<pre><code>CREATE TABLE actions ( A_id int NOT NULL AUTO_INCREMENT,
type ENUM('rate','report','submit','edit','delete') NOT NULL,
Q_id int NOT NULL,
U_id int NOT NULL,
date DATE NOT NULL,
time TIME NOT NULL,
rate tinyint(1),
PRIMARY KEY (A_id),
CONSTRAINT fk_Question FOREIGN KEY (Q_id) REFERENCES questions(P_id),
CONSTRAINT fk_User FOREIGN KEY (U_id) REFERENCES users(P_id));
</code></pre>
<p>This created the table I wanted just fine (although a "DESCRIBE actions;" command showed me that the foreign keys were keys of type MUL, and I'm not sure what this means). However, when I try to enter a Q_id or a U_id that does not exist in the questions or users tables, <strong>MySQL still allows these values.</strong></p>
<p>What did I do wrong? How can I prevent a table with a foreign key from accepting invalid data?</p>
<h2>UPDATE 1</h2>
<p>If I add <code>TYPE=InnoDB</code> to the end, I get an error:</p>
<blockquote>
<p>ERROR 1005 (HY000): Can't create table './quotes/actions.frm' (errno: 150)</p>
</blockquote>
<p>Why might that happen?</p>
<h2>UPDATE 2</h2>
<p>I'm told that it's important to enforce data integrity with functional foreign keys, but also that InnoDB should not be used with MySQL. What do you recommend?</p>
| [
{
"answer_id": 380074,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 6,
"selected": false,
"text": "KEY INDEX CREATE TABLE actions (\n A_id int NOT NULL AUTO_INCREMENT,\n ...\n CONSTRAINT fk_Question FOREIGN KEY (Q_... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1615/"
] |
380,062 | <p>I have heard of apps not working properly on the simulator but working properly on the actual iPhone device. Has anyone experienced an app that runs perfectly in the simulator but not on the actual iPhone device?</p>
| [
{
"answer_id": 1250919,
"author": "Tim",
"author_id": 104200,
"author_profile": "https://Stackoverflow.com/users/104200",
"pm_score": 2,
"selected": false,
"text": "didReceiveMemoryWarning"
},
{
"answer_id": 1715795,
"author": "Kristopher Johnson",
"author_id": 1175,
... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21293/"
] |
380,067 | <p>I'm trying to bring a legacy C# .NET 1.1 application into the modern era. We use DataTables for our collections of what could have been business objects.</p>
<p>Given that most of the code thinks it is talking to the interface of a DataRow, what generic collection would make for the least painful transition?</p>
| [
{
"answer_id": 380111,
"author": "dbones",
"author_id": 47642,
"author_profile": "https://Stackoverflow.com/users/47642",
"pm_score": 4,
"selected": true,
"text": "private void PrintAll<T>(IEnumerable<T> items)\n{\n foreach(T item in items)\n Console.WriteLine(item.ToString());... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380067",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33264/"
] |
380,069 | <p>I'm trying to include JQuery in my DotNetNuke skin by adding these two lines of code at the top of my DNN skin:</p>
<pre><code><%
Page.ClientScript.RegisterClientScriptInclude("jquery", "http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js")
Page.ClientScript.RegisterStartupScript(Me.GetType(), "jQueryNoConflict", "jQuery.noConflict()", True)
%>
</code></pre>
<p>Sadly, when I view source on my page, I don't see the appropriate tag referencing jquery.min.js anywhere. Is DotNetNuke somehow flushing out my requests to add script to my pages here? What am I missing? I'm somewhat of a DNN newbie.</p>
| [
{
"answer_id": 383284,
"author": "Dave Markle",
"author_id": 24995,
"author_profile": "https://Stackoverflow.com/users/24995",
"pm_score": 2,
"selected": true,
"text": "<script runat=\"server\">\n Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handle... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24995/"
] |
380,076 | <p>The data model for my Core Data document-based app (10.5 only) is in a
framework, so automatic schema upgrades using a Core Data mapping
model don't appear to work. It appears that the Core Data machinery
doesn't find the appropriate data models or mapping model when they
are not in the app's main bundle. So, instead of using the automatic
migration, I'm running a migration manually in
<code>configurePersistentStoreCoordinatorForURL:ofType:...</code> in my
<code>NSPersistenDocument</code> subclass (code below). I migrate the persistent
store to a temporary file and then overwrite the existing file if the
migration succeeds. The document then presents an error with the
message "This document's file has been changed by another application
since you opened or saved it." when I try to save. As others on this
list have pointed out, this is due to my modification of the
document's file "behind its back". I tried updating the document's
file modification date, as shown below, but I then get an error dialog
with the message "The location of the document "test.ovproj" cannot be
determined." when I try to save. I'm less sure of the reason for this
error, but trading one unnecessary message (in this case) for an other
isn't quite what I was going for.</p>
<p>Can anyone offer some guidance? Is there a way to manually upgrade the
schema for a document's persistent store without triggering one of
these (in <em>this</em> case unnecessary) warnings?</p>
<p>code for upgrading the data store in my subclasses
<code>-configurePersistentStoreCoordinatorForURL:ofType:...</code> :</p>
<pre><code>if(upgradeNeeded) {
NSManagedObjectModel *sourceModel = [NSManagedObjectModel mergedModelFromBundles:VUIModelBundles() orStoreMetadata:meta];
if(sourceModel == nil) {
*error = [NSError errorWithDomain:VUIErrorDomainn ode:VUICoreDataErrorCode localizedReason:BWLocalizedString(@"Unable to find original data model for project.")];
return NO;
}
NSManagedObjectModel *destinationModel = [self managedObjectModel];
NSMigrationManager *migrationManager = [[NSMigrationManager alloc] initWithSourceModel:sourceModel destinationModel:destinationModel];
NSMappingModel *mappingModel = [NSMappingModel mappingModelFromBundles:VUIModelBundles() forSourceModel:sourceModel destinationModel:destinationModel];
if(mappingModel == nil) {
*error = [NSError errorWithDomain:VUIErrorDomain code:VUICoreDataErrorCode localizedReason:BWLocalizedString(@"Unable to find mapping model to convert project to most recent project format.")];
return NO;
}
@try {
//move file to backup
NSAssert([url isFileURL], @"store url is not a file URL");
NSString *tmpPath = [NSString tempFilePath];
id storeType = [meta objectForKey:NSStoreTypeKey];
if(![migrationManager migrateStoreFromURL:url
type:storeType
options:storeOptions
withMappingModel:mappingModel
toDestinationURL:[NSURLfileURLWithPath:tmpPath]
destinationType:storeType
destinationOptions:storeOptions
error:error]) {
return NO;
} else {
//replace old with new
if(![[NSFileManager defaultManager] removeItemAtPath:[url path] error:error] ||
![[NSFileManager defaultManager] moveItemAtPath:tmpPath toPath:[url path] error:error]) {
return NO;
}
// update document file modification date to prevent warning (#292)
NSDate *newModificationDate = [[[NSFileManager defaultManager] fileAttributesAtPath:[url path] traverseLink:NO] bjectForKey:NSFileModificationDate];
[self setFileModificationDate:newModificationDate];
}
}
@finally {
[migrationManager release];
}
}
}
return [super configurePersistentStoreCoordinatorForURL:url ofType:fileType modelConfiguration:configuration storeOptions:storeOptions error:error];
</code></pre>
| [
{
"answer_id": 48931088,
"author": "AMTourky",
"author_id": 628889,
"author_profile": "https://Stackoverflow.com/users/628889",
"pm_score": 0,
"selected": false,
"text": "migrate()\nif let newModificationDate = try? NSFileManager.defaultManager().attributesOfItemAtPath(url.path!)[NSFileM... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2140/"
] |
380,100 | <p>I'm trying to convert an HTML table to Excel in Javascript using new <code>ActiveXObject("Excel.application")</code>. Bascially I loop through table cells and insert the value to the corresponding cell in excel:</p>
<pre><code>//for each table cell
oSheet.Cells(x,y).value = cell.innerText;
</code></pre>
<p>The problem is that when the cell is in date format of 'dd-mm-yyyy' (e.g. 10-09-2008), excel would read as 'mm-dd-yyyy' (i.e. 09 Oct 2008). I tried to specify <code>NumberFormat</code> like:</p>
<pre><code>oSheet.Cells(x,y).NumberFormat = 'dd-mm-yyyy';
</code></pre>
<p>But, it has no effect. It seems that this only affect how excel <strong>display the value, not parse</strong>. My only solution now is to swap the date like:</p>
<pre><code>var txt = cell.innerText;
if(/^(\d\d)-(\d\d)-\d\d\d\d$/.test(txt)) txt = txt.replace(/^(\d\d)-(\d\d)/,'$2-$1');
</code></pre>
<p>But, I'm worrying that it is not generic and a differnt machine setting would fail this.</p>
<p>Is there a way to specific how excel <strong>parse</strong> the input value?</p>
| [
{
"answer_id": 380146,
"author": "lakshmanaraj",
"author_id": 44541,
"author_profile": "https://Stackoverflow.com/users/44541",
"pm_score": 0,
"selected": false,
"text": " If IsDate ( Cell.Value ) Then\n Cell.Value = DateValue ( Cell.Value )\n End If\n"
},
{
"answer... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47646/"
] |
380,103 | <p>This simple code is not producing any sound on a couple of machines that I've used to test it. I'm running the code from within Eclipse, but I've also tried using the command line to no avail. </p>
<pre><code>public static void main(String[] args)
{
try {
Synthesizer synthesizer = MidiSystem.getSynthesizer();
synthesizer.open();
MidiChannel[] channels = synthesizer.getChannels();
channels[0].noteOn(60, 60);
Thread.sleep(200);
channels[0].noteOff(60);
synthesizer.close();
} catch (Exception e)
{
e.printStackTrace();
}
}</code></pre>
<p>I am able to successfully get sound by getting a Sequencer, adding MIDI events to the sequence, and playing the sequence, but I'm trying to do some real-time music effects, which the sequencer does not support.</p>
<p>Any ideas?</p>
<p><strong>EDIT WITH SOLUTION:</strong> It turns out the problem is that, by default, the JRE doesn't come with a soundbank (interesting, then, that using the Sequencer worked, but using the Synthesizer didn't). Thanks, <a href="https://stackoverflow.com/users/54787/thejmc">thejmc</a>!</p>
<p>To solve the problem, I <a href="http://java.sun.com/products/java-media/sound/soundbanks.html" rel="nofollow noreferrer">downloaded a soundbank from java.sun.com</a> and placed it in (on WinXP) C:\Program Files\jre1.6.0_07\lib\audio (had to make the audio folder).</p>
| [
{
"answer_id": 742702,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "public static void main(String[] args)\n{\n try {\n Synthesizer synthesizer = MidiSystem.getSynthesizer();\n ... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2197/"
] |
380,116 | <p>I've just started developing a WPF application. This is not my first WPF app, but it will be the first that needs some polish. I know quite a bit about the "plumbing" of WPF such as binding, etc., but very little about how to polish it up. I don't need a snazzy UI. I just need something that looks like a native Windows app. For instance, if the app runs on XP, I want it to look like an XP app and pick up the user's UI theme. Same thing on Vista, etc.</p>
<p>How can I do this?</p>
| [
{
"answer_id": 380134,
"author": "Mark Carpenter",
"author_id": 47645,
"author_profile": "https://Stackoverflow.com/users/47645",
"pm_score": 2,
"selected": false,
"text": "Uri uri = new Uri(\"PresentationFramework.Aero;V3.0.0.0;31bf3856ad364e35;component\\\\themes/aero.normalcolor.xaml\... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27779/"
] |
380,124 | <p>I have a very simple Setup project that copies three dlls into the GAC. That's all it has to do. It works fine in XP, but on a Vista machine, it errors out stating that it cannot write to the file and to check permissions. I'm sure this has to do with some impersonation nonsense in Vista, but I'm not sure how to address it.</p>
<p>Has anyone else encountered this, and how did you overcome it if so?</p>
| [
{
"answer_id": 840306,
"author": "Lucas",
"author_id": 24231,
"author_profile": "https://Stackoverflow.com/users/24231",
"pm_score": 0,
"selected": false,
"text": "msiexec /i setup.msi\n"
}
] | 2008/12/19 | [
"https://Stackoverflow.com/questions/380124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5469/"
] |
380,145 | <p>Well, maybe not with all 4 things, but here's my situation:</p>
<p>I have an ActiveMQ backend (running on my desktop Mac). It's a stock Apache ActiveMQ server I have which I am basically using as an echo server to tail the logs and debug my client. The client is an iPhone project with a hacked up Stomp.framework implementation using AsyncSocket.</p>
<p>I need to use AsyncSocket Cocoa library to talk to the Stomp server, which I more or less have working. I can send messages to queues, and read them back out, so I think I am good there.</p>
<p>BUT, when I try to set everything up to use SSL (also a requirement) I get the following error description out of the NSError object I get back:</p>
<pre><code>kCFStreamErrorDomainSSL error -9812.
</code></pre>
<p>I cannot for the life of me figure out what this error code is. Anyone have a clue?</p>
<p>Here is how I setup the SSL stuff for AsyncSocket:</p>
<p>EDIT: ADDED THE CORRECT CODE HERE. NOTE SELF-SIGNED CERTS.</p>
<pre><code>//- (BOOL)onSocketWillConnect:(AsyncSocket *)sock
{
// Connecting to a secure server
NSMutableDictionary * settings = [NSMutableDictionary dictionaryWithCapacity:2];
// Use the highest possible security
[settings setObject:(NSString *)kCFStreamSocketSecurityLevelNegotiatedSSL
forKey:(NSString *)kCFStreamSSLLevel];
// Allow self-signed certificates
[settings setObject:[NSNumber numberWithBool:YES]
forKey:(NSString *)kCFStreamSSLAllowsAnyRoot];
CFReadStreamSetProperty([sock getCFReadStream],
kCFStreamPropertySSLSettings, (CFDictionaryRef)settings);
CFWriteStreamSetProperty([sock getCFWriteStream],
kCFStreamPropertySSLSettings, (CFDictionaryRef)settings);
return YES;
</code></pre>
<p>}</p>
<p>Anyone have any ideas? I <em>think</em> I'm setting the stream properties correctly. Maybe it's something to do with the ActiveMQ setup? I didn't do any configuration other than to enable the SSL over Stomp protocol in ActiveMQ. I don't have a certificate or anything like that. Maybe that is the problem?</p>
<p>Any insight is appreciated!</p>
| [
{
"answer_id": 414355,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "\"errSSLUnknownRootCert\""
}
] | 2008/12/19 | [
"https://Stackoverflow.com/questions/380145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39932/"
] |
380,153 | <p>Alright, so I just finished my last compiler error (so I thought) and these errors came up:</p>
<pre><code>1>GameEngine.obj : error LNK2001: unresolved external symbol "public: static double WeaponsDB::PI" (?PI@WeaponsDB@@2NA)
1>Component.obj : error LNK2001: unresolved external symbol "public: static double WeaponsDB::PI" (?PI@WeaponsDB@@2NA)
1>Coordinate.obj : error LNK2019: unresolved external symbol "public: static double WeaponsDB::PI" (?PI@WeaponsDB@@2NA) referenced in function "public: double __thiscall Coordinate::distanceFrom(class Coordinate *)" (?distanceFrom@Coordinate@@QAENPAV1@@Z)
1>Driver.obj : error LNK2001: unresolved external symbol "public: static double WeaponsDB::PI" (?PI@WeaponsDB@@2NA)
1>Environment.obj : error LNK2001: unresolved external symbol "public: static double WeaponsDB::PI" (?PI@WeaponsDB@@2NA)
1>Environment.obj : error LNK2001: unresolved external symbol "public: static bool Environment::spyFlag" (?spyFlag@Environment@@2_NA)
1>Environment.obj : error LNK2001: unresolved external symbol "private: static class Environment * Environment::instance_" (?instance_@Environment@@0PAV1@A)
1>Environment.obj : error LNK2019: unresolved external symbol "public: static void __cdecl Environment::spyAlertOver(void)" (?spyAlertOver@Environment@@SAXXZ) referenced in function "public: void __thiscall Environment::notificationOfSpySuccess(void)" (?notificationOfSpySuccess@Environment@@QAEXXZ)
1>GameDriver.obj : error LNK2019: unresolved external symbol "public: static void __cdecl MainMenu::gameOver(int)" (?gameOver@MainMenu@@SAXH@Z) referenced in function "public: static void __cdecl GameDriver::run(void)" (?run@GameDriver@@SAXXZ)
1>GameDriver.obj : error LNK2019: unresolved external symbol "public: static void __cdecl GameDriver::gatherInput(void)" (?gatherInput@GameDriver@@SAXXZ) referenced in function "public: static void __cdecl GameDriver::run(void)" (?run@GameDriver@@SAXXZ)
1>GameDriver.obj : error LNK2019: unresolved external symbol "public: static void __cdecl GameDriver::ticker(void)" (?ticker@GameDriver@@SAXXZ) referenced in function "public: static void __cdecl GameDriver::run(void)" (?run@GameDriver@@SAXXZ)
1>GameDriver.obj : error LNK2001: unresolved external symbol "public: static int GameDriver::ticks" (?ticks@GameDriver@@2HA)
1>GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::evaluatingInputFlag" (?evaluatingInputFlag@GameDriver@@2_NA)
1>GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyQuitFlag" (?keyQuitFlag@GameDriver@@2_NA)
1>GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyToggleWeaponRightFlag" (?keyToggleWeaponRightFlag@GameDriver@@2_NA)
1>GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyToggleWeaponLeftFlag" (?keyToggleWeaponLeftFlag@GameDriver@@2_NA)
1>GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyFireFlag" (?keyFireFlag@GameDriver@@2_NA)
1>GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyLeftFlag" (?keyLeftFlag@GameDriver@@2_NA)
1>GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyRightFlag" (?keyRightFlag@GameDriver@@2_NA)
1>GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyUpFlag" (?keyUpFlag@GameDriver@@2_NA)
1>GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyDownFlag" (?keyDownFlag@GameDriver@@2_NA)
1>GUI_Env.obj : error LNK2001: unresolved external symbol "private: static struct BITMAP * GUI_Env::buffer" (?buffer@GUI_Env@@0PAUBITMAP@@A)
1>GUI_Info.obj : error LNK2001: unresolved external symbol "private: static struct BITMAP * GUI_Info::buffer" (?buffer@GUI_Info@@0PAUBITMAP@@A)
1>MenuDriver.obj : error LNK2019: unresolved external symbol "public: static void __cdecl MainMenu::displayMenu(void)" (?displayMenu@MainMenu@@SAXXZ) referenced in function "public: static void __cdecl MenuDriver::start(void)" (?start@MenuDriver@@SAXXZ)
1>SpaceObjectFactory.obj : error LNK2001: unresolved external symbol "private: static class SpaceObjectFactory * SpaceObjectFactory::_instance" (?_instance@SpaceObjectFactory@@0PAV1@A)
1>Spy.obj : error LNK2019: unresolved external symbol "public: virtual bool __thiscall UnFormationable::sameTypeOfSpaceObjectAs(class SpaceObject *)" (?sameTypeOfSpaceObjectAs@UnFormationable@@UAE_NPAVSpaceObject@@@Z) referenced in function "public: virtual bool __thiscall Spy::sameTypeOfSpaceObjectAs(class SpaceObject *)" (?sameTypeOfSpaceObjectAs@Spy@@UAE_NPAVSpaceObject@@@Z)
1>WeaponsDB.obj : error LNK2001: unresolved external symbol "private: static class WeaponsDB * WeaponsDB::_instance" (?_instance@WeaponsDB@@0PAV1@A)
1>C:\Users\Owner\Desktop\Bosconian\code\Bosconian\Debug\Bosconian.exe : fatal error LNK1120: 23 unresolved externals
</code></pre>
<p>Alright, here's a brief overview.</p>
<p>PI is a static constant in WeaponsDB and is referenced by other classes using WeaponsDB::PI and the appropriate #include (what's wrong with this?)</p>
<p>Most other errors stem from static variables and static methods for timers from the allegro gaming library.</p>
<p>What causes these errors and how might I get rid of them?</p>
<p>Thanks in advance</p>
<p>----------------Edits-------------------</p>
<p>As requested, where the WeaponsDB::PI is declared and defined.
It is declared in WeaponsDB.h:</p>
<pre><code>public:
static double PI;
</code></pre>
<p>But it is defined in another class Driver.cpp:</p>
<pre><code>WeaponsDB::PI = 4*atan(1.0);
</code></pre>
<p>If this is one of the problems with my code I would love to know why this causes an error.</p>
| [
{
"answer_id": 380174,
"author": "Mr Fooz",
"author_id": 25050,
"author_profile": "https://Stackoverflow.com/users/25050",
"pm_score": 2,
"selected": false,
"text": "WeaponsDB::PI = 4*atan(1.0);\n double WeaponsDB::PI = 4*atan(1.0);\n"
},
{
"answer_id": 380277,
"author": "Dav... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39189/"
] |
380,165 | <p>Can somebody show me how to calculate the inverse of a matrix? I'm using VC++ 6.0</p>
| [
{
"answer_id": 380214,
"author": "pyon",
"author_id": 46571,
"author_profile": "https://Stackoverflow.com/users/46571",
"pm_score": 2,
"selected": false,
"text": "/* I took this from my implementation of CMatrix\n * It works, but I'm not sure if it's the most efficient algorithm.\n *\n... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
380,167 | <p>What is the best way to limit the number of (concurrent) users accessing a web application that any one can introduce for selling website/application to client and how to increase the number of users accessing it remotely?</p>
| [
{
"answer_id": 380302,
"author": "Pawel Krakowiak",
"author_id": 41420,
"author_profile": "https://Stackoverflow.com/users/41420",
"pm_score": 4,
"selected": true,
"text": "void Application_Start(object sender, EventArgs e)\n{\n Application[\"ActiveSessions\"] = 0;\n}\n\nvoid Session_... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41524/"
] |
380,171 | <p>I have two strings: the first's value is "catdog" and the second's is "got".</p>
<p>I'm trying to find a regex that tells me if the letters for "got" are in "catdog". I'm particularly looking to avoid the case where there are duplicate letters. For example, I know "got" is a match, however "gott" is not a match because there are not two "t" in "catdog".</p>
<p>EDIT:</p>
<p>Based on Adam's response below this is the C# code I got to work in my solution. Thanks to all those that responded.</p>
<p>Note: I had to convert the char to int and subtract 97 to get the appropriate index for the array. In my case the letters are <em>always</em> lower case.</p>
<pre><code> private bool CompareParts(string a, string b)
{
int[] count1 = new int[26];
int[] count2 = new int[26];
foreach (var item in a.ToCharArray())
count1[(int)item - 97]++;
foreach (var item in b.ToCharArray())
count2[(int)item - 97]++;
for (int i = 0; i < count1.Length; i++)
if(count2[i] > count1[i])
return false;
return true;
}
</code></pre>
| [
{
"answer_id": 380197,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 0,
"selected": false,
"text": "^[^got]*(g|o|t)[^got]$\n"
},
{
"answer_id": 380202,
"author": "derobert",
"author_id": 27727,
"... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380171",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42620/"
] |
380,172 | <p>I have a program that was written for linux and I am trying to build and run it on my MacOS 10.5 machine. The program builds and runs without problem, however it makes many calls to syslog. I know that syslogd is running on my mac, however I can't seem to find where my syslog calls are output to.</p>
<p>The syslog calls are of the form</p>
<pre><code>syslog (LOG_WARNING, "Log message");
</code></pre>
<p>Any idea where I might find my log output?</p>
| [
{
"answer_id": 380190,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 4,
"selected": false,
"text": "man syslog /var/log/syslog $ syslog -s -l INFO \"Hello, world.\"\n"
},
{
"answer_id": 380230,
"author":... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
380,184 | <p>I am trying to get a text to wrap around a <code>div</code> in my XHTML. My XHTML looks like so....</p>
<pre><code><div id="cont-content">
<p>content</p>
<p>more content</p>
<div id="content-sidebar">
BLALALALALLAAL
</div>
</div>
</code></pre>
<p>And my CSS looks like...</p>
<pre><code>#content-sidebar {
display: block;
float: right;
width: 270px;
height: 400px;
border: 1px solid red;
}
</code></pre>
<p>Can you see any reason why the text will not wrap around this Div?</p>
| [
{
"answer_id": 394727,
"author": "datasn.io",
"author_id": 49318,
"author_profile": "https://Stackoverflow.com/users/49318",
"pm_score": 6,
"selected": true,
"text": "<div id=\"cont-content\">\n\n<div id=\"content-sidebar\">\n\n BLALALALALLAAL\n\n </div>\n\n<p>content</p>\n\n<p>more cont... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31671/"
] |
380,198 | <p>Is it possible to pass a function as a parameter in C#? I can do it using the Func or Action classes, but this forces me to declare the entire function signature at once. When I try to use Delegate, I get a compile error saying it can't convert a method group to a Delegate. </p>
<p>I'm working on <a href="http://www.codeplex.com/axial" rel="noreferrer">Axial</a> and I'm trying to allow users to call web services. What I'm going for is the ability to create the Visual Studio proxy class and then pass in the generated function. The function signature doesn't matter because the generated code only uses the function name. However, I'd like to pass in the function instead of the name for two reasons: the ability to use the proxy's Url property and a compiler error if the web service doesn't exist or is updated in Visual Studio.</p>
<pre><code>
public void AlertIt(object o) {
Axial.DOM.Window.Alert(o.ToString());
}
public void CallAddService() {
object[] param = new object[] { int.Parse(txtA.Text), int.Parse(txtB.Text) };
Axial.ServerScript.CallWebService(new WSProxy.WS().Add, param, AlertIt, AlertIt);
}
class Axial.ServerScript {
public void CallWebService(Delegate method, object[] param, Action<object> successCallback, Action<object> failureCallback) {
// translate to javascript (already working)
}
}
</code></pre>
| [
{
"answer_id": 380231,
"author": "Jon Limjap",
"author_id": 372,
"author_profile": "https://Stackoverflow.com/users/372",
"pm_score": 2,
"selected": false,
"text": "delegate int Operation(int a, int b)\n public void InvokeMethod(Operation method, object target, object param)\n{\n meth... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23427/"
] |
380,215 | <p>I am building a small wpf app in C#. When a button gets clicked a third
party dll function constructs a tree like object. This object is bound
to a treeview. This works fine but takes a bit of time to load. As the
dll function constructs the object it prints progress info to the
console. I want to redirect this into a TextBlock so that the user
gets to see the progress messages. </p>
<p>My window ctor looks like this: </p>
<pre>
InitializeComponent();
StringRedir s = new StringRedir(ref ProgressTextBlock);
Console.SetOut(s);
Console.SetError(s);
this.DataContext = s;
</pre>
<p>xaml: <pre>
<code><</code>TextBlock Text="{Binding Path=Text}" Width="244"
x:Name="ProgressTextBlock" TextWrapping="Wrap" />
<code><</code>TreeView >...<code><</code>/TreeView>
</pre></p>
<p>The StringRedir class is shown below. The problem is the TextBlock for
some reason does not get updated with the messages until the TreeView
gets loaded. Stepping through I see the Text property being updated
but the TextBlock is not getting refreshed. I added a MessageBox.Show
() at the point where Text gets updated and this seems to cause the
window to refresh each time and I am able to see each message. So I
guess I need some way to explicitly refresh the screen...but this
doesnt make sense I thought the databinding would cause a visual
refresh when the property changed. What am I missing here? How do I
get it to refresh? Any advice is appreciated! </p>
<pre><code>public class StringRedir : StringWriter , INotifyPropertyChanged
{
private string text;
private TextBlock local;
public string Text {
get{ return text;}
set{
text = text + value;
OnPropertyChanged("Text");
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string name)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(name));
}
}
public StringRedir(ref TextBlock t)
{
local = t;
Text = "";
}
public override void WriteLine(string x)
{
Text = x +"\n";
//MessageBox.Show("hello");
}
}
</code></pre>
| [
{
"answer_id": 380255,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 0,
"selected": false,
"text": "local.Text = \"\";\n {Binding Text}\n"
},
{
"answer_id": 380495,
"author": "Kent Boogaart",
"author_id":... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47660/"
] |
380,217 | <p>I have a form without caption, using on double click to maximize : Code looks like this:</p>
<pre><code>procedure xxxxxx;
begin
if Form1.WindowState=wsNormal then
begin
Form1.WindowState:=wsMaximized;
Form1.SetBounds(0,0,screen.Width,screen.Height-getHeightOfTaskBar);
end
else
begin
Form1.WindowState:=wsNormal;
end;
ShowTrayWindow;
end;
function getHeightOfTaskBar : integer;
var hTaskBar:HWND;
rect : TRect;
begin
hTaskbar := FindWindow('Shell_TrayWnd', Nil );
if hTaskBar<>0 then
GetWindowRect(hTaskBar, rect);
Result:=rect.bottom - rect.top;
end;
</code></pre>
<p>This works good, except that I have to figure out where is task bar to reset SetBounds ...</p>
<p>What is the correct way to do this?</p>
<p>Thanks.</p>
| [
{
"answer_id": 380266,
"author": "Drejc",
"author_id": 6482,
"author_profile": "https://Stackoverflow.com/users/6482",
"pm_score": 0,
"selected": false,
"text": "procedure TCustomForm.SetWindowState(Value: TWindowState);\nconst\n ShowCommands: array[TWindowState] of Integer =\n (SW_S... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27016/"
] |
380,221 | <p>How to hide controller name in Url?</p>
<p>I use the ASP.NET MVC.</p>
<p>The original url is: <a href="http://www.sample.com/Users.mvc/UserDetail/9615" rel="nofollow noreferrer">http://www.sample.com/Users.mvc/UserDetail/9615</a></p>
<p>The "Users" is controller name, the "UserDetail" is action name, and the "9615" is UserId.</p>
<p>How can I hide the controller name and action name in the url. </p>
<p>Just like this: <a href="http://www.sample.com/9615" rel="nofollow noreferrer">http://www.sample.com/9615</a></p>
<p>I have writed the following code in the Global.ascx.cs to hide the action name:</p>
<pre><code>routes.MapRoute(
"UserDetail", // Route name
"Users.mvc/{UserId}", // URL with parameters
new { controller = "Users", action = "UserDetail", UserId = "" } // Parameter defaults
);
</code></pre>
<p>Using the above code I hid the action name and got this url: <a href="http://www.sample.com/Users.mvc/9615" rel="nofollow noreferrer">http://www.sample.com/Users.mvc/9615</a></p>
<p>But how can I hide the controller name and get this url: <a href="http://www.sample.com/9615" rel="nofollow noreferrer">http://www.sample.com/9615</a></p>
<p>Thanks.</p>
| [
{
"answer_id": 380298,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 3,
"selected": true,
"text": "routes.MapRoute(\"UserDetails\", \"{UserID}/{*name}\", \n new { controller = \"Users\", action = \"UserDetail\" , UserID=\"\... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380221",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40919/"
] |
380,227 | <p>Suppose I am entering validation code into my model of multi-language publication database. The database needs either an English or a Japanese title for a particular journal. So I need to validate_presence_of at least one of the two. Right now I can easily check that both exists, but am stumped on the case of "at least one":</p>
<pre><code>class Article < ActiveRecord::Base
belongs_to :publication
validate_presence_of :journal_title
validate_presence_of :journal_title_ja
end
</code></pre>
<p>I think this might require a statement like:</p>
<pre><code>:if => :jornal_title_ja is nil
</code></pre>
| [
{
"answer_id": 380250,
"author": "Chirantan",
"author_id": 45942,
"author_profile": "https://Stackoverflow.com/users/45942",
"pm_score": 4,
"selected": true,
"text": "class Article < ActiveRecord::Base \n belongs_to :publication \n validate_presence_of :journal_title, :if => :check_j... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39584/"
] |
380,244 | <p>I want to build a dynamic floating window with close button at corner. Is it possible, and also i want to add some content dynamically into that window. </p>
<p>Please help me.. It should be in javascript.. Better without AJAX..</p>
<p>Thanks in Advance</p>
| [
{
"answer_id": 486493,
"author": "Jack Lawson",
"author_id": 59616,
"author_profile": "https://Stackoverflow.com/users/59616",
"pm_score": 4,
"selected": false,
"text": "<div id=\"example\">I'm in a dialog!</div>\n$(\"#example\").dialog();\n"
}
] | 2008/12/19 | [
"https://Stackoverflow.com/questions/380244",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38172/"
] |
380,267 | <p>i want ask some question about asp.net mvc</p>
<ol>
<li>Is static constructor will init every user request?</li>
<li>Is static data share for every user?</li>
</ol>
| [
{
"answer_id": 380270,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 4,
"selected": true,
"text": "ThreadStatic"
}
] | 2008/12/19 | [
"https://Stackoverflow.com/questions/380267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44533/"
] |
380,274 | <p><strong>What in C#.NET makes it more suitable</strong> for some projects than VB.NET?</p>
<p>Performance?, Capabilities?, Libraries/Components?, Reputation?, Reliability? Maintainability?, Ease?</p>
<hr>
<p>Basically anything <strong>C# can do, that is impossible using VB,</strong> or vice versa.
Things you just <strong>have to consider</strong> when choosing C#/VB for a project.</p>
| [
{
"answer_id": 380282,
"author": "JoshBerke",
"author_id": 26160,
"author_profile": "https://Stackoverflow.com/users/26160",
"pm_score": 6,
"selected": true,
"text": "try\n{\n //do something that fails\n}\ncatch(Exception ex when ArgumentException, \n ArgumentNullException, Format... | 2008/12/19 | [
"https://Stackoverflow.com/questions/380274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41021/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.