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
316,488
<p>What is the best way to construct a bit mask in C with <code>m</code> set bits preceded by <code>k</code> unset bits, and followed by <code>n</code> unset bits:</p> <pre><code>00..0 11..1 00..0 k m n </code></pre> <p>For example, k=1, m=4, n=3 would result in the bit mask:</p> <pre><code>01111000 </code...
[ { "answer_id": 316493, "author": "Darius Bacon", "author_id": 27024, "author_profile": "https://Stackoverflow.com/users/27024", "pm_score": 6, "selected": true, "text": "<p>You can do:</p>\n<pre><code>~(~0 &lt;&lt; m) &lt;&lt; n\n</code></pre>\n" }, { "answer_id": 316494, "au...
2008/11/25
[ "https://Stackoverflow.com/questions/316488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1692070/" ]
What is the best way to construct a bit mask in C with `m` set bits preceded by `k` unset bits, and followed by `n` unset bits: ``` 00..0 11..1 00..0 k m n ``` For example, k=1, m=4, n=3 would result in the bit mask: ``` 01111000 ```
You can do: ``` ~(~0 << m) << n ```
316,508
<p>I am trying to write a JavaScript script to add to greasemonkey that adds a button after an element. The onClick for this button should copy the parents element text to the keyboard. I have seen plenty of examples that copy already selected text to the clipboard such as this:</p> <pre><code> &lt;SCRIPT LANGUAGE=...
[ { "answer_id": 316770, "author": "wimh", "author_id": 33499, "author_profile": "https://Stackoverflow.com/users/33499", "pm_score": 1, "selected": false, "text": "<p>Are you sure your example works? It does not in my browser. But take a look at the following page: <a href=\"http://www.je...
2008/11/25
[ "https://Stackoverflow.com/questions/316508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27657/" ]
I am trying to write a JavaScript script to add to greasemonkey that adds a button after an element. The onClick for this button should copy the parents element text to the keyboard. I have seen plenty of examples that copy already selected text to the clipboard such as this: ``` <SCRIPT LANGUAGE="JavaScript"> ...
If you took the time to read the full article, the author states this doesn't work for Firefox... Actually, I think it doesn't even work for IE, as it does nothing related to the clipboard! There is a technique using Flash, because by default, Firefox inhibits clipboard access for security reasons. Otherwise, th...
316,520
<p>I saw this signature on the ListView class:</p> <pre><code>public ListView..::.ListViewItemCollection Items { get; } </code></pre> <p>When I saw that, "What?!"</p> <p>I searched "dot dot colon colon dot" and "..::." on Google with no result.</p> <p><img src="https://i.stack.imgur.com/av0FO.png" alt="alt text"></...
[ { "answer_id": 316554, "author": "James Kirk", "author_id": 40537, "author_profile": "https://Stackoverflow.com/users/40537", "pm_score": 5, "selected": true, "text": "<p>That's not C#; that's JScript. In C#, it would be:</p>\n\n<p>public ListView.ListViewItemCollection Items { get; }</p...
2008/11/25
[ "https://Stackoverflow.com/questions/316520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11238/" ]
I saw this signature on the ListView class: ``` public ListView..::.ListViewItemCollection Items { get; } ``` When I saw that, "What?!" I searched "dot dot colon colon dot" and "..::." on Google with no result. ![alt text](https://i.stack.imgur.com/av0FO.png)
That's not C#; that's JScript. In C#, it would be: public ListView.ListViewItemCollection Items { get; } It's a little different because ListViewItemCollection is an inner class of ListView. I'm guessing that you saw this looking at [ListView.Items Property (System.Windows.Forms)](http://msdn.microsoft.com/en-us/lib...
316,524
<p>I wish to find all rows in a table where one column is a substring of another column.</p> <p>In other words, suppose I have a table (called people) with two columns: firstname and lastname, and I want to find all people like "rob robinowitz" and "jill bajillion".</p> <p>Is there a way to do something like "select ...
[ { "answer_id": 316539, "author": "Dmitry Khalatov", "author_id": 18174, "author_profile": "https://Stackoverflow.com/users/18174", "pm_score": 4, "selected": true, "text": "<p>You were close</p>\n\n<pre><code>select * from people where lastname like '%' + firstname + '%'\n</code></pre>\n...
2008/11/25
[ "https://Stackoverflow.com/questions/316524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31060/" ]
I wish to find all rows in a table where one column is a substring of another column. In other words, suppose I have a table (called people) with two columns: firstname and lastname, and I want to find all people like "rob robinowitz" and "jill bajillion". Is there a way to do something like "select \* from people wh...
You were close ``` select * from people where lastname like '%' + firstname + '%' ``` Alternative way (may be even faster) ``` select * from people where charindex(firstname,lastname)>0 ```
316,528
<p>Sounds easy, but I can't find where this built in class and others exists in the documentation. I use functions but want to know what there is on the OO side.</p>
[ { "answer_id": 316541, "author": "majelbstoat", "author_id": 38812, "author_profile": "https://Stackoverflow.com/users/38812", "pm_score": 2, "selected": false, "text": "<p>It's not a URL or anything, but you can get a fair idea using Reflection:</p>\n\n<pre><code>Reflection::export(new ...
2008/11/25
[ "https://Stackoverflow.com/questions/316528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10117/" ]
Sounds easy, but I can't find where this built in class and others exists in the documentation. I use functions but want to know what there is on the OO side.
It's not a URL or anything, but you can get a fair idea using Reflection: ``` Reflection::export(new ReflectionClass('DateTime')); Class [ class DateTime ] { - Constants [11] { Constant [ string ATOM ] { Y-m-d\TH:i:sP } Constant [ string COOKIE ] { l, d-M-y H:i:s T } Constant [ string ISO8601 ] { Y-m-...
316,532
<p>If I have code like this:</p> <pre><code> public XALServiceConfiguration CreateInstance() { var config = ConfigurationManager.GetSection(ConfigurationSectionName) as XALServiceConfiguration; if (config == null) throw new ConfigurationErrorsException("Configurat...
[ { "answer_id": 316538, "author": "Aaron Powell", "author_id": 11388, "author_profile": "https://Stackoverflow.com/users/11388", "pm_score": 0, "selected": false, "text": "<p>You could just catch the exception in a <code>try catch</code> statment and do an <code>Assert</code> in the catch...
2008/11/25
[ "https://Stackoverflow.com/questions/316532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13627/" ]
If I have code like this: ``` public XALServiceConfiguration CreateInstance() { var config = ConfigurationManager.GetSection(ConfigurationSectionName) as XALServiceConfiguration; if (config == null) throw new ConfigurationErrorsException("Configuration element 'x...
I think the other answers so far have missed the point of your question, which is how to *provoke* the exception. Using a static technique like this, you really can't easily do it - you'd have to have a way of injecting the particular configuration into your test. I seem to remember that the .NET configuration managem...
316,540
<p>I want add the new node as parent node of the old nodes in XML using C#. for example node have the following XMl file:</p> <pre><code>&lt;bookstore&gt; &lt;books&gt; &lt;author&gt; &lt;/author&gt; &lt;/books&gt; &lt;/bookstore&gt; </code></pre> <p>like that now I want add the new like below:</p>...
[ { "answer_id": 316561, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Don't have VS here so can't confirm that this works but something like this:</p>\n\n<pre><code>XmlDocument xd = new XmlDocu...
2008/11/25
[ "https://Stackoverflow.com/questions/316540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want add the new node as parent node of the old nodes in XML using C#. for example node have the following XMl file: ``` <bookstore> <books> <author> </author> </books> </bookstore> ``` like that now I want add the new like below: ``` <bookstore> <newnode> <books> <author> </aut...
Try this:- ``` XmlDocument doc = new XmlDocument(); doc.Load("BookStore.xml"); XmlElement newNode = doc.CreateElement("newnode"); doc.DocumentElement.AppendChild(newNode); newNode.AppendChild(doc.SelectSingleNode("/bookstore/books")); doc.Save("BookStore.xml"); ```
316,574
<p>Are there any command line interfaces to the DHCP settings in Mac OS X? I have found that inside System Profiler, the Network tab provides a lot of useful information, but I have not found any documentation about any command line equivalents.</p>
[ { "answer_id": 316598, "author": "Jason Coco", "author_id": 34218, "author_profile": "https://Stackoverflow.com/users/34218", "pm_score": -1, "selected": false, "text": "<p>You should look at:</p>\n\n<pre><code>ifconfig(8)\nnetstat(1)\nnetintro(4)\n</code></pre>\n\n<p>The most important ...
2008/11/25
[ "https://Stackoverflow.com/questions/316574", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2910/" ]
Are there any command line interfaces to the DHCP settings in Mac OS X? I have found that inside System Profiler, the Network tab provides a lot of useful information, but I have not found any documentation about any command line equivalents.
You may use ``` networksetup -listallnetworkservices networksetup -getinfo <networkservice> networksetup -setdhcp <networkservice> [clientid] ``` networkservice is something like Ethernet (all availabe listed by the first command)
316,581
<p>I have a batch file that does this.</p> <p>ECHO A41,35,0,a,1,1,N,"Mr ZACHARY KAPLAN">> test.txt </p> <p>There are about 30k similar lines. It takes the batch file about 5 hours to run. </p> <p>Is there a way to speed this up?</p> <p>/Jeanre</p>
[ { "answer_id": 316589, "author": "Adam Davis", "author_id": 2915, "author_profile": "https://Stackoverflow.com/users/2915", "pm_score": 1, "selected": false, "text": "<p>Write a custom script or program to open the file test.txt once, and write all the data into it in one shot.</p>\n\n<p...
2008/11/25
[ "https://Stackoverflow.com/questions/316581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a batch file that does this. ECHO A41,35,0,a,1,1,N,"Mr ZACHARY KAPLAN">> test.txt There are about 30k similar lines. It takes the batch file about 5 hours to run. Is there a way to speed this up? /Jeanre
Try this: Put an `ECHO OFF` at the top of the batch file. Then change each line to: ``` ECHO A41,35,0,a,1,1,N,"Mr ZACHARY KAPLAN" ``` and call your batch file: mybatch.bat >> test.txt Edit the first line to remove the echo off print out.
316,582
<p>I want to pose a question such as:</p> <blockquote> <p>What is your name? Joe</p> </blockquote> <p>How would I accomplish this using <code>Console.WriteLine</code> to also wait for the response on that same line instead of it being broken into:</p> <blockquote> <p>What is your name?</p> <p>Joe</p> </blockquote>
[ { "answer_id": 316583, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 7, "selected": true, "text": "<p>Use <a href=\"https://learn.microsoft.com/en-us/dotnet/api/system.console.write?view=net-5.0\" rel=\"nofollow noreferr...
2008/11/25
[ "https://Stackoverflow.com/questions/316582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to pose a question such as: > > What is your name? Joe > > > How would I accomplish this using `Console.WriteLine` to also wait for the response on that same line instead of it being broken into: > > What is your name? > > > Joe > > >
Use [`Console.Write`](https://learn.microsoft.com/en-us/dotnet/api/system.console.write?view=net-5.0) instead, so there's no newline written: ``` Console.Write("What is your name? "); var name = Console.ReadLine(); ```
316,586
<p>How do i set up a subdomain w/o a TLD? i have this set under my main config</p> <pre><code>&lt;VirtualHost *:80&gt; ServerName bbs.67.777.777.777 #fake bc my server can easily be hacked ATM :( DocumentRoot /var/www/phpBB &lt;/VirtualHost&gt; </code></pre> <p>when i goto bbs.serveripaddress i get a Address ...
[ { "answer_id": 316595, "author": "Chris Kimpton", "author_id": 48310, "author_profile": "https://Stackoverflow.com/users/48310", "pm_score": 1, "selected": false, "text": "<p>I don't think that server name (bbs.67.777.777.777 ) will get you anywhere - unless you have it added to your hos...
2008/11/25
[ "https://Stackoverflow.com/questions/316586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do i set up a subdomain w/o a TLD? i have this set under my main config ``` <VirtualHost *:80> ServerName bbs.67.777.777.777 #fake bc my server can easily be hacked ATM :( DocumentRoot /var/www/phpBB </VirtualHost> ``` when i goto bbs.serveripaddress i get a Address Not Found error. if i put that above m...
You cannot have a subdomain with an IP address. The best way around this is to have a domain or a free subdomain (such as no-ip) to point at your IP address and create a ServerName for that. Remember to add the domain to your server DNS zones. or make a domain in your host files and use that.
316,590
<p>Suppose I want to count the lines of code in a project. If all of the files are in the same directory I can execute:</p> <pre><code>cat * | wc -l </code></pre> <p>However, if there are sub-directories, this doesn't work. For this to work cat would have to have a recursive mode. I suspect this might be a job for xa...
[ { "answer_id": 316602, "author": "chromakode", "author_id": 40508, "author_profile": "https://Stackoverflow.com/users/40508", "pm_score": 4, "selected": false, "text": "<p>Try using the <code>find</code> command, which recurses directories by default:</p>\n\n<p><code>find . -type f -exec...
2008/11/25
[ "https://Stackoverflow.com/questions/316590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39584/" ]
Suppose I want to count the lines of code in a project. If all of the files are in the same directory I can execute: ``` cat * | wc -l ``` However, if there are sub-directories, this doesn't work. For this to work cat would have to have a recursive mode. I suspect this might be a job for xargs, but I wonder if there...
First you do not need to use `cat` to count lines. This is an [antipattern called Useless Use of Cat](http://en.wikipedia.org/wiki/Cat_(Unix)#Useless_use_of_cat) (UUoC). To count lines in files in the current directory, use [`wc`](https://en.wikipedia.org/wiki/Wc_(Unix)): ``` wc -l * ``` Then the `find` command rec...
316,600
<p>I'm working on automating the configuration of several JBoss servers, which involves editing a substantial number of XML files.</p> <p>I'd like to script all these changes as much as possible. But the "standard" tools (sed, grep et al) do not work well with XML. Without necessarily resorting to a higher-level langu...
[ { "answer_id": 316628, "author": "mkoeller", "author_id": 33433, "author_profile": "https://Stackoverflow.com/users/33433", "pm_score": 1, "selected": false, "text": "<p>Typically I'll do this by writing a XSL stylesheet and invoking <a href=\"http://saxon.sourceforge.net/\" rel=\"nofoll...
2008/11/25
[ "https://Stackoverflow.com/questions/316600", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1428/" ]
I'm working on automating the configuration of several JBoss servers, which involves editing a substantial number of XML files. I'd like to script all these changes as much as possible. But the "standard" tools (sed, grep et al) do not work well with XML. Without necessarily resorting to a higher-level language, how c...
You'll find more answers in my [previous question](https://stackoverflow.com/questions/91791/grep-and-sed-equivalent-for-xml-command-line-processing "Grep and Sed Equivalent for XML"). [xmlstar](http://xmlstar.sourceforge.net/ "XMLStarlet tool collection") seems to be the most popular answer.
316,626
<p>I have a version resource in my resources in a C++ project which contains version number, copyright and build details. Is there an easy way to access this at run-time to populate my <em>help/about</em> dialog as I am currently maintaining seperate const values of this information. Ideally, the solution should work...
[ { "answer_id": 316633, "author": "Rob", "author_id": 9236, "author_profile": "https://Stackoverflow.com/users/9236", "pm_score": 3, "selected": false, "text": "<p>Something like this will give you raw access to the resource data and get you started:</p>\n\n<pre><code>HRSRC res = ::FindRe...
2008/11/25
[ "https://Stackoverflow.com/questions/316626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22564/" ]
I have a version resource in my resources in a C++ project which contains version number, copyright and build details. Is there an easy way to access this at run-time to populate my *help/about* dialog as I am currently maintaining seperate const values of this information. Ideally, the solution should work for Windows...
This is an edited version of my original answer. ``` bool GetProductAndVersion(CStringA & strProductName, CStringA & strProductVersion) { // get the filename of the executable containing the version resource TCHAR szFilename[MAX_PATH + 1] = {0}; if (GetModuleFileName(NULL, szFilename, MAX_PATH) == 0) {...
316,632
<p>What is the appropriate method to read arguments from command line? I've read of using strings args[] but I can't come to grasp the concept of how to do it properly.</p> <p>Example Commands:</p> <p>/animal dog -c white -s medium</p> <p>/car civic -c green -y 1999</p> <p>What would be the appropriate manner to re...
[ { "answer_id": 316638, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "<p>It depends on the complexity. If you only have a few options, a simple for/switch would suffice. If the options ar...
2008/11/25
[ "https://Stackoverflow.com/questions/316632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What is the appropriate method to read arguments from command line? I've read of using strings args[] but I can't come to grasp the concept of how to do it properly. Example Commands: /animal dog -c white -s medium /car civic -c green -y 1999 What would be the appropriate manner to read, 1. /thecommand 2. all the ...
It depends on the complexity. If you only have a few options, a simple for/switch would suffice. If the options are complex, you might want a class that allows you to map "-c" to "Color" etc. Examples (just the first 2 from google; not a specific recommendation) of this second approach are [here](http://www.codeproject...
316,649
<p>I am trying to use C# to parse CSV. I used regular expressions to find <code>","</code> and read string if my header counts were equal to my match count.</p> <p>Now this will not work if I have a value like:</p> <pre><code>"a",""b","x","y"","c" </code></pre> <p>then my output is:</p> <pre><code>'a' '"b' 'x' 'y"'...
[ { "answer_id": 316661, "author": "gtd", "author_id": 8376, "author_profile": "https://Stackoverflow.com/users/8376", "pm_score": 1, "selected": false, "text": "<p>In order to have a parseable CSV file, any double quotes inside a value need to be properly escaped somehow. The two standar...
2008/11/25
[ "https://Stackoverflow.com/questions/316649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to use C# to parse CSV. I used regular expressions to find `","` and read string if my header counts were equal to my match count. Now this will not work if I have a value like: ``` "a",""b","x","y"","c" ``` then my output is: ``` 'a' '"b' 'x' 'y"' 'c' ``` but what I want is: ``` 'a' '"b","x","y"' '...
CSV, when dealing with things like multi-line, quoted, different delimiters\* etc - can get trickier than you might think... perhaps consider a pre-rolled answer? I use [this](http://www.codeproject.com/KB/database/CsvReader.aspx), and it works very well. \*=remember that some locales use [tab] as the C in CSV...
316,673
<p>I have an app that is written in Swing, awt. I want to prevent users from pasting values into the textfields. is there any way to do this without using action listeners?</p>
[ { "answer_id": 316703, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>You may be able to override the <code>paste()</code> method in <code>JTextComponent</code>.</p>\n" }, { "answer_id"...
2008/11/25
[ "https://Stackoverflow.com/questions/316673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have an app that is written in Swing, awt. I want to prevent users from pasting values into the textfields. is there any way to do this without using action listeners?
You can just call setTransferHandler with a null parameter like this: ``` textComponent.setTransferHandler(null); ``` This will disable all copy/paste actions on the field.
316,674
<p>How would I accomplish displaying a line as the one below in a console window by writing it into a variable during design time then just calling Console.WriteLine(sDescription) to display it?</p> <pre><code> Options: -t Description of -t argument. -b Description of -...
[ { "answer_id": 316679, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "<p>Personally I'd normally just write three Console.WriteLine calls. I know that gives extra fluff, but it lines the tex...
2008/11/25
[ "https://Stackoverflow.com/questions/316674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How would I accomplish displaying a line as the one below in a console window by writing it into a variable during design time then just calling Console.WriteLine(sDescription) to display it? ``` Options: -t Description of -t argument. -b Description of -b argument. `...
If I understand your question right, what you need is the @ sign in front of your string. This will make the compiler take in your string literally (including newlines etc) In your case I would write the following: ``` String sDescription = @"Options: -t Description of -t argument."; ``` So far for you...
316,682
<p>I have a byte stream I need parsed into a struct, and I also need to be able to parse the struct back to a byte stream.</p> <p>Below is an example of what I want where I've used BitConverter to parse the values. I hope there is a more efficient way of doing this, because my structs are HUGE!</p> <pre><code>ref str...
[ { "answer_id": 316699, "author": "Dmitry Khalatov", "author_id": 18174, "author_profile": "https://Stackoverflow.com/users/18174", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/72hyey7b(VS.71).aspx\" rel=\"nofollow noreferrer\">Here</a> i...
2008/11/25
[ "https://Stackoverflow.com/questions/316682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37583/" ]
I have a byte stream I need parsed into a struct, and I also need to be able to parse the struct back to a byte stream. Below is an example of what I want where I've used BitConverter to parse the values. I hope there is a more efficient way of doing this, because my structs are HUGE! ``` ref struct TestStruct { ...
For stuff like this, you usually use a code generator. Let's assume the source looks like this: ``` struct a { int i; } struct b { string name; struct a a; } ``` What you do is you write a simple parser which searches the source (probably some header file) for "struct", then you read the name of the str...
316,727
<p>I always tell in c# a variable of type double is not suitable for money. All weird things could happen. But I can't seem to create an example to demonstrate some of these issues. Can anyone provide such an example?</p> <p>(edit; this post was originally tagged C#; some replies refer to specific details of <code>dec...
[ { "answer_id": 316731, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 8, "selected": true, "text": "<p>Very, very unsuitable. Use decimal.</p>\n\n<pre><code>double x = 3.65, y = 0.05, z = 3.7;\nConsole.WriteLine((x + y...
2008/11/25
[ "https://Stackoverflow.com/questions/316727", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56/" ]
I always tell in c# a variable of type double is not suitable for money. All weird things could happen. But I can't seem to create an example to demonstrate some of these issues. Can anyone provide such an example? (edit; this post was originally tagged C#; some replies refer to specific details of `decimal`, which th...
Very, very unsuitable. Use decimal. ``` double x = 3.65, y = 0.05, z = 3.7; Console.WriteLine((x + y) == z); // false ``` (example from Jon's page [here](http://csharpindepth.com/Articles/General/FloatingPoint.aspx) - recommended reading ;-p)
316,747
<p>I had this question earlier and it was concluded it was a bug in 5.2.5. Well, it's still broken in 5.2.6, at least for me:</p> <p>Please let me know if it is broken or works for you:</p> <pre><code>$obj = new stdClass(); $obj-&gt;{"foo"} = "bar"; $obj-&gt;{"0"} = "zero"; $arr = (array)$obj; //foo -- bar //0 -- ...
[ { "answer_id": 316772, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 3, "selected": true, "text": "<p>Definitely seems like a bug to me (PHP 5.2.6).</p>\n\n<p>You can fix the array like this:</p>\n\n<pre><code>$arr = array_co...
2008/11/25
[ "https://Stackoverflow.com/questions/316747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I had this question earlier and it was concluded it was a bug in 5.2.5. Well, it's still broken in 5.2.6, at least for me: Please let me know if it is broken or works for you: ``` $obj = new stdClass(); $obj->{"foo"} = "bar"; $obj->{"0"} = "zero"; $arr = (array)$obj; //foo -- bar //0 -- {error: undefined index} f...
Definitely seems like a bug to me (PHP 5.2.6). You can fix the array like this: ``` $arr = array_combine(array_keys($arr), array_values($arr)); ``` It's been reported in [this bug report](http://bugs.php.net/bug.php?id=45346) but marked as bogus... [the documentation](http://www.php.net/manual/en/language.types.arr...
316,757
<p>The UK VAT system is changing from 17.5% to 15%. What strategies have you used in your code to store the VAT, and how will the change affect your applications. Do you store a history of vats so you can calculate old prices, or are old invoices stored in a separate table? Is it a simple config setting, or did you bod...
[ { "answer_id": 316762, "author": "Wolfwyrd", "author_id": 15570, "author_profile": "https://Stackoverflow.com/users/15570", "pm_score": 2, "selected": false, "text": "<p>We pull the VAT from a database table shared by all of our internal apps meaning it's not a big deal for us where our ...
2008/11/25
[ "https://Stackoverflow.com/questions/316757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5055/" ]
The UK VAT system is changing from 17.5% to 15%. What strategies have you used in your code to store the VAT, and how will the change affect your applications. Do you store a history of vats so you can calculate old prices, or are old invoices stored in a separate table? Is it a simple config setting, or did you bodge ...
Don't calculate it. Store it! ----------------------------- HMRC are very fussy about getting paid the right amount of VAT. The rounding of VAT calculations is somewhat vaguely specified in the user guides, and leaving it up to future implementers to get it right is possibly asking for trouble. By storing the amount w...
316,761
<p>I'm working with a Java program that has multiple components (with Eclipse &amp; Ant at the moment). </p> <p>Is there some way to start multiple programs with one launch configuration? I have an Ant target that does the job (launches multiple programs) but there are things I would like to do:</p> <ul> <li>I would...
[ { "answer_id": 316783, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 4, "selected": true, "text": "<p>['multiple launch part':]</p>\n<p>If you have an ant launch configuration which does what you want, you can always transform ...
2008/11/25
[ "https://Stackoverflow.com/questions/316761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28482/" ]
I'm working with a Java program that has multiple components (with Eclipse & Ant at the moment). Is there some way to start multiple programs with one launch configuration? I have an Ant target that does the job (launches multiple programs) but there are things I would like to do: * I would like to debug the program...
['multiple launch part':] If you have an ant launch configuration which does what you want, you can always transform it into a java launcher calling ant. ``` Main Class: org.apache.tools.ant.Main -Dant.home=${resource_loc:/myPath/apache_ant} -f ${resource_loc:/myProject/config/myFile-ant.xml} ``` You can then lau...
316,773
<p>Ok I am a total beginner with the Solaris Operating system and I need to install and configure samba on 3 boxes each has a different version of Solaris (8,9,10).</p> <p>What I want to know location of samba configuration file i.e., <code>smb.conf</code> files in each version? So far all I have found is </p> <ol> <...
[ { "answer_id": 316809, "author": "ayaz", "author_id": 23191, "author_profile": "https://Stackoverflow.com/users/23191", "pm_score": 0, "selected": false, "text": "<p>The FILES section of the manpage for `smbd' may give some hints. I don't have any Solaris box handy, so cannot unfortunate...
2008/11/25
[ "https://Stackoverflow.com/questions/316773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38210/" ]
Ok I am a total beginner with the Solaris Operating system and I need to install and configure samba on 3 boxes each has a different version of Solaris (8,9,10). What I want to know location of samba configuration file i.e., `smb.conf` files in each version? So far all I have found is 1. Solaris 8 > > /usr/local/...
Samba configuration files can be set anywhere your administrator want you to have them. * `/usr/local/samba/` is the path where samba can be installed. * smb.conf is one of the configuration files, along with private/secrets.tdb or username.map You can launch your samba with a: ``` smbd -D -s /myPath/smb.conf ``` ...
316,780
<p>I'm developing a multilanguage software. As far as the application code goes, localizability is not an issue. We can use language specific resources and have all kinds of tools that work well with them.</p> <p>But what is the best approach in defining a multilanguage database schema? Let's say we have a lot of tabl...
[ { "answer_id": 316822, "author": "Adam Davis", "author_id": 2915, "author_profile": "https://Stackoverflow.com/users/2915", "pm_score": 6, "selected": false, "text": "<p>The third option is the best, for a few reasons:</p>\n\n<ul>\n<li>Doesn't require altering the database schema for new...
2008/11/25
[ "https://Stackoverflow.com/questions/316780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5348/" ]
I'm developing a multilanguage software. As far as the application code goes, localizability is not an issue. We can use language specific resources and have all kinds of tools that work well with them. But what is the best approach in defining a multilanguage database schema? Let's say we have a lot of tables (100 or...
What do you think about having a related translation table for each translatable table? > > CREATE TABLE T\_PRODUCT (pr\_id int, PRICE NUMBER(18, 2)) > > > CREATE TABLE T\_PRODUCT\_tr (pr\_id INT FK, languagecode varchar, pr\_name text, pr\_descr text) > > > This way if you have multiple translatable column it ...
316,781
<p>Just wondering if there is anything built-in to Javascript that can take a Form and return the query parameters, eg: <code>"var1=value&amp;var2=value2&amp;arr[]=foo&amp;arr[]=bar..."</code></p> <p>I've been wondering this for years.</p>
[ { "answer_id": 316817, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 2, "selected": false, "text": "<p>I'm not entirely certain myself, I recall seeing jQuery did it to an extent, but it doesn't handle hierarchical re...
2008/11/25
[ "https://Stackoverflow.com/questions/316781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Just wondering if there is anything built-in to Javascript that can take a Form and return the query parameters, eg: `"var1=value&var2=value2&arr[]=foo&arr[]=bar..."` I've been wondering this for years.
2k20 update: use [Josh's](https://stackoverflow.com/a/49701878/2750743) solution with [URLSearchParams.toString()](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/toString). Old answer: --- Without jQuery ``` var params = { parameter1: 'value_1', parameter2: 'value 2', parameter3: 'valu...
316,790
<p>Got a little problem with a Seam application I'm working on and I was wondering if anyone knows a way round it. I've got a form in my application that uses AJAX to show certain input boxes depending on an item in a dropdown box. The code works fine except for setting the ID's in my input boxes. It looks like JSF ...
[ { "answer_id": 318513, "author": "Grant Wagner", "author_id": 9254, "author_profile": "https://Stackoverflow.com/users/9254", "pm_score": 2, "selected": false, "text": "<p>I'm assuming you want to control the ID of your input component so you can reference it later in Javascript?</p>\n\n...
2008/11/25
[ "https://Stackoverflow.com/questions/316790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1900/" ]
Got a little problem with a Seam application I'm working on and I was wondering if anyone knows a way round it. I've got a form in my application that uses AJAX to show certain input boxes depending on an item in a dropdown box. The code works fine except for setting the ID's in my input boxes. It looks like JSF doesn'...
You see why they don't let you set the ID, right? JSF takes over id creation because you're in a repeated loop of components and, if they let you just set the id, you'd end up with duplicate IDs, which wouldn't help you anyway. Without knowing WHY you want to set the ID explicitly, it's hard to give you a workaround. ...
316,807
<p>There are too many method for embedding flash in html, which way is the best? Requirements are:</p> <ul> <li>Cross-browser support</li> <li>Support for alternative content (if flash is not supported by the browser)</li> <li>Possibility to require a specific version of the flash player</li> </ul> <p>I have been rea...
[ { "answer_id": 316815, "author": "martinlund", "author_id": 1808, "author_profile": "https://Stackoverflow.com/users/1808", "pm_score": 5, "selected": true, "text": "<p>In a project I work on we use SWFobject which works like a charm, it allows you to check for a specific version and als...
2008/11/25
[ "https://Stackoverflow.com/questions/316807", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16265/" ]
There are too many method for embedding flash in html, which way is the best? Requirements are: * Cross-browser support * Support for alternative content (if flash is not supported by the browser) * Possibility to require a specific version of the flash player I have been reading about [SWFobject](http://code.google....
In a project I work on we use SWFobject which works like a charm, it allows you to check for a specific version and also display alternative content if flash is not supported. ``` var fn = function() { if(swfobject.hasFlashPlayerVersion("9.0.115")) { var att = { data:"flash.swf", width:"y", height:"x" ...
316,808
<p>Env.: VS 2008, .NET 2.0, WinForms</p> <p>I have a listview in Tile mode. Some items have an associated image. Some don't.</p> <p>The contents (listview items) is often renewed when user clicks some controls. When this happens, it sometimes appears that none of the new items have images. In that case, I would like ...
[ { "answer_id": 317249, "author": "Hath", "author_id": 5186, "author_profile": "https://Stackoverflow.com/users/5186", "pm_score": 2, "selected": true, "text": "<p>Are you sure? I've got it working in this test case:</p>\n\n<pre><code>using System;\nusing System.Windows.Forms;\npublic cla...
2008/11/25
[ "https://Stackoverflow.com/questions/316808", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12379/" ]
Env.: VS 2008, .NET 2.0, WinForms I have a listview in Tile mode. Some items have an associated image. Some don't. The contents (listview items) is often renewed when user clicks some controls. When this happens, it sometimes appears that none of the new items have images. In that case, I would like to get rid of the...
Are you sure? I've got it working in this test case: ``` using System; using System.Windows.Forms; public class MainForm : Form { private System.ComponentModel.IContainer components = null; private System.Windows.Forms.ListView listView; private System.Windows.Forms.ImageList emptySmallImageList; priva...
316,812
<p>How can I find poor performing SQL queries in Oracle?</p> <p>Oracle maintains statistics on shared SQL area and contains one row per SQL string(v$sqlarea). But how can we identify which one of them are badly performing?</p>
[ { "answer_id": 316859, "author": "cagcowboy", "author_id": 19629, "author_profile": "https://Stackoverflow.com/users/19629", "pm_score": 1, "selected": false, "text": "<p>There are a number of possible ways to do this, but have a google for tkprof </p>\n\n<p>There's no GUI... it's entire...
2008/11/25
[ "https://Stackoverflow.com/questions/316812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34058/" ]
How can I find poor performing SQL queries in Oracle? Oracle maintains statistics on shared SQL area and contains one row per SQL string(v$sqlarea). But how can we identify which one of them are badly performing?
I found this SQL statement to be a useful place to start (sorry I can't attribute this to the original author; I found it somewhere on the internet): ``` SELECT * FROM (SELECT sql_fulltext, sql_id, elapsed_time, child_number, disk_reads, executions, first_load_time, last_load_time FROM ...
316,820
<p>I need to launch a media file from a URL from within my c# .NET application. Is there any way to do this natively in .NET? I don't need an embedded player, I just need the default player to launch. I have tried </p> <pre><code>System.Diagnostics.Process.Start("File URL"); </code></pre> <p>but it launches the defau...
[ { "answer_id": 316896, "author": "Stefan", "author_id": 19307, "author_profile": "https://Stackoverflow.com/users/19307", "pm_score": 4, "selected": true, "text": "<p>If you enter an URL it will be handled with the program registered to that URL format, in your case the default web brows...
2008/11/25
[ "https://Stackoverflow.com/questions/316820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13877/" ]
I need to launch a media file from a URL from within my c# .NET application. Is there any way to do this natively in .NET? I don't need an embedded player, I just need the default player to launch. I have tried ``` System.Diagnostics.Process.Start("File URL"); ``` but it launches the default browser and downloads t...
If you enter an URL it will be handled with the program registered to that URL format, in your case the default web browser. What format are the media in? You can get associated program for an extension and then run that program with the url as parameter. See: [Windows: List and Launch applications associated with an ...
316,831
<p>Can we have a SQL query which will basically help in viewing table and index sizes in SQl Server.</p> <p>How SQL server maintains memory usage for tables/indexes?</p>
[ { "answer_id": 316893, "author": "Ben R", "author_id": 27705, "author_profile": "https://Stackoverflow.com/users/27705", "pm_score": 4, "selected": false, "text": "<pre><code>EXEC sp_MSforeachtable @command1=\"EXEC sp_spaceused '?'\"\n</code></pre>\n" }, { "answer_id": 316895, ...
2008/11/25
[ "https://Stackoverflow.com/questions/316831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34058/" ]
Can we have a SQL query which will basically help in viewing table and index sizes in SQl Server. How SQL server maintains memory usage for tables/indexes?
The `exec sp_spaceused` without parameter shows the summary for the whole database. The foreachtable solution generates one result set per table - which SSMS might not be able to handle if you have too many tables. I created a [script](http://devio.wordpress.com/2007/10/11/how-much-space-do-my-sql-server-tables-use/) ...
316,835
<p>I got this page, and have some problems with ie &lt; 7 and opera 7.11</p> <p><a href="http://browsershots.org/png/original/c5/c5bac9b3838ba30cfebae2f03f896548.png" rel="nofollow noreferrer">This</a> is what i hoped to be the layout in all browsers, and these are the IE ones instead: <a href="http://browsershots.org...
[ { "answer_id": 316851, "author": "Liam", "author_id": 18333, "author_profile": "https://Stackoverflow.com/users/18333", "pm_score": 0, "selected": false, "text": "<p>Take a look at a stripped-down layout that works, such as on <a href=\"http://www.alistapart.com/d/holygrail/example_1.htm...
2008/11/25
[ "https://Stackoverflow.com/questions/316835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/553923/" ]
I got this page, and have some problems with ie < 7 and opera 7.11 [This](http://browsershots.org/png/original/c5/c5bac9b3838ba30cfebae2f03f896548.png) is what i hoped to be the layout in all browsers, and these are the IE ones instead: [ie 5.5](http://browsershots.org/screenshots/97347e42778e88203c896cc3f30134bd/) an...
Do you *really* need to support IE5.5? That seems needlessly painful. Unless you're explicitly doing this for a client who's using the browser, you can pretty much assume that everyone uses IE6 or later. The CSS support in IE6 is flaky, and almost nonexistent in IE versions older than that. Your best bet for such anci...
316,847
<p>How can I access the apache basic-auth username in a PHP script?</p>
[ { "answer_id": 39879024, "author": "William Entriken", "author_id": 300224, "author_profile": "https://Stackoverflow.com/users/300224", "pm_score": 4, "selected": false, "text": "<p>Simply access this variable:</p>\n\n<pre><code>$_SERVER['PHP_AUTH_USER']\n</code></pre>\n" }, { "a...
2008/11/25
[ "https://Stackoverflow.com/questions/316847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11522/" ]
How can I access the apache basic-auth username in a PHP script?
Simply access this variable: ``` $_SERVER['PHP_AUTH_USER'] ```
316,855
<p>I have the following string:</p> <pre><code>&lt;SEM&gt;electric&lt;/SEM&gt; cu &lt;SEM&gt;hello&lt;/SEM&gt; rent &lt;SEM&gt;is&lt;I&gt;love&lt;/I&gt;, &lt;PARTITION /&gt;mind </code></pre> <p>I want to find the last "SEM" start tag before the "PARTITION" tag. not the SEM end tag but the start tag. The result shoul...
[ { "answer_id": 316869, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 0, "selected": false, "text": "<p>Have you tried this:</p>\n\n<pre><code>&lt;EM&gt;.*&lt;PARTITION\\s*/&gt;\n</code></pre>\n\n<p>Your regular express...
2008/11/25
[ "https://Stackoverflow.com/questions/316855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40570/" ]
I have the following string: ``` <SEM>electric</SEM> cu <SEM>hello</SEM> rent <SEM>is<I>love</I>, <PARTITION />mind ``` I want to find the last "SEM" start tag before the "PARTITION" tag. not the SEM end tag but the start tag. The result should be: ``` <SEM>is <Im>love</Im>, <PARTITION /> ``` I have tried this re...
And here's your goofy Regex!!! ``` (?=[\s\S]*?\<PARTITION)(?![\s\S]+?\<SEM\>)\<SEM\> ``` What that says is "While ahead somewhere is a PARTITION tag... but while ahead is NOT another SEM tag... match a SEM tag." Enjoy! Here's that regex broken down: ``` (?=[\s\S]*?\<PARTITION) means "While ahead somewhere is a PA...
316,864
<p>is it possible to develop DLL for both win32 console and MFC GUI. If yes please explain.</p> <p>What i want to do is to create dll that contains certain API's for both win32 console and MFC GUI.</p>
[ { "answer_id": 316873, "author": "Atempcode", "author_id": 33823, "author_profile": "https://Stackoverflow.com/users/33823", "pm_score": 0, "selected": false, "text": "<p>There is no reason we cannot do this. You can do it either the traditional dllexport, dllimport way or you can just c...
2008/11/25
[ "https://Stackoverflow.com/questions/316864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38038/" ]
is it possible to develop DLL for both win32 console and MFC GUI. If yes please explain. What i want to do is to create dll that contains certain API's for both win32 console and MFC GUI.
Yes - native dlls are structured in exactly the same way when used with console and MFC applications. The easiest way to do what you want is to create a new plain Win32 project in visual studio, and in application settings set the Application Type to DLL. Select the export symbols checkbox, and the project will includ...
316,866
<p>How do I ping a website or IP address with Python?</p>
[ { "answer_id": 316974, "author": "dbr", "author_id": 745, "author_profile": "https://Stackoverflow.com/users/745", "pm_score": 6, "selected": false, "text": "<p>Depending on what you want to achive, you are probably easiest calling the system ping command..</p>\n\n<p>Using the subprocess...
2008/11/25
[ "https://Stackoverflow.com/questions/316866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40572/" ]
How do I ping a website or IP address with Python?
Depending on what you want to achive, you are probably easiest calling the system ping command.. Using the subprocess module is the best way of doing this, although you have to remember the ping command is different on different operating systems! ``` import subprocess host = "www.google.com" ping = subprocess.Pope...
316,879
<p>I have a method in an objective-C class. It has 2 callback functions written in C. The class pointer i.e. <code>self</code> is passed to these functions as <code>void *</code>. In the C functions I create a pointer of type class and assign the <code>void *</code> parameter. The first callback function executes succe...
[ { "answer_id": 316892, "author": "Robert Gould", "author_id": 15124, "author_profile": "https://Stackoverflow.com/users/15124", "pm_score": 0, "selected": false, "text": "<p>This is what Objective-C's selector is for:\n<a href=\"http://developer.apple.com/iphone/library/documentation/Coc...
2008/11/25
[ "https://Stackoverflow.com/questions/316879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39270/" ]
I have a method in an objective-C class. It has 2 callback functions written in C. The class pointer i.e. `self` is passed to these functions as `void *`. In the C functions I create a pointer of type class and assign the `void *` parameter. The first callback function executes successfully. But the `void *` pointer be...
Are your problems specifically with the IOKit callback routines? The problem with the specific example you gave is that the IOServiceMatchingCallback takes only 2 parameters, not 3. You need your RawDeviceAdded() and BulkTestDeviceAdded() callback functions to match the IOServiceMatchingCallback prototype and to accept...
316,889
<p>I can't seem to retrieve an ID I'm sending in a html.ActionLink in my controller, here is what I'm trying to do</p> <pre><code>&lt;li&gt; &lt;%= Html.ActionLink(&quot;Modify Villa&quot;, &quot;Modify&quot;, &quot;Villa&quot;, new { @id = &quot;1&quot; })%&gt;&lt;/li&gt; public ActionResult Modify(string ID...
[ { "answer_id": 316970, "author": "Davide Vosti", "author_id": 1812, "author_profile": "https://Stackoverflow.com/users/1812", "pm_score": 4, "selected": false, "text": "<p>Don't put the @ before the id</p>\n\n<pre><code>new { id = \"1\" }\n</code></pre>\n\n<p>The framework \"translate\" ...
2008/11/25
[ "https://Stackoverflow.com/questions/316889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29445/" ]
I can't seem to retrieve an ID I'm sending in a html.ActionLink in my controller, here is what I'm trying to do ``` <li> <%= Html.ActionLink("Modify Villa", "Modify", "Villa", new { @id = "1" })%></li> public ActionResult Modify(string ID) { ViewData["Title"] =ID; return View(); } ``...
Doesn't look like you are using the correct overload of ActionLink. Try this:- ``` <%=Html.ActionLink("Modify Villa", "Modify", new {id = "1"})%> ``` This assumes your view is under the /Views/Villa folder. If not then I suspect you need:- ``` <%=Html.ActionLink("Modify Villa", "Modify", "Villa", new {id = "1"}, nu...
316,899
<p>I want to change the behavior of a JavaScript used to display a banner, coming from a central source.</p> <p>Today I include a script-tag inline in code, like this:</p> <pre><code>&lt;script type=&quot;text/javascript&quot; src=&quot;http://banner.com/b?id=1234&quot;&gt;&lt;/script&gt; </code></pre> <p>But what that...
[ { "answer_id": 316906, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 1, "selected": false, "text": "<p>Have you tried overriding document.write? I don't have time to try it right now but give this a go:</p>\n\n<pre><code>var...
2008/11/25
[ "https://Stackoverflow.com/questions/316899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2429/" ]
I want to change the behavior of a JavaScript used to display a banner, coming from a central source. Today I include a script-tag inline in code, like this: ``` <script type="text/javascript" src="http://banner.com/b?id=1234"></script> ``` But what that returns is code which uses `document.write`, like this: ``` ...
Yes, you can override document.write. Prototyping is not necessary, you can do it directly on the document object itself. I do this commonly for analysing malware, but it could certainly be used to capture ad script output, as long as the ad script doesn't do any particularly convoluted processing that would turn up th...
316,900
<p>I'm working on a windows client written in WPF with C# on .Net 3.5 Sp1, where a requirement is that data from emails received by clients can be stored in the database. Right now the easiest way to handle this is to copy and paste the text, subject, contact information and time received manually using an arthritis-in...
[ { "answer_id": 317917, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>I think <a href=\"http://blogs.msdn.com/adamroot/pages/shell-style-drag-and-drop-in-net-wpf-and-winforms.aspx\" rel=\"nofol...
2008/11/25
[ "https://Stackoverflow.com/questions/316900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2122/" ]
I'm working on a windows client written in WPF with C# on .Net 3.5 Sp1, where a requirement is that data from emails received by clients can be stored in the database. Right now the easiest way to handle this is to copy and paste the text, subject, contact information and time received manually using an arthritis-induc...
I found a great [article](http://www.codeproject.com/KB/office/outlook_drag_drop_in_cs.aspx) that should do exactly what you need to. **UPDATE** I was able to get the code in that article working in WPF with a little tweaking, below are the changes you need to make. Change all references from System.Windows.Forms.I...
316,903
<p>I need to know if I can create a file in a specific folder, but there are too many things to check such as permissions, duplicate files, etc. I'm looking for something like <code>File.CanCreate(@"C:\myfolder\myfile.aaa"</code>), but haven't found such a method. The only thing I thought is to try to create a dummy f...
[ { "answer_id": 316913, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 5, "selected": true, "text": "<p>In reality, creating a dummy file isn't going to have a huge performance impact in most applications. Of course, if...
2008/11/25
[ "https://Stackoverflow.com/questions/316903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30729/" ]
I need to know if I can create a file in a specific folder, but there are too many things to check such as permissions, duplicate files, etc. I'm looking for something like `File.CanCreate(@"C:\myfolder\myfile.aaa"`), but haven't found such a method. The only thing I thought is to try to create a dummy file and check ...
In reality, creating a dummy file isn't going to have a huge performance impact in most applications. Of course, if you have advanced permissions with create but not destroy it might get a bit hairy... Guids are always handy for random names (to avoid conflicts) - something like: ``` string file = Path.Combine(dir, G...
316,911
<p>Aloha</p> <p>I have a method with (pseudo) signature:</p> <pre><code>public static T Parse&lt;T&gt;(string datadictionary) where T : List&lt;U&gt; </code></pre> <p>This doesn't build. How can I restrict the in the method to accept only generic List&lt;> objects (which should of cource not contain T's but somethi...
[ { "answer_id": 316925, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "<p>Well, you can have two type parameters:</p>\n\n<pre><code>public static T Parse&lt;T, U&gt;(string datadictionary) whe...
2008/11/25
[ "https://Stackoverflow.com/questions/316911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6399/" ]
Aloha I have a method with (pseudo) signature: ``` public static T Parse<T>(string datadictionary) where T : List<U> ``` This doesn't build. How can I restrict the in the method to accept only generic List<> objects (which should of cource not contain T's but something else :) I need to restrict the type of T beca...
Well, you can have two type parameters: ``` public static T Parse<T, U>(string datadictionary) where T : List<U> ``` That way you'll also actually know what U is (in a compile-time manner)... EDIT: Alternatively (and better), just specify the element type and change the return type: ``` public static List<T> Parse...
316,921
<p>i`m currently playing around with WPF and now i wonder what would be the layout for a typical dataentry window (20+ textboxes and stuff).</p> <p>atm i`m using a grid object like this (basic sample)</p> <pre><code> &lt;Grid Margin="2,2,2,2"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinit...
[ { "answer_id": 316948, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 2, "selected": false, "text": "<p>Some people use nested <code>StackPanel</code>s to \"solve\" this problem, but IMHO that just introduces another pr...
2008/11/25
[ "https://Stackoverflow.com/questions/316921", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12406/" ]
i`m currently playing around with WPF and now i wonder what would be the layout for a typical dataentry window (20+ textboxes and stuff). atm i`m using a grid object like this (basic sample) ``` <Grid Margin="2,2,2,2"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"></ColumnDefinition>...
Karl Shifflett also has a nice approach to LOB forms in WPF: <http://karlshifflett.wordpress.com/2008/10/23/wpf-silverlight-lob-form-layout-searching-for-a-better-solution/>
316,924
<p>If you have a route:</p> <pre><code>routes.MapRoute("search", "{controller}/{action}/{filter1}/{filter2}/{filter3}", _ New With {.filter1 = "", .filter2 = "", .filter3 = ""}) </code></pre> <p>then in a view satisfied by the route pattern with a url of <code>/member/search/dev/phil/hoy</code>, when you attempt to...
[ { "answer_id": 316948, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 2, "selected": false, "text": "<p>Some people use nested <code>StackPanel</code>s to \"solve\" this problem, but IMHO that just introduces another pr...
2008/11/25
[ "https://Stackoverflow.com/questions/316924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29547/" ]
If you have a route: ``` routes.MapRoute("search", "{controller}/{action}/{filter1}/{filter2}/{filter3}", _ New With {.filter1 = "", .filter2 = "", .filter3 = ""}) ``` then in a view satisfied by the route pattern with a url of `/member/search/dev/phil/hoy`, when you attempt to create another route url with only `...
Karl Shifflett also has a nice approach to LOB forms in WPF: <http://karlshifflett.wordpress.com/2008/10/23/wpf-silverlight-lob-form-layout-searching-for-a-better-solution/>
316,931
<ul> <li>I autoformat a GridView in ASP.NET.</li> <li><p>It looks nice but the headers all run together like this:</p> <p><strong>idfirstNamelastNameage</strong></p></li> <li><p>I set CellPadding="5" but it does nothing.</p></li> </ul> <p>How can I set the cell padding of the headers and all cells?</p> <p>A D D E N ...
[ { "answer_id": 316955, "author": "Andrew Bullock", "author_id": 28543, "author_profile": "https://Stackoverflow.com/users/28543", "pm_score": 5, "selected": true, "text": "<p>You should set a cssclass and use css to control it. The only property of a table you cant fully control cross br...
2008/11/25
[ "https://Stackoverflow.com/questions/316931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
* I autoformat a GridView in ASP.NET. * It looks nice but the headers all run together like this: **idfirstNamelastNameage** * I set CellPadding="5" but it does nothing. How can I set the cell padding of the headers and all cells? A D D E N D U M : Thanks Andrew, I fixed it with this. Works in Firefox and Explorer ...
You should set a cssclass and use css to control it. The only property of a table you cant fully control cross browser with css is cellspacing. ``` .myTableClass tr th { padding: 5px; } ```
316,940
<p>I'm looking for a generic method to implement a wait screen during long operations. I have used threading a few times before, but I have the feeling that I implemented it either very poorly, or with way too much hassle (and copy/pasting - the horror!).</p> <p>I want to keep this as generic and simple as possible, s...
[ { "answer_id": 316945, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 0, "selected": false, "text": "<p>In your thread, use Application.Run(yourform) to get what you want.</p>\n\n<p>Note that you need to signal the for...
2008/11/25
[ "https://Stackoverflow.com/questions/316940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39259/" ]
I'm looking for a generic method to implement a wait screen during long operations. I have used threading a few times before, but I have the feeling that I implemented it either very poorly, or with way too much hassle (and copy/pasting - the horror!). I want to keep this as generic and simple as possible, so I won't ...
Your problem is that your getting a cross thread exception when your trying to pass your Worker thread data to your ui thread. what you need to do is check InvokeRequired and begininvoke before setting the controls on your ui so you don't get the error like so: ``` Private Sub work_CrossThreadEvent(ByVal sender As Obj...
316,967
<p>I have need to select a number of 'master' rows from a table, also returning for each result a number of detail rows from another table. What is a good way of achieving this without multiple queries (one for the master rows and one per result to get the detail rows).</p> <p>For example, with a database structure li...
[ { "answer_id": 317019, "author": "Mladen Prajdic", "author_id": 31345, "author_profile": "https://Stackoverflow.com/users/31345", "pm_score": 0, "selected": false, "text": "<p>select &lt; columns > from master</p>\n\n<p>select &lt; columns > from master M join Child C on M.Id = C.MasterI...
2008/11/25
[ "https://Stackoverflow.com/questions/316967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4048/" ]
I have need to select a number of 'master' rows from a table, also returning for each result a number of detail rows from another table. What is a good way of achieving this without multiple queries (one for the master rows and one per result to get the detail rows). For example, with a database structure like below: ...
Normally, I'd go for the two grids approach - however, you might also want to look at FOR XML - it is fairly easy (in SQL Server 2005 and above) to shape the parent/child data as xml, and load it from there. ``` SELECT parent.*, (SELECT * FROM child WHERE child.parentid = parent.id FOR XML PATH('child'),...
316,988
<p>I am developing an application and want to display a form that will be filled in if editing the form, but will not be if the form will be a new entry. I believe the least verbose way of doing this is to have just one form and to suppress any errors for echoing my variables so that nothing will be printed if it is a...
[ { "answer_id": 316993, "author": "Tom Haigh", "author_id": 22224, "author_profile": "https://Stackoverflow.com/users/22224", "pm_score": 1, "selected": false, "text": "<p>I think the best way is to always set the variable</p>\n\n<pre><code>if ( ! $new_item) {\n $variable = 'Example';\...
2008/11/25
[ "https://Stackoverflow.com/questions/316988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3831/" ]
I am developing an application and want to display a form that will be filled in if editing the form, but will not be if the form will be a new entry. I believe the least verbose way of doing this is to have just one form and to suppress any errors for echoing my variables so that nothing will be printed if it is a new...
i tend to use: ``` $variable = (isset($new_item) && $new_item) ? 'Example' : 'Default Value'; ``` Overkill really, but i think going straight for !$new\_item throws a notice if it isn't set. You can also switch the second clause out for !empty($new\_item) depending on the behaviour you want.
317,002
<p>I have this in my installer and I need to change the name of the ini file.</p> <pre><code>[INI] Filename: {app}\bin\old.ini; Section: Data; Key: key; String: Value; </code></pre> <p>If I just change the filename it will create another ini file and I'll lose the data.</p> <p>Is there some easy way to rename this i...
[ { "answer_id": 317545, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 2, "selected": false, "text": "<p>I think you should use RenameFile() in [CODE] section instead, since you know where the ini file is.</p>\n" }, { ...
2008/11/25
[ "https://Stackoverflow.com/questions/317002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/727/" ]
I have this in my installer and I need to change the name of the ini file. ``` [INI] Filename: {app}\bin\old.ini; Section: Data; Key: key; String: Value; ``` If I just change the filename it will create another ini file and I'll lose the data. Is there some easy way to rename this ini file in the installer?
Just being more verbose about PhiLho's answer: In the [INI] section of the installer, just change everything to the new .ini file, then in the code rename the old file in the ssInstall step like this: ``` procedure CurStepChanged(CurStep: TSetupStep); var OldFile: string; begin if CurStep = ssInstall then begin...
317,005
<p>In my routing I would like to have something like not found route handler. </p> <p>For example I have created one mapping like</p> <pre><code>routes.MapRoute( "default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id="" }...
[ { "answer_id": 317545, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 2, "selected": false, "text": "<p>I think you should use RenameFile() in [CODE] section instead, since you know where the ini file is.</p>\n" }, { ...
2008/11/25
[ "https://Stackoverflow.com/questions/317005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56035/" ]
In my routing I would like to have something like not found route handler. For example I have created one mapping like ``` routes.MapRoute( "default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id="" } ); rou...
Just being more verbose about PhiLho's answer: In the [INI] section of the installer, just change everything to the new .ini file, then in the code rename the old file in the ssInstall step like this: ``` procedure CurStepChanged(CurStep: TSetupStep); var OldFile: string; begin if CurStep = ssInstall then begin...
317,029
<p>So far i have got the code below which works lovely when trying an update, delete or select statement. However I run into problems when I try to use an insert. If someone could point me in the correct direction i would be grateful.</p> <pre><code>private function escape($value) { if(get_magic_quotes_gpc()) ...
[ { "answer_id": 317039, "author": "Tim", "author_id": 33914, "author_profile": "https://Stackoverflow.com/users/33914", "pm_score": 1, "selected": false, "text": "<p>You should probably wrap the values() in parens too, like:</p>\n\n<pre><code>$MyDB-&gt;prep(\"INSERT INTO `demo` (`id`, `na...
2008/11/25
[ "https://Stackoverflow.com/questions/317029", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31677/" ]
So far i have got the code below which works lovely when trying an update, delete or select statement. However I run into problems when I try to use an insert. If someone could point me in the correct direction i would be grateful. ``` private function escape($value) { if(get_magic_quotes_gpc()) $value = s...
It may help to start with using valid insert statements. ``` VALUES ( a , b , c ) ``` Not ``` VALUES a, b , c ``` Additionally, why the dickens are you combining a perpared insert with string substituion? you mean $q->prep("blah blah blah VALUES ( :date , etc etc ) " ); $q->bind(":date", $date ); or so...
317,053
<p>I'm trying to extract the attributes of a anchor tag (<code>&lt;a&gt;</code>). So far I have this expression:</p> <pre><code>(?&lt;name&gt;\b\w+\b)\s*=\s*("(?&lt;value&gt;[^"]*)"|'(?&lt;value&gt;[^']*)'|(?&lt;value&gt;[^"'&lt;&gt; \s]+)\s*)+ </code></pre> <p>which works for strings like</p> <pre><code>&lt;a href=...
[ { "answer_id": 317063, "author": "activout.se", "author_id": 20444, "author_profile": "https://Stackoverflow.com/users/20444", "pm_score": 2, "selected": false, "text": "<p>I suggest that you use <a href=\"http://tidy.sourceforge.net/\" rel=\"nofollow noreferrer\">HTML Tidy</a> to conver...
2008/11/25
[ "https://Stackoverflow.com/questions/317053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6461/" ]
I'm trying to extract the attributes of a anchor tag (`<a>`). So far I have this expression: ``` (?<name>\b\w+\b)\s*=\s*("(?<value>[^"]*)"|'(?<value>[^']*)'|(?<value>[^"'<> \s]+)\s*)+ ``` which works for strings like ``` <a href="test.html" class="xyz"> ``` and (single quotes) ``` <a href='test.html' class="xyz"...
Update 2021: [Radon8472](https://stackoverflow.com/users/2377961/radon8472) proposes in [the comments](https://stackoverflow.com/questions/317053/regular-expression-for-extracting-tag-attributes/317081?noredirect=1#comment121192951_317081) the regex <https://regex101.com/r/tOF6eA/1> (note `regex101.com` did not exist w...
317,070
<p>For the purposes of tracking non-HTML documents via google analytics, I need the mentioned algorithm. It should:</p> <ul><li>not hard-code the domain</li> <li>ignore the protocol (i.e. http/https)</li> <li>not worry about the presence/absence of "www" (any absolute links WILL prefix with "www" and all pages WILL be...
[ { "answer_id": 317123, "author": "Tom", "author_id": 26155, "author_profile": "https://Stackoverflow.com/users/26155", "pm_score": 3, "selected": false, "text": "<p>I would like to point out that, if you're on so.com, the following links are URLs within the same domain:</p>\n\n<ul>\n<li>...
2008/11/25
[ "https://Stackoverflow.com/questions/317070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5058/" ]
For the purposes of tracking non-HTML documents via google analytics, I need the mentioned algorithm. It should: * not hard-code the domain * ignore the protocol (i.e. http/https) * not worry about the presence/absence of "www" (any absolute links WILL prefix with "www" and all pages WILL be served via "www") This is...
I would like to point out that, if you're on so.com, the following links are URLs within the same domain: * <http://test.so.com> * <http://so.com/index> * index * /index * # * /# * <https://subdomain.so.com#hash> * mail.google.com * mail.google.com/index.php?var=value#index (it may seem odd, but the last two ones are...
317,087
<p>Does anybody know why</p> <pre><code> vector&lt;int&gt; test(10); int a=0; for_each(test.begin(),test.end(),(_1+=var(a),++var(a))); for_each(test.begin(),test.end(),(cout &lt;&lt; _1 &lt;&lt; " ")); cout &lt;&lt; "\n" </code></pre> <p>Gives : "0 1 2 3 4 5 6 7 8 9"</p> <p>but </p> <pre><code> transfo...
[ { "answer_id": 317100, "author": "Pieter", "author_id": 5822, "author_profile": "https://Stackoverflow.com/users/5822", "pm_score": 4, "selected": true, "text": "<p>Comma operator evaluates left to right, so the result of the</p>\n<pre><code>_1+=var(a), ++var(a)\n</code></pre>\n<p>is ++v...
2008/11/25
[ "https://Stackoverflow.com/questions/317087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24508/" ]
Does anybody know why ``` vector<int> test(10); int a=0; for_each(test.begin(),test.end(),(_1+=var(a),++var(a))); for_each(test.begin(),test.end(),(cout << _1 << " ")); cout << "\n" ``` Gives : "0 1 2 3 4 5 6 7 8 9" but ``` transform(test.begin(),test.end(),test.begin(), (_1+=var(a),++var(a))); .....
Comma operator evaluates left to right, so the result of the ``` _1+=var(a), ++var(a) ``` is ++var(a), which you'll store using the transform version. * for\_each: \_1 += var(a) is evaluated, updating your sequence (via the lambda \_1), then ++var(a) is evaluated, but this has no effect on your sequence. * transfo...
317,095
<p>As the question says, how do I add a new option to a DropDownList using jQuery?</p> <p>Thanks</p>
[ { "answer_id": 317101, "author": "cgreeno", "author_id": 6088, "author_profile": "https://Stackoverflow.com/users/6088", "pm_score": 4, "selected": false, "text": "<p>With the plugin: <a href=\"http://www.texotela.co.uk/code/jquery/select/\" rel=\"noreferrer\">jQuery Selection Box</a>. Y...
2008/11/25
[ "https://Stackoverflow.com/questions/317095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27805/" ]
As the question says, how do I add a new option to a DropDownList using jQuery? Thanks
Without using any extra plugins, ``` var myOptions = { val1 : 'text1', val2 : 'text2' }; var mySelect = $('#mySelect'); $.each(myOptions, function(val, text) { mySelect.append( $('<option></option>').val(val).html(text) ); }); ``` If you had lots of options, or this code needed to be run very...
317,114
<p>In my application I have several DataContexts that connects to different databases with different schemas. In a custom user control I display the results of the query and let the user edit them, and when the user edits the data I want to persist the changes to the database. To do that I need a reference to the sourc...
[ { "answer_id": 317234, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": true, "text": "<p>I think you're going to have to simply pass the DataContext to the code (manually). Sorry.</p>\n" }, { "ans...
2008/11/25
[ "https://Stackoverflow.com/questions/317114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30366/" ]
In my application I have several DataContexts that connects to different databases with different schemas. In a custom user control I display the results of the query and let the user edit them, and when the user edits the data I want to persist the changes to the database. To do that I need a reference to the source D...
I think you're going to have to simply pass the DataContext to the code (manually). Sorry.
317,140
<p>I need to get the image dimensions of a JPEG in C++. I'm looking for either a fairly simple way to do it or a smallish library that provides that functionality. I'm working in C++ on OpenVMS, so any external libraries may have to be adapted to compile on our systems - so please don't post me links to big, closed sou...
[ { "answer_id": 317142, "author": "activout.se", "author_id": 20444, "author_profile": "https://Stackoverflow.com/users/20444", "pm_score": 2, "selected": false, "text": "<p>Maybe <a href=\"http://en.wikipedia.org/wiki/Libjpeg\" rel=\"nofollow noreferrer\">libjpeg</a>? </p>\n" }, { ...
2008/11/25
[ "https://Stackoverflow.com/questions/317140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20972/" ]
I need to get the image dimensions of a JPEG in C++. I'm looking for either a fairly simple way to do it or a smallish library that provides that functionality. I'm working in C++ on OpenVMS, so any external libraries may have to be adapted to compile on our systems - so please don't post me links to big, closed source...
You have this [C function](http://carnage-melon.tom7.org/stuff/jpegsize.html) which may extract the relevant data for you. > > This is a C routine but should compile fine with C++. > > Pass it a normal FILE pointer (from fopen) to the beginning of a jpeg file and two int pointers to be set with the image height a...
317,154
<p>I have a legacy database and I am trying to create a NHibernate DAL. I have a problem with a mapping on Many-To-Many table.</p> <p>The Database tables:</p> <ul> <li><code>studio_Subscribers</code></li> <li><code>studio_Groups</code> (contains a IList of Subscribers)</li> <li><code>studio_Subscribers_Groups</code> ...
[ { "answer_id": 317200, "author": "jishi", "author_id": 33663, "author_profile": "https://Stackoverflow.com/users/33663", "pm_score": 2, "selected": false, "text": "<p>Shouldn't you have an appropriate bag on your subscriber aswell with a many-to-many relation to the group?</p>\n\n<pre><c...
2008/11/25
[ "https://Stackoverflow.com/questions/317154", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29906/" ]
I have a legacy database and I am trying to create a NHibernate DAL. I have a problem with a mapping on Many-To-Many table. The Database tables: * `studio_Subscribers` * `studio_Groups` (contains a IList of Subscribers) * `studio_Subscribers_Groups` - Many-To-Many table with primary keys The problem is when I create...
Shouldn't you have an appropriate bag on your subscriber aswell with a many-to-many relation to the group? ``` <bag name="Groups" table="studio_Groups_Subscribers" access="nosetter.camelcase"> <key column="SubscriberId"></key> <many-to-many column="GroupId" class="GroupItem" /> </bag> ``` and maybe h...
317,170
<p>I would like to change all the names of the attributes where <code>class="testingCase"</code> throughout all my whole html document.</p> <p>e.g. Change:</p> <pre><code>&lt;a class="testingCase" href="#" title="name of testing case"&gt;Blabla&lt;/a&gt; &lt;a class="testingCase" href="#" title="name of another testi...
[ { "answer_id": 317179, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 6, "selected": false, "text": "<p>There is no built-in method/function to \"rename\" an attribute in javascript, but you can create new attributes and remove...
2008/11/25
[ "https://Stackoverflow.com/questions/317170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I would like to change all the names of the attributes where `class="testingCase"` throughout all my whole html document. e.g. Change: ``` <a class="testingCase" href="#" title="name of testing case">Blabla</a> <a class="testingCase" href="#" title="name of another testing case">Bloo</a> ``` To this: ``` <a class...
There is no built-in method/function to "rename" an attribute in javascript, but you can create new attributes and remove other ones... ```js $('a.testingCase[title]').each(function() { var $t = $(this); $t.attr({ newTitleName: $t.attr('title') }) .removeAttr('title'); }); ``` ```html <script ...
317,175
<p>On Apache/PHP sites if I want to put a senstive file within my website folders, I put a .htaccess file in that folder so users can't download the sensitive file.</p> <p><strong>Is there a similar practice for IIS/ASP.NET sites</strong>, i.e. if I have a shared hosting account and don't have access to IIS server. Ca...
[ { "answer_id": 317223, "author": "netadictos", "author_id": 31791, "author_profile": "https://Stackoverflow.com/users/31791", "pm_score": 0, "selected": false, "text": "<p>There are some things you can do with web.config like defining security settings etc...\nOther times you have to use...
2008/11/25
[ "https://Stackoverflow.com/questions/317175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
On Apache/PHP sites if I want to put a senstive file within my website folders, I put a .htaccess file in that folder so users can't download the sensitive file. **Is there a similar practice for IIS/ASP.NET sites**, i.e. if I have a shared hosting account and don't have access to IIS server. Can I do this in web.conf...
Inside of an ASP.Net web.config you can setup locations to add security to specific files and folders. In addition, you can remove all verbs from those directories: ``` <location path="Secret" allowOverride="false"> <system.web> <authorization> <deny users="*" /> </authorization> <httpHandlers> ...
317,176
<p>I am looking for any tool which will allow the performance testing/tuning of Sybase nested stored procedures. There are many tools around and of course Sybase's own for performance tuning and testing SQL but none of these can handle nested stored procedures (i.e. a stored proc calling another stored proc). Does anyo...
[ { "answer_id": 317223, "author": "netadictos", "author_id": 31791, "author_profile": "https://Stackoverflow.com/users/31791", "pm_score": 0, "selected": false, "text": "<p>There are some things you can do with web.config like defining security settings etc...\nOther times you have to use...
2008/11/25
[ "https://Stackoverflow.com/questions/317176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am looking for any tool which will allow the performance testing/tuning of Sybase nested stored procedures. There are many tools around and of course Sybase's own for performance tuning and testing SQL but none of these can handle nested stored procedures (i.e. a stored proc calling another stored proc). Does anyone ...
Inside of an ASP.Net web.config you can setup locations to add security to specific files and folders. In addition, you can remove all verbs from those directories: ``` <location path="Secret" allowOverride="false"> <system.web> <authorization> <deny users="*" /> </authorization> <httpHandlers> ...
317,184
<p>I'd like to know when i should and shouldn't be wrapping things in a USING block.</p> <p>From what I understand, the compiler translates it into a try/finally, where the finally calls Dispose() on the object.</p> <p>I always use a USING around database connections and file access, but its more out of habit rather ...
[ { "answer_id": 317201, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 6, "selected": true, "text": "<p>No, <code>IDisposable</code> items are not disposed when they go out of scope. It is for precisely this reason that...
2008/11/25
[ "https://Stackoverflow.com/questions/317184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28543/" ]
I'd like to know when i should and shouldn't be wrapping things in a USING block. From what I understand, the compiler translates it into a try/finally, where the finally calls Dispose() on the object. I always use a USING around database connections and file access, but its more out of habit rather than a 100% under...
No, `IDisposable` items are not disposed when they go out of scope. It is for precisely this reason that we need `IDisposable` - for deterministic cleanup. They will *eventually* get garbage collected, and if there is a finalizer it will (maybe) be called - but that could be a long time in the future (not good for con...
317,190
<p>I am using the <a href="http://www.sqlite.org/" rel="nofollow noreferrer">SQLite</a> database and have the following persistent class (simplified):</p> <pre><code>public class Project { public virtual int Id { get; set; } public virtual DateTime StartDate { get; set; } } </code></pre> <p>which is mapped to...
[ { "answer_id": 317728, "author": "kͩeͣmͮpͥ ͩ", "author_id": 26479, "author_profile": "https://Stackoverflow.com/users/26479", "pm_score": 3, "selected": true, "text": "<p>If you're regularly querying against months, days, years, you shouldn't really be storing your date as a DateTime col...
2008/11/25
[ "https://Stackoverflow.com/questions/317190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29407/" ]
I am using the [SQLite](http://www.sqlite.org/) database and have the following persistent class (simplified): ``` public class Project { public virtual int Id { get; set; } public virtual DateTime StartDate { get; set; } } ``` which is mapped to this table in the database: ``` CREATE TABLE projects ( i...
If you're regularly querying against months, days, years, you shouldn't really be storing your date as a DateTime column - it makes the queries incredibly inefficient. You could easily create a "Month" column and query against that (and your DBA would love you again)
317,198
<p>I mainly use the MySQL GUI tools. This allows me to easily see the results in a table as well as to quick edits and bookmark frequently run queries. This suits my needs far better than the command line.</p> <p>I remember when I used to do this on Oracle DBs years ago I could put variables in the query itself, so th...
[ { "answer_id": 317210, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 0, "selected": false, "text": "<p>I'm not sure if there's a way to get the GUI tools to prompt you for a value, but you can certainly use variables in MySQL....
2008/11/25
[ "https://Stackoverflow.com/questions/317198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11660/" ]
I mainly use the MySQL GUI tools. This allows me to easily see the results in a table as well as to quick edits and bookmark frequently run queries. This suits my needs far better than the command line. I remember when I used to do this on Oracle DBs years ago I could put variables in the query itself, so that when ru...
Ok, a different solution, since it appears Bill is right (read the comments on my other answer). In the Params tab in the bottom right, you can right click the "Local Params" folder and add a new parameter. Give it a name, eg: "myTest". Initially it is given a value of NULL. Double click on NULL and type in a new valu...
317,225
<pre><code> &lt;form action="/Villa/Add" method="post"&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt; Name: &lt;/td&gt; &lt;td&gt; &lt;%= Html.TextBox("name") %&gt; &lt;%= Html.ValidationMessage("Name") %&gt; &lt;/td&...
[ { "answer_id": 317235, "author": "Mariusz", "author_id": 5228, "author_profile": "https://Stackoverflow.com/users/5228", "pm_score": 1, "selected": false, "text": "<p>It belongs to your url routes, you defined.</p>\n\n<p>In your case the form ist looking for an controller named \"Villa\"...
2008/11/25
[ "https://Stackoverflow.com/questions/317225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29445/" ]
``` <form action="/Villa/Add" method="post"> <table> <tr> <td> Name: </td> <td> <%= Html.TextBox("name") %> <%= Html.ValidationMessage("Name") %> </td> </tr> <tr> <td> ...
This works for ASP.Net MVC Beta. ``` public ActionResult Add( string name ) { .... } or public ActionResult Add( FormCollection form ) { string name = form["Name"]; } or public ActionResult Add( [Bind(Prefix="")]Villa villa ) { villa.Name ... } ```
317,259
<p>I am using NetBeans for PHP 6.5.</p> <p>In my code I frequently use the following type of command:</p> <pre><code>if (($row = $db-&gt;get_row($sql))) { return $row-&gt;folder; } else { return FALSE; } </code></pre> <p>Netbeans tells me that I should not be using assignments in the IF state...
[ { "answer_id": 317268, "author": "Tom Ritter", "author_id": 8435, "author_profile": "https://Stackoverflow.com/users/8435", "pm_score": 3, "selected": false, "text": "<p>It's probably trying to help you avoid the dreaded typo:</p>\n\n<blockquote>\n<pre><code>if(a = b)\n //logic error\n...
2008/11/25
[ "https://Stackoverflow.com/questions/317259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2725/" ]
I am using NetBeans for PHP 6.5. In my code I frequently use the following type of command: ``` if (($row = $db->get_row($sql))) { return $row->folder; } else { return FALSE; } ``` Netbeans tells me that I should not be using assignments in the IF statement. Why ?
They are not bad, but they can lead to dangerous mistakes. In c like languages, where an assignment is an expression, (to support for example a=b=c=1;) a common error is: ``` if (a = 1) { .. } ``` But you wanted to have ``` if (a == 1) { .. } ``` Some developers have learned to type ``` if (1 == a) { .. } ```...
317,279
<p>I'm currently having a problem with a ShoppingCart for my customer.</p> <p>He wants to be able to add Text between the CartItems so I was wondering if there is some way to still only have one List.</p> <p>My solution would be to have two lists, one of type IList that gets iterated over when calculating Weight and ...
[ { "answer_id": 317293, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 5, "selected": true, "text": "<p>Use an interface:</p>\n\n<pre><code> ICartListItem\n</code></pre>\n\n<p>And make your list be:</p>\n\n<pre><code> List&lt;...
2008/11/25
[ "https://Stackoverflow.com/questions/317279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21699/" ]
I'm currently having a problem with a ShoppingCart for my customer. He wants to be able to add Text between the CartItems so I was wondering if there is some way to still only have one List. My solution would be to have two lists, one of type IList that gets iterated over when calculating Weight and overall Price of ...
Use an interface: ``` ICartListItem ``` And make your list be: ``` List<ICartListItem> ``` Now, create several types, have all of them implement this interface, and you can store them all safely in your list. Alternatively, if you want there to be some default logic in a CartItem, use a base class instead of a...
317,281
<p>I have this query in LINQ to Entities.</p> <pre><code> var query = (from s in db.ForumStatsSet where s.LogDate &gt;= date1 &amp;&amp; s.LogDate &lt;= date2 group s by new { s.Topic.topicID, s.Topic.subject, s.Topic.Forum.forumName, s.Topic.datum, s.Topic.Forum.ForumG...
[ { "answer_id": 317303, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 0, "selected": false, "text": "<p>I think the problem is with the grouping construct. Try extract the data first (so there is not need to go via propertie...
2008/11/25
[ "https://Stackoverflow.com/questions/317281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40609/" ]
I have this query in LINQ to Entities. ``` var query = (from s in db.ForumStatsSet where s.LogDate >= date1 && s.LogDate <= date2 group s by new { s.Topic.topicID, s.Topic.subject, s.Topic.Forum.forumName, s.Topic.datum, s.Topic.Forum.ForumGroup.name, s.Topic.Forum.for...
Instead of joining all tables in group by you can join the given tables by yourself. Can you try this; ``` from s in db.ForumStatsSet join t in db.Topics on t.TopicId == s.TopicId join f in db.Forums on f.ForumId == t.ForumId join fg in db.ForumGroups on fg.ForumGroupId == f.ForumGroupId where s.LogDate >= date1 && s....
317,302
<p>Which ftp client or which syntax allows easy chmod for sub-directories?</p>
[ { "answer_id": 317314, "author": "Tim", "author_id": 33914, "author_profile": "https://Stackoverflow.com/users/33914", "pm_score": 0, "selected": false, "text": "<p>To chmod all subdirs from where you are (recursive):</p>\n\n<pre><code>chmod -R *\n</code></pre>\n" }, { "answer_id...
2008/11/25
[ "https://Stackoverflow.com/questions/317302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Which ftp client or which syntax allows easy chmod for sub-directories?
LFTP allows for recursive CHMOD if the client allows it. You can accomplish this by logging in with LFTP from a Unix/Linux CLI and then run the following: ``` chmod -R 0755 /www/directory/* ``` You could also setup a real nifty Bash script for this: ``` #!/bin/bash lftp <<EOF set ftp:ssl-allow no set ftp:passive-mo...
317,310
<p>I am a bit new to Perl, but here is what I want to do: </p> <pre><code>my @array2d; while(&lt;FILE&gt;){ push(@array2d[$i], $_); } </code></pre> <p>It doesn't compile since <code>@array2d[$i]</code> is not an array but a scalar value.</p> <p>How should I declare @array2d as an array of array?</p> <p>Of course,...
[ { "answer_id": 317325, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 3, "selected": false, "text": "<p>Have a look at <a href=\"http://perldoc.perl.org/perlref.html\" rel=\"nofollow noreferrer\">perlref</a> and <a href=...
2008/11/25
[ "https://Stackoverflow.com/questions/317310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38924/" ]
I am a bit new to Perl, but here is what I want to do: ``` my @array2d; while(<FILE>){ push(@array2d[$i], $_); } ``` It doesn't compile since `@array2d[$i]` is not an array but a scalar value. How should I declare @array2d as an array of array? Of course, I have no idea of how many rows I have.
To make an array of arrays, or more accurately an array of arrayrefs, try something like this: ``` my @array = (); foreach my $i ( 0 .. 10 ) { foreach my $j ( 0 .. 10 ) { push @{ $array[$i] }, $j; } } ``` It pushes the value onto a dereferenced arrayref for you. You should be able to access an entry like th...
317,311
<p>I have some string s that is locale specific (eg, 0.01 or 0,01). I want to convert this string to a NSDecimalNumber. From the <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfNumberFormatting10_4.html" rel="noreferrer">examples I've seen thus far on the interwebs</a>, th...
[ { "answer_id": 317953, "author": "Boaz Stuller", "author_id": 1464654, "author_profile": "https://Stackoverflow.com/users/1464654", "pm_score": 2, "selected": false, "text": "<p>This seems to work:</p>\n\n<pre><code>NSString *s = @\"0.07\";\n\nNSScanner* scanner = [NSScanner localizedSca...
2008/11/25
[ "https://Stackoverflow.com/questions/317311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40618/" ]
I have some string s that is locale specific (eg, 0.01 or 0,01). I want to convert this string to a NSDecimalNumber. From the [examples I've seen thus far on the interwebs](http://developer.apple.com/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfNumberFormatting10_4.html), this is accomplished by using an NS...
Based on Boaz Stuller's answer, I logged a bug to Apple for this issue. Until that is resolved, here are the workarounds I've decided upon as being the best approach to take. These workarounds simply rely upon rounding the decimal number to the appropriate precision, which is a simple approach that can supplement your ...
317,315
<p>In my applications, I often have to use relative paths. For example, when I reference JQuery, I usually do so like this:</p> <pre><code>&lt;script type="text/javascript" src="../Scripts/jquery-1.2.6.js"&gt;&lt;/script&gt; </code></pre> <p>Now that I'm making the transition to MVC, I need to account for the differe...
[ { "answer_id": 317333, "author": "kͩeͣmͮpͥ ͩ", "author_id": 26479, "author_profile": "https://Stackoverflow.com/users/26479", "pm_score": 3, "selected": false, "text": "<p>In ASP.NET I usually use <code>&lt;img src='&lt;%= VirtualPathUtility.ToAbsolute(\"~/images/logo.gif\") %&gt;' alt=\...
2008/11/25
[ "https://Stackoverflow.com/questions/317315", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34942/" ]
In my applications, I often have to use relative paths. For example, when I reference JQuery, I usually do so like this: ``` <script type="text/javascript" src="../Scripts/jquery-1.2.6.js"></script> ``` Now that I'm making the transition to MVC, I need to account for the different paths a page might have, relative t...
Try this: ``` <script type="text/javascript" src="<%=Url.Content("~/Scripts/jquery-1.2.6.js")%>"></script> ``` Or use [MvcContrib](http://www.codeplex.com/MVCContrib) and do this: ``` <%=Html.ScriptInclude("~/Content/Script/jquery.1.2.6.js")%> ```
317,322
<p>How would you get tree-structured data from a database with the best performance? For example, say you have a folder-hierarchy in a database. Where the folder-database-row has <strong>ID</strong>, <strong>Name</strong> and <strong>ParentID</strong> columns.</p> <p>Would you use a special algorithm to get all the da...
[ { "answer_id": 317345, "author": "JeeBee", "author_id": 17832, "author_profile": "https://Stackoverflow.com/users/17832", "pm_score": 1, "selected": false, "text": "<p>If you have many trees in the database, and you will only ever get the whole tree out, I would store a tree ID (or root ...
2008/11/25
[ "https://Stackoverflow.com/questions/317322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2429/" ]
How would you get tree-structured data from a database with the best performance? For example, say you have a folder-hierarchy in a database. Where the folder-database-row has **ID**, **Name** and **ParentID** columns. Would you use a special algorithm to get all the data at once, minimizing the amount of database-cal...
It really depends on how you are going to access the tree. One clever technique is to give every node a string id, where the parent's id is a predictable substring of the child. For example, the parent could be '01', and the children would be '0100', '0101', '0102', etc. This way you can select an entire subtree from ...
317,336
<p>I am looking for a way to pull the first 100 characters from a string variable to put in another variable for printing. </p> <p>Is there a function that can do this easily?</p> <p>For example:</p> <pre><code>$string1 = "I am looking for a way to pull the first 100 characters from a string variable to put in anot...
[ { "answer_id": 317350, "author": "Patrick Desjardins", "author_id": 13913, "author_profile": "https://Stackoverflow.com/users/13913", "pm_score": 9, "selected": true, "text": "<pre><code>$small = substr($big, 0, 100);\n</code></pre>\n\n<p>For <a href=\"http://ca3.php.net/manual/en/ref.st...
2008/11/25
[ "https://Stackoverflow.com/questions/317336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33194/" ]
I am looking for a way to pull the first 100 characters from a string variable to put in another variable for printing. Is there a function that can do this easily? For example: ``` $string1 = "I am looking for a way to pull the first 100 characters from a string variable to put in another variable for printing."; ...
``` $small = substr($big, 0, 100); ``` For [String Manipulation](http://ca3.php.net/manual/en/ref.strings.php) here is a page with a lot of function that might help you in your future work.
317,362
<p>I've got in my webservice a simple <code>public boolean isAlive()</code> service. I defined it in my WSDL :</p> <pre><code>&lt;wsdl:types&gt; &lt;xsd:element name="isAliveResponse" type="xsd:boolean"&gt; &lt;/xsd:element&gt; &lt;/wsdl:types&gt; &lt;wsdl:message name="isAliveResponse"&gt; &lt;wsdl:part e...
[ { "answer_id": 317473, "author": "ryan", "author_id": 2454, "author_profile": "https://Stackoverflow.com/users/2454", "pm_score": 0, "selected": false, "text": "<p>I'm not sure if this is your problem but the following line seems to have no closing tag:</p>\n\n<pre><code>&lt;wsdl:types&g...
2008/11/25
[ "https://Stackoverflow.com/questions/317362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26859/" ]
I've got in my webservice a simple `public boolean isAlive()` service. I defined it in my WSDL : ``` <wsdl:types> <xsd:element name="isAliveResponse" type="xsd:boolean"> </xsd:element> </wsdl:types> <wsdl:message name="isAliveResponse"> <wsdl:part element="ns:isAliveResponse" name="parameters"/> </wsdl:mes...
As said in my edit the problem was the missing wsdl:input. By adding ``` <wsdl:input message="ns:isAliveRequest" /> ``` and ``` <wsdl:message name="isAliveRequest"></wsdl:message> ``` then my original problem is solved... conclusion, I should have searched more by myself before to ask on SO :(
317,364
<p>On Linux, the "top" command shows a detailed but high level overview of your memory usage, showing:</p> <p>Total Memory, Used Memory, Free Memory, Buffer Usage, Cache Usage, Swap size and Swap Usage.</p> <p>My question is, what commands are available to show these memory usage figures in a clear and simple way? Bo...
[ { "answer_id": 317415, "author": "James Anderson", "author_id": 38207, "author_profile": "https://Stackoverflow.com/users/38207", "pm_score": 2, "selected": false, "text": "<p>\"top\" is usually available on Solaris.</p>\n\n<p>If not then revert to \"vmstat\" which is available on most U...
2008/11/25
[ "https://Stackoverflow.com/questions/317364", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40626/" ]
On Linux, the "top" command shows a detailed but high level overview of your memory usage, showing: Total Memory, Used Memory, Free Memory, Buffer Usage, Cache Usage, Swap size and Swap Usage. My question is, what commands are available to show these memory usage figures in a clear and simple way? Bonus points if the...
Here are the basics. I'm not sure that any of these count as "clear and simple" though. **`ps(1)`** For process-level view: ``` $ ps -opid,vsz,rss,osz,args PID VSZ RSS SZ COMMAND 1831 1776 1008 222 ps -opid,vsz,rss,osz,args 1782 3464 2504 433 -bash $ ``` vsz/VSZ: total virtual process size (kb) rss/RSS:...
317,368
<p>I'm trying to figure out what the following line does exactly - specifically the %%s part?</p> <pre><code>cursor.execute('INSERT INTO mastertickets (%s, %s) VALUES (%%s, %%s)'%sourcedest, (self.tkt.id, n)) </code></pre> <p>Any good mini-tutorial about string formatting and inserting variables into strings with Pyt...
[ { "answer_id": 317372, "author": "eduffy", "author_id": 7536, "author_profile": "https://Stackoverflow.com/users/7536", "pm_score": 1, "selected": false, "text": "<p>%% turns into a single %</p>\n" }, { "answer_id": 317385, "author": "Ned Batchelder", "author_id": 14343, ...
2008/11/25
[ "https://Stackoverflow.com/questions/317368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6583/" ]
I'm trying to figure out what the following line does exactly - specifically the %%s part? ``` cursor.execute('INSERT INTO mastertickets (%s, %s) VALUES (%%s, %%s)'%sourcedest, (self.tkt.id, n)) ``` Any good mini-tutorial about string formatting and inserting variables into strings with Python?
The `%%` becomes a single `%`. This code is essentially doing two levels of string formatting. First the `%sourcedest` is executed to turn your code essentially into: ``` cursor.execute('INSERT INTO mastertickets (BLAH, FOO) VALUES (%s, %s)', (self.tkt.id, n)) ``` then the db layer applies the parameters to the slot...
317,374
<p>I am trying to import a .csv file into WorldShip containing names, addresses, and zip codes. I have two profiles set up defining package weight, UPS service, bill transportation, package type, and reference numbers.</p> <p>Can I import just name, addresses and zip codes under a specific profile to keep the other va...
[ { "answer_id": 317372, "author": "eduffy", "author_id": 7536, "author_profile": "https://Stackoverflow.com/users/7536", "pm_score": 1, "selected": false, "text": "<p>%% turns into a single %</p>\n" }, { "answer_id": 317385, "author": "Ned Batchelder", "author_id": 14343, ...
2008/11/25
[ "https://Stackoverflow.com/questions/317374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to import a .csv file into WorldShip containing names, addresses, and zip codes. I have two profiles set up defining package weight, UPS service, bill transportation, package type, and reference numbers. Can I import just name, addresses and zip codes under a specific profile to keep the other variables co...
The `%%` becomes a single `%`. This code is essentially doing two levels of string formatting. First the `%sourcedest` is executed to turn your code essentially into: ``` cursor.execute('INSERT INTO mastertickets (BLAH, FOO) VALUES (%s, %s)', (self.tkt.id, n)) ``` then the db layer applies the parameters to the slot...
317,377
<p>I'm creating a stored procedure to return search results where some of the parameters are optional.</p> <p>I want an "if statement" in my <em>where</em> clause but can't get it working. The <em>where</em> clause should filter by only the non-null parameters.</p> <p>Here's the sp</p> <pre><code>ALTER PROCEDURE spV...
[ { "answer_id": 317386, "author": "Ovidiu Pacurar", "author_id": 28419, "author_profile": "https://Stackoverflow.com/users/28419", "pm_score": 6, "selected": true, "text": "<pre><code>select tblVillas.*, tblWeeklyPrices.price \nfrom tblVillas\nINNER JOIN tblWeeklyPrices on tblVillas.villa...
2008/11/25
[ "https://Stackoverflow.com/questions/317377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40623/" ]
I'm creating a stored procedure to return search results where some of the parameters are optional. I want an "if statement" in my *where* clause but can't get it working. The *where* clause should filter by only the non-null parameters. Here's the sp ``` ALTER PROCEDURE spVillaGet -- Add the parameters for the sto...
``` select tblVillas.*, tblWeeklyPrices.price from tblVillas INNER JOIN tblWeeklyPrices on tblVillas.villaId = tblWeeklyPrices.villaFK where (@accomodationFK IS null OR accomodationTypeFK = @accomodationFK) AND (@regionFK IS null or regionFK = @regionFK) AND (@sleeps IS null OR sleeps = @sleeps) AND (@priceFloor...
317,378
<p>When the page is done loading I call a function which puts the hover event on $('a.tooltip'). When I want to <em>unbind</em> this event I do the following: </p> <pre><code> $('a.tooltip').unbind('mouseover mouseout'); </code></pre> <p>That works! However when I want rebind the hover event and I call the funct...
[ { "answer_id": 317474, "author": "Nathan Long", "author_id": 4376, "author_profile": "https://Stackoverflow.com/users/4376", "pm_score": 2, "selected": false, "text": "<p>Are you sure the unbinding is working correctly? In my experience, .hover() does rebind properly, but I have had to u...
2008/11/25
[ "https://Stackoverflow.com/questions/317378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
When the page is done loading I call a function which puts the hover event on $('a.tooltip'). When I want to *unbind* this event I do the following: ``` $('a.tooltip').unbind('mouseover mouseout'); ``` That works! However when I want rebind the hover event and I call the function that was first loaded at documen...
Are you sure the unbinding is working correctly? In my experience, .hover() does rebind properly, but I have had to use this unbind syntax: ``` $(this).unbind('mouseenter').unbind('mouseleave'); ``` When I tried putting both events into one unbind(), it only unbound one of them. I wonder if that's happening for you...
317,381
<p>OK, So i have been watching some MVC vids and reading some bits. I am new to the entire MVC pattern, and until now have been happily wrapped up in the web forms world!</p> <p>Like with so many demos it all seems great and I'm sure I'll have lots I dont understand as I move along, but in the first instance...</p> <...
[ { "answer_id": 317388, "author": "CodeClimber", "author_id": 4724, "author_profile": "https://Stackoverflow.com/users/4724", "pm_score": 0, "selected": false, "text": "<p>You can either pass both objects inside the ViewData hashtable, or create a MyViewViewModel, add two properties, and ...
2008/11/25
[ "https://Stackoverflow.com/questions/317381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6125/" ]
OK, So i have been watching some MVC vids and reading some bits. I am new to the entire MVC pattern, and until now have been happily wrapped up in the web forms world! Like with so many demos it all seems great and I'm sure I'll have lots I dont understand as I move along, but in the first instance... I can see that ...
Setup your strongly typed ViewData class with two properties like this ``` public class MyViewData { public IEnumerable<Car> Cars { get; set; } public IEnumerable<People> People { get; set; } } ``` and then fill them in the controller, Sorry for the duplicate. In good MVC spirit try to use interfaces where po...
317,389
<p>I'm testing the basics for exchanging rest messages between a asp.net mvc site and a WCF 3.5 service. The service is built using the template found in the WCF REST Starter Kit found on codeplex. I would like to exchange json messages using jquery. The REST Singleton service is working properly and it also provide ex...
[ { "answer_id": 317444, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 3, "selected": true, "text": "<p>\"PUT\" and \"DELETE\" are not supported by all browsers according to jQuery</p>\n\n<blockquote>\n <p>The type of reques...
2008/11/25
[ "https://Stackoverflow.com/questions/317389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1929/" ]
I'm testing the basics for exchanging rest messages between a asp.net mvc site and a WCF 3.5 service. The service is built using the template found in the WCF REST Starter Kit found on codeplex. I would like to exchange json messages using jquery. The REST Singleton service is working properly and it also provide examp...
"PUT" and "DELETE" are not supported by all browsers according to jQuery > > The type of request to make ("POST" or > "GET"), default is "GET". Note: Other > HTTP request methods, such as PUT and > DELETE, can also be used here, but > they are not supported by all > browsers. > > > <http://docs.jquery.com/Aj...
317,400
<p>I'm making a simple Image Debugger Visualizer. Code is below. I'm not sure if i need to manually dispose of the Image instance? Because i'm making a windows Form window and the PictureBox inside that contains my dynamic image .. do i need to add some special code when the form is terminating, to dispose of this? </p...
[ { "answer_id": 317410, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 1, "selected": false, "text": "<p>The picture box control does not dispose of the image, so this is up to you, yes.</p>\n" }, { "answer_id":...
2008/11/25
[ "https://Stackoverflow.com/questions/317400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30674/" ]
I'm making a simple Image Debugger Visualizer. Code is below. I'm not sure if i need to manually dispose of the Image instance? Because i'm making a windows Form window and the PictureBox inside that contains my dynamic image .. do i need to add some special code when the form is terminating, to dispose of this? here...
Change your Show method to this: ``` protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider) { Image image = (Image) objectProvider.GetObject(); using (Form form = new Form()) { PictureBox pictureBox = new Pi...
317,413
<p>I am creating a GUI frontend for the Eve Online API in Python.</p> <p>I have successfully pulled the XML data from their server.</p> <p>I am trying to grab the value from a node called "name":</p> <pre><code>from xml.dom.minidom import parse dom = parse("C:\\eve.xml") name = dom.getElementsByTagName('name') print...
[ { "answer_id": 317421, "author": "eduffy", "author_id": 7536, "author_profile": "https://Stackoverflow.com/users/7536", "pm_score": 9, "selected": true, "text": "<p>It should just be</p>\n\n<pre><code>name[0].firstChild.nodeValue\n</code></pre>\n" }, { "answer_id": 317494, "a...
2008/11/25
[ "https://Stackoverflow.com/questions/317413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30786/" ]
I am creating a GUI frontend for the Eve Online API in Python. I have successfully pulled the XML data from their server. I am trying to grab the value from a node called "name": ``` from xml.dom.minidom import parse dom = parse("C:\\eve.xml") name = dom.getElementsByTagName('name') print name ``` This seems to fi...
It should just be ``` name[0].firstChild.nodeValue ```
317,423
<p>I've posted this <a href="https://stackoverflow.com/questions/155739/detecting-unsaved-changes-using-javascript#317246">here</a>, but thought it might deserve a question on its own.</p> <p>What I'm trying to do is show a dialog box that asks the user if he/she wants to leave the page if there are unsaved changes. T...
[ { "answer_id": 317498, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 1, "selected": false, "text": "<p>I haven't encountered this, but surely you could set the flag variable to be equal to the result of the dialog? If the...
2008/11/25
[ "https://Stackoverflow.com/questions/317423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15349/" ]
I've posted this [here](https://stackoverflow.com/questions/155739/detecting-unsaved-changes-using-javascript#317246), but thought it might deserve a question on its own. What I'm trying to do is show a dialog box that asks the user if he/she wants to leave the page if there are unsaved changes. That all works fine. B...
In reaction to annakata: Yes, but you want the result of the dialog box to be used by the browser. So you might think using 'return bFlag' would do the trick (or event.returnValue = bFlag), but that gives you a second dialog box. I've found a way around, thanks to [this page](http://www.codeproject.com/KB/aspnet/EWSWeb...
317,424
<p>I am running a query from ASP using a MySQL database, I want to create a variable (ssResult) based on the result with a person's name (fullname), if the record does not exist I want to assign the text 'N/A' to the variable, code below, I currently use a function getOther for my database connections which passes the ...
[ { "answer_id": 317461, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Why not change the SQL to only pull out a result with a First Name, that way the \"N/A\" would apply:</p>\n\n<pre>sResult =...
2008/11/25
[ "https://Stackoverflow.com/questions/317424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13658/" ]
I am running a query from ASP using a MySQL database, I want to create a variable (ssResult) based on the result with a person's name (fullname), if the record does not exist I want to assign the text 'N/A' to the variable, code below, I currently use a function getOther for my database connections which passes the col...
You could try changing the line ``` if not rstemp.eof then ``` with ``` if rstemp.RecordCount > 0 then ```
317,447
<p>I am using macros in excel 2007 for my work. I am working with many data and I need to sum data from 2 or more rows in the same coloumn according to the same month. However the month column is expressed as date.</p> <p>for example, i have series of data</p> <pre><code>A B 2/10/2008 2 2/10/2008 3 4...
[ { "answer_id": 317455, "author": "Galwegian", "author_id": 3201, "author_profile": "https://Stackoverflow.com/users/3201", "pm_score": 0, "selected": false, "text": "<p>If you are unfamiliar with VBA, I would start off by recording a macro while doing what you want to do by using the Sub...
2008/11/25
[ "https://Stackoverflow.com/questions/317447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am using macros in excel 2007 for my work. I am working with many data and I need to sum data from 2 or more rows in the same coloumn according to the same month. However the month column is expressed as date. for example, i have series of data ``` A B 2/10/2008 2 2/10/2008 3 4/10/2008 3 5/11/20...
``` A B C D E F 1 10/ 1/2008 24106 1 Oct-08 24106 8 2 10/31/2008 24106 7 Nov-08 24107 11 3 11/ 1/2008 24107 8 Dec-08 24108 6 4 11/30/2008 24107 3 5 12/ 1/2008 24108 2 6 12/ 2/2008 24108 4 B1 =MON...
317,450
<p>In the <a href="http://www.boost.org/doc/html/signals.html" rel="noreferrer" title="Boost Signals documentation">Boost Signals</a> library, they are overloading the () operator.</p> <p>Is this a convention in C++? For callbacks, etc.?</p> <p>I have seen this in code of a co-worker (who happens to be a big Boost fa...
[ { "answer_id": 317458, "author": "JeffV", "author_id": 445087, "author_profile": "https://Stackoverflow.com/users/445087", "pm_score": 1, "selected": false, "text": "<p>Another co-worker pointed out that it could be a way to disguise functor objects as functions. For example, this:</p>\n...
2008/11/25
[ "https://Stackoverflow.com/questions/317450", "https://Stackoverflow.com", "https://Stackoverflow.com/users/445087/" ]
In the [Boost Signals](http://www.boost.org/doc/html/signals.html "Boost Signals documentation") library, they are overloading the () operator. Is this a convention in C++? For callbacks, etc.? I have seen this in code of a co-worker (who happens to be a big Boost fan). Of all the Boost goodness out there, this has o...
One of the primary goal when overloading operator() is to create a functor. A functor acts just like a function, but it has the advantages that it is stateful, meaning it can keep data reflecting its state between calls. Here is a simple functor example : ``` struct Accumulator { int counter = 0; int operator...
317,462
<p>In my everlasting quest to suck less I'm trying to understand the "yield" statement, but I keep encountering the same error.</p> <blockquote> <p>The body of [someMethod] cannot be an iterator block because 'System.Collections.Generic.List&lt; AClass>' is not an iterator interface type.</p> </blockquote> <p>Thi...
[ { "answer_id": 317477, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 6, "selected": true, "text": "<p>A method using <em>yield return</em> must be declared as returning one of the following two interfaces:</p>\n\n<pre...
2008/11/25
[ "https://Stackoverflow.com/questions/317462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
In my everlasting quest to suck less I'm trying to understand the "yield" statement, but I keep encountering the same error. > > The body of [someMethod] cannot be an iterator block because > 'System.Collections.Generic.List< AClass>' is not an iterator interface type. > > > This is the code where I got stuck: ...
A method using *yield return* must be declared as returning one of the following two interfaces: ``` IEnumerable<SomethingAppropriate> IEnumerator<SomethingApropriate> ``` (thanks [Jon](https://stackoverflow.com/users/22656/jon-skeet) and [Marc](https://stackoverflow.com/users/23354/marc-gravell) for pointing out IE...
317,472
<p>I have a container element which I need to resize as its contents change. It contains 2 absolutely positioned divs which can both change height. If I don't specify the height of the container then anything after the container disappears under the contents. </p> <p>At the moment I am doing the following but I'd be p...
[ { "answer_id": 317495, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 6, "selected": true, "text": "<p>This is a very odd question, as div's height is always the height of its children. </p>\n\n<p>Are you floating content in y...
2008/11/25
[ "https://Stackoverflow.com/questions/317472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20074/" ]
I have a container element which I need to resize as its contents change. It contains 2 absolutely positioned divs which can both change height. If I don't specify the height of the container then anything after the container disappears under the contents. At the moment I am doing the following but I'd be pleased to ...
This is a very odd question, as div's height is always the height of its children. Are you floating content in your container div? When you float child content the containing div doesn't act the same anymore. If you're floating content that extends past the bottom of the container div, add the following div to the v...
317,527
<p>I know a lot about C# but this one is stumping me and Google isn't helping.</p> <p>I have an IEnumerable range of objects. I want to set a property on the first one. I do so, but when I enumerate over the range of objects after the modification, I don't see my change.</p> <p>Here's a good example of the problem:...
[ { "answer_id": 317542, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 0, "selected": false, "text": "<p>I suspect something going in the background. Most likely due to the fact the IEnumerables can only be iterated once.</p>...
2008/11/25
[ "https://Stackoverflow.com/questions/317527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5198/" ]
I know a lot about C# but this one is stumping me and Google isn't helping. I have an IEnumerable range of objects. I want to set a property on the first one. I do so, but when I enumerate over the range of objects after the modification, I don't see my change. Here's a good example of the problem: ``` public st...
When you call First() it enumerates over the result of this bit of code: ``` Select(i => new SubItem() {Name = "foo", MagicNumber = i}); ``` Note that the Select is a lazy enumerator, meaning that it only does the select when you ask for an item from it (and does it *every* time you ask it). The results are not stor...
317,531
<p>given the following code: </p> <pre><code>import ctypes ip="192.168.1.1" thisdll = ctypes.cdll['aDLL'] thisdll.functionThatExpectsAnIP(ip) </code></pre> <p>how can I correctly pack this for a DLL that expects it as a c_ulong datatype?</p> <p>I've tried using: </p> <pre><code>ip_netFrmt = socket.inet_aton(ip)...
[ { "answer_id": 317572, "author": "user7461", "author_id": 7461, "author_profile": "https://Stackoverflow.com/users/7461", "pm_score": 0, "selected": false, "text": "<p>First a disclaimer: This is just an educated guess.</p>\n\n<p>an ip-address is traditionally represented as four bytes -...
2008/11/25
[ "https://Stackoverflow.com/questions/317531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40637/" ]
given the following code: ``` import ctypes ip="192.168.1.1" thisdll = ctypes.cdll['aDLL'] thisdll.functionThatExpectsAnIP(ip) ``` how can I correctly pack this for a DLL that expects it as a c\_ulong datatype? I've tried using: ``` ip_netFrmt = socket.inet_aton(ip) ip_netFrmt_c = ctypes.c_ulong(ip_netFrmt) ...
The inet\_aton returns a string of bytes. This used to be the *lingua franca* for C-language interfaces. Here's how to unpack those bytes into a more useful value. ``` >>> import socket >>> packed_n= socket.inet_aton("128.0.0.1") >>> import struct >>> struct.unpack( "!L", packed_n ) (2147483649L,) >>> hex(_[0]) '0x80...
317,567
<p>How do I add new record to DataGridView control in VB.Net?</p> <p>I don't use dataset or database binding. I have a small form with 3 fields and when the user clicks OK they should be added to the DataGridView control as a new row.</p>
[ { "answer_id": 317584, "author": "Galwegian", "author_id": 3201, "author_profile": "https://Stackoverflow.com/users/3201", "pm_score": 2, "selected": false, "text": "<p>I think you should build a dataset/datatable in code and bind the grid to that.</p>\n" }, { "answer_id": 317624...
2008/11/25
[ "https://Stackoverflow.com/questions/317567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do I add new record to DataGridView control in VB.Net? I don't use dataset or database binding. I have a small form with 3 fields and when the user clicks OK they should be added to the DataGridView control as a new row.
If you want to add the row to the end of the grid use the **Add()** method of the Rows collection... ``` DataGridView1.Rows.Add(New String(){Value1, Value2, Value3}) ``` If you want to insert the row at a partiular position use the **Insert()** method of the Rows collection (as GWLlosa also said)... ``` DataGridVie...
317,576
<p>I have a table, users, in an Oracle 9.2.0.6 database. Two of the fields are varchar - last_name and first_name.</p> <p>When rows are inserted into this table, the first name and last name fields are supposed to be in all upper case, but somehow some values in these two fields are mixed case.</p> <p>I want to run ...
[ { "answer_id": 317601, "author": "BQ.", "author_id": 4632, "author_profile": "https://Stackoverflow.com/users/4632", "pm_score": 7, "selected": true, "text": "<p>How about this:</p>\n\n<pre><code>select id, first, last from mytable\nwhere first != upper(first) or last != upper(last);\n</...
2008/11/25
[ "https://Stackoverflow.com/questions/317576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40619/" ]
I have a table, users, in an Oracle 9.2.0.6 database. Two of the fields are varchar - last\_name and first\_name. When rows are inserted into this table, the first name and last name fields are supposed to be in all upper case, but somehow some values in these two fields are mixed case. I want to run a query that wil...
How about this: ``` select id, first, last from mytable where first != upper(first) or last != upper(last); ```
317,580
<p>I'm looking for the best way to interpret the standard (well, standardish) Ethernet PHY registers, to determine the speed that an Ethernet link is actually running at. (e.g. 10/100/1000 and full/half-duplex)</p> <p>I daresay that this is to be found in the source of things like Linux, and I'm just off to look ther...
[ { "answer_id": 317601, "author": "BQ.", "author_id": 4632, "author_profile": "https://Stackoverflow.com/users/4632", "pm_score": 7, "selected": true, "text": "<p>How about this:</p>\n\n<pre><code>select id, first, last from mytable\nwhere first != upper(first) or last != upper(last);\n</...
2008/11/25
[ "https://Stackoverflow.com/questions/317580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/987/" ]
I'm looking for the best way to interpret the standard (well, standardish) Ethernet PHY registers, to determine the speed that an Ethernet link is actually running at. (e.g. 10/100/1000 and full/half-duplex) I daresay that this is to be found in the source of things like Linux, and I'm just off to look there now, but ...
How about this: ``` select id, first, last from mytable where first != upper(first) or last != upper(last); ```
317,587
<p>The navigation on the left menu in the below site uses CSS for mouseover links.<br /><a href="http://www.pvh.com/" rel="nofollow noreferrer">PVH</a></p> <p>When I take the code of the navigation and make it separate page. Then the mouseover links are not working. What could be the reason?<br /> <a href="http://shiv...
[ { "answer_id": 317595, "author": "philistyne", "author_id": 16597, "author_profile": "https://Stackoverflow.com/users/16597", "pm_score": 3, "selected": true, "text": "<p>Probably...</p>\n\n<pre><code>&lt;script src=\"menu_1b.js\" type=\"text/javascript\"&gt;\n&lt;/script&gt;\n&lt;script...
2008/11/25
[ "https://Stackoverflow.com/questions/317587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34642/" ]
The navigation on the left menu in the below site uses CSS for mouseover links. [PVH](http://www.pvh.com/) When I take the code of the navigation and make it separate page. Then the mouseover links are not working. What could be the reason? [Test](http://shivanand.in/tmp/navigation.html)
Probably... ``` <script src="menu_1b.js" type="text/javascript"> </script> <script src="menu_com.js" type="text/javascript"> ``` have something to say on the matter. EDIT: A function called function CreateMenuStructureAgain() kind of gives it away.
317,591
<p>is it possible to create my own custom keys in the asp.net web.config file and iterate through them with C#? How do you do both (where do I put the key? what format?)? I have an application for an intranet that does certain things based upon the IP address of the client. Instead of hard coding those in the codeb...
[ { "answer_id": 317629, "author": "Arnout", "author_id": 3496, "author_profile": "https://Stackoverflow.com/users/3496", "pm_score": 2, "selected": false, "text": "<p>You can create a <a href=\"http://msdn.microsoft.com/en-us/library/2tw134k3(VS.80).aspx\" rel=\"nofollow noreferrer\">Cust...
2008/11/25
[ "https://Stackoverflow.com/questions/317591", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28045/" ]
is it possible to create my own custom keys in the asp.net web.config file and iterate through them with C#? How do you do both (where do I put the key? what format?)? I have an application for an intranet that does certain things based upon the IP address of the client. Instead of hard coding those in the codebehind f...
I think this should do it for you... This is in your web.config... ``` <configSections> <section name="DataBaseKeys" type="System.Configuration.NameValueFileSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> </configSections> <DataBaseKeys> <!--Connection Strings f...
317,606
<p>How can I select multiple elements using a WHERE...IN... type of clause as in</p> <pre><code>select * from orders where orderid in (1, 4, 5) </code></pre> <p>in LinqToSql? I'd prefer not to have a lambda expression since they scare me.</p>
[ { "answer_id": 317608, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "<p>LINQ has \"Contains\" which is like \"IN\" but expressed the other way round - an element isn't \"in\" a set, a set \"...
2008/11/25
[ "https://Stackoverflow.com/questions/317606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16440/" ]
How can I select multiple elements using a WHERE...IN... type of clause as in ``` select * from orders where orderid in (1, 4, 5) ``` in LinqToSql? I'd prefer not to have a lambda expression since they scare me.
LINQ has "Contains" which is like "IN" but expressed the other way round - an element isn't "in" a set, a set "contains" an element. ``` int[] validIds = { 1, 4, 5 }; var query = from order in db.Orders where validIds.Contains(order.Id) select order ``` This is more simply expressed (IMO) wit...
317,617
<p>I would like to write a utility that will provide me with a relatively unique ID in Java. Something pretty simple, like x bits from timestamp + y bits from random number.</p> <p>So, how would I implement the following method:</p> <pre><code>long getUniqueID() { long timestamp = System.currentTimeMillis(); ...
[ { "answer_id": 317633, "author": "Judge Maygarden", "author_id": 1491, "author_profile": "https://Stackoverflow.com/users/1491", "pm_score": 1, "selected": false, "text": "<p>What you are trying to do is create a <a href=\"http://en.wikipedia.org/wiki/Hash_function\" rel=\"nofollow noref...
2008/11/25
[ "https://Stackoverflow.com/questions/317617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20498/" ]
I would like to write a utility that will provide me with a relatively unique ID in Java. Something pretty simple, like x bits from timestamp + y bits from random number. So, how would I implement the following method: ``` long getUniqueID() { long timestamp = System.currentTimeMillis(); long random = some ra...
Just clip the bits you don't need: ``` return java.util.UUID.randomUUID().getLeastSignificantBits(); ```