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
452,825
<p>ok, people here is my amazing antigravity library. I'm trying to define it as an object literal, which, uh, i read all the cool kids are doing in order to to encapsulate their libraries. Basic tests indicate it's working properly, but I cannot seem to see document.body from inside my object.</p> <p>what should ha...
[ { "answer_id": 452832, "author": "Jordan Liggitt", "author_id": 54696, "author_profile": "https://Stackoverflow.com/users/54696", "pm_score": 2, "selected": false, "text": "<p>You probably want to do</p>\n\n<pre><code>document.onload=antigrav.activate;\n</code></pre>\n\n<p>With parenthes...
2009/01/17
[ "https://Stackoverflow.com/questions/452825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
ok, people here is my amazing antigravity library. I'm trying to define it as an object literal, which, uh, i read all the cool kids are doing in order to to encapsulate their libraries. Basic tests indicate it's working properly, but I cannot seem to see document.body from inside my object. what should happen is when...
You probably want to do ``` document.onload=antigrav.activate; ``` With parenthesis, you are setting `document.onload` to the *result* of running antigrav.activate(), instead of indicating you want antigrav.activate to run as the document.onload handler. Therefore, activate() was getting run in order to make the ass...
452,827
<p>If the locks make sure only one thread accesses the locked data at a time, then what controls access to the locking functions?</p> <p>I thought that <a href="http://www.boost.org/doc/libs/1_37_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_types.mutex" rel="nofollow noreferrer">boost::mutex::sc...
[ { "answer_id": 452836, "author": "Sydius", "author_id": 43496, "author_profile": "https://Stackoverflow.com/users/43496", "pm_score": 3, "selected": false, "text": "<p>You only need to have exclusive access to shared data. Unless they're static or on the heap, local variables inside fun...
2009/01/17
[ "https://Stackoverflow.com/questions/452827", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36157/" ]
If the locks make sure only one thread accesses the locked data at a time, then what controls access to the locking functions? I thought that [boost::mutex::scoped\_lock](http://www.boost.org/doc/libs/1_37_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_types.mutex) should be at the beginning of ea...
You're right, when implementing locks you need some way of guaranteeing that two processes don't get the lock at the same time. To do this, you need to use an atomic instruction - one that's guaranteed to complete without interruption. One such instruction is [test-and-set](http://en.wikipedia.org/wiki/Test-and-set), a...
452,828
<p>I wanted to see if someone could shed some light on this for me. When I was using the Checkstyle plugin for Eclipse, I got a warning message on the following statement (not exactly this, but this form):</p> <pre><code>if (x != y) { do(); } </code></pre> <p>Why is this a problem?</p> <p><strong>Edit</strong>: ...
[ { "answer_id": 452834, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>See the Checkstyle's check description + rationale: <a href=\"http://checkstyle.sourceforge.net/checks.html\" rel=\"nofoll...
2009/01/17
[ "https://Stackoverflow.com/questions/452828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I wanted to see if someone could shed some light on this for me. When I was using the Checkstyle plugin for Eclipse, I got a warning message on the following statement (not exactly this, but this form): ``` if (x != y) { do(); } ``` Why is this a problem? **Edit**: I apologize, I should have been more clear with...
The default setting for the [LeftCurly](http://checkstyle.sourceforge.net/config_blocks.html#LeftCurly) checker is "eol". This means that you are enforcing the rule that if statements (and similar blocks) should look like this: ``` if (x != y) { do(); } ``` If you prefer the style you showed in the question, use...
452,837
<p>My HTML has</p> <pre><code>cell = document.createElement("td"); cell.appendChild(document.createTextNode(contents)); cell.setAttribute('width', '100'); </code></pre> <p>The following syntax is not working.</p> <pre><code>cell.appendChild(document.createElement('br')).appendChild(document.createTextNode("Another t...
[ { "answer_id": 452855, "author": "Prestaul", "author_id": 5628, "author_profile": "https://Stackoverflow.com/users/5628", "pm_score": 3, "selected": true, "text": "<p>It looks like you are trying to chain your method calls... Sorry! No chaining for native elements. If you want chainin...
2009/01/17
[ "https://Stackoverflow.com/questions/452837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44984/" ]
My HTML has ``` cell = document.createElement("td"); cell.appendChild(document.createTextNode(contents)); cell.setAttribute('width', '100'); ``` The following syntax is not working. ``` cell.appendChild(document.createElement('br')).appendChild(document.createTextNode("Another text")); ``` And after the contents ...
It looks like you are trying to chain your method calls... Sorry! No chaining for native elements. If you want chaining then try [jQuery](http://jquery.com), otherwise try: ``` var cell = document.createElement("td"); cell.appendChild(document.createTextNode(contents)); cell.setAttribute('width', '100'); // To make s...
452,848
<p>I have dumped Zend Framework files in </p> <p><strong>"home/hotbuzz/public_html/include/zend/"</strong></p> <p>My hosting : linux </p> <p>I want to load it in my script. Whenever I load I get this error.</p> <p>Some info: I asked about my Zend, to hosting guys they said its located in "usr/local/zend"</p> <p>B...
[ { "answer_id": 452967, "author": "stunti", "author_id": 54949, "author_profile": "https://Stackoverflow.com/users/54949", "pm_score": 4, "selected": false, "text": "<p>As I said in your previous question. Do not use ';' but use PATH_SEPARATOR.\nThis is a PHP constant that represent the ...
2009/01/17
[ "https://Stackoverflow.com/questions/452848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have dumped Zend Framework files in **"home/hotbuzz/public\_html/include/zend/"** My hosting : linux I want to load it in my script. Whenever I load I get this error. Some info: I asked about my Zend, to hosting guys they said its located in "usr/local/zend" But I want to use this home/hotbuzz/public\_html/inc...
As I said in your previous question. Do not use ';' but use PATH\_SEPARATOR. This is a PHP constant that represent the right separator for your system (semi-colon on windows and colon on linux) ``` set_include_path(dirname(__FILE__).PATH_SEPARATOR.get_include_path()); ```
452,857
<p>Assuming rails app has the following models song, play, radio_station: song has_many plays play has_many radio_stations radio_station has attribute "call_sign"</p> <p>I want to create one find for Song that would return for me the all songs where the last play (of the song) was played by a radio station of "WKRP"<...
[ { "answer_id": 452925, "author": "Jaryl", "author_id": 6291, "author_profile": "https://Stackoverflow.com/users/6291", "pm_score": 0, "selected": false, "text": "<p>You should probably look at named scopes.</p>\n\n<pre><code>class Song\n named_scope :last_played_by, lambda {|call_sign| ...
2009/01/17
[ "https://Stackoverflow.com/questions/452857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56082/" ]
Assuming rails app has the following models song, play, radio\_station: song has\_many plays play has\_many radio\_stations radio\_station has attribute "call\_sign" I want to create one find for Song that would return for me the all songs where the last play (of the song) was played by a radio station of "WKRP" I c...
This probably can't be done by ActiveRecord finders. You have to roll some custom SQL with a subquery (MySQL 5 required): ``` SELECT s.* FROM songs s LEFT JOIN plays p WHERE p.radio_station_id = [id of WKRP] AND p.created_at = (SELECT MAX(created_at) FROM plays p2 WHERE p2.song_id = s....
452,859
<p>I have multiple set of data to insert at once, say 4 rows. My table has three columns: <code>Person</code>, <code>Id</code> and <code>Office</code>.</p> <pre><code>INSERT INTO MyTable VALUES ("John", 123, "Lloyds Office"); INSERT INTO MyTable VALUES ("Jane", 124, "Lloyds Office"); INSERT INTO MyTable VALUES ("Billy...
[ { "answer_id": 452882, "author": "too much php", "author_id": 28835, "author_profile": "https://Stackoverflow.com/users/28835", "pm_score": 10, "selected": false, "text": "<p>If you are inserting into a single table, you can write your query like this (maybe only in MySQL):</p>\n\n<pre><...
2009/01/17
[ "https://Stackoverflow.com/questions/452859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have multiple set of data to insert at once, say 4 rows. My table has three columns: `Person`, `Id` and `Office`. ``` INSERT INTO MyTable VALUES ("John", 123, "Lloyds Office"); INSERT INTO MyTable VALUES ("Jane", 124, "Lloyds Office"); INSERT INTO MyTable VALUES ("Billy", 125, "London Office"); INSERT INTO MyTable V...
In SQL Server 2008 you can insert multiple rows using a single SQL INSERT statement. ``` INSERT INTO MyTable ( Column1, Column2 ) VALUES ( Value1, Value2 ), ( Value1, Value2 ) ``` For reference to this have a look at MOC Course 2778A - Writing SQL Queries in SQL Server 2008. For example: ``` INSERT INTO MyTable ...
452,895
<p>How does one go about attaching a bunch of code to an <code>onkeydown</code> event, but keep entering text into a <code>textarea</code> fast and crisp? Anything more than a couple of IF statements seems to slow it down quite considerably.</p> <p><strong>EDIT</strong>: I should add (can't believe I forgot!) that thi...
[ { "answer_id": 452919, "author": "David", "author_id": 49460, "author_profile": "https://Stackoverflow.com/users/49460", "pm_score": 0, "selected": false, "text": "<p>Well, one way to go would be not using onkeydown, but using a timer instead. You can set an interval running a function ...
2009/01/17
[ "https://Stackoverflow.com/questions/452895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56121/" ]
How does one go about attaching a bunch of code to an `onkeydown` event, but keep entering text into a `textarea` fast and crisp? Anything more than a couple of IF statements seems to slow it down quite considerably. **EDIT**: I should add (can't believe I forgot!) that this doesn't affect desktop browsers. It's mainl...
Considering your edit regarding this being focused on iPhone access... The iPhone really just doesn't have that much power to it. You'll be better off just using **`onchange`** or **`onblur`** instead of **`onkeydown`**. --- --- An alternative to Dave's answer is waiting for the user to pause (e.g. for 5 seconds): ...
452,902
<p>I need to process a large file, around 400K lines and 200 M. But sometimes I have to process from bottom up. How can I use iterator (yield return) here? Basically I don't like to load everything in memory. I know it is more efficient to use iterator in .NET.</p>
[ { "answer_id": 452943, "author": "Igor Zelaya", "author_id": 22769, "author_profile": "https://Stackoverflow.com/users/22769", "pm_score": 2, "selected": false, "text": "<p>To create a file iterator you can do this:</p>\n\n<p>EDIT:</p>\n\n<p>This is my fixed version of a fixed-width reve...
2009/01/17
[ "https://Stackoverflow.com/questions/452902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31689/" ]
I need to process a large file, around 400K lines and 200 M. But sometimes I have to process from bottom up. How can I use iterator (yield return) here? Basically I don't like to load everything in memory. I know it is more efficient to use iterator in .NET.
Reading text files backwards is really tricky unless you're using a fixed-size encoding (e.g. ASCII). When you've got variable-size encoding (such as UTF-8) you will keep having to check whether you're in the middle of a character or not when you fetch data. There's nothing built into the framework, and I suspect you'...
452,969
<p>I have the need to take a string argument and create an object of the class named in that string in Python. In Java, I would use <code>Class.forName().newInstance()</code>. Is there an equivalent in Python?</p> <hr> <p>Thanks for the responses. To answer those who want to know what I'm doing: I want to use a co...
[ { "answer_id": 452971, "author": "Serafina Brocious", "author_id": 4977, "author_profile": "https://Stackoverflow.com/users/4977", "pm_score": 5, "selected": false, "text": "<p>Assuming the class is in your scope:</p>\n\n<pre><code>globals()['classname'](args, to, constructor)\n</code></...
2009/01/17
[ "https://Stackoverflow.com/questions/452969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9133/" ]
I have the need to take a string argument and create an object of the class named in that string in Python. In Java, I would use `Class.forName().newInstance()`. Is there an equivalent in Python? --- Thanks for the responses. To answer those who want to know what I'm doing: I want to use a command line argument as th...
Reflection in python is a lot easier and far more flexible than it is in Java. I recommend reading this [tutorial](https://web.archive.org/web/20160304105303/http://www.diveintopython.net/power_of_introspection/index.html) (on archive.org) There's no direct function (that I know of) which takes a fully qualified clas...
452,972
<p>I have a PHP file that is going to write a two-dimensional array in JavaScript:</p> <pre><code>&lt;?php print "&lt;script language='javascript'&gt;"; print " extra[0][0] = new Array(1,'Bob',12);"; print " extra[0][1] = new Array(2,'Alice',18);"; .. // Need to assign the extra[1][0], extra[1][1...
[ { "answer_id": 452980, "author": "wvanbergen", "author_id": 42431, "author_profile": "https://Stackoverflow.com/users/42431", "pm_score": 4, "selected": false, "text": "<p><code>json_encode</code> is your friend: <a href=\"http://nl3.php.net/json_encode\" rel=\"noreferrer\">json_encode i...
2009/01/17
[ "https://Stackoverflow.com/questions/452972", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44984/" ]
I have a PHP file that is going to write a two-dimensional array in JavaScript: ``` <?php print "<script language='javascript'>"; print " extra[0][0] = new Array(1,'Bob',12);"; print " extra[0][1] = new Array(2,'Alice',18);"; .. // Need to assign the extra[1][0], extra[1][1] and so on. print ...
`json_encode` is your friend: [json\_encode in the PHP manual](http://nl3.php.net/json_encode) ``` <script type="text/javascript"> var jsArray = <?= json_encode($my_array) ?>; </script> ```
452,988
<p>I have a fairly simple UserControl that I have made (pardon my Xaml I am just learning WPF) and I want to slide the off the screen. To do so I am animating a translate transform (I also tried making the Panel the child of a canvas and animating the X position with the same results), but the panel moves very jerkily...
[ { "answer_id": 453002, "author": "Dmitri Nesteruk", "author_id": 9476, "author_profile": "https://Stackoverflow.com/users/9476", "pm_score": 2, "selected": false, "text": "<p>If you work with WPF animations long enough, you'll figure out that large-area controls do, in fact, move in a wh...
2009/01/17
[ "https://Stackoverflow.com/questions/452988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3798/" ]
I have a fairly simple UserControl that I have made (pardon my Xaml I am just learning WPF) and I want to slide the off the screen. To do so I am animating a translate transform (I also tried making the Panel the child of a canvas and animating the X position with the same results), but the panel moves very jerkily, ev...
It looks like the best solution so far, is to use a Visual Brush and move two static images when sliding in and out the panels. Something similar to this is described in this blog post: [Using animated navigation pages in a WPF application](https://web.archive.org/web/20091231041128/http://www.japf.fr/2008/07/8/commen...
453,010
<p>I have a td that I want to inject with a server image control (asp.net) using innerHTML = "". The webcontrol's toString is giving the type.</p> <p>Is there a way to extract the generated from the server control? Or, is there a different solution...?</p> <p>Thanks</p>
[ { "answer_id": 453020, "author": "Al W", "author_id": 50011, "author_profile": "https://Stackoverflow.com/users/50011", "pm_score": 1, "selected": false, "text": "<pre><code>StringBuilder sb = new StringBuilder();\nStringWriter writer = new StringWriter(sb);\nimg.RenderControl(new HtmlTe...
2009/01/17
[ "https://Stackoverflow.com/questions/453010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a td that I want to inject with a server image control (asp.net) using innerHTML = "". The webcontrol's toString is giving the type. Is there a way to extract the generated from the server control? Or, is there a different solution...? Thanks
``` StringBuilder sb = new StringBuilder(); StringWriter writer = new StringWriter(sb); img.RenderControl(new HtmlTextWriter(writer)); td.InnerHtml = sb.ToString(); ``` or the more obvious ``` td.Controls.Add(img); ```
453,018
<p>I use huge data files, sometimes I only need to know the number of lines in these files, usually I open them up and read them line by line until I reach the end of the file</p> <p>I was wondering if there is a smarter way to do that</p>
[ { "answer_id": 453025, "author": "Peter Hilton", "author_id": 2670, "author_profile": "https://Stackoverflow.com/users/2670", "pm_score": 0, "selected": false, "text": "<p>On Unix-based systems, use the <code>wc</code> command on the command-line.</p>\n" }, { "answer_id": 453033,...
2009/01/17
[ "https://Stackoverflow.com/questions/453018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55362/" ]
I use huge data files, sometimes I only need to know the number of lines in these files, usually I open them up and read them line by line until I reach the end of the file I was wondering if there is a smarter way to do that
This is the fastest version I have found so far, about 6 times faster than readLines. On a 150MB log file this takes 0.35 seconds, versus 2.40 seconds when using readLines(). Just for fun, linux' wc -l command takes 0.15 seconds. ``` public static int countLinesOld(String filename) throws IOException { InputStream...
453,023
<p>Given an hypothetical utility class that is used only in program setup:</p> <pre><code>class MyUtils { private static MyObject myObject = new MyObject(); /*package*/static boolean doStuff(Params... params) { // do stuff with myObject and params... } } </code></pre> <p>will myObject be garbage colle...
[ { "answer_id": 453035, "author": "Tom", "author_id": 8969, "author_profile": "https://Stackoverflow.com/users/8969", "pm_score": 3, "selected": false, "text": "<p>I think <a href=\"https://stackoverflow.com/questions/405364/whats-up-with-static-memory-in-java\">this</a> answers your ques...
2009/01/17
[ "https://Stackoverflow.com/questions/453023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4931/" ]
Given an hypothetical utility class that is used only in program setup: ``` class MyUtils { private static MyObject myObject = new MyObject(); /*package*/static boolean doStuff(Params... params) { // do stuff with myObject and params... } } ``` will myObject be garbage collected when it is no longer ...
Static variables cannot be elected for garbage collection while the class is loaded. They can be collected when the respective class loader (that was responsible for loading this class) is itself collected for garbage. Check out the [JLS Section 12.7 Unloading of Classes and Interfaces](https://docs.oracle.com/javase/...
453,036
<p>How would you go about supporting external composable parts in an ASP.NET MVC view?</p> <p>What do I mean by this? Think either "login box on every page" or "iGoogle". It's stuff that needs to be in certain places that is external to each controller/view.</p> <p>One approach at this would be adding components in t...
[ { "answer_id": 453117, "author": "Matt Kocaj", "author_id": 56145, "author_profile": "https://Stackoverflow.com/users/56145", "pm_score": 1, "selected": false, "text": "<p>without understanding the question properly, i'd suggest a masterpage approach. ie. have the masterpage render the c...
2009/01/17
[ "https://Stackoverflow.com/questions/453036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16526/" ]
How would you go about supporting external composable parts in an ASP.NET MVC view? What do I mean by this? Think either "login box on every page" or "iGoogle". It's stuff that needs to be in certain places that is external to each controller/view. One approach at this would be adding components in the view like so: ...
There is two ways you can do this: One: Make a BaseController, that allways gets the data needed for these components, set the ViewData["loginbox"] = loginBoxData, and then you can pass it along like so. ``` <% foreach (var component in GetComponents()) {%> <%= Html.RenderPartial(component.ViewName, ViewData[...
453,045
<p>I have made a new windows service which works fine using barebone code (just the basic framework for a service), however, when i link it against my dlls, lib file to use the functionality in the dll it crashes on start up with a 0xc0000034 error.</p> <p>Is there a special place to put the dlls for a service or a sp...
[ { "answer_id": 453117, "author": "Matt Kocaj", "author_id": 56145, "author_profile": "https://Stackoverflow.com/users/56145", "pm_score": 1, "selected": false, "text": "<p>without understanding the question properly, i'd suggest a masterpage approach. ie. have the masterpage render the c...
2009/01/17
[ "https://Stackoverflow.com/questions/453045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23339/" ]
I have made a new windows service which works fine using barebone code (just the basic framework for a service), however, when i link it against my dlls, lib file to use the functionality in the dll it crashes on start up with a 0xc0000034 error. Is there a special place to put the dlls for a service or a special way ...
There is two ways you can do this: One: Make a BaseController, that allways gets the data needed for these components, set the ViewData["loginbox"] = loginBoxData, and then you can pass it along like so. ``` <% foreach (var component in GetComponents()) {%> <%= Html.RenderPartial(component.ViewName, ViewData[...
453,057
<p>I have a small problem with the way the commands "backward-word" and "backward-kill-word" work. When I hit "backward-kill-word" on a line that is only white-spaces (for example, the first char of an indented line), the command will kill all the white-space, as well as the last word of the previous line.</p> <p>This...
[ { "answer_id": 453091, "author": "David Hanak", "author_id": 42136, "author_profile": "https://Stackoverflow.com/users/42136", "pm_score": 1, "selected": false, "text": "<p>In this case, you might want to try M-\\ (delete-horizontal-space), which does what you want for the first keypress...
2009/01/17
[ "https://Stackoverflow.com/questions/453057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a small problem with the way the commands "backward-word" and "backward-kill-word" work. When I hit "backward-kill-word" on a line that is only white-spaces (for example, the first char of an indented line), the command will kill all the white-space, as well as the last word of the previous line. This behavior ...
How about this: ``` (defun my-backward-kill-word () "Kill words backward my way." (interactive) (if (bolp) (backward-delete-char 1) (if (string-match "^\\s-+$" (buffer-substring (point-at-bol) (point))) (kill-region (point-at-bol) (point)) (backward-kill-word 1)))) ```
453,069
<h1>Update</h1> <p>see <a href="http://labs.trolltech.com/blogs/2009/09/15/using-blur-behind-on-windows/" rel="nofollow noreferrer">Using Blur Behind on Windows</a> for an example of using Qt and <a href="http://msdn.microsoft.com/en-us/library/aa969540(VS.85).aspx" rel="nofollow noreferrer">DWM</a>.<a href="http://la...
[ { "answer_id": 484899, "author": "Viesturs", "author_id": 1660, "author_profile": "https://Stackoverflow.com/users/1660", "pm_score": 4, "selected": true, "text": "<p>Just use:</p>\n\n<pre><code>QPainter p\n\np.setCompositionMode(QPainter::CompositionMode_DestinationIn);\np.fillRect(boun...
2009/01/17
[ "https://Stackoverflow.com/questions/453069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13543/" ]
Update ====== see [Using Blur Behind on Windows](http://labs.trolltech.com/blogs/2009/09/15/using-blur-behind-on-windows/) for an example of using Qt and [DWM](http://msdn.microsoft.com/en-us/library/aa969540(VS.85).aspx).[alt text http://labs.trolltech.com/blogs/wp-content/uploads/2009/09/blurbehind2.png](http://labs...
Just use: ``` QPainter p p.setCompositionMode(QPainter::CompositionMode_DestinationIn); p.fillRect(boundsRect, QColor(0, 0, 0, 0)); ``` This discards the old contents and fills with transparent color. More info at * <http://techbase.kde.org/Development/Tutorials/Graphics/Performance#QPixmap::setAlphaChannel.28.29...
453,099
<p>I declare a static char array, then I pass it to a function. How to get the no. of bytes in the array inside the function?</p>
[ { "answer_id": 453104, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 5, "selected": true, "text": "<p>You would have to pass it to the function. You can use sizeof() to get the size of an array. </p>\n\n<pre><code>const c...
2009/01/17
[ "https://Stackoverflow.com/questions/453099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49781/" ]
I declare a static char array, then I pass it to a function. How to get the no. of bytes in the array inside the function?
You would have to pass it to the function. You can use sizeof() to get the size of an array. ``` const char foo[] = "foobar"; void doSomething( char *ptr, int length) { } doSomething(foo, sizeof(foo)); ``` This [MSDN page](http://msdn.microsoft.com/en-us/library/4s7x1k91(VS.71).aspx) has explains more about size...
453,105
<p>..if the columns height is dependent on the height of another column? Solution should work on IE6,7 and Mozilla at least.</p> <p>HTML table layout:</p> <pre> +------------------------+----------------------+ | top-aligned paragraph | Here | | | is a | | ...
[ { "answer_id": 453122, "author": "Jayx", "author_id": 45527, "author_profile": "https://Stackoverflow.com/users/45527", "pm_score": 4, "selected": false, "text": "<p>The easiest way should be to just use <code>vertical-align</code> top and bottom in the cells that you wish to align:</p>\...
2009/01/17
[ "https://Stackoverflow.com/questions/453105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
..if the columns height is dependent on the height of another column? Solution should work on IE6,7 and Mozilla at least. HTML table layout: ``` +------------------------+----------------------+ | top-aligned paragraph | Here | | | is a | | ...
The easiest way should be to just use `vertical-align` top and bottom in the cells that you wish to align: ``` <table> <tr> <td class="top"> <p>Top aligned paragraph</p> </td> <td rowspan="2"> <p>Lorem ipsum dolor sit amet consectetuer id egestas condimentum neque elit. Non tortor tempus orci quis condimentum interdum...
453,107
<p>I have the following problem. I want to include a multi-line textfile as <code>#define</code>, i.e. what I need is a constant that stores the value of the text file. Example:</p> <pre><code>File 'f.txt': This\nis\n\nsome\ntext </code></pre> <p>and I want to initialize a constant (at compile time) in the style of</...
[ { "answer_id": 453126, "author": "Adrian Heine", "author_id": 55965, "author_profile": "https://Stackoverflow.com/users/55965", "pm_score": -1, "selected": false, "text": "<p>One might come up with an idea like the following:</p>\n\n<p>f.txt:</p>\n\n<pre>\nThis \\\nis \\\nsome \\\ntext \...
2009/01/17
[ "https://Stackoverflow.com/questions/453107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have the following problem. I want to include a multi-line textfile as `#define`, i.e. what I need is a constant that stores the value of the text file. Example: ``` File 'f.txt': This\nis\n\nsome\ntext ``` and I want to initialize a constant (at compile time) in the style of ``` #define txtfile "This\\nis\\na\\n...
Take a look at ["#include" a text file in a C program as a char[]](https://stackoverflow.com/questions/410980/include-a-text-file-in-a-c-program-as-a-char) for a possible alternative which might address your needs.
453,118
<p>My user is able to select multiple items in a <code>ListView</code> collection that is configured to show details (that is, a list of rows).</p> <p>What I want to do is add a <code>Delete</code> button that will delete all of the selected items from the <code>ListViewItem</code> collection associated with the <code...
[ { "answer_id": 453129, "author": "lc.", "author_id": 44853, "author_profile": "https://Stackoverflow.com/users/44853", "pm_score": 1, "selected": false, "text": "<p>As far as I know, there is no way other than to delete them individually.</p>\n\n<p>Wrap your deletion algorithm in <code>L...
2009/01/17
[ "https://Stackoverflow.com/questions/453118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/826/" ]
My user is able to select multiple items in a `ListView` collection that is configured to show details (that is, a list of rows). What I want to do is add a `Delete` button that will delete all of the selected items from the `ListViewItem` collection associated with the `ListView`. The collection of selected items is...
If you have a collecion of your selectedItems, you can simply call remove on each of them instead of iterating over the ListView. There is a method on ListViewItem called [Remove()](http://msdn.microsoft.com/en-us/library/system.windows.forms.listviewitem.remove.aspx). ``` ListView listview = <reference to ListView>...
453,141
<p>After reading quite some threads here at StackOverflow, I have come to the conclusion that I should adopt to some form of test driven development/unit test (or at least explore the area).</p> <p>And since we are talking about c code under Linux, I decided to give <a href="http://check.sourceforge.net/doc/check.h...
[ { "answer_id": 453195, "author": "Rob Wells", "author_id": 2974, "author_profile": "https://Stackoverflow.com/users/2974", "pm_score": 3, "selected": false, "text": "<p>I'd be more inclined to go with <a href=\"http://cunit.sourceforge.net/\" rel=\"nofollow noreferrer\">CUnit</a> which i...
2009/01/17
[ "https://Stackoverflow.com/questions/453141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51425/" ]
After reading quite some threads here at StackOverflow, I have come to the conclusion that I should adopt to some form of test driven development/unit test (or at least explore the area). And since we are talking about c code under Linux, I decided to give [check](http://check.sourceforge.net/doc/check.html/index.h...
You created a first test case. Now you need to [create a test suite](http://libcheck.github.io/check/doc/check_html/check_3.html#Creating-a-Suite) (a group of test cases) and a [runner](http://libcheck.github.io/check/doc/check_html/check_3.html#SRunner-Output). I would recommend you try to compile [their example](ht...
453,161
<p>What I want to achieve is very simple: I have a Windows Forms (.NET 3.5) application that uses a path for reading information. This path can be modified by the user, by using the options form I provide.</p> <p>Now, I want to save the path value to a file for later use. This would be one of the many settings saved t...
[ { "answer_id": 453173, "author": "Frederik Gheysels", "author_id": 55774, "author_profile": "https://Stackoverflow.com/users/55774", "pm_score": 6, "selected": false, "text": "<p>The registry is a no-go. You're not sure whether the user which uses your application, has sufficient rights ...
2009/01/17
[ "https://Stackoverflow.com/questions/453161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2661653/" ]
What I want to achieve is very simple: I have a Windows Forms (.NET 3.5) application that uses a path for reading information. This path can be modified by the user, by using the options form I provide. Now, I want to save the path value to a file for later use. This would be one of the many settings saved to this fil...
If you work with Visual Studio then it is pretty easy to get persistable settings. Right click on the project in Solution Explorer and choose Properties. Select the Settings tab and click on the hyperlink if settings doesn't exist. Use the Settings tab to create application settings. Visual Studio creates the files `S...
453,163
<p>Say I have a DLL assembly, containing an auto-generated class with two methods:</p> <pre><code>public class AutoGeneratedClass { public int DoSomething(bool forReal) { ??? } public void DoSomethingElse(string whatever) { ??? } } </code></pre> <p>The methods could be anything, really. The above is just an i...
[ { "answer_id": 453188, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": true, "text": "<p>Do you have to have a class? Life would be a lot easier using interfaces - you can then use <a href=\"http://msdn.micr...
2009/01/17
[ "https://Stackoverflow.com/questions/453163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/82121/" ]
Say I have a DLL assembly, containing an auto-generated class with two methods: ``` public class AutoGeneratedClass { public int DoSomething(bool forReal) { ??? } public void DoSomethingElse(string whatever) { ??? } } ``` The methods could be anything, really. The above is just an illustration. What kind of...
Do you have to have a class? Life would be a lot easier using interfaces - you can then use [System.Runtime.Remoting.Proxies.RealProxy](http://msdn.microsoft.com/en-us/library/system.runtime.remoting.proxies.realproxy.aspx) or possibly create a new type on demand. I believe [Rhino.Mocks](http://ayende.com/projects/rhin...
453,170
<p>I want to set a property in an ant task differently by os type.</p> <p>The property is a directory, in windows i want it to be "c:\flag" in unix/linux "/opt/flag".</p> <p>My current script only works when i run it with the default target, but why ? </p> <pre><code> &lt;target name="checksw_path" depends="if_w...
[ { "answer_id": 453182, "author": "Drejc", "author_id": 6482, "author_profile": "https://Stackoverflow.com/users/6482", "pm_score": 5, "selected": false, "text": "<p>Move your condition out of the <code>&lt;target /&gt;</code>, as your target probably isn't invoked.</p>\n\n<pre><code> &lt...
2009/01/17
[ "https://Stackoverflow.com/questions/453170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41572/" ]
I want to set a property in an ant task differently by os type. The property is a directory, in windows i want it to be "c:\flag" in unix/linux "/opt/flag". My current script only works when i run it with the default target, but why ? ``` <target name="checksw_path" depends="if_windows, if_unix"/> <target name=...
I solved executing the ant task with the value for sw.root using -Dsw.root=c:\flag (for windows) or -Dsw.root=/opt/superwaba (for linux). Anyway thanks
453,186
<p>In JavaScript the % operator seems to behave in a very weird manner. I tried the following:</p> <pre><code>&gt;&gt;&gt; (0 - 11) % 12 -11 </code></pre> <p>Why does it return -11 instead of 1 (as in Python)?</p> <p>I am sure I am doing or expecting something wrong, but the docs don't tell me what.</p>
[ { "answer_id": 453190, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "<p>It's behaving correctly according to the way the language is specified (e.g. <a href=\"http://www.ecma-international....
2009/01/17
[ "https://Stackoverflow.com/questions/453186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8024/" ]
In JavaScript the % operator seems to behave in a very weird manner. I tried the following: ``` >>> (0 - 11) % 12 -11 ``` Why does it return -11 instead of 1 (as in Python)? I am sure I am doing or expecting something wrong, but the docs don't tell me what.
fmod from the math module behaves correctly in python: ``` >>> from math import * >>> fmod(-11, 12) -11.0 ``` -11 is the correct answer..
453,191
<p>I am parsing some XML something like this:</p> <pre><code>&lt;root&gt; &lt;some_gunk/&gt; &lt;dupe_node&gt; ... stuff I want ... &lt;/dupe_node&gt; &lt;bits_and_pieces/&gt; &lt;other_gunk/&gt; &lt;dupe_node&gt; ... stuff I don't want ... &l...
[ { "answer_id": 453193, "author": "Jonas Elfström", "author_id": 44620, "author_profile": "https://Stackoverflow.com/users/44620", "pm_score": 2, "selected": false, "text": "<p>//dupe_node[1]</p>\n" }, { "answer_id": 453199, "author": "Simon Willison", "author_id": 6083, ...
2009/01/17
[ "https://Stackoverflow.com/questions/453191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42974/" ]
I am parsing some XML something like this: ``` <root> <some_gunk/> <dupe_node> ... stuff I want ... </dupe_node> <bits_and_pieces/> <other_gunk/> <dupe_node> ... stuff I don't want ... </dupe_node> <more_gunk/> </root> ``` An XPath of `'...
``` /descendant::dupe_node[1] ``` `//dupe_node[1]` is generally wrong, although it produces an identical result in this particular case. [See docs](http://www.w3.org/TR/xpath#path-abbrev): > > The location path //para[1] does not mean the same as the location path /descendant::para[1]. The latter selects the first ...
453,208
<p>I want to calculate the age of a person given the date of birth and the current date in years, months and days relative to the current date.</p> <p>For example:</p> <pre><code>&gt;&gt;&gt; calculate_age(2008, 01, 01) 1 years, 0 months, 16 days </code></pre> <p>Any pointer to an algorithm that does that will be ap...
[ { "answer_id": 453224, "author": "Martin Thurau", "author_id": 20247, "author_profile": "https://Stackoverflow.com/users/20247", "pm_score": -1, "selected": false, "text": "<p>Since you are obviously using python: Create to datetime objects, one with \"birthday\" and one with \"now\", su...
2009/01/17
[ "https://Stackoverflow.com/questions/453208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8024/" ]
I want to calculate the age of a person given the date of birth and the current date in years, months and days relative to the current date. For example: ``` >>> calculate_age(2008, 01, 01) 1 years, 0 months, 16 days ``` Any pointer to an algorithm that does that will be appreciated.
First, note the assumption that if, for example, you were born on February 1st then on the following March 1st, you are exactly 1 month old, even though your age in days is only 28 -- less than the length of an average month. Years also have variable length (due to leap years) which means your age on your birthday is u...
453,209
<p>I couldn't find anything about getting the total JSON record count using jQuery.</p> <p>Here is the JSON returned:</p> <p><code>{"Email":"Please enter your Email.","Password":"Please enter a password."}</code></p> <p>Here is my code:</p> <pre><code>$(function() { $("#btnSubmit").click(function() { $....
[ { "answer_id": 453214, "author": "Tiago", "author_id": 55283, "author_profile": "https://Stackoverflow.com/users/55283", "pm_score": 7, "selected": true, "text": "<p>If you have something like this:</p>\n\n<pre><code>var json = [ {a:b, c:d}, {e:f, g:h, ...}, {..}, ... ]\n</code></pre>\n\...
2009/01/17
[ "https://Stackoverflow.com/questions/453209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I couldn't find anything about getting the total JSON record count using jQuery. Here is the JSON returned: `{"Email":"Please enter your Email.","Password":"Please enter a password."}` Here is my code: ``` $(function() { $("#btnSubmit").click(function() { $.ajax({ url: "/account/signup", ...
If you have something like this: ``` var json = [ {a:b, c:d}, {e:f, g:h, ...}, {..}, ... ] ``` then, you can do: ``` alert(json.length) ```
453,218
<p>If i have an interface:</p> <pre><code>interface IFoo { int Offset {get;} } </code></pre> <p>can i have this:</p> <pre><code>interface IBar: IFoo { int Offset {set;} } </code></pre> <p>so consumers of IBar will be able to set or get?</p>
[ { "answer_id": 453235, "author": "AnthonyWJones", "author_id": 17516, "author_profile": "https://Stackoverflow.com/users/17516", "pm_score": 3, "selected": false, "text": "<p>This is close but no banana.</p>\n\n<pre><code>interface IFoo\n{\n int Offset { get; }\n}\n\ninterface IBar : ...
2009/01/17
[ "https://Stackoverflow.com/questions/453218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4653/" ]
If i have an interface: ``` interface IFoo { int Offset {get;} } ``` can i have this: ``` interface IBar: IFoo { int Offset {set;} } ``` so consumers of IBar will be able to set or get?
No, you can't! (I was about to write "Yes", but after reading Anthony's post, and trying out a few tweaks, I found the answer to be NO!) ``` class FooBar : IFoo, IBar { public int Offset{get;set;} } ``` (Will generate a warning as Anthony points out, which can be fixed by adding the "new" keyword.) When trying...
453,221
<p>I have this procedure which is inserting records from one table to another. the destination table is having an identity column called LeadId</p> <pre> <code> Create Procedure prcInsertPrd As Begin Begin Transaction Declare @Identity int Insert into Temp_ProductsArchive (column1,column2,column3) se...
[ { "answer_id": 453269, "author": "rejj", "author_id": 53867, "author_profile": "https://Stackoverflow.com/users/53867", "pm_score": -1, "selected": false, "text": "<p>\"<code>inserted</code>\" is a pseudotable containing a row for each item inserted. The trigger only fires once total, no...
2009/01/17
[ "https://Stackoverflow.com/questions/453221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have this procedure which is inserting records from one table to another. the destination table is having an identity column called LeadId ``` Create Procedure prcInsertPrd As Begin Begin Transaction Declare @Identity int Insert into Temp_ProductsArchive (column1,column2,column3) select ...
You have a major problem with your trigger. When you write a trigger you must assume that it might be called with multiple rows. i.e the `inserted` table might contain more than one row, which means you have to join to the inserted table. I'm not sure what you are trying to achieve in your code, but you would need to ...
453,245
<p>I have a bit of PHP code which I need to return an even number of results from a MySQL database. I'm using the mysqli extension to execute my query.</p> <p>My code is approximately this at the moment:</p> <pre><code>//assume we already have a database connection $query = "SELECT id FROM movies ...
[ { "answer_id": 453250, "author": "Henrik Paul", "author_id": 2238, "author_profile": "https://Stackoverflow.com/users/2238", "pm_score": 3, "selected": false, "text": "<p>I would probably do this in PHP, rather than SQL. In the <code>while</code>-loop, keep a counter, and when you get ou...
2009/01/17
[ "https://Stackoverflow.com/questions/453245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21709/" ]
I have a bit of PHP code which I need to return an even number of results from a MySQL database. I'm using the mysqli extension to execute my query. My code is approximately this at the moment: ``` //assume we already have a database connection $query = "SELECT id FROM movies WHERE publish =...
I'd imagine something like this: ``` // row counter $counter = 1; // loop through each row while($row = $result->fetch_assoc()) { // If there is more than one row remaining // OR if the current row can be divided by two if (($result->num_rows - $counter) > 1 || ($counter % 2)) { // result code for...
453,258
<p>I have nested xsl:for loops:</p> <pre><code>&lt;xsl:for-each select="/Root/A"&gt; &lt;xsl:for-each select="/Root/B"&gt; &lt;!-- Code --&gt; &lt;/xsl:for&gt; &lt;/xsl:for&gt; </code></pre> <p><strong>From within the inner loop, how can I access attributes from the current node in the outer loop?</st...
[ { "answer_id": 453261, "author": "Welbog", "author_id": 52443, "author_profile": "https://Stackoverflow.com/users/52443", "pm_score": 6, "selected": true, "text": "<p>You can store the entire /Root/A structure in a variable, and make reference to that variable rather than creating a new ...
2009/01/17
[ "https://Stackoverflow.com/questions/453258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/755/" ]
I have nested xsl:for loops: ``` <xsl:for-each select="/Root/A"> <xsl:for-each select="/Root/B"> <!-- Code --> </xsl:for> </xsl:for> ``` **From within the inner loop, how can I access attributes from the current node in the outer loop?** I keep finding myself writing code like this: ``` <xsl:for-ea...
You can store the entire /Root/A structure in a variable, and make reference to that variable rather than creating a new variable for every attribute and subelement you need to access. ``` <xsl:for-each select="/Root/A/"> <xsl:variable name="ROOT_A" select="."/> <xsl:for-each select="/Root/B/"> <!-- V...
453,277
<p>I've got an entity Product like this:</p> <pre><code>[Class(0, Name = "Product", Table = "Products")] public class Product { private readonly ISet&lt;ProductPropertyValue&gt; _productPropertyValues; private readonly ISet&lt;ProductImage&gt; _productImages; private readonly ISet&lt;ProductComment&gt; _pr...
[ { "answer_id": 453274, "author": "Aif", "author_id": 51760, "author_profile": "https://Stackoverflow.com/users/51760", "pm_score": 3, "selected": true, "text": "<p>Look at <a href=\"http://dev.mysql.com/doc/refman/5.0/en/triggers.html\" rel=\"nofollow noreferrer\">triggers</a> to delete ...
2009/01/17
[ "https://Stackoverflow.com/questions/453277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2258236/" ]
I've got an entity Product like this: ``` [Class(0, Name = "Product", Table = "Products")] public class Product { private readonly ISet<ProductPropertyValue> _productPropertyValues; private readonly ISet<ProductImage> _productImages; private readonly ISet<ProductComment> _productComments; private reado...
Look at [triggers](http://dev.mysql.com/doc/refman/5.0/en/triggers.html) to delete automatically the old rows.
453,279
<p>I would like to do simple (looping) animation (moving, changing alpha etc) in Haxe (flash9). I don't have anything that resembles frames in my library, just single frame assets.</p> <p>Since I am a beginner. I am not necessarily looking for a sophisticated framework. I would be happy with something quick &amp; dirt...
[ { "answer_id": 453911, "author": "grapefrukt", "author_id": 914, "author_profile": "https://Stackoverflow.com/users/914", "pm_score": 3, "selected": true, "text": "<p>If you want to do animations I would very much recommend using a <a href=\"http://code.google.com/p/tweener/\" rel=\"nofo...
2009/01/17
[ "https://Stackoverflow.com/questions/453279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42188/" ]
I would like to do simple (looping) animation (moving, changing alpha etc) in Haxe (flash9). I don't have anything that resembles frames in my library, just single frame assets. Since I am a beginner. I am not necessarily looking for a sophisticated framework. I would be happy with something quick & dirty. Maybe `if`s...
If you want to do animations I would very much recommend using a [tweening](http://code.google.com/p/tweener/) library, although I understand that you might want to learn the basics before "cheating" past them. I would recommend hooking up your animations to the ENTER\_FRAME event instead of a timer running at the sam...
453,289
<p>I'm now using <code>ListItem()</code> for Json format result, but the generated Json text has an extra property called <code>"selected = false"</code>, I know this is used for drop down list, but I want my app runs faster so I don't want this property. Do you know any other way to get the similar result?</p> <p>Her...
[ { "answer_id": 453303, "author": "Andrew Hare", "author_id": 34211, "author_profile": "https://Stackoverflow.com/users/34211", "pm_score": 0, "selected": false, "text": "<p>Don't use <code>ListItem</code> - use a custom type that has only the properties you want.</p>\n" }, { "ans...
2009/01/17
[ "https://Stackoverflow.com/questions/453289", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm now using `ListItem()` for Json format result, but the generated Json text has an extra property called `"selected = false"`, I know this is used for drop down list, but I want my app runs faster so I don't want this property. Do you know any other way to get the similar result? Here is my code: ``` List<ListItem...
Depending on your JSON serialiser you may or may not be able to tell the serialiser to ignore this property. You'd be better off just creating a class that only has the fields you need. e.g. ``` public class MyListItem { public string Text { get;set; } public string Value { get;set; } } List<MyListItem> list...
453,293
<p>What are all the things one needs to be careful about when coding in a multicore environment?</p> <p>For example, for a singleton class, it is better to create a global object and then return its reference than a static object.</p> <p>i.e Rather than having </p> <pre><code>MyClass &amp; GetInstance() { static My...
[ { "answer_id": 453298, "author": "frankodwyer", "author_id": 42404, "author_profile": "https://Stackoverflow.com/users/42404", "pm_score": 0, "selected": false, "text": "<p>Multicore is not so relevant as you may get multiple threads on a unicore system too.</p>\n\n<p>Both versions of Ge...
2009/01/17
[ "https://Stackoverflow.com/questions/453293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39615/" ]
What are all the things one needs to be careful about when coding in a multicore environment? For example, for a singleton class, it is better to create a global object and then return its reference than a static object. i.e Rather than having ``` MyClass & GetInstance() { static Myclass singleMyclass; return sing...
My first answer addressed your example of singleton initialisation, but as you emphasised in an edit to your question, you are after more general pit falls of C++ as we move to multi-core and multi-threaded applications. The following is a real surprise when you first encounter it. Though not C++ specific, it definitel...
453,329
<p>I've just found <a href="http://ipython.scipy.org/" rel="nofollow noreferrer">IPython</a> and I can report that I'm in deep love. And the affection was immediate. I think this affair will turn into something lasting, like <a href="https://stackoverflow.com/questions/431521/run-a-command-in-a-shell-and-keep-running-t...
[ { "answer_id": 453378, "author": "Igal Serban", "author_id": 25737, "author_profile": "https://Stackoverflow.com/users/25737", "pm_score": 1, "selected": false, "text": "<p>In the ipythonrc.ini file in you home directory change the editor to MacVim.</p>\n" }, { "answer_id": 45383...
2009/01/17
[ "https://Stackoverflow.com/questions/453329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44639/" ]
I've just found [IPython](http://ipython.scipy.org/) and I can report that I'm in deep love. And the affection was immediate. I think this affair will turn into something lasting, like [the one I have with screen](https://stackoverflow.com/questions/431521/run-a-command-in-a-shell-and-keep-running-the-command-when-you-...
I use Linux, but I believe this tip can be used in OS X too. I use [GNU Screen](http://www.gnu.org/software/screen/) to send IPython commands from Vim as recommended by [this tip](http://vim.wikia.com/wiki/IPython_integration). This is how I do it: First, you should open a terminal and start a screen session called 'i...
453,352
<p>I am trying to convert different files to a flash compatible <code>.mp4</code> file with ffmpeg, but I can't seem to get it to work. Of course the objective is to get the greatest quality with the smallest file size.</p> <p>So far I have this, which works, but it doesn't play in a flash player for some reason. The ...
[ { "answer_id": 453669, "author": "olle", "author_id": 48383, "author_profile": "https://Stackoverflow.com/users/48383", "pm_score": 0, "selected": false, "text": "<p>Just some ideas of why this might happen</p>\n\n<ul>\n<li>mp4 is only supported in flash 9.0.115.0 or higher, what version...
2009/01/17
[ "https://Stackoverflow.com/questions/453352", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42546/" ]
I am trying to convert different files to a flash compatible `.mp4` file with ffmpeg, but I can't seem to get it to work. Of course the objective is to get the greatest quality with the smallest file size. So far I have this, which works, but it doesn't play in a flash player for some reason. The result isn't that gre...
To create the interleaving metadata (which will allow for mid stream resumes, and rewinds/fforwards), use the gpac utilities (included in medibuntu for example) to re-interleave the file. Convert to mp4 as follows, with FFmpeg version 0.5 or better: ``` ffmpeg -f mp4 -i video.mov -b 400k video.mp4 ``` then ``` /usr...
453,372
<p>I have a class which has many small functions. By small functions, I mean functions that doesn't do any processing but just return a literal value. Something like:</p> <pre><code>string Foo::method() const{ return "A"; } </code></pre> <p>I have created a header file "Foo.h" and source file "Foo.cpp". But since...
[ { "answer_id": 453379, "author": "Qubeuc", "author_id": 46145, "author_profile": "https://Stackoverflow.com/users/46145", "pm_score": 3, "selected": false, "text": "<p>There will be an increase in performance because implementation in header files are implicitly inlined. As you mentioned...
2009/01/17
[ "https://Stackoverflow.com/questions/453372", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50419/" ]
I have a class which has many small functions. By small functions, I mean functions that doesn't do any processing but just return a literal value. Something like: ``` string Foo::method() const{ return "A"; } ``` I have created a header file "Foo.h" and source file "Foo.cpp". But since the function is very smal...
If the function is small (the chance you would change it often is low), and if the function can be put into the header without including myriads of other headers (because your function depends on them), it is perfectly valid to do so. If you declare them extern inline, then the compiler is required to give it the same ...
453,396
<p>This is what I came up with for my rock-paper-scissors game:</p> <pre><code>import random from time import sleep print "Please select: " print "1 Rock" print "2 Paper" print "3 Scissors" player = input ("Choose from 1-3: ") if player == 1: print "You choose Rock" sleep (2) print "CPU ch...
[ { "answer_id": 453400, "author": "sykora", "author_id": 53850, "author_profile": "https://Stackoverflow.com/users/53850", "pm_score": 5, "selected": false, "text": "<p>Well, you've already imported the random module, that's a start.</p>\n\n<p>Try the random.choice function.</p>\n\n<pre><...
2009/01/17
[ "https://Stackoverflow.com/questions/453396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56206/" ]
This is what I came up with for my rock-paper-scissors game: ``` import random from time import sleep print "Please select: " print "1 Rock" print "2 Paper" print "3 Scissors" player = input ("Choose from 1-3: ") if player == 1: print "You choose Rock" sleep (2) print "CPU chooses Paper" ...
Well, you've already imported the random module, that's a start. Try the random.choice function. ``` >>> from random import choice >>> cpu_choice = choice(('rock', 'paper', 'scissors')) ```
453,399
<p>I heard that AS <strong>boxes</strong> and un-boxes values every time arguments are passed into/out of functions.</p> <p><strong>A.</strong> Therefore, would this be faster?</p> <pre><code>var val = doWork(50,"hello", 2048); function doWork (param1,param2,param3){ t.text = param2; return param1+param3; } </...
[ { "answer_id": 453563, "author": "Christian Nunciato", "author_id": 32129, "author_profile": "https://Stackoverflow.com/users/32129", "pm_score": 0, "selected": false, "text": "<p>You'll <strong>always</strong> do better performance-wise declaring types than omitting them, so in your cas...
2009/01/17
[ "https://Stackoverflow.com/questions/453399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41021/" ]
I heard that AS **boxes** and un-boxes values every time arguments are passed into/out of functions. **A.** Therefore, would this be faster? ``` var val = doWork(50,"hello", 2048); function doWork (param1,param2,param3){ t.text = param2; return param1+param3; } ``` **B.** Or this? ``` var val:Number = doWor...
There's no difference at runtime. AS 2 is run by the Actionscript Virtual Machine 1 (AVM1), which doesn't support static typing, so type information is rather a hint for the compiler to help you catch type inconsistencies earlier. But the same code with or without type annotations produces the same bytecode. AS 3 is r...
453,406
<p>I've searched and searched but nothing has really worked.</p> <p>I'm trying to set a textvalue from a text box, into a string or whatever, so that I can call it up later in a different view controller. I can't seem to get it to work!</p> <p>I'd also like numbers to be carried over, such like currency's.</p> <p>An...
[ { "answer_id": 453445, "author": "philsquared", "author_id": 32136, "author_profile": "https://Stackoverflow.com/users/32136", "pm_score": 0, "selected": false, "text": "<p>Your question is a bit vague. Could you give any more specifics.\nIt <em>sounds</em> like you want to know:</p>\n\n...
2009/01/17
[ "https://Stackoverflow.com/questions/453406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53677/" ]
I've searched and searched but nothing has really worked. I'm trying to set a textvalue from a text box, into a string or whatever, so that I can call it up later in a different view controller. I can't seem to get it to work! I'd also like numbers to be carried over, such like currency's. Any ideas on them? Cheers...
You could make an instance variable on the other view controller retain or copy the value before you push/pop the view. For example: ``` OpenNextViewController *varNextPageController = [[OpenNextViewController alloc] initWithNibName:@"OpenNextViewController" bundle:nil]; varNextPageController .textString= self.textStr...
453,407
<p>What do people here use C++ Abstract Base Class constructors for in the field? I am talking about pure interface classes having no data members and no non-pure virtual members. </p> <p>Can anyone demonstrate any idioms which use ABC constructors in a useful way? Or is it just intrinsic to the nature of using ABCs t...
[ { "answer_id": 453425, "author": "gbjbaanb", "author_id": 13744, "author_profile": "https://Stackoverflow.com/users/13744", "pm_score": 0, "selected": false, "text": "<p>usually its solely to initialise members to sensible values.</p>\n" }, { "answer_id": 453534, "author": "j...
2009/01/17
[ "https://Stackoverflow.com/questions/453407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27601/" ]
What do people here use C++ Abstract Base Class constructors for in the field? I am talking about pure interface classes having no data members and no non-pure virtual members. Can anyone demonstrate any idioms which use ABC constructors in a useful way? Or is it just intrinsic to the nature of using ABCs to implemen...
> > Can anyone demonstrate any idioms which use ABC constructors in a useful way? > > > Here's an example, although it's a contrived, uncommon example. You might use it to keep a list of all instances: ``` class IFoo { private: //static members to keep a list of all constructed instances typedef std::set<IFo...
453,410
<p>Is there a way to adjust all image sizes in a directory?</p> <p>If I set the max size to 800x600 it will make larger ones smaller and leave smaller ones at their original size.</p>
[ { "answer_id": 453413, "author": "dusoft", "author_id": 56066, "author_profile": "https://Stackoverflow.com/users/56066", "pm_score": 2, "selected": false, "text": "<p>image magick package needs to be installed:\nmogrify -resize 320x240 *.jpg\nwhere 320 = width, 240 = height</p>\n\n<p>or...
2009/01/17
[ "https://Stackoverflow.com/questions/453410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43960/" ]
Is there a way to adjust all image sizes in a directory? If I set the max size to 800x600 it will make larger ones smaller and leave smaller ones at their original size.
``` for img in *.png; do convert "$img" "800x600>" $(basename "$img" .png)_new.png done ``` `convert` is from ImageMagick. ">" says it's only resized if larger. See [here](http://www.imagemagick.org/script/command-line-options.php#resize) for its other options.
453,420
<p>Im trying to make a simple template system in PHP. I'm new to PHP, so it's nothing serious. I have some problems though:</p> <p>A regular include works:</p> <pre><code>$variable = "test"; include("templates/news.html"); </code></pre> <p>But this won't:</p> <p>This says <code>$variable</code> is undefined:</p> <...
[ { "answer_id": 453433, "author": "dusoft", "author_id": 56066, "author_profile": "https://Stackoverflow.com/users/56066", "pm_score": 1, "selected": false, "text": "<p>you are trying to reach global variable in a function.</p>\n\n<p>you must either declare a variable global in a function...
2009/01/17
[ "https://Stackoverflow.com/questions/453420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Im trying to make a simple template system in PHP. I'm new to PHP, so it's nothing serious. I have some problems though: A regular include works: ``` $variable = "test"; include("templates/news.html"); ``` But this won't: This says `$variable` is undefined: ``` $variable = "test"; getTemplate("news"); ``` The F...
With the [extract](http://php.net/extract) function, you can define different variables from an array. You can make it like this: ``` $vars = array('var1' => "value1", 'var2' => "value2"); function getTemplate($tpl, $vars) { $file = "templates/$tpl.html"; extract($vars, EXTR_SKIP) if (file_exists($file)) retur...
453,432
<p>In c (or maybe c++) , what's the difference between <br/></p> <pre> char myarr[16]={0x00}; </pre> <p>and <br/></p> <pre> char myarr[16]; memset(myarr, '\0', sizeof(myarr)); </pre> <p>??</p> <p>edit: I ask this because in vc++ 2005 the result is the same.. <br/> edit more : and <pre>char myarr[16]={0x00,}; <...
[ { "answer_id": 453462, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 5, "selected": true, "text": "<p>The important difference is that the first default initializes the array in an element-specific manner: P...
2009/01/17
[ "https://Stackoverflow.com/questions/453432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38515/" ]
In c (or maybe c++) , what's the difference between ``` char myarr[16]={0x00}; ``` and ``` char myarr[16]; memset(myarr, '\0', sizeof(myarr)); ``` ?? edit: I ask this because in vc++ 2005 the result is the same.. edit more : and ``` char myarr[16]={0x00,}; ``` ? maybe can get more comprehensive answer ...
The important difference is that the first default initializes the array in an element-specific manner: Pointers will receive a *null pointer value*, which doesn't need to be 0x00 (as in all-bits-zero), booleans will be *false*. If the element type is a class type that's not a so-called *POD* (plain old data-type), the...
453,436
<p>Java EE 6 looks exciting. It will include the Servlet 3.0 spec, EJB3.1 Lite, Profiles, JSF2.0 Restful API, JPA2.0 and the WebBeans.</p> <p>I tried to google the scheduled release date for the platform but could not find anything official. Anyone? Or is it just the way it works? As soon as all the JCP expert groups ...
[ { "answer_id": 453462, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 5, "selected": true, "text": "<p>The important difference is that the first default initializes the array in an element-specific manner: P...
2009/01/17
[ "https://Stackoverflow.com/questions/453436", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56194/" ]
Java EE 6 looks exciting. It will include the Servlet 3.0 spec, EJB3.1 Lite, Profiles, JSF2.0 Restful API, JPA2.0 and the WebBeans. I tried to google the scheduled release date for the platform but could not find anything official. Anyone? Or is it just the way it works? As soon as all the JCP expert groups finish the...
The important difference is that the first default initializes the array in an element-specific manner: Pointers will receive a *null pointer value*, which doesn't need to be 0x00 (as in all-bits-zero), booleans will be *false*. If the element type is a class type that's not a so-called *POD* (plain old data-type), the...
453,477
<pre><code>class Message(models.Model): subject = models.CharField(max_length=100) pub_date = models.DateTimeField(default=datetime.now()) class Topic(models.Model): title = models.CharField(max_length=100) message = models.ManyToManyField(Message, verbose_name='Discussion') </code></pre> <p>I want t...
[ { "answer_id": 460702, "author": "akaihola", "author_id": 15770, "author_profile": "https://Stackoverflow.com/users/15770", "pm_score": 3, "selected": true, "text": "<p>You'll find the explanation in the <a href=\"http://docs.djangoproject.com/en/dev/ref/models/querysets/#distinct\" rel=...
2009/01/17
[ "https://Stackoverflow.com/questions/453477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56183/" ]
``` class Message(models.Model): subject = models.CharField(max_length=100) pub_date = models.DateTimeField(default=datetime.now()) class Topic(models.Model): title = models.CharField(max_length=100) message = models.ManyToManyField(Message, verbose_name='Discussion') ``` I want to get order all the...
You'll find the explanation in the [documentation for `.distinct()`](http://docs.djangoproject.com/en/dev/ref/models/querysets/#distinct). I would de-normalize by adding a `modified_date` field to the `Topic` model and updating it whenever a Message is saved or deleted.
453,479
<p>Two Questions:</p> <p>Will I get different sequences of numbers for every seed I put into it?</p> <p>Are there some "dead" seeds? (Ones that produce zeros or repeat very quickly.)</p> <p>By the way, which, if any, other PRNGs should I use?</p> <p>Solution: Since, I'm going to be using the PRNG to make a game, I ...
[ { "answer_id": 453485, "author": "zvrba", "author_id": 2583, "author_profile": "https://Stackoverflow.com/users/2583", "pm_score": 2, "selected": false, "text": "<p>This is described in the <a href=\"http://java.sun.com/j2se/1.4.2/docs/api/java/util/Random.html\" rel=\"nofollow noreferre...
2009/01/17
[ "https://Stackoverflow.com/questions/453479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27677/" ]
Two Questions: Will I get different sequences of numbers for every seed I put into it? Are there some "dead" seeds? (Ones that produce zeros or repeat very quickly.) By the way, which, if any, other PRNGs should I use? Solution: Since, I'm going to be using the PRNG to make a game, I don't need it to be cryptograph...
To some extent, random number generators are horses for courses. The Random class implements an LCG with reasonably chosen parameters. But it still exhibits the following features: * fairly short period (2^48) * bits are not equally random (see my article on [randomness of bit positions](http://www.javamex.com/tutoria...
453,561
<p>I'm trying to create simply connect with ActiveMQ using JNDI. <hr/> I have</p> <ol> <li><p>Queue named 'example.A'.</p></li> <li><p>According <a href="http://activemq.apache.org/jndi-support.html" rel="noreferrer">ActiveMQ documentation touching JNDI</a>, if I want to use ConectionFactories and Queues (Topics) via ...
[ { "answer_id": 454179, "author": "BenM", "author_id": 43850, "author_profile": "https://Stackoverflow.com/users/43850", "pm_score": 4, "selected": true, "text": "<p>The problem is that you are explicitly creating the properties and passing them into the InitialContext constructor. This m...
2009/01/17
[ "https://Stackoverflow.com/questions/453561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56228/" ]
I'm trying to create simply connect with ActiveMQ using JNDI. --- I have 1. Queue named 'example.A'. 2. According [ActiveMQ documentation touching JNDI](http://activemq.apache.org/jndi-support.html), if I want to use ConectionFactories and Queues (Topics) via JNDI, I have to place jndi.properties file on my classpa...
The problem is that you are explicitly creating the properties and passing them into the InitialContext constructor. This means the jndi.properties on the class path won't be read. Your code should be something like: ``` Context context = new InitialContext(); ConnectionFactory connectionFactory = (ConnectionFactory)...
453,576
<p>I want to generate a dict with the letters of the alphabet as the keys, something like </p> <pre><code>letter_count = {'a': 0, 'b': 0, 'c': 0} </code></pre> <p>what would be a fast way of generating that dict, rather than me having to type it in?</p> <p>Thanks for your help.</p> <p><b>EDIT</b><br> Thanks everyon...
[ { "answer_id": 453592, "author": "recursive", "author_id": 44743, "author_profile": "https://Stackoverflow.com/users/44743", "pm_score": 2, "selected": false, "text": "<p>There's this too:</p>\n<pre class=\"lang-py prettyprint-override\"><code>import string\nletter_count = dict((letter, ...
2009/01/17
[ "https://Stackoverflow.com/questions/453576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41718/" ]
I want to generate a dict with the letters of the alphabet as the keys, something like ``` letter_count = {'a': 0, 'b': 0, 'c': 0} ``` what would be a fast way of generating that dict, rather than me having to type it in? Thanks for your help. **EDIT** Thanks everyone for your solutions :) [nosklo's](https://...
I find this solution more elegant: ```py import string d = dict.fromkeys(string.ascii_lowercase, 0) print(d) # {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}...
453,581
<h3>Duplicate</h3> <blockquote> <p><a href="https://stackoverflow.com/questions/635378/unable-to-remove-everything-else-in-a-folder-except-filea">Unable to remove everything else in a folder except FileA</a></p> </blockquote> <p>I guess that it is slightly similar to this: delete [^Music]</p> <p>However, it does not wo...
[ { "answer_id": 453772, "author": "A. Rex", "author_id": 3508, "author_profile": "https://Stackoverflow.com/users/3508", "pm_score": 2, "selected": false, "text": "<p>The command</p>\n\n<pre><code>rm (ls | grep -v '^Music$')\n</code></pre>\n\n<p>should work. If some of your \"files\" are...
2009/01/17
[ "https://Stackoverflow.com/questions/453581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54964/" ]
### Duplicate > > [Unable to remove everything else in a folder except FileA](https://stackoverflow.com/questions/635378/unable-to-remove-everything-else-in-a-folder-except-filea) > > > I guess that it is slightly similar to this: delete [^Music] However, it does not work.
Put the following command to your ~/.bashrc ``` shopt -s extglob ``` You can now delete everything else in the folder except the Music folder by ``` rm -r !(Music) ``` Please, be careful with the command. It is powerful, but dangerous too. I recommend to test it always with the command ``` echo rm -r !(Music) ...
453,586
<p>In firefox, I have the following fragment in my .css file</p> <pre><code>tree (negative){ font-size: 120%; color: green;} </code></pre> <p>Using javascript, how do I change the <strong>rule</strong>, to set the color to red?</p> <p><strong>NOTE:<br> I do not want to change the element.<br> I want to change the r...
[ { "answer_id": 453598, "author": "Andrew Hare", "author_id": 34211, "author_profile": "https://Stackoverflow.com/users/34211", "pm_score": 0, "selected": false, "text": "<p>As there is no HTML element <code>tree</code> I am going to assume that <code>tree</code> is the <code>id</code> or...
2009/01/17
[ "https://Stackoverflow.com/questions/453586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12113/" ]
In firefox, I have the following fragment in my .css file ``` tree (negative){ font-size: 120%; color: green;} ``` Using javascript, how do I change the **rule**, to set the color to red? **NOTE: I do not want to change the element. I want to change the rule. Please do not answer with something like** ......
What you're looking for is the `document.styleSheets` property, through which you can access your css rules and manipulate them. Most browsers have this property, however the interface is slightly different for IE. For example, try pasting the following in FF for this page and pressing enter: ``` javascript:alert(doc...
453,607
<p>What is the best Java spell checking API?</p> <p>Free or purchased, must be royalty-free.</p>
[ { "answer_id": 453637, "author": "David Crow", "author_id": 2783, "author_profile": "https://Stackoverflow.com/users/2783", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://www.wintertreesoftware.com/spell-check/java/index.html\" rel=\"nofollow noreferrer\">Sentry Spell Che...
2009/01/17
[ "https://Stackoverflow.com/questions/453607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/363822/" ]
What is the best Java spell checking API? Free or purchased, must be royalty-free.
Just used [Jazzy](http://sourceforge.net/projects/jazzy/) and it worked well. Try this [example](http://jazzy.cvs.sourceforge.net/viewvc/jazzy/jazzy/src/com/swabunga/spell/examples/SpellCheckExample.java?view=markup) and download the [dictionary](http://sourceforge.net/projects/jazzy/files/Dictionaries/English/). Here...
453,614
<p>What is the really minimal example of Silverlight application?</p> <p>For example, I made the following example with IronPython:</p> <pre><code>from System.Windows import Application from System.Windows.Controls import Canvas, TextBlock canvas = Canvas() textblock = TextBlock() textblock.FontSize = 24 textblock.T...
[ { "answer_id": 453636, "author": "Ifeanyi Echeruo", "author_id": 47702, "author_profile": "https://Stackoverflow.com/users/47702", "pm_score": 5, "selected": false, "text": "<p>You can use the <a href=\"http://msdn.microsoft.com/en-us/library/system.windows.controls.panel.zindex.aspx\" r...
2009/01/17
[ "https://Stackoverflow.com/questions/453614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45269/" ]
What is the really minimal example of Silverlight application? For example, I made the following example with IronPython: ``` from System.Windows import Application from System.Windows.Controls import Canvas, TextBlock canvas = Canvas() textblock = TextBlock() textblock.FontSize = 24 textblock.Text = 'Hello!' canvas...
You can use the [Panel.ZIndex](http://msdn.microsoft.com/en-us/library/system.windows.controls.panel.zindex.aspx) property to change the display order of elements in a panel
453,627
<p>Here is my script:</p> <pre><code>#!/bin/bash echo "Digite o local em que deseja instalar o IGRAFU(pressione enter para instalar em ${HOME}/IGRAFO):" read caminho if test -z $caminho then caminho="${HOME}/IGRAFO" fi echo "O IGRAFU será instalado no diretório: $caminho" mkdir -pv $caminho mv -v ./* $caminho echo...
[ { "answer_id": 453635, "author": "falstro", "author_id": 46991, "author_profile": "https://Stackoverflow.com/users/46991", "pm_score": 5, "selected": true, "text": "<p>You will probably need to eval the variable to have it substituted correctly. One example would be to simply do</p>\n\n<...
2009/01/17
[ "https://Stackoverflow.com/questions/453627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2605/" ]
Here is my script: ``` #!/bin/bash echo "Digite o local em que deseja instalar o IGRAFU(pressione enter para instalar em ${HOME}/IGRAFO):" read caminho if test -z $caminho then caminho="${HOME}/IGRAFO" fi echo "O IGRAFU será instalado no diretório: $caminho" mkdir -pv $caminho mv -v ./* $caminho echo "Pronto!" ``...
You will probably need to eval the variable to have it substituted correctly. One example would be to simply do ``` caminho=`eval "echo $caminho"` ``` Keep in mind that this will break if `caminho` contains semicolons or quotes, it will also treat backslashes as escaping, and if the data is untrusted, you need to ta...
453,640
<p>I'd like to write an application in C which uses arrow-keys to navigate and F-keys for other functions, such as saving to a file, language selection, etc.</p> <p>Propably the values depend on the platform, so how could I find out which values the keys have?</p> <p>If they don't, or if you know them, I don't have t...
[ { "answer_id": 453648, "author": "Paul Beckingham", "author_id": 14356, "author_profile": "https://Stackoverflow.com/users/14356", "pm_score": 1, "selected": false, "text": "<p>I think that depends on $TERM, but either way it's going to be a sequence of characters. I get this:</p>\n\n<p...
2009/01/17
[ "https://Stackoverflow.com/questions/453640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56234/" ]
I'd like to write an application in C which uses arrow-keys to navigate and F-keys for other functions, such as saving to a file, language selection, etc. Propably the values depend on the platform, so how could I find out which values the keys have? If they don't, or if you know them, I don't have to know how to fin...
I think that depends on $TERM, but either way it's going to be a sequence of characters. I get this: ``` % read x; echo $x | od -c -- ^[[15~ 0000000 033 [ 1 5 ~ \n 0000006 ``` That's my F5 key, and apologies for this being a \*nix-centric answer, if that's not your p...
453,654
<p>I'm trying to create:</p> <p>AxShockwaveFlashObjects.dll and ShockwaveFlashObjects.dll</p> <p>entering the following command:</p> <p>aximp C:\WINDOWS\system32\Macromed\Flash\FlDbg10.ocx /nologo</p> <p>but I get an E_ACCESSDENIED error.</p> <p>What am I doing wrong? Thanks!</p>
[ { "answer_id": 453648, "author": "Paul Beckingham", "author_id": 14356, "author_profile": "https://Stackoverflow.com/users/14356", "pm_score": 1, "selected": false, "text": "<p>I think that depends on $TERM, but either way it's going to be a sequence of characters. I get this:</p>\n\n<p...
2009/01/17
[ "https://Stackoverflow.com/questions/453654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to create: AxShockwaveFlashObjects.dll and ShockwaveFlashObjects.dll entering the following command: aximp C:\WINDOWS\system32\Macromed\Flash\FlDbg10.ocx /nologo but I get an E\_ACCESSDENIED error. What am I doing wrong? Thanks!
I think that depends on $TERM, but either way it's going to be a sequence of characters. I get this: ``` % read x; echo $x | od -c -- ^[[15~ 0000000 033 [ 1 5 ~ \n 0000006 ``` That's my F5 key, and apologies for this being a \*nix-centric answer, if that's not your p...
453,683
<p>When you call DbConnection.GetSchema you give it the string name of a collection you are interested in. I can't find a list of collections anywhere. Is the list of collections immutable or does it vary by database type (orcle, sql server, etc.)?</p> <p>I'm interested in getting a list of all collection names in a f...
[ { "answer_id": 453790, "author": "JAG", "author_id": 16032, "author_profile": "https://Stackoverflow.com/users/16032", "pm_score": 4, "selected": true, "text": "<p>I use an OleDbConnection even if I'm connecting with Oracle, Sql Server... Then I can use:</p>\n\n<pre><code>myOleDbConnecti...
2009/01/17
[ "https://Stackoverflow.com/questions/453683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28343/" ]
When you call DbConnection.GetSchema you give it the string name of a collection you are interested in. I can't find a list of collections anywhere. Is the list of collections immutable or does it vary by database type (orcle, sql server, etc.)? I'm interested in getting a list of all collection names in a few databas...
I use an OleDbConnection even if I'm connecting with Oracle, Sql Server... Then I can use: ``` myOleDbConnection.GetOleDbSchemaTable(OleDbSchemGuid.Tables); ``` Possible values for OleDbSchemaGuid: (note that depending of the database some of these can throw a NotSupported Exception: ``` OleDbSchemaGuid.Assert...
453,691
<p>I'm building a app that needs to perform calculations on money.</p> <p>I wonder how to properly use NSDecimalNumber, especially how to initialize it from integers, floats &amp; doubles?</p> <p>I only found it easy to use the <code>-decimalNumberWithString:</code> method. The <code>-initWith...</code> methods are d...
[ { "answer_id": 454562, "author": "Ashley Clark", "author_id": 4556, "author_profile": "https://Stackoverflow.com/users/4556", "pm_score": 7, "selected": true, "text": "<p>Do <strong>NOT</strong> use <code>NSNumber</code>'s <code>+numberWith...</code> methods to create <code>NSDecimalNumb...
2009/01/17
[ "https://Stackoverflow.com/questions/453691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53185/" ]
I'm building a app that needs to perform calculations on money. I wonder how to properly use NSDecimalNumber, especially how to initialize it from integers, floats & doubles? I only found it easy to use the `-decimalNumberWithString:` method. The `-initWith...` methods are discouraged so that only left the ones with ...
Do **NOT** use `NSNumber`'s `+numberWith...` methods to create `NSDecimalNumber` objects. They are declared to return `NSNumber` objects and are not guaranteed to function as `NSDecimalNumber` instances. This is explained in this [thread](http://www.cocoabuilder.com/archive/message/cocoa/2009/1/10/227253) by Bill Bumg...
453,696
<p>I'm working with some code that widely uses the idiom of returning a pointer to a static local variable. eg:</p> <pre><code>char* const GetString() { static char sTest[5]; strcpy(sTest, "Test"); return sTest; } </code></pre> <p>Am I right in thinking that this is safe?</p> <p>PS, I know that this would be ...
[ { "answer_id": 453730, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 4, "selected": false, "text": "<p><code>static</code> variables (in a function) are like scoped global variables. In general, they should be avoided (li...
2009/01/17
[ "https://Stackoverflow.com/questions/453696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8331/" ]
I'm working with some code that widely uses the idiom of returning a pointer to a static local variable. eg: ``` char* const GetString() { static char sTest[5]; strcpy(sTest, "Test"); return sTest; } ``` Am I right in thinking that this is safe? PS, I know that this would be a better way of doing the same thi...
**First example: Somewhat safe** ``` char* const GetString() { static char sTest[5]; strcpy(sTest, "Test"); return sTest; } ``` Although not recommended, this is safe, the scope of a static variable remains alive even when the scope of the function ends. This function is not very thread-safe at all. A better f...
453,738
<p>When I design classes and have to choose between inheritance and composition, I usually use the rule of thumb: if the relationship is "is-a" - use inheritance, and if the relationship is "has-a" - use composition.</p> <p>Is it always right? </p> <p>Thank you.</p>
[ { "answer_id": 453744, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 1, "selected": false, "text": "<p><del>No</del>Yes. If the relationship is \"has-a\", use composition. (<em>Added</em>: the original version o...
2009/01/17
[ "https://Stackoverflow.com/questions/453738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44673/" ]
When I design classes and have to choose between inheritance and composition, I usually use the rule of thumb: if the relationship is "is-a" - use inheritance, and if the relationship is "has-a" - use composition. Is it always right? Thank you.
No - "is a" does not always lead to inheritence. A well cited example is the relationship between a square and a rectangle. A square is a rectangle, but it will be bad to design code that inherits a Square class off a Rectangle class. My suggestion is to enhance your "is a / has a" heuristic with the [Liskov Substitut...
453,755
<p>I use the <a href="http://github.com/nkallen/cache-money" rel="nofollow noreferrer">cache-money</a> gem for transparent usage of Memcached. Using the supplied config file it is enabled on all modes (development, test, production). Is there a way to only activate cache-money in production mode?</p> <p>It's not immed...
[ { "answer_id": 509087, "author": "wesgarrison", "author_id": 62140, "author_profile": "https://Stackoverflow.com/users/62140", "pm_score": 0, "selected": false, "text": "<p>In your initializer, skip initialization if you're running in development mode:</p>\n\n<pre><code>unless 'developme...
2009/01/17
[ "https://Stackoverflow.com/questions/453755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52283/" ]
I use the [cache-money](http://github.com/nkallen/cache-money) gem for transparent usage of Memcached. Using the supplied config file it is enabled on all modes (development, test, production). Is there a way to only activate cache-money in production mode? It's not immediately clear how to do this, and it's a total p...
Thanks to [Obie Fernandez](http://obiefernandez.com/) for a great offline hint: Stub out cache-money's #index method to do nothing. This provides a place for the #index statements in the models to go, and stops the error mentioned above. Here is my full cache\_money.rb lib: ``` if RAILS_ENV != 'development' require...
453,762
<p>I'm getting a <code>NoMethodError</code> when trying to access a method defined in one of my helper modules from one of my controller classes. My Rails application uses the <code>helper</code> class method with the <code>:all</code> symbol as shown below:</p> <pre><code>class ApplicationController &lt; ActionContro...
[ { "answer_id": 453844, "author": "Milan Novota", "author_id": 26123, "author_profile": "https://Stackoverflow.com/users/26123", "pm_score": 2, "selected": false, "text": "<p>Helpers are to be used with templates, ie. views, not in controllers. That's why you can't access the method. If y...
2009/01/17
[ "https://Stackoverflow.com/questions/453762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1450/" ]
I'm getting a `NoMethodError` when trying to access a method defined in one of my helper modules from one of my controller classes. My Rails application uses the `helper` class method with the `:all` symbol as shown below: ``` class ApplicationController < ActionController::Base helper :all . . end ``` My unde...
`helper :all` makes all the helpers (yes, all of them) available in the views, it does not include them into the controller. If you wish to share some code between helper and controller, which is not very desirable because helper is UI code and controller is, well, controller code, you can either include the helper in...
453,765
<p>I have been playing with javascript arrays and I have run into, what I feel, are some inconsistencies, I hope someone can explain them for me.</p> <p>Lets start with this:</p> <pre><code> var myArray = [1, 2, 3, 4, 5]; document.write("Length: " + myArray.length + "&lt;br /&gt;"); for( var i in myArray){ documen...
[ { "answer_id": 453773, "author": "Christoph", "author_id": 48015, "author_profile": "https://Stackoverflow.com/users/48015", "pm_score": 5, "selected": true, "text": "<p>The keys of a JavaScript array are actually strings. For details and an implementation of a map type for arbitrary key...
2009/01/17
[ "https://Stackoverflow.com/questions/453765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48728/" ]
I have been playing with javascript arrays and I have run into, what I feel, are some inconsistencies, I hope someone can explain them for me. Lets start with this: ``` var myArray = [1, 2, 3, 4, 5]; document.write("Length: " + myArray.length + "<br />"); for( var i in myArray){ document.write( "myArray[" + i + "...
The keys of a JavaScript array are actually strings. For details and an implementation of a map type for arbitrary keys, check [this answer](https://stackoverflow.com/questions/368280/javascript-hashmap-equivalent#383540). --- To clarify and add to what Jason posted: JavaScript arrays are objects. Objects have proper...
453,769
<p>In C++, I have a <code>map&lt;string, string&gt;</code>, containing an unknown number of entries. How can I pass this to a Lua function, so that the Lua function can use the data as a table?</p>
[ { "answer_id": 453796, "author": "Doug Currie", "author_id": 33252, "author_profile": "https://Stackoverflow.com/users/33252", "pm_score": 3, "selected": false, "text": "<p>A couple options...</p>\n\n<ol>\n<li><p>Copy the map into a new Lua table, and pass the Lua table.</p></li>\n<li><p...
2009/01/17
[ "https://Stackoverflow.com/questions/453769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55934/" ]
In C++, I have a `map<string, string>`, containing an unknown number of entries. How can I pass this to a Lua function, so that the Lua function can use the data as a table?
if you want a real lua table: ``` lua_newtable(L); int top = lua_gettop(L); for (std::map::iterator it = mymap.begin(); it != mymap.end(); ++it) { const char* key = it->first.c_str(); const char* value = it->second.c_str(); lua_pushlstring(L, key, it->first.size()); lua_pushlstring(L, value, it->secon...
453,776
<p>I would like to create a Java program to listen for and respond to events captured by a thread in C.<br> Can someone explain how this can be achieved using JNI, or point me to online tutorials?</p> <p>Thank you.</p>
[ { "answer_id": 453796, "author": "Doug Currie", "author_id": 33252, "author_profile": "https://Stackoverflow.com/users/33252", "pm_score": 3, "selected": false, "text": "<p>A couple options...</p>\n\n<ol>\n<li><p>Copy the map into a new Lua table, and pass the Lua table.</p></li>\n<li><p...
2009/01/17
[ "https://Stackoverflow.com/questions/453776", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I would like to create a Java program to listen for and respond to events captured by a thread in C. Can someone explain how this can be achieved using JNI, or point me to online tutorials? Thank you.
if you want a real lua table: ``` lua_newtable(L); int top = lua_gettop(L); for (std::map::iterator it = mymap.begin(); it != mymap.end(); ++it) { const char* key = it->first.c_str(); const char* value = it->second.c_str(); lua_pushlstring(L, key, it->first.size()); lua_pushlstring(L, value, it->secon...
453,784
<p>I am trying to remove javascript comments (<code>//</code> and <code>/**/</code>) from sting with C#. Does anyone have RegEx for it. I am reading list of javascript files then append them to string and trying to clean javascript code and make light to load. Bellow you will find one of the RegEx that works fine with ...
[ { "answer_id": 453794, "author": "Marko Dumic", "author_id": 5817, "author_profile": "https://Stackoverflow.com/users/5817", "pm_score": 3, "selected": false, "text": "<p>If you want to minify Javascript files (\"make it light to load\"), why not try <a href=\"http://www.crockford.com/ja...
2009/01/17
[ "https://Stackoverflow.com/questions/453784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56248/" ]
I am trying to remove javascript comments (`//` and `/**/`) from sting with C#. Does anyone have RegEx for it. I am reading list of javascript files then append them to string and trying to clean javascript code and make light to load. Bellow you will find one of the RegEx that works fine with `/* */` comments but I ne...
If you want to minify Javascript files ("make it light to load"), why not try [JSMin by Douglas Crockford](http://www.crockford.com/javascript/jsmin.html)? There is link to c# implementation at the bottom of the page (<http://www.crockford.com/javascript/jsmin.cs>)
453,802
<p>Let say we have a Wordlist with words </p> <p>What i want to is to Genate Them to MD5 Hashes. (Have a 30gb Wordlist, i want to make All of they to MD5) I dont care which language.</p> <p>This say I have The Word "Test" in the wordlist So i want it in this format : </p> <pre><code>test:098f6bcd4621d373cade4e8326...
[ { "answer_id": 453815, "author": "Bombe", "author_id": 43582, "author_profile": "https://Stackoverflow.com/users/43582", "pm_score": 2, "selected": false, "text": "<p>bash ftw! \\o/</p>\n\n<pre><code>while read word; do\n echo -n $word | md5sum -1 | cut -f 1 -d \" \"\ndone &lt; wordli...
2009/01/17
[ "https://Stackoverflow.com/questions/453802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56206/" ]
Let say we have a Wordlist with words What i want to is to Genate Them to MD5 Hashes. (Have a 30gb Wordlist, i want to make All of they to MD5) I dont care which language. This say I have The Word "Test" in the wordlist So i want it in this format : ``` test:098f6bcd4621d373cade4e832627b4f6 ``` 098f6bcd4621d37...
bash ftw! \o/ ``` while read word; do echo -n $word | md5sum -1 | cut -f 1 -d " " done < wordlist ```
453,808
<p>I'm trying to use the PYTHONSTARTUP environmental variable. I set it to be "c:\python25\pythonstartup.py" in My Computer --> Advanced etc., and it doesn't seem to work.</p> <p>Opening IDLE doesn't run the script, although it recognized the variable:</p> <pre><code>&gt;&gt;&gt; import os &gt;&gt;&gt; os.environ['PY...
[ { "answer_id": 453819, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 4, "selected": true, "text": "<p><a href=\"http://docs.python.org/using/cmdline.html\" rel=\"noreferrer\">The documentation</a> says that PYTHONSTARTUP ...
2009/01/17
[ "https://Stackoverflow.com/questions/453808", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54248/" ]
I'm trying to use the PYTHONSTARTUP environmental variable. I set it to be "c:\python25\pythonstartup.py" in My Computer --> Advanced etc., and it doesn't seem to work. Opening IDLE doesn't run the script, although it recognized the variable: ``` >>> import os >>> os.environ['PYTHONSTARTUP'] 'c:\\python25\\pythonstar...
[The documentation](http://docs.python.org/using/cmdline.html) says that PYTHONSTARTUP is only run for interactive sessions. I'm not sure how IDLE runs the Python interpreter, but it could be interfering. Instead, try running `python` directly from a command prompt, rather than from clicking on an icon.
453,820
<p>I'm trying to use protobuf in a C# project, using protobuf-net, and am wondering what is the best way to organise this into a Visual Studio project structure.</p> <p>When manually using the protogen tool to generate code into C#, life seems easy but it doesn't feel right.</p> <p>I'd like the .proto file to be cons...
[ { "answer_id": 453832, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "<p>Calling a pre-build step but using project variables (e.g. <code>$(ProjectPath)</code>) to create absolute filenames ...
2009/01/17
[ "https://Stackoverflow.com/questions/453820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7093/" ]
I'm trying to use protobuf in a C# project, using protobuf-net, and am wondering what is the best way to organise this into a Visual Studio project structure. When manually using the protogen tool to generate code into C#, life seems easy but it doesn't feel right. I'd like the .proto file to be considered to be the ...
As an extension of Shaun's code, I am pleased to announce that protobuf-net now has Visual Studio integration by way of a Custom Tool. The msi installer is available from the [project page](http://code.google.com/p/protobuf-net/). More complete information here: [protobuf-net; now with added Orcas](http://marcgravell.b...
453,849
<p>I am using parameterized queries in my C# code to interact with an Oracle database. What can I do to log the statements in a more readable fashion?</p> <p>Suppose I have a parameterized query like:</p> <pre><code>INSERT INTO PERSON (ID, NAME, BIRTHDATE) VALUES (:id, :name, :birthdate) </code></pre> <p>Ideally I w...
[ { "answer_id": 453889, "author": "Geoff", "author_id": 55487, "author_profile": "https://Stackoverflow.com/users/55487", "pm_score": 2, "selected": false, "text": "<p>The trouble with trying to store this as a runnable statement for later use is that the parameter version runs differentl...
2009/01/17
[ "https://Stackoverflow.com/questions/453849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53881/" ]
I am using parameterized queries in my C# code to interact with an Oracle database. What can I do to log the statements in a more readable fashion? Suppose I have a parameterized query like: ``` INSERT INTO PERSON (ID, NAME, BIRTHDATE) VALUES (:id, :name, :birthdate) ``` Ideally I would like to see the log entry wi...
Maybe it's worth looking at the way its done in the NHibernate [source](https://nhibernate.svn.sourceforge.net/svnroot/nhibernate/trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs). Find the function called "GetCommandLogString(IDbCommand command)" which you could almost copy/paste :p ``` protected string Ge...
453,868
<p>I have a VB.NET MDI WinForms app. My users have been complaining about form creep (as they call it), this is where each time you open a specific form within the main MDI window it opens slightly below and to the right of the location it loaded previously - i.e. it starts in the top left of the window and works its w...
[ { "answer_id": 453922, "author": "psant", "author_id": 56020, "author_profile": "https://Stackoverflow.com/users/56020", "pm_score": 0, "selected": false, "text": "<p>Regardless of the language used, the cause is the same. When you open the first MDI window, the starting point is 0,0 re...
2009/01/17
[ "https://Stackoverflow.com/questions/453868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20048/" ]
I have a VB.NET MDI WinForms app. My users have been complaining about form creep (as they call it), this is where each time you open a specific form within the main MDI window it opens slightly below and to the right of the location it loaded previously - i.e. it starts in the top left of the window and works its way ...
Try `frmPurchaseInvoiceSelect.StartPosition = FromStartPosition.CenterParent` to always start in the centre of the Mdi parent. There are a few options but it depends on where you would like the form to start. I haven't tried it but: ``` frmPurchaseInvoiceSelect.Location = windowPoint frmPurchaseInvoiceSelect.Size...
453,881
<p>Any <strong>code-analysis</strong> or "reverse-engineering" tool that can do either of these?:</p> <ul> <li>Calculate which classes are <strong>sub-classes</strong> of which classes</li> <li>Calculate which classes <strong>instantiate</strong> which classes -- <em>(like <strong><a href="http://msdn.microsoft.com/en...
[ { "answer_id": 453913, "author": "earlNameless", "author_id": 27107, "author_profile": "https://Stackoverflow.com/users/27107", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://www.doxygen.nl/\" rel=\"nofollow noreferrer\">Doxygen</a> + <a href=\"http://www.graphviz.org/\" ...
2009/01/17
[ "https://Stackoverflow.com/questions/453881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41021/" ]
Any **code-analysis** or "reverse-engineering" tool that can do either of these?: * Calculate which classes are **sub-classes** of which classes * Calculate which classes **instantiate** which classes -- *(like **[VS Class Designer](http://msdn.microsoft.com/en-us/library/aa288743.aspx)**)* * Calculate which functions...
> > Calculate which functions call which functions > > > NDepend can produce some useful methods or class **call graph** like for example the screenshot below (image full size [here](http://www.ndepend.com/Res/DiagramBoxAndArrowGraphBig.jpg)) *Disclaimer: I am one of the developers of the tool* ![NDepend Methods...
453,884
<p>I have a win form UI that looks like a typical calculator. Naturally I do not want to rewrite the same logic for every single numeric button(0-9). I want to be able to know which button was clicked so I can perform calculations based on it's text property. Should I just make a method that accepts the button object a...
[ { "answer_id": 453898, "author": "earlNameless", "author_id": 27107, "author_profile": "https://Stackoverflow.com/users/27107", "pm_score": 2, "selected": false, "text": "<p>When specifying the event handler, you can register the same function to handle multiple events (if in VS.Net, go ...
2009/01/17
[ "https://Stackoverflow.com/questions/453884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56256/" ]
I have a win form UI that looks like a typical calculator. Naturally I do not want to rewrite the same logic for every single numeric button(0-9). I want to be able to know which button was clicked so I can perform calculations based on it's text property. Should I just make a method that accepts the button object as a...
The typical signature of an event handler is `void EventHandler(object sender, EventArgs e)`. The important part there is the `object sender`. This is the object that fired the event. In the case of a `Button`'s click event, the sender will be that `Button`. ``` void digitButton_Click(object sender, EventArgs e) { ...
453,896
<p>I need to profile a java application launched by the JNI invocation API from a C application, and naturally the TPTP tools seemed like a good place to start. However, I can start the application, but I have no idea how to connect to it for profiling. I realize this falls into the 'dumb newbie' bucket, but I really...
[ { "answer_id": 453898, "author": "earlNameless", "author_id": 27107, "author_profile": "https://Stackoverflow.com/users/27107", "pm_score": 2, "selected": false, "text": "<p>When specifying the event handler, you can register the same function to handle multiple events (if in VS.Net, go ...
2009/01/17
[ "https://Stackoverflow.com/questions/453896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23309/" ]
I need to profile a java application launched by the JNI invocation API from a C application, and naturally the TPTP tools seemed like a good place to start. However, I can start the application, but I have no idea how to connect to it for profiling. I realize this falls into the 'dumb newbie' bucket, but I really am k...
The typical signature of an event handler is `void EventHandler(object sender, EventArgs e)`. The important part there is the `object sender`. This is the object that fired the event. In the case of a `Button`'s click event, the sender will be that `Button`. ``` void digitButton_Click(object sender, EventArgs e) { ...
453,925
<p>I'm using Spring Security to secure a webapp. The URLs are secured like this:</p> <pre class="lang-xml prettyprint-override"><code>&lt;security:http entry-point-ref="authenticationEntryPoint"&gt; &lt;security:intercept-url pattern="/" access="ROLE_ANONYMOUS" /&gt; &lt;security:intercept-url pattern="/assets/**/...
[ { "answer_id": 454047, "author": "Andrzej Doyle", "author_id": 45664, "author_profile": "https://Stackoverflow.com/users/45664", "pm_score": 2, "selected": false, "text": "<p>Don't forget that what actually happens when deciding whether to allow access is that the URL and existing authen...
2009/01/17
[ "https://Stackoverflow.com/questions/453925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50175/" ]
I'm using Spring Security to secure a webapp. The URLs are secured like this: ```xml <security:http entry-point-ref="authenticationEntryPoint"> <security:intercept-url pattern="/" access="ROLE_ANONYMOUS" /> <security:intercept-url pattern="/assets/**/*" access="ROLE_ANONYMOUS" /> ... <security:intercept-url pa...
Don't forget that what actually happens when deciding whether to allow access is that the URL and existing authentication is passed through a series of [AccessDecisionVoter](http://static.springframework.org/spring-security/site/apidocs/org/springframework/security/vote/AccessDecisionVoter.html)s, one of the default of...
453,926
<p>I would like to use a transparent png file on a silverlight button. In addition I would like the button itself to be transparent so the background (behind the button) shows through. I find that if I set the opacity of the button it also affects the image. I don't want the entire image to be transparent - just the tr...
[ { "answer_id": 455708, "author": "Shawn Wildermuth", "author_id": 40125, "author_profile": "https://Stackoverflow.com/users/40125", "pm_score": 3, "selected": true, "text": "<p>Silverlight supports png transparency. This works:</p>\n\n<pre><code>&lt;UserControl x:Class=\"SilverlightAppl...
2009/01/17
[ "https://Stackoverflow.com/questions/453926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18106/" ]
I would like to use a transparent png file on a silverlight button. In addition I would like the button itself to be transparent so the background (behind the button) shows through. I find that if I set the opacity of the button it also affects the image. I don't want the entire image to be transparent - just the trans...
Silverlight supports png transparency. This works: ``` <UserControl x:Class="SilverlightApplication17.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="400" Height="300"> <Grid x:Name="LayoutRoot" Background="Green"> <Button Width="2...
453,964
<p>I'm trying to learn a little more on vectormath through writing a simple ray tracer and I've been doing some reading on it, but what I haven't been able to find is how to determine the direction of the primary rays. This sounds like a simple problem and probably is, but with my current knowledge I haven't been able ...
[ { "answer_id": 453988, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 2, "selected": true, "text": "<p>EDIT: Here's some code, which is substantially reduced from that originally posted because it omits the creation of a view...
2009/01/17
[ "https://Stackoverflow.com/questions/453964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to learn a little more on vectormath through writing a simple ray tracer and I've been doing some reading on it, but what I haven't been able to find is how to determine the direction of the primary rays. This sounds like a simple problem and probably is, but with my current knowledge I haven't been able to ...
EDIT: Here's some code, which is substantially reduced from that originally posted because it omits the creation of a viewMatrix. That was only needed for some some scanline rendering and wasn't used for ray-tracing. The hard work is the lookat() function, particularly the creation of the 'up' and 'right' vectors. The...
453,967
<p>I am an experienced developer new to python, and still catching myself writing correct but unpythonic code. I thought it might be enlightening and entertaining to see small examples of python code people have written that in some way clashes with the generally preffered way of doing things. </p> <p>I'm interested i...
[ { "answer_id": 453974, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>I have been doing lots of python for years, and I prefer the more verbose first example to the more \"pythonic\" example.</...
2009/01/17
[ "https://Stackoverflow.com/questions/453967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56135/" ]
I am an experienced developer new to python, and still catching myself writing correct but unpythonic code. I thought it might be enlightening and entertaining to see small examples of python code people have written that in some way clashes with the generally preffered way of doing things. I'm interested in code you...
Some unpythonic habits that one could inherit from C-like languages: 1) The unnecessary semicolon: ``` printf "Hello world"; ``` 2) Unnecessary indexes: ``` # Bad for i in range(len(myList)): print myList[i] # Good for item in myList: print item ```
453,975
<p>So I'm trying to build a script that automagically prepends valid column names with its appropriate table prefix (e.g. "t." or "r.")</p> <pre><code>$t_columns = array('id', 'name', 'label'); $r_columns = array('related_value'); </code></pre> <p>INPUT:</p> <pre><code>id &gt; 1 AND (name = 'Hello' OR label IN ('Wor...
[ { "answer_id": 454026, "author": "Henrik Paul", "author_id": 2238, "author_profile": "https://Stackoverflow.com/users/2238", "pm_score": 1, "selected": false, "text": "<p>After a few seconds' thinking, here's how I'd tackle it:</p>\n\n<p>Walk through the string, char by char, looking for...
2009/01/17
[ "https://Stackoverflow.com/questions/453975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32881/" ]
So I'm trying to build a script that automagically prepends valid column names with its appropriate table prefix (e.g. "t." or "r.") ``` $t_columns = array('id', 'name', 'label'); $r_columns = array('related_value'); ``` INPUT: ``` id > 1 AND (name = 'Hello' OR label IN ('World', 'Planet name AND label')) AND (rela...
This can be done in a lot of ways, and also using regex. I'd personally use an array approach. First of all, I'd define the mangling table this way: ``` $table = array( 'id' => 't.id', 'name' => 't.name', 'label' => 't.label', 'related_value' => 'r.related_value' ); ``` This will make a lot easier th...
453,989
<p>This is not a technical question, but given that there are a few iPhone developers on here I figured I'd ask. Are there design firms advertising services for designing custom iPhone icons?</p>
[ { "answer_id": 454027, "author": "Gordon Wilson", "author_id": 23071, "author_profile": "https://Stackoverflow.com/users/23071", "pm_score": 0, "selected": false, "text": "<p>A quick google found <a href=\"http://www.softfacade.com/\" rel=\"nofollow noreferrer\">SoftFacade</a> and <a hre...
2009/01/17
[ "https://Stackoverflow.com/questions/453989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36609/" ]
This is not a technical question, but given that there are a few iPhone developers on here I figured I'd ask. Are there design firms advertising services for designing custom iPhone icons?
I'm sure that you can find plenty on the web, just google it. [Icon Factory](http://iconfactory.com/design/) and [IconShock](http://www.iconshock.com/professional-icons.php) are one of my favorites, but there are individuals that can make you what you need for a price, **just ask them**, take a look for example at the...
454,053
<p>I have a database that has a vessel pressure that is trended every 30 seconds. I would like to be able to retrieve a recording at a specific time of day for a number of days in the past. I am not able to base this on the server as a Stored Procedure or a View – I only have read access. I have created a routine that ...
[ { "answer_id": 454111, "author": "Allain Lalonde", "author_id": 2443, "author_profile": "https://Stackoverflow.com/users/2443", "pm_score": 0, "selected": false, "text": "<p>Couldn't you do this more efficiently by converting the datetime into a unixtime number and modding it to give you...
2009/01/17
[ "https://Stackoverflow.com/questions/454053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54009/" ]
I have a database that has a vessel pressure that is trended every 30 seconds. I would like to be able to retrieve a recording at a specific time of day for a number of days in the past. I am not able to base this on the server as a Stored Procedure or a View – I only have read access. I have created a routine that wor...
I've seen quite a few tricks for converting a DATETIME into "just a time". Infact where I work there was quite some time spent finding the fastest. What people seem to forget is that "shortest code" is not always fastest, and often includes Implicit type conversions hidden away. The fastest we came up with is... DATEA...
454,104
<p>I have the following script:</p> <pre><code>if (Object.isUndefined(Axent)) { var Axent = { } } Axent.SelfLabeledInput = Class.create({ initialize: function() { var labelSelector = arguments[0] || 'label'; $$(labelSelector).findAll(function(l) {return (l.readAttribute('for') !== null)}).each(function(l){ ...
[ { "answer_id": 454254, "author": "meouw", "author_id": 12161, "author_profile": "https://Stackoverflow.com/users/12161", "pm_score": 0, "selected": false, "text": "<p>You don't have to worry, labels won't get submitted.</p>\n\n<p>This script will remove the labels from the DOM on submit ...
2009/01/17
[ "https://Stackoverflow.com/questions/454104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have the following script: ``` if (Object.isUndefined(Axent)) { var Axent = { } } Axent.SelfLabeledInput = Class.create({ initialize: function() { var labelSelector = arguments[0] || 'label'; $$(labelSelector).findAll(function(l) {return (l.readAttribute('for') !== null)}).each(function(l){ l.hide()...
I finally got it to work! Here's the final code if someone else wants to run it: ``` if (Object.isUndefined(Axent)) { var Axent = { } } Axent.SelfLabeledInput = Class.create({ initialize: function() { var labelSelector = arguments[0] || 'label'; $$(labelSelector).findAll(function(l) {return (l.readAttribute('f...
454,113
<p>I'm making a simple test object-oriented program to try and help me get to grips with OOP. I've got an ICommand inteface which has the method Run(params object[] parameters) and I have various classes that use that interface and implement their own versions of run. Each class also has a name property which says what...
[ { "answer_id": 454123, "author": "Johnno Nolan", "author_id": 1116, "author_profile": "https://Stackoverflow.com/users/1116", "pm_score": 2, "selected": false, "text": "<p>Store all your classes in a generic list of ICommand , override ToString() with the name of your command and apply t...
2009/01/17
[ "https://Stackoverflow.com/questions/454113", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1912/" ]
I'm making a simple test object-oriented program to try and help me get to grips with OOP. I've got an ICommand inteface which has the method Run(params object[] parameters) and I have various classes that use that interface and implement their own versions of run. Each class also has a name property which says what th...
Store all your classes in a generic list of ICommand , override ToString() with the name of your command and apply the contents of the list to your listbox. ``` var commandlist = new List<ICommand>(); commandList.add(new Command("Run")); commandList.add(new Command("Walk")); commandList.add(new Command("Crawl")); ```
454,143
<p>When running on an xhtml page, xpath doesn't seem to return any results.</p> <pre><code>var result = document.evaluate( "//a/img", document.body, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null ); </code></pre> <p>For example returns an empty result set. What's the problem here, and how do I fix it?</p>
[ { "answer_id": 454263, "author": "Azat Razetdinov", "author_id": 9649, "author_profile": "https://Stackoverflow.com/users/9649", "pm_score": 4, "selected": true, "text": "<p>xhtml elements are not in null namespace, so you have to pass a <a href=\"https://developer.mozilla.org/en/Introdu...
2009/01/17
[ "https://Stackoverflow.com/questions/454143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43904/" ]
When running on an xhtml page, xpath doesn't seem to return any results. ``` var result = document.evaluate( "//a/img", document.body, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null ); ``` For example returns an empty result set. What's the problem here, and how do I fix it?
xhtml elements are not in null namespace, so you have to pass a [namespace resolver](https://developer.mozilla.org/en/Introduction_to_using_XPath_in_JavaScript#Implementing_a_User_Defined_Namespace_Resolver) to the method: ``` function resolver(prefix) { return prefix === 'x' ? 'http://www.w3.org/1999/xhtml' : nul...
454,147
<p>I'm using Visual Studio 2008 to write an installation, and I'm a completely new to installations. I've created an installation and successfully written some custom actions using a C# assembly. One action sets a RunOnce registry value, and now I need to prompt the user to reboot when the installation finishes, but I ...
[ { "answer_id": 454157, "author": "Ray Hayes", "author_id": 7093, "author_profile": "https://Stackoverflow.com/users/7093", "pm_score": 0, "selected": false, "text": "<p>If you are implementing your installer using <a href=\"http://en.wikipedia.org/wiki/WiX\" rel=\"nofollow noreferrer\">W...
2009/01/17
[ "https://Stackoverflow.com/questions/454147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7893/" ]
I'm using Visual Studio 2008 to write an installation, and I'm a completely new to installations. I've created an installation and successfully written some custom actions using a C# assembly. One action sets a RunOnce registry value, and now I need to prompt the user to reboot when the installation finishes, but I hav...
Thanks. I ended up using a post-build event to run a batch file with the following command. The hard part was tracking down WiRunSQL.vbs, which was in the ["Windows SDK Components for Windows Installer Developers"](http://msdn.microsoft.com/en-us/library/aa370834(VS.85).aspx) download. ``` cscript "C:\Program Files\Mi...
454,163
<p>The responses I've got to <a href="https://stackoverflow.com/questions/454113/c-polymorphism-how-not-to-hardcode-types">this question</a> have solved the problem I had in that question, but I'm wondering whether it's possible to extend it a bit. For example, if I were to have third parties contributing commands to t...
[ { "answer_id": 454172, "author": "Tom Anderson", "author_id": 13502, "author_profile": "https://Stackoverflow.com/users/13502", "pm_score": 1, "selected": false, "text": "<p>You can load each assembly in a directory, iterate through each exposed class in the assembly, and then check for ...
2009/01/17
[ "https://Stackoverflow.com/questions/454163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1912/" ]
The responses I've got to [this question](https://stackoverflow.com/questions/454113/c-polymorphism-how-not-to-hardcode-types) have solved the problem I had in that question, but I'm wondering whether it's possible to extend it a bit. For example, if I were to have third parties contributing commands to this system, wo...
Yes. ``` Assembly commandAssembly = Assembly.Load("some/path") var commands = new List<ICommand>(); foreach (Type type in commandAssembly.GetTypes()) { if (type.GetInterface(typeof(ICommand).FullName) != null) { commands.Add((ICommand)Activator.CreateInstance(type)); } } ``` However, you wil...
454,174
<p>I'm writing some db utility scripts, and one of the tasks I need to do is rebuild the data only, but leave the schema intact. What is the easiest way to automate this from the command-line using bash and the mysql tools (no php, etc)?</p> <p>Update: I'd like the solution to handle all tables in one command, and if ...
[ { "answer_id": 454180, "author": "UnkwnTech", "author_id": 115, "author_profile": "https://Stackoverflow.com/users/115", "pm_score": 7, "selected": true, "text": "<pre><code>TRUNCATE tableName;\n</code></pre>\n\n<p>This will empty the contents of the table.</p>\n\n<p>Edit in response to ...
2009/01/17
[ "https://Stackoverflow.com/questions/454174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2567/" ]
I'm writing some db utility scripts, and one of the tasks I need to do is rebuild the data only, but leave the schema intact. What is the easiest way to automate this from the command-line using bash and the mysql tools (no php, etc)? Update: I'd like the solution to handle all tables in one command, and if possible, ...
``` TRUNCATE tableName; ``` This will empty the contents of the table. Edit in response to the Q edit: It seems from my quick test that you will have to do at least 2 queries as it seems that "show tables" cannot be used as a sub query, I don't know how to do this in bash so here is a PHP example, hopefully it will ...
454,182
<p>I have a Python interface of a graph library written in C - igraph (the name of library). My need is to invoke the python modules pertaining to this graph library from Java code. It goes like this, the core of library is in c. This core has been imported into Python and interfaces to the functions embedded in core a...
[ { "answer_id": 454211, "author": "Igal Serban", "author_id": 25737, "author_profile": "https://Stackoverflow.com/users/25737", "pm_score": 2, "selected": false, "text": "<p>Never tried it. But I recently <a href=\"http://www.miketec.org/serendipity/index.php?/archives/9-Sure,-Change-Jobs...
2009/01/17
[ "https://Stackoverflow.com/questions/454182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36813/" ]
I have a Python interface of a graph library written in C - igraph (the name of library). My need is to invoke the python modules pertaining to this graph library from Java code. It goes like this, the core of library is in c. This core has been imported into Python and interfaces to the functions embedded in core are ...
Never tried it. But I recently [stumbled](http://www.miketec.org/serendipity/index.php?/archives/9-Sure,-Change-Jobs!.html) on a [project named Jepp](http://jepp.sourceforge.net/) that may be of interest to you. > > Jepp embeds CPython in Java. It is safe to use in a heavily threaded environment, it is quite fast and...
454,202
<p>There was <a href="https://stackoverflow.com/questions/7477/autosizing-textarea">another thread about this</a>, which I've tried. But there is one problem: the <code>textarea</code> doesn't shrink if you delete the content. I can't find any way to shrink it to the correct size - the <code>clientHeight</code> value c...
[ { "answer_id": 454409, "author": "bobince", "author_id": 18936, "author_profile": "https://Stackoverflow.com/users/18936", "pm_score": 4, "selected": false, "text": "<p>You're using the higher value of the current clientHeight and the content scrollHeight. When you make the scrollHeight ...
2009/01/17
[ "https://Stackoverflow.com/questions/454202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37947/" ]
There was [another thread about this](https://stackoverflow.com/questions/7477/autosizing-textarea), which I've tried. But there is one problem: the `textarea` doesn't shrink if you delete the content. I can't find any way to shrink it to the correct size - the `clientHeight` value comes back as the full size of the `t...
This works for me (Firefox 3.6/4.0 and Chrome 10/11): ```js var observe; if (window.attachEvent) { observe = function (element, event, handler) { element.attachEvent('on'+event, handler); }; } else { observe = function (element, event, handler) { element.addEventListener(event, hand...
454,218
<p>I am relatively new to C# and each time I begin to work on a C# project (I only worked on nearly mature projects in C#) I wonder why there are no inner classes?</p> <p>Maybe I don't understand their goal. To me, inner classes -- at least private inner classes -- look a lot like "inner procedures" in Pascal / Modula...
[ { "answer_id": 454233, "author": "Tom Anderson", "author_id": 13502, "author_profile": "https://Stackoverflow.com/users/13502", "pm_score": 2, "selected": false, "text": "<p>For me personally I only create private inner classes if I need to create in-process collections of an object that...
2009/01/17
[ "https://Stackoverflow.com/questions/454218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54783/" ]
I am relatively new to C# and each time I begin to work on a C# project (I only worked on nearly mature projects in C#) I wonder why there are no inner classes? Maybe I don't understand their goal. To me, inner classes -- at least private inner classes -- look a lot like "inner procedures" in Pascal / Modula-2 / Ada :...
Nested classes (probably best to avoid the word "inner" as nested classes in C# are somewhat different to inner classes in Java) can indeed be very useful. One pattern which hasn't been mentioned is the "better enum" pattern - which can be even more flexible than the one in Java: ``` public abstract class MyCleverEnu...
454,250
<p>I have a list of non-overlaping ranges (ranges of numbers, e.g. 500-1000, 1001-1200 .. etc), is there an elegant and fast way to do lookup by only passing a number? I could use List.BinarySearch() or Array.BinarySearch() but I have to pass the type of the range object (Array.BinarySearch(T[], T)), I can pass a dummy...
[ { "answer_id": 454300, "author": "Ria", "author_id": 53218, "author_profile": "https://Stackoverflow.com/users/53218", "pm_score": 1, "selected": false, "text": "<p>If you have .Net 3.5 or above, try</p>\n\n<pre><code>foundRange = yourList.Where(range =› range.BottomNumber ‹= searchInt &...
2009/01/17
[ "https://Stackoverflow.com/questions/454250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/676066/" ]
I have a list of non-overlaping ranges (ranges of numbers, e.g. 500-1000, 1001-1200 .. etc), is there an elegant and fast way to do lookup by only passing a number? I could use List.BinarySearch() or Array.BinarySearch() but I have to pass the type of the range object (Array.BinarySearch(T[], T)), I can pass a dummy ra...
Three options: * Create a dummy Range and suck it up. Urgh. * Hand-craft a binary search just for this case. Not too bad. * Generalise the binary search for any IList and a TValue, given an IRangeComparer. I'm not wild on the name "TRange" here - we're not necessarily talking about ranges, but just finding the right p...
454,252
<p>In</p> <pre><code>&lt;meta http-equiv="refresh" content="n"&gt; </code></pre> <p>Is there a maximum value for n? Is there a number large enough to where the browser, or whatever is counting down, will fail to refresh after n seconds?</p>
[ { "answer_id": 454264, "author": "Salty", "author_id": 50548, "author_profile": "https://Stackoverflow.com/users/50548", "pm_score": 4, "selected": true, "text": "<p>No, there is not. At least not within reasonable terms...I'm sure there's a limit to an HTML attribute, but the amount of ...
2009/01/17
[ "https://Stackoverflow.com/questions/454252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55619/" ]
In ``` <meta http-equiv="refresh" content="n"> ``` Is there a maximum value for n? Is there a number large enough to where the browser, or whatever is counting down, will fail to refresh after n seconds?
No, there is not. At least not within reasonable terms...I'm sure there's a limit to an HTML attribute, but the amount of numbers you could fit into that limit would cause the refresh to take so long you'd probably fall asleep. :P
454,258
<p>I have just begun adding a REST API on a rails app, and since I only wanted to expose a couple controller/actions, I added a method to ApplicationController:</p> <pre><code> def http_basic_authentication if request.format == Mime::XML authenticate_or_request_with_http_basic do |username, api_key| ...
[ { "answer_id": 454346, "author": "Sophie Alpert", "author_id": 49485, "author_profile": "https://Stackoverflow.com/users/49485", "pm_score": 1, "selected": false, "text": "<p>Possibly this would be cleaner:</p>\n\n<pre><code>self.current_user = Account.find_by_api_key(api_key).user\n</co...
2009/01/17
[ "https://Stackoverflow.com/questions/454258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43962/" ]
I have just begun adding a REST API on a rails app, and since I only wanted to expose a couple controller/actions, I added a method to ApplicationController: ``` def http_basic_authentication if request.format == Mime::XML authenticate_or_request_with_http_basic do |username, api_key| self.current_...
Possibly this would be cleaner: ``` self.current_user = Account.find_by_api_key(api_key).user ```
454,270
<p>I am currently saving a .net ( c# ) usercontrol to the disk as a XML file by saving each property as an element in the xml document. The file is used for later recreation of the controls at runtime. I am wondering if it is possible or better to save the control as a binary file. There would be many controls so I gue...
[ { "answer_id": 454363, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "<p>Winforms controls don't serialize especially well, and you might have a lot of difficulty getting the base-classes...
2009/01/17
[ "https://Stackoverflow.com/questions/454270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54009/" ]
I am currently saving a .net ( c# ) usercontrol to the disk as a XML file by saving each property as an element in the xml document. The file is used for later recreation of the controls at runtime. I am wondering if it is possible or better to save the control as a binary file. There would be many controls so I guess ...
We had to do this for a data-driven application where a user could create persistable views. We did an XML version to start but moved to using BinaryFormatter and the ISerializable interface as this allows us to control exactly what gets persisted and which constructors to use. For the controls we actually persisted th...
454,271
<p>This is a copy paste of a post i made on the processing forum (where i haven't got an answer so far) thought i might as well try here.</p> <p>Processing is a very cool way to draw stuff, specially for the webpages. Just as a reference <a href="http://processing.org" rel="nofollow noreferrer">http://processing.org</...
[ { "answer_id": 498800, "author": "Gerrit", "author_id": 5976, "author_profile": "https://Stackoverflow.com/users/5976", "pm_score": -1, "selected": false, "text": "<p>You can ask the user to calibrate the system, before use. It's not fully an answer to the question, but a sollution to th...
2009/01/17
[ "https://Stackoverflow.com/questions/454271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26004/" ]
This is a copy paste of a post i made on the processing forum (where i haven't got an answer so far) thought i might as well try here. Processing is a very cool way to draw stuff, specially for the webpages. Just as a reference <http://processing.org> Hey, i'm new to processing, i'm using it to make a flashless websi...
I'm not familiar with processing, but can't you just calculate the difference between the top left corner of the browser window and the top left corner of the canvas? i.e. (using jquery) ``` $(window).onresize = function() { //offset return position realive to the document. var offset = $('#canvas').offset(); wi...