qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
369,994 | <p>I would like to log changes made to all fields in a table to another table. This will be used to keep a history of all the changes made to that table (Your basic change log table).</p>
<p>What is the best way to do it in SQL Server 2005?</p>
<p>I am going to assume the logic will be placed in some Triggers.</p>
<p>What is a good way to loop through all the fields checking for a change without hard coding all the fields? </p>
<p>As you can see from my questions, example code would be veeery much appreciated.</p>
<p>I noticed SQL Server 2008 has a new feature called Change Data Capture (CDC). (Here is a nice <a href="http://channel9.msdn.com/posts/ashishjaiman/CDC-Change-Data-Capture-SQL-Server-2008/" rel="nofollow noreferrer">Channel9</a> video on CDC). This is similar to what we are looking for except we are using SQL Server 2005, already have a Log Table layout in-place and are also logging the user that made the changes. I also find it hard to justify writing out the before and after image of the whole record when one field might change. </p>
<p>Our current log file structure in place has a column for the Field Name, Old Data, New Data.</p>
<p>Thanks in advance and have a nice day.</p>
<p><strong>Updated 12/22/08:</strong> I did some more research and found these two answers on <a href="http://qna.live.com/" rel="nofollow noreferrer">Live Search QnA</a></p>
<ol>
<li><p>You can create a trigger to do this. See
<a href="http://web.archive.org/web/20071006100909/http://sqlserver2000.databases.aspfaq.com:80/how-do-i-audit-changes-to-sql-server-data.html" rel="nofollow noreferrer">How do I audit changes to sql server data</a>.</p></li>
<li><p>You can use triggers to log the data changes into the log tables. You can also purchase Log Explorer from <a href="http://www.lumigent.com" rel="nofollow noreferrer">www.lumigent.com</a> and use that to read the transaction log to see what user made the change. The database needs to be in full recovery for this option however.</p></li>
</ol>
<p><strong>Updated 12/23/08:</strong> I also wanted a clean way to compare what changed and this looked like the reverse of a PIVOT, which I found out in SQL is called UNPIVOT. I am now leaning towards a Trigger using UNPIVOT on the INSERTED and DELETED tables. I was curious if this was already done so I am going through a search on "<a href="http://www.google.com/search?hl=en&sa=X&oi=spell&resnum=1&ct=result&cd=1&q=unpivot+deleted+inserted&spell=1" rel="nofollow noreferrer">unpivot deleted inserted</a>".</p>
<ol>
<li>Posting <a href="http://social.msdn.microsoft.com/forums/en-US/sqlgetstarted/thread/2910645b-82b2-4dec-8286-553ae5eaa1cc/" rel="nofollow noreferrer">Using update function from an after trigger</a> had some different ideas but I still believe UNPIVOT is going to be the route to go.</li>
</ol>
| [
{
"answer_id": 370049,
"author": "NotMe",
"author_id": 2424,
"author_profile": "https://Stackoverflow.com/users/2424",
"pm_score": 2,
"selected": false,
"text": "INSERT INTO mytable(description, phone)\nOUTPUT INSERTED.description, INSERTED.phone INTO #TempTable\nVALUES('blah', '12312312... | 2008/12/15 | [
"https://Stackoverflow.com/questions/369994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4964/"
] |
370,001 | <p>The docs for <a href="http://msdn.microsoft.com/en-us/library/bb347013.aspx" rel="noreferrer">Dictionary.TryGetValue</a> say:</p>
<blockquote>
<p>When this method returns, [the value argument] contains the value associated with the specified key, if the key is found; otherwise, the <strong>default value for the type of the value parameter</strong>. This parameter is passed uninitialized.</p>
</blockquote>
<p>I need to mimic this in my class. <em>How do I find the default value for type T?</em></p>
<hr>
<p>How can this question be modified to make it show up in the search?</p>
<p>Exact duplicate of <a href="https://stackoverflow.com/questions/367378/returning-a-default-value-c">Returning a default value. (C#)</a></p>
| [
{
"answer_id": 370006,
"author": "Szymon Rozga",
"author_id": 7583,
"author_profile": "https://Stackoverflow.com/users/7583",
"pm_score": 4,
"selected": false,
"text": "default(T);\n"
},
{
"answer_id": 370009,
"author": "Nathan W",
"author_id": 6335,
"author_profile":... | 2008/12/15 | [
"https://Stackoverflow.com/questions/370001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1343/"
] |
370,004 | <p>Using Java, I need to encode a Map<String, String> of name value pairs to store into a String, and be able to decode it again. These will be stored in a database column, and will probably usually be short and simple, so the common case should produce a simple nice looking line, but shouldn't corrupt the data, even if it contains unexpected characters, etc.</p>
<p>How would you choose to do it such that:</p>
<ul>
<li>The encoded form is a single, human readable line</li>
<li>It doesn't require a big library or much context to encode / decode</li>
<li>Any delimeters are properly escaped</li>
</ul>
<p>Url encoding? JSON? Do it yourself? Please specify any helper libraries or methods you'd use.</p>
<p>(Edited to specify more context and requirements as requested.)</p>
| [
{
"answer_id": 370039,
"author": "Dan Vinton",
"author_id": 21849,
"author_profile": "https://Stackoverflow.com/users/21849",
"pm_score": 3,
"selected": false,
"text": "Map<String, String>"
},
{
"answer_id": 372083,
"author": "alepuzio",
"author_id": 45745,
"author_pr... | 2008/12/15 | [
"https://Stackoverflow.com/questions/370004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3093/"
] |
370,013 | <p>Using jQuery, how do I delete all rows in a table except the first? This is my first attempt at using index selectors. If I understand the examples correctly, the following should work:</p>
<pre><code>$(some table selector).remove("tr:gt(0)");
</code></pre>
<p>which I would read as "Wrap some table in a jQuery object, then remove all 'tr' elements (rows) where the element index of such rows is greater than zero". In reality, it executes without generating an error, but doesn't remove any rows from the table.</p>
<p>What am I missing, and how do I fix this? Of course, I could use straight javascript, but I'm having so much fun with jQuery that I'd like to solve this using jQuery.</p>
| [
{
"answer_id": 370031,
"author": "Strelok",
"author_id": 2788,
"author_profile": "https://Stackoverflow.com/users/2788",
"pm_score": 10,
"selected": true,
"text": "$(document).ready(function() {\n $(\"someTableSelector\").find(\"tr:gt(0)\").remove();\n});\n"
},
{
"answer_id": 3... | 2008/12/15 | [
"https://Stackoverflow.com/questions/370013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26671/"
] |
370,024 | <p>I have a SQL Server 2005 database that I'm trying to access as a limited user account, using Windows authentication. I've got BUILTIN\Users added as a database user (before I did so, I couldn't even open the database). I'm working under the assumption that everybody is supposed to have permissions for the "public" role applied to them, so I didn't do anything with role assignment. Under tblFoo, I can use the SSMS Properties dialog (Permissions page) to add "public", then set explicit permissions. Among these is "Grant" for SELECT. But running</p>
<pre><code>SELECT * from tblFoo;
</code></pre>
<p>as a limited (BUILTIN\Users) account gives me an error "Select permission denied on object 'tblFoo', database 'bar', schema 'dbo'". In the properties dialog, there's an "Effective Permissions button, but it's greyed out.</p>
<p>Further, I tried creating a non-priv account called "UserTest", adding that at the server level, then mapping it down to the "bar" database. This let me add UserTest to the "Users or Roles" list, which let me run "Effective Permissions" for the account. No permissions are listed at all -- this doesn't seem right. The account must be in public, and public grants (among other things) Select on tblFoo, so why doesn't the UserTest account show an effective permission? I feel like I'm going a bit crazy here.</p>
<p>ASIDE: I am aware that many people don't like using the "public" role to set permissions. This is just my tinkering time; in final design I'm sure we'll have several flexible (custom) database roles. I'm just trying to figure out the behavior I'm seeing, so please no "don't do that!" answers.</p>
<p>UPDATE: Apparently I know just enough SQL Server to be a danger to myself and others. In setting permissions (as I said, "among others"), I had DENY CONTROL. When I set this permission, I think I tried to look up what it did, had a vague idea, and decided on DENY. I cannot currently recall why this seemed the thing to do, but it would appear that that was the reason I was getting permission failures. So I'm updating my question: can anyone explain the "CONTROL" permission, as it pertains to tables?</p>
| [
{
"answer_id": 370127,
"author": "Nathan Griffiths",
"author_id": 46239,
"author_profile": "https://Stackoverflow.com/users/46239",
"pm_score": 0,
"selected": false,
"text": "EXEC MASTER.dbo.xp_logininfo 'Domain\\UserTest', 'all'\n"
},
{
"answer_id": 370498,
"author": "gbn",
... | 2008/12/15 | [
"https://Stackoverflow.com/questions/370024",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26286/"
] |
370,030 | <p>I have just start using git and i can't get it to remember my passphrase I'm using cmd.exe elevated and my git host is github and i have create a ssh key like that guide on github</p>
<p>but i still get </p>
<pre><code>*\subnus.mvc>git push origin master
Enter passphrase for key '/c/Users/Subnus/.ssh/id_rsa':
</code></pre>
| [
{
"answer_id": 3932378,
"author": "hwjp",
"author_id": 366221,
"author_profile": "https://Stackoverflow.com/users/366221",
"pm_score": 3,
"selected": false,
"text": "git"
},
{
"answer_id": 4356869,
"author": "RobertB",
"author_id": 388702,
"author_profile": "https://S... | 2008/12/15 | [
"https://Stackoverflow.com/questions/370030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31296/"
] |
370,047 | <p>Or more generally, how do I remove an item from a colon-separated list in a Bash environment variable?</p>
<p>I thought I had seen a simple way to do this years ago, using the more advanced forms of Bash variable expansion, but if so I've lost track of it. A quick search of Google turned up surprisingly few relevant results and none that I would call "simple" or "elegant". For example, two methods using sed and awk, respectively:</p>
<pre><code>PATH=$(echo $PATH | sed -e 's;:\?/home/user/bin;;' -e 's;/home/user/bin:\?;;')
PATH=!(awk -F: '{for(i=1;i<=NF;i++){if(!($i in a)){a[$i];printf s$i;s=":"}}}'<<<$PATH)
</code></pre>
<p>Does nothing straightforward exist? Is there anything analogous to a split() function in Bash?</p>
<p><strong>Update:</strong><br/>
It looks like I need to apologize for my intentionally-vague question; I was less interested in solving a specific use-case than in provoking good discussion. Fortunately, I got it!</p>
<p>There are some very clever techniques here. In the end, I've added the following three functions to my toolbox. The magic happens in path_remove, which is based largely on Martin York's clever use of <code>awk</code>'s RS variable.</p>
<pre><code>path_append () { path_remove $1; export PATH="$PATH:$1"; }
path_prepend () { path_remove $1; export PATH="$1:$PATH"; }
path_remove () { export PATH=`echo -n $PATH | awk -v RS=: -v ORS=: '$0 != "'$1'"' | sed 's/:$//'`; }
</code></pre>
<p>The only real cruft in there is the use of <code>sed</code> to remove the trailing colon. Considering how straightforward the rest of Martin's solution is, though, I'm quite willing to live with it!</p>
<hr>
<p>Related question: <A href="https://stackoverflow.com/questions/273909/how-do-i-manipulate-path-elements-in-shell-scripts"><a href="https://stackoverflow.com/questions/273909/how-do-i-manipulate-path-elements-in-shell-scripts">How do I manipulate $PATH elements in shell scripts?</a></A></p>
| [
{
"answer_id": 370056,
"author": "mat",
"author_id": 42083,
"author_profile": "https://Stackoverflow.com/users/42083",
"pm_score": 2,
"selected": false,
"text": "PATH=${PATH/:\\/home\\/user\\/bin/}\n"
},
{
"answer_id": 370135,
"author": "Martin York",
"author_id": 14065,
... | 2008/12/15 | [
"https://Stackoverflow.com/questions/370047",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46387/"
] |
370,055 | <p>How would one change the view on the screen programmatically in an iPhone app?</p>
<p>I've been able to create navigation view's and programmatically push/pop them to produce this behaviour, but if I wanted to simply change the current view (not using a UINavigation controller object), what is the neatest way to achieve this?</p>
<p>A simple example, imagine an application with a single button, when pressed will display a new view, or possibly one of multiple views depending on some internal state variable.</p>
<p>I have yet to see any examples that attempt to do this, and I don't seem to understand enough about the relationships and initialisation procedure between UIViewController/UIView objects to achieve this programmatically.</p>
| [
{
"answer_id": 370148,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 2,
"selected": false,
"text": "-[UIView addSubview:]"
},
{
"answer_id": 370390,
"author": "davidavr",
"author_id": 8247,
"author_p... | 2008/12/15 | [
"https://Stackoverflow.com/questions/370055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40175/"
] |
370,060 | <p>I'm using ASP.NET MVC and I have a partial control that needs a particular CSS & JS file included. Is there a way to make the parent page render the <code>script</code> and <code>link</code> tags in the 'head' section of the page, rather than just rendering them inline in the partial contol?</p>
<p>To clarify the control that I want to include the files from is being rendered from a View with <code>Html.RenderPartial</code> and so cannot have server-side content controls on it. I want to be able to include the files in the html <code>head</code> section so as to avoid validation issues.</p>
| [
{
"answer_id": 370085,
"author": "Todd Smith",
"author_id": 31624,
"author_profile": "https://Stackoverflow.com/users/31624",
"pm_score": -1,
"selected": false,
"text": "<head runat=\"server>\n <asp:ContentPlaceHolder ID=\"head\" runat=\"server\" />\n</head>\n"
},
{
"answer_id... | 2008/12/15 | [
"https://Stackoverflow.com/questions/370060",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2975/"
] |
370,075 | <p>Is there a script to display a simple world clock (time in various places around the world) on a *nix terminal?</p>
<p>I was thinking of writing a quick Python script, but I have a feeling that's gonna be more work than I think (e.g. due to config and output format) - not to mention reinventing the wheel...</p>
| [
{
"answer_id": 370105,
"author": "Dustin",
"author_id": 39975,
"author_profile": "https://Stackoverflow.com/users/39975",
"pm_score": 5,
"selected": false,
"text": "#!/bin/sh\n\nPT=`env TZ=US/Pacific date`\nCT=`env TZ=US/Central date`\nAT=`env TZ=Australia/Melbourne date`\n\necho \"Santa... | 2008/12/15 | [
"https://Stackoverflow.com/questions/370075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
370,079 | <p>I'm trying to write some C# code that calls a method from an unmanaged DLL. The prototype for the function in the dll is:</p>
<pre><code>extern "C" __declspec(dllexport) char *foo(void);
</code></pre>
<p>In C#, I first used:</p>
<pre><code>[DllImport(_dllLocation)]
public static extern string foo();
</code></pre>
<p>It seems to work on the surface, but I'm getting memory corruption errors during runtime. I think I'm pointing to memory that happens to be correct, but has already been freed.</p>
<p>I tried using a PInvoke code gen utility called "P/Invoke Interop Assistant". It gave me the output:</p>
<pre><code>[System.Runtime.InteropServices.DLLImportAttribute(_dllLocation, EntryPoint = "foo")]
public static extern System.IntPtr foo();
</code></pre>
<p>Is this correct? If so, how do I convert this IntPtr to a string in C#?</p>
| [
{
"answer_id": 370093,
"author": "Strelok",
"author_id": 2788,
"author_profile": "https://Stackoverflow.com/users/2788",
"pm_score": 5,
"selected": false,
"text": "IntPtr ptr = foo();\nstring str = Marshal.PtrToStringAuto(ptr);\n"
},
{
"answer_id": 370519,
"author": "JaredPar... | 2008/12/15 | [
"https://Stackoverflow.com/questions/370079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5959/"
] |
370,086 | <p>I'm loading the XML in, and I'm able to read the XML nodes into text fields in my flash. It is also loading the URL, but the last one from the loop. It's not loading the one that I click on. I tried using <code>event.target</code>, but that is not working. I'm pretty close to figuring it out, I'm just not sure where to look.</p>
<pre><code>// loads xml
var xml:XML = new XML();
var loader:URLLoader = new URLLoader();
loader.load(new URLRequest(audioPlaylist));
loader.addEventListener(Event.COMPLETE, onComplete);
function onComplete(evt:Event):void {
xml = XML(evt.target.data);
xmlList = xml.children();
trace(xmlList);
trackLength = xmlList.children().children().length();
trace(trackLength);
for(var i:int = 0; i < trackLength; i++) {
trace(i);
var track:Playlist_item = new Playlist_item();
track.y = i * 28;
track.playlist_text.text = xmlList.children().track[i].toString();
trackURL = xmlList.children().track[i].@rel.toString();
trace(trackURL);
playlist_container.addChild(track);
track.buttonMode = true;
track.mouseChildren=false;
track.addEventListener(MouseEvent.MOUSE_OVER, onCarHover);
track.addEventListener(MouseEvent.MOUSE_OUT, onCarOut);
track.addEventListener(MouseEvent.CLICK, onClickLoadData);
}
}
function onCarHover(event:MouseEvent):void {
event.target.gotoAndStop(6);
}
function onCarOut(event:MouseEvent):void {
event.target.gotoAndStop(10);
}
function onClickLoadData(event:MouseEvent):void {
ns.play(trackURL);
}
</code></pre>
<hr>
<p>I'm getting closer, I managed to create an array, with an index value - so now I can choose different URLs from the array to play, but I'm still unsure how to target the one that I'm clicking directly on and have that play.</p>
<p>Here is my updated code:</p>
<pre><code>// xml variables
var xmlList:XMLList;
var trackLength:Number;
var trackURL;
var trackNum:Number = -1;
var tracksArray:Array = new Array();
// loads xml
var xml:XML = new XML();
var loader:URLLoader = new URLLoader();
loader.load(new URLRequest(audioPlaylist));
loader.addEventListener(Event.COMPLETE, onComplete);
function onComplete(evt:Event):void {
xml = XML(evt.target.data);
xmlList = xml.children();
trace(xmlList);
trackLength = xmlList.children().children().length();
while (trackNum < trackLength) {
trackNum = trackNum + 1;
trace(trackNum);
var track:Playlist_item = new Playlist_item();
track.y = trackNum * 28;
playlist_container.addChild(track);
track.buttonMode = true;
track.mouseChildren=false;
track.playlist_text.text = xmlList.children().track[trackNum].toString();
//trackURL = xmlList.children().track[trackNum].@rel.toString();
tracksArray[trackNum] = xmlList.children().track[trackNum].@rel.toString();
track.addEventListener(MouseEvent.MOUSE_OVER, onCarHover);
track.addEventListener(MouseEvent.MOUSE_OUT, onCarOut);
track.addEventListener(MouseEvent.CLICK, onClickLoadData);
}
}
function onCarHover(event:MouseEvent):void {
event.target.gotoAndStop(6);
}
function onCarOut(event:MouseEvent):void {
event.target.gotoAndStop(10);
}
function onClickLoadData(event:MouseEvent):void {
trace(tracksArray[5]);
trace(event.target.trackNum);
ns.play(tracksArray[5]);
}
</code></pre>
| [
{
"answer_id": 372090,
"author": "jrutter",
"author_id": 28454,
"author_profile": "https://Stackoverflow.com/users/28454",
"pm_score": 0,
"selected": false,
"text": "trackNum"
},
{
"answer_id": 379221,
"author": "Brian Hodge",
"author_id": 20628,
"author_profile": "ht... | 2008/12/15 | [
"https://Stackoverflow.com/questions/370086",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28454/"
] |
370,087 | <p>I currently have an INSERT TRIGGER which in Oracle 10g runs a custom defined function that generates a funky alpha-numeric code that is used as part of the insert.</p>
<p>I really need to make sure that the function (or even trigger) is thread safe so that if two users activate the trigger at once, the function used within the trigger does NOT return the same code for both users.</p>
<p>The flow in the trigger is as follows:</p>
<p>START</p>
<ol>
<li>determine if we need to continue based on business logic</li>
<li>run the custom function to get new code</li>
<li>use the returned code as an insert into a different table</li>
</ol>
<p>END</p>
<p>The main issue is if while step 2 is running, a separate thread fires the trigger, which also gets into step 2, and returns the same code as the first thread. (I understand that this is a very tight situation, but we need to handle it).</p>
<p>I have thought of two main ways of doing this:</p>
<p>The currently best way that I have thought of so far is to lock the table used in the trigger in "exclusive mode" at the very start of the trigger, and <strong>do not</strong> specify the NOWAIT attribute of the lock. This way each subsequent activation of the trigger will sort of "stop and wait" for the lock to be available and hence wait for other threads to finish with the trigger.</p>
<p>I would love to lock the table any deny reading of the table, but I could seem to find out how to do this in Oracle.</p>
<p>My idea is not ideal, but it should work, however i would love to hear from anyone who may have better ideas that this!</p>
<p>Thanks a lot for any help given.</p>
<p>Cheers,
Mark</p>
| [
{
"answer_id": 370107,
"author": "BQ.",
"author_id": 4632,
"author_profile": "https://Stackoverflow.com/users/4632",
"pm_score": 3,
"selected": false,
"text": "select sys_guid() from dual;\n"
}
] | 2008/12/15 | [
"https://Stackoverflow.com/questions/370087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26310/"
] |
370,108 | <p>I'd love to use PHP variables in my CSS files but I don't want to load up the whole Symfony stack for each file load. Any one have any best practices and/or plugins to manage their CSS files in Symfony?</p>
| [
{
"answer_id": 483310,
"author": "deresh",
"author_id": 11851,
"author_profile": "https://Stackoverflow.com/users/11851",
"pm_score": 4,
"selected": true,
"text": "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"/css/mycss.php\" />\n"
}
] | 2008/12/15 | [
"https://Stackoverflow.com/questions/370108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46443/"
] |
370,113 | <pre><code>SaveFileDialog savefileDialog1 = new SaveFileDialog();
DialogResult result = savefileDialog1.ShowDialog();
switch(result == DialogResult.OK)
case true:
//do something
case false:
MessageBox.Show("are you sure?","",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
</code></pre>
<p>How to show the messagebox over the savedialog box after clicking "Cancel" on the SaveDialog box i.e. the Save Dialog box should be present on the background.</p>
| [
{
"answer_id": 370132,
"author": "lubos hasko",
"author_id": 275,
"author_profile": "https://Stackoverflow.com/users/275",
"pm_score": 1,
"selected": false,
"text": "SaveFileDialog"
},
{
"answer_id": 370235,
"author": "Patrick Desjardins",
"author_id": 13913,
"author_... | 2008/12/15 | [
"https://Stackoverflow.com/questions/370113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42564/"
] |
370,114 | <p>How would one go about adding a submenu item to the windows explorer context menu (like for example 7-Zip does) for a Java application?</p>
| [
{
"answer_id": 370130,
"author": "Jayden",
"author_id": 44873,
"author_profile": "https://Stackoverflow.com/users/44873",
"pm_score": 5,
"selected": true,
"text": "HKEY_CLASSES_ROOT\\<file type>\\shell\\<display text>\\command\n"
}
] | 2008/12/15 | [
"https://Stackoverflow.com/questions/370114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14955/"
] |
370,124 | <p>Are there any pre-written component-like Silverlight web widgets like there are for Flash? </p>
<p>Flash examples:<br>
<a href="http://musicplayer.sourceforge.net/" rel="nofollow noreferrer">XSPF Web Music Player</a><br>
<a href="http://wpaudioplayer.com/" rel="nofollow noreferrer">WordPress Audio Player</a><br>
<a href="http://www.flamplayer.com/flamplayer_demo/pages/demo.html" rel="nofollow noreferrer">FLAMPlayer</a><br>
<a href="http://www.aflax.org/demos.htm" rel="nofollow noreferrer">Aflax</a> </p>
<p>Clarification: I don't mean controls to use in your IDE to write something custom.<br>
See <a href="http://altnetpodcast.com/" rel="nofollow noreferrer">ALTNET Podcast</a><br>
I think they use the WordPress Audio Player.</p>
| [
{
"answer_id": 370130,
"author": "Jayden",
"author_id": 44873,
"author_profile": "https://Stackoverflow.com/users/44873",
"pm_score": 5,
"selected": true,
"text": "HKEY_CLASSES_ROOT\\<file type>\\shell\\<display text>\\command\n"
}
] | 2008/12/15 | [
"https://Stackoverflow.com/questions/370124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] |
370,165 | <p>I am having trouble retrieving results from my datareader in visual studio 2008. I have several stored Procs in the same database. I am able to retrieve values from those that dont receive input parameters. However, when i use the executreReader() method on a stored proc with input parameters i get an empty datareader. Upon examining the result collection the message "IEnumerable returned no results" appears. I am baffled as I can execute the stored procs within sql server and return result sets. I was previously able to retrieve rows from these stored procedures within Visual Studio but apparently it just stopped working one day.</p>
<p>I have tried using a dataadapter to fill a dataset with my results and using the executereader() method to get a sqldatareader and Still I get no results. No exceptions are thrown either. My parameters are all named properly but I should be able to call these stored procs with no parameters and have that return an unfiltered result set. The code im currently using is the following:</p>
<pre><code>string connStr = ConfigurationManager.ConnectionStrings["MyConnectionString"]
.ConnectionString;
SqlConnection connCactus = new SqlConnection(connStr);
SqlCommand cmdPopulateFilterDropDowns = new SqlCommand( "dbo.MyStoredProc",
connCactus);
SqlDataReader rdrFilterSearch = null;
cmdPopulateFilterDropDowns.CommandType = CommandType.StoredProcedure;
connCactus.Open();
rdrFilterSearch = cmdPopulateFilterDropDowns
.ExecuteReader(CommandBehavior.CloseConnection);
return (rdrFilterSearch);
</code></pre>
<p>Please Help!</p>
| [
{
"answer_id": 370177,
"author": "Kevin Tighe",
"author_id": 39461,
"author_profile": "https://Stackoverflow.com/users/39461",
"pm_score": 0,
"selected": false,
"text": "rdrFilterSearch.GetString(0);\n"
},
{
"answer_id": 370256,
"author": "BFree",
"author_id": 15861,
... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
370,174 | <p>I've got several function where I need to do a one-to-many join, using count(), group_by, and order_by. I'm using the sqlalchemy.select function to produce a query that will return me a set of id's, which I then iterate over to do an ORM select on the individual records. What I'm wondering is if there is a way to do what I need using the ORM in a single query so that I can avoid having to do the iteration.</p>
<p>Here's an example of what I'm doing now. In this case the entities are Location and Guide, mapped one-to-many. I'm trying get a list of the top locations sorted by how many guides they are related to.</p>
<pre><code>def popular_world_cities(self):
query = select([locations.c.id, func.count(Guide.location_id).label('count')],
from_obj=[locations, guides],
whereclause="guides.location_id = locations.id AND (locations.type = 'city' OR locations.type = 'custom')",
group_by=[Location.id],
order_by='count desc',
limit=10)
return map(lambda x: meta.Session.query(Location).filter_by(id=x[0]).first(), meta.engine.execute(query).fetchall())
</code></pre>
<p><strong>Solution</strong></p>
<p>I've found the best way to do this. Simply supply a <code>from_statement</code> instead of a <code>filter_by</code> or some such. Like so:</p>
<pre><code>meta.Session.query(Location).from_statement(query).all()
</code></pre>
| [
{
"answer_id": 468869,
"author": "Joshua Kifer",
"author_id": 45076,
"author_profile": "https://Stackoverflow.com/users/45076",
"pm_score": 1,
"selected": true,
"text": "from_statement"
},
{
"answer_id": 679479,
"author": "Community",
"author_id": -1,
"author_profile"... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45076/"
] |
370,183 | <p>I'm trying to achieve a 50px space at the bottom of my page, below the main content area so that no matter what text size the user is at, or how much content happens to be inside the page - there is always a proceeding 50px space after the content area which will make either the container div(transparent) or body show.</p>
<p>It sounds fairly simple, and I've fiddled about setting margins and padding to my container div and the body tag etc, but I'm having no luck what so ever. The increase in size or content pushes past whatever space I manage to create.</p>
<p>Is there a general, clean approach of producing this effect?</p>
| [
{
"answer_id": 370197,
"author": "Logan Serman",
"author_id": 29595,
"author_profile": "https://Stackoverflow.com/users/29595",
"pm_score": 0,
"selected": false,
"text": "height: 50px;\nwidth: 100%;\nposition: fixed;\nbottom: 0;\n"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46502/"
] |
370,186 | <p>This is on the Mac:</p>
<p>If I have two filenames /foo/foo and /foo/FOO they may refer to the same file or the may be different files depending on the file system. How do I figure out if they are both pointing to the same file? And if they are, how do I get the correct representation of the filename?</p>
<p>My problem is caused by links. A link might point to /foo/FOO but the actual directory is named /foo/foo.</p>
<p>Is there any function that will follow a link and give me the the full path of the linked file? [NSFileManager pathContentOfSymbolicLinkAtPath] gives relative paths that might be in the incorrect case.</p>
<p>Ultimately what I'm try to do is cache info for files. But if I have two different paths for the same file, my cache can get out of sync.</p>
<p>Thanks</p>
| [
{
"answer_id": 370295,
"author": "Boaz Stuller",
"author_id": 1464654,
"author_profile": "https://Stackoverflow.com/users/1464654",
"pm_score": 3,
"selected": false,
"text": "FSPathMakeRef()"
},
{
"answer_id": 370684,
"author": "TALlama",
"author_id": 5657,
"author_pr... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39138/"
] |
370,195 | <p>I know that the compiler will sometimes initialize memory with certain patterns such as <code>0xCD</code> and <code>0xDD</code>. What I want to know is <strong>when</strong> and <strong>why</strong> this happens.</p>
<p><H2>When</H2></p>
<p>Is this specific to the compiler used?</p>
<p>Do <code>malloc/new</code> and <code>free/delete</code> work in the same way with regard to this?</p>
<p>Is it platform specific?</p>
<p>Will it occur on other operating systems, such as <code>Linux</code> or <code>VxWorks</code>?</p>
<p><H2>Why</H2></p>
<p>My understanding is this only occurs in <code>Win32</code> debug configuration, and it is used to detect memory overruns and to help the compiler catch exceptions.</p>
<p>Can you give any practical examples as to how this initialization is useful?</p>
<p>I remember reading something (maybe in Code Complete 2) saying that it is good to initialize memory to a known pattern when allocating it, and certain patterns will trigger interrupts in <code>Win32</code> which will result in exceptions showing in the debugger.</p>
<p>How portable is this?</p>
| [
{
"answer_id": 370217,
"author": "Martin Beckett",
"author_id": 10897,
"author_profile": "https://Stackoverflow.com/users/10897",
"pm_score": 3,
"selected": false,
"text": "malloc"
},
{
"answer_id": 370229,
"author": "FryGuy",
"author_id": 28776,
"author_profile": "ht... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22489/"
] |
370,202 | <p>I'm using Grails to send a large number of HTML emails. I use the SimpleTemplateEngine to create my email bodies in this fashion:</p>
<pre><code>def ccIdToEmailMap = [:]
def emailTemplateFile = Utilities.retrieveFile("email${File.separator}emailTemplate.gtpl")
def engine = new SimpleTemplateEngine()
def clientContacts = ClientContact.list()
for(ClientContact cc in clientContactList) {
def binding = [clientContact : cc]
//STOPS (FREEZES) EITHER HERE OR....
def template = template = engine.createTemplate(emailTemplateFile).make(binding)
//OR STOPS (FREEZES) HERE
def body = template.toString()
def email = [text: body, to: cc.emailAddress]
ccIdToEmailMap.put(cc.id, email)
println "added to map"
}
return ccIdToEmailMap
</code></pre>
<p>Here is the template I'm trying to render for each email body:</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Happy Holidays from google Partners</title>
</head>
<body>
<table width="492" cellpadding="0" cellspacing="0" style="border:2px solid #acacac;margin:8px auto;" align="center">
<tr>
<td colspan="5" bgcolor="#c1e0f3"><img src="http://www.google.com/holiday2008/cardbg.gif" width="492" height="10" border="0"></td>
</tr>
<tr>
<td width="6" bgcolor="#c1e0f3"><img src="http://www.google.com/holiday2008/sidebgl.gif" width="6" height="453" border="0"></td>
<td style="background:#fff;border:1px solid #acacac;padding:2px;" width="228">
<div style="width:208px;margin:4px 8px 0px 8px; color:#515151;">
<font face="Times New Roman" size="2">
<span style="font:14px 'Times New Roman',times,serif;">Static text that is the same for each email
<br>&nbsp;<br>
More text
<br>&nbsp;<br>
We wish you health and happiness during the holidays and a year of growth in 2009.
</span>
</font>
</div>
</td>
<td style="background:#c9f4fe;border-top:1px solid #acacac;border-bottom:1px solid #acacac;" width="5"><img src="http://www.google.com/holiday2008/vertbg.gif" border="0" height="453" width="5"></td>
<td width="247" style="background:#fff;border:1px solid #acacac;"><img src="http://www.google.com/holiday2008/snowing.gif" width="247" height="453" border="0"></td>
<td width="6" bgcolor="#c1e0f3"><img src="http://www.google.com/holiday2008/sidebgr.gif" width="6" height="453" border="0"></td>
</tr>
<tr>
<td width="6" bgcolor="#c1e0f3"><img src="http://www.google.com/holiday2008/sidebgr.gif" width="6" height="38" border="0"></td>
<td colspan="3" style="border:1px solid #acacac;" align="center"><img src="http://www.google.com/holiday2008/happyholidays.gif" width="480" height="38" alt="Happy Holidays" border="0"></td>
<td width="6" bgcolor="#c1e0f3"><img src="http://www.google.com/holiday2008/sidebgr.gif" width="6" height="38" border="0"></td>
</tr>
<tr>
<td width="6" bgcolor="#c1e0f3"><img src="http://www.google.com/holiday2008/sidebgr.gif" width="6" height="120" border="0"></td>
<td colspan="3" style="background-color#fff;border:1px solid #acacac;padding:2px;" valign="top">
<img src="http://www.google.com/holiday2008/gogl_logo_card.gif" width="140" height="40" alt="google partners" border="0" align="right" hspace="4" vspace="4" />
<font face="Times New Roman" size="2">
<div style="padding:4px;font:12pt 'Times New Roman',serif;color:#515151;">
<span style="font-size:10pt"><i>from:</i></span>
<div style="padding:2px 4px;">
<% clientContact.owners.eachWithIndex { it, i -> %>
<% if(i < (clientContact.owners.size() - 1)) { %>
${it.toString()},
<% }else { %>
${it.toString()}
<% } %>
<% } %>
</div>
</div>
</font>
</td>
<td width="6" bgcolor="#c1e0f3"><img src="http://www.google.com/holiday2008/sidebgr.gif" width="6" height="120" border="0"></td>
</tr>
<tr>
<td colspan="5" bgcolor="#c1e0f3"><img src="http://www.google.com/holiday2008/cardbg.gif" width="492" height="10" border="0"></td>
</tr>
</table>
</body>
</html>
</code></pre>
<p>Once this methods returns the ccIdToEmail map, I send out all of my emails. For some reason, preparing this map of clientContactIds and email bodies causes my application to freeze at either of the two lines listed above. I can successfully prepare/send ~140 emails before it freezes. This happens very consistently.</p>
<p>Does anyone know why this would work but then stop working after a ~140 email bodies are created from a template? I haven't been able to find anything online about other peope having trouble with this.</p>
<p>Andrew</p>
| [
{
"answer_id": 370727,
"author": "Siegfried Puchbauer",
"author_id": 46301,
"author_profile": "https://Stackoverflow.com/users/46301",
"pm_score": 1,
"selected": false,
"text": " def ccIdToEmailMap = [:]\n def emailTemplateFile = Utilities.retrieveFile(\"email${File.separator}email... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21832/"
] |
370,204 | <p>Is there a way to run a specific Ant task via the keyboard? I have a rsync to dev task that I run a lot and running to the mouse to double-click is a pain.</p>
| [
{
"answer_id": 370609,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 5,
"selected": true,
"text": "\"Run Last Launched External Tool\""
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46443/"
] |
370,211 | <p>I wanna stop the reading of my text input file when the word "synonyms" appears. I'm using ifstream and I don't know how to break the loop. I tried using a stringstream "synonyms" but it ended up junking my bst. I included the complete project files below in case you wanna avoid typing. </p>
<p>Important part:</p>
<pre><code> for(;;) /*here, I wanna break the cycle when it reads "synonyms"*/
{
inStream >> word;
if (inStream.eof()) break;
wordTree.insert(word);
}
wordTree.graph(cout);
</code></pre>
<p>dictionary.txt</p>
<pre><code> 1 cute
2 hello
3 ugly
4 easy
5 difficult
6 tired
7 beautiful
synonyms
1 7
7 1
antonyms
1 3
3 1 7
4 5
5 4
7 3
</code></pre>
<p>Project.cpp</p>
<pre><code>#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include "MiBST.h"
using namespace std;
class WordInfo{
public:
//--id accesor
int id ()const {return myId; }
/* myId is the number that identifies each word*/
//--input function
void read (istream &in)
{
in>>myId>>word;
}
//--output function
void print(ostream &out)
{
out<<myId<<" "<<word;
}
//--- equals operator
bool operator==(const WordInfo & otherword) const
{ return myId == otherword.myId; }
//--- less-than operator
bool operator<(const WordInfo & otherword) const
{ return myId < otherword.myId; }
private:
int myId;
string word;
};
//--- Definition of input operator
istream & operator>>(istream & in, WordInfo & word)
{
word.read(in);
}
//---Definition of output operator
ostream & operator <<(ostream &out, WordInfo &word)
{
word.print(out);
}
int main(){
// Open stream to file of ids and words
string wordFile;
cout << "Enter name of dictionary file: ";
getline(cin, wordFile);
ifstream inStream(wordFile.data());
if (!inStream.is_open())
{
cerr << "Cannot open " << wordFile << "\n";
exit(1);
}
// Build the BST of word records
BST<WordInfo> wordTree; // BST of word records
WordInfo word; // a word record
for(;;) /*here, I wanna break the cycle when it reads "synonyms"*/
{
inStream >> word;
if (inStream.eof()) break;
wordTree.insert(word);
}
wordTree.graph(cout);
//wordTree.inorder(cout);
system ("PAUSE");
return 0;
}
</code></pre>
<p>MiBST.h (in case you wanna run it)</p>
<pre><code>#include <iostream>
#include <iomanip>
#ifndef BINARY_SEARCH_TREE
#define BINARY_SEARCH_TREE
template <typename DataType>
class BST
{
public:
/***** Function Members *****/
BST();
bool empty() const;
bool search(const DataType & item) const;
void insert(const DataType & item);
void remove(const DataType & item);
void inorder(std::ostream & out) const;
void graph(std::ostream & out) const;
private:
/***** Node class *****/
class BinNode
{
public:
DataType data;
BinNode * left;
BinNode * right;
// BinNode constructors
// Default -- data part is default DataType value; both links are null.
BinNode()
: left(0), right(0)
{}
// Explicit Value -- data part contains item; both links are null.
BinNode(DataType item)
: data(item), left(0), right(0)
{}
}; //end inner class
typedef BinNode * BinNodePointer;
/***** Private Function Members *****/
void search2(const DataType & item, bool & found,
BinNodePointer & locptr, BinNodePointer & parent) const;
/*------------------------------------------------------------------------
Locate a node containing item and its parent.
Precondition: None.
Postcondition: locptr points to node containing item or is null if
not found, and parent points to its parent.#include <iostream>
------------------------------------------------------------------------*/
void inorderAux(std::ostream & out,
BST<DataType>::BinNodePointer subtreePtr) const;
/*------------------------------------------------------------------------
Inorder traversal auxiliary function.
Precondition: ostream out is open; subtreePtr points to a subtree
of this BST.
Postcondition: Subtree with root pointed to by subtreePtr has been
output to out.
------------------------------------------------------------------------*/
void graphAux(std::ostream & out, int indent,
BST<DataType>::BinNodePointer subtreeRoot) const;
/*------------------------------------------------------------------------
Graph auxiliary function.
Precondition: ostream out is open; subtreePtr points to a subtree
of this BST.
Postcondition: Graphical representation of subtree with root pointed
to by subtreePtr has been output to out, indented indent spaces.
------------------------------------------------------------------------*/
/***** Data Members *****/
BinNodePointer myRoot;
}; // end of class template declaration
//--- Definition of constructor
template <typename DataType>
inline BST<DataType>::BST()
: myRoot(0)
{}
//--- Definition of empty()
template <typename DataType>
inline bool BST<DataType>::empty() const
{ return myRoot == 0; }
//--- Definition of search()
template <typename DataType>
bool BST<DataType>::search(const DataType & item) const
{
typename BST<DataType>::BinNodePointer locptr = myRoot;
typename BST<DataType>::BinNodePointer parent =0;
/* BST<DataType>::BinNodePointer locptr = myRoot;
parent = 0; */ //falta el typename en la declaracion original
bool found = false;
while (!found && locptr != 0)
{
if (item < locptr->data) // descend left
locptr = locptr->left;
else if (locptr->data < item) // descend right
locptr = locptr->right;
else // item found
found = true;
}
return found;
}
//--- Definition of insert()
template <typename DataType>
inline void BST<DataType>::insert(const DataType & item)
{
typename BST<DataType>::BinNodePointer
locptr = myRoot, // search pointer
parent = 0; // pointer to parent of current node
bool found = false; // indicates if item already in BST
while (!found && locptr != 0)
{
parent = locptr;
if (item < locptr->data) // descend left
locptr = locptr->left;
else if (locptr->data < item) // descend right
locptr = locptr->right;
else // item found
found = true;
}
if (!found)
{ // construct node containing item
locptr = new typename BST<DataType>::BinNode(item);
if (parent == 0) // empty tree
myRoot = locptr;
else if (item < parent->data ) // insert to left of parent
parent->left = locptr;
else // insert to right of parent
parent->right = locptr;
}
else
std::cout << "Item already in the tree\n";
}
//--- Definition of remove()
template <typename DataType>
void BST<DataType>::remove(const DataType & item)
{
bool found; // signals if item is found
typename BST<DataType>::BinNodePointer
x, // points to node to be deleted
parent; // " " parent of x and xSucc
search2(item, found, x, parent);
if (!found)
{
std::cout << "Item not in the BST\n";
return;
}
//else
if (x->left != 0 && x->right != 0)
{ // node has 2 children
// Find x's inorder successor and its parent
typename BST<DataType>::BinNodePointer xSucc = x->right;
parent = x;
while (xSucc->left != 0) // descend left
{
parent = xSucc;
xSucc = xSucc->left;
}
// Move contents of xSucc to x and change x
// to point to successor, which will be removed.
x->data = xSucc->data;
x = xSucc;
} // end if node has 2 children
// Now proceed with case where node has 0 or 2 child
typename BST<DataType>::BinNodePointer
subtree = x->left; // pointer to a subtree of x
if (subtree == 0)
subtree = x->right;
if (parent == 0) // root being removed
myRoot = subtree;
else if (parent->left == x) // left child of parent
parent->left = subtree;
else // right child of parent
parent->right = subtree;
delete x;
}
//--- Definition of inorder()
template <typename DataType>
inline void BST<DataType>::inorder(std::ostream & out) const
{
inorderAux(out, myRoot);
}
//--- Definition of graph()
template <typename DataType>
inline void BST<DataType>::graph(std::ostream & out) const
{ graphAux(out, 0, myRoot); }
//--- Definition of search2()
template <typename DataType>
void BST<DataType>::search2(const DataType & item, bool & found,
BST<DataType>::BinNodePointer & locptr,
BST<DataType>::BinNodePointer & parent) const
{
locptr = myRoot;
parent = 0;
found = false;
while (!found && locptr != 0)
{
if (item < locptr->data) // descend left
{
parent = locptr;
locptr = locptr->left;
}
else if (locptr->data < item) // descend right
{
parent = locptr;
locptr = locptr->right;
}
else // item found
found = true;
}
}
//--- Definition of inorderAux()
template <typename DataType>
void BST<DataType>::inorderAux(std::ostream & out,
BST<DataType>::BinNodePointer subtreeRoot) const
{
if (subtreeRoot != 0)
{
inorderAux(out, subtreeRoot->left); // L operation
out << subtreeRoot->data << " "; // V operation
inorderAux(out, subtreeRoot->right); // R operation
}
}
//--- Definition of graphAux()
template <typename DataType>
void BST<DataType>::graphAux(std::ostream & out, int indent,
BST<DataType>::BinNodePointer subtreeRoot) const
{
if (subtreeRoot != 0)
{
graphAux(out, indent + 8, subtreeRoot->right);
out << std::setw(indent) << " " << subtreeRoot->data << std::endl;
graphAux(out, indent + 8, subtreeRoot->left);
}
}
#endif
</code></pre>
| [
{
"answer_id": 370225,
"author": "SoapBox",
"author_id": 36384,
"author_profile": "https://Stackoverflow.com/users/36384",
"pm_score": 2,
"selected": false,
"text": "if ( word == \"synonyms\" ) break;\n"
},
{
"answer_id": 370236,
"author": "Johannes Schaub - litb",
"autho... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45963/"
] |
370,215 | <p>I am trying to process an uploaded file in a Perl program, using CGI::Application. I need to get the content type of the uploaded file. From what I read, the following should work, but it doesn't for me:</p>
<pre><code>my $filename = $q->param("file");
my $contenttype = $q->uploadInfo($filename)->{'Content-Type'};
</code></pre>
<p>As it turns out, <code>$q->uploadInfo($filename)</code> returns <code>undef</code>. So does <code>$q->uploadInfo("file")</code>.</p>
<p>Any ideas?</p>
<p>Thanks!</p>
| [
{
"answer_id": 370342,
"author": "ysth",
"author_id": 17389,
"author_profile": "https://Stackoverflow.com/users/17389",
"pm_score": 4,
"selected": true,
"text": "chomp(my $mime_type = qx!file -i $uploaded!);\n$mime_type =~ s/^.*?: //;\n$mime_type =~ s/;.*//;\n"
},
{
"answer_id": ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4257/"
] |
370,218 | <p>I'm trying to setup a second ruby install in my home directory (a different version of ruby for testing). I've compiled ruby into <code>~/bin/</code> and everything is working until I try to install rubygems.</p>
<p>I have <code>GEM_HOME</code> set to <code>~/gems</code> directory and <code>GEM_PATH</code> set to the same. Then I try to install rubygems with</p>
<pre><code>~/bin/ruby setup.rb
</code></pre>
<p>The installation appears to succeed but ruby can't find rubygems after the install. </p>
<pre><code>$~/bin/irb
irb(main):001:0> require 'rubygems'
LoadError: no such file to load -- rubygems
from (irb):1:in `require'
from (irb):1
</code></pre>
<p>Anyone have any idea why ruby can't find rubygems?</p>
| [
{
"answer_id": 370355,
"author": "Gordon Wilson",
"author_id": 23071,
"author_profile": "https://Stackoverflow.com/users/23071",
"pm_score": 3,
"selected": true,
"text": "GEM_HOME"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46505/"
] |
370,222 | <p>How can instantiated classes <strong>access the Document class?</strong></p>
<p>Even after I <strong>name the Document class</strong> using the Properties bar in Flash, attempting to access it from other classes usually fails, saying <em>"attempting to access an undefined property...</em></p>
<p>One solution is always <strong>casting the Document class to itself!</strong> eg.</p>
<pre><code>Main(Main).globalMethod();
</code></pre>
<p>But sometimes even this stellar gotcha fails, and then there's usually no way out, apart from <strong>the obvious!</strong></p>
<pre><code>class Other{
var parentClass:Main;
public function Other(parent:Main){
parentClass = parent; // pointer to the Main class in a local var!
Main(parentClass).globalMethod();
}
}
</code></pre>
| [
{
"answer_id": 371625,
"author": "Matt W",
"author_id": 32396,
"author_profile": "https://Stackoverflow.com/users/32396",
"pm_score": 2,
"selected": false,
"text": "stage.getChildAt( 0 );"
},
{
"answer_id": 373591,
"author": "aaaidan",
"author_id": 26331,
"author_prof... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41021/"
] |
370,258 | <p>I've been reading about the <a href="http://en.wikipedia.org/wiki/Open/closed_principle" rel="noreferrer">OCP principle</a> and how to use the strategy pattern to accomplish this.</p>
<p>I was going to try and explain this to a couple of people, but the only example I can think of is using different validation classes based on what status an "order" is.</p>
<p>I've read a couple of articles online, but these don't usually describe a real alike reason to use the strategy, like generating reports/bills/validation, etc...</p>
<p>Are there any real-world examples where you think a strategy pattern is common?</p>
| [
{
"answer_id": 370270,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": 7,
"selected": false,
"text": " File file = getFile();\n Cipher c = CipherFactory.getCipher( file.size() );\n c.performAction();\n\n\n\n// implementatio... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
370,259 | <p>I've been working with Swing for a while now but the whole model/structure of <code>JFrame</code>s, <code>paint()</code>, <code>super</code>, etc is all murky in my mind.
I need a clear explanation or link that will explain how the whole GUI system is organized.</p>
| [
{
"answer_id": 370284,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": 5,
"selected": true,
"text": "JLabel"
},
{
"answer_id": 371815,
"author": "coobird",
"author_id": 17172,
"author_profile": "https://... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51518/"
] |
370,265 | <p>Newbie question.</p>
<p>I have a NSMutableArray that holds multiple objects (objects that stores Bezier paths and related variables e.g. path colour etc.) These are properly released whenever the relevant <code>-dealloc</code> method is called. Each object is instantiated with <code>+alloc/-init</code> and added to the array. After adding them to the array I <code>release</code> the object and hence their retainCount=1 (due to the array). Thus, when the array is released, the objects are also properly <code>dealloc</code>ated.</p>
<p>But, I'm also implementing an undo/redo mechanism that removes/adds these objects from/to the NSMutable array. </p>
<p>My question is, when an undo removes the object from the array, they are not released (otherwise redo will not work) so if redo is never called, how do you properly release these object?</p>
<p>Hope that makes sense! Thanks!</p>
| [
{
"answer_id": 370438,
"author": "Marc Charbonneau",
"author_id": 35136,
"author_profile": "https://Stackoverflow.com/users/35136",
"pm_score": 3,
"selected": true,
"text": "registerUndoWithTarget:"
},
{
"answer_id": 370607,
"author": "Ashley Clark",
"author_id": 4556,
... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370265",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41880/"
] |
370,267 | <p>This may seem like a stupid question, so here goes:</p>
<p>Other than parsing the string of FileInfo.FullPath for the drive letter to then use DriveInfo("c") etc to see if there is enough space to write this file. Is there a way to get the drive letter from FileInfo?</p>
| [
{
"answer_id": 370279,
"author": "Joel Martinez",
"author_id": 5416,
"author_profile": "https://Stackoverflow.com/users/5416",
"pm_score": -1,
"selected": false,
"text": "FullPath.Substring(0,1);\n"
},
{
"answer_id": 370287,
"author": "BFree",
"author_id": 15861,
"aut... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28717/"
] |
370,268 | <p>Is this</p>
<pre><code>... T1 join T2 using(ID) where T2.VALUE=42 ...
</code></pre>
<p>the same as</p>
<pre><code>... T1 join T2 on(T1.ID=T2.ID) where T2.VALUE=42 ...
</code></pre>
<p>for all types of joins?</p>
<p>My understanding of <code>using(ID)</code> is that it's just shorthand for <code>on(T1.ID=T2.ID)</code>. Is this true?</p>
<p><br />
Now for another question:</p>
<p>Is the above the same as</p>
<pre><code>... T1 join T2 on(T1.ID=T2.ID and T2.VALUE=42) ...
</code></pre>
<p>This I don't think is true, but why? How does conditions in the on clause interact with the join vs if its in the where clause?</p>
| [
{
"answer_id": 370317,
"author": "Cebjyre",
"author_id": 1612,
"author_profile": "https://Stackoverflow.com/users/1612",
"pm_score": 5,
"selected": true,
"text": "T1 JOIN T2 USING(id) JOIN T3 USING(id_2)\n"
},
{
"answer_id": 370332,
"author": "Bill Karwin",
"author_id": 2... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21838/"
] |
370,273 | <p>I have a whole bunch of POV-RAY files from a molecular dynamics simulation with the general name "frameXX.pov" where "XX" is the number of the frame. I want to render them all but I have like 500 so I really don't wanna do it by hand. I'm sure there is a way to do this from the command line or a batch file...what would be the best way to do it? Thanks for the help :)</p>
| [
{
"answer_id": 558266,
"author": "stevenvh",
"author_id": 66056,
"author_profile": "https://Stackoverflow.com/users/66056",
"pm_score": 3,
"selected": true,
"text": "Input_File_Name=somegreatscene.pov\n\n; these are the default values\nInitial_Clock=0.000\nFinal_CLock=1.000\n\n; usually ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41718/"
] |
370,283 | <p>I noticed C++ will not compile the following:</p>
<pre><code>class No_Good {
static double const d = 1.0;
};
</code></pre>
<p>However it will happily allow a variation where the double is changed to an int, unsigned, or any integral type:</p>
<pre><code>class Happy_Times {
static unsigned const u = 1;
};
</code></pre>
<p>My solution was to alter it to read:</p>
<pre><code>class Now_Good {
static double d() { return 1.0; }
};
</code></pre>
<p>and figure that the compiler will be smart enough to inline where necessary... but it left me curious.</p>
<p>Why would the C++ designer(s) allow me to static const an int or unsigned, but not a double?</p>
<p>Edit: I am using visual studio 7.1 (.net 2003) on Windows XP.</p>
<p>Edit2:</p>
<p>Question has been answered, but for completion, the error I was seeing:</p>
<pre><code>error C2864: 'd' : only const static integral data members can be initialized inside a class or struct
</code></pre>
| [
{
"answer_id": 370293,
"author": "Mark Ransom",
"author_id": 5987,
"author_profile": "https://Stackoverflow.com/users/5987",
"pm_score": 2,
"selected": false,
"text": "class Now_Better\n{\n static double const d;\n};\n"
},
{
"answer_id": 370311,
"author": "Adam Rosenfield"... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370283",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29703/"
] |
370,286 | <p>The code below pretty much sums up what I want to achieve. </p>
<p>We have a solution which comprises many different projects however we have a need to be able to call methods in projects from projects which are not referenced (would cause circular reference).</p>
<p>I have posted previous questions and the code below is pretty much what I have come up with using interfaces. I still do not know how I can call a method that resides in a different project that is not referenced.</p>
<p>I cannot create an instance of the interface, it has to be a class. But how can I create an instance of a class that is not referenced. I do not want to use reflection for this. </p>
<p>Code is C# 2.0</p>
<p>Any help is appreciated.</p>
<p>What code do I need to place in "GeneralMethod" (Class Raise) to be able to execute the "Update" method in Class "Listen" ?</p>
<pre><code>// Link Project
namespace Stack.Link
{
public class Interface
{
public interface Update
{
void Update();
}
}
}
// Project A
// References Link only
namespace Stack.ProjA
{
public class Raise
{
public void GeneralMethod()
{
// I want to place code in here to be able to execute
// "Update" method in ProjB.
// Keep in mind that ProjA and ProjB only reference
// Link Project
}
}
}
// Project B
// References Link only
namespace Stack.ProjB
{
public class Listen : Stack.Link.Interface.Update
{
public void Update()
{
// Do something here that is executed from ProjA
Console.Write("Executed Method in ProjB");
}
}
}
</code></pre>
<p>I should probably clarify the motivation behind needing to do this. Perhaps there is a better way ....</p>
<p>We have a baseform from which all other projects are referenced. As an example we pass an object which contains various settings to the project when it is loaded (from the baseform).</p>
<p>If for example, the settings object has some variables change (settings object populated in baseform), we would like the loaded project to listen for this change and obtain a new settings object.</p>
<p>Because the baseform references all the other projects, we need to have the projects "listen" for events in the baseform.</p>
<p>Clear as mud :-)</p>
| [
{
"answer_id": 370302,
"author": "Andrew Kennan",
"author_id": 22506,
"author_profile": "https://Stackoverflow.com/users/22506",
"pm_score": 1,
"selected": false,
"text": "public interface IThing { void Update(); }\n\npublic static class ThingRegistry {\n public static void RegisterThin... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
370,291 | <p>I'm deserializing a class called <code>Method</code> using .NET Serialization. <code>Method</code> contains a list of objects implementing <code>IAction</code>. I originally used the <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlincludeattribute.aspx" rel="nofollow noreferrer"><code>[XmlInclude]</code></a> attribute to specify all classes which implement <code>IAction</code>. </p>
<p>But now, I'd like to change my program to load all the dll's in a directory and strip out the classes which implement <code>IAction</code>. Then users can deserialize files which contain their actions implementing <code>IAction</code>. </p>
<p>I don't control the classes which implement <code>IAction</code> anymore, therefore I can't use <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlincludeattribute.aspx" rel="nofollow noreferrer"><code>[XmlInclude]</code></a>.</p>
<p>Is there a way to set this attribute at runtime? Or have a similar attribute set for the implementing class?</p>
<pre><code>public class Method
{
public List<Actions.IAction> Actions = new List<Actions.IAction>();
}
public interface IAction
{
void DoExecute();
}
public static Type[] LoadActionPlugins(string pluginDirectoryPath)
{
List<Type> pluginTypes = new List<Type>();
string[] filesInDirectory = Directory.GetFiles(pluginDirectoryPath, "*.dll", SearchOption.TopDirectoryOnly);
foreach (string pluginPath in filesInDirectory)
{
System.Reflection.Assembly actionPlugin = System.Reflection.Assembly.LoadFrom(pluginPath);
Type[] assemblyTypes = actionPlugin.GetTypes();
foreach (Type type in assemblyTypes)
{
Type foundInterface = type.GetInterface("IAction");
if (foundInterface != null)
{
pluginTypes.Add(type);
}
}
}
return pluginTypes.Count == 0 ? null : pluginTypes.ToArray();
}
</code></pre>
| [
{
"answer_id": 370395,
"author": "David Norman",
"author_id": 34502,
"author_profile": "https://Stackoverflow.com/users/34502",
"pm_score": 4,
"selected": true,
"text": "public XmlSerializer(\n Type type,\n Type[] extraTypes\n);\n"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/165305/"
] |
370,292 | <p>Is it worth changing my code to be "more portable" and able to deal with the horror of magic quotes, or should I just make sure that it's always off via a .htaccess file?</p>
<pre><code>if (get_magic_quotes_gpc()) {
$var = stripslashes($_POST['var']);
} else {
$var = $_POST['var'];
}
</code></pre>
<p>Versus</p>
<pre><code>php_flag magic_quotes_gpc off
</code></pre>
| [
{
"answer_id": 370339,
"author": "Zan Lynx",
"author_id": 13422,
"author_profile": "https://Stackoverflow.com/users/13422",
"pm_score": 2,
"selected": false,
"text": "get_magic_quotes_gpc()"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
370,310 | <p>I have a JPanel full of JTextFields...</p>
<pre><code>for (int i=0; i<maxPoints; i++) {
JTextField textField = new JTextField();
points.add(textField);
}
</code></pre>
<p>How do I later get the JTextFields in that JPanel? Like if I want their values with </p>
<pre><code>TextField.getText();
</code></pre>
<p>Thanks</p>
| [
{
"answer_id": 370341,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": 5,
"selected": true,
"text": "List<JTextField> list = new ArrayLists<JTextField>();\n\n// your code...\nfor (int i=0; i<maxPoints; i++) { \n JTextFie... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51518/"
] |
370,322 | <p>How can I remove the very first "1" from any string if that string starts with a "1"?</p>
<pre><code>"1hello world" => "hello world"
"112345" => "12345"
</code></pre>
<p>I'm thinking of doing</p>
<pre><code>string.sub!('1', '') if string =~ /^1/
</code></pre>
<p>but I' wondering there's a better way. Thanks!</p>
| [
{
"answer_id": 370331,
"author": "Zach Langley",
"author_id": 45230,
"author_profile": "https://Stackoverflow.com/users/45230",
"pm_score": 7,
"selected": true,
"text": "sub!"
},
{
"answer_id": 370334,
"author": "Gordon Wilson",
"author_id": 23071,
"author_profile": "... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
370,325 | <p>I have a .NET DLL and application. The DLL is written in C++/CLI and it's "mixed", i.e., partially managed code and partially native. </p>
<p>I have two goals:<br/>
1. Obfuscate all the managed code so it can't be disassembled<br/>
2. Obfuscate the public methods/classes of the mixed DLL so no one can use the DLL in their own applications, i.e., scramble the public names.</p>
<p>Yes, I understand obfuscation isn't perfect and people can still figure it out and blah blah. The two goals are a management requirement. The only app I've found that can handle this appears to be the Dotfuscator Professional Edition. Unfortunately it is one of those incredibly annoying apps where you have to beg a salesman to tell you the price. Does anyone know of a another solution, or know of a good place to buy a cheap, legal copy? </p>
<p>Don't tell me to rewrite the DLL in managed code, that would take a month of work and I'd never get approval. :-)</p>
<p>Note that I'm not particularly paranoid about how <em>good</em> the obfuscation is. Anything that scrambles the names of all the methods and classes in the app is probably good enough.</p>
<p>Here are the other obfuscators I have tried:</p>
<ul>
<li><p>Dotfuscator Community Edition comes with Visual Studio 2008 but doesn't support mixed assemblies.</p></li>
<li><p>Eazfuscator .NET is simple and free but doesn't support mixed assemblies.</p></li>
<li><p>{smartassembly} is $500 for a single license. It has some interesting features, but it doesn't support mixed assemblies.</p></li>
<li><p>Salamander is $800. Claims to fully support mixed assemblies, but whenever I tried to use the obfuscated dll, the application crashed</p></li>
<li><p>.NET Reactor is $180 for a single developer license. It supports "partial" obfuscation of mixed DLLs. Unfortunately if you obfuscate the <em>public</em> types on the DLL it doesn't work, the .exe can't find the classes. It has the ability to merge/pack DLLs into an .exe but when you do it with a mixed DLL it doesn't work (the exe can't find the DLL's assembly, even though it's part of the .exe)</p></li>
<li><p>Skater is $300 for a single license. I don't see anything on their website claiming it supports mixed assemblies and I'm tired of trying apps only to be disappointed so I'm going to assume it doesn't.</p></li>
</ul>
<p>I have also tried Microsoft's ILMerge to see if I could merge the DLL with the .exe and then obfuscate, but it appears that also chokes on mixed DLLs.</p>
<p>Any suggestions for an alternative to Dotfuscator or a good place to buy a legitimate copy? I found a couple of no-name sites claiming to sell it cheap but I assume those are Russian pirated versions.</p>
| [
{
"answer_id": 370429,
"author": "faulty",
"author_id": 20007,
"author_profile": "https://Stackoverflow.com/users/20007",
"pm_score": -1,
"selected": false,
"text": "[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];\n"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24267/"
] |
370,340 | <p>Say I wanted to have a project, and one-to-many with to-do items, and wanted to re-order the to-do items arbitrarily? </p>
<p>In the past, I've added a numbered order field, and when someone wants to change the order, had to update all the items with their new order numbers. This is probably the worst approach, since it's not atomic & required several updates.</p>
<p>I notice Django has a multi-valued CommaSeparatedIntegerField which could contain the order by storing the ordered keys to the items in the to-do items table right in one field of the project table.</p>
<p>I've pondered a dewey decimal system where if I wanted to take item 3 and put it between 1 and 2 I would change it's order number to 1.5.</p>
<p>Something tells me there's an easier option that I'm missing though...</p>
<p>How would you give order to a one-to-many relationship?</p>
| [
{
"answer_id": 375370,
"author": "Peter Rowell",
"author_id": 17017,
"author_profile": "https://Stackoverflow.com/users/17017",
"pm_score": 4,
"selected": true,
"text": "{% extends 'admin/change_form.html' %}\n\n{% block form_top %}{% endblock %}\n{% block extrahead %}{{ block.super }}\n... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35922/"
] |
370,353 | <p>I'm refactoring some client-server code and it uses the terms Response, Result & Reply for the same thing (an answer from the server). And although its not really that important it's become hard to guess which word to use while writing new code, so I'd like to unify the three terms into one and do the appropriate refactoring, but I'm not sure which word is the "best", if there is such a thing.</p>
<p>Any suggestions based on precedence and standards towards naming for this case?</p>
| [
{
"answer_id": 2602641,
"author": "Carl Manaster",
"author_id": 82118,
"author_profile": "https://Stackoverflow.com/users/82118",
"pm_score": 2,
"selected": false,
"text": "Response"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15124/"
] |
370,357 | <p>The following code works as expected in both Python 2.5 and 3.0:</p>
<pre><code>a, b, c = (1, 2, 3)
print(a, b, c)
def test():
print(a)
print(b)
print(c) # (A)
#c+=1 # (B)
test()
</code></pre>
<p>However, when I uncomment line <strong>(B)</strong>, I get an <code>UnboundLocalError: 'c' not assigned</code> at line <strong>(A)</strong>. The values of <code>a</code> and <code>b</code> are printed correctly. I don't understand:</p>
<ol>
<li><p>Why is there a runtime error raised at line <strong>(A)</strong> because of a later statement on line <strong>(B)</strong>?</p>
</li>
<li><p>Why are variables <code>a</code> and <code>b</code> printed as expected, while <code>print(c)</code> raises an error?</p>
</li>
</ol>
<p>The only explanation I can come up with is that the assignment <code>c+=1</code> creates a <strong>local</strong> variable <code>c</code>, which takes precedence over the global <code>c</code>. But how can a variable "steal" scope before it exists? Why is <code>c</code> apparently local here?</p>
<hr />
<p><sub>See also <a href="https://stackoverflow.com/questions/423379/">Using global variables in a function</a> for questions that are simply about how to reassign a global variable from within a function, and <a href="https://stackoverflow.com/questions/8447947">Is it possible to modify variable in python that is in outer, but not global, scope?</a> for reassigning from an enclosing function (closure). See <a href="https://stackoverflow.com/questions/4693120">Why isn't the 'global' keyword needed to access a global variable?</a> for cases where OP <em>expected</em> an error but <em>didn't</em> get one, from simply accessing a global without the <code>global</code> keyword.</sub></p>
| [
{
"answer_id": 370363,
"author": "recursive",
"author_id": 44743,
"author_profile": "https://Stackoverflow.com/users/44743",
"pm_score": 9,
"selected": true,
"text": "c"
},
{
"answer_id": 370364,
"author": "Mongoose",
"author_id": 46523,
"author_profile": "https://Sta... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46521/"
] |
370,359 | <p>I'm creating HTML with a loop that has a column for Action. That column
is a Hyperlink that when the user clicks calls a JavaScript
function and passes the parameters...</p>
<p>example:</p>
<pre><code><a href="#" OnClick="DoAction(1,'Jose');" > Click </a>
<a href="#" OnClick="DoAction(2,'Juan');" > Click </a>
<a href="#" OnClick="DoAction(3,'Pedro');" > Click </a>
...
<a href="#" OnClick="DoAction(n,'xxx');" > Click </a>
</code></pre>
<p>I want that function to call an Ajax jQuery function with the correct
parameters.</p>
<p>Any help?</p>
| [
{
"answer_id": 370391,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 8,
"selected": true,
"text": "function DoAction( id, name )\n{\n $.ajax({\n type: \"POST\",\n url: \"someurl.php\",\n data:... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46522/"
] |
370,366 | <p>I noticed for a while now the following syntax in some of our code:</p>
<pre><code>if( NULL == var){
//...
}
</code></pre>
<p>or</p>
<pre><code>if( 0 == var){
//...
}
</code></pre>
<p>and similar things.</p>
<p>Can someone please explain why did the person who wrote this choose this notation instead of the common <code>var == 0</code> way)?</p>
<p>Is it a matter of style, or does it somehow affect performance?</p>
| [
{
"answer_id": 370370,
"author": "jpoh",
"author_id": 4368,
"author_profile": "https://Stackoverflow.com/users/4368",
"pm_score": 3,
"selected": false,
"text": "if (var = NULL)\n"
},
{
"answer_id": 370373,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14587/"
] |
370,369 | <p>I have a <code>JTable</code> with a custom <code>TableModel</code> called <code>DataTableModel</code>. I initialized the table with a set of column names and no data as follows:</p>
<pre><code>books = new JTable(new DataTableModel(new Vector<Vector<String>>(), title2));
JScrollPane scroll1 = new JScrollPane(books);
scroll1.setEnabled(true);
scroll1.setVisible(true);
JSplitPane jsp1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scroll1, scroll2);
JSplitPane jsp2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, inventory, jsp1);
myPanel.add(jsp2, BorderLayout.CENTER);
</code></pre>
<p>I later want to update books with a set of data, and use the following:</p>
<pre><code>DataTableModel d = (DataTableModel)books.getModel();
d.setValues(bookList);
books.setModel(d);
</code></pre>
<p>where bookList is a <code>Vector<Vector<String>></code> that definitely has data. However, although all this code is being executed, it is not displaying on the screen. The code for the <code>setValues()</code> method is:</p>
<pre><code>public void setValues(Vector<Vector<String>> v) {
values = v;
fireTableDataChanged();
}
</code></pre>
<p>Am I missing something here?</p>
<p>The class and methods for my DataTableModel are (these methods are all implemented to return correct results):</p>
<pre><code>public class DataTableModel extends AbstractTableModel {
public DataTableModel(Vector<Vector<String>> v, Vector<String> c) {}
public int getColumnCount() {
if (values != null && values.size() > 0)
return values.elementAt(0).size();
else
return 0;
}
public int getRowCount() {
if (values != null && values.size() > 0)
return values.size();
else
return 0;
}
public Object getValueAt(int arg0, int arg1) {}
public void setValues(Vector<Vector<String>> v) {}
public Vector<Vector<String>> getValues() {}
public void setColumnNames(Vector<String> columns) {}
public String getColumnName(int col) {}
}
</code></pre>
| [
{
"answer_id": 370565,
"author": "Daniel Hiller",
"author_id": 16193,
"author_profile": "https://Stackoverflow.com/users/16193",
"pm_score": 2,
"selected": true,
"text": "TableModel"
},
{
"answer_id": 370700,
"author": "Rastislav Komara",
"author_id": 22068,
"author_p... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23249/"
] |
370,379 | <p>If php code like below how it's like as mysql stored procedure equivalent. If any links tutorial on advance stored procedure mysql please put.</p>
<pre><code>$sql = " SELECT a,b FROM j ";
$result = mysql_query($sql);
if(mysql_num_rows($result) > 0) {
while($row = mysql_fetch_array($result)) {
$sql_update = "UPDATE b set a=" . $row['a'] . "'";
mysql_query($sql_update);
}
}
</code></pre>
| [
{
"answer_id": 370423,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 1,
"selected": false,
"text": "mysqli"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
370,401 | <p>been searching for a quick example of sorting a IQueryable (Using Linq To SQL) using a Aggregate value.</p>
<p>I basically need to calculate a few derived values (Percentage difference between two values etc) and sort the results by this.</p>
<p>i.e.</p>
<p>return rows.OrderBy(Function(s) CalcValue(s.Visitors, s.Clicks))</p>
<p>I want to call an external function to calculate the Aggregate. Should this implement IComparer? or IComparable?</p>
<p>thanks</p>
<p>[EDIT]
Have tried to use:</p>
<pre><code>Public Class SortByCPC : Implements IComparer(Of Statistic)
Public Function Compare(ByVal x As Statistic, ByVal y As Statistic) As Integer Implements System.Collections.Generic.IComparer(Of Statistic).Compare
Dim xCPC = x.Earnings / x.Clicks
Dim yCPC = y.Earnings / y.Clicks
Return yCPC - xCPC
End Function
End Class
</code></pre>
<p>LINQ to SQL doesn't like me using IComparer</p>
| [
{
"answer_id": 370409,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 0,
"selected": false,
"text": "rows"
},
{
"answer_id": 370587,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30576/"
] |
370,425 | <p>Does anyone know of any gotachs or problems when writing multithreaded Perl applications using the Oracle DBI? Each thread would have it's own connection to Oracle.</p>
<p>For the longest time I was told multithreading was not supported in Perl with Oracle.</p>
| [
{
"answer_id": 370653,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 3,
"selected": false,
"text": "$dbh"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21357/"
] |
370,427 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/710288/where-are-the-best-explanations-of-memory-management-for-iphone">Where are the best explanations of memory management for iPhone?</a> </p>
</blockquote>
<p>I come from a web development background. I'm good at XHTML, CSS, JavaScript, PHP and MySQL, because I use all of those technologies at my day job.</p>
<p>Recently I've been tinkering with Obj-C in Xcode in the evenings and on weekends. I've written code for both the iPhone and Mac OS X, but I can't wrap my head around the practicalities of memory management. I understand the high-level concepts but am unclear how that plays out in implementation. Web developers typically don't have to worry about these sorts of things, so it is pretty new to me.</p>
<p>I've tried adding memory management to my projects, but things usually end up crashing. Any suggestions of how to learn? Any suggestions are appreciated.</p>
| [
{
"answer_id": 565355,
"author": "Georg Schölly",
"author_id": 24587,
"author_profile": "https://Stackoverflow.com/users/24587",
"pm_score": 2,
"selected": false,
"text": "[[NSObject alloc] init]"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
370,428 | <p>I am getting into strange situation regarding the RSS viewer on SharePoint</p>
<p>I have two environments of SharePoint (production & testing)</p>
<p>I was showing a specific RSS news (ABC) on both of them , and it was working after setting the proxies and other stuff.</p>
<p>Suddenly (may be due to some changes done on the production without testing), the RSS viewer on the production is not showing the RSS news it is showing protocol error, while it is still working fine on the testing environment.</p>
<p>Now the strange part is if I change the RSS of the one our management wants and put BBC or CNN news these works well on both the production and the test environment.</p>
<p>But the one we want it to work (which was working fine on both) do not work on the production and works fine on testing.</p>
<p>Any suggestions of how can I figure it out?</p>
| [
{
"answer_id": 565355,
"author": "Georg Schölly",
"author_id": 24587,
"author_profile": "https://Stackoverflow.com/users/24587",
"pm_score": 2,
"selected": false,
"text": "[[NSObject alloc] init]"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/247597/"
] |
370,432 | <p>I have a div called NAV and inside of NAV I have an UL with 5 li which I float to the left, the li's that is but when I do that the NAV collapses. I know this because I put a border around NAV to see if it collapses and it does. Here is the example.</p>
<p><a href="http://img401.imageshack.us/img401/8867/collapsedze4.png" rel="noreferrer">collapsed http://img401.imageshack.us/img401/8867/collapsedze4.png</a></p>
<p><a href="http://img71.imageshack.us/img71/879/nocollapsedkx7.png" rel="noreferrer">no collapsed http://img71.imageshack.us/img71/879/nocollapsedkx7.png</a></p>
<p>as you can see in the first image, the links in the NAV div are floated left and that
black border ontop is the actual div called NAV.</p>
<p>in this image you can see how it has top and bottom border and it not collapsed.</p>
<p>here is some of the html and css I used.</p>
<p><a href="http://img301.imageshack.us/img301/5514/codejc8.png" rel="noreferrer">alt text http://img301.imageshack.us/img301/5514/codejc8.png</a></p>
<pre><code>#nav #ulListNavi a {
float: left;
}
</code></pre>
| [
{
"answer_id": 370439,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<div style=\"clear: both\"></div> \n"
},
{
"answer_id": 370442,
"author": "Abram Simon",
"author_id": 46204,
... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36682/"
] |
370,449 | <p>I'm trying to add a feature to my AIR app that can listen for (configurable) global keyboard events even when the app is minimized. Ex: CTRL-ALT-SHIFT-F12 to grab a screenshot.</p>
<p>I can't find any way to register a keyboard hook, and listening for keyboard events only captures them when the app has focus. Suggestions?</p>
| [
{
"answer_id": 381409,
"author": "Robin Rodricks",
"author_id": 41021,
"author_profile": "https://Stackoverflow.com/users/41021",
"pm_score": 1,
"selected": false,
"text": "stage.addEventListener(KeyboardEvent.KEY_DOWN,KeyHandler); \n\nfunction KeyHandler(e:KeyboardEvent){\n trace (\... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
370,451 | <p>In my app I have 2 divs, one with a long list of products that can be dragged into another div (shopping cart). The product div has the overflow but it breaks prototype draggable elements. The prototype hacks are very obtrusive and not compatible with all browsers.</p>
<p>So I am taking a different approach, is it possible to have a scrollable div without using CSS <code>overflow:auto</code>? </p>
| [
{
"answer_id": 370462,
"author": "fasih.rana",
"author_id": 46024,
"author_profile": "https://Stackoverflow.com/users/46024",
"pm_score": 3,
"selected": true,
"text": "<div style=\"width:100px;height:100px;overflow:scroll\">\n</div>\n"
},
{
"answer_id": 3067789,
"author": "Ni... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10258/"
] |
370,454 | <p>I need to include or exclude a subreport based on a condition. I'm using iReport to create JasperReports. I.e., if a subreport has values, I need to include that subreport, otherwise not. Can anyone please send a sample or tell me how to resolve this.</p>
| [
{
"answer_id": 388097,
"author": "Jamie Love",
"author_id": 27308,
"author_profile": "https://Stackoverflow.com/users/27308",
"pm_score": 3,
"selected": false,
"text": "new Boolean($F{TOTAL_STATS}.intValue() != 0)\n"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
370,499 | <p>I have been trying to do a fill using the open source <a href="http://srecord.sourceforge.net/" rel="nofollow noreferrer">Srecord</a> Program. I need to do a fill that is
<code>0xC2AF00</code>. It appears the program can only do fills that are a byte long (ex: <code>0xff</code>). If this is not possible with the <a href="http://srecord.sourceforge.net/" rel="nofollow noreferrer">Srecord</a> program, then how would I go about writing my own algorithm to do what I want? </p>
<p>I am not quite sure how to determine what needs a fill and then how I would proceed to go about doing the fill that is needed. And on the off chance that someone could answer the same question for a Tektronix file, that would be just as good or better than how to do what I am asking for on the Intel hex file.</p>
| [
{
"answer_id": 370777,
"author": "Sparr",
"author_id": 13675,
"author_profile": "https://Stackoverflow.com/users/13675",
"pm_score": 4,
"selected": true,
"text": "srec_cat -Output -Intel -generate 0x10 0x20 -repeat-data 0xC2 0xAF 0x00\n"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34531/"
] |
370,500 | <p>Is it possible to inherit from both ViewPage and ViewPage<T>?? Or do I have to implement both. Currently this is what I have for ViewPage. Do i need to repeat myself and do the same for ViewPage<T>??</p>
<pre><code> public class BaseViewPage : ViewPage
{
public bool LoggedIn
{
get
{
if (ViewContext.Controller is BaseController)
return ((BaseController)ViewContext.Controller).LoggedOn;
else
return false;
}
}
}
</code></pre>
| [
{
"answer_id": 370579,
"author": "Todd Smith",
"author_id": 31624,
"author_profile": "https://Stackoverflow.com/users/31624",
"pm_score": 3,
"selected": true,
"text": "public class BaseViewPage : ViewPage\n{\n // put your custom code here\n}\n\npublic class BaseViewPage<TModel> : Bas... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29376/"
] |
370,504 | <p>I'm implementing a math library in C++. The library will be compiled to a DLL so those who use it will only need the header files the classes' definitions.</p>
<p>The users of my classes will be people who are new to the language. However, there are some objects that might be referenced in several parts of their programs. Since I don't expect them to do the memory management, I'd like to do it myself. Therefore, I have to implement reference counting (garbage collection is not a possibility).</p>
<p>I want to make that reference counting as transparent as possible, for example...</p>
<pre><code>// Define a Bézier curve
CVecList pts;
pts.Add(Vector(0,0,0));
pts.Add(Vector(0,0,100));
pts.Add(Vector(0,100,0));
pts.Add(Vector(0,100,100));
CCurve* c1 = new CBezier(pts);
// Define a 3rd order B-Spline curve
pts.Clear();
pts.Add(Vector(0,0,0));
pts.Add(Vector(0,200,100));
pts.Add(Vector(0,200,200));
pts.Add(Vector(0,-200,100));
pts.Add(Vector(0,-200,200));
pts.Add(Vector(0,0,0));
CCurve* c2 = new CBSpline(pts,3);
// The Bézier curve object must be deleted automatically
// because the only reference to it has been released
// Similar to IUnknown::Release() in COM
c1 = c2;
</code></pre>
<p>Things get a little bit more tricky when I define surface objects, because some surfaces are defined in terms of two curves:</p>
<pre><code>CVecList pts;
// ...
CCurve* f = new CBezier(pts);
pts.Clear();
// ...
CCurve* g = new CBezier(pts);
// Mixed surface: S(u,v) = (1-v)*f(u) + v*g(u)
CSurface* s = new CMixed(f,g);
// There are two references to the first Bézier curve,
// the first one is f
// the second one is hidden in a member of CMixed
// Something similar applies to the second Bézier curve
</code></pre>
<p>I thought that overriding <code>operator =</code> for pointers could have helped:</p>
<pre><code>// This is what I tried, but it's illegal:
typedef CReferenceCounted* PRC;
PRC& operator =(PRC& dest, PRC& source)
{
if (source)
source->AddRef();
if (dest)
dest->Release();
memcpy(&dest,&source,sizeof(PRC));
return dest;
}
</code></pre>
<p>... but then I found that <code>operator =</code> is not valid unless it is as a non-static member of a class.</p>
<p>Could anybody possible help me?</p>
| [
{
"answer_id": 370520,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 4,
"selected": false,
"text": "boost::shared_ptr"
},
{
"answer_id": 370714,
"author": "MSalters",
"author_id": 15416,
... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
370,512 | <p>I'm guessing the StackOverflow code has something along the lines of a UsersController that defines a function like this:</p>
<pre><code>public ActionResult Profile(string id, string username, string sort)
{
}
</code></pre>
<p>From what I can tell, there's two ways to go about implementing the Profile function. One is to use a switch statement on the sort parameter and render a different view based on what is being displayed (e.g. stats, recent, responses). These views would then render a partial user control to handle the display of the top half of the profile page (gravatar, username, last seen, etc).</p>
<p>The other way I could see implementing this would be to always render one view and have the logic for showing / hiding its different sections based on the sort. This would lead to a pretty monstrous view page, but it should work as well.</p>
<p>Are there any other ways of implementing the StackOverflow profile page that I'm missing? The reason I ask is because my current ASP.NET MVC page has a similar profile page and I want to make sure I'm not going about this the wrong way.</p>
| [
{
"answer_id": 370562,
"author": "Todd Smith",
"author_id": 31624,
"author_profile": "https://Stackoverflow.com/users/31624",
"pm_score": 0,
"selected": false,
"text": "<% RenderPartial(sort + \"View\") %>\n"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1574/"
] |
370,518 | <p>I'm new to this SCM, but since SVN is gaining popularity I was going to give it a try.</p>
<p>Things I noticed:</p>
<ol>
<li>SVN is only the backbone of the SCM, no front-end?</li>
<li>Why is there several versions of Windows Binaries? Tigris? SlikSVN? VisualSVN?</li>
<li>Do I need a Web Server like Apache in order to use SVN?</li>
<li>There's dozens of front-end, Tortoise, WinSVN, etc... Which one is recommended?</li>
</ol>
<p>The whole thing is rather confusing and I got no idea where to start. I'm using Delphi and would like to use it to store my source files.</p>
<p>Update 1:
Seems I got it working using the "file:///" protocol, thanks. Now, how do I configure it as a server with client PCs.</p>
| [
{
"answer_id": 370528,
"author": "Mick",
"author_id": 12458,
"author_profile": "https://Stackoverflow.com/users/12458",
"pm_score": 5,
"selected": true,
"text": "svn Commit"
},
{
"answer_id": 370734,
"author": "Miel",
"author_id": 17336,
"author_profile": "https://Sta... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30787/"
] |
370,547 | <p>How can I get a record id after saving it into database. Which I mean is actually something like that.</p>
<p>I have Document class (which is entity tho from DataBase) and I create an instance like </p>
<pre><code>Document doc = new Document() {title="Math",name="Important"};
dataContext.Documents.InsertOnSubmit(doc);
dataContext.SubmitChanges();
</code></pre>
<p>than what I want is to retrieve it's id value (docId) which is located in database and it's primary key also automatic number. One thing, there will be lots of users on the system and submits tons of records like that.</p>
<p>Thanks in advance everybody :)</p>
| [
{
"answer_id": 370577,
"author": "Nathan W",
"author_id": 6335,
"author_profile": "https://Stackoverflow.com/users/6335",
"pm_score": 3,
"selected": false,
"text": "Document doc = new Document() {title=\"Math\",name=\"Important\"};\ndataContext.Documents.InsertOnSubmit(doc);\ndataContext... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44852/"
] |
370,548 | <p>I have a row of divs that must all be the same height, but I have no way of knowing what that height might be ahead of time (the content comes from an external source). I initially tried placing the divs in an enclosing div and floated them left. I then set their height to be "100%", but this had no perceptible effect. By setting the height on the enclosing div to a fixed-height I could then get the floated divs to expand, but only up to the fixed height of the container. When the content in one of the divs exceeded the fixed height, it spilled over; the floated divs refused to expand.</p>
<p>I Googled this floated-divs-of-the-same-height problem and apparently there's no way to do it using CSS. So now I am trying to use a combination of relative and absolute positioning instead of floats. This is the CSS:</p>
<pre><code><style type="text/css">
div.container {
background: #ccc;
position: relative;
min-height: 10em;
}
div.a {
background-color: #aaa;
position: absolute;
top: 0px;
left: 0px;
bottom: 0px;
width: 40%;
}
div.b {
background-color: #bbb;
position: absolute;
top: 0px;
left: 41%;
bottom: 0px;
width: 40%;
}
</style>
</code></pre>
<p>This is a simplified version of the HTML:</p>
<pre><code> <div class="container">
<div class="a">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit.</div>
<div class="b">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit.</div>
</div>
</code></pre>
<p>This works, unless you change the min-height to something like 5em (demonstranting what happens when the content exceeds the minimum height), and you can see that while the text doesn't get cutoff, the divs still refuse to expand. Now I am at a lose. Is there any way to do this using CSS?</p>
| [
{
"answer_id": 370576,
"author": "alex",
"author_id": 31671,
"author_profile": "https://Stackoverflow.com/users/31671",
"pm_score": 1,
"selected": false,
"text": "display: table-cell"
},
{
"answer_id": 374237,
"author": "Community",
"author_id": -1,
"author_profile": ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
370,549 | <p>I have a static library *.lib created using MSVC on windows. The size of library is say 70KB. Then I have an application which links this library. But now the size of the final executable (*.exe) is 29KB, less than the library. What i want to know is :</p>
<ol>
<li><p>Since the library is statically linked, I was thinking it should add directly to the executable size and the final exe size should be more than that? Does windows exe format also do some compression of the binary data? </p></li>
<li><p>How is it for linux systems, that is how do sizes of library on linux (*.a/*.la file) relate with size of linux executable (*.out) ? </p></li>
</ol>
<p>-AD</p>
| [
{
"answer_id": 370608,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 4,
"selected": true,
"text": ".lib"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2759376/"
] |
370,557 | <p>In Jackrabbit I have experienced two ways to save my POJOs into repository nodes for storage in the Jackrabbit JCR: </p>
<ol>
<li>writing my own layer
and </li>
<li>using Apache Graffito </li>
</ol>
<p>Writing my own code has proven time consuming and labor intensive (had to write and run a lot of ugly automated tests) though quite flexible. </p>
<p>Using Graffito has been a disappointment because it seems to be a "dead" project <a href="http://incubator.apache.org/graffito/news.html" rel="noreferrer">stuck in 2006</a></p>
<p>What are some better alternatives?</p>
| [
{
"answer_id": 371152,
"author": "Alexander Klimetschek",
"author_id": 2709,
"author_profile": "https://Stackoverflow.com/users/2709",
"pm_score": 5,
"selected": true,
"text": "javax.jcr.Node"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31892/"
] |
370,571 | <p>I am creating a pdf document using C# code in my process. I need to protect the docuemnt
with some standard password like "123456" or some account number. I need to do this without
any reference dlls like pdf writer.</p>
<p>I am generating the PDF file using SQL Reporting services reports.</p>
<p>Is there are easiest way.</p>
| [
{
"answer_id": 370888,
"author": "Darin Dimitrov",
"author_id": 29407,
"author_profile": "https://Stackoverflow.com/users/29407",
"pm_score": 6,
"selected": true,
"text": "using (Stream input = new FileStream(\"test.pdf\", FileMode.Open, FileAccess.Read, FileShare.Read))\nusing (Stream o... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22162/"
] |
370,578 | <p>One doubt in MSSQL.
There are two tables in a databases.</p>
<p>Table 1 named Property contain
fields PRPT_Id(int),PRPT_Name(varchar), PRPT_Status(bit) </p>
<p>Table 2 named PropertyImages contain fields PIMG_Id(int),PIMG_ImageName(varchar),PRPT_Id(int),PIMG_Status(bit)</p>
<p>These two tables follow a one-to-many relationship.
That means the each Property can have zero, one or more PropertyImages corresponding to it.</p>
<p>What is required is a query to display</p>
<p>PRPT_Id, PRPT_Name, ImageCount(Count of all images corresponding to a PRPT_Id where PIMG_Status is true. o if there arent any images), FirstImageName(if there are n images, the name of the first image in the image table corresponding to the PRPT_Id with PIMG_Status true. if there aren't any images we fill that with whitespace/blank) . another condition is that PRPT_Status should be true.</p>
<p>Edit Note - Both the tables are having autoincremented integers as primary key.
So first Image name will be the name with MIN(PIMG_Id), isn't that so?</p>
<p>I want the PIMG_ImageName corresponding to the MIN(PIMG_ID) in the resultset</p>
| [
{
"answer_id": 370589,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "SELECT PRPT_Id, COUNT(PIMG_Id) AS PRPT_ImageCount, MIN(PIMG_Id) AS PRPT_MinImage\nFROM PropertyImages\nGROUP BY PRPT_Id\n"
}... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17447/"
] |
370,586 | <p>Why is the following?:</p>
<pre><code> const int i0 = 5;
//int i1 = const_cast<int>(i0); // compilation error
int i2 = (int)i0; // okay
int i3 = 5;
//const int i4 = const_cast<const int>(i3); // compilation error
const int i5 = (const int)i3; // okay
</code></pre>
| [
{
"answer_id": 370591,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 4,
"selected": false,
"text": " const int i0 = 5;\n//int i1 = const_cast<int>(i0); // compilation error\n int i2 = (in... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
370,601 | <p>In a bunch o' places in my code, I have something like this: </p>
<pre><code>public Class mySpecialMethod() {
return MySpecialClass.class;
}
</code></pre>
<p>which causes the warning </p>
<blockquote>
<p>Class is a raw type. References to
generic type Class should be
parameterized.</p>
</blockquote>
<p>But, if I replace </p>
<p><code>Class</code> </p>
<p>with </p>
<p><code>Class<? extends Object></code></p>
<p>the warning goes away. </p>
<p>Is this simple practice ok, or could it cause trouble later?</p>
| [
{
"answer_id": 370674,
"author": "Guillaume",
"author_id": 23704,
"author_profile": "https://Stackoverflow.com/users/23704",
"pm_score": 3,
"selected": false,
"text": "public Class<MySpecialClass> mySpecialMethod() {\n return MySpecialClass.class;\n}\n"
},
{
"answer_id": 370686,... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46277/"
] |
370,622 | <p>I have written a simple C++ program like this:</p>
<pre><code>#include <iostream>
using namespace std;
int main()
{
cout << "Hello.";
return 0;
}
</code></pre>
<p>Now I want to debug it. So what will be the command for it so my control goes to every line?</p>
| [
{
"answer_id": 370627,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 5,
"selected": false,
"text": "gdb"
},
{
"answer_id": 370642,
"author": "Salvatore Dario Minonne",
"author_id": 10170,
"author_profi... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
370,624 | <p>I'm learning C# by writing a home library manager.</p>
<p>I have a BookController that will store the books in a data structure and perform operations on them.</p>
<p>Does C# have a way of saving the data in the dictionary to a local file perhaps in an XML fashion to load later, or am I going to have to write it myself?</p>
<p>What is the best method of saving and loading this data available to C#? Just need pointed in a good direction.</p>
| [
{
"answer_id": 370676,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 6,
"selected": true,
"text": "XmlSerializer"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46534/"
] |
370,632 | <p>Is it possible to use Mark of the Web in XML file which is parsed by a local XSL file?</p>
<p>When I insert MOTW mark:</p>
<pre><code><!-- saved from url=(0014)about:internet -->
</code></pre>
<p>i get following message:<br>
Access is Denied. Error Processing Resource.</p>
<hr>
<p>Ok, I see that I was trying to do it wrong - I wanted to insert this comment into XML.</p>
<p>I have three files: XML with data, XSL to transform the data into html, and JS file with JavaScript functions. As you said, I want to get rid of the Internet Explorer orange bar.</p>
<p>Putting everything on IIS or Apache is good way, but I want to open these files localy.</p>
<p>I tried to insert xml:comment tag, but nothing happened (the bar is still showing).</p>
| [
{
"answer_id": 372540,
"author": "scunliffe",
"author_id": 6144,
"author_profile": "https://Stackoverflow.com/users/6144",
"pm_score": 0,
"selected": false,
"text": "<xsl:comment> saved from url=(0014)about:internet </xsl:comment>\n"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22174/"
] |
370,641 | <p>I have a client and server program (both in Obj-C) and I am transferring files between two devices using the programs.</p>
<p>The transferring is working fine, but I would like to display to the user what transfer rate they are getting.</p>
<p>So I know the total size of the file, and how much of the file has been transferred, is there a way to figure out the transfer rate from this information, and if not, what information do I need to calculate the transfer rate?</p>
<p>Thanks</p>
| [
{
"answer_id": 370651,
"author": "Marc Novakowski",
"author_id": 27020,
"author_profile": "https://Stackoverflow.com/users/27020",
"pm_score": 5,
"selected": true,
"text": "transfer_speed = bytes_transferred / ( current_time - start_time)\n"
},
{
"answer_id": 372734,
"author"... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26728/"
] |
370,664 | <p>I have a two classes:</p>
<pre><code>public class Question
{
public IList<Answer> Answers { get; set; }
}
public class Answer
{ .. }
</code></pre>
<p>In my Linq2Sql designer, there's two L2S objects on designer, with the correct 0<->many arrow between them. Kewl.</p>
<p>I'm not sure how i can retrieve these questions/answers in a single call and populate my POCO objects .. </p>
<p>this is what i've got ... can someone fill in the blanks?</p>
<pre><code>public IQueryable<Question> GetQuestions()
{
return from q in _db.Questions
select new Question
{
Title = q.Title,
Answers = ???????? // <-- HALP! :)
};
}
</code></pre>
<p>thoughts?</p>
<h2>Update : War of the POCO</h2>
<p>Thanks for the replies but it's not 100% there yet.</p>
<p>Firstly, i'm returning a POCO class, not the Linq2Sql context class. This is why i'm doing...</p>
<pre><code>select new Question { .. };
</code></pre>
<p>that class is POCO, not the linq2sql.</p>
<p>Secondly, I like the answers that point to doing Answers = q.Answers.ToList() but this also will not work because it's trying to set a Linq2Sql class to a POCO class.</p>
| [
{
"answer_id": 370671,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 4,
"selected": true,
"text": "return from q in _db.Questions\n select new Question\n {\n Title = q.Title,\n Answers = q... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] |
370,667 | <p>Does anyone know how to remove the extra branding on the google custom search? </p>
<p>they've added a button and other things like text that says "gadgets powered by google".</p>
<p>there has to be a way to pipe the CSE data into a normal form, right?</p>
<p><a href="http://www.google.com/coop/cse/" rel="nofollow noreferrer">http://www.google.com/coop/cse/</a></p>
| [
{
"answer_id": 26536827,
"author": "coddiwomplefrog",
"author_id": 3005071,
"author_profile": "https://Stackoverflow.com/users/3005071",
"pm_score": 2,
"selected": false,
"text": "input.gsc-input {\n font-size: 11px; \n height: 16px !important;\n background: none !important;\n}\n"
... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42589/"
] |
370,678 | <p>I just have started to learn Haskell and combine reading books and tutorials with solving problems from Project Euler. I have stuck on <a href="http://projecteuler.net/index.php?section=problems&id=27" rel="nofollow noreferrer">Problem 27</a> because I get "C stack overflow" error using this code: </p>
<p><strong>euler.hs</strong></p>
<pre><code>divisors n = [x | x <- [1..n `div` 2], n `mod` x == 0] ++ [n]
is_prime n = divisors n == [1, n]
f a b = [n^2 + a * n + b | n <- [0..]]
primes_from_zero a b = length(takeWhile is_prime (f a b))
</code></pre>
<p><strong>command window</strong></p>
<p>this command gives Euler's coefficients 1 and 41 (40 primes in row)</p>
<pre><code>foldr (max) (0, 0, 0) [(primes_from_zero a b, a, b) | a <- [0..10], b <- [0..50]]
</code></pre>
<p>this one fails with "C stack overflow" (I wanted to obtain coefficients -79 and 1601 also mentioned in the problem definition):</p>
<pre><code>foldr (max) (0, 0, 0) [(primes_from_zero a b, a, b) | a <- [-100..0], b <- [1500..1700]]
</code></pre>
<p>Would you tell me, please, why does the error arise and how to resolve it? Thank you!</p>
<p>I use WinHugs.</p>
| [
{
"answer_id": 371568,
"author": "Chris Conway",
"author_id": 1412,
"author_profile": "https://Stackoverflow.com/users/1412",
"pm_score": 4,
"selected": true,
"text": "foldl f x (y:ys) = foldl f (f x y) ys\n"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11256/"
] |
370,694 | <p>I am working on some batch file.
I need to read name from some text file. Let me explain it</p>
<p>I have one file <code>File.txt</code>, which has entry like <code>FirstName=John</code>.
Now my batch file should read text <code>John</code> from the file and I should be able store <code>John</code> in some variable too.</p>
<p>But with following code, if I use <code>delims==</code>,I can get <code>FirstName</code> text stored in some variable but not <code>John</code>.</p>
<pre><code>for /F "delims==" %%I in (File.txt) do set Title=%%I
echo %Title%
</code></pre>
<p>Is there any way where I can get <code>John</code> from my <code>File.txt</code> and store it with in my <code>for</code> loop ?</p>
| [
{
"answer_id": 370715,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 2,
"selected": false,
"text": "@echo off\nsetlocal\nfor /F \"tokens=1,2 delims==\" %%a in (File.txt) do set Title=%%b\necho %Title%\n"
},
{
"answer_id... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
370,695 | <p>I have a java class which fires custom java events. The structure of the code is the following:</p>
<pre><code>public class AEvent extends EventObject {
...
}
public interface AListener extends EventListener {
public void event1(AEvent event);
}
public class A {
public synchronized void addAListener(AListener l) {
..
}
public synchronized void removeAListener(AListener l) {
..
}
protected void fireAListenerEvent1(AEvent event) {
..
}
}
</code></pre>
<p>Everything works correctly, but I'd like to create a new subclass of A (call it B), which may fire a new event. I'm thinking of the following modification:</p>
<pre><code>public class BEvent extends AEvent {
...
}
public interface BListener extends AListener {
public void event2(BEvent event);
}
public class B extends A {
public synchronized void addBListener(BListener l) {
..
}
public synchronized void removeBListener(BListener l) {
..
}
protected void fireBListenerEvent2(AEvent event) {
..
}
}
</code></pre>
<p>Is this the correct approach? I was searching the web for examples, but couldn't find any.</p>
<p>There are a few things I don't like in this solution:</p>
<ol>
<li><code>BListener</code> has two methods one uses <code>AEvent</code> the other uses <code>BEvent</code> as a parameter.</li>
<li><code>B</code> class both has <code>addAListener</code> and <code>addBListener</code> methods. Should I hide addAListener with private keyword? <strong>[UPDATE: it's not possible to hide with private keyword]</strong></li>
<li>Similar problem with <code>fireAListenerEvent1</code> and <code>fireBListenerEvent1</code> methods.</li>
</ol>
<p>I'm using Java version 1.5.</p>
| [
{
"answer_id": 370703,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 5,
"selected": true,
"text": "BListener"
},
{
"answer_id": 371331,
"author": "Yoni Roit",
"author_id": 34161,
"author_profile":... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21348/"
] |
370,698 | <p>I'm researching a bug that looks like some kind of timing issue and so I'm a bit curious about how events work in Delphi 7. What happens is we get some data sent to our application through a COM interface and it gets handled in an event raised from the COM thread. It seems like the event, which has quite a bit of code in it, takes longer and longer to execute and after a while the entire application crashes. There are calls to graphics and stuffing into large arrays inside the event that might affect time. I have been unable to spot any significant increase in memory usage and have not had opportunity to run any profilers to check for leaks yet. Also, the obvious thing to test would be to strip the event of all the code in it just to see if we can run for a longer period of time.</p>
<p>Are events serial or parallell in Delphi, that is, if I get a new event while one is executing -what happens? Is it run in parallell on some kind of automatic thread, is it ignored or is it queued up?</p>
<p>If it is queued up, how many can I have in the queue before the application crashes?</p>
<p>Does indexing into a large array take longer the further into it you are? Even if it's of a fixed size? I don't think it should so I'm looking for leaks and allocations that take time. If I get sent an object through the event, should I dispose of it within the event or in the "calling" code?</p>
<p>What things usually do not scale well in Delphi? What can I look for that would increase in execution time?</p>
<p>Finally, since this is COM related, any pointers to common pitfalls in COM are appreciated although I realize this is tricky. I do have a grip on co-initialize though.</p>
| [
{
"answer_id": 972767,
"author": "Christer Fahlgren",
"author_id": 87476,
"author_profile": "https://Stackoverflow.com/users/87476",
"pm_score": 0,
"selected": false,
"text": "CoInitializeEx(nil, COINIT_MULTITHREADED);"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9077/"
] |
370,707 | <p>I fail to understand why this code won't compile</p>
<pre><code>ExecutorService executor = new ScheduledThreadPoolExecutor(threads);
class DocFeeder implements Callable<Boolean> {....}
...
List<DocFeeder> list = new LinkedList<DocFeeder>();
list.add(new DocFeeder(1));
...
executor.invokeAll(list);
</code></pre>
<p>The error msg is: </p>
<pre><code>The method invokeAll(Collection<Callable<T>>) in the type ExecutorService is
not applicable for the arguments (List<DocFeeder>)
</code></pre>
<p><code>list</code> is a <code>Collection</code> of <code>DocFeeder</code>, which implements <code>Callable<Boolean></code> - What is going on?!</p>
| [
{
"answer_id": 370721,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 3,
"selected": false,
"text": "list"
},
{
"answer_id": 370742,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "ht... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370707",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4038/"
] |
370,716 | <p>I have written jQuery code, in files <code>Main.html</code> and <code>ajax.php</code>. The <code>ajax.php</code> file returns the link of images to <code>Main.html</code>.</p>
<p>Now in <code>Main.html</code>, I have Image1, Image2, Image3, etc.</p>
<p>My <code>Main.html</code> file:</p>
<pre><code><html>
...
# ajax.php Call
...
# Return fields from Ajax.php
</html>
</code></pre>
<p>My ajax.php file</p>
<pre><code>echo "<a href='src1'><img src='src_path1' id='fid1' alt='Name1' /></a>Click To View image1\n";
echo "<a href='src2'><img src='src_path2' id='fid2' alt='Name2' /></a>Click To View image2\n";
// etc.
</code></pre>
<p>So, after executing ajax.php, I get the image locations in Main.html.</p>
<p>Now, when I click the Image1 link from Main.html, that corresponding image should display in the same window.</p>
<p>So I thought about whether again to use jQuery to view an image on the same page. How can I achieve this?</p>
| [
{
"answer_id": 370762,
"author": "kgiannakakis",
"author_id": 24054,
"author_profile": "https://Stackoverflow.com/users/24054",
"pm_score": 0,
"selected": false,
"text": "<div id=\"pictureframe\"></div>\n"
},
{
"answer_id": 370764,
"author": "Ata",
"author_id": 46110,
... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44984/"
] |
370,717 | <p>I have a job to enter survey results (in paper form) to excel.
I've never written any macro in Office :(</p>
<p>Here I what I basically need:</p>
<ol>
<li>I have predefined columns (|A|B|...|AG|AH|)</li>
<li>All surveys are grouped into groups. All surveys from same group have few (like predefined) same columns. It's always same columns that 'define' group</li>
<li>All other survey answers are in numerical type [1..10].</li>
<li>Columns are not in same order as answers in servey</li>
<li>I want macro that will take my input (for example '1575'), and first place predefined values to that 'group' to |A| |B| |C|, and then |E| = 1, |D| = 5, |F| = 7, |G| = 5, and automatically start entering next row.</li>
</ol>
<p>Anything that will give me a clue how to write this macro in more than welcome</p>
<p>Huge thanks for reading this... </p>
<p>EDIT1: I suppose question is not clear enough...
I need macro that will read my keyboard input ( '1575' ) and write integers '1' '5' '7' and '5' to predefined rows. For now, I have an idea to make a form, but I need event handler that will change focus to next input when I press a key, as I want to avoid pressing TAB all the time...</p>
| [
{
"answer_id": 371143,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 3,
"selected": true,
"text": "Dim LastCol As Integer\nDim CurRow As Integer\n\n\nPrivate Sub UpdateCells()\nDim Col As Variant\nDim ColumnOrder As Range\... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35425/"
] |
370,718 | <p>Is it possible to access a USB drive or Flash card without using the drive letter that Windows assigns it? I thought I read somewhere that the Volume GUID or something can be used but will that allow me to open it up in explorer once I identify it? The reason this is important to me is because there may not be enough drive letters to handle the number of drives so I want to be able to still access them.</p>
| [
{
"answer_id": 370732,
"author": "Chris",
"author_id": 43960,
"author_profile": "https://Stackoverflow.com/users/43960",
"pm_score": 2,
"selected": true,
"text": "MOUNTVOL C:\\USB: \\\\?\\Volume{ebc79032-5270-11d8-a724-806d6172696f}\\ \n\nOR Winkey+R (Start-Run) \\\\?\\Volume{ebc79032-5... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
370,720 | <p>I have the following construction:</p>
<pre><code>typedef struct bucket {
char *key;
ENTRY *data;
struct bucket *next;
} bucket;
typedef struct {
size_t size;
bucket **table;
} hash_table;
</code></pre>
<p>But I have no idea how to allocate memory for that. I tried: </p>
<pre><code>hash_table* ht = malloc(sizeof(hash_table)*101);
</code></pre>
<p>in order to create a hashtable for 101 entries but it din't work! Can anyone help me? I would really appreciate it!</p>
| [
{
"answer_id": 370726,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 0,
"selected": false,
"text": "hash_table"
},
{
"answer_id": 370729,
"author": "jmucchiello",
"author_id": 44065,
"author_profi... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43960/"
] |
370,722 | <p>i'm begginner in java,
i have textarea and i have set only verticle scrollbar to that textarea.i'm appending data for every 1 minute to textarea,problem is when new data appends to the textarea scrollbar will move up.To see the new data,every time i have to drag the scroll bar, that is not the requirment.i want scrollbar should not move up it should move down how can i do this?
plz help me.</p>
<p>thanks for reply</p>
| [
{
"answer_id": 370726,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 0,
"selected": false,
"text": "hash_table"
},
{
"answer_id": 370729,
"author": "jmucchiello",
"author_id": 44065,
"author_profi... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
370,754 | <p>In a C# Windows.Forms project I have a control that does not supply the KeyPressed event (It’s a COM control – ESRI map). </p>
<p>It only supplies the KeyUp and KeyDown events, containing the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.keyeventargs.aspx" rel="noreferrer">KeyEventArgs</a> structure.</p>
<p>How can I convert the information in KeyEventArgs to a displayable Unicode character, taking the current active keyboard layout into account, etc.?</p>
| [
{
"answer_id": 375047,
"author": "Itai Bar-Haim",
"author_id": 47104,
"author_profile": "https://Stackoverflow.com/users/47104",
"pm_score": 5,
"selected": true,
"text": " public class KeyboardHelper\n {\n [DllImport(\"user32.dll\", CharSet = CharSet.Unicode, ExactSpelling = t... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38265/"
] |
370,768 | <p>Requirements:</p>
<ul>
<li>Must be able to use C strings as well as C++ strings</li>
<li>Fast</li>
<li>No maps</li>
<li>No templates</li>
<li>No direct lookup, i.e. index might be out of bounds.</li>
<li>Index is not consecutive</li>
<li>Enums and strings contained in one header file</li>
<li>Only instantiate what you use.</li>
</ul>
<p>This is what I have come up with so far:</p>
<pre><code>- test.hh -
// Generic mapper
//
// The idea here is to create a map between an integer and a string.
// By including it inside a class we prevent every module which
// includes this include file from creating their own instance.
//
struct Mapper_s
{
int Idx;
const char *pStr;
};
// Status
enum State_t
{
Running = 1,
Jumping = 6,
Singing = 12
};
struct State_s
{
static const Mapper_s *GetpMap(void)
{
static Mapper_s Map[] =
{
{ Running, "Running" },
{ Jumping, "Jumping" },
{ Singing, "Singing" },
{ 0, 0}
};
return Map;
};
};
- test.cc -
// This is a generic function
const char *MapEnum2Str(int Idx, const Mapper_s *pMap)
{
int i;
static const char UnknownStr[] = "Unknown";
for (i = 0; pMap[i].pStr != 0; i++)
{
if (Idx == pMap[i].Idx)
{
return pMap[i].pStr;
}
}
return UnknownStr;
}
int main()
{
cout << "State: " << MapEnum2Str(State, State_s::GetpMap()) << endl;
return 0;
}
</code></pre>
<p>Any suggestions on how to improve this ? </p>
<p>I feel that the header file looks slightly cluttered... </p>
| [
{
"answer_id": 370805,
"author": "Patrick",
"author_id": 38892,
"author_profile": "https://Stackoverflow.com/users/38892",
"pm_score": 0,
"selected": false,
"text": "struct map {\nconst char *mapping[] = { \"Running\", \"Jumping\", \"Singing\" };\nconst int count = 3;\n}\n"
},
{
... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46583/"
] |
370,783 | <p>My master page has a contentplaceholder in the head tag.</p>
<p>Because I want my page's title to represent the function of the current page and because I want the title to be translated in the user's language I have added a title tag in the page's head's contentplaceholder. All jolly and good except that now there appears a second, empty title tag that off course isn't valid.</p>
<p>Any ideas how to solve this?</p>
| [
{
"answer_id": 370827,
"author": "Zhaph - Ben Duguid",
"author_id": 33051,
"author_profile": "https://Stackoverflow.com/users/33051",
"pm_score": 3,
"selected": false,
"text": "<title><%= Html.Encode(ViewData[\"Title\"]) %></title>\n"
},
{
"answer_id": 611555,
"author": "Hele... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] |
370,796 | <p>How to use crystal Reports with ASP.Net 2.0.
Any Samples/Tutorials/Examples which shows how to deploy Crystal Reports on a production Server.</p>
| [
{
"answer_id": 945720,
"author": "SchwartzE",
"author_id": 94382,
"author_profile": "https://Stackoverflow.com/users/94382",
"pm_score": 0,
"selected": false,
"text": "'Generate the Report\nDim oRpt As New ReportDocument\nDim reportPath As String = Server.MapPath(\"crtTAL.rpt\")\noRpt.Lo... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
370,801 | <p>When reading data from the Input file I noticed that the ¥ symbom was not being read by the StreamReader. Mozilla Firefox showed the input file type as Western (ISO-8859-1).</p>
<p>After playing around with the encoding parameters I found it worked successfully for the following values:</p>
<pre><code>System.Text.Encoding.GetEncoding(1252) // (western iso 88591)
System.Text.Encoding.Default
System.Text.Encoding.UTF7
</code></pre>
<p>Now I am planning on using the "Default" setting, however I am not very sure if this is the right decision. The existing code did not use any encoding and I am worried I might break something.</p>
<p>I know very little (OR rather nothing) about encoding. How do I go about this? Is my decision to use System.Text.Encoding.Default safe? Should I be asking the user to save the files in a particular format ?</p>
| [
{
"answer_id": 370811,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": true,
"text": "Encoding.GetEncoding(28591)"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41766/"
] |
370,814 | <p>I'm getting a NullPointerException in a Class from a 3rd party library. Now I'd like to debug the whole thing and I would need to know from which object the class is held. But it seems to me that I cannot set a breakpoint in a Class from a 3rd party. </p>
<p>Does anyone know a way out of my trouble? Of course I'm using Eclipse as my IDE.</p>
<p>Update: the library is open-source.</p>
| [
{
"answer_id": 370819,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 6,
"selected": false,
"text": "Toggle Method Breakpoint"
},
{
"answer_id": 372620,
"author": "Jared",
"author_id": 44757,
"auth... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15108/"
] |
370,817 | <p>I've thrown myself headfirst into C# and .Net 2.0 using Linq, and I'm having a few problems debugging some of the problems, namely the following:</p>
<p>I have a ComboBox control (<code>cmbObjects</code>) I want to populate with a set of objects retrieved using Linq. I've written a helper method to populate a <code>List<T></code> generic:</p>
<pre><code>class ObjectProvider
{
public static List<T> Get<T>(bool includeNull) where T : class, new()
{
List<T> list = new List<T>();
LutkeDataClassesDataContext db = ConnectionManager.GetConnection();
IQueryable<T> objects = db.GetTable<T>().AsQueryable();
if (includeNull) list.Add(null);
foreach (T o in objects) list.Add(o);
return list;
}
public static List<T> Get<T>() where T : class, new()
{
return Get<T>(false);
}
}
</code></pre>
<p>I verified the results when calling the function with true or false - the <code>List</code> does contain the right values, when passing <code>true</code>, it contains <code>null</code> as the first value, followed by the other objects.</p>
<p>When I assign the <code>DataSource</code> to the <code>ComboBox</code> however, the control simply refuses to display any items, including the <code>null</code> value (not selectable):</p>
<pre><code>cmbObjects.DataSource = ObjectProvider.Get<Car>(true);
</code></pre>
<p>Passing in <code>false</code> (or no parameter) does work - it displays all of the objects.</p>
<p>Is there a way for me to specify a "null" value for the first object without resorting to magic number objects (like having a bogus entry in the DB just to designate a N/A value)? Something along the lines of a nullable would be ideal, but I'm kind of lost.</p>
<p>Also, I've tried adding <code>new T()</code> instead of <code>null</code> to the list, but that only resulted in an <code>OutOfMemoryException</code>.</p>
| [
{
"answer_id": 374133,
"author": "Klemen Slavič",
"author_id": 46588,
"author_profile": "https://Stackoverflow.com/users/46588",
"pm_score": 1,
"selected": true,
"text": "DataSource"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46588/"
] |
370,818 | <p>I want to build an SQL string to do database manipulation (updates, deletes, inserts, selects, that sort of thing) - instead of the awful string concat method using millions of "+"'s and quotes which is unreadable at best - there must be a better way. </p>
<p>I did think of using MessageFormat - but its supposed to be used for user messages, although I think it would do a reasonable job - but I guess there should be something more aligned to SQL type operations in the java sql libraries.</p>
<p>Would Groovy be any good?</p>
| [
{
"answer_id": 370891,
"author": "Piotr Kochański",
"author_id": 34102,
"author_profile": "https://Stackoverflow.com/users/34102",
"pm_score": 7,
"selected": true,
"text": "PreparedStatement stm = c.prepareStatement(\"UPDATE user_table SET name=? WHERE id=?\");\nstm.setString(1, \"the na... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5175/"
] |
370,820 | <p>I have a CheckedListBox, and I want to automatically tick one of the items in it.</p>
<p>The <code>CheckedItems</code> collection doesn't allow you to add things to it.</p>
<p>Any suggestions?</p>
| [
{
"answer_id": 370828,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 7,
"selected": true,
"text": "SetItemChecked"
},
{
"answer_id": 11567074,
"author": "B. Clay Shannon-B. Crow Raven",
"author_id": 87531... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26874/"
] |
370,831 | <p>I have an SVN repository and I need the commits to fail if no description is entered. Is this possible to do, preferably server-side? (The users use several different tools for interacting with the repository; although if this were possible client-side in TortoiseSVN, that would alleviate the problem)</p>
<p>Google has not been very helpful, can you give me some pointers?</p>
<p>Thanks.</p>
| [
{
"answer_id": 370842,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "pre-commit.tmpl"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19746/"
] |
370,839 | <p>I'm using Linq To Sql to fill up a listbox with Segment objects, where Segment is designer created/ORM generated class.</p>
<pre><code><Window x:Class="ICTemplates.Window1"
...
xmlns:local="clr-namespace:ICTemplates"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<DataTemplate x:Key="MyTemplate">
<!-- <DataTemplate DataType="x:Type local:Segment"> -->
// some stuff in here
</DataTemplate>
</Window.Resources>
<ListView x:Name="tvwSegments" ItemsSource="{Binding}" ItemTemplate="{StaticResource MyTemplate}" MaxHeight="200"/>
// code-behind
var queryResults = from segment in tblSegments
where segment.id <= iTemplateSid
select segment;
tvwSegments.DataContext = queryResults;
</code></pre>
<p>This works.</p>
<p>However if I used a Typed Data Template (by replacing the x:Key with the DataType attribute on the template, the items all show up with <code>ICTemplates.Segment</code> (the ToString() return value)<br>
The concept is that it should pick up the data template automatically if the Type matches. Can someone spot the mistake here?</p>
| [
{
"answer_id": 372014,
"author": "Gishu",
"author_id": 1695,
"author_profile": "https://Stackoverflow.com/users/1695",
"pm_score": 6,
"selected": true,
"text": "<DataTemplate DataType=\"x:Type local:Segment\"> <!-- doesn't work -->\n"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1695/"
] |
370,840 | <p>Silly question, but I'm unable to figure out..</p>
<p>I tried the following in Ruby:</p>
<pre><code>irb(main):020:0> JSON.load('[1,2,3]').class
=> Array
</code></pre>
<p>This seems to work. While neither</p>
<pre><code>JSON.load('1').class
</code></pre>
<p>nor this </p>
<pre><code>JSON.load('{1}').class
</code></pre>
<p>works. Any ideas?</p>
| [
{
"answer_id": 370853,
"author": "a2800276",
"author_id": 27408,
"author_profile": "https://Stackoverflow.com/users/27408",
"pm_score": 2,
"selected": false,
"text": ">> JSON.parse(1.to_json)\nJSON::ParserError: A JSON text must at least contain two octets!\n from /opt/local/lib/ruby... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44232/"
] |
370,850 | <p>I have a PHP file, Test.php, and it has two functions:</p>
<pre><code><?php
echo displayInfo();
echo displayDetails();
?>
</code></pre>
<p>JavaScript:</p>
<pre><code><html>
...
<script type="text/javascript">
$.ajax({
type:'POST',
url: 'display.php',
data:'id='+id ,
success: function(data){
$("#response").html(data);
}
});
</script>
...
<div id="response">
</div>
</html>
</code></pre>
<p>It returns the response from jQuery. The response shows as <code><a href=Another.php?>Link</a></code>. When I click the Another.php link in <code>test.php</code>, it loads in another window. But I need it to load the same <code><div> </div></code> area without changing the content of <code>test.php</code>, since it has <code>displayInfo(), displayDetails()</code>. Or is it possible to load a PHP page inside <code><div> </div></code> elements?</p>
<p>How can I tackle this problem?</p>
| [
{
"answer_id": 370882,
"author": "Klemen Slavič",
"author_id": 46588,
"author_profile": "https://Stackoverflow.com/users/46588",
"pm_score": 4,
"selected": true,
"text": "a"
},
{
"answer_id": 372882,
"author": "gradbot",
"author_id": 17919,
"author_profile": "https://... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44984/"
] |
370,852 | <p>Anytime I have to handle dates/times in java it makes me sad </p>
<p>I'm trying to parse a string and turn it into a date object to insert in a preparepared statement. I've been trying to get this working but am having no luck. I also get the helpful error message when I go to compile the class.</p>
<p>"Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method setDate(int, Date) in the type PreparedStatement is not applicable for the arguments (int, Date)"</p>
<p>Eh WTF?</p>
<p>Here is the offending code.</p>
<pre><code>for(int i = 0; i < flights.size(); i++){
String[] details = flight[i].toString().split(":");
DateFormat formatter ;
formatter = new SimpleDateFormat("ddMMyyyy");
Date date = formatter.parse(details[1]);
PreparedStatement pstmt = conn.prepareStatement(insertsql);
pstmt.setString(1, details[0]);
pstmt.setDate(2, date);
pstmt.setString(3, details[2] + "00");
pstmt.setString(4, details[3]);
pstmt.setString(5, details[4]);
pstmt.setString(6, details[5]);
pstmt.setString(7, details[6]);
pstmt.setString(8, details[7]);
pstmt.setString(9, details[8]);
pstmt.executeUpdate();
}
</code></pre>
| [
{
"answer_id": 1336222,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "import java.sql.Date;\nimport java.sql.Time;\n\n statement.setDate(4, Date.valueOf(\"2009-08-26\"));\n statement.setTime(5, T... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
370,859 | <p>The question is in the title, why :</p>
<pre><code>return double.IsNaN(0.6d) && double.IsNaN(x);
</code></pre>
<p>Instead of</p>
<pre><code>return (0.6d).IsNaN && x.IsNaN;
</code></pre>
<p>I ask because when implementing custom structs that have a special value with the same meaning as NaN I tend to prefer the second.</p>
<p>Additionally the performance of the property is normally better as it avoid copying the struct on the stack to call the IsNaN static method (And as my property isn't virtual there is no risk of auto-boxing). Granted it isn't really an issue for built-in types as the JIT could optimize this easilly.</p>
<p>My best guess for now is that as you can't have both the property and the static method with the same name in the double class they favored the java-inspired syntax. (In fact you could have both as one define a get_IsNaN property getter and the other an IsNaN static method but it will be confusing in any .Net language supporting the property syntax)</p>
| [
{
"answer_id": 370873,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": true,
"text": "static bool IsNaN(this double value)\n{\n return double.IsNaN(value);\n}\n\nstatic void Main()\n{\n double x = 1... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46594/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.