qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
488,705
<p>The SQL Server query I have is:</p> <pre><code>SELECT ep.employeeID, ep.punchdate, rc.creditAmount FROM EmployeePunch ep INNER JOIN ResponderCredit rc ON rc.employeeID = ep.employeeID AND rc.punchdate = rc.creditdate ORDER BY ep.employeeID </code></pre> <p>and get a result set:</p> <pre><cod...
[ { "answer_id": 488722, "author": "Rob", "author_id": 58304, "author_profile": "https://Stackoverflow.com/users/58304", "pm_score": 0, "selected": false, "text": "<p>for MS SQL, this should do it</p>\n\n<pre><code>SELECT\n ep.employeeID, rc.creditAmount, \n datediff(month, max(ep.punchd...
2009/01/28
[ "https://Stackoverflow.com/questions/488705", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16642/" ]
The SQL Server query I have is: ``` SELECT ep.employeeID, ep.punchdate, rc.creditAmount FROM EmployeePunch ep INNER JOIN ResponderCredit rc ON rc.employeeID = ep.employeeID AND rc.punchdate = rc.creditdate ORDER BY ep.employeeID ``` and get a result set: ``` EmployeeID Date Cr...
In Oracle: ``` SELECT r1.employeeID, amMax - amMin FROM ( SELECT employeeID, amMin FROM ( SELECT ROW_NUMBER() OVER (PARTITION BY ep.EmployeeID ORDER BY rc.creditdate) AS rnMin, ep.employeeID, rc.creditAmount AS amMin FROM EmployeePunch ep, ResponderCredi...
488,717
<p>I'm using NSIS to create an installer for a program, what is the best way to detect if this program is already installed? Also, since I'm running the installer from the autorun.inf, can I immediately quit the installer if it locates an installed copy? Is there a better way to do this?</p>
[ { "answer_id": 488821, "author": "Kevin", "author_id": 26620, "author_profile": "https://Stackoverflow.com/users/26620", "pm_score": 1, "selected": false, "text": "<p>This is generally done by having NSIS insert a registry key for your product when it installs. It is then an easy manner...
2009/01/28
[ "https://Stackoverflow.com/questions/488717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47110/" ]
I'm using NSIS to create an installer for a program, what is the best way to detect if this program is already installed? Also, since I'm running the installer from the autorun.inf, can I immediately quit the installer if it locates an installed copy? Is there a better way to do this?
How about this. I had this in an old NSIS script laying around. ``` ; Check to see if already installed ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\<YOUR-APP-NAME>" "UninstallString" IfFileExists $R0 +1 NotInstalled messagebox::show MB_DEFBUTTON4|MB_TOPMOST "<YOUR-APP-NAME>" \ "0...
488,726
<p>I have an Ajax actionlink that requests a string in the controller method. I want to insert that string into an attribute of a hyperlink. HOw do I specify the attribute field of the target id element?</p> <pre><code>&lt;img id="CHANGE-MY-SRC" src=ViewData["src"] &gt; &lt;%=Ajax.ActionLink("Change IMG Source","acti...
[ { "answer_id": 488773, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 2, "selected": false, "text": "<p>I'm not sure exactly what you mean but you can provide a set of HTML attributes some versions of the ActionLink exte...
2009/01/28
[ "https://Stackoverflow.com/questions/488726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49632/" ]
I have an Ajax actionlink that requests a string in the controller method. I want to insert that string into an attribute of a hyperlink. HOw do I specify the attribute field of the target id element? ``` <img id="CHANGE-MY-SRC" src=ViewData["src"] > <%=Ajax.ActionLink("Change IMG Source","actionChange",new AjaxOptio...
The default behavior for the Ajax helpers won't support this. You can, however, create a custom JavaScript handler that is run when the Ajax request returns, and then use that to inject the value into the attribute Create a common JavaScript file (load it up in the Master page, for example) and add this function: ```...
488,727
<p>I have a question about inheritance in Java.</p> <p>I have two classes <code>A</code> and <code>B</code> , and class B, <strong>inherits</strong> from A:</p> <pre><code>public class A { public A() { System.out.println("Hi!"); } } public class B extends A { public B() { System.out...
[ { "answer_id": 488744, "author": "Brian Rasmussen", "author_id": 38206, "author_profile": "https://Stackoverflow.com/users/38206", "pm_score": 3, "selected": false, "text": "<p>Remember inheritance is an \"is a\" relationship between the base class and the subclass, thus every time you h...
2009/01/28
[ "https://Stackoverflow.com/questions/488727", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42155/" ]
I have a question about inheritance in Java. I have two classes `A` and `B` , and class B, **inherits** from A: ``` public class A { public A() { System.out.println("Hi!"); } } public class B extends A { public B() { System.out.println("Bye!"); } public static void main(St...
It doesn't create two objects, only one: *B*. When inheriting from another class, you **must** call super() in your constructor. If you don't, the compiler will insert that call for you as you can plainly see. The superclass constructors are called because otherwise the object would be left in an uninitialized state,...
488,729
<p>I have some questions on using <code>std::map</code>:</p> <ol> <li><p>Is using an <code>enum</code> as the key in <code>std::map</code> a good practice? Consider the following code:</p> <pre><code>enum Shape{ Circle, Rectangle }; int main(int argc, char* argv[]) { std::map&lt;Shape,std::string&gt; st...
[ { "answer_id": 488762, "author": "gimpf", "author_id": 15529, "author_profile": "https://Stackoverflow.com/users/15529", "pm_score": 5, "selected": true, "text": "<ol>\n<li>Having an enum as key_type is not bad by itself. (<strong>edit</strong>) But if you only use sequential enum-value...
2009/01/28
[ "https://Stackoverflow.com/questions/488729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50419/" ]
I have some questions on using `std::map`: 1. Is using an `enum` as the key in `std::map` a good practice? Consider the following code: ``` enum Shape{ Circle, Rectangle }; int main(int argc, char* argv[]) { std::map<Shape,std::string> strMap; // strMap.insert(Shape::Circle,"Circle"); // This will ...
1. Having an enum as key\_type is not bad by itself. (**edit**) But if you only use sequential enum-values, a `std::vector` with O(1) access is even better. 2. `insert` must be used like this: `mapVar.insert(make_pair(key, value));` See also [cppreference.com](http://www.cppreference.com/wiki/stl/map/insert). 3. Yes, `...
488,731
<p>I'm creating an installer with NSIS for a program that needs to run on an NTFS volume. How do I detect if the install to path is on an NTFS volume and act accordingly (show a help/warning message)?</p>
[ { "answer_id": 488954, "author": "Borzio", "author_id": 36215, "author_profile": "https://Stackoverflow.com/users/36215", "pm_score": 1, "selected": false, "text": "<p>I'm not familiar with NSIS, but you may find this little \"DOS\" trick helpful. </p>\n\n<p>I did notice that it is possi...
2009/01/28
[ "https://Stackoverflow.com/questions/488731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47110/" ]
I'm creating an installer with NSIS for a program that needs to run on an NTFS volume. How do I detect if the install to path is on an NTFS volume and act accordingly (show a help/warning message)?
Using external tools is not always a good idea (Not every command line tool exists on the Home versions of windows ) It's always better to call the correct API directly with the system plug in. ``` !include LogicLib.nsh StrCpy $0 "c:\" System::Call 'Kernel32::GetVolumeInformation(t "$0",t,i ${NSIS_MAX_STRLEN},*i,*i,*...
488,746
<p>I'm comparing some currency values in DUnit but it is not working at all on my machine (work on others, but not on mine).</p> <p>An example:</p> <pre><code>CheckEquals(16.65, SomeCurrencyFieldValue); </code></pre> <p>Raises:</p> <pre><code>expected: &lt;16,65&gt; but was: &lt;16,65&gt; </code></pre> <p>if do th...
[ { "answer_id": 488782, "author": "mghie", "author_id": 30568, "author_profile": "https://Stackoverflow.com/users/30568", "pm_score": 2, "selected": false, "text": "<p>I see that there is only CheckEquals() for extended values in the Delphi 2007 dUnit sources. But you could use this one:<...
2009/01/28
[ "https://Stackoverflow.com/questions/488746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/727/" ]
I'm comparing some currency values in DUnit but it is not working at all on my machine (work on others, but not on mine). An example: ``` CheckEquals(16.65, SomeCurrencyFieldValue); ``` Raises: ``` expected: <16,65> but was: <16,65> ``` if do the following the comparison then works: ``` var Temp: Currency; be...
The issue has to do with how `Currency` values get converted to `Extended` values at run time versus how floating-point literals get converted to `Extended` values at compile time. If the conversion isn't the same in both cases, then the values passed to `CheckEquals` may not compare equal. It would be worth checking ...
488,761
<p>We have a table that maintains account balances by recording transactions in that table. i.e. the most recent row is the account balance.</p> <p>When recording a withdrawal, we would like to ensure that the balance can never go negative. Our proposed solution is something like:</p> <pre><code>INSERT INTO `txns` ...
[ { "answer_id": 488841, "author": "Leonidas", "author_id": 57510, "author_profile": "https://Stackoverflow.com/users/57510", "pm_score": 2, "selected": false, "text": "<p>I cannot say anything about the performance of the query, sorry. But you might want to consider triggers to prevent th...
2009/01/28
[ "https://Stackoverflow.com/questions/488761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
We have a table that maintains account balances by recording transactions in that table. i.e. the most recent row is the account balance. When recording a withdrawal, we would like to ensure that the balance can never go negative. Our proposed solution is something like: ``` INSERT INTO `txns` (`account_id`, `prev_...
I cannot say anything about the performance of the query, sorry. But you might want to consider triggers to prevent the case of the 'new\_balance' ever becoming negative. (Because it strikes me as odd to do a null-insert in case the 'new\_balance' is lower than $amount, but it might work nevertheless :) ). See [docume...
488,772
<p>I'm trying to validate a few python arguments. Until we get the new static typing in Python 3.0, what is the best way of going about this.</p> <p>Here is an example of what I am attempting:</p> <pre><code>class A(object): @accepts(int, int, int) def __init__(a, b, c): pass class B(A): @accepts...
[ { "answer_id": 488946, "author": "D.Shawley", "author_id": 41747, "author_profile": "https://Stackoverflow.com/users/41747", "pm_score": 0, "selected": false, "text": "<p>You might want to play around with the <code>inspect</code> module. It will let you enumerate superclasses, argument ...
2009/01/28
[ "https://Stackoverflow.com/questions/488772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18909/" ]
I'm trying to validate a few python arguments. Until we get the new static typing in Python 3.0, what is the best way of going about this. Here is an example of what I am attempting: ``` class A(object): @accepts(int, int, int) def __init__(a, b, c): pass class B(A): @accepts(int, int, int, int) ...
Why not just define an `any` value, and decorate the subclass constructor with `@accepts(any, any, any, int)`? Your decorator won't check parameters marked with `any`, and the `@accepts` on the superclass constructor will check all the arguments passed up to it by subclasses.
488,789
<p>I have weird error, but that only appears to be happening in IE6, and it happens randomly. I’m implementing omniture analytics on my company’s site. I made a literal server control and called it from inside an update panel. All the control does is build the java script and uses ScriptManager.RegisterStartupScript(Co...
[ { "answer_id": 489686, "author": "DNS", "author_id": 51025, "author_profile": "https://Stackoverflow.com/users/51025", "pm_score": 2, "selected": false, "text": "<p>Sorry if this ends up being completely off-base, but I remember running into something like this a while back. I fixed it ...
2009/01/28
[ "https://Stackoverflow.com/questions/488789", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13053/" ]
I have weird error, but that only appears to be happening in IE6, and it happens randomly. I’m implementing omniture analytics on my company’s site. I made a literal server control and called it from inside an update panel. All the control does is build the java script and uses ScriptManager.RegisterStartupScript(Contr...
Sorry if this ends up being completely off-base, but I remember running into something like this a while back. I fixed it by adding 'defer' to my script tag, i.e.: ``` <script defer="true"> ... </script> ``` This prevents the script from running until the rest of the page has finished loading, which avoids an IE DOM...
488,804
<p>How does one check to see if a user has typed in the right password to log in?</p> <p>This is what (out of a bunch of combinations...) I am doing:</p> <pre><code>&lt;? $login = $_POST['login']; $password = $_POST['password']; mysql_connect('localhost', 'root', 'abc123'); mysql_select_db('aun_vox') or die(mysql_...
[ { "answer_id": 488843, "author": "Javier", "author_id": 11649, "author_profile": "https://Stackoverflow.com/users/11649", "pm_score": 1, "selected": false, "text": "<p>some points:</p>\n\n<ul>\n<li>Do NOT insert string data in the query string. Especially user-provided data. what would ...
2009/01/28
[ "https://Stackoverflow.com/questions/488804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59351/" ]
How does one check to see if a user has typed in the right password to log in? This is what (out of a bunch of combinations...) I am doing: ``` <? $login = $_POST['login']; $password = $_POST['password']; mysql_connect('localhost', 'root', 'abc123'); mysql_select_db('aun_vox') or die(mysql_error()); $q = mysql_qu...
I see you are storing a hash of the password in the database, but for the benefit of other readers, *never* store passwords in plain text in the database. You don't want to be [like Monster.com.uk](http://www.dailymail.co.uk/sciencetech/article-1128822/Hackers-steal-details-4-5m-users-Monster-uk-Britains-biggest-cyber-...
488,808
<p>I have a list with multiple class that contain a Property that is an Integer (Id). </p> <p>I have a List of Integer too.</p> <p>Now, I would like to trim the List of my object to only those class that has the Property in the list of the integer.</p> <p>Example:</p> <pre><code>List of MyObject [MyObjectA].Id = 1 ...
[ { "answer_id": 488816, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "<p>You could use contains:</p>\n\n<pre><code>var finalList = originalList.Where(x =&gt; idList.Contains(x.Id)).ToList();\...
2009/01/28
[ "https://Stackoverflow.com/questions/488808", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13913/" ]
I have a list with multiple class that contain a Property that is an Integer (Id). I have a List of Integer too. Now, I would like to trim the List of my object to only those class that has the Property in the list of the integer. Example: ``` List of MyObject [MyObjectA].Id = 1 [MyObjectB].Id = 2 [MyObjectC].Id =...
You could use contains: ``` var finalList = originalList.Where(x => idList.Contains(x.Id)).ToList(); ``` Or a join: ``` var finalList = (from entry in originalList join id in idList on entry.Id equals id select entry).ToList(); ```
488,809
<p>I'm evaluating some underdocumented software. When I build a sample project, I'm getting a linker error that looks like:</p> <pre>error LNK2019: unresolved external symbol</pre> <p>There aren't a whole lot of lib files with this app, so I can solve this problem with trial and error, but I know there's a more <i>el...
[ { "answer_id": 488823, "author": "LarryF", "author_id": 18518, "author_profile": "https://Stackoverflow.com/users/18518", "pm_score": 4, "selected": false, "text": "<p>More than one thing can be your problem here. I'm not sure looking in the lib file will be the best way to solve it, IM...
2009/01/28
[ "https://Stackoverflow.com/questions/488809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47154/" ]
I'm evaluating some underdocumented software. When I build a sample project, I'm getting a linker error that looks like: ``` error LNK2019: unresolved external symbol ``` There aren't a whole lot of lib files with this app, so I can solve this problem with trial and error, but I know there's a more *elegant* way is t...
First of all you need to know which type of library you are looking at. Some libraries simply contain linkages for a DLL (i.e., import libraries) and others are code objects that become part of the executable image (i.e., static libraries). From the looks of that output, you were looking at a DLL import library. Next ...
488,812
<p>I'm writing a small Grails app, and I keep on getting StaleObjectStateException:s for about 1/10:th of the calls to "createfoo" when running the following rather simple code. Most probably I'm missing out on the best way to use GORM.</p> <p>This is the code:</p> <pre><code>def viewfoo = { session.user.refresh() ...
[ { "answer_id": 488818, "author": "Mike Robinson", "author_id": 43687, "author_profile": "https://Stackoverflow.com/users/43687", "pm_score": 4, "selected": false, "text": "<p>Bit...unless you're of the \"true / false / file not found\" clan</p>\n\n<p><a href=\"http://thedailywtf.com/Comm...
2009/01/28
[ "https://Stackoverflow.com/questions/488812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58394/" ]
I'm writing a small Grails app, and I keep on getting StaleObjectStateException:s for about 1/10:th of the calls to "createfoo" when running the following rather simple code. Most probably I'm missing out on the best way to use GORM. This is the code: ``` def viewfoo = { session.user.refresh() // ... } def creat...
When you add a bit column to your table it will occupy a whole byte in each record, not just a single bit. When you add a second bit column it will be stored in the same byte. The ninth bit column will require a second byte of storage. Tables with 1 bit column will not gain any storage benefit. Tinyint and bit can bot...
488,830
<pre><code>&lt;ol&gt; &lt;li&gt;test&lt;/li&gt; &lt;li&gt;test&lt;/li&gt; &lt;/ol&gt; </code></pre> <p>will show as:</p> <ol> <li>test</li> <li>test</li> </ol> <p>I want to have numbers coloured and text black!</p> <p>I can edit the css, but I do not have access to the HTML.</p>
[ { "answer_id": 488834, "author": "Pim Jager", "author_id": 35197, "author_profile": "https://Stackoverflow.com/users/35197", "pm_score": 5, "selected": false, "text": "<p>Not sure if this works but i think it should:</p>\n\n<pre><code>&lt;li style='color: red;'&gt;&lt;span style='color:b...
2009/01/28
[ "https://Stackoverflow.com/questions/488830", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` <ol> <li>test</li> <li>test</li> </ol> ``` will show as: 1. test 2. test I want to have numbers coloured and text black! I can edit the css, but I do not have access to the HTML.
The [CSS spec](http://www.w3.org/TR/CSS2/generate.html#counters) gives an example of doing just this. Unfortunately, while it works on Firefox 3, it doesn't appear to work on IE7: ``` <html> <head> <style> ol { counter-reset: item; } ol li { display: block; } ol li:before { cont...
488,856
<p>I was working with some C# code today in the morning and I had something like:</p> <pre><code>foreach(DataRow row in MyMethod.GetDataTable().Rows) { //do something } </code></pre> <p>So, as I dont have a full understanding of the language framework I would like to know if GetDataTable() gets called each time an it...
[ { "answer_id": 488867, "author": "Steven Evers", "author_id": 48553, "author_profile": "https://Stackoverflow.com/users/48553", "pm_score": 1, "selected": false, "text": "<p>It only gets called once and then stored.</p>\n" }, { "answer_id": 488868, "author": "mqp", "autho...
2009/01/28
[ "https://Stackoverflow.com/questions/488856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14533/" ]
I was working with some C# code today in the morning and I had something like: ``` foreach(DataRow row in MyMethod.GetDataTable().Rows) { //do something } ``` So, as I dont have a full understanding of the language framework I would like to know if GetDataTable() gets called each time an iteration is done or if it j...
Don't worry about it; it'll only execute GetDataTable() once internally to get the enumerator object from the DataRowCollection, and then fetch a new item from it every run through the loop.
488,874
<p>I have a pool manager template class. When a class object gets added back to the pool manager I would like to reset it back to it's initial state. I would like to call the placment destructor and placment constructor on it so it gets fully reset for the next time it is given out by the pool manager. I've tried many ...
[ { "answer_id": 488977, "author": "e.James", "author_id": 33686, "author_profile": "https://Stackoverflow.com/users/33686", "pm_score": 3, "selected": true, "text": "<p>How about:</p>\n\n<pre><code>template &lt;class T&gt;\nvoid PoolClass&lt;T&gt;::ReleaseToPool(T *obj)\n{\n obj-&gt;~T...
2009/01/28
[ "https://Stackoverflow.com/questions/488874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13676/" ]
I have a pool manager template class. When a class object gets added back to the pool manager I would like to reset it back to it's initial state. I would like to call the placment destructor and placment constructor on it so it gets fully reset for the next time it is given out by the pool manager. I've tried many way...
How about: ``` template <class T> void PoolClass<T>::ReleaseToPool(T *obj) { obj->~T(); //call destructor obj = new ((void *)obj)T(); //call constructor // add a pointer to the object to the list... } ```
488,919
<p>I am writing a Java application using SWT widgets. I would like to update the state of certain widgets upon a certain event happening (for example, updating the data model's state).</p> <p>Is there something in Java similar to Cocoa's NSNotificationCenter, where I can register an object to listen for notification e...
[ { "answer_id": 488950, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 2, "selected": false, "text": "<p>What sort of notifications are you looking for? If all you want is for one object to be able to tell anybody else \...
2009/01/28
[ "https://Stackoverflow.com/questions/488919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19410/" ]
I am writing a Java application using SWT widgets. I would like to update the state of certain widgets upon a certain event happening (for example, updating the data model's state). Is there something in Java similar to Cocoa's NSNotificationCenter, where I can register an object to listen for notification events and ...
Ok, suppose that for example, you want parts of your program to be notified when your Loader starts a scan, and when it finishes a scan (don't worry about what a Loader is, or what a scan is, these are examples from some code I have lying around from my last job). You define an interface, call it "ScanListener", like ...
488,923
<p>I'm building a project that loads data from a webservice into a TreeView Control. When the TreeView is contained on the LayoutRoot grid by itself and it's height is set to Auto, if the contents extend beyond the vertical or horizontal limits of the treeview scrollbars appear automatically, as expected.</p> <p>If t...
[ { "answer_id": 489014, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Yeh - StackPanels don't seem to be a great control for containing variable sized objects.</p>\n\n<p>Similarly; I have had t...
2009/01/28
[ "https://Stackoverflow.com/questions/488923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26516/" ]
I'm building a project that loads data from a webservice into a TreeView Control. When the TreeView is contained on the LayoutRoot grid by itself and it's height is set to Auto, if the contents extend beyond the vertical or horizontal limits of the treeview scrollbars appear automatically, as expected. If that same Tr...
Managed to get this one figured out with some help from the Silverlight.net forums. You can read the original question and answer [here](http://silverlight.net/forums/p/69145/167215.aspx#167215). It turns out that a StackPanel oriented vertically (the defaul orientation) will give infinite size to its children, so sinc...
488,930
<p>It's hard to see how <em>StringTemplate</em> integrates easily (or not) with <em>popular</em> Java web MVC frameworks.</p> <p><strong>Which Java MVC frameworks integrate easily with StringTemplate?</strong></p> <p>A good answer:</p> <ul> <li>mentions <strong>one solution</strong> to integrate with a framework,</l...
[ { "answer_id": 489486, "author": "yawmark", "author_id": 45204, "author_profile": "https://Stackoverflow.com/users/45204", "pm_score": 2, "selected": false, "text": "<p>A quick search led me to this <a href=\"http://jira.springframework.org/browse/SPR-3266\" rel=\"nofollow noreferrer\">d...
2009/01/28
[ "https://Stackoverflow.com/questions/488930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25167/" ]
It's hard to see how *StringTemplate* integrates easily (or not) with *popular* Java web MVC frameworks. **Which Java MVC frameworks integrate easily with StringTemplate?** A good answer: * mentions **one solution** to integrate with a framework, * includes a **link** to something useful and applicable, like: + a *...
I've gotten StringTemplate to work with Spring. Basically, all it took was a custom view. But first, a disclaimer: This is an experimental hack. I've never used this in production code, and it could use some improvement before that happens. I think it is adequate to answer your question about how easily StringTemplate...
488,936
<p>I have an application in Perl that reads in HTML based mark up and converts it to a textual output. One of the things I have encountered is the need to easily convert a HTML table to a fixed font output.</p> <pre><code> &lt;table border="1"&gt; &lt;tr&gt;&lt;td&gt;Hello&lt;/td&gt; &lt;td&gt;World&lt;/td&gt; ...
[ { "answer_id": 489010, "author": "friedo", "author_id": 20745, "author_profile": "https://Stackoverflow.com/users/20745", "pm_score": 4, "selected": true, "text": "<p>I've used <a href=\"http://search.cpan.org/~anno/Text-Table-1.114/lib/Text/Table.pm\" rel=\"nofollow noreferrer\">Text::T...
2009/01/28
[ "https://Stackoverflow.com/questions/488936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13999/" ]
I have an application in Perl that reads in HTML based mark up and converts it to a textual output. One of the things I have encountered is the need to easily convert a HTML table to a fixed font output. ``` <table border="1"> <tr><td>Hello</td> <td>World</td> <tr> <td>foo</td> <td>bar</td> </tr></t...
I've used [Text::Table](http://search.cpan.org/~anno/Text-Table-1.114/lib/Text/Table.pm) with great success. In combination with something like [HTML::TreeBuilder](http://search.cpan.org/~petek/HTML-Tree-3.23/lib/HTML/TreeBuilder.pm) it should be pretty easy.
488,942
<p>In c# when you want to divide the result of a method such as below, what is the best way to force it to return a double value rather than the default integer. </p> <pre><code>(int)Math.Ceiling((double)(System.DateTime.DaysInMonth(2009, 1) / 7)); </code></pre> <p>As you can see I need the division to return a doubl...
[ { "answer_id": 488955, "author": "Alex Jordan", "author_id": 3699, "author_profile": "https://Stackoverflow.com/users/3699", "pm_score": 1, "selected": false, "text": "<p>As far as I know, you can't force a function to return a different type, so casting the result is your best bet. Cas...
2009/01/28
[ "https://Stackoverflow.com/questions/488942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50970/" ]
In c# when you want to divide the result of a method such as below, what is the best way to force it to return a double value rather than the default integer. ``` (int)Math.Ceiling((double)(System.DateTime.DaysInMonth(2009, 1) / 7)); ``` As you can see I need the division to return a double so I can use the ceiling...
A division of two `int` numbers returns an `int`, truncating any decimal points. This is generally true for other data types as well: arithmetic operations don't change the type of their operands. To enforce a certain return type, you must therefore convert the operands appropriately. In your particular case, it's act...
488,949
<p>I have several databound comboboxes in my application and I notice that when i open the combobox to click on an item it doesn't select the item unless i click to the right of the text. I'm assuming there is some way to include the text area as part of the item in terms of making a selection. Any help would be appr...
[ { "answer_id": 489170, "author": "Caleb Postlethwait", "author_id": 39439, "author_profile": "https://Stackoverflow.com/users/39439", "pm_score": 3, "selected": true, "text": "<p>I was using :</p>\n\n<pre><code>&lt;ComboBoxItem Content=\"{Binding time}\"/&gt;\n</code></pre>\n\n<p>It work...
2009/01/28
[ "https://Stackoverflow.com/questions/488949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39439/" ]
I have several databound comboboxes in my application and I notice that when i open the combobox to click on an item it doesn't select the item unless i click to the right of the text. I'm assuming there is some way to include the text area as part of the item in terms of making a selection. Any help would be appreciat...
I was using : ``` <ComboBoxItem Content="{Binding time}"/> ``` It worked fine after I switched it to: ``` <TextBlock Text="{Binding time}"/> ``` Now no matter where I click it still selects. Hope this helps the next guy.
488,959
<p>I'm trying to create a generic function that removes duplicates from an std::vector. Since I don't want to create a function for each vector type, I want to make this a template function that can accept vectors of any type. Here is what I have:</p> <pre><code>//foo.h Class Foo { template&lt;typename T&gt; stati...
[ { "answer_id": 488979, "author": "jalf", "author_id": 33213, "author_profile": "https://Stackoverflow.com/users/33213", "pm_score": 2, "selected": false, "text": "<p>You can't implement a template function in a .cpp file. The complete implementation has to be visible anywhere it's instan...
2009/01/28
[ "https://Stackoverflow.com/questions/488959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23504/" ]
I'm trying to create a generic function that removes duplicates from an std::vector. Since I don't want to create a function for each vector type, I want to make this a template function that can accept vectors of any type. Here is what I have: ``` //foo.h Class Foo { template<typename T> static void RemoveVectorDup...
Short Answer ------------ Define the function in the header, preferably inside the class definition. Long answer ----------- Defining the template function inside the .cpp means it won't get `#include`d into any translation units: it will only be available to the translation unit it's defined in. Hence `RemoveVecto...
488,963
<p>I'd like to work on a bbcode filter for a php website. (I'm using cakephp, it would be a bbcode helper) I have some requirement. </p> <p><strong>Bbcodes can be nested. So something like that is valid.</strong></p> <pre><code>[block] [block] [/block] [block] [block] [/block] ...
[ { "answer_id": 488998, "author": "codemonkey", "author_id": 56800, "author_profile": "https://Stackoverflow.com/users/56800", "pm_score": 2, "selected": false, "text": "<blockquote>\n <p>Responding to: \"Any better idea?\" (and I'm assuming that this was an invite not just for improveme...
2009/01/28
[ "https://Stackoverflow.com/questions/488963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54606/" ]
I'd like to work on a bbcode filter for a php website. (I'm using cakephp, it would be a bbcode helper) I have some requirement. **Bbcodes can be nested. So something like that is valid.** ``` [block] [block] [/block] [block] [block] [/block] [/block] [/block] ``` **...
There's both a [pecl](http://pecl.php.net/package/bbcode) and [PEAR](http://pear.php.net/package/HTML_BBCodeParser) BBCode parsing library. Software's hard enough without reinventing years of work on your own. If neither of those are an option, I'd concentrate on turning the BBCode into a valid XML string, and then us...
488,969
<p>I use a MediaWiki instance on a thumb drive to keep track of a ton of stuff. In the past, I've been in a hurry so I haven't had the chance to look for a nice way to make tables, so this syntax has served my purposes well:</p> <pre><code>{| border=1 ... |} </code></pre> <p>Now I want something a little nicer; I'm ...
[ { "answer_id": 488997, "author": "MaxVT", "author_id": 19530, "author_profile": "https://Stackoverflow.com/users/19530", "pm_score": 3, "selected": true, "text": "<p>As you wrote, you can edit <a href=\"http://www.mediawiki.org/wiki/Manual:CSS\" rel=\"nofollow noreferrer\">Mediawiki CSS ...
2009/01/28
[ "https://Stackoverflow.com/questions/488969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2547/" ]
I use a MediaWiki instance on a thumb drive to keep track of a ton of stuff. In the past, I've been in a hurry so I haven't had the chance to look for a nice way to make tables, so this syntax has served my purposes well: ``` {| border=1 ... |} ``` Now I want something a little nicer; I'm used to using CSS to make n...
As you wrote, you can edit [Mediawiki CSS files](http://www.mediawiki.org/wiki/Manual:CSS). This is the way to go; however, if for some reason you can't use CSS, you can always use Wiki templates that contain cell-specific styling tags.
488,982
<p>For whatever reason when I use Response.Redirect the window just closes out instead of navigating to the given URL, here is the code.</p> <pre><code> if (mode == "print") { error_code.Text = ""; //thumb.Src = file_loc + "source/" + "certificate_thumbnail.jpeg"; link.HRef = "Certificat...
[ { "answer_id": 488991, "author": "Sean Bright", "author_id": 21926, "author_profile": "https://Stackoverflow.com/users/21926", "pm_score": 2, "selected": false, "text": "<p>Maybe the Adobe Reader plugin is crashing the browser?</p>\n" }, { "answer_id": 488993, "author": "spla...
2009/01/28
[ "https://Stackoverflow.com/questions/488982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18309/" ]
For whatever reason when I use Response.Redirect the window just closes out instead of navigating to the given URL, here is the code. ``` if (mode == "print") { error_code.Text = ""; //thumb.Src = file_loc + "source/" + "certificate_thumbnail.jpeg"; link.HRef = "Certificates/" + u_name ...
The problem is due to you opening an aspx page which contains the redirect to .pdf. As the aspx is pre-compiled when its opened by IE it EXPECTS text/html to come back - however as you've redirected its actually receiving application/pdf so IE craps itself and closes. Try it in firefox - works fine I bet. I actually h...
489,024
<p>I'd like to develop a network graph application for Flex - imagine placing nodes on a Canvas and connecting them with links. The nodes should have editable text and other UI components.</p> <p>I'm trying to find examples of creating an entirely new UI component from scratch, but all I've been able to find are triv...
[ { "answer_id": 489062, "author": "darronschall", "author_id": 30458, "author_profile": "https://Stackoverflow.com/users/30458", "pm_score": 3, "selected": false, "text": "<p>You want to create a component that overrides the updateDisplayList method, and do your drawing in there:</p>\n\n<...
2009/01/28
[ "https://Stackoverflow.com/questions/489024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2197/" ]
I'd like to develop a network graph application for Flex - imagine placing nodes on a Canvas and connecting them with links. The nodes should have editable text and other UI components. I'm trying to find examples of creating an entirely new UI component from scratch, but all I've been able to find are trivial example...
You want to create a component that overrides the updateDisplayList method, and do your drawing in there: ``` override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList( unscaledWidth, unscaledHeight ); // The drawing API is found on the components "g...
489,026
<p>I need to do something like this but SQL Server 2008 doesn't like it. My query is actually more complex than this and I realize this isn't the best way to accomplish what I'm doing but my focus is on the functionality of the WITH statement and not the select and where statements.</p> <blockquote> <p>WITH stuff1 A...
[ { "answer_id": 489033, "author": "Kezzer", "author_id": 39693, "author_profile": "https://Stackoverflow.com/users/39693", "pm_score": -1, "selected": false, "text": "<p>Nope, you can only have one CTE in a statement as I found out the other day.</p>\n\n<p><em>EDIT</em>: And that WITH sta...
2009/01/28
[ "https://Stackoverflow.com/questions/489026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29277/" ]
I need to do something like this but SQL Server 2008 doesn't like it. My query is actually more complex than this and I realize this isn't the best way to accomplish what I'm doing but my focus is on the functionality of the WITH statement and not the select and where statements. > > WITH stuff1 AS ( > select name, ...
I do it all the time: ``` WITH stuff1 AS ( SELECT name ,startdate ,id FROM employees WHERE startdate > 0 ) ,stuff2 AS ( SELECT name ,startdate ,id FROM stuff1 ) SELECT * FROM stuff2 WHERE id > 10 ``` As far as I can tell, I haven't reached a limit in CT...
489,036
<p>The socket API is the de-facto standard for TCP/IP and UDP/IP communications (that is, networking code as we know it). However, one of its core functions, <code>accept()</code> is a bit magical.</p> <p>To borrow a semi-formal definition:</p> <blockquote> <p>accept() is used on the server side. It accepts a rec...
[ { "answer_id": 489047, "author": "17 of 26", "author_id": 2284, "author_profile": "https://Stackoverflow.com/users/2284", "pm_score": 8, "selected": true, "text": "<p>Your confusion lies in thinking that a socket is identified by Server IP : Server Port. When in actuality, sockets are u...
2009/01/28
[ "https://Stackoverflow.com/questions/489036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
The socket API is the de-facto standard for TCP/IP and UDP/IP communications (that is, networking code as we know it). However, one of its core functions, `accept()` is a bit magical. To borrow a semi-formal definition: > > accept() is used on the server side. > It accepts a received incoming attempt > to create a...
Your confusion lies in thinking that a socket is identified by Server IP : Server Port. When in actuality, sockets are uniquely identified by a quartet of information: **`Client IP : Client Port` and `Server IP : Server Port`** So while the Server IP and Server Port are constant in all accepted connections, the clien...
489,048
<p>The class mshtml.HTMLDocumentClass in Microsoft.mshtml.dll assembly has a method:</p> <pre><code>public virtual void write(params object[] psarray); </code></pre> <p>Avoiding the real question for a moment, what code would you use to call <strong>write()</strong>? Would you use:</p> <pre><code>String html = "&lt;...
[ { "answer_id": 489047, "author": "17 of 26", "author_id": 2284, "author_profile": "https://Stackoverflow.com/users/2284", "pm_score": 8, "selected": true, "text": "<p>Your confusion lies in thinking that a socket is identified by Server IP : Server Port. When in actuality, sockets are u...
2009/01/28
[ "https://Stackoverflow.com/questions/489048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
The class mshtml.HTMLDocumentClass in Microsoft.mshtml.dll assembly has a method: ``` public virtual void write(params object[] psarray); ``` Avoiding the real question for a moment, what code would you use to call **write()**? Would you use: ``` String html = "<html><body>Hello, world!</body></html>"; mshtml.HTMLD...
Your confusion lies in thinking that a socket is identified by Server IP : Server Port. When in actuality, sockets are uniquely identified by a quartet of information: **`Client IP : Client Port` and `Server IP : Server Port`** So while the Server IP and Server Port are constant in all accepted connections, the clien...
489,051
<p>I'd like to be able to specify a default value to return if the key I specify can't be found in the dictionary.</p> <p>e.g.</p> <pre><code>int default = 5; string key = "MyKey"; int foo = myDictionary.GetValue(key, default); </code></pre> <p>if <code>key</code> is in <code>myDictionary</code> <code>foo</code> sho...
[ { "answer_id": 489055, "author": "Redwood", "author_id": 1512, "author_profile": "https://Stackoverflow.com/users/1512", "pm_score": 3, "selected": true, "text": "<p>I found a piece of code <a href=\"http://gen5.info/q/2008/07/17/the-semantics-of-dictionaries-maps-and-hashtables/\" rel=\...
2009/01/28
[ "https://Stackoverflow.com/questions/489051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1512/" ]
I'd like to be able to specify a default value to return if the key I specify can't be found in the dictionary. e.g. ``` int default = 5; string key = "MyKey"; int foo = myDictionary.GetValue(key, default); ``` if `key` is in `myDictionary` `foo` should hold the value from the dictionary, otherwise it will hold `5`...
I found a piece of code [here](http://gen5.info/q/2008/07/17/the-semantics-of-dictionaries-maps-and-hashtables/) which does the job nicely by adding an extension method to IDictionary: ``` using System.Collections.Generic; namespace MyNamespace { public static class DictionaryExtensions { public static V ...
489,071
<p>In several places in our code, we notice that if running under debugger it'll show that there's an unhandled exception in the code, however if running outside the debugger it will just ignore the exception completely as if it were caught. We have an exception handler that pops up an error submit dialog that's hooke...
[ { "answer_id": 489098, "author": "Ricardo Villamil", "author_id": 19314, "author_profile": "https://Stackoverflow.com/users/19314", "pm_score": 2, "selected": false, "text": "<p>There are some special exceptions that don't get bubbled up or caught, it sounds like you're dealing with one ...
2009/01/28
[ "https://Stackoverflow.com/questions/489071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23822/" ]
In several places in our code, we notice that if running under debugger it'll show that there's an unhandled exception in the code, however if running outside the debugger it will just ignore the exception completely as if it were caught. We have an exception handler that pops up an error submit dialog that's hooked up...
Found one place where this could occur is if there's an exception in the UnhandledException event handler. An easy way to see this is this: In the Form.Load event handler throw any old exception. In the Application.ThreadException event put something similar to the following: ``` static void Application_ThreadExceptio...
489,081
<p>Looking for a query in Informix's SQL that will simulate MySQL's <code>group_concat</code> function.</p> <p>What MySQL's <code>group_concat</code> does is it creates an enumeration of all members in the group.</p> <p>So with the data as follows:</p> <pre><code>orderid:itemName:price 1:Paper :10 1:Pe...
[ { "answer_id": 489677, "author": "RET", "author_id": 14750, "author_profile": "https://Stackoverflow.com/users/14750", "pm_score": 0, "selected": false, "text": "<p>There is certainly no built-in function in Informix to do this. Does any other mainstream RDBMS have such a bizarre aggrega...
2009/01/28
[ "https://Stackoverflow.com/questions/489081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53949/" ]
Looking for a query in Informix's SQL that will simulate MySQL's `group_concat` function. What MySQL's `group_concat` does is it creates an enumeration of all members in the group. So with the data as follows: ``` orderid:itemName:price 1:Paper :10 1:Pen :5 2:Sugar :15 ``` and the followi...
You would have to define a user-defined aggregate to do this. That has four parts - four functions (search for [CREATE AGGREGATE](https://www.ibm.com/support/knowledgecenter/SSGU8G_12.1.0/com.ibm.sqls.doc/ids_sqs_0358.htm) in the [IDS 12.10 Info Centre](http://www-01.ibm.com/support/knowledgecenter/SSGU8G_12.1.0/com.ib...
489,095
<p>I guess my question is best explained with an (simplified) example.</p> <p>Regex 1:</p> <pre><code>^\d+_[a-z]+$ </code></pre> <p>Regex 2:</p> <pre><code>^\d*$ </code></pre> <p>Regex 1 will <strong>never</strong> match a string where regex 2 matches. So let's say that regex 1 is <em>orthogonal</em> to regex 2.</p> <p...
[ { "answer_id": 489134, "author": "codelogic", "author_id": 43427, "author_profile": "https://Stackoverflow.com/users/43427", "pm_score": 1, "selected": false, "text": "<p>You can maybe use something like <a href=\"http://search.cpan.org/~bowmanbs/Regexp-Genex-0.07/lib/Regexp/Genex.pm\" r...
2009/01/28
[ "https://Stackoverflow.com/questions/489095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4308/" ]
I guess my question is best explained with an (simplified) example. Regex 1: ``` ^\d+_[a-z]+$ ``` Regex 2: ``` ^\d*$ ``` Regex 1 will **never** match a string where regex 2 matches. So let's say that regex 1 is *orthogonal* to regex 2. As many people asked what I meant by *orthogonal* I'll try to clarify it: L...
I finally found exactly the library that I was looking for: [dk.brics.automaton](http://www.brics.dk/automaton/) Usage: ``` /** * @return true if the two regexes will never both match a given string */ public boolean isRegexOrthogonal( String regex1, String regex2 ) { Automaton automaton1 = new RegExp(regex1).t...
489,105
<p>I'm currently using the following function which is based on an example from the web, it is called every second to display the current progress through a video stream.</p> <p>Is there something I could do to make this more efficient?</p> <pre><code>function secondstominutes(secs){ var s; if(secs &gt; 60){ var m...
[ { "answer_id": 489143, "author": "Paweł Witkowski Photography", "author_id": 58260, "author_profile": "https://Stackoverflow.com/users/58260", "pm_score": 1, "selected": false, "text": "<p>Yes it can be a little simpler, and uses less Math.floor, local variables etc. Here mine propositio...
2009/01/28
[ "https://Stackoverflow.com/questions/489105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1335448/" ]
I'm currently using the following function which is based on an example from the web, it is called every second to display the current progress through a video stream. Is there something I could do to make this more efficient? ``` function secondstominutes(secs){ var s; if(secs > 60){ var min = Math.floor(secs / 6...
``` function secondstominutes(secs) { var mins = Math.floor(secs / 60); secs = secs % 60; return (mins < 10 ? "0" + mins : mins) + ":" + (secs < 10 ? "0" + secs : secs); } ```
489,113
<p>I was imagining a 3-line Python script to do this but the yum Python API is impenetrable. Is this even possible?</p> <p>Is writing a wrapper for 'yum list package-name' the only way to do this?</p>
[ { "answer_id": 490314, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "<p><a href=\"http://fpaste.org/paste/2453\" rel=\"noreferrer\">http://fpaste.org/paste/2453</a></p>\n\n<p>and there are many e...
2009/01/28
[ "https://Stackoverflow.com/questions/489113", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18446/" ]
I was imagining a 3-line Python script to do this but the yum Python API is impenetrable. Is this even possible? Is writing a wrapper for 'yum list package-name' the only way to do this?
As Seth points out, you can use the updates APIs to ask if something is available as an update. For something that's close to what the "yum list" does you probably want to use the doPackageLists(). Eg. ``` import os, sys import yum yb = yum.YumBase() yb.conf.cache = os.geteuid() != 1 pl = yb.doPackageLists(patterns=s...
489,116
<p>I have the following table:</p> <p>ratings:</p> <pre><code>ID | post_id | rating_type </code></pre> <p>The rating_type field is either 'thumb-up' or 'thumb-down'. I want to get a result set telling me what the highest rated posts are. The following query gives me a result set with the number of up votes for eac...
[ { "answer_id": 489141, "author": "Quassnoi", "author_id": 55159, "author_profile": "https://Stackoverflow.com/users/55159", "pm_score": 3, "selected": true, "text": "<pre><code>SELECT SUM(CASE WHEN rating_type = 'up' THEN 1 WHEN rating_type = 'down' THEN -1 END CASE)\nFROM posts\nGROUP B...
2009/01/28
[ "https://Stackoverflow.com/questions/489116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59907/" ]
I have the following table: ratings: ``` ID | post_id | rating_type ``` The rating\_type field is either 'thumb-up' or 'thumb-down'. I want to get a result set telling me what the highest rated posts are. The following query gives me a result set with the number of up votes for each unique post\_id. ``` SELECT COU...
``` SELECT SUM(CASE WHEN rating_type = 'up' THEN 1 WHEN rating_type = 'down' THEN -1 END CASE) FROM posts GROUP BY post_id ``` P. S. It's better to keep up and down votes as numbers (+1 and -1) rather than strings.
489,119
<p>In some way I have managed to get this error when I try to access into MySQL via the command line:</p> <pre><code>[root@localhost ~]# mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) </code></pre> <p>I have tried resetting the password without any...
[ { "answer_id": 489124, "author": "Chad Birch", "author_id": 41665, "author_profile": "https://Stackoverflow.com/users/41665", "pm_score": 4, "selected": false, "text": "<p>Try connecting without any password:</p>\n\n<pre><code>mysql -u root\n</code></pre>\n\n<p>I believe the initial defa...
2009/01/28
[ "https://Stackoverflow.com/questions/489119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51649/" ]
In some way I have managed to get this error when I try to access into MySQL via the command line: ``` [root@localhost ~]# mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) ``` I have tried resetting the password without any luck using this HowTo. I...
If you actually have set a root password and you've just lost/forgotten it: 1. Stop MySQL 2. Restart it manually with the skip-grant-tables option: `mysqld_safe --skip-grant-tables` 3. Now, open a new terminal window and run the MySQL client: `mysql -u root` 4. Reset the root password manually with this MySQL command:...
489,123
<p>From what i know a vector is guaranteed to be continuous and i can write a chunk of memory to it and do send of fwrite with it. All i need to do is make sure i call .resize() to force it to be the min length i need then i can use it as a normal char array? would this code be correct</p> <pre><code>v.resize(numOfEle...
[ { "answer_id": 489155, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 3, "selected": true, "text": "<pre><code>v.resize(numOfElements);\nv.clear(); //so i wont get numOfElements + len when i push back\n</code...
2009/01/28
[ "https://Stackoverflow.com/questions/489123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
From what i know a vector is guaranteed to be continuous and i can write a chunk of memory to it and do send of fwrite with it. All i need to do is make sure i call .resize() to force it to be the min length i need then i can use it as a normal char array? would this code be correct ``` v.resize(numOfElements); v.clea...
``` v.resize(numOfElements); v.clear(); //so i wont get numOfElements + len when i push back ``` Well, that above code snippet is in effect allocating and creating elements, just to destroy them again. It's in effect the same as: ``` v.reserve(numOfElements); ``` Just that this code is way faster. So, `v.size() ==...
489,140
<p>I have 2 tables that have a many to many relationship; An Individual can belong to many Groups. A Group can have many Individuals. </p> <p>Individuals basically just have their Primary Key ID</p> <p>Groups have a Primary Key ID, IndividualID (same as the ID in the Individual Table), and a bit flag for if that gr...
[ { "answer_id": 489158, "author": "devio", "author_id": 21336, "author_profile": "https://Stackoverflow.com/users/21336", "pm_score": 0, "selected": false, "text": "<p>You need to include the IsPrimaryGroup condition into the JOIN clause. This query finds all individuals with no PrimaryGr...
2009/01/28
[ "https://Stackoverflow.com/questions/489140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30415/" ]
I have 2 tables that have a many to many relationship; An Individual can belong to many Groups. A Group can have many Individuals. Individuals basically just have their Primary Key ID Groups have a Primary Key ID, IndividualID (same as the ID in the Individual Table), and a bit flag for if that group is the primary ...
Don't know your data...but....that LEFT JOIN is an INNER JOIN what happens when you change the WHERE to AND ``` SELECT * FROM Individual i LEFT JOIN Group g ON g.IndividualID = i.ID AND g.IsPrimaryGroup = 0 ``` Here try running this....untested of course since you didn't provide any ample data ``` SELECT SUM(con...
489,150
<p>I'm looking for a JavaScript Testing Framework that I can easily use in whatever context, be it browser, console, XUL, etc.</p> <p>Is there such a framework, or a way to easily retrofit an existing framework so its context agnostic?</p> <p>Edit: The testing framework should <strong>not</strong> be tied to any othe...
[ { "answer_id": 489261, "author": "geowa4", "author_id": 50214, "author_profile": "https://Stackoverflow.com/users/50214", "pm_score": 0, "selected": false, "text": "<p>These run wherever javascript is enabled.</p>\n\n<p><a href=\"http://wiki.github.com/madrobby/scriptaculous/unit-testing...
2009/01/28
[ "https://Stackoverflow.com/questions/489150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9128/" ]
I'm looking for a JavaScript Testing Framework that I can easily use in whatever context, be it browser, console, XUL, etc. Is there such a framework, or a way to easily retrofit an existing framework so its context agnostic? Edit: The testing framework should **not** be tied to any other framework such as jQuery or ...
OK, here's something I just brewed based on some earlier work. I hope this would meet your needs. [jsUnity](http://jsunity.com/) ------------------------------ Lightweight Universal JavaScript Testing Framework > > **jsUnity** is a lightweight universal JavaScript testing framework that is > context-agnostic. It ...
489,173
<p>My C# is a bit rusty and I've never written XML with it before. I'm having trouble getting the XML to write to a file if I attempt to write anything other than elements. Here is the test code that I have:</p> <pre><code>var guiPath = txtGuiPath.Text; MessageBox.Show("Dumping File: " + guiPath); try { var write...
[ { "answer_id": 489186, "author": "Daniel Schaffer", "author_id": 2596, "author_profile": "https://Stackoverflow.com/users/2596", "pm_score": 2, "selected": false, "text": "<p>Why not create a simple class to hold all the data you need and then serialize it using XmlSerializer, rather tha...
2009/01/28
[ "https://Stackoverflow.com/questions/489173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/204/" ]
My C# is a bit rusty and I've never written XML with it before. I'm having trouble getting the XML to write to a file if I attempt to write anything other than elements. Here is the test code that I have: ``` var guiPath = txtGuiPath.Text; MessageBox.Show("Dumping File: " + guiPath); try { var writer = new XmlTex...
You might want to examine the API in System.Xml.Linq. It's a bit of a more flexible approach to generating and writing XML. Writing your document might go roughly like this: ``` XDocument document = new XDocument(); document.Add(new XComment("Config generated on 01/01/01")); document.Add(new XElement("Config", new XEl...
489,181
<p>We have a multitude of databases whose files are stored on their own individual mount points in a drive </p> <pre> (ex. Z:\dbname_db\dbname_db.mdf and Z:\dbname_log\dbname_log.ldf) </pre> <p>What I'm looking for is a way to find the available free space of the mount point.</p> <pre> EXEC xp_cmdshell 'fsutil v...
[ { "answer_id": 489212, "author": "SQLMenace", "author_id": 740, "author_profile": "https://Stackoverflow.com/users/740", "pm_score": 0, "selected": false, "text": "<p>what happens when you run</p>\n\n<pre><code>exec master..xp_fixeddrives\n</code></pre>\n" }, { "answer_id": 48941...
2009/01/28
[ "https://Stackoverflow.com/questions/489181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8607/" ]
We have a multitude of databases whose files are stored on their own individual mount points in a drive ``` (ex. Z:\dbname_db\dbname_db.mdf and Z:\dbname_log\dbname_log.ldf) ``` What I'm looking for is a way to find the available free space of the mount point. ``` EXEC xp_cmdshell 'fsutil volume diskfree Z:\...
xp\_fixeddrives will not display information for mount points, only normal fixed drives. The following link has a CLR procedure that will use a Performance Counter to return the capacity and free space of a mount point. <http://weblogs.sqlteam.com/tarad/archive/2007/12/18/60435.aspx>
489,188
<p>Using .net MVC and I am doing some server side validation in my Action that handles the form post.</p> <p>What is a good technique to pass the errors back to the view?</p> <p>I am thinking of creating an error collection, then adding that collection to my ViewData and then somehow weave some javascript (using jQue...
[ { "answer_id": 489199, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 1, "selected": false, "text": "<p><code>ViewData.ModelState</code> is designed to pass state information (errors) from the controller to the view.</p>\n" }...
2009/01/28
[ "https://Stackoverflow.com/questions/489188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39677/" ]
Using .net MVC and I am doing some server side validation in my Action that handles the form post. What is a good technique to pass the errors back to the view? I am thinking of creating an error collection, then adding that collection to my ViewData and then somehow weave some javascript (using jQuery) to display th...
You want to add the errors to the ModelState as @Mehrdad indicates. ``` ... catch (ArgumentOutOfRangeException e) { ModelState.AddModelError( e.ParamName, e.Message ); result = View( "New" ); } ``` And include the ValidationSummary in your View ``` <%= Html.ValidationSummary() %> ```
489,232
<p>If have a following element in my XSL file:</p> <pre><code>&lt;xsl:value-of select="replace(lower-case(@name), '_([a-z0-9])', '$1')" /&gt; </code></pre> <p>For example from 'get_polygene_lubricants' it makes 'getpolygenelubricants'.</p> <p>What I want to do is to replace the first letter after '_' with the upperc...
[ { "answer_id": 489268, "author": "baretta", "author_id": 30052, "author_profile": "https://Stackoverflow.com/users/30052", "pm_score": 1, "selected": false, "text": "<p>You could do this using a template, recursively calling itself to iterate through the characters in the string. This te...
2009/01/28
[ "https://Stackoverflow.com/questions/489232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4411/" ]
If have a following element in my XSL file: ``` <xsl:value-of select="replace(lower-case(@name), '_([a-z0-9])', '$1')" /> ``` For example from 'get\_polygene\_lubricants' it makes 'getpolygenelubricants'. What I want to do is to replace the first letter after '\_' with the uppercase variant of the letter. I googled...
**Edited**: Per clarification from the original poster, the first string delimited by the underscores should not have its starting letter capitalized. **This solution does not use recursion and should be quite more efficient**. **Here is the new solution**: ``` string-join( (for $i in 1 to count(tokeniz...
489,252
<p>I am trying to create a custom form field and validate off it. This is version 1.0 of Django.</p> <p>Here is my form object</p> <pre><code>class UsernameField(forms.CharField): def clean(self, values): print "" </code></pre> <p>Here is how I call it</p> <pre><code>class RegisterForm(forms.Form): u...
[ { "answer_id": 489395, "author": "user59922", "author_id": 59922, "author_profile": "https://Stackoverflow.com/users/59922", "pm_score": 2, "selected": false, "text": "<p>That didn't work in 1.0... here is how I solved it</p>\n\n<pre><code>class UsernameField(forms.CharField):\n def c...
2009/01/28
[ "https://Stackoverflow.com/questions/489252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59922/" ]
I am trying to create a custom form field and validate off it. This is version 1.0 of Django. Here is my form object ``` class UsernameField(forms.CharField): def clean(self, values): print "" ``` Here is how I call it ``` class RegisterForm(forms.Form): username = UsernameField(max_length=30, min_l...
If you just want to clean your field, there's no need to define a whole new field, you can do that in the form's clean\_username method ``` class RegisterForm(forms.Form): username = forms.CharField(max_length=30, min_length=4) ... ... def clean_username(self): username = self.cleaned_data['username'] ...
489,258
<p>I am playing with LINQ to learn about it, but I can't figure out how to use <code>Distinct</code> when I do not have a simple list (a simple list of integers is pretty easy to do, this is not the question). What I if want to use <a href="https://msdn.microsoft.com/library/system.linq.enumerable.distinct%28v=vs.100%2...
[ { "answer_id": 489271, "author": "mqp", "author_id": 55943, "author_profile": "https://Stackoverflow.com/users/55943", "pm_score": 3, "selected": false, "text": "<p>You can do it (albeit not lightning-quickly) like so:</p>\n\n<pre><code>people.Where(p =&gt; !people.Any(q =&gt; (p != q &a...
2009/01/28
[ "https://Stackoverflow.com/questions/489258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13913/" ]
I am playing with LINQ to learn about it, but I can't figure out how to use `Distinct` when I do not have a simple list (a simple list of integers is pretty easy to do, this is not the question). What I if want to use [Distinct](https://msdn.microsoft.com/library/system.linq.enumerable.distinct%28v=vs.100%29.aspx) on a...
**EDIT**: This is now part of [MoreLINQ](https://github.com/morelinq/MoreLINQ). What you need is a "distinct-by" effectively. I don't believe it's part of LINQ as it stands, although it's fairly easy to write: ``` public static IEnumerable<TSource> DistinctBy<TSource, TKey> (this IEnumerable<TSource> source, Func...
489,269
<p>In Python 2.5, the following code raises a <code>TypeError</code>:</p> <pre><code>&gt;&gt;&gt; class X: def a(self): print "a" &gt;&gt;&gt; class Y(X): def a(self): super(Y,self).a() print "b" &gt;&gt;&gt; c = Y() &gt;&gt;&gt; c.a() Traceback (most recent call last): File "&l...
[ { "answer_id": 489278, "author": "Serafina Brocious", "author_id": 4977, "author_profile": "https://Stackoverflow.com/users/4977", "pm_score": 8, "selected": true, "text": "<p>The reason is that <a href=\"https://docs.python.org/2/library/functions.html#super\" rel=\"noreferrer\"><code>s...
2009/01/28
[ "https://Stackoverflow.com/questions/489269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31610/" ]
In Python 2.5, the following code raises a `TypeError`: ``` >>> class X: def a(self): print "a" >>> class Y(X): def a(self): super(Y,self).a() print "b" >>> c = Y() >>> c.a() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in a Ty...
The reason is that [`super()`](https://docs.python.org/2/library/functions.html#super) only operates on [new-style classes](https://docs.python.org/2/glossary.html#term-new-style-class), which in the 2.x series means extending from `object`: ``` >>> class X(object): def a(self): print 'a' >>> clas...
489,277
<p>I have an export SQL file containing tables and data from MySQL and I want to import it into a Sqlite 3 DB.</p> <p>What is the best way to do that?</p> <p>Just importing the file via the sqlite3 tool doesn't work.</p>
[ { "answer_id": 489296, "author": "Igor", "author_id": 174644, "author_profile": "https://Stackoverflow.com/users/174644", "pm_score": 6, "selected": true, "text": "<p>This shell script help you</p>\n\n<pre><code>#!/bin/sh\nif [ \"x$1\" == \"x\" ]; then\n echo \"Usage: $0 &lt;dumpname&g...
2009/01/28
[ "https://Stackoverflow.com/questions/489277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58693/" ]
I have an export SQL file containing tables and data from MySQL and I want to import it into a Sqlite 3 DB. What is the best way to do that? Just importing the file via the sqlite3 tool doesn't work.
This shell script help you ``` #!/bin/sh if [ "x$1" == "x" ]; then echo "Usage: $0 <dumpname>" exit fi cat $1 | grep -v ' KEY "' | grep -v ' UNIQUE KEY "' | grep -v ' PRIMARY KEY ' | sed '/^SET/d' | sed 's/ unsigned / /g' | sed 's/ auto_increment/ primary key autoincrement/g' | sed 's/ smallint([0-9]*) / integer...
489,281
<p>I have an MDIChild form that needs to show a dialog. I'm currently doing it like this from inside the mdichild form...</p> <pre><code>f.ShowDialog(Me) </code></pre> <p>Should I be using <code>f.ShowDialog(mdiparent)</code>?</p> <p>What is the difference when setting the owner before calling <code>ShowDialog()</co...
[ { "answer_id": 489697, "author": "Joey", "author_id": 25962, "author_profile": "https://Stackoverflow.com/users/25962", "pm_score": 2, "selected": false, "text": "<p>I'm not sure if this is related, but I've had some issues with passing the owning form in ShowDialog, I usually do this:</...
2009/01/28
[ "https://Stackoverflow.com/questions/489281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40822/" ]
I have an MDIChild form that needs to show a dialog. I'm currently doing it like this from inside the mdichild form... ``` f.ShowDialog(Me) ``` Should I be using `f.ShowDialog(mdiparent)`? What is the difference when setting the owner before calling `ShowDialog()`?
The difference is in which parent owns the dialog. If you explicitly set the parent then that window owns the dialog. If you don't set it (using the parameterless version of ShowDialog) then the current active window of your application owns the dialog. That's on [MSDN](http://msdn.microsoft.com/en-us/library/w61zzfwe....
489,293
<p>I'm trying to do something simple here. When I execute the following code in Visual Studio 2008 using the unicode character set, xmlString is correct. </p> <p>Unfortunately I need to convert the CString to a unsigned char*. Using the code below, ucStr becomes "&lt;" (i.e. the first character of xmlString).</p> <p>...
[ { "answer_id": 489398, "author": "KenE", "author_id": 43783, "author_profile": "https://Stackoverflow.com/users/43783", "pm_score": 0, "selected": false, "text": "<p>I assume \"SendXmlData\" wants the number of bytes and not the number of characters. </p>\n\n<p>If so, you want to change...
2009/01/28
[ "https://Stackoverflow.com/questions/489293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to do something simple here. When I execute the following code in Visual Studio 2008 using the unicode character set, xmlString is correct. Unfortunately I need to convert the CString to a unsigned char\*. Using the code below, ucStr becomes "<" (i.e. the first character of xmlString). **How should I conv...
I find the simplest is to use the CStringA constructor, like this: ``` CString xmlString; xmlString.Format( _T("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><gateway><config-read><%s /></config-read></gateway>"), "test"); printf("%s\n",xmlString ); // fails "<" //unsigned char * ucStr = reinterpre...
489,295
<p>As far as I know, I have added no internet access in my .net windows forms application. But every so often it attempts an outgoing connection to 239.255.255.250. I have no idea why this is happening. Is it something in the .net framework?</p> <p>Info for 239.255.255.250:</p> <pre><code>OrgName: Internet Assigne...
[ { "answer_id": 489313, "author": "Michael Haren", "author_id": 29, "author_profile": "https://Stackoverflow.com/users/29", "pm_score": 3, "selected": true, "text": "<p>I'd guess it isn't a big deal. References for your viewing pleasure:</p>\n\n<ul>\n<li><a href=\"http://www.nthelp.com/up...
2009/01/28
[ "https://Stackoverflow.com/questions/489295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28343/" ]
As far as I know, I have added no internet access in my .net windows forms application. But every so often it attempts an outgoing connection to 239.255.255.250. I have no idea why this is happening. Is it something in the .net framework? Info for 239.255.255.250: ``` OrgName: Internet Assigned Numbers Authority ...
I'd guess it isn't a big deal. References for your viewing pleasure: * <http://www.nthelp.com/upnpscrewup.htm> * <http://forums.snapstream.com/vb/showthread.php?p=129675> * <http://www.google.com/search?hl=en&q=239.255.255.250&btnG=Google+Search> Questions for you: * How do you know it's your windows app? **ZoneAlar...
489,304
<p>I want to load one of four separate C# assemblies based upon what the build target is. This is going into a webservice with .net framework 3.0. </p> <p>possibilities:</p> <p>32-bit debug: AmtApiWrapper32d.dll</p> <p>32-bit release: AmtApiWrapper32.dll</p> <p>64-bit debug: AmtApiWrapper64d.dll</p> <p>64-bit rele...
[ { "answer_id": 489382, "author": "Chris J", "author_id": 16059, "author_profile": "https://Stackoverflow.com/users/16059", "pm_score": 0, "selected": false, "text": "<p>Have you tried using pre-compiler directives and defining different variables in the build target?</p>\n\n<p>i.e.</p>\n...
2009/01/28
[ "https://Stackoverflow.com/questions/489304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59890/" ]
I want to load one of four separate C# assemblies based upon what the build target is. This is going into a webservice with .net framework 3.0. possibilities: 32-bit debug: AmtApiWrapper32d.dll 32-bit release: AmtApiWrapper32.dll 64-bit debug: AmtApiWrapper64d.dll 64-bit release: AmtApiWrapper64.dll Those wrappe...
It's definitely possible, but you'll have to wade into the build file. You'd want something like: ``` <ItemGroup Condition=" '$(Configuration)' == '32-bit debug' "> <Reference Include="AmtApiWrapper32d"> </ItemGroup> <ItemGroup Condition=" '$(Configuration)' == '32-bit release' "> <Reference Include="AmtApiWrappe...
489,308
<p>I have a bcb5 project group that I am trying to compile with make.exe. Make seems to run fine and generates a call to bcc32.exe, but that fails. Here is the call to bcc32.exe followed by the error.</p> <pre><code>M:\projects\Project&gt;"D:\Program Files\Borland\CBuilder5\Bin\bcc32.exe" -Od -H=.\obj_files\vcl50.cs...
[ { "answer_id": 489324, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 1, "selected": false, "text": "<p>A guess is that <code>-nobj_files\\</code> (near the end of the command) is causing the next space to be excaped. Try ...
2009/01/28
[ "https://Stackoverflow.com/questions/489308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54790/" ]
I have a bcb5 project group that I am trying to compile with make.exe. Make seems to run fine and generates a call to bcc32.exe, but that fails. Here is the call to bcc32.exe followed by the error. ``` M:\projects\Project>"D:\Program Files\Borland\CBuilder5\Bin\bcc32.exe" -Od -H=.\obj_files\vcl50.csm -Hc -Vx -Ve -X- -...
Thanks for the idea, strager. It was close, but the actual problem is the set of quotes around P:\bg\Gif Image. Changing them to single quotes fixes the problem. I believe this can be also be solved with FixMake: <http://www.grassvalleysoftware.com/>. FixMake takes a makefile and cleans up things such as trailing back...
489,317
<p>OK I need to design a way to keep track of how many of each item exists. There are approximately 26 items. I also need a way to find out if a certain combination of items exist.</p> <p>For example, This is an engine for a card game. Each card has a different type and each card can have card attached to it. There n...
[ { "answer_id": 489333, "author": "Otávio Décio", "author_id": 48684, "author_profile": "https://Stackoverflow.com/users/48684", "pm_score": 5, "selected": false, "text": "<p>Use <a href=\"https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/params\" rel=\"nofollow ...
2009/01/28
[ "https://Stackoverflow.com/questions/489317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43734/" ]
OK I need to design a way to keep track of how many of each item exists. There are approximately 26 items. I also need a way to find out if a certain combination of items exist. For example, This is an engine for a card game. Each card has a different type and each card can have card attached to it. There need to be ...
I would take a Predicate which can be evaluated against your data source and then evaluate that, returning the result from the Predicate.
489,340
<p>Why won't <code>vertical-align: middle</code> work? And yet, <code>vertical-align: top</code> <em>does</em> work.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>span{ ...
[ { "answer_id": 489365, "author": "Ikke", "author_id": 20261, "author_profile": "https://Stackoverflow.com/users/20261", "pm_score": 4, "selected": false, "text": "<p>Because you have to set the <code>line-height</code> to the height of the div for this to work</p>\n" }, { "answer...
2009/01/28
[ "https://Stackoverflow.com/questions/489340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58249/" ]
Why won't `vertical-align: middle` work? And yet, `vertical-align: top` *does* work. ```css span{ vertical-align: middle; } ``` ```html <div> <img src="https://via.placeholder.com/30" alt="small img" /> <span>Doesn't work.</span> </div> ```
Actually, in this case it's quite simple: apply the vertical align to the image. Since it's all in one line, it's really the image you want aligned, not the text. ```html <!-- moved "vertical-align:middle" style from span to img --> <div> <img style="vertical-align:middle" src="https://via.placeholder.com/60x60" alt...
489,360
<p>Does anyone know if HQL has a keyword to identify rows such as ROWID or ROWNUM?</p> <p>I would like to implement pagination with HQL but I am not able to use .setMaxResult() or .setFirstResult() because I don't work with the session object directly and therefore don't use the Query object but simply create my query...
[ { "answer_id": 491301, "author": "sleske", "author_id": 43681, "author_profile": "https://Stackoverflow.com/users/43681", "pm_score": 1, "selected": false, "text": "<p>Well, you can in principle access ROWNUM/ROWID from HSQL (though I've never used it). See e.g. <a href=\"http://ronfranc...
2009/01/28
[ "https://Stackoverflow.com/questions/489360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57701/" ]
Does anyone know if HQL has a keyword to identify rows such as ROWID or ROWNUM? I would like to implement pagination with HQL but I am not able to use .setMaxResult() or .setFirstResult() because I don't work with the session object directly and therefore don't use the Query object but simply create my query as a stri...
this is one situation where hibernate shines: typical solution with hql query. ``` int elementsPerBlock = 10; int page = 2; return getSession().createQuery("from SomeItems order by id asc") .setFirstResult(elementsPerBlock * (page-1) + 1 ) .setMaxResults(elementsPerBlock) .list()...
489,364
<p>HI,</p> <p>I don't like posting compile problems, but I really can't figure this one out. Using this code:</p> <pre><code>#include &lt;map&gt; #include &lt;boost/iterator/transform_iterator.hpp&gt; using namespace std; template &lt;typename K, typename V&gt; struct get_value { const V&amp; operator ()(std::p...
[ { "answer_id": 489400, "author": "Eclipse", "author_id": 8701, "author_profile": "https://Stackoverflow.com/users/8701", "pm_score": 3, "selected": false, "text": "<p>You'll have to inherit <code>get_value</code> from <code>unary_function&lt;const V&amp;, std::pair&lt;K, V&gt; const&amp;...
2009/01/28
[ "https://Stackoverflow.com/questions/489364", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18909/" ]
HI, I don't like posting compile problems, but I really can't figure this one out. Using this code: ``` #include <map> #include <boost/iterator/transform_iterator.hpp> using namespace std; template <typename K, typename V> struct get_value { const V& operator ()(std::pair<K, V> const& p) { return p.second; } };...
Since you also asked for an explanation The `transform_iterator` needs to know the return type of the function called in order to instantiate itself. This is determined via [`result_of`](http://www.boost.org/doc/libs/1_37_0/libs/utility/utility.htm#result_of) (found in `<boost/utility/result_of.hpp>` If you use a fun...
489,369
<p>I am using a jQuery plugin to set cookies and when I use localhost for the domain it will not store the cookie.</p> <p>Here is the plugin I am using with jQuery 1.2.6.</p> <p><a href="http://www.stilbuero.de/2006/09/17/cookie-plugin-for-jquery/" rel="noreferrer">http://www.stilbuero.de/2006/09/17/cookie-plugin-for...
[ { "answer_id": 489396, "author": "empi", "author_id": 49048, "author_profile": "https://Stackoverflow.com/users/49048", "pm_score": 6, "selected": true, "text": "<p>I had similar problem with setting cookies. Make up a domain name and add it to your hosts file as 127.0.0.1. Then run web ...
2009/01/28
[ "https://Stackoverflow.com/questions/489369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10366/" ]
I am using a jQuery plugin to set cookies and when I use localhost for the domain it will not store the cookie. Here is the plugin I am using with jQuery 1.2.6. <http://www.stilbuero.de/2006/09/17/cookie-plugin-for-jquery/> Below is the code that I am using. You can see it does not like localhost, and I am running i...
I had similar problem with setting cookies. Make up a domain name and add it to your hosts file as 127.0.0.1. Then run web application on that domain.
489,415
<p>In RC1 the behavior of the template for creating a view changed.</p> <p>As explained by Scott Gu's post about the <a href="http://weblogs.asp.net/scottgu/archive/2009/01/27/asp-net-mvc-1-0-release-candidate-now-available.aspx" rel="nofollow noreferrer">release candidate</a> a newly created aspx view doesn't have a ...
[ { "answer_id": 489769, "author": "Andrew Stanton-Nurse", "author_id": 29813, "author_profile": "https://Stackoverflow.com/users/29813", "pm_score": 3, "selected": true, "text": "<p>To answer your question directly, I don't think you can change this default. You could try modifying the te...
2009/01/28
[ "https://Stackoverflow.com/questions/489415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
In RC1 the behavior of the template for creating a view changed. As explained by Scott Gu's post about the [release candidate](http://weblogs.asp.net/scottgu/archive/2009/01/27/asp-net-mvc-1-0-release-candidate-now-available.aspx) a newly created aspx view doesn't have a code-behind file by default anymore. > > Base...
To answer your question directly, I don't think you can change this default. You could try modifying the template (which would be somewhere in %programfiles%\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates"), but I don't know for sure. However, the "MVC-way" for this scenario is probably to create a custom helpe...
489,417
<p>After looking at the .net on IIS7 application lifecycle: </p> <p><a href="http://msdn.microsoft.com/en-us/library/ms178473.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms178473.aspx</a></p> <p>For maximum performance, I want to find a way to get my code started as soon as the HttpContext...
[ { "answer_id": 494164, "author": "ajma", "author_id": 60117, "author_profile": "https://Stackoverflow.com/users/60117", "pm_score": 0, "selected": false, "text": "<p>Look at the <a href=\"http://msdn.microsoft.com/en-us/library/ms178472.aspx\" rel=\"nofollow noreferrer\">life-cycle event...
2009/01/28
[ "https://Stackoverflow.com/questions/489417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46706/" ]
After looking at the .net on IIS7 application lifecycle: <http://msdn.microsoft.com/en-us/library/ms178473.aspx> For maximum performance, I want to find a way to get my code started as soon as the HttpContext object is created but before HttpApplication is. (it's easy to run code after the HttpApplication class is l...
You cannot ever be sure your code starts before the HttpApplication instance is created, since these instances may be reused. Also, running code at this stage is beyond the scope of the pipeline. It should make you ask yourself whether it's really a sensible thing to do. And what's this about performance? You really ...
489,420
<p>I'm looking to refactor the below query to something more readable and modifiable. The first half is identical to the second, with the exception of the database queried from (table names are the same though.)</p> <pre><code> SELECT Column 1 AS c1, ... Column N AS cN FROM database1.dbo.Table1 UN...
[ { "answer_id": 489438, "author": "Michael Haren", "author_id": 29, "author_profile": "https://Stackoverflow.com/users/29", "pm_score": 2, "selected": false, "text": "<p>One performance tip that I see off the bat is using <code>UNION ALL</code> instead of <code>UNION</code> unless you int...
2009/01/28
[ "https://Stackoverflow.com/questions/489420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33226/" ]
I'm looking to refactor the below query to something more readable and modifiable. The first half is identical to the second, with the exception of the database queried from (table names are the same though.) ``` SELECT Column 1 AS c1, ... Column N AS cN FROM database1.dbo.Table1 UNION SELECT ...
This is a pretty standard SQL pattern. Sometimes it's easy to inadvisedly transfer OOP/Procedural code principles like DRY to SQL, but they aren't necessarily transferable concepts. Note how easily you can grok the entire logical design of the query, vs. hunting through submodules. If one of the subexpressions had an...
489,425
<p>I have a DataTable which is populated from a CSV file then, using a DataGridView the data is edited in memory. As far as I understand the programmatic editing of the data should be done on the DataTable where the user editing is done via. the DataGridView.</p> <p>However when I add columns programmatically to the Da...
[ { "answer_id": 489476, "author": "Mark Brittingham", "author_id": 15592, "author_profile": "https://Stackoverflow.com/users/15592", "pm_score": 1, "selected": false, "text": "<p>Is AutoGenerateColumns set to true? If you are making changes after the initial Binding you'll also have to c...
2009/01/28
[ "https://Stackoverflow.com/questions/489425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/199/" ]
I have a DataTable which is populated from a CSV file then, using a DataGridView the data is edited in memory. As far as I understand the programmatic editing of the data should be done on the DataTable where the user editing is done via. the DataGridView. However when I add columns programmatically to the DataTable, ...
This doesn't sound right. To test it out, I wrote a simple app, that creates a DataTable and adds some data to it. On the `button1.Click` it binds the table to the DataGridView. Then, I added a second button, which when clicked, adds another column to the underlying DataTable. When I tested it, and I clicked t...
489,429
<p>I'm looking to add an extra set of pages to my auto-generated admin site. I want to generate reports off my models and some logs surrounding it. The actual generating isn't the issue.</p> <p>How do I:</p> <ol> <li>Make the report output look like it's an admin page, with breadcrumbs, similarly formatted table, etc...
[ { "answer_id": 489463, "author": "Andy Hume", "author_id": 46460, "author_profile": "https://Stackoverflow.com/users/46460", "pm_score": 2, "selected": false, "text": "<p>In terms of generating the look and feel of admin, it should be trivial to inherit the parent pages of the admin and ...
2009/01/28
[ "https://Stackoverflow.com/questions/489429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12870/" ]
I'm looking to add an extra set of pages to my auto-generated admin site. I want to generate reports off my models and some logs surrounding it. The actual generating isn't the issue. How do I: 1. Make the report output look like it's an admin page, with breadcrumbs, similarly formatted table, etc? 2. Register the vi...
The above answer didn't address question 2, at least directly... the "hack" way to get your custom view to show up as the front page of the admin is probably to just override it in the urlconf: ``` (r'^admin/$', my.custom.admin.homepage), ``` before the normal admin line: ``` (r'^admin/', admin.site.root), ``` th...
489,441
<p>This package uses two unique features of Oracle, REF_CURSOR and a package global variable. I would like to port the functionality from Oracle to Postgresql or MySQL.</p> <pre><code>PACKAGE tox IS /*=======================*/ g_spool_key spool.key%TYPE := NULL; TYPE t_spool IS REF CURSOR RETURN s...
[ { "answer_id": 499725, "author": "Yoni", "author_id": 36071, "author_profile": "https://Stackoverflow.com/users/36071", "pm_score": -1, "selected": false, "text": "<p>For mysql:</p>\n\n<ol>\n<li>For ref_cursor you can just use a regular select in a procedure. Mysql has an implicit result...
2009/01/28
[ "https://Stackoverflow.com/questions/489441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13930/" ]
This package uses two unique features of Oracle, REF\_CURSOR and a package global variable. I would like to port the functionality from Oracle to Postgresql or MySQL. ``` PACKAGE tox IS /*=======================*/ g_spool_key spool.key%TYPE := NULL; TYPE t_spool IS REF CURSOR RETURN spool%ROWTYPE; ...
**PostgreSQL 8.3** The problem in PostgreSQL is the lack of global (or package) variables, so that part has to be solved with a temp-table that is created first. The rest of it was quite easy. If you are serious about porting the application over to PostgreSQL or MySQL, I would recommend you to not use global variabl...
489,466
<p>I have a requirement to pad all single digits numbers with a starting zero. Can some one please suggest the best method? (ex 1 -> 01, 2 -> 02, etc)</p>
[ { "answer_id": 489472, "author": "Rockcoder", "author_id": 5290, "author_profile": "https://Stackoverflow.com/users/5290", "pm_score": 6, "selected": false, "text": "<pre><code>number.ToString().PadLeft(2, '0')\n</code></pre>\n" }, { "answer_id": 489473, "author": "bdukes", ...
2009/01/28
[ "https://Stackoverflow.com/questions/489466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41508/" ]
I have a requirement to pad all single digits numbers with a starting zero. Can some one please suggest the best method? (ex 1 -> 01, 2 -> 02, etc)
I'd call [.ToString](https://learn.microsoft.com/en-us/dotnet/api/system.int32.tostring?view=netframework-4.7.2#System_Int32_ToString_System_String_) on the numbers, providing a [format string](https://learn.microsoft.com/en-us/dotnet/standard/base-types/formatting-types#FormatStrings) which requires two digits, as bel...
489,474
<p>I am working on an asp page that verifies information in a text box after the user types it in.</p> <p>A “product number” is manually entered (free form). Using the after update event, I have the page post the data and lookup the product number to determine if it is valid. If not valid an error message is posted in...
[ { "answer_id": 489472, "author": "Rockcoder", "author_id": 5290, "author_profile": "https://Stackoverflow.com/users/5290", "pm_score": 6, "selected": false, "text": "<pre><code>number.ToString().PadLeft(2, '0')\n</code></pre>\n" }, { "answer_id": 489473, "author": "bdukes", ...
2009/01/28
[ "https://Stackoverflow.com/questions/489474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am working on an asp page that verifies information in a text box after the user types it in. A “product number” is manually entered (free form). Using the after update event, I have the page post the data and lookup the product number to determine if it is valid. If not valid an error message is posted in the box, ...
I'd call [.ToString](https://learn.microsoft.com/en-us/dotnet/api/system.int32.tostring?view=netframework-4.7.2#System_Int32_ToString_System_String_) on the numbers, providing a [format string](https://learn.microsoft.com/en-us/dotnet/standard/base-types/formatting-types#FormatStrings) which requires two digits, as bel...
489,475
<p>We're implementing Team Build and know we need to write MSBuild scripts to build our legacy VB 6 app. It's configured to use Binary Compatibility and we break Compatibility occassionally and we'd like our new automated build process to be able to Break Compatibility automatically.</p> <p>Anyone know how to do this ...
[ { "answer_id": 489537, "author": "jdigital", "author_id": 37231, "author_profile": "https://Stackoverflow.com/users/37231", "pm_score": 3, "selected": true, "text": "<p>Regarding changing from Compatibility to No Compatibility, I've done things like this by editing the project file with ...
2009/01/28
[ "https://Stackoverflow.com/questions/489475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
We're implementing Team Build and know we need to write MSBuild scripts to build our legacy VB 6 app. It's configured to use Binary Compatibility and we break Compatibility occassionally and we'd like our new automated build process to be able to Break Compatibility automatically. Anyone know how to do this or if it's...
Regarding changing from Compatibility to No Compatibility, I've done things like this by editing the project file with Unix-style tools (sed, awk, and/or perl). Do not change the original project file, but instead generate a new/temporary project file, and build with that. Here's an example: ``` sed -e "s/CompatibleMo...
489,485
<p>I was looking at the String and Int32 types through the reflector but couldn't find any operators that are defined.</p> <p>If they aren't defined, how do +/-, etc works on these types?</p>
[ { "answer_id": 489539, "author": "Hans Passant", "author_id": 17034, "author_profile": "https://Stackoverflow.com/users/17034", "pm_score": 3, "selected": false, "text": "<p>The String class has only two, they have CLS compliant names: op_Equality and op_Inequality. The compiler has lot...
2009/01/28
[ "https://Stackoverflow.com/questions/489485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51816/" ]
I was looking at the String and Int32 types through the reflector but couldn't find any operators that are defined. If they aren't defined, how do +/-, etc works on these types?
The numeric operators are part of IL itself. The "+" operator on strings is a bit special though - it's not overloaded by the string type itself, it's done by the compiler. The C# compiler translates: ``` string x = a + "hello" + b; ``` into: ``` string x = string.Concat(a, "hello", b); ``` This is more efficient...
489,492
<p>I am calling a web Method from javascript. The web method returns an array of customers from the northwind database. The example I am working from is here: <a href="http://www.asp.net/learn/ajax/tutorial-05-cs.aspx" rel="nofollow noreferrer">Calling Web Services with ASP.NET AJAX</a></p> <p>I dont know how to write...
[ { "answer_id": 489582, "author": "Pim Jager", "author_id": 35197, "author_profile": "https://Stackoverflow.com/users/35197", "pm_score": 1, "selected": false, "text": "<p>You should pass the array as JSON or XML instead of just the toString() value of it (unless that offcourse is returns...
2009/01/28
[ "https://Stackoverflow.com/questions/489492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59941/" ]
I am calling a web Method from javascript. The web method returns an array of customers from the northwind database. The example I am working from is here: [Calling Web Services with ASP.NET AJAX](http://www.asp.net/learn/ajax/tutorial-05-cs.aspx) I dont know how to write this javascript method: **CreateCustomersTable...
Try to look what is the result variable value in debug mode. If the structure seems the structure that i'm imagining, something like this could work: ``` function CreateCustomersTable(result) { var str = '<table>'; str += '<tr><th>Id</th><th>Name</th></tr>'; for ( var i=0; i< result.length; i++){ ...
489,496
<p>When i try to compile this as part of an objective-c program it gives the warning:<br> <code>warning: passing argument 1 of 'sqlite3_close' from incompatible pointer type</code></p> <pre><code>sqlite3 *db; sqlite3_open("~/Documents/testdb.sqlite", &amp;db); /*stuff*/ sqlite3_close(&amp;db); </code></pre> <p>An al...
[ { "answer_id": 489506, "author": "Ates Goral", "author_id": 23501, "author_profile": "https://Stackoverflow.com/users/23501", "pm_score": 1, "selected": false, "text": "<p>You should just pass in the pointer, not a reference to it:</p>\n\n<pre><code>sqlite3_close(db);\n</code></pre>\n" ...
2009/01/28
[ "https://Stackoverflow.com/questions/489496", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26659/" ]
When i try to compile this as part of an objective-c program it gives the warning: `warning: passing argument 1 of 'sqlite3_close' from incompatible pointer type` ``` sqlite3 *db; sqlite3_open("~/Documents/testdb.sqlite", &db); /*stuff*/ sqlite3_close(&db); ``` An almost identical error is given with nearly any o...
I don't think you need the second `&`... If this is anything like plain c, you just want to call `sqlite3_close(db);` (Thereby passing it the pointer itself, rather than the address of the pointer.) The `sqlite3_open` call would, I believe, be left as is.
489,497
<p>I'm a Python newbie, so bear with me :)</p> <p>I created a file called test.py with the contents as follows:</p> <pre><code>test.py import sys print sys.platform print 2 ** 100 </code></pre> <p>I then ran <code>import test.py</code> file in the interpreter to follow an example in my book. When I do this, I get th...
[ { "answer_id": 489501, "author": "Evan Fosmark", "author_id": 49701, "author_profile": "https://Stackoverflow.com/users/49701", "pm_score": 3, "selected": false, "text": "<p>You don't specify the extension when importing. Just do:</p>\n\n<pre><code>import test\n</code></pre>\n" }, { ...
2009/01/28
[ "https://Stackoverflow.com/questions/489497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14723/" ]
I'm a Python newbie, so bear with me :) I created a file called test.py with the contents as follows: ``` test.py import sys print sys.platform print 2 ** 100 ``` I then ran `import test.py` file in the interpreter to follow an example in my book. When I do this, I get the output with the import error on the end. ...
Instead of: ``` import test.py ``` simply write: ``` import test ``` This assumes test.py is in the same directory as the file that imports it.
489,504
<p>Is there a built-in way of specifying asserts in Rails that will throw an exception if an invariant is broken during development and testing?</p> <p>Edit: Just to be clear, I'm looking for asserts that can be placed in models or controllers as opposed to asserts that you would use for unit tests.</p>
[ { "answer_id": 489549, "author": "Craig Stuntz", "author_id": 7714, "author_profile": "https://Stackoverflow.com/users/7714", "pm_score": 0, "selected": false, "text": "<p>Beyond <a href=\"http://topfunky.com/clients/rails/ruby_and_rails_assertions.pdf\" rel=\"nofollow noreferrer\">these...
2009/01/28
[ "https://Stackoverflow.com/questions/489504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4883/" ]
Is there a built-in way of specifying asserts in Rails that will throw an exception if an invariant is broken during development and testing? Edit: Just to be clear, I'm looking for asserts that can be placed in models or controllers as opposed to asserts that you would use for unit tests.
There are many assert functions if you are writing tests. But for assertiona in the main code, there aren't any and you can roll your own easily. Add something like this to `environment.rb`: ``` class AssertFailure < Exception end def assert(message = 'assertion failed') unless block_given? and yield raise mes...
489,510
<p>In a Flash game I am developing, there are some settings that are set by an external XML file. When I run the SWF file through the Flash IDE, it loads fine. If I run the same file as a projector (.exe) or the independent SWF file, it does not load the XML file.</p> <p>My (unexpected) fix was to assign an <em>erro...
[ { "answer_id": 489944, "author": "ForYourOwnGood", "author_id": 48728, "author_profile": "https://Stackoverflow.com/users/48728", "pm_score": 0, "selected": false, "text": "<p>The answer to your question is no, actionscript 3.0 does not require an error event handler for XML. It does not...
2009/01/28
[ "https://Stackoverflow.com/questions/489510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54331/" ]
In a Flash game I am developing, there are some settings that are set by an external XML file. When I run the SWF file through the Flash IDE, it loads fine. If I run the same file as a projector (.exe) or the independent SWF file, it does not load the XML file. My (unexpected) fix was to assign an *error* event listen...
On the first addEventListener you're telling it to use weak references (that last argument to the call). Your loadXML function is defined within your getSettings() method. Once you leave the getSettings() scope loadXML goes out of scope. The only thing left referencing loadXML is the event listener, but since you tell ...
489,524
<p>Is it possible to make a user-defined Python function act like a statement? In other words, I'd like to be able to say:</p> <pre><code>myfunc </code></pre> <p>rather than:</p> <pre><code>myfunc() </code></pre> <p>and have it get called anyway -- the way that, say, <code>print</code> would.</p> <p>I can already ...
[ { "answer_id": 489529, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "<p>No, it is not possible.</p>\n\n<p>As you can see from the <a href=\"http://docs.python.org/3.0/reference/simple_stmts.html#...
2009/01/28
[ "https://Stackoverflow.com/questions/489524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91385/" ]
Is it possible to make a user-defined Python function act like a statement? In other words, I'd like to be able to say: ``` myfunc ``` rather than: ``` myfunc() ``` and have it get called anyway -- the way that, say, `print` would. I can already hear you all composing responses about how this is a horrible thing...
No, it is not possible. As you can see from the [Language Reference](http://docs.python.org/3.0/reference/simple_stmts.html#simple-statements), there is no room left for extensions of the list of simple statements in the specification. Moreover, `print` as a statement no longer exists in Python 3.0 and is replaced by...
489,527
<p>Consider an HTML form:</p> <pre><code>&lt;form action="" method="POST" onsubmit="return checkValidArray()"&gt; &lt;input type="text" name="data" onchange="return validate(this);"&gt; &lt;/form&gt; </code></pre> <p>It appears (in both IE 6 and Firefox 3) that when you type some text into the input field and cli...
[ { "answer_id": 489554, "author": "Lauri Lehtinen", "author_id": 59604, "author_profile": "https://Stackoverflow.com/users/59604", "pm_score": 1, "selected": false, "text": "<p>You could use the onblur event in your inputs instead of onchange.</p>\n" }, { "answer_id": 489597, ...
2009/01/28
[ "https://Stackoverflow.com/questions/489527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57229/" ]
Consider an HTML form: ``` <form action="" method="POST" onsubmit="return checkValidArray()"> <input type="text" name="data" onchange="return validate(this);"> </form> ``` It appears (in both IE 6 and Firefox 3) that when you type some text into the input field and click submit that the onchange event fires for ...
Solution (of a sort): It turns out that it is only presence of an alert() - or a confirm() - during the input's onchange event that causes the form's onsubmit event to not fire. The JS thread appears to get blocked by the alert(). The workaround is to not include any alert() or confirm() in the input's onchange cal...
489,538
<p>Is there a good, <em>strict</em> date parser for Java? I have access to Joda-Time but I have yet to see this option. I found the "Is there a good date parser for Java" question, and while this is related it is sort of the opposite. Whereas that question was asking for a lenient, more fuzzy-logic and prone to huma...
[ { "answer_id": 489574, "author": "yawmark", "author_id": 45204, "author_profile": "https://Stackoverflow.com/users/45204", "pm_score": 5, "selected": true, "text": "<p>I don't see that <a href=\"http://joda-time.sourceforge.net/\" rel=\"noreferrer\">Joda</a> recognizes that as a valid da...
2009/01/28
[ "https://Stackoverflow.com/questions/489538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8026/" ]
Is there a good, *strict* date parser for Java? I have access to Joda-Time but I have yet to see this option. I found the "Is there a good date parser for Java" question, and while this is related it is sort of the opposite. Whereas that question was asking for a lenient, more fuzzy-logic and prone to human error parse...
I don't see that [Joda](http://joda-time.sourceforge.net/) recognizes that as a valid date. Example: ``` strict = org.joda.time.format.DateTimeFormat.forPattern("MM/dd/yyyy") try { strict.parseDateTime('40/40/4353') assert false } catch (org.joda.time.IllegalFieldValueException e) { assert 'Cannot parse "4...
489,544
<p>I have the following regex, where I want to match any explicit dot followed by one or more:</p> <pre><code>&lt;b&gt; &lt;i&gt; &lt;u&gt; &lt;/b&gt; &lt;/i&gt; &lt;/u&gt; </code></pre> <p>I would like this Regex to NOT match this pattern if it occurs at the end of the string.</p> <pre><code>string = Regex.Replace(...
[ { "answer_id": 489557, "author": "Evan Fosmark", "author_id": 49701, "author_profile": "https://Stackoverflow.com/users/49701", "pm_score": 4, "selected": false, "text": "<pre><code>\"\\.((&lt;[\\/biu]+&gt;)+)(?!$)\"\n</code></pre>\n\n<p>Use the negative lookahead assertion with the <cod...
2009/01/28
[ "https://Stackoverflow.com/questions/489544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1508/" ]
I have the following regex, where I want to match any explicit dot followed by one or more: ``` <b> <i> <u> </b> </i> </u> ``` I would like this Regex to NOT match this pattern if it occurs at the end of the string. ``` string = Regex.Replace(string, "\.((<[\/biu]+>)+)", ".$1||") ``` Ex: ``` This <b>should match...
``` "\.((<[\/biu]+>)+)(?!$)" ``` Use the negative lookahead assertion with the `$` symbol to check for end of line. (Remember, `$` matches end of line so you want to *not* match that.)
489,567
<p>I suspect this has already been answered somewhere, but I can't find it, so...</p> <p>I need to extract a string from between two tokens in a larger string, in which the second token will probably appear again meaning... (pseudo code...)</p> <pre><code>myString = "A=abc;B=def_3%^123+-;C=123;" ; myB = getInnerStr...
[ { "answer_id": 489576, "author": "Gumbo", "author_id": 53114, "author_profile": "https://Stackoverflow.com/users/53114", "pm_score": 3, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>B=([^;]+);\n</code></pre>\n\n<p>This matches everything between <code>B=</code> and <code>;</...
2009/01/28
[ "https://Stackoverflow.com/questions/489567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59947/" ]
I suspect this has already been answered somewhere, but I can't find it, so... I need to extract a string from between two tokens in a larger string, in which the second token will probably appear again meaning... (pseudo code...) ``` myString = "A=abc;B=def_3%^123+-;C=123;" ; myB = getInnerString(myString, "B=", "...
You're using a greedy pattern by not specifying the `?` in it. Try this: ``` ".+B=(.+?);.+" ```
489,581
<p>How can i get the current time? (in JavaScript)</p> <p>Not the time of your computer like:</p> <pre><code>now = new Date; now_string = addZero(now.getHours()) + ":" + addZero(now.getMinutes()) + ":" + addZero(now.getSeconds()); </code></pre> <p>But the real accurate world time?</p> <p>Do i need to connect to to...
[ { "answer_id": 489632, "author": "Wookai", "author_id": 56761, "author_profile": "https://Stackoverflow.com/users/56761", "pm_score": 2, "selected": false, "text": "<p>You could use <a href=\"http://www.w3schools.com/jsref/jsref_getTimezoneOffset.asp\" rel=\"nofollow noreferrer\">getTime...
2009/01/28
[ "https://Stackoverflow.com/questions/489581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26004/" ]
How can i get the current time? (in JavaScript) Not the time of your computer like: ``` now = new Date; now_string = addZero(now.getHours()) + ":" + addZero(now.getMinutes()) + ":" + addZero(now.getSeconds()); ``` But the real accurate world time? Do i need to connect to to a server (most likely yes, which one? an...
First, to get the accurate GMT time you need a source that you trust. This means some server somewhere. Javascript can generally only make HTTP calls, and only to the server hosting the page in question (same origin policy). Thus that server has to be your source for GMT time. I would configure your webserver to use N...
489,584
<p>Whenever I play Sudoko, I see the finished puzzle as an overspecified version of the original input. Like 8b/10b, Reed-Solomon codes, turbo codes, or low-density parity-check codes. With ECC the computer has to solve a puzzle to produce the correct data, and with Sudoku the human has to solve a puzzle to produce 81 ...
[ { "answer_id": 489632, "author": "Wookai", "author_id": 56761, "author_profile": "https://Stackoverflow.com/users/56761", "pm_score": 2, "selected": false, "text": "<p>You could use <a href=\"http://www.w3schools.com/jsref/jsref_getTimezoneOffset.asp\" rel=\"nofollow noreferrer\">getTime...
2009/01/28
[ "https://Stackoverflow.com/questions/489584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36330/" ]
Whenever I play Sudoko, I see the finished puzzle as an overspecified version of the original input. Like 8b/10b, Reed-Solomon codes, turbo codes, or low-density parity-check codes. With ECC the computer has to solve a puzzle to produce the correct data, and with Sudoku the human has to solve a puzzle to produce 81 dig...
First, to get the accurate GMT time you need a source that you trust. This means some server somewhere. Javascript can generally only make HTTP calls, and only to the server hosting the page in question (same origin policy). Thus that server has to be your source for GMT time. I would configure your webserver to use N...
489,601
<p>I'm doing some string replacement on text I'm getting back from a JSON web service, the string may look like this:</p> <pre><code>"Hello I am a string.\r\nThis is a second line.\r\n\r\nThis is a bigger space" </code></pre> <p>I want to replace all the <code>\r\n</code> with <code>&lt;br /&gt;</code> tags so that t...
[ { "answer_id": 489612, "author": "Ates Goral", "author_id": 23501, "author_profile": "https://Stackoverflow.com/users/23501", "pm_score": 4, "selected": true, "text": "<p>Try a regexp with the global flag set:</p>\n\n<pre><code>var string = result.replace(/\\r\\n/g,'&lt;br /&gt;');\n</co...
2009/01/28
[ "https://Stackoverflow.com/questions/489601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11388/" ]
I'm doing some string replacement on text I'm getting back from a JSON web service, the string may look like this: ``` "Hello I am a string.\r\nThis is a second line.\r\n\r\nThis is a bigger space" ``` I want to replace all the `\r\n` with `<br />` tags so that the HTML is formatted, but when I do: ``` var string =...
Try a regexp with the global flag set: ``` var string = result.replace(/\r\n/g,'<br />'); ```
489,607
<p>Can WinDbg can be used together with the <a href="https://en.wikipedia.org/wiki/Microsoft_Visual_Studio_Express#Visual_C.23_Express" rel="nofollow noreferrer">Visual C# 2008 Express Edition</a>?</p>
[ { "answer_id": 489612, "author": "Ates Goral", "author_id": 23501, "author_profile": "https://Stackoverflow.com/users/23501", "pm_score": 4, "selected": true, "text": "<p>Try a regexp with the global flag set:</p>\n\n<pre><code>var string = result.replace(/\\r\\n/g,'&lt;br /&gt;');\n</co...
2009/01/28
[ "https://Stackoverflow.com/questions/489607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Can WinDbg can be used together with the [Visual C# 2008 Express Edition](https://en.wikipedia.org/wiki/Microsoft_Visual_Studio_Express#Visual_C.23_Express)?
Try a regexp with the global flag set: ``` var string = result.replace(/\r\n/g,'<br />'); ```
489,626
<p>I'm updating some old Managed C++ code with lines like this:</p> <pre><code>instanceOfEventSource-&gt;add_OnMyEvent( new EventSource::MyEventHandlerDelegate(this, MyEventHandlerMethod) ); </code></pre> <p>where</p> <ul> <li><strong>EventSource</strong> is the class that publishes events</li> <li><strong>inst...
[ { "answer_id": 489654, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 4, "selected": true, "text": "<p>The syntax is similar to C#'s, in other words, <code>+=</code> is overloaded to make this possible:</p>\n\n<pre><co...
2009/01/28
[ "https://Stackoverflow.com/questions/489626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4540/" ]
I'm updating some old Managed C++ code with lines like this: ``` instanceOfEventSource->add_OnMyEvent( new EventSource::MyEventHandlerDelegate(this, MyEventHandlerMethod) ); ``` where * **EventSource** is the class that publishes events * **instanceOfEventSource** is an instance of that class * **EventSource::...
The syntax is similar to C#'s, in other words, `+=` is overloaded to make this possible: ``` instanceOfEventSource.MyEvent += gcnew EventSource::MyEventHandlerDelegate(this, &MyClass::MyEventHandlerMethod); ``` Analogously for removal. Unlike C#, however, you may not omit the explicit instantiation of the event ...
489,641
<p>I'm writing a model that handles user input from a text area. Following the advice from <a href="http://web.archive.org/web/20090416200046/http://blog.caboo.se/articles/2008/8/25/sanitize-your-users-html-input" rel="noreferrer">http://blog.caboo.se/articles/2008/8/25/sanitize-your-users-html-input</a>, I'm cleaning...
[ { "answer_id": 489910, "author": "Alfreddd", "author_id": 59168, "author_profile": "https://Stackoverflow.com/users/59168", "pm_score": 8, "selected": true, "text": "<p>Just change the first line as follows :</p>\n\n<pre><code>include ActionView::Helpers\n</code></pre>\n\n<p>that will ma...
2009/01/28
[ "https://Stackoverflow.com/questions/489641", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45553/" ]
I'm writing a model that handles user input from a text area. Following the advice from [http://blog.caboo.se/articles/2008/8/25/sanitize-your-users-html-input](http://web.archive.org/web/20090416200046/http://blog.caboo.se/articles/2008/8/25/sanitize-your-users-html-input), I'm cleaning up the input in the model befor...
Just change the first line as follows : ``` include ActionView::Helpers ``` that will make it works. **UPDATE:** For Rails 3 use: ``` ActionController::Base.helpers.sanitize(str) ``` Credit goes to [lornc's answer](https://stackoverflow.com/a/7593347/59168)
489,682
<p>I am trying to change some DateTime data in a QuickWatch window. I have tried 1/29/2009, etc. but none of them seem to work. It just keeps going back to #12:00:00 AM#.</p>
[ { "answer_id": 489692, "author": "Joey", "author_id": 25962, "author_profile": "https://Stackoverflow.com/users/25962", "pm_score": 3, "selected": true, "text": "<p>Put it inside of pound symbols (#) Like...</p>\n\n<pre><code>#1/29/2009#\n</code></pre>\n" }, { "answer_id": 489741...
2009/01/28
[ "https://Stackoverflow.com/questions/489682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48954/" ]
I am trying to change some DateTime data in a QuickWatch window. I have tried 1/29/2009, etc. but none of them seem to work. It just keeps going back to #12:00:00 AM#.
Put it inside of pound symbols (#) Like... ``` #1/29/2009# ```
489,691
<p>I'm writing the <code>RenderContents()</code> method of my ASP.NET server control. The method uses an <code>HtmlTextWriter</code> object to render the output content. For the control I'm writing, using the <code>HtmlTextWriter</code>'s methods seems like it will require a lot of lines of code to open and close every...
[ { "answer_id": 489711, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 2, "selected": false, "text": "<p>Performance-wise, this will require more string copies to be done. <code>HtmlTextWriter</code> writes directly to the outpu...
2009/01/28
[ "https://Stackoverflow.com/questions/489691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/392/" ]
I'm writing the `RenderContents()` method of my ASP.NET server control. The method uses an `HtmlTextWriter` object to render the output content. For the control I'm writing, using the `HtmlTextWriter`'s methods seems like it will require a lot of lines of code to open and close every tag and add every attribute to the ...
I work on an application where the developers followed the horrible path you're exploring. This harkens back to the days when you had to write your own ISAPI dlls that spit out html code. It is a constant headache to work in. If your code is mostly strings, then something is wrong. Most of the code of this type that I...
489,699
<p>I tried this:</p> <pre><code>test1.pl &gt;output.log 2&gt;&amp;1 </code></pre> <p>but this is the result:</p> <pre><code>Can't dup STDOUT: Permission denied at C:/Perl/lib/Test/Builder.pm line 1376. Compilation failed in require at C:/Perl/lib/Test/Builder/Module.pm line 3. BEGIN failed--compilation aborted at C...
[ { "answer_id": 489779, "author": "Quassnoi", "author_id": 55159, "author_profile": "https://Stackoverflow.com/users/55159", "pm_score": 4, "selected": true, "text": "<p>There is general problem with redirection in <code>Perl</code> for <code>Windows</code>.</p>\n\n<p>The line that fails ...
2009/01/28
[ "https://Stackoverflow.com/questions/489699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28991/" ]
I tried this: ``` test1.pl >output.log 2>&1 ``` but this is the result: ``` Can't dup STDOUT: Permission denied at C:/Perl/lib/Test/Builder.pm line 1376. Compilation failed in require at C:/Perl/lib/Test/Builder/Module.pm line 3. BEGIN failed--compilation aborted at C:/Perl/lib/Test/Builder/Module.pm line 3. Compi...
There is general problem with redirection in `Perl` for `Windows`. The line that fails in `Test::More` package says: ``` open TESTOUT, ">&STDOUT" or die $!; ``` This fails when you invoke command as `test.pl > outlog.log`, as the file that you are redirecting `STDOUT` to is locked by `cmd.exe`, not by `perl.exe`. Y...
489,715
<p>I'm not very experienced in this area - so I've got a few questions. Firstly, do all .Net created DLLs have their own GUID? If not, my question is how do I get one and associate it with the DLL.</p> <p>Then the question is, how do I get the GUID of that dll - ie. given a DLL path (c:\some\path\to\a\file.dll) how do...
[ { "answer_id": 489737, "author": "Sebastian", "author_id": 56440, "author_profile": "https://Stackoverflow.com/users/56440", "pm_score": 0, "selected": false, "text": "<p>As a Visual Studio user have a look at the AssemblyInfo.cs where the assemblies GUID is defined\n<code>[assembly: Gui...
2009/01/28
[ "https://Stackoverflow.com/questions/489715", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1912/" ]
I'm not very experienced in this area - so I've got a few questions. Firstly, do all .Net created DLLs have their own GUID? If not, my question is how do I get one and associate it with the DLL. Then the question is, how do I get the GUID of that dll - ie. given a DLL path (c:\some\path\to\a\file.dll) how do I determi...
To answer the second question (Guid -> assembly) this is simple if the dll is already loaded and you just want to find which one had a guid (if any) you can simply do ``` using System; using System.Reflection; using System.Runtime.InteropServices; static Assembly FindAssemblyForGuid(Guid match) { foreach (var a ...
489,720
<p>While I like to think of myself as a reasonably competent Python coder, one aspect of the language I've never been able to grok is decorators.</p> <p>I know what they are (superficially), I've read tutorials, examples, questions on Stack Overflow, and I understand the syntax, can write my own, occasionally use @cla...
[ { "answer_id": 489735, "author": "DzinX", "author_id": 18745, "author_profile": "https://Stackoverflow.com/users/18745", "pm_score": 4, "selected": false, "text": "<p>I use them mainly for debugging (wrapper around a function that prints its arguments and result) and verification (e.g. t...
2009/01/28
[ "https://Stackoverflow.com/questions/489720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7856/" ]
While I like to think of myself as a reasonably competent Python coder, one aspect of the language I've never been able to grok is decorators. I know what they are (superficially), I've read tutorials, examples, questions on Stack Overflow, and I understand the syntax, can write my own, occasionally use @classmethod a...
I've used them for synchronization. ``` import functools def synchronized(lock): """ Synchronization decorator """ def wrap(f): @functools.wraps(f) def newFunction(*args, **kw): lock.acquire() try: return f(*args, **kw) finally: ...
489,722
<p><a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" rel="noreferrer">http://bassistance.de/jquery-plugins/jquery-plugin-validation/</a> looks to be the best jquery validation plugin out there. I can't seem to get it working in the jQuery UI dialog though.</p> <p>This code works outside of the d...
[ { "answer_id": 489767, "author": "Jared", "author_id": 59958, "author_profile": "https://Stackoverflow.com/users/59958", "pm_score": 0, "selected": false, "text": "<p>Have you tried wrapping the form around your div instead (according to the W3C spec form tags are not allowed to be insid...
2009/01/28
[ "https://Stackoverflow.com/questions/489722", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59143/" ]
<http://bassistance.de/jquery-plugins/jquery-plugin-validation/> looks to be the best jquery validation plugin out there. I can't seem to get it working in the jQuery UI dialog though. This code works outside of the dialog DIV: ``` <script type="text/javascript"> $(document).ready(function() { $("form").validate...
In case someone else comes across this, the jQuery-UI dialog does not append to the form, it appends just before `</body>`, so the elements to validate are outside the `<form></form>` section: To resolve this, just direct the dialog to move itself inside the form when you create it, like this: ``` $("#mydiv").dialog(...
489,748
<p>I know it's not supported, and I know it's not even a terribly good idea. But, I want to have a WCF client inside a SQL Table Valued Function.</p> <p>I've (seemingly) registered the correct assemblies, but when running my client - I get a WCF error:</p> <pre> Msg 6522, Level 16, State 1, Line 1 System.ServiceModel...
[ { "answer_id": 489850, "author": "David Morton", "author_id": 45916, "author_profile": "https://Stackoverflow.com/users/45916", "pm_score": 0, "selected": false, "text": "<p>At least in SQL Server 2005, there were only a handful of supported assemblies for SQL CLR. I don't believe WCF w...
2009/01/28
[ "https://Stackoverflow.com/questions/489748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2199/" ]
I know it's not supported, and I know it's not even a terribly good idea. But, I want to have a WCF client inside a SQL Table Valued Function. I've (seemingly) registered the correct assemblies, but when running my client - I get a WCF error: ``` Msg 6522, Level 16, State 1, Line 1 System.ServiceModel.CommunicationO...
This article might help you find out what the true underlying exception is and to see how fatal it is: > > [http://jdconley.com/blog/archive/2007/08/22/wcfclientwrapper.aspx](http://web.archive.org/web/20101230161606/http://www.jdconley.com/blog/archive/2007/08/22/wcfclientwrapper.aspx) (archive.org copy) > > > A...
489,785
<p>I'd just like to play a little bit with groovy</p> <p>I was thinking about developing my own-tiny web framework, something very simple and manageable...</p> <p>So i'd like tou use GSP pages whtout having to install the whole grails stuff, with all its dependencies and behind-the-scenes frameworks...</p> <p>can anyon...
[ { "answer_id": 489820, "author": "Hates_", "author_id": 3410, "author_profile": "https://Stackoverflow.com/users/3410", "pm_score": 2, "selected": false, "text": "<p>Standalone GSP is on the current Grails roadmap. In the mean time see the GSP module project page: <a href=\"https://gsp.d...
2009/01/28
[ "https://Stackoverflow.com/questions/489785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47633/" ]
I'd just like to play a little bit with groovy I was thinking about developing my own-tiny web framework, something very simple and manageable... So i'd like tou use GSP pages whtout having to install the whole grails stuff, with all its dependencies and behind-the-scenes frameworks... can anyone provide me detailed...
Well, it seems like it wasn't so hard in deed as I expected just had to copy groovy-all-1.5.7.jar from C:\java\groovy-1.5.7\embeddable to C:\java\Tomcat 6.0\lib and add the following lines to C:\java\Tomcat 6.0\conf\web.xml ``` <!-- Groovy mapping - sas 2009-01-29 --> <servlet> <servlet-name>Groovy</servlet...
489,791
<p>Well, as the title says, how can I set an image or anything else as the mouse cursor. I know you can use the built in ones that are part of the Cursors class, but I was wondering if there's a way to use your own image (preferably without P/Invoke, but either way is fine.)</p> <p>EDIT: I guess I didn't explain what ...
[ { "answer_id": 489813, "author": "Jared", "author_id": 59958, "author_profile": "https://Stackoverflow.com/users/59958", "pm_score": 2, "selected": false, "text": "<p>First add the custom cursor to your project then it's pretty simple:</p>\n\n<pre><code>Cursor myCursor = new Cursor(\"cus...
2009/01/28
[ "https://Stackoverflow.com/questions/489791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15861/" ]
Well, as the title says, how can I set an image or anything else as the mouse cursor. I know you can use the built in ones that are part of the Cursors class, but I was wondering if there's a way to use your own image (preferably without P/Invoke, but either way is fine.) EDIT: I guess I didn't explain what I wanted c...
At the simplest, you just use: ``` form.Cursor = new Cursor(path); ``` But there are overloads to load from other sources (an unmanaged pointer, a raw stream, or a resx).
489,798
<p>When I ask ActiveScaffold to show me a very long list (for example the list of products sold), it runs the database query to get the first page of data and it displays it. If the list has a few relations, this query might take some time to execute (over a second). Most of the time, I'm not interested in this "unfi...
[ { "answer_id": 493154, "author": "Otto", "author_id": 9594, "author_profile": "https://Stackoverflow.com/users/9594", "pm_score": 0, "selected": false, "text": "<p>You probably need to override the <code>#index</code> action and provide your own template. It doesn't appear there's any w...
2009/01/28
[ "https://Stackoverflow.com/questions/489798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38626/" ]
When I ask ActiveScaffold to show me a very long list (for example the list of products sold), it runs the database query to get the first page of data and it displays it. If the list has a few relations, this query might take some time to execute (over a second). Most of the time, I'm not interested in this "unfiltere...
I found a solution by defining the *conditions\_for\_collection* method in the controller. It is kind of a hack, but it's simple (3 lines) and it works: ``` def conditions_for_collection params[:action]=="update_table" ? "" : "1=2" end ``` This is how it goes: when you ask for the list, the controller's *list* met...
489,805
<p>Does anyone know how much memory is taken up when you create a reference type variable?</p> <p>String s = "123";</p> <p>How much memory would 's' take up as a reference, not the data pointing to it?</p>
[ { "answer_id": 489830, "author": "mqp", "author_id": 55943, "author_profile": "https://Stackoverflow.com/users/55943", "pm_score": 2, "selected": false, "text": "<p>Depending on whether you're on a 32- or 64-bit machine, it'll be either a 32- or 64-bit pointer.</p>\n" }, { "answe...
2009/01/28
[ "https://Stackoverflow.com/questions/489805", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Does anyone know how much memory is taken up when you create a reference type variable? String s = "123"; How much memory would 's' take up as a reference, not the data pointing to it?
This is broken down in the following fashion: ``` String s = "123"; ``` The variable s: this will consume the native pointer size on the current architecture (which is considered 32bit if the OS is 32bit or the process is executing under WoW64), so 32 bits or 64 bits accordingly. In this case s is either on the stac...
489,808
<p>I'm building a site that requires an audio file to be played with an equalizer. I don't know alot about AS3 yet so this might be a simple question.</p> <p>I've found an example that I would like to use <a href="http://www.everydayflash.com/blog/index.php/2008/03/26/classic-sound-equalizer-in-flashas3/" rel="nofoll...
[ { "answer_id": 489841, "author": "Chad Birch", "author_id": 41665, "author_profile": "https://Stackoverflow.com/users/41665", "pm_score": 3, "selected": true, "text": "<p>Right below the lines:</p>\n\n<pre><code>e.x = 100;\ne.y = 100;\n</code></pre>\n\n<p>Try adding:</p>\n\n<pre><code>e....
2009/01/28
[ "https://Stackoverflow.com/questions/489808", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56692/" ]
I'm building a site that requires an audio file to be played with an equalizer. I don't know alot about AS3 yet so this might be a simple question. I've found an example that I would like to use [Demonstrated here](http://www.everydayflash.com/blog/index.php/2008/03/26/classic-sound-equalizer-in-flashas3/) and the [so...
Right below the lines: ``` e.x = 100; e.y = 100; ``` Try adding: ``` e.rotation = 90; ``` I believe that should work, but you may run into some issues with the location of the pivot point (whether you want it rotated 90 degrees around the center, or around the top left).
489,819
<p>When creating a unit test for a class that uses the <a href="http://msdn.microsoft.com/en-us/library/system.web.httpcontext.aspx" rel="nofollow noreferrer"><code>HttpContext.Current.Cache</code> class</a>, I get an error when using NUnit. The functionality is basic - check if an item is in the cache, and if not, cr...
[ { "answer_id": 490277, "author": "Antony Perkov", "author_id": 60008, "author_profile": "https://Stackoverflow.com/users/60008", "pm_score": 2, "selected": false, "text": "<p>General consensus seems to be that driving anything HttpContext related from within a unit test is a total nightm...
2009/01/28
[ "https://Stackoverflow.com/questions/489819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4555/" ]
When creating a unit test for a class that uses the [`HttpContext.Current.Cache` class](http://msdn.microsoft.com/en-us/library/system.web.httpcontext.aspx), I get an error when using NUnit. The functionality is basic - check if an item is in the cache, and if not, create it and put it in: ``` if (HttpContext.Current....
The way to do this is to avoid direct use of the HttpContext or other similar classes, and substitute them with mocks. After all, you're not trying to test that the HttpContext functions properly (that's microsoft's job), you're just trying to test that the methods got called when they should have. Steps (In case you ...
489,853
<p>I'm making an interface to a DLL library, so i can use it with Java. I need my native function to modify the value of a jlong parameter. Like the parameter was passed by reference. My Java method must have the exact parameters as the native function MPUSBWrite shown down here.</p> <p>Example of actual not working c...
[ { "answer_id": 489866, "author": "kdgregory", "author_id": 42126, "author_profile": "https://Stackoverflow.com/users/42126", "pm_score": 2, "selected": true, "text": "<p>No.</p>\n\n<p>Your best option, if you truly need to do this, is to define your fourth parameter as a long[], and have...
2009/01/28
[ "https://Stackoverflow.com/questions/489853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13116/" ]
I'm making an interface to a DLL library, so i can use it with Java. I need my native function to modify the value of a jlong parameter. Like the parameter was passed by reference. My Java method must have the exact parameters as the native function MPUSBWrite shown down here. Example of actual not working code: The M...
No. Your best option, if you truly need to do this, is to define your fourth parameter as a long[], and have your JNI code update the array element. Actually, your best option would be to consider why you can't return the long from the method.