qid
int64 4
19.1M
| question
stringlengths 18
48.3k
| answers
list | date
stringlengths 10
10
| metadata
list |
|---|---|---|---|---|
192,796
|
<p>Suppose I have an M-file that calculates, for exampleת <code>d=a+b+c</code> (The values on <code>a</code>, <code>b</code>, <code>c</code> were given earlier). </p>
<p>What command should I use in order to produce an output M-file showing the result of this sum?</p>
|
[
{
"answer_id": 192841,
"author": "Scottie T",
"author_id": 6688,
"author_profile": "https://Stackoverflow.com/users/6688",
"pm_score": 1,
"selected": false,
"text": "disp(num2str(d));\n"
},
{
"answer_id": 192859,
"author": "Azim J",
"author_id": 4612,
"author_profile": "https://Stackoverflow.com/users/4612",
"pm_score": 3,
"selected": false,
"text": ">> d=1+2;\n>> d=1+2\nd = \n 3\n >> disp(num2str(d));\n3\n >> dlmwrite('filename',d,',') \n >> save('filename','d')\n"
},
{
"answer_id": 193765,
"author": "b3.",
"author_id": 14946,
"author_profile": "https://Stackoverflow.com/users/14946",
"pm_score": 2,
"selected": false,
"text": "save 'filename' d -ascii\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
192,801
|
<p>Trivial data binding examples are just that, trivial. I want to do something a little more complicated and am wondering if there's an easy, built in way to handle it.</p>
<pre><code>public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
List<DataStruct> list = new List<DataStruct>()
{
new DataStruct(){Name = "Name 1", Value = "Value 1", ComplexValue = new ComplexValue(){Part1 = "1:P1", Part2 = "1:P2"}},
new DataStruct(){Name = "Name 2", Value = "Value 2", ComplexValue = new ComplexValue(){Part1 = "2:P1", Part2 = "2:P2"}}
};
listBox1.DataSource = list;
listBox1.DisplayMember = "ComplexValue.Part1";
}
}
public class DataStruct
{
public string Name { get; set; }
public string Value { get; set; }
public ComplexValue ComplexValue { get; set; }
}
public class ComplexValue
{
public string Part1 { get; set; }
public string Part2 { get; set; }
}
</code></pre>
<p>Is there an easy way to get the value of the Part1 property to be set as the display member for a list of DataStruct items? Above I tried something that I thought made sense, but it just defaults back to the ToString() on DataStruct. I can work around it if necessary, I was just wondering if there was something built into the data binding that would handle more complex data binding like above.</p>
<p>Edit: Using WinForms</p>
|
[
{
"answer_id": 192841,
"author": "Scottie T",
"author_id": 6688,
"author_profile": "https://Stackoverflow.com/users/6688",
"pm_score": 1,
"selected": false,
"text": "disp(num2str(d));\n"
},
{
"answer_id": 192859,
"author": "Azim J",
"author_id": 4612,
"author_profile": "https://Stackoverflow.com/users/4612",
"pm_score": 3,
"selected": false,
"text": ">> d=1+2;\n>> d=1+2\nd = \n 3\n >> disp(num2str(d));\n3\n >> dlmwrite('filename',d,',') \n >> save('filename','d')\n"
},
{
"answer_id": 193765,
"author": "b3.",
"author_id": 14946,
"author_profile": "https://Stackoverflow.com/users/14946",
"pm_score": 2,
"selected": false,
"text": "save 'filename' d -ascii\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16979/"
] |
192,810
|
<p>I have a home-grown automated build script in the form of a DOS batch file. In part of that script, I check out (with "svn checkout") a section of our SVN repository that includes a bunch of third-party stuff that's used in our projects. This batch file performed pretty well for a long time, but now people have checked in lots of fluff (docs, sample code, etc.) into the third-party area and the checkout part of this script has gotten lots slower. I'd like to mitigate this by checking out only the stuff we need -- mostly dll files in our case. So, my question is this: what's the best way to check out an SVN repository filtered by file extension?</p>
<p>I didn't see any obvious way to do this in the svn help. I have a .NET utility library that wraps svn.exe in some ways, and I was thinking of extending this to retrieve only content that matched my extensions of interest. But I'd prefer to use an easier or existing method if one exists.</p>
|
[
{
"answer_id": 2023917,
"author": "Michael Hackner",
"author_id": 189919,
"author_profile": "https://Stackoverflow.com/users/189919",
"pm_score": 6,
"selected": true,
"text": "svn checkout svn update filename svn checkout svn://path/to/repos/directory --depth empty svn list --recursive svn://path/to/repos/directory grep svn update --parents"
},
{
"answer_id": 32982278,
"author": "eddie.sholl",
"author_id": 2658793,
"author_profile": "https://Stackoverflow.com/users/2658793",
"pm_score": -1,
"selected": false,
"text": "svn ls http://svn-server/src --recursive | Out-File svn.txt\nGet-Content .\\svn.txt | where {$_.toLower().EndsWith('special.xml')} | select -First 200 | foreach {New-Object PSObject -Property @{ Path = $_; Munged = $_.Replace('/', '_') } } | foreach { svn export \"http://svn-server/src/$($_.Path)\" $($_.Munged) }\n"
},
{
"answer_id": 43532291,
"author": "Kamyar",
"author_id": 2617093,
"author_profile": "https://Stackoverflow.com/users/2617093",
"pm_score": 0,
"selected": false,
"text": "@echo off\n\nsvn list --recursive https://path_to_repository_folder | find /I \".sql\" > filelist.txt\n\nREM Specify a custom delim. Otherwise space in filename will be treated as a delimiter.\nFOR /F \"delims=|\" %%i IN (filelist.txt) DO (\n echo -------------\n echo %%i\n svn update --parents \"%%i\"\n)\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/404/"
] |
192,822
|
<p>I know the #warning directive does not exist in vb.net... is there anything like it?<br>
I want to be able to throw messages (warnings) at compiler time.</p>
|
[
{
"answer_id": 59661392,
"author": "bitlischieber",
"author_id": 3767329,
"author_profile": "https://Stackoverflow.com/users/3767329",
"pm_score": 1,
"selected": false,
"text": "<ObsoleteAttribute(\"You should no used this method!\", False)>\nSub MySub()\nEnd Sub\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23893/"
] |
192,824
|
<p>Can I ignore a folder on svn checkout? I need to ignore DOCs folder on checkout at my build server.</p>
<p><strong>edit:</strong> Ignore externals isn't an option. I have some externals that I need.</p>
|
[
{
"answer_id": 192835,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 2,
"selected": false,
"text": "svn checkout --ignore-externals"
},
{
"answer_id": 218131,
"author": "Jon Topper",
"author_id": 6945,
"author_profile": "https://Stackoverflow.com/users/6945",
"pm_score": 8,
"selected": true,
"text": "$ svn co http://subversion/project/trunk my_checkout --depth immediates\n $ cd my_checkout && ls\nbar/ baz foo xyzzy/\n $ cd bar && svn update --set-depth infinity\n"
},
{
"answer_id": 218160,
"author": "mxcl",
"author_id": 6444,
"author_profile": "https://Stackoverflow.com/users/6444",
"pm_score": 3,
"selected": false,
"text": "svn co -N foo\ncd foo\nsvn up -N bar\nsvn up\n lala bar svn up lala"
},
{
"answer_id": 4492129,
"author": "bv.",
"author_id": 215846,
"author_profile": "https://Stackoverflow.com/users/215846",
"pm_score": 2,
"selected": false,
"text": " # Path to the svn repository to be checked out\nrpath=https://svn-repo.company.com/sw/trunk/ && \\\n # This files are to be excluded (folders are ending with '/')\n # this is a regex pattern with OR ('|') between enties to be excluded\nexcludep='docs_folder/tests_folder/|huge_folder/|file1|file2' && \\\n # Get list of the files/folders right under the repository path\nfiltered=`svn ls $rpath | egrep -v $excludep` && \\\n # Get list of files out of filtered - they need to be 'uped'\nfiles=`echo $filtered | sed 's| |\\n|g' | egrep '^.*[^/]$'` && \\\n # Get list of folders out of filtered - they need to be 'coed'\nfolders=`echo $filtered | sed 's| |\\n|g' | egrep '^.*[/]$'` && \\\n # Initial nonrecursive checkout of repository - just empty\n # to the current (./) working directory\nsvn co $rpath ./ --depth empty && \\\n # Update the files\nsvn up $files &&\\\n # Check out the all other folders finally.\nsvn co `echo $folders | sed \"s|\\<|$rpath|g\"`\n"
},
{
"answer_id": 8446590,
"author": "tommy_turrell",
"author_id": 1089829,
"author_profile": "https://Stackoverflow.com/users/1089829",
"pm_score": 6,
"selected": false,
"text": "svn checkout http://www.example.com/project\ncd project\nsvn update --set-depth=exclude docs\nrm -fr docs\n"
},
{
"answer_id": 25256909,
"author": "rgov",
"author_id": 145504,
"author_profile": "https://Stackoverflow.com/users/145504",
"pm_score": 2,
"selected": false,
"text": "svn checkout http://svn.webkit.org/repository/webkit/trunk WebKit \\\n --depth immediates\n\ncd WebKit\nfind . \\\n -maxdepth 1 -type d \\\n -not -name '.*' \\\n -not -name '*Tests' \\\n -not -name 'Examples' \\\n -not -name 'Websites' \\\n | (while read SUBDIR; do svn update --set-depth infinity \"$SUBDIR\"; done)\n"
},
{
"answer_id": 73405760,
"author": "Nathan Pacey",
"author_id": 15526191,
"author_profile": "https://Stackoverflow.com/users/15526191",
"pm_score": 0,
"selected": false,
"text": "$ svn co svn://subversion/project/my_project_dir --depth immediates\n $ cd my_project_dir\n$ cd working_dir && svn update --set-depth infinity\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20683/"
] |
192,838
|
<p>I was wondering if it is possible to generate a "core" file, copy if to another machine and then continue execution of the a core file on that machine?</p>
<p>I have seen the gcore utility that will make a core file from a running process. But I do not think gdb can continue execution based on a core file.</p>
<p>Is there any way to just dump the heap/stack and and restore those at a later point?</p>
|
[
{
"answer_id": 42280061,
"author": "Nobilis",
"author_id": 1006955,
"author_profile": "https://Stackoverflow.com/users/1006955",
"pm_score": 2,
"selected": false,
"text": "sudo apt-get install criu"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7743/"
] |
192,839
|
<p>Is it possible to get the machine name, or IP, or MAC address (basically client network information) from javascript running Internet Explorer?</p>
<p>I found the following code that seems to accomplish this:</p>
<pre><code>function Button1_onclick() {
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");
var e = new Enumerator (properties);
document.write("<table border=1>");
dispHeading();
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.Caption + "</td>");
document.write("<td>" + p.IPFilterSecurityEnabled + "</td>");
document.write("<td>" + p.IPPortSecurityEnabled + "</td>");
document.write("<td>" + p.IPXAddress + "</td>");
document.write("<td>" + p.IPXEnabled + "</td>");
document.write("<td>" + p.IPXNetworkNumber + "</td>");
document.write("<td>" + p.MACAddress + "</td>");
document.write("<td>" + p.WINSPrimaryServer + "</td>");
document.write("<td>" + p.WINSSecondaryServer + "</td>");
document.write("</tr>");
}
document.write("</table>");
</code></pre>
<p>}</p>
<p>So it's using an ActiveX Object that seems to be installed with the OS to accomplish this. Is something similar like this possible to do from a terminal service session? To get the terminal service client network information? (Not the terminal server network information which is what the above code would do when run from a terminal service session).</p>
<p>I'm thinking maybe there is another Active X object available to accomplish this?</p>
|
[
{
"answer_id": 195351,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 2,
"selected": true,
"text": "MetaFrameSession MetaFrame_ICA_Client root\\Citrix var MetaFrameSessionObject = 6;\n\nvar oShell = new ActiveXObject(\"WScript.Shell\");\nvar oSession = new ActiveXObject(\"MetaFrameCOM.MetaFrameSession\");\n\noSession.Initialize(\n MetaFrameSessionObject, \n oShell.ExpandEnvironmentStrings(\"%COMPUTERNAME%\"), \n oShell.ExpandEnvironmentStrings(\"%SESSIONNAME%\"), \n -1\n);\n\nalert(oSession.ClientAddress);\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1341/"
] |
192,862
|
<p>I'm developing a webapp where the user is given the chance to upload his resume in pdf format. I'm using NHibernate as a data mapper and MS SQL SERVER 2005.</p>
<p>I want to be able to save the .pdf file to a given table... any ideas?</p>
<p>Thank you very much!</p>
|
[
{
"answer_id": 200565,
"author": "huo73",
"author_id": 15657,
"author_profile": "https://Stackoverflow.com/users/15657",
"pm_score": 4,
"selected": true,
"text": "package com.hibernate.pdf.sample;\n\npublic class TPDFDocument implements java.io.Serializable {\n\n\n private Integer pdfDocumentId;\n private byte[] document;\n\n\n public Integer getPdfDocumentId() {\n return this.pdfDocumentId;\n }\n\n public void setPdfDocumentId(Integer pdfDocumentId) {\n this.pdfDocumentId = pdfDocumentId;\n }\n\n public byte[] getDocument() {\n return this.document;\n }\n\n public void setDocument(byte[] document) {\n this.document = document;\n }\n\n}\n <hibernate-mapping>\n <class name=\"com.hibernate.pdf.sample.TPDFDocument\" table=\"T_PDFDocument\">\n <id name=\"pdfDocumentId\" type=\"integer\">\n <column name=\"pdfDocumentId\" />\n <generator class=\"identity\" />\n </id>\n <property name=\"document\" type=\"binary\">\n <column name=\"document\" not-null=\"true\" />\n </property>\n </class>\n</hibernate-mapping>\n CREATE TABLE [dbo].[T_PDFDocument](\n [pdfDocumentId] [int] IDENTITY(1,1) NOT NULL,\n [document] [image] NOT NULL,\nCONSTRAINT [PK_PDFDocument] PRIMARY KEY CLUSTERED \n(\n [pdfDocumentId] ASC\n)\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7595/"
] |
192,876
|
<p>Is there any way to set a system wide memory limit a process can use in Windows XP? I have a couple of unstable apps which do work ok for most of the time but can hit a bug which results in eating whole memory in a matter of seconds (or at least I suppose that's it). This results in a hard reset as Windows becomes totally unresponsive and I lose my work.</p>
<p>I would like to be able to do something like the /etc/limits on Linux - setting M90, for instance (to set 90% max memory for a single user to allocate). So the system gets the remaining 10% no matter what.</p>
|
[
{
"answer_id": 73521886,
"author": "Jim Grisham",
"author_id": 5711986,
"author_profile": "https://Stackoverflow.com/users/5711986",
"pm_score": 3,
"selected": true,
"text": "renice"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26943/"
] |
192,878
|
<p>I've been tasked with writing a outlook .MSG files from XML files that have associated metadata. I've tried using the Aspose library, but all of the exposed MapiMessage properties are read only. Using the Outlook Object Model I'm unable to change the creation date, and other properties that I must have access to. I've also tried the Rebex library also, but it exports to EML, and doesn't support RTF.</p>
<p>My question is, is there a Mapi or any kind of way to write a .MSG file and have access over every property?</p>
|
[
{
"answer_id": 73521886,
"author": "Jim Grisham",
"author_id": 5711986,
"author_profile": "https://Stackoverflow.com/users/5711986",
"pm_score": 3,
"selected": true,
"text": "renice"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
192,888
|
<p>I have some nested tables that I want to hide/show upon a click on one of the top-level rows.</p>
<p>The markup is, in a nutshell, this:</p>
<pre>
<table>
<tr>
<td>stuff</td>
.... more tds here
</tr>
<tr>
<td colspan=some_number>
<table>
</table>
</td>
</tr>
</table>
</pre>
<p>Now, I'm using some jQuery to target a link in the first table row. When that link is clicked, it pulls some data down, formats it as a bunch of table rows, and appends it to the table inside. Then it applies the .show() to the table. (this is all done via id/class targeting. I left them out of the sample for brevity).</p>
<p>This works beautifully in firefox. Click the link, data gets loaded, main table "expands" with the secondary table all nice and filled in.</p>
<p>Problem is -- Internet Explorer is giving me the finger. As best as I can tell, the data is getting appended to the inner table. The problem is that the .show() does not appear to be doing anything useful. To make matters more annoying, I've got a page that has this functionality that is working splendidly in both -- the only difference being two things:</p>
<p>In the one that is working, the inner table is wrapped in a div. I've even tried wrapping my table in this example in a div without success.
In the one that is not working, I have an extra jQuery plugin loaded -- but I've removed this plugin and tried the page without it and it still fails to show the inner table.</p>
<p>I've tried attaching the .show to the parent tr, parent td, and the table itself with no success. I must be missing something incredibly simple, because as near as I can tell this should work.</p>
<p>Has anyone come across something like this before?</p>
|
[
{
"answer_id": 192901,
"author": "Mark Biek",
"author_id": 305,
"author_profile": "https://Stackoverflow.com/users/305",
"pm_score": 1,
"selected": false,
"text": "<td <table"
},
{
"answer_id": 192904,
"author": "Zack The Human",
"author_id": 18265,
"author_profile": "https://Stackoverflow.com/users/18265",
"pm_score": 4,
"selected": true,
"text": "<table>\n <tbody>\n <!-- Add stuff here... -->\n </tbody>\n</table>\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22390/"
] |
192,892
|
<p>Has anyone implemented a very large EAV or open schema style database in SQL Server? I'm wondering if there are performance issues with this and how you were able to overcome those obstacles.</p>
|
[
{
"answer_id": 231681,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 3,
"selected": false,
"text": "SELECT e.id, a1.attr_value as \"cost\", a2.attr_value as \"color\",\n a3.attr_value as \"size\", . . .\nFROM entity e\n LEFT OUTER JOIN attrib a1 ON (e.entity_id = a1.entity_id AND a1.attr_name = 'cost')\n LEFT OUTER JOIN attrib a2 ON (e.entity_id = a2.entity_id AND a2.attr_name = 'color')\n LEFT OUTER JOIN attrib a2 ON (e.entity_id = a3.entity_id AND a3.attr_name = 'size')\n . . . additional joins for each attribute . . .\n SELECT e.id, a.attr_name, a.attr_value\nFROM entity e JOIN attrib a USING (entity_id)\nORDER BY e.id;\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192892",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4541/"
] |
192,900
|
<p>Is it possible to set the cursor to 'wait' on the entire html page in a simple way? The idea is to show the user that something is going on while an ajax call is being completed. The code below shows a simplified version of what I tried and also demonstrate the problems I run into:</p>
<ol>
<li>if an element (#id1) has a cursor style set it will ignore the one set on body (obviously) </li>
<li>some elements have a default cursor style (a) and will not show the wait cursor on hover </li>
<li>the body element has a certain height depending on the content and if the page is short, the cursor will not show below the footer</li>
</ol>
<p>The test:</p>
<pre><code><html>
<head>
<style type="text/css">
#id1 {
background-color: #06f;
cursor: pointer;
}
#id2 {
background-color: #f60;
}
</style>
</head>
<body>
<div id="id1">cursor: pointer</div>
<div id="id2">no cursor</div>
<a href="#" onclick="document.body.style.cursor = 'wait'; return false">Do something</a>
</body>
</html>
</code></pre>
<p>Later edit...<br>
It worked in firefox and IE with: </p>
<pre><code>div#mask { display: none; cursor: wait; z-index: 9999;
position: absolute; top: 0; left: 0; height: 100%;
width: 100%; background-color: #fff; opacity: 0; filter: alpha(opacity = 0);}
<a href="#" onclick="document.getElementById('mask').style.display = 'block'; return false">
Do something</a>
</code></pre>
<p>The problem with (or feature of) this solution is that it will prevent clicks because of the overlapping div (thanks Kibbee)</p>
<p>Later later edit...<br>
A simpler solution from Dorward:</p>
<pre><code>.wait, .wait * { cursor: wait !important; }
</code></pre>
<p>and then </p>
<pre><code><a href="#" onclick="document.body.className = 'wait'; return false">Do something</a>
</code></pre>
<p>This solution only shows the wait cursor but allows clicks.</p>
|
[
{
"answer_id": 193006,
"author": "Kibbee",
"author_id": 1862,
"author_profile": "https://Stackoverflow.com/users/1862",
"pm_score": 4,
"selected": false,
"text": "<style>\n*{ cursor: inherit;}\nbody{ cursor: wait;}\n</style>\n"
},
{
"answer_id": 202671,
"author": "GameFreak",
"author_id": 26659,
"author_profile": "https://Stackoverflow.com/users/26659",
"pm_score": 1,
"selected": false,
"text": "html.waiting {\ncursor: wait;\n}\n body html"
},
{
"answer_id": 10801889,
"author": "Dani",
"author_id": 1424042,
"author_profile": "https://Stackoverflow.com/users/1424042",
"pm_score": 7,
"selected": false,
"text": "html.wait, html.wait * { cursor: wait !important; }\n $(document).ready(function () {\n $(document).ajaxStart(function () { $(\"html\").addClass(\"wait\"); });\n $(document).ajaxStop(function () { $(\"html\").removeClass(\"wait\"); });\n});\n $(document).ready(function () {\n $(\"html\").ajaxStart(function () { $(this).addClass(\"wait\"); });\n $(\"html\").ajaxStop(function () { $(this).removeClass(\"wait\"); });\n});\n"
},
{
"answer_id": 11644401,
"author": "jere_hr",
"author_id": 998698,
"author_profile": "https://Stackoverflow.com/users/998698",
"pm_score": 2,
"selected": false,
"text": "$('*').css('cursor','wait');\n"
},
{
"answer_id": 11725235,
"author": "pasx",
"author_id": 683319,
"author_profile": "https://Stackoverflow.com/users/683319",
"pm_score": 3,
"selected": false,
"text": "//...\ndocument.body.style.cursor = 'wait';\nsetTimeout(this.SomeLongFunction, 1);\n\n//setTimeout syntax when calling a function with parameters\n//setTimeout(function() {MyClass.SomeLongFunction(someParam);}, 1);\n\n//no () after function name this is a function ref not a function call\nsetTimeout(this.SetDefaultCursor, 1);\n...\n\nfunction SetDefaultCursor() {document.body.style.cursor = 'default';}\n\nfunction SomeLongFunction(someParam) {...}\n"
},
{
"answer_id": 12966122,
"author": "redbmk",
"author_id": 817950,
"author_profile": "https://Stackoverflow.com/users/817950",
"pm_score": 2,
"selected": false,
"text": ".waiting * { cursor: 'wait' } $('body').toggleClass('waiting');"
},
{
"answer_id": 31445877,
"author": "kofifus",
"author_id": 460084,
"author_profile": "https://Stackoverflow.com/users/460084",
"pm_score": 1,
"selected": false,
"text": "function changeCursor(elem, cursor, decendents) {\n if (!elem) elem=$('body');\n\n // remove all classes starting with changeCursor-\n elem.removeClass (function (index, css) {\n return (css.match (/(^|\\s)changeCursor-\\S+/g) || []).join(' ');\n });\n\n if (!cursor) return;\n\n if (typeof decendents==='undefined' || decendents===null) decendents=true;\n\n let cname;\n\n if (decendents) {\n cname='changeCursor-Dec-'+cursor;\n if ($('style:contains(\"'+cname+'\")').length < 1) $('<style>').text('.'+cname+' , .'+cname+' * { cursor: '+cursor+' !important; }').appendTo('head');\n } else {\n cname='changeCursor-'+cursor;\n if ($('style:contains(\"'+cname+'\")').length < 1) $('<style>').text('.'+cname+' { cursor: '+cursor+' !important; }').appendTo('head');\n }\n\n elem.addClass(cname);\n}\n changeCursor(, 'wait'); // wait cursor on all decendents of body\nchangeCursor($('#id'), 'wait', false); // wait cursor on elem with id only\nchangeCursor(); // remove changed cursor from body\n"
},
{
"answer_id": 46794402,
"author": "ungalcrys",
"author_id": 443427,
"author_profile": "https://Stackoverflow.com/users/443427",
"pm_score": 1,
"selected": false,
"text": "div#waitMask {\n z-index: 999;\n position: absolute;\n top: 0;\n right: 0;\n height: 100%;\n width: 100%;\n cursor: wait;\n background-color: #000;\n opacity: 0;\n transition-duration: 0.5s;\n -webkit-transition-duration: 0.5s;\n}\n // to show it\n$(\"#waitMask\").show();\n$(\"#waitMask\").css(\"opacity\"); // must read it first\n$(\"#waitMask\").css(\"opacity\", \"0.8\");\n\n...\n\n// to hide it\n$(\"#waitMask\").css(\"opacity\", \"0\");\nsetTimeout(function() {\n $(\"#waitMask\").hide();\n}, 500) // wait for animation to end\n <body>\n <div id=\"waitMask\" style=\"display:none;\"> </div>\n ... rest of html ...\n"
},
{
"answer_id": 48931250,
"author": "indiaaditya",
"author_id": 2837780,
"author_profile": "https://Stackoverflow.com/users/2837780",
"pm_score": 1,
"selected": false,
"text": "var vArrOriginalCursors = new Array(2);\n function CursorModifyEntirePage(CursorType){\n var elements = document.body.getElementsByTagName('*');\n alert(\"These are the elements found:\" + elements.length);\n let lclCntr = 0;\n vArrOriginalCursors.length = elements.length; \n for(lclCntr = 0; lclCntr < elements.length; lclCntr++){\n vArrOriginalCursors[lclCntr] = elements[lclCntr].style.cursor;\n elements[lclCntr].style.cursor = CursorType;\n }\n}\n function CursorRestoreEntirePage(){\n let lclCntr = 0;\n var elements = document.body.getElementsByTagName('*');\n for(lclCntr = 0; lclCntr < elements.length; lclCntr++){\n elements[lclCntr].style.cursor = vArrOriginalCursors[lclCntr];\n }\n}\n"
},
{
"answer_id": 60616224,
"author": "Peter J. de Bruin",
"author_id": 2061591,
"author_profile": "https://Stackoverflow.com/users/2061591",
"pm_score": 2,
"selected": false,
"text": "document.documentElement.style.cursor = 'wait';\n html { cursor: wait; }\n"
},
{
"answer_id": 61948501,
"author": "javocity",
"author_id": 3700767,
"author_profile": "https://Stackoverflow.com/users/3700767",
"pm_score": 0,
"selected": false,
"text": "Object.values(document.querySelectorAll('*')).forEach(element => element.style.cursor = \"wait\");\n Object.values(document.querySelectorAll('*')).forEach(element => element.style.cursor = \"default\");\n function setCursor(cursor)\n{\n var x = document.querySelectorAll(\"*\");\n\n for (var i = 0; i < x.length; i++)\n {\n x[i].style.cursor = cursor;\n }\n}\n setCursor(\"wait\");\n setCursor(\"default\");\n"
},
{
"answer_id": 72450083,
"author": "Francisco Jesus",
"author_id": 13899551,
"author_profile": "https://Stackoverflow.com/users/13899551",
"pm_score": -1,
"selected": false,
"text": "document.documentElement html#wait * {\n cursor: wait !important;\n}"
},
{
"answer_id": 74288000,
"author": "djvg",
"author_id": 4720018,
"author_profile": "https://Stackoverflow.com/users/4720018",
"pm_score": 0,
"selected": false,
"text": "<dialog> <div> ::backdrop wait function showWaitDialog() {\n document.getElementById('id_dialog').showModal();\n} #id_dialog, #id_dialog::backdrop {\n cursor: wait;\n} <button onclick=\"showWaitDialog()\">click me</button>\n<dialog id=\"id_dialog\">busy...</dialog> show() showModal() onclick"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20417/"
] |
192,907
|
<p>Python has several ways to parse XML...</p>
<p>I understand the very basics of parsing with <strong>SAX</strong>. It functions as a stream parser, with an event-driven API.</p>
<p>I understand the <strong>DOM</strong> parser also. It reads the XML into memory and converts it to objects that can be accessed with Python.</p>
<p>Generally speaking, it was easy to choose between the two depending on what you needed to do, memory constraints, performance, etc.</p>
<p>(Hopefully I'm correct so far.)</p>
<p>Since Python 2.5, we also have <strong>ElementTree</strong>. How does this compare to DOM and SAX? Which is it more similar to? Why is it better than the previous parsers?</p>
|
[
{
"answer_id": 194248,
"author": "Torsten Marek",
"author_id": 9567,
"author_profile": "https://Stackoverflow.com/users/9567",
"pm_score": 7,
"selected": true,
"text": "iterparse iterparse <a>This is <b>a</b> test</a>\n test tail b"
},
{
"answer_id": 15452402,
"author": "Paolo Rovelli",
"author_id": 2128591,
"author_profile": "https://Stackoverflow.com/users/2128591",
"pm_score": 4,
"selected": false,
"text": "<?xml version=\"1.0\"?>\n<catalog>\n <book isdn=\"xxx-1\">\n <author>A1</author>\n <title>T1</title>\n </book>\n <book isdn=\"xxx-2\">\n <author>A2</author>\n <title>T2</title>\n </book>\n</catalog>\n import os\nfrom xml.dom import minidom\nfrom xml.parsers.expat import ExpatError\n\n#-------- Select the XML file: --------#\n#Current file name and directory:\ncurpath = os.path.dirname( os.path.realpath(__file__) )\nfilename = os.path.join(curpath, \"sample.xml\")\n#print \"Filename: %s\" % (filename)\n\n#-------- Parse the XML file: --------#\ntry:\n #Parse the given XML file:\n xmldoc = minidom.parse(filepath)\nexcept ExpatError as e:\n print \"[XML] Error (line %d): %d\" % (e.lineno, e.code)\n print \"[XML] Offset: %d\" % (e.offset)\n raise e\nexcept IOError as e:\n print \"[IO] I/O Error %d: %s\" % (e.errno, e.strerror)\n raise e\nelse:\n catalog = xmldoc.documentElement\n books = catalog.getElementsByTagName(\"book\")\n\n for book in books:\n print book.getAttribute('isdn')\n print book.getElementsByTagName('author')[0].firstChild.data\n print book.getElementsByTagName('title')[0].firstChild.data\n import os\nfrom xml.etree import cElementTree # C implementation of xml.etree.ElementTree\nfrom xml.parsers.expat import ExpatError # XML formatting errors\n\n#-------- Select the XML file: --------#\n#Current file name and directory:\ncurpath = os.path.dirname( os.path.realpath(__file__) )\nfilename = os.path.join(curpath, \"sample.xml\")\n#print \"Filename: %s\" % (filename)\n\n#-------- Parse the XML file: --------#\ntry:\n #Parse the given XML file:\n tree = cElementTree.parse(filename)\nexcept ExpatError as e:\n print \"[XML] Error (line %d): %d\" % (e.lineno, e.code)\n print \"[XML] Offset: %d\" % (e.offset)\n raise e\nexcept IOError as e:\n print \"[XML] I/O Error %d: %s\" % (e.errno, e.strerror)\n raise e\nelse:\n catalogue = tree.getroot()\n\n for book in catalogue:\n print book.attrib.get(\"isdn\")\n print book.find('author').text\n print book.find('title').text\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192907",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16148/"
] |
192,915
|
<p>Within my Subversion project I have a few directories that contain other open source projects that my code needs. For example ffmpeg, freetype, matrixssl and a few others. </p>
<p>What is the best way to update SVN to hold the the latest version of one of these projects?</p>
<p>Essentially I will be doing the following (using ffmpeg as an example):</p>
<pre><code>1) Rename current ffmpeg folder to ffmpeg.old
2) Download new version of ffmpeg from net
3) Make sure it and my code compile and work fine together
4) Update subversion to now hold the "new" version of ffmpeg
5) Delete ffmpeg.old directory tree
</code></pre>
|
[
{
"answer_id": 192946,
"author": "JesperE",
"author_id": 13051,
"author_profile": "https://Stackoverflow.com/users/13051",
"pm_score": 2,
"selected": false,
"text": "branches/\ntrunk/\nvendor/\n cmake/\n cmake-2.6.0/\n cmake-2.6.1/\n cmake-2.6.2/\n ...\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13676/"
] |
192,920
|
<p><strong>Summary:</strong> I'm developing a persistent Java web application, and I need to make sure that all resources I persist have globally unique identifiers to prevent duplicates.</p>
<p><strong>The Fine Print:</strong></p>
<ol>
<li>I'm not using an RDBMS, so I don't have any fancy sequence generators (such as the one provided by Oracle)</li>
<li>I'd like it to be fast, preferably all in memory - I'd rather not have to open up a file and increment some value</li>
<li>It needs to be thread safe (I'm anticipating that only one JVM at a time will need to generate IDs)</li>
<li>There needs to be consistency across instantiations of the JVM. If the server shuts down and starts up, the ID generator shouldn't re-generate the same IDs it generated in previous instantiations (or at least the chance has to be really, really slim - I anticipate many millions of presisted resources)</li>
<li>I have seen the examples in the EJB unique ID pattern article. They won't work for me (I'd rather not rely solely on System.currentTimeMillis() because we'll be persisting multiple resources per millisecond).</li>
<li>I have looked at the answers proposed in <a href="https://stackoverflow.com/questions/41107/how-to-generate-a-random-alpha-numeric-string-in-java">this question</a>. My concern about them is, what is the chance that I will get a duplicate ID over time? I'm intrigued by the suggestion to use <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/UUID.html" rel="nofollow noreferrer">java.util.UUID</a> for a <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier" rel="nofollow noreferrer">UUID</a>, but again, the chances of a duplicate need to be infinitesimally small.</li>
<li>I'm using JDK6</li>
</ol>
|
[
{
"answer_id": 192947,
"author": "Bill K",
"author_id": 12943,
"author_profile": "https://Stackoverflow.com/users/12943",
"pm_score": 1,
"selected": false,
"text": "(System.currentTimeMillis() << 4) | (staticCounter++ & 15) private static int staticCounter=0;\nprivate final int nBits=4;\npublic long getUnique() {\n return (currentTimeMillis() << nBits) | (staticCounter++ & 2^nBits-1);\n}\n"
},
{
"answer_id": 197003,
"author": "Dave Griffiths",
"author_id": 15379,
"author_profile": "https://Stackoverflow.com/users/15379",
"pm_score": 1,
"selected": false,
"text": "public class UniqueID {\n private static long startTime = System.currentTimeMillis();\n private static long id;\n\n public static synchronized String getUniqueID() {\n return \"id.\" + startTime + \".\" + id++;\n }\n}\n"
},
{
"answer_id": 9744935,
"author": "kem",
"author_id": 1275015,
"author_profile": "https://Stackoverflow.com/users/1275015",
"pm_score": 0,
"selected": false,
"text": "String id = Long.toString(System.currentTimeMillis()) + \n (new Random()).nextInt(1000) + \n (new Random()).nextInt(1000);\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192920",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8217/"
] |
192,924
|
<p>Can you get the distinct combination of 2 different fields in a database table? if so, can you provide the SQL example.</p>
|
[
{
"answer_id": 192933,
"author": "Howard Pinsley",
"author_id": 7961,
"author_profile": "https://Stackoverflow.com/users/7961",
"pm_score": 8,
"selected": true,
"text": "select distinct c1, c2 from t\n select c1, c2, count(*)\nfrom t\ngroup by c1, c2\n"
},
{
"answer_id": 15370893,
"author": "Denno",
"author_id": 2162666,
"author_profile": "https://Stackoverflow.com/users/2162666",
"pm_score": 3,
"selected": false,
"text": "select c1, count(*) from (select distinct c1, c2 from t) group by c1\n"
},
{
"answer_id": 17667639,
"author": "Wilson Wu",
"author_id": 1756039,
"author_profile": "https://Stackoverflow.com/users/1756039",
"pm_score": 3,
"selected": false,
"text": "SELECT COUNT(*) FROM (SELECT DISTINCT c1, c2 FROM [TableEntity]) TE\n"
},
{
"answer_id": 55280856,
"author": "youkaichao",
"author_id": 9191338,
"author_profile": "https://Stackoverflow.com/users/9191338",
"pm_score": 2,
"selected": false,
"text": "select ([distinct] col)+ distinct | A | B\n__________\n 1| 1 | 2\n 2| 1 | 1\n select (distinct A), B B A = 1 distinct statement"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] |
192,938
|
<p>When in Outlook 2003, open the Address Book, select Tools->Options. You get the address dialog showing the option "When sending mail, check names using these address lists in the following order:"</p>
<p><img src="https://i.stack.imgur.com/wa79y.jpg" alt="Address dialog"></p>
<p>For most people, this will contain only "Contacts". For corporate networks, it'll probably also contain "Global Address List". The problem is that in my company the GAL is many tens of thousands large, and it's common that conflicts occur in name resolution when attempting to send email and it goes to the wrong person in another country.</p>
<p>Instead, I would like to place a separate Exchange address list "X" at the top of that list, to first resolve against names in our own company before checking the GAL. Then, resolve against "Contacts", then GAL. This configuration would need to be deployed to many hundreds of PCs.</p>
<p>I've been able to do this on my own PC by hacking registry key:
<code>HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\your_profile_name\9207f3e0a3b11019908b08002b2a56c2</code>, Value <code>11023d05</code>.</p>
<p>This contains a REG_BINARY data structure that lists the IDs of the items of this list. I can reorder them to my liking and Outlook accepts it.</p>
<p>The IDs of the GAL and "X" address list are static. However, the problem is that the "Contacts" ID is apparently not static, perhaps unique to the user and/or computer. Its value appears to be undiscoverable in the registry. This prevents me from simply copying this registry value to all PCs.</p>
<p>Has anyone been able to progammatically reorder the contact name resolution list?</p>
|
[
{
"answer_id": 17750361,
"author": "Dmitry Streblechenko",
"author_id": 332059,
"author_profile": "https://Stackoverflow.com/users/332059",
"pm_score": 0,
"selected": false,
"text": "IAddrBook.SetSearchPath RDOSession.AddressBook.SearchPath"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192938",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3347/"
] |
192,944
|
<p>I am trying to build a homebrew web brower to get more proficient at Cocoa. I need a good way to validate whether the user has entered a valid URL. I have tried some regular expressions but NSString has some interesting quirks and doesn't like some of the back-quoting that most regular expressions I've seen use.</p>
|
[
{
"answer_id": 193171,
"author": "Jon Shea",
"author_id": 3770,
"author_profile": "https://Stackoverflow.com/users/3770",
"pm_score": 4,
"selected": true,
"text": "+ (id)URLWithString:(NSString *)URLString NSURL nil baseURL host parameterString path"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26948/"
] |
192,951
|
<p>What's the fastest way to get a framebuffer and render to in software on the iPhone?</p>
<p>Basically getting into a mode 13h style thing going so I can make some effects? :)</p>
|
[
{
"answer_id": 192983,
"author": "Mark Bessey",
"author_id": 17826,
"author_profile": "https://Stackoverflow.com/users/17826",
"pm_score": 3,
"selected": true,
"text": "CGImageContext frameBuffer"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8005/"
] |
192,957
|
<p>Lets say that I have 10,000 regexes and one string and I want to find out if the string matches any of them and get all the matches.
The trivial way to do it would be to just query the string one by one against all regexes. Is there a faster,more efficient way to do it? </p>
<p>EDIT:
I have tried substituting it with DFA's (lex)
The problem here is that it would only give you one single pattern. If I have a string "hello" and patterns "[H|h]ello" and ".{0,20}ello", DFA will only match one of them, but I want both of them to hit.</p>
|
[
{
"answer_id": 192995,
"author": "Markus Jarderot",
"author_id": 22364,
"author_profile": "https://Stackoverflow.com/users/22364",
"pm_score": 2,
"selected": false,
"text": "(?=(regex1)?)(?=(regex2)?)(?=(regex3)?)...(?=(regex20)?)\n undefined None null"
},
{
"answer_id": 193027,
"author": "EfForEffort",
"author_id": 14113,
"author_profile": "https://Stackoverflow.com/users/14113",
"pm_score": 2,
"selected": false,
"text": "(r1)|(r2)|(r3)|...|(r10000)\n"
},
{
"answer_id": 1361359,
"author": "RCIX",
"author_id": 117069,
"author_profile": "https://Stackoverflow.com/users/117069",
"pm_score": -1,
"selected": false,
"text": "public static List<Regex> FindAllMatches(string s, List<Regex> regexes)\n{\n List<Regex> matches = new List<Regex>();\n foreach (Regex r in regexes)\n {\n if (r.IsMatch(string))\n {\n matches.Add(r);\n }\n }\n return matches;\n}\n"
},
{
"answer_id": 47319512,
"author": "Glen Thompson",
"author_id": 3866246,
"author_profile": "https://Stackoverflow.com/users/3866246",
"pm_score": 3,
"selected": false,
"text": "'cat' r'\\w+' import ahocorasick\nA = ahocorasick.Automaton()\n\npatterns = [\n [['cat','dog'],'mammals'],\n [['bass','tuna','trout'],'fish'],\n [['toad','crocodile'],'amphibians'],\n]\n\nfor row in patterns:\n vals = row[0]\n for val in vals:\n A.add_word(val, (row[1], val))\n\nA.make_automaton()\n\n_string = 'tom loves lions tigers cats and bass'\n\ndef test():\n vals = []\n for item in A.iter(_string):\n vals.append(item)\n return vals\n %timeit test() _string 100,000 2.09 ms 631 ms re.search()"
},
{
"answer_id": 49358587,
"author": "hroptatyr",
"author_id": 107375,
"author_profile": "https://Stackoverflow.com/users/107375",
"pm_score": 0,
"selected": false,
"text": "action hello {...}\naction ello {...}\naction ello2 {...}\nmain := /[Hh]ello/ % hello |\n /.+ello/ % ello |\n any{0,20} \"ello\" % ello2 ;\n action hello action ello action ello2"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13820/"
] |
192,960
|
<p>I have a TListBox with multiselect and ExtendedSelect both set to true. I need to be able to drag multiple items in the list box to re-arrange them. My problem is what happens when the user clicks on an item that is already selected without holding down the CTRL or SHIFT key.</p>
<p>Case 1: DragMode is set to dmManual
The selection is cleared before the mouse down. This will not allow multiple items to be dragged.</p>
<p>Case 2: DragMode is set to dmAutomatic
The MouseDown event never fires. The selection is not cleared so dragging is OK, but the user cannot clear the selection by clicking on one of the selected items. This really causes a problem if all the items are selected or the next item the user wants to select was part of the current selection.</p>
<p>Note that this problem only happens if you assign something to the DragObject in the OnStartDrag procedure. I think the problem would go away if OnStartDrag would only start after the user moves the mouse. I have Mouse.DragImmediate := false set but I still get the StartDrag fired as soon as I click on an item in the list box.</p>
<p>I am using Delphi 7 for this project but I see the same behavior in Delphi 2007.</p>
|
[
{
"answer_id": 192995,
"author": "Markus Jarderot",
"author_id": 22364,
"author_profile": "https://Stackoverflow.com/users/22364",
"pm_score": 2,
"selected": false,
"text": "(?=(regex1)?)(?=(regex2)?)(?=(regex3)?)...(?=(regex20)?)\n undefined None null"
},
{
"answer_id": 193027,
"author": "EfForEffort",
"author_id": 14113,
"author_profile": "https://Stackoverflow.com/users/14113",
"pm_score": 2,
"selected": false,
"text": "(r1)|(r2)|(r3)|...|(r10000)\n"
},
{
"answer_id": 1361359,
"author": "RCIX",
"author_id": 117069,
"author_profile": "https://Stackoverflow.com/users/117069",
"pm_score": -1,
"selected": false,
"text": "public static List<Regex> FindAllMatches(string s, List<Regex> regexes)\n{\n List<Regex> matches = new List<Regex>();\n foreach (Regex r in regexes)\n {\n if (r.IsMatch(string))\n {\n matches.Add(r);\n }\n }\n return matches;\n}\n"
},
{
"answer_id": 47319512,
"author": "Glen Thompson",
"author_id": 3866246,
"author_profile": "https://Stackoverflow.com/users/3866246",
"pm_score": 3,
"selected": false,
"text": "'cat' r'\\w+' import ahocorasick\nA = ahocorasick.Automaton()\n\npatterns = [\n [['cat','dog'],'mammals'],\n [['bass','tuna','trout'],'fish'],\n [['toad','crocodile'],'amphibians'],\n]\n\nfor row in patterns:\n vals = row[0]\n for val in vals:\n A.add_word(val, (row[1], val))\n\nA.make_automaton()\n\n_string = 'tom loves lions tigers cats and bass'\n\ndef test():\n vals = []\n for item in A.iter(_string):\n vals.append(item)\n return vals\n %timeit test() _string 100,000 2.09 ms 631 ms re.search()"
},
{
"answer_id": 49358587,
"author": "hroptatyr",
"author_id": 107375,
"author_profile": "https://Stackoverflow.com/users/107375",
"pm_score": 0,
"selected": false,
"text": "action hello {...}\naction ello {...}\naction ello2 {...}\nmain := /[Hh]ello/ % hello |\n /.+ello/ % ello |\n any{0,20} \"ello\" % ello2 ;\n action hello action ello action ello2"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6174/"
] |
192,976
|
<p>I have a similar problem to <a href="https://stackoverflow.com/questions/174535/google-maps-overlays">this post</a>. I need to display up to 1000 polygons on an embedded Google map. The polygons are in a SQL database, and I can render each one as a single KML file on the fly using a custom HttpHandler (in ASP.NET), like this <a href="http://alpha.foresttransparency.org/concession.1.kml" rel="nofollow noreferrer">http://alpha.foresttransparency.org/concession.1.kml</a> . </p>
<p>Even on my (very fast) development machine, it takes a while to load up even a couple dozen shapes. So two questions, really:</p>
<ol>
<li><p>What would be a good strategy for rendering these as markers instead of overlays once I'm beyond a certain zoom level?</p></li>
<li><p>Is there a publicly available algorithm for simplifying a polygon (reducing the number of points) so that I'm not showing more points than make sense at a certain zoom level?</p></li>
</ol>
|
[
{
"answer_id": 228776,
"author": "Daniel Beardsley",
"author_id": 13216,
"author_profile": "https://Stackoverflow.com/users/13216",
"pm_score": 0,
"selected": false,
"text": "P[0..n] T[n] P[n-1], P[n], P[n+1] Max T[1..n-1] T[i] P[i] T[n-1], T[n+1] Max"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/239663/"
] |
192,978
|
<p>I am working on a process to allow people to upload PDF files and manage the document (page order) via a web based interface.</p>
<p>The pages of the PDF file need to be cropped to a particular size for printing and currently we run them through a Photoshop action that takes care of this.</p>
<p>What I want to do is upload the PDF files to a dedicated server for performing the desired process (photoshop action, convert, send images back to web server).</p>
<p>What are some good ways to perform the functions, but sending updates to the webserver to allow for process tracking/progress bars to keep the user informed on how long their files are taking to process.</p>
<p>Additionally what are some good techniques for queueing/tracking jobs/processes in general (with an emphasis on web based technologies)?</p>
|
[
{
"answer_id": 228776,
"author": "Daniel Beardsley",
"author_id": 13216,
"author_profile": "https://Stackoverflow.com/users/13216",
"pm_score": 0,
"selected": false,
"text": "P[0..n] T[n] P[n-1], P[n], P[n+1] Max T[1..n-1] T[i] P[i] T[n-1], T[n+1] Max"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
192,980
|
<p>I've recently created these two (unrelated) methods to replace lots of boiler-plate code in my winforms application. As far as I can tell, they work ok, but I need some reassurance/advice on whether there are some problems I might be missing.</p>
<p>(from memory)</p>
<pre><code>static class SafeInvoker
{
//Utility to avoid boiler-plate InvokeRequired code
//Usage: SafeInvoker.Invoke(myCtrl, () => myCtrl.Enabled = false);
public static void Invoke(Control ctrl, Action cmd)
{
if (ctrl.InvokeRequired)
ctrl.BeginInvoke(new MethodInvoker(cmd));
else
cmd();
}
//Replaces OnMyEventRaised boiler-plate code
//Usage: SafeInvoker.RaiseEvent(this, MyEventRaised)
public static void RaiseEvent(object sender, EventHandler evnt)
{
var handler = evnt;
if (handler != null)
handler(sender, EventArgs.Empty);
}
}
</code></pre>
<p>EDIT: See related question <a href="https://stackoverflow.com/questions/258409/how-to-get-information-about-an-exception-raised-by-the-target-of-controlinvoke">here</a></p>
<p><strong>UPDATE</strong></p>
<p>Following on from deadlock problems (related in <a href="https://stackoverflow.com/questions/2055960/control-invoke-getting-stuck-in-hidden-showdialog">this question</a>), I have switched from Invoke to BeginInvoke (see an explanation <a href="https://stackoverflow.com/questions/229554/whats-the-difference-between-invoke-and-begininvoke/229558#229558">here</a>).</p>
<p><strong>Another Update</strong></p>
<p>Regarding the second snippet, I am increasingly inclined to use the 'empty delegate' pattern, which fixes this problem 'at source' by declaring the event directly with an empty handler, like so:</p>
<pre><code>event EventHandler MyEventRaised = delegate {};
</code></pre>
|
[
{
"answer_id": 193038,
"author": "programmer",
"author_id": 5289,
"author_profile": "https://Stackoverflow.com/users/5289",
"pm_score": 5,
"selected": true,
"text": "//Replaces OnMyEventRaised boiler-plate code\n//Usage: SafeInvoker.RaiseEvent(this, MyEventRaised)\npublic static void Raise(this EventHandler eventToRaise, object sender)\n{\n EventHandler eventHandler = eventToRaise;\n\n if (eventHandler != null)\n eventHandler(sender, EventArgs.Empty);\n}\n"
},
{
"answer_id": 2057360,
"author": "Oliver",
"author_id": 1838048,
"author_profile": "https://Stackoverflow.com/users/1838048",
"pm_score": 2,
"selected": false,
"text": "static class SafeInvoker\n{\n //Utility to avoid boiler-plate InvokeRequired code\n //Usage: myCtrl.SafeInvoke(() => myCtrl.Enabled = false);\n public static void SafeInvoke(this Control ctrl, Action cmd)\n {\n if (ctrl.InvokeRequired)\n ctrl.BeginInvoke(cmd);\n else\n cmd();\n }\n\n //Replaces OnMyEventRaised boiler-plate code\n //Usage: this.RaiseEvent(myEventRaised);\n public static void RaiseEvent(this object sender, EventHandler evnt)\n {\n if (evnt != null)\n evnt(sender, EventArgs.Empty);\n }\n}\n MethodInvoker Action MethodInvoker Action(T) Action(T) Action MethodInvoker Action Action(T1, T2, T3, T4) Func Action MethodInvoker"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410/"
] |
192,985
|
<p>I have a class which extends <code>DefaultTableCellRenderer</code>, which renders strings in a monospace font, with a particular color. By default, it appears that tabs are not rendered at all (0 spaces). How can I set the tab size and/or cause them to be rendered?</p>
<p><strong>edits:</strong>
By "tabs" I mean tab characters, which I would just like to be rendered as some number of spaces. Rewriting the string is an option, but I figured there was a better way.</p>
|
[
{
"answer_id": 193287,
"author": "Tom Hawtin - tackline",
"author_id": 4725,
"author_profile": "https://Stackoverflow.com/users/4725",
"pm_score": 2,
"selected": false,
"text": "DefaultTableCellRenderer JLabel JLabel TableCellRenderer JPanel JLabel JComponent paintComponent"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26960/"
] |
192,998
|
<p>I have some custom SharePoint site definitions that are deployed via SharePoint wsp solution packages. They appear to work fine. I can deploy them fine via the stsadm command line, and my C# code running in some features can also deploy sites based on them. My <code>webtemp.*.xml</code> files appear to be correctly placed in the <code>12\1033\XML</code> folder when my solutions are deployed. My problem is that they just don't show up in the central admin app when I try to <code>Create Site Collection.</code> Why not? I don't even know where to look for this.</p>
<hr>
<p><strong>EDIT:</strong></p>
<p>Hmmm.. About an hour later I happened to go back to the create site collection page and my templates were there. I'm not sure what was up... weird caching somewhere or something. </p>
<p>I also should have been more clear that these solution packages had been successfully deployed many times on my dev box, so I didn't expect there to be a problem (with the deployment aspect anyway) on this other server.</p>
|
[
{
"answer_id": 815391,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "stsadm -o execadmsvcjobs\n"
},
{
"answer_id": 9710852,
"author": "Jason S",
"author_id": 691965,
"author_profile": "https://Stackoverflow.com/users/691965",
"pm_score": 0,
"selected": false,
"text": "$site = get-spsite(\"http://localhost\")\n$web = $site.RootWeb\n$list = $web.Lists[\"TestDocLibrary\"]\n$list.SaveAsTemplate(\"MyListTemplate.stp\", \"MyListTemplate\", \"My List Template\", $false)\n$site.GetCustomListTemplates($web).Count\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/192998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/404/"
] |
193,020
|
<p>If I define a constant in a Perl module, how do I use that constant in my main program? (Or how do I call that constant in the main program?)</p>
|
[
{
"answer_id": 193031,
"author": "friedo",
"author_id": 20745,
"author_profile": "https://Stackoverflow.com/users/20745",
"pm_score": 6,
"selected": false,
"text": "package Foo;\nuse strict;\nuse warnings;\n\nuse base 'Exporter';\n\nuse constant CONST => 42;\n\nour @EXPORT_OK = ('CONST');\n\n1;\n use Foo 'CONST';\nprint CONST;\n %EXPORT_TAGS %EXPORT_TAGS use constant LARRY => 42;\nuse constant CURLY => 43;\nuse constant MOE => 44;\n\nour @EXPORT_OK = ('LARRY', 'CURLY', 'MOE');\nour %EXPORT_TAGS = ( stooges => [ 'LARRY', 'CURLY', 'MOE' ] );\n use Foo ':stooges';\nprint \"$_\\n\" for LARRY, CURLY, MOE;\n"
},
{
"answer_id": 193037,
"author": "moritz",
"author_id": 14132,
"author_profile": "https://Stackoverflow.com/users/14132",
"pm_score": 5,
"selected": false,
"text": "# file Foo.pm\npackage Foo;\nuse constant BAR => 123;\nuse Exporter qw(import);\nour @EXPORT_OK = qw(BAR);\n\n\n# file main.pl:\nuse Foo qw(BAR);\nprint BAR;\n"
},
{
"answer_id": 193069,
"author": "Tanktalus",
"author_id": 23512,
"author_profile": "https://Stackoverflow.com/users/23512",
"pm_score": 5,
"selected": false,
"text": "use Foo;\nprint Foo::BAR;\n"
},
{
"answer_id": 195946,
"author": "maletin",
"author_id": 27239,
"author_profile": "https://Stackoverflow.com/users/27239",
"pm_score": 3,
"selected": false,
"text": "package Foo;\nuse Readonly;\nReadonly my $C1 => 'const1';\nReadonly our $C2 => 'const2';\nsub get_c1 { return $C1 }\n1;\n\nperl -MFoo -e 'print \"$_\\n\" for Foo->get_c1, $Foo::C2'\n"
},
{
"answer_id": 214795,
"author": "Schwern",
"author_id": 14660,
"author_profile": "https://Stackoverflow.com/users/14660",
"pm_score": 3,
"selected": false,
"text": "package Foo;\nuse constant PI => 3.14;\n\nprint Foo->PI;\n Foo::PI PI Foo->PI"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26964/"
] |
193,044
|
<p>Languages like C and even C# (which technically doesn't have a preprocessor) allow you to write code like:</p>
<pre><code>#DEFINE DEBUG
...
string returnedStr = this.SomeFoo();
#if DEBUG
Debug.WriteLine("returned string =" + returnedStr);
#endif
</code></pre>
<p>This is something I like to use in my code as a form of scaffolding, and I'm wondering if PHP has something like this. I'm sure I can emulate this with variables, but I imagine the fact that PHP is interpreted in most cases will not make it easy to strip/remove the debugging code (since its not needed) automatically when executing it.</p>
|
[
{
"answer_id": 193072,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 4,
"selected": true,
"text": "define('DEBUG', true);\n...\nif (DEBUG):\n $debug->writeLine(\"stuff\");\nendif;\n $str = 'string';\nDEBUG ? $debug->writeLine(\"stuff is \".$str) : null;\n"
},
{
"answer_id": 193097,
"author": "douglashunter",
"author_id": 13838,
"author_profile": "https://Stackoverflow.com/users/13838",
"pm_score": 0,
"selected": false,
"text": "define define"
},
{
"answer_id": 193099,
"author": "Jayrox",
"author_id": 24802,
"author_profile": "https://Stackoverflow.com/users/24802",
"pm_score": 1,
"selected": false,
"text": "define(DEBUG, true);\n\n[...]\n\nif(DEBUG) echo xdump::dump($debugOut);\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10708/"
] |
193,077
|
<p>How can I distribute a standalone Python application in Linux?</p>
<p>I think I can take for granted the presence of a recent Python interpreter in any modern distribution. The problem is dealing with those libraries that do not belong to the standard library, i.e. wxPython, scipy, python cryptographic toolkit, reportlab, and so on.</p>
<p>Is there a working Linux counterpart to, say, py2exe (which, by the way, I have never tried)?
Is there a free, opensource one?</p>
|
[
{
"answer_id": 195770,
"author": "HUAGHAGUAH",
"author_id": 27233,
"author_profile": "https://Stackoverflow.com/users/27233",
"pm_score": 3,
"selected": false,
"text": "# program startup code\nimport os\nimport sys\nimport site\npath = os.path.abspath(os.path.dirname(__file__))\nver = 'python%d.%d' % sys.version_info[:2]\nthirdparty = os.path.join(path, 'third-party', 'lib', ver, 'site-packages')\nsite.addsitedir(thirdparty)\n # sample third-party/Makefile\nPYTHON_VER = `python -c \"import sys; \\\n print 'python%d.%d' % sys.version_info[:2]\"`\nPYTHON_PATH = lib/$(PYTHON_VER)/site-packages\nMODS = egenix-mx-base-3.0.0 # etc\n\n.PHONY: all init clean realclean $(MODS)\nall: $(MODS)\n$(MODS): init\ninit:\n mkdir -p bin\n mkdir -p $(PYTHON_PATH)\nclean:\n rm -rf $(MODS)\nrealclean: clean\n rm -rf bin\n rm -rf lib\n\negenix-mx-base-3.0.0:\n tar xzf $@.tar.gz\n cd $@ && python setup.py install --prefix=..\n rm -rf $@\n"
},
{
"answer_id": 2013022,
"author": "ternaryOperator",
"author_id": 244358,
"author_profile": "https://Stackoverflow.com/users/244358",
"pm_score": -1,
"selected": false,
"text": "#!/bin/bash\nif [ -e /usr/bin/python ]\nthen\n echo \"Python found!\"\nelse\n echo \"Python missing!\"\nfi\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18770/"
] |
193,080
|
<p>I really want to put in some sort of section handler into App.config that will execute some code before the application actually starts executing at Main. Is there any way to do such a thing?</p>
|
[
{
"answer_id": 193131,
"author": "Ricardo Villamil",
"author_id": 19314,
"author_profile": "https://Stackoverflow.com/users/19314",
"pm_score": 2,
"selected": false,
"text": "static void Main(string[] args)\n{\n //read your app.config variable\n callAlternate = GetConfigSettings(); \n if(callAlternate)\n AltMain();\n\n ///...rest of Main()\n}\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14101/"
] |
193,092
|
<p>I am just starting to fiddle with Excel via C# to be able to automate the creation, and addition to an Excel file.</p>
<p>I can open the file and update its data and move through the existing worksheets. My problem is how can I add new sheets?</p>
<p>I tried:</p>
<pre><code>Excel.Worksheet newWorksheet;
newWorksheet = (Excel.Worksheet)excelApp.ThisWorkbook.Worksheets.Add(
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
</code></pre>
<p>But I get below <em>COM Exception</em> and my googling has not given me any answer.</p>
<blockquote>
<p>Exception from HRESULT: 0x800A03EC Source is: "Interop.Excel"</p>
</blockquote>
<p>I am hoping someone maybe able to put me out of my misery.</p>
|
[
{
"answer_id": 193323,
"author": "AR.",
"author_id": 1354,
"author_profile": "https://Stackoverflow.com/users/1354",
"pm_score": 6,
"selected": true,
"text": "Microsoft Excel 11.0 Object Library private void AddWorksheetToExcelWorkbook(string fullFilename,string worksheetName)\n{\n Microsoft.Office.Interop.Excel.Application xlApp = null;\n Workbook xlWorkbook = null;\n Sheets xlSheets = null;\n Worksheet xlNewSheet = null;\n\n try {\n xlApp = new Microsoft.Office.Interop.Excel.Application();\n\n if (xlApp == null)\n return;\n\n // Uncomment the line below if you want to see what's happening in Excel\n // xlApp.Visible = true;\n\n xlWorkbook = xlApp.Workbooks.Open(fullFilename, 0, false, 5, \"\", \"\",\n false, XlPlatform.xlWindows, \"\",\n true, false, 0, true, false, false);\n\n xlSheets = xlWorkbook.Sheets as Sheets;\n\n // The first argument below inserts the new worksheet as the first one\n xlNewSheet = (Worksheet)xlSheets.Add(xlSheets[1], Type.Missing, Type.Missing, Type.Missing);\n xlNewSheet.Name = worksheetName;\n\n xlWorkbook.Save();\n xlWorkbook.Close(Type.Missing,Type.Missing,Type.Missing);\n xlApp.Quit();\n }\n finally {\n Marshal.ReleaseComObject(xlNewSheet);\n Marshal.ReleaseComObject(xlSheets);\n Marshal.ReleaseComObject(xlWorkbook);\n Marshal.ReleaseComObject(xlApp);\n xlApp = null;\n }\n}\n"
},
{
"answer_id": 193856,
"author": "Jon",
"author_id": 6486,
"author_profile": "https://Stackoverflow.com/users/6486",
"pm_score": 3,
"selected": false,
"text": "Excel.exe using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Reflection;\nusing System.IO;\nusing Excel;\n\nnamespace testExcelconsoleApp\n{\n class Program\n {\n private String fileLoc = @\"C:\\temp\\test.xls\";\n\n static void Main(string[] args)\n {\n Program p = new Program();\n p.createExcel();\n }\n\n private void createExcel()\n {\n Excel.Application excelApp = null;\n Excel.Workbook workbook = null;\n Excel.Sheets sheets = null;\n Excel.Worksheet newSheet = null;\n\n try\n {\n FileInfo file = new FileInfo(fileLoc);\n if (file.Exists)\n {\n excelApp = new Excel.Application();\n workbook = excelApp.Workbooks.Open(fileLoc, 0, false, 5, \"\", \"\",\n false, XlPlatform.xlWindows, \"\",\n true, false, 0, true, false, false);\n\n sheets = workbook.Sheets;\n\n //check columns exist\n foreach (Excel.Worksheet sheet in sheets)\n {\n Console.WriteLine(sheet.Name);\n sheet.Select(Type.Missing);\n\n System.Runtime.InteropServices.Marshal.ReleaseComObject(sheet);\n }\n\n newSheet = (Worksheet)sheets.Add(sheets[1], Type.Missing, Type.Missing, Type.Missing);\n newSheet.Name = \"My New Sheet\";\n newSheet.Cells[1, 1] = \"BOO!\";\n\n workbook.Save();\n workbook.Close(null, null, null);\n excelApp.Quit();\n }\n }\n finally\n {\n System.Runtime.InteropServices.Marshal.ReleaseComObject(newSheet);\n System.Runtime.InteropServices.Marshal.ReleaseComObject(sheets);\n System.Runtime.InteropServices.Marshal.ReleaseComObject(workbook);\n System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);\n\n newSheet = null;\n sheets = null;\n workbook = null;\n excelApp = null;\n\n GC.Collect();\n }\n }\n }\n}\n"
},
{
"answer_id": 2111540,
"author": "hmm",
"author_id": 256043,
"author_profile": "https://Stackoverflow.com/users/256043",
"pm_score": 0,
"selected": false,
"text": "xlsheet1 xlsheet2 excel.workbooks xlBook = xlBooks.Add(\"C:\\location\\XlTemplate.xls\")"
},
{
"answer_id": 9959997,
"author": "Gokul",
"author_id": 1305548,
"author_profile": "https://Stackoverflow.com/users/1305548",
"pm_score": 1,
"selected": false,
"text": "Microsoft Excel 12.0/11.0 object Library using Excel = Microsoft.Office.Interop.Excel;\n// Include this Namespace\n Microsoft.Office.Interop.Excel.Application xlApp = null;\nExcel.Workbook xlWorkbook = null;\nExcel.Sheets xlSheets = null;\nExcel.Worksheet xlNewSheet = null;\nstring worksheetName =\"Sheet_Name\";\nobject readOnly1 = false;\n\nobject isVisible = true;\n\nobject missing = System.Reflection.Missing.Value;\n\ntry\n{\n xlApp = new Microsoft.Office.Interop.Excel.Application();\n\n if (xlApp == null)\n return;\n\n // Uncomment the line below if you want to see what's happening in Excel\n // xlApp.Visible = true;\n\n xlWorkbook = xlApp.Workbooks.Open(@\"C:\\Book1.xls\", missing, readOnly1, missing, missing, missing, missing, missing, missing, missing, missing, isVisible, missing, missing, missing);\n\n xlSheets = (Excel.Sheets)xlWorkbook.Sheets;\n\n // The first argument below inserts the new worksheet as the first one\n xlNewSheet = (Excel.Worksheet)xlSheets.Add(xlSheets[1], Type.Missing, Type.Missing, Type.Missing);\n xlNewSheet.Name = worksheetName;\n\n xlWorkbook.Save();\n xlWorkbook.Close(Type.Missing, Type.Missing, Type.Missing);\n xlApp.Quit();\n}\nfinally\n{\n System.Runtime.InteropServices.Marshal.ReleaseComObject(xlNewSheet);\n System.Runtime.InteropServices.Marshal.ReleaseComObject(xlSheets);\n System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWorkbook);\n System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp);\n //xlApp = null;\n}\n"
},
{
"answer_id": 20488719,
"author": "Dobermaxx99",
"author_id": 1631890,
"author_profile": "https://Stackoverflow.com/users/1631890",
"pm_score": 0,
"selected": false,
"text": "Workbook workbook = null;\nWorksheet worksheet = null;\n\nworkbook = app.Workbooks.Add(1);\nworkbook.Sheets.Add();\n\nWorksheet additionalWorksheet = workbook.ActiveSheet;\n"
},
{
"answer_id": 26180388,
"author": "Jiri Tersel",
"author_id": 2660867,
"author_profile": "https://Stackoverflow.com/users/2660867",
"pm_score": 0,
"selected": false,
"text": "Excel.Worksheet newSheetException = Globals.ThisAddIn.Application.ThisWorkbook.Worksheets.Add(Type.Missing, sheet, Type.Missing, Type.Missing);\nExcel.Worksheet newSheetNoException = Globals.ThisAddIn.Application.ActiveWorkbook.Worksheets.Add(Type.Missing, sheet, Type.Missing, Type.Missing);\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6486/"
] |
193,107
|
<p>I am using Oracle SQL (in SQLDeveloper, using the SQL Worksheet). I would like to print a statement before my select, such as</p>
<pre><code>PRINT 'Querying Table1';
SELECT * from Table1;
</code></pre>
<p>What do I use to Print / show text output? It's not Print, because that gives me the error: Bind Variable <code>Table1</code> is NOT DECLARED. DBMS_OUTPUT.PUT_LINE is an unknown command. (Obviously, I'm an inexperienced SQLDeveloper and Oracle user. There must be some synonym for Print, but I'm having trouble finding help on it without knowing what it is.)</p>
|
[
{
"answer_id": 193158,
"author": "Eddie Awad",
"author_id": 17273,
"author_profile": "https://Stackoverflow.com/users/17273",
"pm_score": 4,
"selected": false,
"text": "set echo on\nREM Querying table\nselect * from dual;\n"
},
{
"answer_id": 195000,
"author": "Leigh Riffel",
"author_id": 27010,
"author_profile": "https://Stackoverflow.com/users/27010",
"pm_score": 4,
"selected": false,
"text": "SELECT 'Querying Table1' FROM dual;\n"
},
{
"answer_id": 360029,
"author": "Perry Tribolet",
"author_id": 5668,
"author_profile": "https://Stackoverflow.com/users/5668",
"pm_score": 8,
"selected": true,
"text": "set serveroutput on format wrapped;\nbegin\n DBMS_OUTPUT.put_line('simple comment');\nend;\n/\n\n-- do something\n\nbegin\n DBMS_OUTPUT.put_line('second simple comment');\nend;\n/\n anonymous block completed\nsimple comment\n\nanonymous block completed\nsecond simple comment\n set serveroutput on format wrapped;\ndeclare\na_comment VARCHAR2(200) :='first comment';\nbegin\n DBMS_OUTPUT.put_line(a_comment);\nend;\n\n/\n\n-- do something\n\n\ndeclare\na_comment VARCHAR2(200) :='comment';\nbegin\n DBMS_OUTPUT.put_line(a_comment || 2);\nend;\n anonymous block completed\nfirst comment\n\nanonymous block completed\ncomment2\n"
},
{
"answer_id": 4084876,
"author": "H77",
"author_id": 489884,
"author_profile": "https://Stackoverflow.com/users/489884",
"pm_score": 6,
"selected": false,
"text": "PROMPT text to print\n"
},
{
"answer_id": 5170303,
"author": "Michael Erickson",
"author_id": 591312,
"author_profile": "https://Stackoverflow.com/users/591312",
"pm_score": 3,
"selected": false,
"text": "set serveroutput on format word_wrapped;\n"
},
{
"answer_id": 54714471,
"author": "ΩmegaMan",
"author_id": 285795,
"author_profile": "https://Stackoverflow.com/users/285795",
"pm_score": 4,
"selected": false,
"text": "dbms_output.put_line('Start');\n set serveroutput on format wrapped;\nbegin\n DBMS_OUTPUT.put_line('jabberwocky');\nend;\n"
},
{
"answer_id": 61905399,
"author": "FrenkyB",
"author_id": 867703,
"author_profile": "https://Stackoverflow.com/users/867703",
"pm_score": 2,
"selected": false,
"text": "set serveroutput on;\nbegin\nDBMS_OUTPUT.PUT_LINE('testing');\nend;\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22523/"
] |
193,119
|
<p>I need to have my iPhone Objective-C code catch Javascript errors in a UIWebView. That includes uncaught exceptions, syntax errors when loading files, undefined variable references, etc.</p>
<p>This is for a development environment, so it doesn't need to be SDK-kosher. In fact, it only really needs to work on the simulator.</p>
<p>I've already found used some of the hidden WebKit tricks to e.g. expose Obj-C objects to JS and to intercept alert popups, but this one is still eluding me.</p>
<p>[NOTE: after posting this I did find one way using a debugging delegate. Is there a way with lower overhead, using the error console / web inspector?]</p>
|
[
{
"answer_id": 193212,
"author": "kdbdallas",
"author_id": 26728,
"author_profile": "https://Stackoverflow.com/users/26728",
"pm_score": 0,
"selected": false,
"text": "// Dismiss Javascript alerts and telephone confirms\n/*- (void)alertSheet:(UIAlertSheet*)sheet buttonClicked:(int)button\n{\n if (button == 1)\n {\n [sheet setContext: nil];\n }\n\n [sheet dismiss];\n}*/\n\n// Javascript errors and logs\n- (void) webView: (WebView*)webView addMessageToConsole: (NSDictionary*)dictionary\n{\n NSLog(@\"Javascript log: %@\", dictionary);\n}\n\n// Javascript alerts\n- (void) webView: (WebView*)webView runJavaScriptAlertPanelWithMessage: (NSString*) message initiatedByFrame: (WebFrame*) frame\n{\n NSLog(@\"Javascript Alert: %@\", message);\n\n UIAlertSheet *alertSheet = [[UIAlertSheet alloc] init];\n [alertSheet setTitle: @\"Javascript Alert\"];\n [alertSheet addButtonWithTitle: @\"OK\"];\n [alertSheet setBodyText:message];\n [alertSheet setDelegate: self];\n [alertSheet setContext: self];\n [alertSheet popupAlertAnimated:YES];\n}\n"
},
{
"answer_id": 193282,
"author": "Robert Sanders",
"author_id": 16952,
"author_profile": "https://Stackoverflow.com/users/16952",
"pm_score": 5,
"selected": false,
"text": "- (void)webView:(id)webView windowScriptObjectAvailable:(id)newWindowScriptObject {\n // save these goodies\n windowScriptObject = newWindowScriptObject;\n privateWebView = webView;\n\n if (scriptDebuggingEnabled) {\n [webView setScriptDebugDelegate:[[YourScriptDebugDelegate alloc] init]];\n }\n}\n // in YourScriptDebugDelegate\n\n- (void)webView:(WebView *)webView didParseSource:(NSString *)source\n baseLineNumber:(unsigned)lineNumber\n fromURL:(NSURL *)url\n sourceId:(int)sid\n forWebFrame:(WebFrame *)webFrame\n{\n NSLog(@\"NSDD: called didParseSource: sid=%d, url=%@\", sid, url);\n}\n\n// some source failed to parse\n- (void)webView:(WebView *)webView failedToParseSource:(NSString *)source\n baseLineNumber:(unsigned)lineNumber\n fromURL:(NSURL *)url\n withError:(NSError *)error\n forWebFrame:(WebFrame *)webFrame\n{\n NSLog(@\"NSDD: called failedToParseSource: url=%@ line=%d error=%@\\nsource=%@\", url, lineNumber, error, source);\n}\n\n- (void)webView:(WebView *)webView exceptionWasRaised:(WebScriptCallFrame *)frame\n sourceId:(int)sid\n line:(int)lineno\n forWebFrame:(WebFrame *)webFrame\n{\n NSLog(@\"NSDD: exception: sid=%d line=%d function=%@, caller=%@, exception=%@\", \n sid, lineno, [frame functionName], [frame caller], [frame exception]);\n}\n // just entered a stack frame (i.e. called a function, or started global scope)\n- (void)webView:(WebView *)webView didEnterCallFrame:(WebScriptCallFrame *)frame\n sourceId:(int)sid\n line:(int)lineno\n forWebFrame:(WebFrame *)webFrame;\n\n// about to execute some code\n- (void)webView:(WebView *)webView willExecuteStatement:(WebScriptCallFrame *)frame\n sourceId:(int)sid\n line:(int)lineno\n forWebFrame:(WebFrame *)webFrame;\n\n// about to leave a stack frame (i.e. return from a function)\n- (void)webView:(WebView *)webView willLeaveCallFrame:(WebScriptCallFrame *)frame\n sourceId:(int)sid\n line:(int)lineno\n forWebFrame:(WebFrame *)webFrame;\n"
},
{
"answer_id": 774573,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "try{\n//put your code here\n}\ncatch(err){\n logError(err);\n}\n"
},
{
"answer_id": 4108206,
"author": "Krešimir Prcela",
"author_id": 475978,
"author_profile": "https://Stackoverflow.com/users/475978",
"pm_score": 4,
"selected": false,
"text": "@class WebView; @class WebFrame; @class WebScriptCallFrame; - (void)webView:(id)webView windowScriptObjectAvailable:(id)newWindowScriptObject \n - (void)webView:(id)sender didClearWindowObject:(id)windowObject forFrame:(WebFrame*)frame\n"
},
{
"answer_id": 7694244,
"author": "psy",
"author_id": 195090,
"author_profile": "https://Stackoverflow.com/users/195090",
"pm_score": 3,
"selected": false,
"text": "#ifdef DEBUG\n@interface DebugWebDelegate : NSObject\n@end\n@implementation DebugWebDelegate\n@class WebView;\n@class WebScriptCallFrame;\n@class WebFrame;\n- (void)webView:(WebView *)webView exceptionWasRaised:(WebScriptCallFrame *)frame\n sourceId:(int)sid\n line:(int)lineno\n forWebFrame:(WebFrame *)webFrame\n{\n NSLog(@\"NSDD: exception: sid=%d line=%d function=%@, caller=%@, exception=%@\", \n sid, lineno, [frame functionName], [frame caller], [frame exception]);\n}\n@end\n@interface DebugWebView : UIWebView\nid windowScriptObject;\nid privateWebView;\n@end\n@implementation DebugWebView\n- (void)webView:(id)sender didClearWindowObject:(id)windowObject forFrame:(WebFrame*)frame\n{\n [sender setScriptDebugDelegate:[[DebugWebDelegate alloc] init]];\n}\n@end\n#endif\n #ifdef DEBUG\n myWebview = [[DebugWebView alloc] initWithFrame:frame];\n#else\n myWebview = [[UIWebView alloc] initWithFrame:frame];\n#endif\n"
},
{
"answer_id": 28664004,
"author": "Yoav Zibin",
"author_id": 2304593,
"author_profile": "https://Stackoverflow.com/users/2304593",
"pm_score": 0,
"selected": false,
"text": "[context setExceptionHandler:^(JSContext *context, JSValue *value) {\n NSLog(@\"%@\", value);\n}];\n"
},
{
"answer_id": 43383129,
"author": "Patrick",
"author_id": 689568,
"author_profile": "https://Stackoverflow.com/users/689568",
"pm_score": 0,
"selected": false,
"text": " window.originConsoleError = console.error;\n console.error = (msg) => {\n window.originConsoleError(msg);\n bridge.callHandler(\"sendConsoleLogToNative\", {\n action:action,\n message:message\n }, null)\n };\n [self.bridge registerHandler:@\"sendConsoleLogToNative\" handler:^(id data, WVJBResponseCallback responseCallback) {\n NSString *action = data[@\"action\"];\n NSString *msg = data[@\"message\"];\n if (isStringValid(action)){\n if ([@\"console.error\" isEqualToString:action]){\n NSLog(@\"JS error :%@\",msg);\n }\n }\n}];\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16952/"
] |
193,124
|
<p>I have an ASPX page that creates an XMLDocument object from SQL data and then transforms it into another XML document (RSS feed) using an XSLT file with XPathNavigator and XslCompiledTransform. Occasionally the data will contain smart quotes (\u2019) which results in an error (Unable to translate Unicode character \u2019 at index 947 to specified code page). I'm not sure how all the encoding settings work, but is there a way to prevent this without having to check for these types of characters in all the data as I'm creating the XML attributes? </p>
<p>My XSLT file looks like this...</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="iso-8859-1"/>
</code></pre>
<p>I've tried changing the xsl:output encoding to utf-8 and utf-16 but still get the same problem. Any ideas? </p>
<p>Here's my code if that helps...</p>
<pre><code>XmlDocument xdoc = new XmlDocument();
XmlNode xnode = requests.XMLNode(xdoc, imageType, Request, promotionPageId, eventPageId);
xdoc.AppendChild(xnode);
Response.Clear();
Response.ContentType = "text/xml";
Response.AddHeader("Content-Type", "text/xml");
if (xsltFile != string.Empty)
{
XPathNavigator xnav = xdoc.CreateNavigator();
XslCompiledTransform xslTransform = new XslCompiledTransform();
xslTransform.Load(Server.MapPath(string.Format("~/xslt/{0}.xslt", xsltFile)));
xslTransform.OutputSettings.Encoding.
xslTransform.Transform(xnav, null, Response.OutputStream);
}
else
{
xdoc.Save(Response.OutputStream);
}
Response.End();
</code></pre>
|
[
{
"answer_id": 194525,
"author": "Robert Rossney",
"author_id": 19403,
"author_profile": "https://Stackoverflow.com/users/19403",
"pm_score": 1,
"selected": false,
"text": "ContentEncoding HttpResponse Encoding.UTF16"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
193,130
|
<p>I'd like to have a custom object attached to the application so I can preserve state in it between different html pages in adobe air. Is this possible?</p>
<hr>
<p>I was asking for a fullblown solution to store a custom js object in memory and persist it between pages loaded from the application sandbox, but this cannot be done unless I use iframes which is not very pleasant, since I have to add a lot of stuff to the bridge. Anoter way may be to do partial rendering of the page filled with html read from files, but this exposes a lot of unpleasant bugs + you cant write script tags in the dom dynamically. It's a crippled platform.</p>
|
[
{
"answer_id": 194276,
"author": "Dimitry",
"author_id": 27073,
"author_profile": "https://Stackoverflow.com/users/27073",
"pm_score": 1,
"selected": false,
"text": "//write an Object to a file\nprivate function writeObject():void {\n var object:Object = new Object();//create an object to store\n object.value = asObject.text; //set the text field value to the value property\n //create a file under the application storage folder\n var file:File = File.applicationStorageDirectory.resolvePath(\"myobject.file\");\n if (file.exists)\n file.deleteFile();\n var fileStream:FileStream = new FileStream(); //create a file stream\n fileStream.open(file, FileMode.WRITE);// and open the file for write\n fileStream.writeObject(object);//write the object to the file\n fileStream.close();\n}\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7883/"
] |
193,142
|
<p>I have a WPF app which snaps to screen edges (I just set the .Top or .Left of the window if you're within 20 pixels of the screen edge), but I recently added some code <a href="http://blogs.msdn.com/wpfsdk/archive/2008/09/08/custom-window-chrome-in-wpf.aspx" rel="noreferrer">provided by the WPF SDK Team</a> to "mess" with the window chrome, and although it's working great (<a href="http://huddledmasses.org/images/PoshConsole/NewLook_Aero.png" rel="noreferrer">screenshot</a>), it's causing the "snapto" to move the window unexpectedly (e.g.: it jumps to the left when it should be snapping straight down to the bottom)</p>
<p>I've narrowed it down to their handling of the WM_NCCALCSIZE ... which is really odd because they basically don't do anything, they just say they handle it, and return 0. </p>
<p>According to the documentation of WM_NCCALCSIZE, this should just result in the whole window being treated as client (having no non-client edge), but somehow it also means that whenever my snap-to code moves the window down to the bottom of the screen, it also moves left about 134 pixels ... (moving to the other edges has similar side effects) and as long as I hold the mouse to drag it, it flickers back and forth from where it's supposed to be. If I comment the WM_NCCALCSIZE handling out, the snap-to works the way it should (but the form doesn't look right).</p>
<p>I've tried everything I can thing of in the WM_NCCALCSIZE handler, but I can't stop it from jumping left ... and of course, WM_NCCALCSIZE only gets called when the window size changes, so I don't understand how it causes this in the first place! </p>
<p>P.S. If you want to actually see the code, it's already <a href="http://www.codeplex.com/PoshConsole/SourceControl/DirectoryView.aspx?SourcePath=%24%2fPoshConsole%2ftrunk&changeSetId=25220" rel="noreferrer">on CodePlex</a>, in two files, look for <a href="http://www.codeplex.com/PoshConsole/SourceControl/FileView.aspx?itemId=359235&changeSetId=25220" rel="noreferrer">_HandleNCCalcSize</a> and <a href="http://www.codeplex.com/PoshConsole/SourceControl/FileView.aspx?itemId=3029&changeSetId=25220" rel="noreferrer">OnWindowLocationChanged</a></p>
|
[
{
"answer_id": 260600,
"author": "Jaykul",
"author_id": 8718,
"author_profile": "https://Stackoverflow.com/users/8718",
"pm_score": 4,
"selected": true,
"text": "WM_NCCALCSIZE WM_MOVE WM_WINDOWPOSCHANGED WindowPositionChanged WM_NCCALCSIZE WM_NCCALCSIZE WM_MOVE WM_MOVE WM_NCCALCSIZE WM_WINDOWPOSCHANGING"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8718/"
] |
193,143
|
<p>I'm using MSTEST inside Visual Studio 2008. How can I have each unit test method in a certain test class act as if it were the first test to run so that all global state is reset before running each test? I do not want to explicitly clean up the world using TestInitialize, ClassInitialize, AssemblyInitialize, etc. For example:</p>
<pre><code>[TestClass]
public class MyClassTests
{
[TestMethod]
public void Test1()
{
// The "Instance" property creates a new instance of "SomeSingleton"
// if it hasn't been created before.
var i1 = SomeSingleton.Instance;
...
}
[TestMethod]
public void Test2()
{
// When I select "Test1" and "Test2" to run, I'd like Test2
// to have a new AppDomain feel so that the static variable inside
// of "SomeSingleton" is reset (it was previously set in Test1) on
// the call to ".Instance"
var i2 = SomeSingleton.Instance;
// some code
}
</code></pre>
<p>Although a <a href="https://stackoverflow.com/questions/154180/how-does-nunit-and-mstest-handle-tests-that-change-staticshared-variables">similar question</a> appeared on this topic, it only clarified that tests do not run in parallel. I realize that tests run serially, but there doesn't seem to be a way to explicitly force a new AppDomain for each method (or something equivalent to clear all state).</p>
<p>Ideally, I'd like to specify this behavior for only a small subset of my unit tests so that I don't have to pay the penalty of a new AppDomain creation for tests that don't care about global state (the vast majority of my tests).</p>
|
[
{
"answer_id": 198562,
"author": "Watson",
"author_id": 25807,
"author_profile": "https://Stackoverflow.com/users/25807",
"pm_score": 3,
"selected": false,
"text": "public static class SingletonHelper {\n public static void CleanDALFactory() \n {\n typeof(DalFactory)\n .GetField(\"_instance\",BindingFlags.Static | BindingFlags.NonPublic)\n .SetValue(null, null);\n }\n}\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1869/"
] |
193,151
|
<p>So the question is how to distribute/offload the media files from Wordpress posts across multiple domains. </p>
<p>The reasoning being to overcome this limitation:
"Most browser will only make 2 simultaneous requests to a server, so if you page requires 16 files they will be requested 2 at a time."</p>
<p>In relation to: <a href="http://codex.wordpress.org/WordPress_Optimization/Offloading" rel="nofollow noreferrer">http://codex.wordpress.org/WordPress_Optimization/Offloading</a></p>
<p>To further clarify:<br>
There are two plug ins for "offloading" that already do this. They are the SteadyOffloading Plugin and the Amazon S3 plugin.<br>
So is there a generic solution that anyone has come across. Where it will allow you to change the base URL of the media, it doesn't necessary have to upload that media to an external service/server.</p>
<p>Thanks</p>
|
[
{
"answer_id": 193447,
"author": "Jordan Ogren",
"author_id": 21888,
"author_profile": "https://Stackoverflow.com/users/21888",
"pm_score": 1,
"selected": false,
"text": "print(\"<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"<?php bloginfo('stylesheet_url'); ?>\" />\");\n print(\"<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"http://www.NEW_DOMAIN.com/theme/stylesheet.css\" />\");\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
193,154
|
<p>I am getting the following error when I try to call a stored procedure that contains a SELECT Statement:</p>
<blockquote>
<p>The operation is not valid for the state of the transaction</p>
</blockquote>
<p>Here is the structure of my calls:</p>
<pre><code>public void MyAddUpdateMethod()
{
using (TransactionScope Scope = new TransactionScope(TransactionScopeOption.RequiresNew))
{
using(SQLServer Sql = new SQLServer(this.m_connstring))
{
//do my first add update statement
//do my call to the select statement sp
bool DoesRecordExist = this.SelectStatementCall(id)
}
}
}
public bool SelectStatementCall(System.Guid id)
{
using(SQLServer Sql = new SQLServer(this.m_connstring)) //breaks on this line
{
//create parameters
//
}
}
</code></pre>
<p>Is the problem with me creating another connection to the same database within the transaction?</p>
|
[
{
"answer_id": 203394,
"author": "Michael Kniskern",
"author_id": 26327,
"author_profile": "https://Stackoverflow.com/users/26327",
"pm_score": 7,
"selected": true,
"text": "public void MyAddUpdateMethod()\n{\n using (TransactionScope Scope = new TransactionScope(TransactionScopeOption.RequiresNew))\n {\n using(SQLServer Sql = new SQLServer(this.m_connstring))\n {\n //do my first add update statement \n }\n\n //removed the method call from the first sql server using statement\n bool DoesRecordExist = this.SelectStatementCall(id)\n }\n}\n\npublic bool SelectStatementCall(System.Guid id)\n{\n using(SQLServer Sql = new SQLServer(this.m_connstring))\n {\n //create parameters\n }\n}\n"
},
{
"answer_id": 4313273,
"author": "Sharique",
"author_id": 68238,
"author_profile": "https://Stackoverflow.com/users/68238",
"pm_score": 4,
"selected": false,
"text": "TransactionOptions options = new TransactionOptions();\noptions.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;\noptions.Timeout = new TimeSpan(0, 15, 0);\nusing (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required,options))\n{\n sp1();\n sp2();\n ...\n\n}\n"
},
{
"answer_id": 9160763,
"author": "R. Schreurs",
"author_id": 456456,
"author_profile": "https://Stackoverflow.com/users/456456",
"pm_score": 4,
"selected": false,
"text": "<system.transactions> \n <machineSettings maxTimeout=\"00:05:00\" /> \n</system.transactions>\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26327/"
] |
193,155
|
<p>SQL Server (2005/2008)</p>
<p>Each of the below statements have the same result. Does anyone know if one outperforms the other?</p>
<pre><code>insert into SOMETABLE
values ('FieldOneValue','FieldTwoValue',3,4.55,'10/10/2008 16:42:00.000')
insert into SOMETABLE
select 'FieldOneValue','FieldTwoValue',3,4.55,'10/10/2008 16:42:00.000'
insert into SOMETALBE
Select
Field1 = 'FieldOneValue',
Field2 = 'FieldTwoValue',
Field3 = 3,
Field4 = 4.55,
Field5 = '10/10/2008 16:42:00.000'
</code></pre>
<p>Assuming of course that the data types match the table appropriately...</p>
|
[
{
"answer_id": 193164,
"author": "Aaron Smith",
"author_id": 12969,
"author_profile": "https://Stackoverflow.com/users/12969",
"pm_score": 0,
"selected": false,
"text": "INSERT into SOMETABLE\n(\nSELECT * FROM SOMEOTHERTABLE\n)\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7870/"
] |
193,161
|
<p>Imagine that you want to develop a non-trivial end-user desktop (not web) application in Python. What is the best way to structure the project's folder hierarchy?</p>
<p>Desirable features are ease of maintenance, IDE-friendliness, suitability for source control branching/merging, and easy generation of install packages.</p>
<p>In particular:</p>
<ol>
<li>Where do you put the source?</li>
<li>Where do you put application startup scripts?</li>
<li>Where do you put the IDE project cruft?</li>
<li>Where do you put the unit/acceptance tests?</li>
<li>Where do you put non-Python data such as config files?</li>
<li>Where do you put non-Python sources such as C++ for pyd/so binary extension modules?</li>
</ol>
|
[
{
"answer_id": 193181,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 10,
"selected": true,
"text": "/scripts /bin /tests /lib /doc /apidoc /src /src /lib /bin /src /foo /bar /baz quux /quux PYTHONPATH /path/to/quux/foo QUUX.foo /quux"
},
{
"answer_id": 193256,
"author": "Charles Duffy",
"author_id": 14122,
"author_profile": "https://Stackoverflow.com/users/14122",
"pm_score": 4,
"selected": false,
"text": "package_data com.yourcompany.yourproject com.yourcompany.utils src doc test package_data"
},
{
"answer_id": 3419951,
"author": "Adrian",
"author_id": 412514,
"author_profile": "https://Stackoverflow.com/users/412514",
"pm_score": 8,
"selected": false,
"text": "Twisted Twisted-2.5 Twisted/bin .py Twisted/twisted.py Twisted/twisted/ Twisted/twisted/__init__.py Twisted/twisted/internet.py Twisted/twisted/test/ Twisted/twisted/test/__init__.py Twisted/twisted/test/test_internet.py Twisted/README Twisted/setup.py src lib __init__.py __init__.py"
},
{
"answer_id": 5998845,
"author": "cmcginty",
"author_id": 64313,
"author_profile": "https://Stackoverflow.com/users/64313",
"pm_score": 8,
"selected": false,
"text": "Project/\n|-- bin/\n| |-- project\n|\n|-- project/\n| |-- test/\n| | |-- __init__.py\n| | |-- test_main.py\n| | \n| |-- __init__.py\n| |-- main.py\n|\n|-- setup.py\n|-- README\n"
},
{
"answer_id": 19871661,
"author": "David C. Bishop",
"author_id": 187237,
"author_profile": "https://Stackoverflow.com/users/187237",
"pm_score": 7,
"selected": false,
"text": "$ pwd\n~/code/sandman\n$ tree\n.\n|- LICENSE\n|- README.md\n|- TODO.md\n|- docs\n| |-- conf.py\n| |-- generated\n| |-- index.rst\n| |-- installation.rst\n| |-- modules.rst\n| |-- quickstart.rst\n| |-- sandman.rst\n|- requirements.txt\n|- sandman\n| |-- __init__.py\n| |-- exception.py\n| |-- model.py\n| |-- sandman.py\n| |-- test\n| |-- models.py\n| |-- test_sandman.py\n|- setup.py\n"
},
{
"answer_id": 22554594,
"author": "KT.",
"author_id": 318964,
"author_profile": "https://Stackoverflow.com/users/318964",
"pm_score": 5,
"selected": false,
"text": "PROJECT_ROOT/src/<egg_name> entry_point PROJECT_ROOT/.<something> PROJECT_ROOT/src/<egg_name>/tests py.test pkg_resources setuptools importlib.resources PROJECT_ROOT/config %APP_DATA%/<app-name>/config /etc/<app-name> /opt/<app-name>/config PROJECT_ROOT/var /var PROJECT_ROOT/src/<egg_name>/native PROJECT_ROOT/doc PROJECT_ROOT/src/<egg_name>/doc PROJECT_ROOT/buildout.cfg PROJECT_ROOT/setup.cfg"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13402/"
] |
193,166
|
<p>Java process control is notoriously bad - primarily due to inadequate support by the Java VM/JDK classes (e.g. java.lang.Process).</p>
<p>I am wondering, are there any good open source libraries out there that are reliable.</p>
<p>The requirements would be:</p>
<ol>
<li>OSS</li>
<li>Start/Stop processes</li>
<li>Manage STDIN and STDOUT</li>
<li>cross platform (at least Linux,
Windows, Solaris, HP, and IBM in
that order)</li>
<li>(optional) restartable</li>
<li>(desirable) mature</li>
</ol>
|
[
{
"answer_id": 4464978,
"author": "Ryan",
"author_id": 545294,
"author_profile": "https://Stackoverflow.com/users/545294",
"pm_score": 3,
"selected": false,
"text": "java.lang.Process"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19013/"
] |
193,182
|
<p>Is there any way to get own phone number by standard APIs from iPhone SDK?</p>
|
[
{
"answer_id": 224356,
"author": "Robert Sanders",
"author_id": 16952,
"author_profile": "https://Stackoverflow.com/users/16952",
"pm_score": 6,
"selected": false,
"text": "NSString *num = [[NSUserDefaults standardUserDefaults] stringForKey:@\"SBFormattedPhoneNumber\"];\n WebKitJavaScriptCanOpenWindowsAutomatically\nNSInterfaceStyle\nTVOutStatus\nWebKitDeveloperExtrasEnabledPreferenceKey\n"
},
{
"answer_id": 2901196,
"author": "Andres Garcia",
"author_id": 349454,
"author_profile": "https://Stackoverflow.com/users/349454",
"pm_score": 5,
"selected": false,
"text": "NSString *num = [[NSUserDefaults standardUserDefaults] stringForKey:@\"SBFormattedPhoneNumber\"];\n NSString *phoneName = [[UIDevice currentDevice] name];\n\nNSString *phoneUniqueIdentifier = [[UIDevice currentDevice] uniqueIdentifier];\n @property(nonatomic,readonly,retain) NSString *name; // e.g. \"My iPhone\"\n@property(nonatomic,readonly,retain) NSString *model; // e.g. @\"iPhone\", @\"iPod Touch\"\n@property(nonatomic,readonly,retain) NSString *localizedModel; // localized version of model\n@property(nonatomic,readonly,retain) NSString *systemName; // e.g. @\"iPhone OS\"\n@property(nonatomic,readonly,retain) NSString *systemVersion; // e.g. @\"2.0\"\n@property(nonatomic,readonly) UIDeviceOrientation orientation; // return current device orientation\n@property(nonatomic,readonly,retain) NSString *uniqueIdentifier; // a string unique to each device based on various hardware info.\n"
},
{
"answer_id": 12199204,
"author": "Igor",
"author_id": 1116052,
"author_profile": "https://Stackoverflow.com/users/1116052",
"pm_score": 5,
"selected": false,
"text": "extern NSString* CTSettingCopyMyPhoneNumber();\n\n\n+(NSString *) phoneNumber {\nNSString *phone = CTSettingCopyMyPhoneNumber();\n\nreturn phone;\n}\n"
},
{
"answer_id": 15678582,
"author": "David Gölzhäuser",
"author_id": 1766321,
"author_profile": "https://Stackoverflow.com/users/1766321",
"pm_score": 2,
"selected": false,
"text": "NSString *commcenter = @\"/private/var/wireless/Library/Preferences/com.apple.commcenter.plist\";\n NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:commcenter];\n NSString *PhoneNumber = [dict valueForKey:@\"PhoneNumber\"];\n NSLog([NSString stringWithFormat:@\"Phone number: %@\",PhoneNumber]);\n"
},
{
"answer_id": 25923818,
"author": "0x8BADF00D",
"author_id": 2196150,
"author_profile": "https://Stackoverflow.com/users/2196150",
"pm_score": 2,
"selected": false,
"text": "-(NSString*) getMyNumber {\n NSLog(@\"Open CoreTelephony\");\n void *lib = dlopen(\"/Symbols/System/Library/Framework/CoreTelephony.framework/CoreTelephony\",RTLD_LAZY);\n NSLog(@\"Get CTSettingCopyMyPhoneNumber from CoreTelephony\");\n NSString* (*pCTSettingCopyMyPhoneNumber)() = dlsym(lib, \"CTSettingCopyMyPhoneNumber\");\n NSLog(@\"Get CTSettingCopyMyPhoneNumber from CoreTelephony\");\n\n if (pCTSettingCopyMyPhoneNumber == nil) {\n NSLog(@\"pCTSettingCopyMyPhoneNumber is nil\");\n return nil;\n }\n NSString* ownPhoneNumber = pCTSettingCopyMyPhoneNumber();\n dlclose(lib);\n return ownPhoneNumber;\n}\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26980/"
] |
193,185
|
<p>I've got a little problem that's slightly frustrating. Is it possible to set a default value when deserializing xml in C# (.NET 3.5)? Basically I'm trying to deserialize some xml that is not under my control and one element looks like this:</p>
<pre><code><assignee-id type="integer">38628</assignee-id>
</code></pre>
<p>it can also look like this:</p>
<pre><code><assignee-id type="integer" nil="true"></assignee-id>
</code></pre>
<p>Now, in my class I have the following property that should receive the data:</p>
<pre><code>[XmlElementAttribute("assignee-id")]
public int AssigneeId { get; set; }
</code></pre>
<p>This works fine for the first xml element example, but the second fails. I've tried changing the property type to be int? but this doesn't help. I'll need to serialize it back to that same xml format at some point too, but I'm trying to use the built in serialization support without having to resort to rolling my own. </p>
<p>Does anyone have experience with this kind of problem?</p>
|
[
{
"answer_id": 193874,
"author": "Timothy Walters",
"author_id": 14454,
"author_profile": "https://Stackoverflow.com/users/14454",
"pm_score": 3,
"selected": true,
"text": "<assignees>\n <assignee>\n <assignee-id type=\"integer\">123456</assignee-id>\n </assignee>\n <assignee>\n <assignee-id type=\"integer\" nil=\"true\"></assignee-id>\n </assignee>\n</assignees>\n <assignees xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n <assignee>\n <assignee-id xsi:type=\"integer\">123456</assignee-id>\n </assignee>\n <assignee>\n <assignee-id xsi:type=\"integer\" xsi:nil=\"true\" />\n </assignee>\n</assignees>\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15726/"
] |
193,257
|
<p>Assuming a Read Committed Snapshot transaction isolation setting, is the following statement "atomic" in the sense that you won't ever "lose" a concurrent increment?</p>
<pre><code>update mytable set counter = counter + 1
</code></pre>
<p>I would assume that in the general case, where this update statement is part of a larger transaction, that it wouldn't be. For example, I think this scenario is possible:</p>
<ul>
<li>update the counter within transaction #1</li>
<li>do some other stuff
in transaction #1</li>
<li>update the counter
with transaction #2</li>
<li>commit
transaction #2</li>
<li>commit transaction #1</li>
</ul>
<p>In this situation, wouldn't the counter end up only being incremented by 1? Does it make a difference if that is the only statement in a transaction?</p>
<p>How does a site like stackoverflow handle this for its question view counter? Or is the possibility of "losing" some increments just considered acceptable?</p>
|
[
{
"answer_id": 193265,
"author": "GSerg",
"author_id": 11683,
"author_profile": "https://Stackoverflow.com/users/11683",
"pm_score": 2,
"selected": false,
"text": "update t\nset counter = counter+1\nfrom t with(updlock, <some other hints maybe>)\nwhere foo = bar\n"
},
{
"answer_id": 193456,
"author": "Robert Paulson",
"author_id": 14033,
"author_profile": "https://Stackoverflow.com/users/14033",
"pm_score": 5,
"selected": true,
"text": "DECLARE @CounterInitialValue INT\nDECLARE @NewCounterValue INT\nSELECT @CounterInitialValue = SELECT counter FROM MyTable WHERE MyID = 1234\n\n-- do stuff with the counter value\n\nUPDATE MyTable\n SET counter = counter + 1\nWHERE\n MyID = 1234\n AND \n counter = @CounterInitialValue -- prevents the update if counter changed.\n\n-- the value of counter must not change in this scenario.\n-- so we rollback if the update affected no rows\nIF( @@ROWCOUNT = 0 )\n ROLLBACK\n"
},
{
"answer_id": 193484,
"author": "yfeldblum",
"author_id": 12349,
"author_profile": "https://Stackoverflow.com/users/12349",
"pm_score": 1,
"selected": false,
"text": "use Playground\n\ndrop table C\ncreate table C (\n Num int not null)\n\ninsert into C (Num) values (1)\n\nbegin tran X\n update C set Num = Num + 1\n begin tran Y\n update C set Num = Num + 1\n commit tran Y\ncommit tran X\n\nselect * from C\n"
},
{
"answer_id": 2695823,
"author": "scott-pascoe",
"author_id": 195550,
"author_profile": "https://Stackoverflow.com/users/195550",
"pm_score": 5,
"selected": false,
"text": "UPDATE tablename SET counterfield = counterfield + 1 OUTPUT INSERTED.counterfield\n"
},
{
"answer_id": 58123448,
"author": "shatl",
"author_id": 87055,
"author_profile": "https://Stackoverflow.com/users/87055",
"pm_score": 1,
"selected": false,
"text": "ALTER PROCEDURE [dbo].[GetNext](\n@name varchar(50) )\nAS BEGIN SET NOCOUNT ON\n\nDECLARE @Out TABLE(Id BIGINT)\n\nMERGE TOP (1) dbo.Counter as Target\n USING (SELECT 1 as C, @name as name) as Source ON Target.name = Source.Name\n WHEN MATCHED THEN UPDATE SET Target.[current] = Target.[current] + 1\n WHEN NOT MATCHED THEN INSERT (name, [current]) VALUES (@name, 1)\nOUTPUT\n INSERTED.[current];\nEND\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26651/"
] |
193,260
|
<p>We're currently running an <code>svnserve</code> instance as NT service. While this works, it's needlessly cumbersome to administer, and I'd like to move on to the much simpler VisualSVN Server. (Bonus side benefits include Windows-integrated authentication and, thanks to HTTP/WebDAV, browsing of the latest revision.)</p>
<p>That said, the current server offers up URLs that look like this:</p>
<pre><code>svn://oldserver/path/to/some/file.foo
</code></pre>
<p>Rather memorable.</p>
<p>The new one, as set up through VSVNS:</p>
<pre><code>https://newserver:8443/svn/Repos/path/to/some/file.foo
</code></pre>
<p>Ouch. For one, the <code>/svn</code> bit is <em>entirely</em> unnecessary. Since VSVNS runs its own HTTP server (that's why it's on the special port <code>8443</code>, after all), <em>of course</em> everything is related to <code>svn</code>. Moreover, we only have one repository (and no real need for more), so the repository name in <code>/Repos</code> shouldn't be there either — we could turn this off with <code>svnserve</code>, so there should be a way to do it now, too.</p>
<ul>
<li>Is it possible to configure VisualSVN Server to drop the <code>/svn</code>? (Why is it there to begin with?)</li>
<li>Given that there is only one repository, can I tell it not to make the repository name part of the URL?</li>
</ul>
|
[
{
"answer_id": 193265,
"author": "GSerg",
"author_id": 11683,
"author_profile": "https://Stackoverflow.com/users/11683",
"pm_score": 2,
"selected": false,
"text": "update t\nset counter = counter+1\nfrom t with(updlock, <some other hints maybe>)\nwhere foo = bar\n"
},
{
"answer_id": 193456,
"author": "Robert Paulson",
"author_id": 14033,
"author_profile": "https://Stackoverflow.com/users/14033",
"pm_score": 5,
"selected": true,
"text": "DECLARE @CounterInitialValue INT\nDECLARE @NewCounterValue INT\nSELECT @CounterInitialValue = SELECT counter FROM MyTable WHERE MyID = 1234\n\n-- do stuff with the counter value\n\nUPDATE MyTable\n SET counter = counter + 1\nWHERE\n MyID = 1234\n AND \n counter = @CounterInitialValue -- prevents the update if counter changed.\n\n-- the value of counter must not change in this scenario.\n-- so we rollback if the update affected no rows\nIF( @@ROWCOUNT = 0 )\n ROLLBACK\n"
},
{
"answer_id": 193484,
"author": "yfeldblum",
"author_id": 12349,
"author_profile": "https://Stackoverflow.com/users/12349",
"pm_score": 1,
"selected": false,
"text": "use Playground\n\ndrop table C\ncreate table C (\n Num int not null)\n\ninsert into C (Num) values (1)\n\nbegin tran X\n update C set Num = Num + 1\n begin tran Y\n update C set Num = Num + 1\n commit tran Y\ncommit tran X\n\nselect * from C\n"
},
{
"answer_id": 2695823,
"author": "scott-pascoe",
"author_id": 195550,
"author_profile": "https://Stackoverflow.com/users/195550",
"pm_score": 5,
"selected": false,
"text": "UPDATE tablename SET counterfield = counterfield + 1 OUTPUT INSERTED.counterfield\n"
},
{
"answer_id": 58123448,
"author": "shatl",
"author_id": 87055,
"author_profile": "https://Stackoverflow.com/users/87055",
"pm_score": 1,
"selected": false,
"text": "ALTER PROCEDURE [dbo].[GetNext](\n@name varchar(50) )\nAS BEGIN SET NOCOUNT ON\n\nDECLARE @Out TABLE(Id BIGINT)\n\nMERGE TOP (1) dbo.Counter as Target\n USING (SELECT 1 as C, @name as name) as Source ON Target.name = Source.Name\n WHEN MATCHED THEN UPDATE SET Target.[current] = Target.[current] + 1\n WHEN NOT MATCHED THEN INSERT (name, [current]) VALUES (@name, 1)\nOUTPUT\n INSERTED.[current];\nEND\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1600/"
] |
193,271
|
<p>CVS and Subversion both have a handy merge feature so that when you update a source file that you have modified, it merges in changes that others have made on the same file.</p>
<p>However, if your changes and the other ones are incompatible - generally if you have both changed the same parts of the code - it will create a conflict. Both stretches of source code will be included into the merged file and you need to manually sort out which changes to keep. All fine so far.</p>
<p>My problem is that some of us use different development environments (Netbeans versus vi if you must know) and Netbeans has an auto-indenting feature which re-indents the code. Therefore, when we merge changes, we sometimes get huge conflicts which are mostly caused by simple changes in indentation and are not genuine changes to code. Often these create hundreds of lines of apparent conflicts which have to be manually resolved, but usually they come down to just a few lines of real changes. A similar situation occurs when someone's editor changes unix to Windows newlines or vice versa.</p>
<p>So - can I set merge to ignore these "conflicts" when comparing the two versions? Diff has the --ignore-space-change or -b option and I would like to have essentially the same feature available in cvs or svn. We use each tool on different projects so I would be happy to have the answer for either or both.</p>
<p>Two final notes:</p>
<ul>
<li>clearly the merge process would have to make an arbitrary choice as to which version of the whitespace to use in the merged file. I'm fine with that - we can always reformat it again later.</li>
<li>I could avoid some of this by being more disciplined and checking in more often - acknowledged and understood. But I am not perfect.</li>
</ul>
|
[
{
"answer_id": 26581522,
"author": "vCillusion",
"author_id": 1688718,
"author_profile": "https://Stackoverflow.com/users/1688718",
"pm_score": 0,
"selected": false,
"text": "/* DisableWhitespaceDifferences and DisableCaseDifferences. \n* The settings for TortoiseMerge is stored in Registry in CurrentUser\\Software\\TortoiseMerge\\\n* DWORDS stored the property values.\n* \n* IgnoreWS : Set to 1 to ignore the whitespace differences. \n* Set to 0 to allow the whitespace differences. \n* IgnoreEOL : Set to 1 to ignore the End of Line differences. \n* Set to 0 to allow the End of Line differences. \n* CaseInsensitive : Set to 1 to ignore the Case differences. \n* Set to 0 to allow the Case differences. \n*/\n\n// Get the key from the registry\nusing (RegistryKey key = Registry.CurrentUser.OpenSubKey(@\"Software\\TortoiseMerge\", true))\n{\n if (key != null)\n {\n // Set the IgnoreWS and IgnoreEOL DWORDs based on DisableWhitespaceDifferences is set or not\n key.SetValue(\"IgnoreWS\", DisableWhitespaceDifferences ? 1 : 0, RegistryValueKind.DWord);\n key.SetValue(\"IgnoreEOL\", DisableWhitespaceDifferences ? 1 : 0, RegistryValueKind.DWord);\n\n // Set the CaseInsensitive DWORD based on DisableCaseDifferences is set or not\n key.SetValue(\"CaseInsensitive\", DisableCaseDifferences ? 1 : 0, RegistryValueKind.DWord);\n\n // close key\n key.Close();\n }\n}\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3267/"
] |
193,273
|
<p>I'm making a dynamic image for a forum that doesn't allow dynamic images.</p>
<p>I tried using .htacess to redirect all *.png files to image.png... which works perfectly, but from here I can't seem to be able to get the filename of the .png that was requested to generate the content. </p>
<p>For example:</p>
<ol>
<li><p>user puts in banana.png</p></li>
<li><p>htaccess forwards to image.php</p></li>
</ol>
<p>I need a way of getting that banana into my php script.</p>
<p>Using <code>$_SERVER['REQUEST_URI']</code> and <code>$_SERVER["SCRIPT_NAME"]</code> just returns that of the PHP file.</p>
<p>Is there a way of redirecting it to <code>image.php?=bananana</code> for example?</p>
|
[
{
"answer_id": 26581522,
"author": "vCillusion",
"author_id": 1688718,
"author_profile": "https://Stackoverflow.com/users/1688718",
"pm_score": 0,
"selected": false,
"text": "/* DisableWhitespaceDifferences and DisableCaseDifferences. \n* The settings for TortoiseMerge is stored in Registry in CurrentUser\\Software\\TortoiseMerge\\\n* DWORDS stored the property values.\n* \n* IgnoreWS : Set to 1 to ignore the whitespace differences. \n* Set to 0 to allow the whitespace differences. \n* IgnoreEOL : Set to 1 to ignore the End of Line differences. \n* Set to 0 to allow the End of Line differences. \n* CaseInsensitive : Set to 1 to ignore the Case differences. \n* Set to 0 to allow the Case differences. \n*/\n\n// Get the key from the registry\nusing (RegistryKey key = Registry.CurrentUser.OpenSubKey(@\"Software\\TortoiseMerge\", true))\n{\n if (key != null)\n {\n // Set the IgnoreWS and IgnoreEOL DWORDs based on DisableWhitespaceDifferences is set or not\n key.SetValue(\"IgnoreWS\", DisableWhitespaceDifferences ? 1 : 0, RegistryValueKind.DWord);\n key.SetValue(\"IgnoreEOL\", DisableWhitespaceDifferences ? 1 : 0, RegistryValueKind.DWord);\n\n // Set the CaseInsensitive DWORD based on DisableCaseDifferences is set or not\n key.SetValue(\"CaseInsensitive\", DisableCaseDifferences ? 1 : 0, RegistryValueKind.DWord);\n\n // close key\n key.Close();\n }\n}\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26987/"
] |
193,288
|
<p>Most of Apples documentation seems to avoid using autoreleased objects especially when creating gui views, but I want to know what the cost of using autoreleased objects is?</p>
<pre><code>UIScrollView *timeline = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 20, 320, 34)];
[self addSubview:timeline];
[timeline release];
</code></pre>
<p>Ultimately should I use a strategy where everything is autoreleased and using retain/release should be the exception to the rule for specific cases? Or should I generally be using retain/release with autorelease being the exception for returned objects from convenience methods like [NSString stringWithEtc...] ?</p>
|
[
{
"answer_id": 193640,
"author": "mmalc",
"author_id": 23233,
"author_profile": "https://Stackoverflow.com/users/23233",
"pm_score": 5,
"selected": true,
"text": "NSString stringWithEtc initWithEtc"
},
{
"answer_id": 224525,
"author": "Dave Dribin",
"author_id": 26825,
"author_profile": "https://Stackoverflow.com/users/26825",
"pm_score": 3,
"selected": false,
"text": "@try @finally autorelease autorelease"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26986/"
] |
193,293
|
<p>Given a filename, I need to be able to access certain metadata in an image for a (closed source) project I'm currently developing, without regard to how the metadata is stored (that is, Exif, IPTC, or XMP). In particular, I want to access geotagging data.</p>
<p>Is there a way of doing this <b>without</b> requiring any third party assemblies or libraries (i.e. is it doable with stock Microsoft .NET) and how would it be done? Or am I stuck with a lot of P/Invoking of <a href="http://msdn.microsoft.com/en-us/library/ms735422(VS.85).aspx" rel="nofollow noreferrer">WIC</a>?</p>
|
[
{
"answer_id": 2120868,
"author": "Dave Cowart",
"author_id": 88959,
"author_profile": "https://Stackoverflow.com/users/88959",
"pm_score": 2,
"selected": false,
"text": "public static string GetEXIFInfo(System.Drawing.Image img, int propertyItem) {\n return new ASCIIEncoding().GetString(img.GetPropertyItem(propertyItem).Value);\n}\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5697/"
] |
193,341
|
<p>I have a Trac project installed on top of a Subversion implementation (easy to do thanks to Webfaction's control panel), but now I have configuration work to do. With that in mind, are there <em>easy</em> ways to do the following in Trac:</p>
<p>1) Ensure that customers can only see a high level progress indicator.<br>
2) Give daily summary reports on tickets, testing, and tasks.</p>
<p>Also, I am interested in knowing if there are any <strong>highly</strong> recommended plugins that I would be sorry I forgot to install.</p>
|
[
{
"answer_id": 524915,
"author": "Oliver Giesen",
"author_id": 9784,
"author_profile": "https://Stackoverflow.com/users/9784",
"pm_score": 2,
"selected": false,
"text": "ROADMAP_VIEW"
},
{
"answer_id": 530173,
"author": "Bob Nadler",
"author_id": 2514,
"author_profile": "https://Stackoverflow.com/users/2514",
"pm_score": 2,
"selected": false,
"text": "WHERE datetime(t.changetime, 'unixepoch') >= datetime('now','-$DAYS days')\n Show activity for last [http://server.com/trac/report/9?DAYS=8 8] days.\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13990/"
] |
193,351
|
<p>Is it possible to break at runtime when a particular file has been modified? </p>
<p>ie. monitor the file and break into a debugger once a change has been made to it.</p>
<p>This is for a windows app...is this possible in visual studio or windbg?</p>
<p>edit: i should have mentioned that this is for a Win32 app..</p>
|
[
{
"answer_id": 193360,
"author": "MusiGenesis",
"author_id": 14606,
"author_profile": "https://Stackoverflow.com/users/14606",
"pm_score": 0,
"selected": false,
"text": "FileSystemWatcher watcher = new FileSystemWatcher(\"c:filename.txt\");\nwatcher.Changed += new FileSystemEventHandler(watcher_Changed);\n// \nvoid watcher_Changed(object sender, FileSystemEventArgs e)\n{\n // put a breakpoint here\n}\n"
},
{
"answer_id": 193381,
"author": "Enrico Murru",
"author_id": 68336,
"author_profile": "https://Stackoverflow.com/users/68336",
"pm_score": 3,
"selected": true,
"text": "FileSystemWatcher watcher = = new FileSystemWatcher();\nwatcher.Filter = @\"myFile.ini\";\nwatcher.Changed += new FileSystemEventHandler(watcher_Changed);\n static void watcher_Changed(object sender, FileSystemArgs e)\n{\n Console.WriteLine(\"File {0} has changed.\", e.FullPath );\n}\n"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193351",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19263/"
] |
193,398
|
<p>Is there an algorithm for accurately multiplying two arbitrarily long integers together? The language I am working with is limited to 64-bit unsigned integer length (maximum integer size of 18446744073709551615). Realistically, I would like to be able to do this by breaking up each number, processing them somehow using the unsigned 64-bit integers, and then being able to put them back together in to a string (which would solve the issue of multiplied result storage).</p>
<p>Any ideas?</p>
|
[
{
"answer_id": 193416,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 5,
"selected": true,
"text": " 45\n x67\n ---\n 315\n+270\n----\n 585\n 101\n x101\n ----\n 101\n 000\n+101\n------\n 11001\n"
},
{
"answer_id": 18036443,
"author": "ron",
"author_id": 2649254,
"author_profile": "https://Stackoverflow.com/users/2649254",
"pm_score": 1,
"selected": false,
"text": "char *multiply(char s1[], char s2[]) {\n int l1 = strlen(s1);\n int l2 = strlen(s2);\n int i, j, k = 0, c = 0;\n char *r = (char *) malloc (l1+l2+1); // add one byte for the zero terminating string\n int temp;\n\n strrev(s1);\n strrev(s2);\n for (i = 0;i <l1+l2; i++) {\n r[i] = 0 + '0';\n }\n\n for (i = 0; i <l1; i ++) {\n c = 0; k = i;\n for (j = 0; j < l2; j++) {\n temp = get_int(s1[i]) * get_int(s2[j]);\n temp = temp + c + get_int(r[k]);\n c = temp /10;\n r[k] = temp%10 + '0';\n\n k++;\n }\n if (c!=0) {\n r[k] = c + '0';\n k++;\n }\n }\n\n r[k] = '\\0';\n strrev(r);\n return r;\n}\n"
},
{
"answer_id": 52869819,
"author": "Pianistprogrammer",
"author_id": 5546672,
"author_profile": "https://Stackoverflow.com/users/5546672",
"pm_score": 1,
"selected": false,
"text": " //Here is a JavaScript version of an Karatsuba Algorithm running with less time than the usual multiplication method\n \n function range(start, stop, step) {\n if (typeof stop == 'undefined') {\n // one param defined\n stop = start;\n start = 0;\n }\n if (typeof step == 'undefined') {\n step = 1;\n }\n if ((step > 0 && start >= stop) || (step < 0 && start <= stop)) {\n return [];\n }\n var result = [];\n for (var i = start; step > 0 ? i < stop : i > stop; i += step) {\n result.push(i);\n }\n return result;\n };\n function zeroPad(numberString, zeros, left = true) {\n //Return the string with zeros added to the left or right.\n for (var i in range(zeros)) {\n if (left)\n numberString = '0' + numberString\n else\n numberString = numberString + '0'\n }\n \n return numberString\n }\n function largeMultiplication(x, y) {\n x = x.toString();\n y = y.toString();\n \n if (x.length == 1 && y.length == 1)\n return parseInt(x) * parseInt(y)\n \n if (x.length < y.length)\n x = zeroPad(x, y.length - x.length);\n \n else\n y = zeroPad(y, x.length - y.length);\n \n n = x.length\n j = Math.floor(n/2);\n \n //for odd digit integers\n if ( n % 2 != 0)\n j += 1 \n var BZeroPadding = n - j\n var AZeroPadding = BZeroPadding * 2\n \n a = parseInt(x.substring(0,j));\n b = parseInt(x.substring(j));\n c = parseInt(y.substring(0,j));\n d = parseInt(y.substring(j));\n \n //recursively calculate\n ac = largeMultiplication(a, c)\n bd = largeMultiplication(b, d)\n k = largeMultiplication(a + b, c + d)\n A = parseInt(zeroPad(ac.toString(), AZeroPadding, false))\n B = parseInt(zeroPad((k - ac - bd).toString(), BZeroPadding, false))\n return A + B + bd\n }\n //testing the function here\n example = largeMultiplication(12, 34)\n console.log(example)"
}
] |
2008/10/10
|
[
"https://Stackoverflow.com/questions/193398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14322/"
] |
193,440
|
<pre><code>func()
{
Object* pNext;
func1(pNext);
}
func1(Object* pNext)
{
pNext = Segement->GetFirstPara(0);
}
</code></pre>
<p>I was expecting it to be pointer to firstpara returned from func1() but I'm seeing NULL can some explain and how to fix it to actually return the firstpara() pointer?</p>
|
[
{
"answer_id": 193450,
"author": "Matthew Scharley",
"author_id": 15537,
"author_profile": "https://Stackoverflow.com/users/15537",
"pm_score": 2,
"selected": false,
"text": "Object** pNext func() { \n Object* pNext;\n func1(&pNext);\n}\n\nfunc1(Object** pNext) { *pNext = Segement->GetFirstPara(0); }\n"
},
{
"answer_id": 193454,
"author": "Dima",
"author_id": 13313,
"author_profile": "https://Stackoverflow.com/users/13313",
"pm_score": 0,
"selected": false,
"text": "\nfunc()\n{\n Object *pNext;\n func1(&pNext);\n}\n\nvoid func1(Object **pNext)\n{\n *pNext = Segment->GetFirstPara(0);\n}\n"
},
{
"answer_id": 193455,
"author": "ejgottl",
"author_id": 9808,
"author_profile": "https://Stackoverflow.com/users/9808",
"pm_score": 3,
"selected": false,
"text": "func1(&pNext);\nfunc1(Object** pNext) { *pNext = ... }\n func1(pNext);\nfunc1(Object*& pNext) { pNext = ... }\n Object* func1"
},
{
"answer_id": 193461,
"author": "Diastrophism",
"author_id": 18093,
"author_profile": "https://Stackoverflow.com/users/18093",
"pm_score": 4,
"selected": false,
"text": "func()\n{\n Object* pNext;\n func1(pNext);\n}\n\nfunc1(Object*& pNext)\n{\n pNext = Segement->GetFirstPara(0);\n}\n"
},
{
"answer_id": 194043,
"author": "John Dibling",
"author_id": 241536,
"author_profile": "https://Stackoverflow.com/users/241536",
"pm_score": 1,
"selected": false,
"text": "if( NULL != pNext )\n{\n pNext->DoSomething();\n}\n func()\n{\n Object *pNext = func1();\n}\n\nObject* func1()\n{\n return Segment->GetFirstPara(0);\n}\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22535/"
] |
193,457
|
<p>I have subclassed <a href="https://docs.oracle.com/javase/9/docs/api/java/awt/Frame.html" rel="nofollow noreferrer"><code>java.awt.Frame</code></a> and have overridden the <a href="https://docs.oracle.com/javase/9/docs/api/java/awt/Window.html#paint-java.awt.Graphics-" rel="nofollow noreferrer"><code>paint()</code></a> method as I wish to draw the entire contents of the window manually.</p>
<p>However, on the graphics object, (0,0) corresponds to the upper left hand corner of the window <strong>inside</strong> the title bar decoration, not the first drawable pixel.</p>
<p>Can I determine the co-ordinate of the first drawable pixel (ie, the height of the decoration) in a cross-platform manner, avoiding using a Mac OS X-specific <a href="https://en.wikipedia.org/wiki/Fudge_factor" rel="nofollow noreferrer">fudge factor</a>? Will I be forced to nest a <a href="https://docs.oracle.com/javase/9/docs/api/java/awt/Panel.html" rel="nofollow noreferrer">Panel</a> component in order to find the actual drawable area of the window?</p>
<p>Here, my code fails to centre the blue square inside the paintable area of the window:</p>
<pre><code>@Override
public void paint (Graphics g) {
g.setColor(Color.BLUE);
g.setPaintMode();
g.fillRect(30, 30, getWidth()-60, getHeight()-60);
}
</code></pre>
|
[
{
"answer_id": 193450,
"author": "Matthew Scharley",
"author_id": 15537,
"author_profile": "https://Stackoverflow.com/users/15537",
"pm_score": 2,
"selected": false,
"text": "Object** pNext func() { \n Object* pNext;\n func1(&pNext);\n}\n\nfunc1(Object** pNext) { *pNext = Segement->GetFirstPara(0); }\n"
},
{
"answer_id": 193454,
"author": "Dima",
"author_id": 13313,
"author_profile": "https://Stackoverflow.com/users/13313",
"pm_score": 0,
"selected": false,
"text": "\nfunc()\n{\n Object *pNext;\n func1(&pNext);\n}\n\nvoid func1(Object **pNext)\n{\n *pNext = Segment->GetFirstPara(0);\n}\n"
},
{
"answer_id": 193455,
"author": "ejgottl",
"author_id": 9808,
"author_profile": "https://Stackoverflow.com/users/9808",
"pm_score": 3,
"selected": false,
"text": "func1(&pNext);\nfunc1(Object** pNext) { *pNext = ... }\n func1(pNext);\nfunc1(Object*& pNext) { pNext = ... }\n Object* func1"
},
{
"answer_id": 193461,
"author": "Diastrophism",
"author_id": 18093,
"author_profile": "https://Stackoverflow.com/users/18093",
"pm_score": 4,
"selected": false,
"text": "func()\n{\n Object* pNext;\n func1(pNext);\n}\n\nfunc1(Object*& pNext)\n{\n pNext = Segement->GetFirstPara(0);\n}\n"
},
{
"answer_id": 194043,
"author": "John Dibling",
"author_id": 241536,
"author_profile": "https://Stackoverflow.com/users/241536",
"pm_score": 1,
"selected": false,
"text": "if( NULL != pNext )\n{\n pNext->DoSomething();\n}\n func()\n{\n Object *pNext = func1();\n}\n\nObject* func1()\n{\n return Segment->GetFirstPara(0);\n}\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8779/"
] |
193,469
|
<p>I have a collection of Boost unit tests I want to run as a console application.</p>
<p>When I'm working on the project and I run the tests I would like to be able to debug the tests, and I would like to have the console stay open after the tests run.</p>
<p>I see that if I run in release mode the console window stays up after the program exits, but in debug mode this is not the case.</p>
<p>I do not want to add 'system("pause");' or any other hacks like reading a character to my program. I just want to make Visual Studio pause after running the tests with debugging like it would if I were running in release mode. I would also like it if the output of tests were captured in one of Visual Studio's output windows, but that also seems to be harder than it should be.</p>
<p>How can I do this?</p>
|
[
{
"answer_id": 318975,
"author": "Die in Sente",
"author_id": 40756,
"author_profile": "https://Stackoverflow.com/users/40756",
"pm_score": 2,
"selected": false,
"text": "system(\"pause\") void pause () {\n system (\"pause\");\n}\n\nint main (int argc, char ** argv) {\n // If \"launched\", then don't let the console close at the end until\n // the user has seen the report.\n // (See the MSDN ConGUI sample code)\n //\n do {\n HANDLE hConsoleOutput = ::GetStdHandle (STD_OUTPUT_HANDLE);\n if (INVALID_HANDLE_VALUE == hConsoleOutput)\n break;\n CONSOLE_SCREEN_BUFFER_INFO csbi;\n if (0 == ::GetConsoleScreenBufferInfo (hConsoleOutput, &csbi))\n break;\n if (0 != csbi.dwCursorPosition.X)\n break;\n if (0 != csbi.dwCursorPosition.Y)\n break;\n if (csbi.dwSize.X <= 0)\n break;\n if (csbi.dwSize.Y <= 0)\n break;\n atexit (pause);\n } while (0);\n atexit() atexit()"
},
{
"answer_id": 2981381,
"author": "Daniel Gomez Rico",
"author_id": 273119,
"author_profile": "https://Stackoverflow.com/users/273119",
"pm_score": -1,
"selected": false,
"text": "static void Main(string[] args)\n{\n .\n .\n .\n String temp = Console.ReadLine();\n}\n"
},
{
"answer_id": 5010798,
"author": "Mattias",
"author_id": 618758,
"author_profile": "https://Stackoverflow.com/users/618758",
"pm_score": 1,
"selected": false,
"text": "<time.h> clock_t wait;\n\nwait = clock();\nwhile (clock() <= (wait + 5000)) // Wait for 5 seconds and then continue\n ;\nwait = 0;\n"
},
{
"answer_id": 5868340,
"author": "razzmatazz",
"author_id": 535154,
"author_profile": "https://Stackoverflow.com/users/535154",
"pm_score": 2,
"selected": false,
"text": "--auto_start_dbg #ifdef _DEBUG\n\n#include <boost/test/framework.hpp>\n#include <boost/test/test_observer.hpp>\n\nstruct BoostUnitTestCrtBreakpointInDebug: boost::unit_test::test_observer\n{\n BoostUnitTestCrtBreakpointInDebug()\n {\n boost::unit_test::framework::register_observer(*this);\n }\n\n virtual ~BoostUnitTestCrtBreakpointInDebug()\n {\n boost::unit_test::framework::deregister_observer(*this);\n }\n\n virtual void assertion_result( bool passed /* passed */ )\n {\n if (!passed)\n BreakIfInDebugger();\n }\n\n virtual void exception_caught( boost::execution_exception const& )\n {\n BreakIfInDebugger();\n }\n\n void BreakIfInDebugger()\n {\n if (IsDebuggerPresent())\n {\n /**\n * Hello, I know you are here staring at the debugger :)\n *\n * If you got here then there is an exception in your unit\n * test code. Walk the call stack to find the actual cause.\n */\n _CrtDbgBreak();\n }\n }\n};\n\nBOOST_GLOBAL_FIXTURE(BoostUnitTestCrtBreakpointInDebug);\n\n#endif\n"
},
{
"answer_id": 18058687,
"author": "zurfyx",
"author_id": 2013580,
"author_profile": "https://Stackoverflow.com/users/2013580",
"pm_score": 1,
"selected": false,
"text": "pause system(\"pause >nul | set /p \\\"=\\\"\");\n"
},
{
"answer_id": 59709086,
"author": "Rich Vogt",
"author_id": 2069474,
"author_profile": "https://Stackoverflow.com/users/2069474",
"pm_score": 0,
"selected": false,
"text": "'use strict';\n\nconsole.log('Hello world');\n\nconst readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.question('Press enter to continue...', (answer) => {\n rl.close(); /* discard the answer */\n});\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5113/"
] |
193,471
|
<p>As I recall <code>BOOST_MPL_ASSERT</code> was once preferred. Is this still true? Anyone know why?</p>
|
[
{
"answer_id": 193592,
"author": "Head Geek",
"author_id": 12193,
"author_profile": "https://Stackoverflow.com/users/12193",
"pm_score": 2,
"selected": false,
"text": "BOOST_MPL_ASSERT BOOST_MPL_ASSERT_MSG BOOST_STATIC_ASSERT"
},
{
"answer_id": 687302,
"author": "jwfearn",
"author_id": 10559,
"author_profile": "https://Stackoverflow.com/users/10559",
"pm_score": 5,
"selected": true,
"text": "BOOST_STATIC_ASSERT( P ) P != true BOOST_MPL_ASSERT(( P )) P::type::value != true <type_traits> #include <boost/static_assert.hpp>\n#include <boost/mpl/assert.hpp>\n#include <type_traits>\nusing namespace ::boost::mpl;\nusing namespace ::std::tr1;\n\nstruct A {};\nstruct Z {};\n\nint main() {\n // boolean predicates\n BOOST_STATIC_ASSERT( true ); // OK\n BOOST_STATIC_ASSERT( false ); // assert\n// BOOST_MPL_ASSERT( false ); // syntax error!\n// BOOST_MPL_ASSERT(( false )); // syntax error!\n BOOST_MPL_ASSERT(( bool_< true > )); // OK\n BOOST_MPL_ASSERT(( bool_< false > )); // assert\n\n // metafunction predicates\n BOOST_STATIC_ASSERT(( is_same< A, A >::type::value ));// OK\n BOOST_STATIC_ASSERT(( is_same< A, Z >::type::value ));// assert, line 19\n BOOST_MPL_ASSERT(( is_same< A, A > )); // OK\n BOOST_MPL_ASSERT(( is_same< A, Z > )); // assert, line 21\n return 0;\n}\n 1>static_assert.cpp(19) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'\n1> with\n1> [\n1> x=false\n1> ]\n1>static_assert.cpp(21) : error C2664: 'boost::mpl::assertion_failed' : cannot convert parameter 1 from 'boost::mpl::failed ************std::tr1::is_same<_Ty1,_Ty2>::* ***********' to 'boost::mpl::assert<false>::type'\n1> with\n1> [\n1> _Ty1=A,\n1> _Ty2=Z\n1> ]\n1> No constructor could take the source type, or constructor overload resolution was ambiguous\n BOOST_MPL_ASSERT BOOST_STATIC_ASSERT"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10559/"
] |
193,474
|
<p>I want to create an ini file to store some settings for my application. Is it a good idea to find where the jar file is located and create an ini file there? If yes, then how can I find the location of the jar file? </p>
<p>But if you know a better solution for something like this, I would like to hear some of them.</p>
<p><strong>EDIT</strong>: I'm using mac and I want to run the same application in windows. I could write something in the System.getProperty("user.home") directory, but I want to keep the system clean, if the user decides to remove the app. There is no a better way to store the settings file, for example in the same directory with the application?</p>
|
[
{
"answer_id": 193987,
"author": "McDowell",
"author_id": 304,
"author_profile": "https://Stackoverflow.com/users/304",
"pm_score": 6,
"selected": true,
"text": "/home/user/.eclipse\nC:\\Documents and Settings\\User\\.eclipse\n public static File getSettingsDirectory() {\n String userHome = System.getProperty(\"user.home\");\n if(userHome == null) {\n throw new IllegalStateException(\"user.home==null\");\n }\n File home = new File(userHome);\n File settingsDirectory = new File(home, \".myappdir\");\n if(!settingsDirectory.exists()) {\n if(!settingsDirectory.mkdir()) {\n throw new IllegalStateException(settingsDirectory.toString());\n }\n }\n return settingsDirectory;\n}\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8418/"
] |
193,483
|
<p>When using Maven to build an executable JAR, how do I specify the JVM arguments that are used when the JAR is executed?</p>
<p>I can specify the main class using <code><mainClass></code>. I suspect there's a similar attribute for JVM arguments. Specially I need to specify the maximum memory (example -Xmx500m).</p>
<p>Here's my assembly plugin:</p>
<pre><code> <plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.me.myApplication</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</code></pre>
<p>Edit/Follow-up: It seems that it might not be possible to specify JVM arguments for an executable JAR according to <a href="http://forums.sun.com/thread.jspa?threadID=633125&messageID=3667132" rel="noreferrer">this</a> and <a href="http://www.javalobby.org/forums/thread.jspa?threadID=15486&tstart=0#91817576" rel="noreferrer">this</a> post.</p>
|
[
{
"answer_id": 195815,
"author": "David Carlson",
"author_id": 4901,
"author_profile": "https://Stackoverflow.com/users/4901",
"pm_score": 2,
"selected": false,
"text": "<mainClass>scratch.Bootstrap</mainClass> package scratch;\n\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.PrintStream;\n\npublic class Bootstrap {\n class StreamProxy extends Thread {\n final InputStream is;\n final PrintStream os;\n\n StreamProxy(InputStream is, PrintStream os) {\n this.is = is;\n this.os = os;\n }\n\n public void run() {\n try {\n InputStreamReader isr = new InputStreamReader(is);\n BufferedReader br = new BufferedReader(isr);\n String line = null;\n while ((line = br.readLine()) != null) {\n os.println(line);\n }\n } catch (IOException ex) {\n throw new RuntimeException(ex.getMessage(), ex);\n }\n }\n }\n\n private void go(){\n try {\n /*\n * Spin up a separate java process calling a non-default Main class in your Jar. \n */\n Process process = Runtime.getRuntime().exec(\"java -cp scratch-1.0-SNAPSHOT-jar-with-dependencies.jar -Xmx500m scratch.App\");\n\n /*\n * Proxy the System.out and System.err from the spawned process back to the user's window. This\n * is important or the spawned process could block.\n */\n StreamProxy errorStreamProxy = new StreamProxy(process.getErrorStream(), System.err);\n StreamProxy outStreamProxy = new StreamProxy(process.getInputStream(), System.out);\n\n errorStreamProxy.start();\n outStreamProxy.start();\n\n System.out.println(\"Exit:\" + process.waitFor());\n } catch (Exception ex) {\n System.out.println(\"There was a problem execting the program. Details:\");\n ex.printStackTrace(System.err);\n\n if(null != process){\n try{\n process.destroy();\n } catch (Exception e){\n System.err.println(\"Error destroying process: \"+e.getMessage());\n }\n }\n }\n }\n\n public static void main(String[] args) {\n new Bootstrap().go();\n }\n\n}\n package scratch;\n\npublic class App \n{\n public static void main( String[] args )\n {\n System.out.println( \"Hello World! maxMemory:\"+Runtime.getRuntime().maxMemory() );\n }\n}\n java -jar scratch-1.0-SNAPSHOT-jar-with-dependencies.jar Hello World! maxMemory:520290304\nExit:0\n"
},
{
"answer_id": 7848011,
"author": "Leonard Hagger",
"author_id": 1006883,
"author_profile": "https://Stackoverflow.com/users/1006883",
"pm_score": -1,
"selected": false,
"text": "<configuation>\n...\n<argLine> -Xmx500m </argLine>\n...\n</configuation>\n"
},
{
"answer_id": 49866558,
"author": "Dmitriy Ryabin",
"author_id": 8340633,
"author_profile": "https://Stackoverflow.com/users/8340633",
"pm_score": 0,
"selected": false,
"text": ".bat > java .. yourClass.. -D<jvmOption1> -D<jvmOption2>..."
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24396/"
] |
193,488
|
<p>I've just started tinkering with XML manipulation with PHP, and i've stumbled into something unexpected. Here's the XML i'm using as a test input:</p>
<pre><code><list>
<activity1> running </activity1>
<activity2> swimming </activity2>
<activity3> soccer </activity3>
</list>
</code></pre>
<p>Now, i was expecting that this PHP code would output 'activity1':</p>
<pre><code>$xmldoc = new DOMDocument();
$xmldoc->load('file.xml');
//the line below would make $root the <list> node
$root = $xmldoc->firstChild;
//the line below would make $cnode the first child
//of the <list> node, which is <activity1>
$cnode = $root->firstChild;
//this should output 'activity1'
echo 'element name: ' . $cnode->nodeName;
</code></pre>
<p>Instead, this code outputs #text. I could fix that by inserting a new line in the code, before printing the node name:</p>
<pre><code>$cnode = $cnode->nextSibling;
</code></pre>
<p>Now, i would have expected that to print 'activity2' instead, but is printing 'activity1'. What is going on?</p>
|
[
{
"answer_id": 193571,
"author": "Czimi",
"author_id": 3906,
"author_profile": "https://Stackoverflow.com/users/3906",
"pm_score": 1,
"selected": false,
"text": "<?php\n$xmldoc = new DOMDocument();\n$xmldoc->load('file.xml', LIBXML_NOBLANKS);\n?>\n"
},
{
"answer_id": 193736,
"author": "eyelidlessness",
"author_id": 17964,
"author_profile": "https://Stackoverflow.com/users/17964",
"pm_score": 0,
"selected": false,
"text": "while($nodeInQuestion->nodeType != 1 && $nodeInQuestion->nextSibling) {\n $nodeInQuestion = $nodeInQuestion->nextSibling;\n}\n"
},
{
"answer_id": 194494,
"author": "Robert Rossney",
"author_id": 19403,
"author_profile": "https://Stackoverflow.com/users/19403",
"pm_score": 1,
"selected": false,
"text": "DOMDocument::xpath_eval() /list/* list"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
193,499
|
<p>What's the easiest way to get the UTC offset in PHP, relative to the current (system) timezone?</p>
|
[
{
"answer_id": 193516,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 5,
"selected": false,
"text": "timezone_offset_get() $this_tz_str = date_default_timezone_get();\n$this_tz = new DateTimeZone($this_tz_str);\n$now = new DateTime(\"now\", $this_tz);\n$offset = $this_tz->getOffset($now);\n"
},
{
"answer_id": 193517,
"author": "Czimi",
"author_id": 3906,
"author_profile": "https://Stackoverflow.com/users/3906",
"pm_score": 8,
"selected": true,
"text": " date('Z');\n"
},
{
"answer_id": 14173489,
"author": "Amr",
"author_id": 458204,
"author_profile": "https://Stackoverflow.com/users/458204",
"pm_score": -1,
"selected": false,
"text": "date(\"Z\") getTimezoneOffset() <script type=\"text/javascript\">\n d = new Date();\n window.location.href = \"page.php?offset=\" + d.getTimezoneOffset();\n</script>\n page.php"
},
{
"answer_id": 30735962,
"author": "Kenny",
"author_id": 810607,
"author_profile": "https://Stackoverflow.com/users/810607",
"pm_score": 4,
"selected": false,
"text": "date_default_timezone_set('America/New_York');\n$utc_offset = date('Z') / 3600;\n"
},
{
"answer_id": 36021293,
"author": "Tuhin Bepari",
"author_id": 3046071,
"author_profile": "https://Stackoverflow.com/users/3046071",
"pm_score": 6,
"selected": false,
"text": "// will output something like +02:00 or -04:00\necho date('P');\n"
},
{
"answer_id": 44250551,
"author": "زياد",
"author_id": 6316770,
"author_profile": "https://Stackoverflow.com/users/6316770",
"pm_score": 3,
"selected": false,
"text": "date.getTimezoneOffset() <?php\necho date('Z')/-60;\n?>\n"
},
{
"answer_id": 49455413,
"author": "HMagdy",
"author_id": 1665955,
"author_profile": "https://Stackoverflow.com/users/1665955",
"pm_score": 3,
"selected": false,
"text": "//Object oriented style\nfunction getUTCOffset_OOP($timezone)\n{\n $current = timezone_open($timezone);\n $utcTime = new \\DateTime('now', new \\DateTimeZone('UTC'));\n $offsetInSecs = $current->getOffset($utcTime);\n $hoursAndSec = gmdate('H:i', abs($offsetInSecs));\n return stripos($offsetInSecs, '-') === false ? \"+{$hoursAndSec}\" : \"-{$hoursAndSec}\";\n}\n\n//Procedural style\nfunction getUTCOffset($timezone)\n{\n $current = timezone_open($timezone);\n $utcTime = new \\DateTime('now', new \\DateTimeZone('UTC'));\n $offsetInSecs = timezone_offset_get( $current, $utcTime);\n $hoursAndSec = gmdate('H:i', abs($offsetInSecs));\n return stripos($offsetInSecs, '-') === false ? \"+{$hoursAndSec}\" : \"-{$hoursAndSec}\";\n}\n\n\n$timezone = 'America/Mexico_City';\n\necho \"Procedural style<br>\";\necho getUTCOffset($timezone); //-06:00\necho \"<br>\";\necho \"(UTC \" . getUTCOffset($timezone) . \") \" . $timezone; // (UTC -06:00) America/Mexico_City\necho \"<br>--------------<br>\";\necho \"Object oriented style<br>\";\necho getUTCOffset_OOP($timezone); //-06:00\necho \"<br>\";\necho \"(UTC \" . getUTCOffset_OOP($timezone) . \") \" . $timezone; // (UTC -06:00) America/Mexico_City\n"
},
{
"answer_id": 71776737,
"author": "Jesse",
"author_id": 10343144,
"author_profile": "https://Stackoverflow.com/users/10343144",
"pm_score": 2,
"selected": false,
"text": "+0200 -0400 echo date('O');\n <pubDate>Sat, 07 Sep 2002 00:00:01 -0500</pubDate>\n +02:00 date('P'); PDT CST"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/79/"
] |
193,514
|
<p>There is another recent Project Euler question but I think this is a bit more specific (I'm only really interested in PHP based solutions) so I'm asking anyway.</p>
<p><a href="http://projecteuler.net/index.php?section=problems&id=5" rel="nofollow noreferrer">Question #5</a> tasks you with: "What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?"</p>
<p>Now, I have solved it twice. Once very inefficiently and once much more efficiently but I am still far away from an especially sophisticated answer (and I am not especially solid in math hence my brute force solution). I can see a couple of areas where I could improve this but I am wondering if any of you could demonstrate a more efficient solution to this problem. </p>
<p>*spoiler: Here is my less than optimal (7 seconds to run) but still tolerable solution (not sure what to do about the double $... just pretend you only see 1...</p>
<pre><code> function euler5(){
$x = 20;
for ($y = 1; $y < 20; $y++) {
if (!($x%$y)) {
} else {
$x+=20;
$y = 1;
}
}echo $x;
};
</code></pre>
|
[
{
"answer_id": 193521,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 3,
"selected": false,
"text": "16 = 2**4 9 = 3**2"
},
{
"answer_id": 193566,
"author": "Czimi",
"author_id": 3906,
"author_profile": "https://Stackoverflow.com/users/3906",
"pm_score": 3,
"selected": true,
"text": "<?php\nfunction gcd($a,$b) {\n while($a>0 && $b>0) {\n if($a>$b) $a=$a-$b; else $b=$b-$a; \n }\n if($a==0) return $b;\n return $a;\n}\nfunction euler5($i=20) {\n $euler=$x=1;\n while($x++<$i) {\n $euler*=$x/gcd($euler,$x);\n }\n return $euler;\n}\n\n?>\n"
},
{
"answer_id": 193644,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 2,
"selected": false,
"text": "<?\nfunction eulerPuzzle()\n{\n $integers = array( 11,12,13,14,15,16,17,18,19 );\n\n for ($n = 20; 1; $n += 20 ) {\n foreach ($integers as $int) { \n if ( $n % $int ) { \n break; \n }\n if ( $int == 19 ) { \n die (\"Result:\" . $n); \n }\n }\n }\n}\n\neulerPuzzle();\n?>\n"
},
{
"answer_id": 193669,
"author": "Kirk Strauser",
"author_id": 32538,
"author_profile": "https://Stackoverflow.com/users/32538",
"pm_score": -1,
"selected": false,
"text": "#!/usr/bin/env python\n\nfrom operator import mul\n\ndef factor(n):\n factors = {}\n i = 2\n while i < n and n != 1:\n while n % i == 0:\n try:\n factors[i] += 1\n except KeyError:\n factors[i] = 1\n n = n / i\n i += 1\n if n != 1:\n factors[n] = 1\n return factors\n\nbase = {}\nfor i in range(2, 2000):\n for f, n in factor(i).items():\n try:\n base[f] = max(base[f], n)\n except KeyError:\n base[f] = n\n\nprint reduce(mul, [f**n for f, n in base.items()], 1)\n"
},
{
"answer_id": 475010,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<?php\n$i=20;\nwhile ($i+=20) {\n for ($j=19;$j!==10;--$j){\n if ($i%$j) continue 2;\n }\n die (\"result: $i\\n\");\n}\n"
},
{
"answer_id": 1010761,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "puts 5*7*9*11*13*16*17*19\n"
},
{
"answer_id": 6262882,
"author": "Tjirp",
"author_id": 392851,
"author_profile": "https://Stackoverflow.com/users/392851",
"pm_score": 0,
"selected": false,
"text": "function eulerPuzzle() {\n $integers = array (11, 12, 13, 14, 15, 16, 17, 18, 19 );\n\n for($n = 2520; 1; $n += 2520) {\n foreach ( $integers as $int ) {\n if ($n % $int) {\n break;\n }\n if ($int == 19) {\n die ( \"Result:\" . $n );\n }\n }\n }\n}\n\neulerPuzzle ();\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11252/"
] |
193,536
|
<p>I know that JavaScript doesn't support macros (Lisp-style ones) but I was wondering if anyone had a solution to maybe simulate macros? I Googled it, and one of the solutions suggested using <code>eval()</code>, but as he said, would be quite costly.</p>
<p>They don't really have to be very fancy. I just want to do simple stuff with them. And it shouldn't make debugging significantly harder :)</p>
|
[
{
"answer_id": 1390694,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "function CPU_CP_A(R,C) { // this function simulates the CP instruction, \n return ''+ // sets CPU flags and stores in CCC the number\n 'FZ=(RA=='+R+');'+ // of cpu cycles needed\n 'FN=1;'+\n 'FC=RA<'+R+';'+\n 'FH=(RA&0x0F)<('+R+'&0x0F);'+\n 'ICC='+C+';';\n}\n OP[0xB8]=new Function(CPU_CP_A('RB',4)); // CP B\nOP[0xB9]=new Function(CPU_CP_A('RC',4)); // CP C\nOP[0xBA]=new Function(CPU_CP_A('RD',4)); // CP D\nOP[0xBB]=new Function(CPU_CP_A('RE',4)); // CP E\nOP[0xBC]=new Function('T1=HL>>8;'+CPU_CP_A('T1',4)); // CP H\nOP[0xBD]=new Function('T1=HL&0xFF;'+CPU_CP_A('T1',4)); // CP L\nOP[0xBE]=new Function('T1=MEM[HL];'+CPU_CP_A('T1',8)); // CP (HL)\nOP[0xBF]=new Function(CPU_CP_A('RA',4)); // CP A\n OP[MEM[PC]](); // MEM is an array of bytes and PC the program counter\n"
},
{
"answer_id": 1624176,
"author": "Volodymyr M. Lisivka",
"author_id": 196559,
"author_profile": "https://Stackoverflow.com/users/196559",
"pm_score": 3,
"selected": false,
"text": "function unless(condition,body) {\n return 'if(! '+condition.toSource()+'() ) {' + body.toSource()+'(); }';\n}\n\n\neval(unless( function() {\n return false;\n }, function() {\n alert(\"OK\");\n}));\n"
},
{
"answer_id": 14167673,
"author": "Anderson Green",
"author_id": 975097,
"author_profile": "https://Stackoverflow.com/users/975097",
"pm_score": 5,
"selected": false,
"text": "function def"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13995/"
] |
193,540
|
<p>Has anyone ever given table columns the "fisheye" effect? Im talking about an expanding effect of the table columns when hovering the mouse over them. I'd love to see some code if anyone has tried this.</p>
<p>EDIT: ...or an accordian effect</p>
|
[
{
"answer_id": 193857,
"author": "Wayne",
"author_id": 8236,
"author_profile": "https://Stackoverflow.com/users/8236",
"pm_score": 2,
"selected": false,
"text": "<html>\n<head>\n<script type=\"text/javascript\" src=\"jquery.js\"></script>\n<script type=\"text/javascript\">\n$(document).ready(function() {\n $(\"#table > div:even\").addClass(\"row\");\n $(\"#table > div:odd\").addClass(\"altrow\");\n $(\"#table > div > div\").addClass(\"normal\");\n $(\"div[class*='col']\").hover(\n function () {\n var myclass = $(this).attr(\"class\");\n $(\"div[class*='col']\").css(\"width\",\"20px\");\n $(\"div[class*='\"+myclass+\"']\").css(\"width\",\"80px\").css(\"overflow\",\"auto\");\n }, \n function () {\n $(\"div[class*='col']\").css(\"width\",\"40px\").css(\"overflow\",\"hidden\");\n }\n )\n });\n</script>\n<style type=\"text/css\">\n.row{\n background-color: #eee;\n float:left;\n}\n.altrow{\n background-color: #fff;\n float:left;\n}\n.normal{\n width: 40px;\n overflow: hidden;\n float:left;\n padding :3px;\n text-align:center;\n}\n</style>\n</head>\n<body>\n<div id=\"table\">\n <div>\n <div class=\"col1\">Column1</div>\n <div class=\"col2\">Column2</div>\n <div class=\"col3\">Column3</div>\n </div>\n <br style=\"clear:both\" />\n <div>\n <div class=\"col1\">Column1</div>\n <div class=\"col2\">Column2</div>\n <div class=\"col3\">Column3</div>\n </div>\n <br style=\"clear:both\" />\n <div>\n <div class=\"col1\">Column1</div>\n <div class=\"col2\">Column2</div>\n <div class=\"col3\">Column3</div>\n </div>\n</div>\n</body>\n</html>\n"
},
{
"answer_id": 196821,
"author": "AquilaX",
"author_id": 17734,
"author_profile": "https://Stackoverflow.com/users/17734",
"pm_score": 0,
"selected": false,
"text": " <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n <html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n <head>\n <style>\n table{\n width: 150px;\n height: 150px;\n }\n tr{\n height: 20px;\n }\n tr:hover{\n height: 30px;\n }\n td{\n width: 20px;\n border: 1px solid black;\n text-align:center;\n }\n td:hover{\n width: 30px;\n }\n\n </style>\n\n </head>\n\n <body>\n <table>\n <tr>\n <td>1</td>\n <td>2</td>\n <td>3</td>\n <td>4</td>\n </tr>\n <tr>\n <td>1</td>\n <td>2</td>\n <td>3</td>\n <td>4</td>\n </tr>\n <tr>\n <td>1</td>\n <td>2</td>\n <td>3</td>\n <td>4</td>\n </tr>\n <tr>\n <td>1</td>\n <td>2</td>\n <td>3</td>\n <td>4</td>\n </tr>\n </table>\n </body>\n </html>\n"
},
{
"answer_id": 202632,
"author": "GameFreak",
"author_id": 26659,
"author_profile": "https://Stackoverflow.com/users/26659",
"pm_score": 1,
"selected": false,
"text": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/2001/REC-xhtml11-20010531/DTD/xhtml11-flat.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n <head>\n <title>Example</title>\n <style type=\"text/css\">\n td {\n border: thin black solid;\n width: 3em;\n height: 3em;\n }\n\n td:hover {\n background-color: red;\n width: 5em;\n\n /*height: 5em;*/\n /*uncomment the above if you also want to zoom the rows*/\n }\n </style>\n </head>\n <body>\n <table>\n <tr>\n <td>1</td>\n <td>2</td>\n <td>3</td>\n <td>4</td>\n </tr>\n <tr>\n <td>1</td>\n <td>2</td>\n <td>3</td>\n <td>4</td>\n </tr>\n <tr>\n <td>1</td>\n <td>2</td>\n <td>3</td>\n <td>4</td>\n </tr>\n <tr>\n <td>1</td>\n <td>2</td>\n <td>3</td>\n <td>4</td>\n </tr>\n </table>\n </body>\n </html>\n"
},
{
"answer_id": 16170885,
"author": "Berteh",
"author_id": 1694411,
"author_profile": "https://Stackoverflow.com/users/1694411",
"pm_score": 0,
"selected": false,
"text": " td {\n border: thin black solid;\n width: 3em;\n }\n td:hover {\n background-color: YellowGreen;\n max-width: 5em;\n font-size: 130%;\n }\n $(document).ready(function() {\n $('td').hover(function () {\n $(this).find('.desc').toggle(300);\n });\n});\n <table>\n <tr>\n <th>row1</th>\n <td>1<div class=\"desc\">descZ</div></td>\n <td>2<div class=\"desc\">descU</div></td>\n <td>3<div class=\"desc\">descI</div></td>\n <td>4<div class=\"desc\">descO</div></td>\n </tr>\n\n <tr>\n <th>row2</th>\n <td>1<div class=\"desc\">descZ</div></td>\n <td>2<div class=\"desc\">descU</div></td>\n <td>3<div class=\"desc\">descI</div></td>\n <td>4<div class=\"desc\">descO</div></td>\n </tr>\n</table>\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16435/"
] |
193,547
|
<p>I have stumbled into several methods of looping in JavaScript, what I like the most is:</p>
<pre><code>for(var i = 0; i < a.length; i++){
var element = a[i];
}
</code></pre>
<p>But as tested here (<a href="http://www.robertnyman.com/2008/04/11/javascript-loop-performance/" rel="noreferrer">http://www.robertnyman.com/2008/04/11/javascript-loop-performance/</a>), it should probably be written so that the length is only calculated once. </p>
<p>In jQuery there is a .each that you can stick a function. I like this a little better, because I don't have to type the array twice, like in the above solution. </p>
<p>If JavaScript supported macros it would be a piece of cake to roll your own, but sadly it does not. </p>
<p>So what do you guys use?</p>
|
[
{
"answer_id": 193553,
"author": "Kibbee",
"author_id": 1862,
"author_profile": "https://Stackoverflow.com/users/1862",
"pm_score": 2,
"selected": false,
"text": "Var max = a.length-1;\nvar i = 0;\n\nwhile(i <= max)\n{\nvar element = a[i];\ni++;\n}\n"
},
{
"answer_id": 193563,
"author": "Ash",
"author_id": 5023,
"author_profile": "https://Stackoverflow.com/users/5023",
"pm_score": 6,
"selected": true,
"text": "function createIterator(x) {\n var i = 0;\n\n return function(){\n return x[i++];\n };\n}\n var iterator=createIterator(['a','b','c','d','e','f','g']);\n\niterator();\n iterator();\n var current;\n\nwhile((current=iterator())!==undefined)\n{\n console.log(current);\n}\n"
},
{
"answer_id": 193584,
"author": "Chase Seibert",
"author_id": 7679,
"author_profile": "https://Stackoverflow.com/users/7679",
"pm_score": 3,
"selected": false,
"text": "for(var i = 0, len = a.length; i < len; i++){ var element = a[i]; }\n for (i in a) { var element = a[i]; }\n"
},
{
"answer_id": 193595,
"author": "Randy Sugianto 'Yuku'",
"author_id": 11238,
"author_profile": "https://Stackoverflow.com/users/11238",
"pm_score": 3,
"selected": false,
"text": " var len = a.length;\n for (var i = 0; i < len; i++) {\n var element = a[i];\n }\n"
},
{
"answer_id": 194437,
"author": "Mr. Muskrat",
"author_id": 2657951,
"author_profile": "https://Stackoverflow.com/users/2657951",
"pm_score": 1,
"selected": false,
"text": " var i = a.length;\n while( --i >= 0 ) {\n var element = a[i];\n // do stuff with element\n } \n"
},
{
"answer_id": 195303,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 1,
"selected": false,
"text": "var myArray = [1,2,3,4];\nfor (var i = 0, item; item = myArray[i]; ++i) {\n alert(item);\n}\n (item = myArray[i]) != undefined"
},
{
"answer_id": 201580,
"author": "Remy Sharp",
"author_id": 22617,
"author_profile": "https://Stackoverflow.com/users/22617",
"pm_score": 3,
"selected": false,
"text": "var i = a.length, element = null;\nwhile (i--) {\n element = a[i];\n}\n"
},
{
"answer_id": 422566,
"author": "meouw",
"author_id": 12161,
"author_profile": "https://Stackoverflow.com/users/12161",
"pm_score": 0,
"selected": false,
"text": "var x;\nvar a = [];\n// filling array\nvar t0 = new Date().getTime();\nfor( var i = 0; i < 100000; i++ ) {\n a[i] = Math.floor( Math.random()*100000 );\n}\n\n// normal loop\nvar t1 = new Date().getTime();\nfor( var i = 0; i < 100000; i++ ) {\n x = a[i];\n}\n\n// using length\nvar t2 = new Date().getTime();\nfor( var i = 0; i < a.length; i++ ) {\n x = a[i];\n}\n\n// storing length (pollution - we now have a global l as well as an i )\nvar t3 = new Date().getTime();\nfor( var i = 0, l = a.length; i < l; i++ ) {\n x = a[i];\n}\n\n// for in\nvar t4 = new Date().getTime();\nfor( var i in a ) {\n x = a[i];\n}\n\n// checked for in\nvar t5 = new Date().getTime();\nfor( var i in a ) {\n if (a.hasOwnProperty(i)) {\n x = a[i];\n }\n}\n\nvar t6 = new Date().getTime();\nvar msg = 'filling array: '+(t1-t0)+'ms\\n'+\n 'normal loop: '+(t2-t1)+'ms\\n'+\n 'using length: '+(t3-t2)+'ms\\n'+\n 'storing length: '+(t4-t3)+'ms\\n'+\n 'for in: '+(t5-t4)+'ms\\n'+\n 'checked for in: '+(t6-t5)+'ms';\nconsole.log( msg );\n filling array: 227ms\nnormal loop: 21ms\nusing length: 26ms\nstoring length: 24ms \nfor in: 154ms\nchecked for in: 176ms\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13995/"
] |
193,560
|
<p>Intuitively, it would seems that a compiler for language <code>Foo</code> cannot itself be written in Foo. More specifically, the <em>first</em> compiler for language <code>Foo</code> cannot be written in Foo, but any subsequent compiler could be written for <code>Foo</code>.</p>
<p>But is this actually true? I have some very vague recollection of reading about a language whose first compiler was written in "itself". Is this possible, and if so how?</p>
|
[
{
"answer_id": 193832,
"author": "Federico A. Ramponi",
"author_id": 18770,
"author_profile": "https://Stackoverflow.com/users/18770",
"pm_score": 6,
"selected": false,
"text": "make bootstrap\n"
},
{
"answer_id": 256679,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": false,
"text": "Reflection.Emit"
},
{
"answer_id": 486980,
"author": "Aaron Digulla",
"author_id": 34088,
"author_profile": "https://Stackoverflow.com/users/34088",
"pm_score": 6,
"selected": false,
"text": "\\n \\r ...\nif (c == 92) { // backslash\n c = getc();\n if (c == 110) { // n\n return 10;\n } else if (c == 92) { // another backslash\n return 92;\n } else {\n ...\n }\n}\n...\n ...\nif (c == '\\\\') {\n c = getc();\n if (c == 'n') {\n return '\\n';\n } else if (c == '\\\\') {\n return '\\\\';\n } else {\n ...\n }\n}\n...\n void compileFunction(char * name, char * filename, char * code) {\n if (strcmp(\"compileFunction\", name) == 0 && strcmp(\"compile.c\", filename) == 0) {\n code = A;\n } else if (strcmp(\"xxx\", name) == 0 && strcmp(\"yyy.c\", filename) == 0) {\n code = B;\n }\n\n ... code to compile the function body from the string in \"code\" ...\n}\n compileFunction"
},
{
"answer_id": 59432473,
"author": "G K",
"author_id": 1421655,
"author_profile": "https://Stackoverflow.com/users/1421655",
"pm_score": 3,
"selected": false,
"text": " ADD\n / \\\n MPY 3\n / \\\n5 x\n [ADD,[MPY,5,x],3]\n ADD[MPY[5,x],3]\n <NAME>(<unparse>)=><action>;\n (<unparse>)=><action>;\n ...\n (<unparse>)=><action>;\n expr_gen(ADD[expr_gen(x),expr_gen(y)])=> x+y;\n expr_gen(#node[expr_gen(x),expr_gen(y)])=> #action;\n\n node: ADD, SUB, MPY, DIV;\n action: x+y, x-y, x*y, x/y;\n\n (NUMBER(x))=> x;\n (SYMBOL(x))=> val:(x);\n .MACHOP #opnm register,@indirect offset (index): // Instruction's parameters.\n.MORG 36, O(18): $/36; // Align to 36 bit boundary print format: 18 bit octal $/36\nO(9): #opcd; // Op code 9 bit octal print out\n (4): register; // 4 bit register field appended print\n (1): indirect; // 1 bit appended print\n (4): index; // 4 bit index register appended print\nO(18): if (#opcd&&3==1) offset // immediate mode use value else\n else offset/36; // memory address divide by 36\n // to get word address.\n// Vectored entry opcode table:\n#opnm := MOVE, MOVEI, MOVEM, MOVES, MOVS, MOVSI, MOVSM, MOVSS,\n MOVN, MOVNI, MOVNM, MOVNS, MOVM, MOVMI, MOVMM, MOVMS,\n IMUL, IMULI, IMULM, IMULB, MUL, MULI, MULM, MULB,\n ...\n TDO, TSO, TDOE, TSOE, TDOA, TSOA, TDON, TSON;\n// corresponding opcode value:\n#opcd := 0O200, 0O201, 0O202, 0O203, 0O204, 0O205, 0O206, 0O207,\n 0O210, 0O211, 0O212, 0O213, 0O214, 0O215, 0O216, 0O217,\n 0O220, 0O221, 0O222, 0O223, 0O224, 0O225, 0O226, 0O227,\n ...\n 0O670, 0O671, 0O672, 0O673, 0O674, 0O675, 0O676, 0O677;\n 400020 201082 000005 MOVEI r1,5(r2)\n <name> <formula type operator> <expression> ;\n /* Character Class Formula class_mask */\nbin: '0'|'1'; // 0b00000010\noct: bin|'2'|'3'|'4'|'5'|'6'|'7'; // 0b00000110\ndgt: oct|'8'|'9'; // 0b00001110\nhex: dgt|'A'|'B'|'C'|'D'|'E'|'F'|'a'|'b'|'c'|'d'|'e'|'f'; // 0b00011110\nupr: 'A'|'B'|'C'|'D'|'E'|'F'|'G'|'H'|'I'|'J'|'K'|'L'|'M'|\n 'N'|'O'|'P'|'Q'|'R'|'S'|'T'|'U'|'V'|'W'|'X'|'Y'|'Z'; // 0b00100000\nlwr: 'a'|'b'|'c'|'d'|'e'|'f'|'g'|'h'|'i'|'j'|'k'|'l'|'m'|\n 'n'|'o'|'p'|'q'|'r'|'s'|'t'|'u'|'v'|'w'|'x'|'y'|'z'; // 0b01000000\nalpha: upr|lwr; // 0b01100000\nalphanum: alpha|dgt; // 0b01101110\n test byte ptr [eax+_classmap],dgt\n jne <success>\n je <failure>\n string .. (''' .ANY ''' | '\"' $(-\"\"\"\" .ANY | \"\"\"\"\"\",\"\"\"\") '\"') MAKSTR[];\n -\"\"\"\" .ANY\n \"\"\"\"\"\",\"\"\"\"\n number .. \"0B\" bin $bin MAKBIN[] // binary integer\n |\"0O\" oct $oct MAKOCT[] // octal integer\n |(\"0H\"|\"0X\") hex $hex MAKHEX[] // hexadecimal integer\n// look for decimal number determining if integer or floating point.\n | ('+'|+'-'|--) // only - matters\n dgt $dgt // integer part\n ( +'.' $dgt // fractional part?\n ((+'E'|'e','E') // exponent part\n ('+'|+'-'|--) // Only negative matters\n dgt(dgt(dgt|--)|--)|--) // 1 2 or 3 digit exponent\n MAKFLOAT[] ) // floating point\n MAKINT[]; // decimal integer\n (a b | c d)\\ e\n :<node name> creates a node object and pushes it onto the node stack.\n.. Token formula create token objects and push them onto \n the parse stack.\n!<number> pops the top node object and top <number> of parstack \n entries into a list representation of the tree. The \n tree then pushed onto the parse stack.\n+[ ... ]+ creates a list of the parse stack entries created \n between them:\n '(' +[argument $(',' argument]+ ')'\n could parse an argument list. into a list.\n Exp = Term $(('+':ADD|'-':SUB) Term!2); \nTerm = Factor $(('*':MPY|'/':DIV) Factor!2);\nFactor = ( number\n | id ( '(' +[Exp $(',' Exp)]+ ')' :FUN!2\n | --)\n | '(' Exp ')\" )\n (^' Factor:XPO!2 |--);\n d^(x+5)^3-a+b*c => ADD[SUB[EXP[EXP[d,ADD[x,5]],3],a],MPY[b,c]]\n\n ADD\n / \\\n SUB MPY\n / \\ / \\\n EXP a b c\n / \\\n d EXP \n / \\\n ADD 3\n / \\\n x 5\n program = $((declaration // A program is a sequence of\n // declarations terminated by\n |.EOF .STOP) // End Of File finish & stop compile\n \\ // Backtrack: .EOF failed or\n // declaration long-failed.\n (ERRORX[\"?Error?\"] // report unknown error\n // flagging furthest parse point.\n $(-';' (.ANY // find a ';'. skiping .ANY\n | .STOP)) // character: .ANY fails on end of file\n // so .STOP ends the compile.\n // (-';') failing breaks loop.\n ';')); // Match ';' and continue\n\ndeclaration = \"#\" directive // Compiler directive.\n | comment // skips comment text\n | global DECLAR[*1] // Global linkage\n |(id // functions starting with an id:\n ( formula PARSER[*1] // Parsing formula\n | sequencer GENERATOR[*1] // Code generator\n | optimizer ISO[*1] // Optimizer\n | pseudo_op PRODUCTION[*1] // Pseudo instruction\n | emitor_op MACHOP[*1] // Machine instruction\n ) // All the above start with an identifier\n \\ (ERRORX[\"Syntax error.\"]\n garbol); // skip over error.\n formula = (\"==\" syntax :BCKTRAK // backtrack grammar formula\n |'=' syntax :SYNTAX // grammar formula.\n |':' chclass :CLASS // character class define\n |\"..\" token :TOKEN // token formula\n )';' !2 // Combine node name with id \n // parsed in calling declaration \n // formula and tree produced\n // by the called syntax, token\n // or character class formula.\n $(-(.NL |\"/*\") (.ANY|.STOP)); Comment ; to line separator?\n\nchclass = +[ letter $('|' letter) ]+;// a simple list of character codes\n // except \nletter = char | number | id; // when including another class\n\nsyntax = seq ('|' alt1|'\\' alt2 |--);\n\nalt1 = seq:ALT!2 ('|' alt1|--); Non-backtrack alternative sequence.\n\nalt2 = seq:BKTK!2 ('\\' alt2|--); backtrack alternative sequence\n\nseq = +[oper $oper]+;\n\noper = test | action | '(' syntax ')' | comment; \n\ntest = string | id ('[' (arg_list| ,NILL) ']':GENCALL!2|.EMPTY);\n\naction = ':' id:NODE!1\n | '!' number:MAKTREE!1\n | \"+[\" seq \"]+\" :MAKLST!1;\n\n// C style comments\ncomment = \"//\" $(-.NL .ANY)\n | \"/*\" $(-\"*/\" .ANY) \"*/\";\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] |
193,561
|
<p>I have managed to create an <a href="http://docs.sencha.com/ext-js/3-4/#!/api/Ext.tree.TreeNode" rel="nofollow noreferrer">Ext.tree.TreePanel</a> that loads child nodes dynamically, but I'm having a difficult time clearing the tree and loading it with new data. Can someone help me with the code to do this?</p>
|
[
{
"answer_id": 193617,
"author": "slmcmahon",
"author_id": 26233,
"author_profile": "https://Stackoverflow.com/users/26233",
"pm_score": 1,
"selected": false,
"text": "if (tree)\n{\n var delNode;\n while (delNode = tree.root.childNodes[0])\n tree.root.removeChild(delNode);\n}\n"
},
{
"answer_id": 193678,
"author": "eyelidlessness",
"author_id": 17964,
"author_profile": "https://Stackoverflow.com/users/17964",
"pm_score": -1,
"selected": false,
"text": "if (tree) { var delNode; while (delNode = tree.root.childNodes[0]) tree.root.removeChild(delNode); }\n tree.root.immediateDescendants().invoke('remove'); // or\ntree.root.select('> *').invoke('remove');\n tree.root"
},
{
"answer_id": 194734,
"author": "Joel Mueller",
"author_id": 24380,
"author_profile": "https://Stackoverflow.com/users/24380",
"pm_score": 2,
"selected": false,
"text": "tree.getRootNode().reload();\n"
},
{
"answer_id": 649801,
"author": "jDempster",
"author_id": 78504,
"author_profile": "https://Stackoverflow.com/users/78504",
"pm_score": 3,
"selected": false,
"text": "while (node.firstChild) {\n node.removeChild(node.firstChild);\n}\n"
},
{
"answer_id": 1412677,
"author": "J Sidhu",
"author_id": 111641,
"author_profile": "https://Stackoverflow.com/users/111641",
"pm_score": 0,
"selected": false,
"text": "listeners: {\n collapsenode: function(node){\n node.loaded = false;\n},\n"
},
{
"answer_id": 6573037,
"author": "Farish",
"author_id": 346880,
"author_profile": "https://Stackoverflow.com/users/346880",
"pm_score": 2,
"selected": false,
"text": "getCmp('treeId').getStore().load();\n getCmp('treeId').getRootNode().removeAll();\n"
},
{
"answer_id": 17356169,
"author": "zzg",
"author_id": 1982267,
"author_profile": "https://Stackoverflow.com/users/1982267",
"pm_score": 1,
"selected": false,
"text": "node.removeAll()"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26233/"
] |
193,593
|
<p>I have a small financial application with PHP as the front end and MySQL as the back end. I have ancient prejudices, and I store money values in MySQL as an integer of cents. My HTML forms allow input of dollar values, like "156.64" and I use PHP to convert that to cents and then I store the cents in the database.</p>
<p>I have a function that both cleans the dollar value from the form, and converts it to cents. I strip leading text, I strip trailing text, I multiply by 100 and convert to an integer. That final step is</p>
<p><code>$cents = (integer) ($dollars * 100);</code></p>
<p>This works fine for almost everything, except for a very few values like '156.64' which consistently converts to 15663 cents. Why does it do this?</p>
<p>If I do this:</p>
<p><code>$cents = (integer) ($dollars * 100 + 0.5);</code></p>
<p>then it consistently works. Why do I need to add that rounding value?</p>
<p>Also, my prejudices about storing money amounts as integers and not floating point values, is that no longer needed? Will modern float calculations produce nicely rounded and accurate money values adequate for keeping 100% accurate accounting?</p>
|
[
{
"answer_id": 193621,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 2,
"selected": false,
"text": "DECIMAL NUMERIC MONEY"
},
{
"answer_id": 193650,
"author": "Steve Clay",
"author_id": 3779,
"author_profile": "https://Stackoverflow.com/users/3779",
"pm_score": 2,
"selected": false,
"text": "round() (int)3.99 3 (int)-3.99 -3 round()"
},
{
"answer_id": 196785,
"author": "Barry Austin",
"author_id": 27304,
"author_profile": "https://Stackoverflow.com/users/27304",
"pm_score": 2,
"selected": false,
"text": "list($bills, $pennies) = explode('.', $dollars);\n$cents = 100 * $bills + $pennies;\n"
},
{
"answer_id": 2064344,
"author": "Álvaro González",
"author_id": 13508,
"author_profile": "https://Stackoverflow.com/users/13508",
"pm_score": 0,
"selected": false,
"text": "string int <?php\n// Quick ugly code not fully tested\n$input = '156.64';\n$output = NULL;\n\nif( preg_match('/\\d+(\\.\\d+)?/', $input) ){\n $tmp = explode('.', $input);\n switch( count($tmp) ){\n case 1:\n $output = $tmp[0];\n break;\n\n case 2:\n $output = $tmp[0] . substr($tmp[1], 0, 2);\n break;\n\n default:\n echo \"Invalid decimal\\n\";\n }\n}else{\n echo \"Invalid number\\n\";\n}\n\nvar_dump($output);\n\n?>\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13667/"
] |
193,602
|
<p>Does anyone know of a really simple way of publishing Java methods as web services? I don't really want the overhead of using Tomcat or Jetty or any of the other container frameworks.</p>
<p>Scenario: I've got a set of Java methods in a service type application that I want to access from other machines on the local LAN.</p>
|
[
{
"answer_id": 193623,
"author": "Simon Lehmann",
"author_id": 27011,
"author_profile": "https://Stackoverflow.com/users/27011",
"pm_score": 4,
"selected": true,
"text": "<service name=\"name of the service\" scope=\"<one of request, session or application>\">\n <description>\n optional description of your service\n </description>\n\n <messageReceivers>\n <messageReceiver mep=\"http://www.w3.org/2004/08/wsdl/in-only\" class=\"org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver\" />\n <messageReceiver mep=\"http://www.w3.org/2004/08/wsdl/in-out\" class=\"org.apache.axis2.rpc.receivers.RPCMessageReceiver\"/>\n </messageReceivers>\n\n <parameter name=\"ServiceClass\" locked=\"false\">put here the fully qualified name of your service class (e.g. x.y.z.FooService)</parameter>\n\n</service>\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/826/"
] |
193,603
|
<p>I'm looking for a simple file format to use for wireframe models. I am aware of VRML, u3D, etc, but these seem heavyweight for my needs. My criterea are:</p>
<ul>
<li>Must have a clear spec. Either open or very well established/documented.</li>
<li>I only need (want) simple models - vertices and edges. I don't want to handle faces or objects. If the format supports more, that's fine so long as I can ignore them.</li>
<li>End-user tools are not a requirement, but would be great. If not, it must be human readable (and editable for simple models).</li>
<li>It would be nice (but not necessary) to be able to annotate or at least label nodes.</li>
<li>It shouldn't matter what language I'm using, but probable options are Java/C++ & OpenGL</li>
</ul>
<p>Or am I just better writing vertices/edge lists to a text file and be done with it?</p>
|
[
{
"answer_id": 193633,
"author": "lajos",
"author_id": 3740,
"author_profile": "https://Stackoverflow.com/users/3740",
"pm_score": 3,
"selected": false,
"text": "v -0.500000 -0.000000 0.500000\nv 0.000000 -0.000000 0.500000\nv 0.500000 -0.000000 0.500000\nv -0.500000 0.000000 0.000000\nv 0.000000 0.000000 0.000000\nv 0.500000 0.000000 0.000000\nv -0.500000 0.000000 -0.500000\nv 0.000000 0.000000 -0.500000\nv 0.500000 0.000000 -0.500000\nv -0.500000 -0.000000 0.500000\nv 0.000000 -0.000000 0.500000\nv 0.500000 -0.000000 0.500000\nv -0.500000 0.000000 0.000000\nv 0.000000 0.000000 0.000000\nv 0.500000 0.000000 0.000000\nv -0.500000 0.000000 -0.500000\nv 0.000000 0.000000 -0.500000\nv 0.500000 0.000000 -0.500000\nf 1/1 2/2 5/5 4/4\nf 2/2 3/3 6/6 5/5\nf 4/4 5/5 8/8 7/7\nf 5/5 6/6 9/9 8/8\nf 10/10 11/11 14/14 13/13\nf 11/11 12/12 15/15 14/14\nf 13/13 14/14 17/17 16/16\nf 14/14 15/15 18/18 17/17\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26334/"
] |
193,629
|
<p>When I give Java and C large floats and doubles (in the billion range), they convert them to scientific notation, losing precision in the process. How can I stop this behavior?</p>
|
[
{
"answer_id": 193635,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 3,
"selected": false,
"text": "printf(\"%10f\", dbl);\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24391/"
] |
193,630
|
<p>I've implemented a few poor solutions for bringing up an AJAX loader before dynamically updating a content DIV, but none seem to be "universal", and I find each time I do it I'm reworking it. If I have a DIV with content that updates depending on what a user clicks on the page, and I want to display the loader over this content DIV, what is the best approach? I've seen some developers have the loader always on the page, and they just display it block or none, and I've seen others append it to the DIV. What about when you also have multiple areas that can update? I'm thinking something repeatable that I can call with a function, maybe passing a few parameters.</p>
|
[
{
"answer_id": 194262,
"author": "Dimitry",
"author_id": 27073,
"author_profile": "https://Stackoverflow.com/users/27073",
"pm_score": 3,
"selected": true,
"text": "Ajax.Responders.register({\n onCreate: function() {\n $('loader').show();\n Ajax.activeRequestCount++;\n },\n onComplete: function() {\n Ajax.activeRequestCount--;\n if (Ajax.activeRequestCount < 1) $('loader').hide();\n }\n});\n new FieldUpdateRequest(field) new Request(); new PartialRequest(div);"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
193,634
|
<p>Is it possible to create a footer div that sits at the bottom of a site regardless of how much information is present in the middle?</p>
<p>Currently the div I have is positioned depending on how much content i have in the body.</p>
<blockquote>
<h3>See also:</h3>
<p><a href="https://stackoverflow.com/questions/42294/how-do-you-get-the-footer-to-stay-at-the-bottom-of-a-web-page">How do you get the footer to stay at the bottom of a Web page?</a></p>
</blockquote>
|
[
{
"answer_id": 193637,
"author": "JasonS",
"author_id": 1865,
"author_profile": "https://Stackoverflow.com/users/1865",
"pm_score": 5,
"selected": true,
"text": ".d_footer\n{\n position:fixed;\n bottom:0px;\n background-color: #336699;\n width:100%;\n text-align:center;\n padding-top:5px;\n padding-bottom:5px;\n color:#ffffff;\n}\n"
},
{
"answer_id": 193655,
"author": "Jonathan Mueller",
"author_id": 13832,
"author_profile": "https://Stackoverflow.com/users/13832",
"pm_score": 2,
"selected": false,
"text": "clear: both"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17211/"
] |
193,651
|
<p>I've had my first go at writing a DLL in Delphi. So far so good. By using a typelib I've been able to pass Widestrings to and from the DLL without difficulty.</p>
<p>What's curious at the moment is that I'm using VB6 as the testbed, and every time I run a test within the IDE, the program runs and then the IDE process suddenly disappears from memory - no error messages, nothing. If I step through the code, everything works fine until I execute the last line, then the IDE disappears. </p>
<p>By contrast, when I compile the test to an EXE the program runs to its end, without error messages etc.</p>
<p>Has anyone had this problem before and is there an obvious solution that's staring me in the face?</p>
<p>Source code below, in case it matters:</p>
<p>-- project</p>
<pre><code>library BOSLAD;
uses
ShareMem,
SysUtils,
Classes,
BOSLADCode in 'BOSLADCode.pas';
exports
version,
DMesg,
foo;
{$R *.res}
begin
end.
</code></pre>
<p>-- unit</p>
<pre><code>unit BOSLADCode;
interface
function version() : Double; stdcall;
procedure DMesg(sText : WideString; sHead : WideString ); stdcall;
function foo() : PWideString; stdcall;
implementation
uses Windows;
function version() : Double;
var
s : String;
begin
result := 0.001;
end;
procedure DMesg( sText : WideString; sHead : WideString);
begin
Windows.MessageBoxW(0, PWideChar(sText), PWideChar(sHead), 0);
end;
function foo() : PWideString;
var s : WideString;
begin
s := 'My dog''s got fleas';
result := PWideString(s);
end;
end.
</code></pre>
<p>-- typelib</p>
<pre><code> // This is the type library for BOSLAD.dll
[
// Use GUIDGEN.EXE to create the UUID that uniquely identifies
// this library on the user's system. NOTE: This must be done!!
uuid(0C55D7DA-0840-40c0-B77C-DC72BE9D109E),
// This helpstring defines how the library will appear in the
// References dialog of VB.
helpstring("BOSLAD TypeLib"),
// Assume standard English locale.
lcid(0x0409),
// Assign a version number to keep track of changes.
version(1.0)
]
library BOSLAD
{
// Now define the module that will "declare" your C functions.
[
helpstring("Functions in BOSLAD.DLL"),
version(1.0),
// Give the name of your DLL here.
dllname("BOSLAD.dll")
]
module BOSLADFunctions
{
[helpstring("version"), entry("version")] void __stdcall version( [out,retval] double* res );
[helpstring("DMesg"), entry("DMesg")] void __stdcall DMesg( [in] BSTR msg, [in] BSTR head );
[helpstring("foo"), entry("foo")] void __stdcall foo( [out,retval] BSTR* msg );
} // End of Module
}; // End of Library
</code></pre>
<hr>
<p>I moved the declaration of the WideString outside of the function in which I had declared it, in the expectation that that would increase the lifetime of the variable to longer than just the lifetime of the <code>foo</code> function. It made no difference whatsoever.</p>
<p>Likewise I commented out of the VB6 the call to the <code>foo</code> function. That made no difference either. No matter what I do, VB6 IDE dies after the last line of code is executed.</p>
<p>Something apart from pointers to local variables is the cause. But what?</p>
|
[
{
"answer_id": 193774,
"author": "GSerg",
"author_id": 11683,
"author_profile": "https://Stackoverflow.com/users/11683",
"pm_score": 2,
"selected": false,
"text": "result := PWideString(s);\n"
},
{
"answer_id": 193972,
"author": "Hugh Allen",
"author_id": 15069,
"author_profile": "https://Stackoverflow.com/users/15069",
"pm_score": 2,
"selected": true,
"text": "result := PWideString(s);\n function foo() : PWideString;\nconst s : WideString = 'My dog''s got fleas';\nbegin\n result := PWideString(s);\nend;\n"
},
{
"answer_id": 194173,
"author": "bugmagnet",
"author_id": 426,
"author_profile": "https://Stackoverflow.com/users/426",
"pm_score": 1,
"selected": false,
"text": "BORLNDMM.DLL"
},
{
"answer_id": 203706,
"author": "bugmagnet",
"author_id": 426,
"author_profile": "https://Stackoverflow.com/users/426",
"pm_score": 0,
"selected": false,
"text": "library BOSLAD;\nuses\n BOSLADCode in 'BOSLADCode.pas';\nexports\n version,\n DMesg,\n foo;\n{$R *.res}\nbegin\nend.\n unit BOSLADCode;\n\ninterface\n function version() : Double; stdcall;\n procedure DMesg(sText : PWideChar; sHead : PWideChar ); stdcall;\n function foo() : PWideChar; stdcall;\n\nimplementation\n uses Windows;\n\n var s : WideString;\n\n function version() : Double;\n begin\n result := 0.001;\n end;\n\n procedure DMesg( sText : PWideChar; sHead : PWideChar);\n begin\n Windows.MessageBoxW(0, sText, sHead, 0);\n end;\n\n function foo() : PWideChar;\n begin\n s := 'My dog''s got fleas';\n result := PWideChar(s);\n end;\nend.\n // This is the type library for BOSLAD.dll\n[\nuuid(0C55D7DA-0840-40c0-B77C-DC72BE9D109E),\nhelpstring(\"BOSLAD TypeLib\"),\nlcid(0x0409),\nversion(1.0)\n]\nlibrary BOSLAD\n{\n[\nhelpstring(\"Functions in BOSLAD.DLL\"),\nversion(1.0),\ndllname(\"BOSLAD.dll\")\n]\nmodule BOSLADFunctions\n{\n[helpstring(\"version\"), entry(\"version\")] \n void __stdcall version( [out,retval] double* res );\n[helpstring(\"DMesg\"), entry(\"DMesg\")] \n void __stdcall DMesg( [in] BSTR msg, [in] BSTR head );\n[helpstring(\"foo\"), entry(\"foo\")] \n void __stdcall foo( [out,retval] BSTR* msg );\n} \n}; \n Sub Main()\n Dim cfg As New CFGProject.cfg\n cfg.Load \"test.cfg\"\n Dim s As String\n s = cfg.Recall(\"msg\")\n DMesg s, \"\" & version\n s = foo\n DMesg s, \"\" & version\nEnd Sub\n msg=毅訜訝\n"
},
{
"answer_id": 212746,
"author": "bugmagnet",
"author_id": 426,
"author_profile": "https://Stackoverflow.com/users/426",
"pm_score": 0,
"selected": false,
"text": "news:comp.lang.pascal.delphi.misc library BOSLAD;\n\nuses\n BOSLADCode in 'BOSLADCode.pas';\n\nexports\n version,\n DMesg,\n foo;\n{$R *.res}\n\nbegin\nend.\n unit BOSLADCode;\n\ninterface\n function version() : Double; stdcall;\n procedure DMesg(const sText : WideString; const sHead : WideString ); stdcall;\n function foo() : PWideChar; stdcall;\n\nimplementation\n uses Windows, ActiveX;\n\n\n function version() : Double;\n begin\n result := 0.001;\n end;\n\n procedure DMesg( const sText : WideString; const sHead : WideString);\n begin\n Windows.MessageBoxW(0, PWideChar(sText), PWideChar(sHead), 0);\n end;\n\n function foo() : PWideChar;\n var s : WideString;\n begin\n s := 'My dog''s got fleas';\n result := SysAllocString(PWideChar(s));\n end;\nend.\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/426/"
] |
193,656
|
<p>Can I put the painter into the class variables? :</p>
<pre><code>protected:
QPainter *myPainter;
...
void MyWidget::paintEvent(QPaintEvent *event)
{
myPainter = new QPainter(this);
</code></pre>
|
[
{
"answer_id": 193658,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "void MyWidget::paintEvent(QPaintEvent *event)\n{\n QPainter painter(this);\n // use painter\n ...\n // paint object automatically closes and paint on desctruction\n}\n"
},
{
"answer_id": 232165,
"author": "Caleb Huitt - cjhuitt",
"author_id": 9876,
"author_profile": "https://Stackoverflow.com/users/9876",
"pm_score": 3,
"selected": true,
"text": "Foo::paintEvent() Foo::m_painter_p Foo::paintEvent() Foo::paintAntarticaFlag() Foo::paintAntarticaFlag() Foo::m_painter_p Foo::update() Foo::m_painter_p Foo::update()"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19884/"
] |
193,663
|
<p>Classic ASP had 'server side includes' so that one could easily design a generic layout for the header, footer, left or right side bar.</p>
<p>In ASP.NET, I think we must use 'Page Templates'. Although most people say that it is easy to use, I find it rather complicated, as we must copy the whole HTML code inside the 'Render' function. Is there a simpler method? Can I load the code from a HTML file instead pasting the whole code in the 'Render' function?</p>
<p>Or is there any better alternative to 'Page Templates'?</p>
|
[
{
"answer_id": 193725,
"author": "Rajeshwaran S P",
"author_id": 21995,
"author_profile": "https://Stackoverflow.com/users/21995",
"pm_score": 0,
"selected": false,
"text": "<asp:content id='page_contents'>"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15065/"
] |
193,686
|
<p>I enabled PHP5 on my website and my webhost needs me to add the following to .htaccess files for PHP5 to work:</p>
<blockquote>
<p>AddHandler application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml<br>
AddType application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml </p>
</blockquote>
<p>Locally, I am running XAMPP to develop code, but XAMPP does not want to work with the .htaccess file above.</p>
<p>I think it is an issue with XAMPP not recognizing php5 (but it does recognize php if I use "application/x-httpd-php" instead of "application/x-httpd-php5")</p>
<p>How do I resolve this?! I need the .htaccess files to look like above so they work with my webhost, but I need XAMPP to work locally with the same files without making changes!</p>
|
[
{
"answer_id": 194006,
"author": "Kornel",
"author_id": 27009,
"author_profile": "https://Stackoverflow.com/users/27009",
"pm_score": 2,
"selected": false,
"text": "<IfDefine> AddType <IfDefine !MyServer>\nAddType application/x-httpd-php5 .php5 …\n…\n</IfDefine>\n apachectl -D MyServer\n"
},
{
"answer_id": 692232,
"author": "Steve Clay",
"author_id": 3779,
"author_profile": "https://Stackoverflow.com/users/3779",
"pm_score": 0,
"selected": false,
"text": "<Directory />\n #existing stuff here...\n AccessFileName .htaccess.home\n</Directory>\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
193,701
|
<p>I am working on developing a pair of libraries to work with a REST API. Because I need to be able to use the API in very different settings I'm currently planning to have a version in PHP (for web applications) and a second version in Python (for desktop applications, and long running processes). Are there any best practices to follow in the development of the libraries to help maintain my own sanity?</p>
|
[
{
"answer_id": 193709,
"author": "Daniel Spiewak",
"author_id": 9815,
"author_profile": "https://Stackoverflow.com/users/9815",
"pm_score": 0,
"selected": false,
"text": "MyCompany::Foo bar_baz() com.mycompany.rest.Foo barBaz()"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24215/"
] |
193,703
|
<p>recently I've been reading through Scott Meyers's excellent <a href="https://rads.stackoverflow.com/amzn/click/com/0321334876" rel="noreferrer" rel="nofollow noreferrer">Effective C++</a> book. In one of the last tips he covered some of the features from TR1 - I knew many of them via Boost. </p>
<p>However, there was one that I definitely did NOT recognize: tr1::reference_wrapper. </p>
<p>How and when would I use tr1::reference_wrapper?</p>
|
[
{
"answer_id": 193752,
"author": "Nick",
"author_id": 26240,
"author_profile": "https://Stackoverflow.com/users/26240",
"pm_score": 5,
"selected": true,
"text": "void Increment( int& iValue )\n{\n iValue++;\n}\n\nint iVariable = 0;\nboost::function< void () > fIncrementMyVariable = boost::bind( &Increment, boost::ref( iVariable ));\n\nfIncrementMyVariable();\n"
},
{
"answer_id": 1011382,
"author": "amit kumar",
"author_id": 19501,
"author_profile": "https://Stackoverflow.com/users/19501",
"pm_score": 4,
"selected": false,
"text": "reference_wrapper<T> reference_wrapper<T> reference_wrapper<T> reference_wrapper<T> T->f() T.f() class A\n{\n //...\n};\n\nclass B\n{\n public:\n void setA(A& a) \n {\n a_ = boost::ref(a); // use boost::cref if using/storing const A&\n }\n A& getA()\n {\n return a_;\n }\n B(A& a): a_(a) {}\nprivate:\n boost::reference_wrapper<A> a_; \n};\n\nint main()\n{\n A a1;\n B b(a1);\n A a2;\n b.setA(a2);\n return 0;\n}\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14069/"
] |
193,707
|
<p>What is a preferred way to store recurring time windows? <br />
For example. If I have a calendar system where I need to be able to accommodate daily, weekly or monthly recurring events, what sort of time management system is best? <br /><br />
How is this best represented in a database? </p>
<p><strong>More Details</strong> <br />
The Specific goal of this is to provide sets of open time windows. Once we have these time windows, the code needs to test if a message that arrives to the system falls within one of the time windows.</p>
|
[
{
"answer_id": 193752,
"author": "Nick",
"author_id": 26240,
"author_profile": "https://Stackoverflow.com/users/26240",
"pm_score": 5,
"selected": true,
"text": "void Increment( int& iValue )\n{\n iValue++;\n}\n\nint iVariable = 0;\nboost::function< void () > fIncrementMyVariable = boost::bind( &Increment, boost::ref( iVariable ));\n\nfIncrementMyVariable();\n"
},
{
"answer_id": 1011382,
"author": "amit kumar",
"author_id": 19501,
"author_profile": "https://Stackoverflow.com/users/19501",
"pm_score": 4,
"selected": false,
"text": "reference_wrapper<T> reference_wrapper<T> reference_wrapper<T> reference_wrapper<T> T->f() T.f() class A\n{\n //...\n};\n\nclass B\n{\n public:\n void setA(A& a) \n {\n a_ = boost::ref(a); // use boost::cref if using/storing const A&\n }\n A& getA()\n {\n return a_;\n }\n B(A& a): a_(a) {}\nprivate:\n boost::reference_wrapper<A> a_; \n};\n\nint main()\n{\n A a1;\n B b(a1);\n A a2;\n b.setA(a2);\n return 0;\n}\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193707",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8880/"
] |
193,708
|
<p>I hear that tr1::result_of gets used frequently inside of Boost... I'm wondering if there are any good (simple) use cases for tr1::result_of I can use at home.</p>
|
[
{
"answer_id": 193803,
"author": "Lev",
"author_id": 7224,
"author_profile": "https://Stackoverflow.com/users/7224",
"pm_score": 2,
"selected": false,
"text": "BOOST_AUTO BOOST_AUTO(x, make_pair(a, b));\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14069/"
] |
193,715
|
<p>atoi() is giving me this error:</p>
<pre><code>
error C2664: 'atoi' : cannot convert parameter 1 from 'char' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
</code></pre>
<p>from this line:
int pid = atoi( token.at(0) );
where token is a vector</p>
<p>how can i go around this?</p>
|
[
{
"answer_id": 193717,
"author": "Jason Etheridge",
"author_id": 2193,
"author_profile": "https://Stackoverflow.com/users/2193",
"pm_score": 2,
"selected": false,
"text": "int pid = atoi(std::string(1, token.at(0)).c_str());\n"
},
{
"answer_id": 193722,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 4,
"selected": false,
"text": "int pid = token.at(0) - '0';\n"
},
{
"answer_id": 193749,
"author": "jfs",
"author_id": 4279,
"author_profile": "https://Stackoverflow.com/users/4279",
"pm_score": 1,
"selected": false,
"text": "stringstream ss;\nss << token.at(0);\nint pid = -1;\nss >> pid;\n #include <iostream>\n#include <sstream>\n#include <vector>\n\nint main()\n{\n using namespace std;\n\n vector<char> token(1, '8');\n\n stringstream ss;\n ss << token.at(0);\n int pid = -1;\n ss >> pid;\n if(!ss) {\n cerr << \"error: can't convert to int '\" << token.at(0) << \"'\" << endl; \n }\n\n cout << pid << endl;\n return 0;\n}\n"
},
{
"answer_id": 194221,
"author": "paercebal",
"author_id": 14089,
"author_profile": "https://Stackoverflow.com/users/14089",
"pm_score": 2,
"selected": false,
"text": "void doSomething(const std::vector & token)\n{\n char c[2] = {token.at(0), 0} ;\n int pid = std::atoi(c) ;\n}\n"
},
{
"answer_id": 9362937,
"author": "jyotirmoy",
"author_id": 1221308,
"author_profile": "https://Stackoverflow.com/users/1221308",
"pm_score": 2,
"selected": false,
"text": "const char tempChar = token.at(0);\nint tempVal = atoi(&tempChar);\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
193,728
|
<p>Is there a free XML formatting (indent) tool available where I can past an XML string and have it formatted so I can read the XML document correctly?</p>
<p>Thanks</p>
<p>Edit ~ I am using XML Notepad on Windows XP.</p>
|
[
{
"answer_id": 193745,
"author": "zoul",
"author_id": 17279,
"author_profile": "https://Stackoverflow.com/users/17279",
"pm_score": 6,
"selected": false,
"text": "xmllint --format"
},
{
"answer_id": 193753,
"author": "Guy",
"author_id": 1463,
"author_profile": "https://Stackoverflow.com/users/1463",
"pm_score": 9,
"selected": true,
"text": "C:\\Program Files\\Notepad++\\plugins\\Config\\tidy\\TIDYCFG.INI [Tidy: Reindent XML] wrap:0"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23667/"
] |
193,771
|
<p>As part of learning jQuery, I decided to do a simple tic-tac-toe game in JavaScript and, at the moment, I'm using a HTML table for spacing and using graphic images within the table.</p>
<p>The images are either a small circle or a big X or O. When the user clicks on a circle, it changes to an X or O then checks whether the game has been won.</p>
<p>Lame, I know, but it's a good educational experience.</p>
<p>The images are all the same size (circle has a lot of white space) to ensure table size doesn't change.</p>
<p>My question is two-fold.</p>
<p>1/ Should I be using CSS rather than tables to do the formatting and how would that best be done (HTML tables are very easy)?</p>
<p>2/ Is there a better way than using images so that I don't have to create the JPGs before hand? I tried with text labels (<a>) but the changing colors and underlines annoyed me?</p>
<p>As you can probably tell, I'm comfortable with HTML but not so with CSS.</p>
|
[
{
"answer_id": 193799,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 2,
"selected": false,
"text": "<!-- your html -->\n<div id=\"board\">\n <div class=\"square\" id=\"topLeft\"> </div>\n <div class=\"square\" id=\"topCenter\"> </div>\n <div class=\"square\" id=\"topRight\"> </div>\n<!-- 6 more .square divs! -->\n</div> \n #board {\n width: 606px;\n height: 606px;\n border: 1px solid #000000;\n}\n\n.square {\n float: left;\n width: 200px;\n height: 200px;\n border: 1px dotted #CCCCCC;\n}\n a:hover, a:active, a:visited {\n text-decoration: none;\n font-color: blue;\n}\n"
},
{
"answer_id": 193805,
"author": "Aleris",
"author_id": 20417,
"author_profile": "https://Stackoverflow.com/users/20417",
"pm_score": 1,
"selected": false,
"text": ".board {\n border-collapse: collapse;\n}\n.board td {\n width: 40px;\n height: 40px;\n border: 1px solid #666;\n font-size: 40px;\n line-height: 40px;\n font-family: 'courier new' serif;\n font-weight: bold;\n background-color: #ddf;\n text-align: center;\n}\n <table class=\"board\">\n <td onclick=\"alert(1)\">\n"
},
{
"answer_id": 282173,
"author": "Jason Moore",
"author_id": 18158,
"author_profile": "https://Stackoverflow.com/users/18158",
"pm_score": 2,
"selected": false,
"text": "var ex_or_oh = 'EX'; // 'OH'\n$('td.box').click(function() {\n var t = $(this);\n if (t.hasClass('OH') || t.hasClass('EX')) { return; } // spot taken\n t.addClass(ex_or_oh);\n (ex_or_oh == 'EX') ? ex_or_oh = 'OH' : ex_or_oh = 'EX';\n});\n <table><tr>\n <td class=\"box\"></td>\n <td class=\"box\"></td>\n <td class=\"box\"></td></tr>\n ...\n</table>\n"
},
{
"answer_id": 293289,
"author": "bill d",
"author_id": 1798,
"author_profile": "https://Stackoverflow.com/users/1798",
"pm_score": 0,
"selected": false,
"text": "<table> display: table-row; display: table-cell;"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14860/"
] |
193,773
|
<p>You often see, on sites like <a href="http://en.wikipedia.org/wiki/The_Daily_WTF" rel="nofollow noreferrer">The Daily WTF</a>, examples of overengineered code that should have just been a call to a built-in method within the .NET framework.</p>
<p>What namespaces/classes should be considered essential knowledge for a developer starting his/her first .NET job?</p>
<p><em>As per Joel Spolsky's instruction for these types of questions, please limit your answers to individual items for voting purposes.</em></p>
|
[
{
"answer_id": 193796,
"author": "Inisheer",
"author_id": 2982,
"author_profile": "https://Stackoverflow.com/users/2982",
"pm_score": 5,
"selected": true,
"text": "System;\nSystem.Collections;\nSystem.Collections.Generic;\n"
},
{
"answer_id": 193815,
"author": "James Newton-King",
"author_id": 11829,
"author_profile": "https://Stackoverflow.com/users/11829",
"pm_score": 3,
"selected": false,
"text": "System.IDisposable\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1588/"
] |
193,780
|
<p>I have 2-3 different column names that I want to look up in the entire database and list out all tables which have those columns. Is there any easy script?</p>
|
[
{
"answer_id": 193788,
"author": "GSerg",
"author_id": 11683,
"author_profile": "https://Stackoverflow.com/users/11683",
"pm_score": 8,
"selected": false,
"text": "SELECT TABLE_NAME, COLUMN_NAME\nFROM INFORMATION_SCHEMA.COLUMNS\nWHERE COLUMN_NAME LIKE '%wild%';\n"
},
{
"answer_id": 193860,
"author": "Ken",
"author_id": 20074,
"author_profile": "https://Stackoverflow.com/users/20074",
"pm_score": 12,
"selected": true,
"text": "columnA ColumnB YourDatabase SELECT DISTINCT TABLE_NAME \n FROM INFORMATION_SCHEMA.COLUMNS\n WHERE COLUMN_NAME IN ('columnA','ColumnB')\n AND TABLE_SCHEMA='YourDatabase';\n"
},
{
"answer_id": 4415053,
"author": "baycaysoi",
"author_id": 538621,
"author_profile": "https://Stackoverflow.com/users/538621",
"pm_score": 5,
"selected": false,
"text": "SELECT DISTINCT TABLE_NAME, COLUMN_NAME \nFROM INFORMATION_SCHEMA.COLUMNS \nWHERE column_name LIKE 'employee%' \nAND TABLE_SCHEMA='YourDatabase'\n"
},
{
"answer_id": 11952827,
"author": "Radu Maris",
"author_id": 207603,
"author_profile": "https://Stackoverflow.com/users/207603",
"pm_score": 4,
"selected": false,
"text": "information_schema mysqldump -h$host -u$user -p$pass --compact --no-data --all-databases > some_file.sql\n some_file.sql sed -n '/^USE/{h};/^CREATE/{H;x;s/\\nCREATE.*\\n/\\n/;x};/COLUMN_NAME/{x;p};' <some_file.sql\nUSE `DATABASE_NAME`;\nCREATE TABLE `TABLE_NAME` (\n `COLUMN_NAME` varchar(10) NOT NULL,\n"
},
{
"answer_id": 12798381,
"author": "Xman Classical",
"author_id": 1465704,
"author_profile": "https://Stackoverflow.com/users/1465704",
"pm_score": 6,
"selected": false,
"text": "SELECT * FROM information_schema.columns WHERE column_name = 'column_name';\n"
},
{
"answer_id": 32115340,
"author": "oucil",
"author_id": 1058733,
"author_profile": "https://Stackoverflow.com/users/1058733",
"pm_score": 4,
"selected": false,
"text": "SELECT DISTINCT TABLE_NAME FROM information_schema.columns WHERE \nTABLE_SCHEMA = 'your_db_name' AND TABLE_NAME NOT IN (SELECT DISTINCT \nTABLE_NAME FROM information_schema.columns WHERE column_name = \n'column_name' AND TABLE_SCHEMA = 'your_db_name');\n ai_col"
},
{
"answer_id": 34223872,
"author": "Shivendra Prakash Shukla",
"author_id": 3281806,
"author_profile": "https://Stackoverflow.com/users/3281806",
"pm_score": 3,
"selected": false,
"text": "SELECT TABLE_NAME\nFROM INFORMATION_SCHEMA.TABLES\nWHERE TABLE_NAME like '%'\nand TABLE_SCHEMA = 'tresbu_lk'\n SELECT DISTINCT TABLE_NAME, COLUMN_NAME\nFROM INFORMATION_SCHEMA.COLUMNS\nWHERE column_name LIKE '%'\nAND TABLE_SCHEMA='tresbu_lk'\n"
},
{
"answer_id": 46304671,
"author": "António Delgado",
"author_id": 8634731,
"author_profile": "https://Stackoverflow.com/users/8634731",
"pm_score": 4,
"selected": false,
"text": "SELECT TABLE_NAME FROM information_schema.columns WHERE column_name = 'desired_column_name';\n"
},
{
"answer_id": 50384182,
"author": "nageen nayak",
"author_id": 3996624,
"author_profile": "https://Stackoverflow.com/users/3996624",
"pm_score": 3,
"selected": false,
"text": "SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE '%city_id%' AND TABLE_SCHEMA='database'\n"
},
{
"answer_id": 59382822,
"author": "love2code",
"author_id": 426759,
"author_profile": "https://Stackoverflow.com/users/426759",
"pm_score": 3,
"selected": false,
"text": "select distinct table_name \nfrom information_schema.columns \nwhere column_name in ('ColumnA') \n and table_schema='YourDatabase';\n and table_name in \n (\n select distinct table_name \n from information_schema.columns \n where column_name in ('ColumnB')\n and table_schema='YourDatabase';\n );\n"
},
{
"answer_id": 73928849,
"author": "MiraTech",
"author_id": 2114983,
"author_profile": "https://Stackoverflow.com/users/2114983",
"pm_score": 2,
"selected": false,
"text": "SELECT *\nFROM information_schema.columns\nWHERE column_name = 'column_name';\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8091/"
] |
193,794
|
<p>How can I change a file's extension using PHP?</p>
<p>Ex: photo.jpg to photo.exe</p>
|
[
{
"answer_id": 193795,
"author": "Galen",
"author_id": 7894,
"author_profile": "https://Stackoverflow.com/users/7894",
"pm_score": 3,
"selected": false,
"text": "rename(string $from, string $to, ?resource $context = null)"
},
{
"answer_id": 193798,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 3,
"selected": false,
"text": "function replace_extension($filename, $new_extension) {\n return preg_replace('/\\..+$/', '.' . $new_extension, $filename);\n}\n"
},
{
"answer_id": 207153,
"author": "PHLAK",
"author_id": 27025,
"author_profile": "https://Stackoverflow.com/users/27025",
"pm_score": -1,
"selected": false,
"text": "// Converts image file extensions to all lowercase\n$currentdir = opendir($gallerydir);\nwhile(false !== ($file = readdir($currentdir))) {\n if(strpos($file,'.JPG',1) || strpos($file,'.GIF',1) || strpos($file,'.PNG',1)) {\n $srcfile = \"$gallerydir/$file\";\n $filearray = explode(\".\",$file);\n $count = count($filearray);\n $pos = $count - 1;\n $filearray[$pos] = strtolower($filearray[$pos]);\n $file = implode(\".\",$filearray);\n $dstfile = \"$gallerydir/$file\";\n rename($srcfile,$dstfile);\n }\n}\n"
},
{
"answer_id": 4963491,
"author": "Matt ",
"author_id": 277250,
"author_profile": "https://Stackoverflow.com/users/277250",
"pm_score": 5,
"selected": false,
"text": "substr_replace($file , 'png', strrpos($file , '.') +1)\n"
},
{
"answer_id": 7296238,
"author": "Tony Maro",
"author_id": 534088,
"author_profile": "https://Stackoverflow.com/users/534088",
"pm_score": 7,
"selected": true,
"text": "my.file.name.jpg\n function replace_extension($filename, $new_extension) {\n $info = pathinfo($filename);\n return $info['filename'] . '.' . $new_extension;\n}\n"
},
{
"answer_id": 13619292,
"author": "niksmac",
"author_id": 827525,
"author_profile": "https://Stackoverflow.com/users/827525",
"pm_score": 2,
"selected": false,
"text": "$filename = preg_replace('\"\\.bmp$\"', '.jpg', $filename);\n $filename = preg_replace('\"\\.(bmp|gif)$\"', '.jpg', $filename);\n"
},
{
"answer_id": 14726079,
"author": "Alex",
"author_id": 288568,
"author_profile": "https://Stackoverflow.com/users/288568",
"pm_score": 4,
"selected": false,
"text": "function replace_extension($filename, $new_extension) {\n $info = pathinfo($filename);\n return ($info['dirname'] ? $info['dirname'] . DIRECTORY_SEPARATOR : '') \n . $info['filename'] \n . '.' \n . $new_extension;\n}\n"
},
{
"answer_id": 26446963,
"author": "Chris Hadi",
"author_id": 3960081,
"author_profile": "https://Stackoverflow.com/users/3960081",
"pm_score": 2,
"selected": false,
"text": "preg_replace('/\\.[^.]+$/', '.', $file) . $extension\n"
},
{
"answer_id": 28502488,
"author": "Enyby",
"author_id": 1504248,
"author_profile": "https://Stackoverflow.com/users/1504248",
"pm_score": 2,
"selected": false,
"text": "substr($filename, 0, -strlen(pathinfo($filename, PATHINFO_EXTENSION))).$new_extension\n"
},
{
"answer_id": 46738829,
"author": "mgutt",
"author_id": 318765,
"author_profile": "https://Stackoverflow.com/users/318765",
"pm_score": 1,
"selected": false,
"text": "$oldname = 'path/photo.jpg';\n$newname = (dirname($oldname) ? dirname($oldname) . DIRECTORY_SEPARATOR : '') . basename($oldname, 'jpg') . 'exe';\n $newname = (dirname($oldname) ? dirname($oldname) . DIRECTORY_SEPARATOR : '') . basename($oldname, pathinfo($path, PATHINFO_EXTENSION)) . 'exe';\n rename($oldname, $newname);\n"
},
{
"answer_id": 54087565,
"author": "Moradnejad",
"author_id": 2419960,
"author_profile": "https://Stackoverflow.com/users/2419960",
"pm_score": 0,
"selected": false,
"text": "pathinfo substr_replace preg_replace substr_replace substr_replace $parts = explode('.', $inpath);\n$parts[count( $parts ) - 1] = 'exe';\n$outpath = implode('.', $parts);\n"
},
{
"answer_id": 73534113,
"author": "Eaten by a Grue",
"author_id": 1767412,
"author_profile": "https://Stackoverflow.com/users/1767412",
"pm_score": 0,
"selected": false,
"text": "strrpos() function replace_extension($filename, $extension) {\n if (($pos = strrpos($filename , '.')) !== false) {\n $filename = substr($filename, 0, $pos);\n }\n return $filename . '.' . $extension;\n}\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27025/"
] |
193,835
|
<p>I'm looking to move some of my lighter weight metaprogramming from Nemerle to Boo and I'm trying to figure out how to define custom operators. For example, I can do the following in Nemerle:</p>
<pre><code>macro @<-(func, v) {
<[ $func($v) ]>
}
</code></pre>
<p>Then these two are equivalent:</p>
<pre><code>foo <- 5;
foo(5);
</code></pre>
<p>I can't find a way of doing this in Boo -- any ideas?</p>
|
[
{
"answer_id": 1110562,
"author": "Marcus Griep",
"author_id": 28645,
"author_profile": "https://Stackoverflow.com/users/28645",
"pm_score": 4,
"selected": true,
"text": "op_addition"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4977/"
] |
193,838
|
<p>I want to do a conditional rendering at the layout level based on the actual template has defined <code>content_for(:an__area)</code>, any idea how to get this done?</p>
|
[
{
"answer_id": 194243,
"author": "William Yeung",
"author_id": 16371,
"author_profile": "https://Stackoverflow.com/users/16371",
"pm_score": 1,
"selected": false,
"text": " def content_defined?(symbol)\n content_var_name=\"@content_for_\" + \n if symbol.kind_of? Symbol \n symbol.to_s\n elsif symbol.kind_of? String\n symbol\n else\n raise \"Parameter symbol must be string or symbol\"\n end\n\n !instance_variable_get(content_var_name).nil?\n\n end\n"
},
{
"answer_id": 636225,
"author": "Nick B",
"author_id": 37460,
"author_profile": "https://Stackoverflow.com/users/37460",
"pm_score": 2,
"selected": false,
"text": "def content_defined?(var)\n content_var_name=\"@content_for_#{var}\" \n !instance_variable_get(content_var_name).nil?\nend\n <% if content_defined?(:an__area) %>\n <h1>An area is defined: <%= yield :an__area %></h1>\n<% end %>\n"
},
{
"answer_id": 636257,
"author": "efalcao",
"author_id": 73985,
"author_profile": "https://Stackoverflow.com/users/73985",
"pm_score": 3,
"selected": false,
"text": "<% if @content_for_sidebar %>\n <div id=\"sidebar\">\n <%= yield :sidebar %>\n </div>\n<% end %>\n <% content_for :sidebar do %>\n ...\n<% end %>\n"
},
{
"answer_id": 1741764,
"author": "Enrico",
"author_id": 212014,
"author_profile": "https://Stackoverflow.com/users/212014",
"pm_score": 1,
"selected": false,
"text": "<% if yield :sidebar %>\n <div id=\"sidebar\">\n <%= yield :sidebar %>\n </div>\n<% end %>\n"
},
{
"answer_id": 2429033,
"author": "gudleik",
"author_id": 291939,
"author_profile": "https://Stackoverflow.com/users/291939",
"pm_score": 9,
"selected": true,
"text": "@content_for_whatever content_for? <% if content_for?(:whatever) %>\n <div><%= yield(:whatever) %></div>\n<% end %>\n"
},
{
"answer_id": 21860184,
"author": "gregwinn",
"author_id": 1011426,
"author_profile": "https://Stackoverflow.com/users/1011426",
"pm_score": 2,
"selected": false,
"text": "<%if content_for?(:content)%>\n <%= yield(:content) %>\n<%end%>\n"
},
{
"answer_id": 72906340,
"author": "jmichaeln5",
"author_id": 8643768,
"author_profile": "https://Stackoverflow.com/users/8643768",
"pm_score": 0,
"selected": false,
"text": "@view_flow.content[:header_left_or_whatever_the_name_of_your_block_is].present?\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16371/"
] |
193,852
|
<p>I have the following character string: </p>
<pre><code>"..1....10..20....30...40....50...80..."
</code></pre>
<p>and I need to extract all numbers from it into array. </p>
<p>What is the best way to do it in C? </p>
|
[
{
"answer_id": 193858,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 4,
"selected": false,
"text": "strtok() strtok_r() char str[] = \"..1...10...20\";\nchar *p = strtok(str, \".\");\nwhile (p != NULL) {\n printf(\"%d\\n\", atoi(p));\n p = strtok(NULL, \".\");\n}\n atoi()"
},
{
"answer_id": 193892,
"author": "Diomidis Spinellis",
"author_id": 20520,
"author_profile": "https://Stackoverflow.com/users/20520",
"pm_score": 2,
"selected": false,
"text": "const char *s = \"..1....10..20....30...40....50...80...\";\nint num, nc;\n\nwhile (sscanf(s, \"%*[.]%d%n\", &num, &nc) == 1) {\n printf(\"%d\\n\", num);\n s += nc;\n}\n"
},
{
"answer_id": 193947,
"author": "graham.reeds",
"author_id": 342,
"author_profile": "https://Stackoverflow.com/users/342",
"pm_score": -1,
"selected": false,
"text": "char str[] = \"..1....10..20....30...40....50...80...\"\nfor ( char* p = strtok( strtok, \".\" ); p != NULL; p = strtok( NULL, \".\" ) )\n{\n printf( \"%d\\n\", atoi( p ) );\n}\n"
},
{
"answer_id": 194305,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 1,
"selected": false,
"text": "#include <stdio.h>\n#include <stdlib.h>\n#include <ctype.h>\n#include <errno.h>\n\n#define ARRAY_SIZE 10\n\nsize_t store_numbers (const char *s, long *array, size_t elems)\n{\n /* Scan string s, returning the number of integers found, delimited by\n * non-digit characters. If array is not null, store the first elems\n * numbers into the provided array */\n\n long value;\n char *endptr;\n size_t index = 0;\n\n while (*s)\n {\n /* Skip any non-digits, add '-' to support negative numbers */\n while (!isdigit(*s) && *s != '\\0')\n s++;\n\n /* Try to read a number with strtol, set errno to 0 first as\n * we need it to detect a range error. */\n errno = 0;\n value = strtol(s, &endptr, 10);\n\n if (s == endptr) break; /* Conversion failed, end of input */\n if (errno != 0) { /* Error handling for out of range values here */ }\n\n /* Store value if array is not null and index is within array bounds */\n if (array && index < elems) array[index] = value;\n index++;\n\n /* Update s to point to the first character not processed by strtol */\n s = endptr;\n }\n\n /* Return the number of numbers found which may be more than were stored */\n return index;\n}\n\nvoid print_numbers (const long *a, size_t elems)\n{\n size_t idx;\n for (idx = 0; idx < elems; idx++) printf(\"%ld\\n\", a[idx]);\n return;\n}\n\nint main (void)\n{\n size_t found, stored;\n long numbers[ARRAY_SIZE];\n found = store_numbers(\"..1....10..20....30...40....50...80...\", numbers, ARRAY_SIZE);\n\n if (found > ARRAY_SIZE)\n stored = ARRAY_SIZE;\n else\n stored = found;\n\n printf(\"Found %zu numbers, stored %zu numbers:\\n\", found, stored);\n print_numbers(numbers, stored);\n\n return 0;\n}\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
193,864
|
<p>You can structure a C++ program so that (almost) all the code resides in Header files. It essentially looks like a C# or Java program. However, you do need at least one <code>.cpp</code> file to pull in all the header files when compiling. Now I know some people would absolutely detest this idea. But I haven't found any convincing downsides of doing this. I can list some advantages:</p>
<p>[1] Faster compile times. All header files only get parsed once, because there is only one .cpp file. Also, one header file cannot be included more than once, otherwise you will get a build break. There are other ways of achieving faster compiles when using the alternate approach, but this is so simple.</p>
<p>[2] It avoids circular dependencies, by making them absolutely clear. If <code>ClassA</code> in <code>ClassA.h</code> has a circular dependency on <code>ClassB</code> in <code>ClassB.h</code>, I have to put a forward reference & it sticks out. (Note that this is unlike C# & Java where the compiler automatically resolves circular dependencies. This encourages bad coding practices IMO). Again, you can avoid circular dependencies if your code was in <code>.cpp</code> files, but in a real-world project, <code>.cpp</code> files tend to include random headers until you can't figure out who depends on whom.</p>
<p>Your thoughts?</p>
|
[
{
"answer_id": 193868,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 4,
"selected": false,
"text": ".cpp"
},
{
"answer_id": 194184,
"author": "paercebal",
"author_id": 14089,
"author_profile": "https://Stackoverflow.com/users/14089",
"pm_score": 5,
"selected": false,
"text": "struct A\n{\n B * b ;\n void doSomethingWithB() ;\n} ;\n\nstruct B\n{\n A * a ;\n void doSomethingWithA() ;\n} ;\n\nvoid A::doSomethingWithB() { /* etc. */ }\nvoid B::doSomethingWithA() { /* etc. */ }\n // A.hpp\n\nstruct B ;\n\nstruct A\n{\n B * b ;\n void doSomethingWithB() ;\n} ;\n // B.hpp\n\nstruct A ;\n\nstruct B\n{\n A * a ;\n void doSomethingWithA() ;\n} ;\n // A.cpp\n#include \"A.hpp\"\n#include \"B.hpp\"\n\nvoid A::doSomethingWithB() { /* etc. */ }\n // B.cpp\n#include \"B.hpp\"\n#include \"A.hpp\"\n\nvoid B::doSomethingWithA() { /* etc. */ }\n"
},
{
"answer_id": 194379,
"author": "terson",
"author_id": 22974,
"author_profile": "https://Stackoverflow.com/users/22974",
"pm_score": 2,
"selected": false,
"text": "// foo.hpp\n#ifndef __FOO_HPP__\n#define __FOO_HPP__\n\nstruct foo\n{\n int data ;\n} ;\n\n#endif // __FOO_HPP__\n // bar.hpp\n#ifndef __BAR_HPP__\n#define __BAR_HPP__\n\n#include \"foo.hpp\"\n\nstruct bar\n{\n foo f ;\n void doSomethingWithFoo() ;\n} ;\n#endif // __BAR_HPP__\n // bar.cpp\n#include \"bar.hpp\"\n\nvoid bar::doSomethingWithFoo()\n{\n // Initialize f\n f.data = 0;\n // etc.\n}\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15071/"
] |
193,875
|
<p>I have some very simple code to generate an assembly and invoke a method on a contained type. The method gets called and runs correctly, however when I view the generated assembly using Reflector, I don't see the type.</p>
<p>Below is the sample code:</p>
<pre><code>namespace ConsoleApplication2
{
class Proggy
{
public static void Main(string[] args)
{
var ab = AppDomain.CurrentDomain.DefineDynamicAssembly(
new AssemblyName() { Name = "MyAssembly" },
AssemblyBuilderAccess.RunAndSave);
var module = ab.DefineDynamicModule(ab.GetName().Name);
var typeBuilder = module.DefineType("MyType");
var ctr = typeBuilder.DefineConstructor(MethodAttributes.Public,
CallingConventions.Standard, Type.EmptyTypes);
var ilgc = ctr.GetILGenerator();
ilgc.Emit(OpCodes.Ldarg_0);
ilgc.Emit(OpCodes.Call, typeof(object).GetConstructor(Type.EmptyTypes));
ilgc.Emit(OpCodes.Ret);
var method = typeBuilder.DefineMethod("MyMethod", MethodAttributes.Public,
typeof(int), new[] { typeof(string) });
var ilg = method.GetILGenerator();
ilg.Emit(OpCodes.Ldarg_1);
ilg.EmitCall(OpCodes.Callvirt, typeof(string).GetProperty("Length").GetGetMethod(),
null);
ilg.Emit(OpCodes.Ret);
var type = typeBuilder.CreateType();
ab.Save("mytestasm.dll");
var inst = Activator.CreateInstance(type);
Console.WriteLine(type.InvokeMember("MyMethod", BindingFlags.InvokeMethod, null, inst,
new[] { "MyTestString" }));
Console.ReadLine();
}
}
}
</code></pre>
<p>and here is the corresponding disassembly from Reflector:</p>
<pre><code>.assembly MyAssembly
{
.ver 0:0:0:0
.hash algorithm 0x00008004
}
.module RefEmit_OnDiskManifestModule
// MVID: {0B944140-58D9-430E-A867-DE0AD0A8701F}
// Target Runtime Version: v2.0.50727
</code></pre>
<p>... and ...</p>
<pre><code>{
.class private auto ansi <Module>
{
}
}
</code></pre>
<p>Can anyone help me with getting the assembly properly saved?</p>
|
[
{
"answer_id": 193932,
"author": "alexmac",
"author_id": 23066,
"author_profile": "https://Stackoverflow.com/users/23066",
"pm_score": -1,
"selected": false,
"text": "print(\" Microsoft.CSharp.CSharpCodeProvider objCodeProvider = new Microsoft.CSharp.CSharpCodeProvider();\n string strCode = \"using System;\" + Environment.NewLine + \"using System.Data;\" + Environment.NewLine + \"using DC.Common;\" + Environment.NewLine + \"\" + Environment.NewLine + \"using System.Data.SqlClient;\" + Environment.NewLine + \"using System.Configuration;\" + Environment.NewLine + \"\" + Environment.NewLine + Environment.NewLine + BaseClassFile + Environment.NewLine + BaseManagerFile + Environment.NewLine;\n string strSourceModule = BuilderSettings.ExportDir + \"/\" + BuilderSettings.ProjectName + \"/\" + \"BaseFile.cs\";\n\n FileHelper.WriteAllText(strSourceModule, strCode);\n FileHelper.WriteAllText(BuilderSettings.ExportDir + \"/\" + BuilderSettings.ProjectName + \"/\" + \"test.txt\", strCode);\n\n ICodeCompiler icc = objCodeProvider.CreateCompiler();\n string OutputPath = BuilderSettings.ExportDir + \"/\" + BuilderSettings.ProjectName + \"/\" + BuilderSettings.ProjectName + \".dll\";\n CompilerParameters parameters = new CompilerParameters();\n CompilerResults results;\n\n parameters.GenerateExecutable = false;\n parameters.OutputAssembly = OutputPath;\n parameters.GenerateInMemory = false;\n parameters.IncludeDebugInformation = false;\n\n //Add required assemblies\n DynamicLinkLibraries.Clear();\n\n //User defined\n DynamicLinkLibraries.Add(@\"d:\\wwwroot\\\\DC.Common\\bin\\Debug\\DC.Common.dll\");\n\n //System\n DynamicLinkLibraries.Add(\"System.dll\");\n DynamicLinkLibraries.Add(\"System.Data.dll\");\n DynamicLinkLibraries.Add(\"mscorlib.dll\");\n DynamicLinkLibraries.Add(\"System.xml.dll\");\n DynamicLinkLibraries.Add(\"System.web.dll\");\n DynamicLinkLibraries.Add(\"System.configuration.dll\");\n\n //Any dynamic assembly adding must be done here\n foreach (string strLibrary in DynamicLinkLibraries)\n {\n parameters.ReferencedAssemblies.Add(strLibrary);\n }\n\n results = icc.CompileAssemblyFromSource(parameters, strCode);\n\n if (results.Errors.Count > 0)\n {\n //report any compilation errors\n string strErrors = \"Compilation failed:\" + Environment.NewLine;\n\n foreach (CompilerError oError in results.Errors)\n {\n strErrors = strErrors + \"Line number \" + oError.Line + \", Error Number: \" + oError.ErrorNumber + \", '\" + oError.ErrorText + \";\";\n\n }\n\n throw new Exception(\"Error in CompileSourceCode(): \" + Environment.NewLine + strErrors);\n }\n\n objCodeProvider = null;\n icc = null;\n parameters = null;\");\n"
},
{
"answer_id": 193948,
"author": "Eric Smith",
"author_id": 26054,
"author_profile": "https://Stackoverflow.com/users/26054",
"pm_score": 4,
"selected": true,
"text": "var module = ab.DefineDynamicModule(ab.GetName().Name);\n var module = ab.DefineDynamicModule(ab.GetName().Name, ab.GetName().Name + \".mod\");\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26054/"
] |
193,918
|
<p>Given a point such as (0, 0, 0) and a vector like (x, y, z). What is the easiest way to align the negative Z-axis centered at (0, 0, 0) to point in the direction of this vector? Examples using OpenGL would be welcome, but not neccessary.</p>
|
[
{
"answer_id": 194037,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": true,
"text": "vec3 target_dir = normalise( vector );\nfloat rot_angle = acos( dot_product(target_dir,z_axis) );\nif( fabs(rot_angle) > a_very_small_number )\n{\n vec3 rot_axis = normalise( cross_product(target_dir,z_axis) );\n glRotatef( rot_angle, rot_axis.x, rot_axis.y, rot_axis.z );\n}\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12828/"
] |
193,919
|
<p>I am a little confused by the multitude of ways in which you can import modules in Python. </p>
<pre><code>import X
import X as Y
from A import B
</code></pre>
<p>I have been reading up about scoping and namespaces, but I would like some practical advice on what is the best strategy, under which circumstances and why. Should imports happen at a module level or a method/function level? In the <code>__init__.py</code> or in the module code itself?</p>
<p>My question is not really answered by "<a href="https://stackoverflow.com/questions/45122/python-packages-import-by-class-not-file">Python packages - import by class, not file</a>" although it is obviously related.</p>
|
[
{
"answer_id": 193927,
"author": "MvdD",
"author_id": 18044,
"author_profile": "https://Stackoverflow.com/users/18044",
"pm_score": 4,
"selected": false,
"text": "import X from X import Y import X as Y def main():\n import sys\n if len(sys.argv) > 1:\n pass\n"
},
{
"answer_id": 193931,
"author": "DzinX",
"author_id": 18745,
"author_profile": "https://Stackoverflow.com/users/18745",
"pm_score": 7,
"selected": true,
"text": "\"\"\"\nRegistry related functionality.\n\"\"\"\nimport wx\n# ...\n from RegistryController import RegistryController\nfrom ui.windows.lists import ListCtrl, DynamicListCtrl\n from main.core import Exceptions\n# ...\nraise Exceptions.FileNotFound()\n import X as Y from Queue import Queue\nfrom main.core.MessageQueue import Queue as MessageQueue\n"
},
{
"answer_id": 193937,
"author": "olt",
"author_id": 19759,
"author_profile": "https://Stackoverflow.com/users/19759",
"pm_score": 0,
"selected": false,
"text": "import X as Y try..import..except ImportError..import try:\n from lxml import etree\n print(\"running with lxml.etree\")\nexcept ImportError:\n try:\n # Python 2.5\n import xml.etree.cElementTree as etree\n print(\"running with cElementTree on Python 2.5+\")\n except ImportError:\n try:\n # Python 2.5\n import xml.etree.ElementTree as etree\n print(\"running with ElementTree on Python 2.5+\")\n except ImportError:\n try:\n # normal cElementTree install\n import cElementTree as etree\n print(\"running with cElementTree\")\n except ImportError:\n try:\n # normal ElementTree install\n import elementtree.ElementTree as etree\n print(\"running with ElementTree\")\n except ImportError:\n print(\"Failed to import ElementTree from any known place\")\n"
},
{
"answer_id": 193979,
"author": "dbr",
"author_id": 745,
"author_profile": "https://Stackoverflow.com/users/745",
"pm_score": 2,
"selected": false,
"text": "import modulename from BeautifulSoup import BeautifulStoneSoup as BSS\n soup = BSS(html) BeautifulSoup.BeautifulStoneSoup(html) from xmpp import XmppClientBase\n import x as y from my_other_module import main as other_module_main\n main main from x import * from x import *; from y import *; my_func() import modulename modulename.subthing1.subthing2.method(\"test\") from x import y as z"
},
{
"answer_id": 194085,
"author": "davidavr",
"author_id": 8247,
"author_profile": "https://Stackoverflow.com/users/8247",
"pm_score": 3,
"selected": false,
"text": "import X as Y xyz_new import xyz_new as xyz\n xyz xyz_new import xyz\n"
},
{
"answer_id": 194096,
"author": "Jason Baker",
"author_id": 2147,
"author_profile": "https://Stackoverflow.com/users/2147",
"pm_score": 2,
"selected": false,
"text": "from X import *\n from X import Y\n from X import A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P\n import X\n"
},
{
"answer_id": 204340,
"author": "Cheery",
"author_id": 21711,
"author_profile": "https://Stackoverflow.com/users/21711",
"pm_score": 1,
"selected": false,
"text": "import gat\n\nnode = gat.Node()\nchild = node.children()\n from gat import Node, SubNode\n\nnode = Node()\nchild = SubNode(node)\n from gat import (\n Node, SubNode, TopNode, SuperNode, CoolNode,\n PowerNode, UpNode\n)\n"
},
{
"answer_id": 2236989,
"author": "CastleDweller",
"author_id": 270293,
"author_profile": "https://Stackoverflow.com/users/270293",
"pm_score": 0,
"selected": false,
"text": "from X import *\n from const import *\n"
},
{
"answer_id": 16070330,
"author": "Robert Jacobs",
"author_id": 2066459,
"author_profile": "https://Stackoverflow.com/users/2066459",
"pm_score": 4,
"selected": false,
"text": "from X import A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P\n import X\n import X from X import ... from X import A..P"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24039/"
] |
193,939
|
<p>What is the difference between the CIL instructions "Call" and "Callvirt"?</p>
|
[
{
"answer_id": 193952,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 7,
"selected": true,
"text": "call callvirt this"
},
{
"answer_id": 193955,
"author": "Drew Noakes",
"author_id": 24874,
"author_profile": "https://Stackoverflow.com/users/24874",
"pm_score": 6,
"selected": false,
"text": "call jmp callvirt call sealed class SealedObject : object\n{\n public override bool Equals(object o)\n {\n // ...\n }\n}\n SealedObject a = // ...\nobject b = // ...\n\nbool equal = a.Equals(b);\n System.Object.Equals(object) Equals SealedObject sealed this callvirt if (this==null) // ...\n this call sealed call new SealedObject().Equals(\"Rubber ducky\");\n callvirt var o = new SealedObject();\no.Equals(\"Rubber ducky\");\n o call callvirt"
},
{
"answer_id": 193960,
"author": "Cameron MacFarland",
"author_id": 3820,
"author_profile": "https://Stackoverflow.com/users/3820",
"pm_score": 4,
"selected": false,
"text": "public class SampleClass\n{\n public override bool Equals(object obj)\n {\n if (obj.ToString().Equals(\"Rubber Ducky\", StringComparison.InvariantCultureIgnoreCase))\n return true;\n\n return base.Equals(obj);\n }\n\n public void SomeOtherMethod()\n {\n }\n\n static void Main(string[] args)\n {\n // This will emit a callvirt to System.Object.Equals\n bool test1 = new SampleClass().Equals(\"Rubber Ducky\");\n\n // This will emit a call to SampleClass.SomeOtherMethod\n new SampleClass().SomeOtherMethod();\n\n // This will emit a callvirt to System.Object.Equals\n SampleClass temp = new SampleClass();\n bool test2 = temp.Equals(\"Rubber Ducky\");\n\n // This will emit a callvirt to SampleClass.SomeOtherMethod\n temp.SomeOtherMethod();\n }\n}\n"
},
{
"answer_id": 31101353,
"author": "Boris",
"author_id": 3383865,
"author_profile": "https://Stackoverflow.com/users/3383865",
"pm_score": 2,
"selected": false,
"text": " public class Test {\n public int Val;\n public Test(int val)\n { Val = val; }\n public string FInst () // note: this==null throws before this point\n { return this == null ? \"NO VALUE\" : \"ACTUAL VALUE \" + Val; }\n public virtual string FVirt ()\n { return \"ALWAYS AN ACTUAL VALUE \" + Val; }\n }\n public static class TestExt {\n public static string FExt (this Test pObj) // note: pObj==null passes\n { return pObj == null ? \"NO VALUE\" : \"VALUE \" + pObj.Val; }\n }\n pObj.FExt(); // IL:call\n mov rcx, <pObj>\n call (direct-ptr-to) <TestExt.FExt>\n\n pObj.FInst(); // IL:callvirt[instance]\n mov rax, <pObj>\n cmp byte ptr [rax],0\n mov rcx, <pObj>\n call (direct-ptr-to) <Test.FInst>\n\n pObj.FVirt(); // IL:callvirt[virtual]\n mov rax, <pObj>\n mov rax, qword ptr [rax] \n mov rax, qword ptr [rax + NNN] \n mov rcx, <pObj>\n call qword ptr [rax + MMM] \n var d = GetDForABC (a, b, c);\nvar e = d != null ? d.GetE() : ClassD.SOME_DEFAULT_E;\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26054/"
] |
193,965
|
<p>I love the Ruby RSpec BDD development style. Are there any good tools for doing this with C/C++?</p>
|
[
{
"answer_id": 7065024,
"author": "Tony Bai",
"author_id": 207003,
"author_profile": "https://Stackoverflow.com/users/207003",
"pm_score": 2,
"selected": false,
"text": "FEATURE(1, \"strstr\")\n SCENARIO(\"The strstr finds the first occurrence of the substring in the source string\")\n\n GIVEN(\"A source string: [Lionel Messi is a great football player]\")\n char *str = \"Lionel Messi is a great football player\";\n GIVEN_END\n\n WHEN(\"we use strstr to find the first occurrence of [football]\")\n char *p = strstr(str, \"football\");\n WHEN_END\n\n THEN(\"We should get the string: [football player]\")\n SHOULD_STR_EQUAL(p, \"football player\");\n THEN_END\n SCENARIO_END\nFEATURE_END\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6805/"
] |
193,973
|
<p>It obviously depends on the context you are using them in but, I was wondering if there is a universally accepted way to name such variables, or at least in a mathematical context.</p>
<p>I've often seen:</p>
<pre><code>float k = someValue;
float oneMinusK = 1 - k;
</code></pre>
<p>...which seems as descriptive as much as meaningless to me. </p>
<p>Please note that I'm not asking how to name a variable, but how to do it in this very case. Examples and contexts where you used them will be much appreciated,</p>
<p>Thanks.</p>
|
[
{
"answer_id": 193978,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 5,
"selected": true,
"text": "float will_win_lottery = 0.00000000001;\nfloat will_not_win_lottery = 1 - will_win_lottery;\n"
},
{
"answer_id": 194023,
"author": "Ande Turner",
"author_id": 4857,
"author_profile": "https://Stackoverflow.com/users/4857",
"pm_score": 0,
"selected": false,
"text": "float complement(float n) { return (1.0 - n); }\n"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7839/"
] |
193,994
|
<p>I'm writing a construct in PHP where a parser determins which function to call dynamically, kind of like this:</p>
<pre><code>// The definition of what to call
$function_call_spec = array( "prototype" => "myFunction",
"parameters" => array( "first_par" => "Hello",
"second_par" => "World"));
// Dispatch
$funcPrototype = $function_call_spec["prototype"];
$funcPrototype(); // Here we call function 'myFunction'.
</code></pre>
<p>This is all fine and dandy. But now comes the next step, passing the parameters, which I don't really know if it's possible the way I want to do it. It never stops amazing me however what script languages can do these days, so here goes:</p>
<p>One could pass the parameters to the function like this:</p>
<pre><code>// Here we call function 'myFunction' with the array of parameters.
$funcPrototype( $function_call_spec["parameters"] );
</code></pre>
<p>However, I want to declare 'myFunction' properly with clear arguments etc:</p>
<pre><code>function myFunction( $first_par, $second_par )
{
}
</code></pre>
<p>The question then follows - Is there any way to pass parameters to a function dynamically simply by looping through the parameter array?</p>
<p>To clarify, I <strong>don't</strong> want to do it like this:</p>
<pre><code>$funcPrototype( $function_call_spec["parameters"]["first_par"],
$function_call_spec["parameters"]["second_par"] );
</code></pre>
<p>Because this requires my code to statically know details about myFunction, which goes against the whole idea.</p>
<p>Instead I would want to do it in some way like this maybe:</p>
<pre><code>// Special magic PHP function which can be used for invoking functions dynamically
InvokeFunction( $funcPrototype, $function_call_spec["parameters"] );
</code></pre>
<p>Which then results in myFunction being called and all parameters in the array gets passed to each individual parameter variable in the prototype.</p>
<p>Any comments are welcome.</p>
<p>Regards.</p>
<p>/R</p>
<p>PS: None of the code in this post has been tested for typos etc.</p>
|
[
{
"answer_id": 193998,
"author": "moo",
"author_id": 23107,
"author_profile": "https://Stackoverflow.com/users/23107",
"pm_score": 3,
"selected": false,
"text": "call_user_func_array($funcPrototype, $function_call_spec[\"parameters\"]);\n function InvokeFunction($function, $args = array()) {\n return call_user_func_array($function, (array)$args);\n}\n $return = InvokeFunction('doStuff');\n$return = InvokeFunction('doStuff', $single_arg);\n$return = InvokeFunction('doStuff', $multiple_args);\n"
},
{
"answer_id": 194000,
"author": "Kornel",
"author_id": 27009,
"author_profile": "https://Stackoverflow.com/users/27009",
"pm_score": 5,
"selected": true,
"text": "call_user_func_array ReflectionFunction::invokeArgs call_user_func_array"
},
{
"answer_id": 194047,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "call_user_func_array() ReflectionFunction"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/193994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7891/"
] |
194,032
|
<p>I need to build a little webapp but I'm not sure what is the best thing to do.</p>
<p>A person that subscribe the petition is signing an email sent to <em>X</em>. This will be also saved to a db in order to show online who subscribed.</p>
<p>The idea is to have a standard text message, the user submit his name and that name goes into the message as signature.</p>
<p>I could make php send the email with the address of the real sender, or let the user copy and paste the text and let him send the email on his own.</p>
<p>I'm not sure of what is the best way to implement it. What will be more "effective", I mean as number of subscribers the solution where the app send the email is easier, but what about the authenticity of the emails? They could be considered not valid if sent all from the same place? </p>
|
[
{
"answer_id": 194074,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 3,
"selected": true,
"text": "<a href=\"mailto:... mailto:"
}
] |
2008/10/11
|
[
"https://Stackoverflow.com/questions/194032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21384/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.