qid int64 4 19.1M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
386,713 | <p>I'm trying to make two XML attributes to be mutually exclusive. How can one create an XSD schema to capture this kind of scenario?</p>
<p>I would like to have one of these</p>
<pre><code><elem value="1" />
<elem ref="something else" />
</code></pre>
<p>but not</p>
<pre><code><elem value="1" ref="something else" />
</code></pre>
| [
{
"answer_id": 386717,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 3,
"selected": false,
"text": "<elem type=\"xxx\"> \n<elem ref=\"yyy\">\n <elem>"
},
{
"answer_id": 386732,
"author": "Daniel Silveira",
"a... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21704/"
] |
386,715 | <p>Our 32-Bit application launches Windows LNK files (Shell Links) via ShellExecute. When it tries to "launch" a link to a 64-Bit binary (such as the "Internet Explorer (64-Bit)" shortcut in Start Menu) it always ends up launching the 32-Bit binary. Internally, ShellExecute incorrectly resolves the link target: There's a hidden field inside the LNK which holds FOLDERID_ProgramFiles. A 64-Bit app resolves this to the 64-Bit Program Files directory, but a 32-Bit app won't.</p>
<p>Wow64DisableWow64FsRedirection does not change this behavior of ShellExecute.</p>
<p>Besides going through a 64-Bit "trampoline" process (which is not an option due to how our plugin architecture works), Is there any way for a 32-Bit app to launch shell links exactly the way a 64-Bit app would?</p>
| [
{
"answer_id": 1949087,
"author": "Andrew Sandoval",
"author_id": 205810,
"author_profile": "https://Stackoverflow.com/users/205810",
"pm_score": 0,
"selected": false,
"text": "#include <windows.h>\n#include <ShellAPI.h>\n#include <stdio.h>\n\nint main(int iArgc, const char *pArgv[])\n{\... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
386,728 | <p>I am using path-based authentication with svnserve, but it is giving me permission errors if I specify a repository. However, if I just specify a path then it authenticates.</p>
<p>In my authz file, if I do this it works:</p>
<pre><code>[/my/path]
my_username = r
</code></pre>
<p>If I do this, it does not work:</p>
<pre><code>[svn:/my/path]
my_username = r
</code></pre>
<p>I'm fairly certain that "svn" is the actual name of my repository. If someone could let me know how I find out the name of a repository, that might help. The repository is under /usr/local/svn.</p>
| [
{
"answer_id": 386789,
"author": "LizB",
"author_id": 13616,
"author_profile": "https://Stackoverflow.com/users/13616",
"pm_score": 0,
"selected": false,
"text": "[bizlib:/branches/2.0.x]\n dev_login = r\n"
}
] | 2008/12/22 | [
"https://Stackoverflow.com/questions/386728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
386,731 | <p>I would like to get the absolute position of an element in relation to the window/root element when it is double clicked. The element's relative position within it's parent is all I can seem to get to, and what I'm trying to get to is the point relative to the window. I've seen solutions of how to get a the point of an element on the screen, but not in the window.</p>
| [
{
"answer_id": 387034,
"author": "Oleg",
"author_id": 47856,
"author_profile": "https://Stackoverflow.com/users/47856",
"pm_score": -1,
"selected": false,
"text": "Mouse.GetPosition(IInputElement relativeTo) protected override void OnMouseDown(MouseButtonEventArgs e)\n {\n base... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42858/"
] |
386,753 | <p>I am trying to talk to a device using python. I have been handed a tuple of bytes which contains the storage information. How can I convert the data into the correct values:</p>
<p>response = (0, 0, 117, 143, 6)</p>
<p>The first 4 values are a 32-bit int telling me how many bytes have been used and the last value is the percentage used.</p>
<p>I can access the tuple as response[0] but cannot see how I can get the first 4 values into the int I require.</p>
| [
{
"answer_id": 386763,
"author": "Jay",
"author_id": 20840,
"author_profile": "https://Stackoverflow.com/users/20840",
"pm_score": 5,
"selected": true,
"text": "import struct\n\nresponse = (0, 0, 117, 143, 6)\nstruct.unpack(\">I\", ''.join([chr(x) for x in response[:-1]]))\n import struc... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24459/"
] |
386,762 | <p>I have a class called DatabaseHelper that wraps a DbConnection. What's the proper way to setup this class for a using statement? I have implemented IDisposible, but I'm not sure when and where I should be calling Connection.Close() or Connection.Dispose().</p>
<p>When I simply call Connection.Dispose() in my own Dispose() method, I'll sometimes get a SocketException from my DbConnection object. I assume this is because old connections are being left open, but there's no details attached the to exception, so I can't know for sure.</p>
| [
{
"answer_id": 386772,
"author": "Neil Barnwell",
"author_id": 26414,
"author_profile": "https://Stackoverflow.com/users/26414",
"pm_score": 4,
"selected": true,
"text": "public void Dispose()\n{\n Dispose(true);\n GC.SuppressFinalize(this);\n}\n\nprotected virtual void Dispose(boo... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31516/"
] |
386,783 | <p>I don't know why this method returns a blank string:</p>
<pre><code>- (NSString *)installedGitLocation {
NSString *launchPath = @"/usr/bin/which";
// Set up the task
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:launchPath];
NSArray *args = [NSArray arrayWithObject:@"git"];
[task setArguments:args];
// Set the output pipe.
NSPipe *outPipe = [[NSPipe alloc] init];
[task setStandardOutput:outPipe];
[task launch];
NSData *data = [[outPipe fileHandleForReading] readDataToEndOfFile];
NSString *path = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
return path;
}
</code></pre>
<p>If instead of passing <code>@"git"</code> as the argument, I pass <code>@"which"</code> I get <code>/usr/bin/which</code> returned as expected. So at least the principle works.</p>
<p>from the terminal</p>
<pre><code>$ which which
$ /usr/bin/which
$
$ which git
$ /usr/local/git/bin/git
</code></pre>
<p>So it works there.</p>
<p>The only thing I can think of is that <code>which</code> isn't searching through all the paths in my environment.</p>
<p>This is driving me crazy! Does anyone have any ideas?</p>
<p><strong>EDIT:</strong> It looks like this is about setting up either NSTask or the user's shell (e.g., ~/.bashrc) so that the correct environment ($PATH) is seen by NSTask.</p>
| [
{
"answer_id": 386813,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 2,
"selected": false,
"text": "which"
},
{
"answer_id": 387997,
"author": "Chris Hanson",
"author_id": 714,
"author_profile": "http... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41116/"
] |
386,792 | <p>In Java 1.4 you could use ((SunToolkit) Toolkit.getDefaultToolkit()).getNativeWindowHandleFromComponent() but that was removed.</p>
<p>It looks like you have to use JNI to do this now. Do you have the JNI code and sample Java code to do this?</p>
<p>I need this to call the Win32 GetWindowLong and SetWindowLong API calls, which can be done via the Jawin library.</p>
<p>I would like something very precise so I can pass a reference to the JDialog or JFrame and get the window handle.</p>
<p><a href="https://stackoverflow.com/questions/265602/swing-transparency-using-jni">Swing transparency using JNI</a> may be related.</p>
| [
{
"answer_id": 389734,
"author": "RealHowTo",
"author_id": 25122,
"author_profile": "https://Stackoverflow.com/users/25122",
"pm_score": 4,
"selected": false,
"text": "JNIEXPORT jint JNICALL Java_JavaHowTo_getHwnd\n (JNIEnv *env, jclass obj, jstring title){\n HWND hwnd = NULL;\n cons... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35264/"
] |
386,795 | <p>SQL Server 2005</p>
<p>I have 10 million rows in DB, and run a select (with lots of "where" and joints.. pretty complex). The results are presented in grid (think goolge results) and because of that, the user cannot possibly use more then 1000 results. </p>
<p>So I limit my SQL with a TOP 1000.</p>
<p><strong>Problem</strong>: User still wants to know that there are 5432 results for his search.</p>
<p>Can I get that info without paying the price (or in other words, with still getting the speed benefits the "top 1000" is giving me ?)</p>
<p><strong>Assumptions</strong>
- Assume that the TOP 1000 brings 1000 out of <strong>100K</strong> rows. So even the network price of moving 100K might be an issue.</p>
<p><strong>Conclusions</strong>
There is no free lunch! you can get the elegant way (accepted answer) but it still takes as long as the more expensive operation (i.e. counting all results).
In real life, I will go with the 2 SQL approach, one to return top 1000 rows for display, and one that is ASYNC and updates some AJAX panel with the count(*) results that will take much much longer to computer</p>
| [
{
"answer_id": 386805,
"author": "Neil Barnwell",
"author_id": 26414,
"author_profile": "https://Stackoverflow.com/users/26414",
"pm_score": 3,
"selected": false,
"text": "-- Get the count\nselect count(*) from table where [criteria]\n\n-- Get the data\nselect [cols] from table where [cr... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386795",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/350/"
] |
386,826 | <p>This happens when compiling for Any Cpu as well as compiling to x86. Sections of the GUI doesn't redraw unless it's resized, for instance if the main form is maximized some of the controls don't resize with it, and others have sections that don't redraw and displays the what was previously there.</p>
<p>This works fine on 32-bit machines, both XP and Vista, but on 64-bit Vista (don't have x64 XP to test with) the redrawing just isn't working properly.</p>
<p>Anyone have any ideas on where to start tracking this down?</p>
<p>Edit: This occurs on 2 separate machines, and at least the one I'm currently on has the latest drivers from NVidia. </p>
<p>Edit2: Running a 32-bit XP virtual machine on my 64-bit machine and the application doesn't exhibit the redrawing issue in the VM</p>
<p>Edit3: It may be a driver issue, but we don't know if or when drivers will fix the issue. A co-worker says there's fewer issues with an ATI card at home than with NVidia, but I've been updating my video drivers pretty much monthly for the past few months and it's still not resolved, so we can't just release our product and just tell our customers that some day the driver manufacturers may get around to fixing this.</p>
<p>Does anyone have any insight on what things to try to avoid? We're compiling as x86 and all our components are x86. I can't seem to reproduce this issue with any of the components in test projects, and I haven't heard anyone else report these issues on most of the the component forums, so it is fairly likely that it's something we're doing.</p>
| [
{
"answer_id": 555142,
"author": "Bids",
"author_id": 35996,
"author_profile": "https://Stackoverflow.com/users/35996",
"pm_score": 5,
"selected": true,
"text": "WM_SIZE MoveWindow() WM_SIZE WM_SIZE"
},
{
"answer_id": 557418,
"author": "stusmith",
"author_id": 6604,
"... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23822/"
] |
386,828 | <p>Now I know there are a lot of similar questions around SO but I think I've covered all the basics. Here's what I know:</p>
<p>My favicon is accessible through /favicon.ico (<a href="http://www.bandcmotors.co.uk/favicon.ico" rel="nofollow noreferrer">full link</a>)</p>
<p>The HTML is (<a href="http://www.bandcmotors.co.uk" rel="nofollow noreferrer">page URL</a>):</p>
<pre><code><link rel="icon" href="http://www.bandcmotors.co.uk/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="http://www.bandcmotors.co.uk/favicon.ico" type="image/x-icon" />
</code></pre>
<p>I've tried relative and absolute versions too. No love.</p>
<p>The HTTP response headers:</p>
<pre><code>Date: Mon, 22 Dec 2008 15:07:34 GMT
Server: Cherokee
Etag: 494bc264=57e
Last-Modified: Fri, 19 Dec 2008 15:48:52 GMT
Content-Type: image/x-icon
Content-Length: 1406
200 OK
</code></pre>
<p>The icon loads fine in a browser and I've cleared my cache but I still can't see the icon in the address bar or tab. On either Firefox or IE.</p>
<p>What on earth am I doing wrong?</p>
<p>Edit 1. I used <a href="http://www.html-kit.com/favicon/validator/" rel="nofollow noreferrer">a validator</a> and it rather helpfully told me that it could not download it. Rather odd considering I can download it fine... If anybody could explain that, it might help fix the problem.</p>
<p>Edit 2. I just drop-kicked my computer, restarted and it all worked. I hate caches that refuse to clear themselves properly ****grumbles**** >=(</p>
| [
{
"answer_id": 386870,
"author": "William Brendel",
"author_id": 2405,
"author_profile": "https://Stackoverflow.com/users/2405",
"pm_score": 0,
"selected": false,
"text": "<link rel=\"shortcut icon\" href=\"/favicon.ico\" type=\"image/x-icon\" />\n <link rel=\"shortcut icon\" href=\"/fav... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12870/"
] |
386,831 | <p>My MS Visual C# program was compiling and running just fine.
I close MS Visual C# to go off and do other things in life.</p>
<p>I reopen it and (before doing anything else) go to "Publish" my program and get the following error message:</p>
<blockquote>
<p>Program C:\myprogram.exe does not contain a static 'Main' method suitable for an entry point</p>
</blockquote>
<p>Huh? Yes it does... and it was all working 15 min earlier. Sure, I can believe that I accidentally hit something or done something before I closed it up... but what? How do I troubleshoot this? </p>
<p>My Program.cs file looks like this:</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Threading;
namespace SimpleAIMLEditor
{
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new mainSAEForm());
}
}
}
</code></pre>
<p>...and there are some comments in there. There are no other errors.</p>
<p>Help?</p>
| [
{
"answer_id": 386852,
"author": "configurator",
"author_id": 9536,
"author_profile": "https://Stackoverflow.com/users/9536",
"pm_score": 2,
"selected": false,
"text": "Build Action Compile"
},
{
"answer_id": 386894,
"author": "Igal Tabachnik",
"author_id": 8205,
"aut... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44004/"
] |
386,834 | <p>I'm building an outlook control for an application, and am populating a treelist by recursively adding child folders. These folders are declared as Outlook.MAPIFolder. But the application only allows import from actual emails, so I want to exclude folders containing calendar items. I can right click on those folders in outlook, go to properties, and see type as "Folder containing Calendar Items". But I don't seem to be able to get at that programmatically in VB.Net. Am I missing something simple?</p>
| [
{
"answer_id": 387448,
"author": "Oliver Giesen",
"author_id": 9784,
"author_profile": "https://Stackoverflow.com/users/9784",
"pm_score": 2,
"selected": false,
"text": "DefaultItemType olMailItem olPostItem DefaultItemType OlItemType"
}
] | 2008/12/22 | [
"https://Stackoverflow.com/questions/386834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30415/"
] |
386,838 | <p>I'm working on a PHP CMS like project and I'm trying to find out what's the most convenient way of dealing with the CRUD functionality in PHP.</p>
<p>The CMS is programmed completely in procedural PHP (no OOP - I know that many of you will not agree with this...) and was designed keeping everything as simple and light as possible, as well as creating highly reusable functions and snippets of code.</p>
<p>The CMS allows multiple modules to be installed / activated on needs basis. These modules describe different types of content so I will probably end up having something like pages, news, blogs just to name a few.</p>
<p>For each of this content types I will have to create the CRUD operations and now I'm trying to find the most convenient way to achieve this.</p>
<p>One requirement would be that the form for each of these content types is contained in a single external file (for both insert and edit) and if there is some way to integrate server side input validation that would be a plus.</p>
| [
{
"answer_id": 386936,
"author": "dcousineau",
"author_id": 20265,
"author_profile": "https://Stackoverflow.com/users/20265",
"pm_score": 3,
"selected": true,
"text": "CREATE TABLE `content` (\n `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,\n `name` VARCHAR NOT NULL,\n `short_descriptio... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43923/"
] |
386,845 | <p>I've written a PHP script that handles file downloads, determining which file is being requested and setting the proper HTTP headers to trigger the browser to actually download the file (rather than displaying it in the browser).</p>
<p>I now have a problem where some users have reported certain files being identified incorrectly (so regardless of extension, the browser will consider it a GIF image). I'm guessing this is because I haven't set the "Content-type" in the response header. Is this most likely the case? If so, is there a fairly generic type that could be used for all files, rather than trying to account for every possible file type?</p>
<p>Currently I'm only setting the value "Content-disposition: attachment; filename=arandomf.ile"</p>
<p><strong>Update:</strong> I followed this guide here to build a more robust process for file downloads (<a href="http://w-shadow.com/blog/2007/08/12/how-to-force-file-download-with-php/" rel="nofollow noreferrer">http://w-shadow.com/blog/2007/08/12/how-to-force-file-download-with-php/</a>), but there is a significant delay between when the script is executed and when the browser's download dialog appears. Can anyone identify the bottleneck that is causing this?</p>
<p>Here's my implementation:</p>
<pre><code>/**
* Outputs the specified file to the browser.
*
* @param string $filePath the path to the file to output
* @param string $fileName the name of the file
* @param string $mimeType the type of file
*/
function outputFile($filePath, $fileName, $mimeType = '') {
// Setup
$mimeTypes = array(
'pdf' => 'application/pdf',
'txt' => 'text/plain',
'html' => 'text/html',
'exe' => 'application/octet-stream',
'zip' => 'application/zip',
'doc' => 'application/msword',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
'gif' => 'image/gif',
'png' => 'image/png',
'jpeg' => 'image/jpg',
'jpg' => 'image/jpg',
'php' => 'text/plain'
);
$fileSize = filesize($filePath);
$fileName = rawurldecode($fileName);
$fileExt = '';
// Determine MIME Type
if($mimeType == '') {
$fileExt = strtolower(substr(strrchr($filePath, '.'), 1));
if(array_key_exists($fileExt, $mimeTypes)) {
$mimeType = $mimeTypes[$fileExt];
}
else {
$mimeType = 'application/force-download';
}
}
// Disable Output Buffering
@ob_end_clean();
// IE Required
if(ini_get('zlib.output_compression')) {
ini_set('zlib.output_compression', 'Off');
}
// Send Headers
header('Content-Type: ' . $mimeType);
header('Content-Disposition: attachment; filename="' . $fileName . '"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');
// Send Headers: Prevent Caching of File
header('Cache-Control: private');
header('Pragma: private');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
// Multipart-Download and Download Resuming Support
if(isset($_SERVER['HTTP_RANGE'])) {
list($a, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
list($range) = explode(',', $range, 2);
list($range, $rangeEnd) = explode('-', $range);
$range = intval($range);
if(!$rangeEnd) {
$rangeEnd = $fileSize - 1;
}
else {
$rangeEnd = intval($rangeEnd);
}
$newLength = $rangeEnd - $range + 1;
// Send Headers
header('HTTP/1.1 206 Partial Content');
header('Content-Length: ' . $newLength);
header('Content-Range: bytes ' . $range - $rangeEnd / $fileSize);
}
else {
$newLength = $fileSize;
header('Content-Length: ' . $fileSize);
}
// Output File
$chunkSize = 1 * (1024*1024);
$bytesSend = 0;
if($file = fopen($filePath, 'r')) {
if(isset($_SERVER['HTTP_RANGE'])) {
fseek($file, $range);
while(!feof($file) && !connection_aborted() && $bytesSend < $newLength) {
$buffer = fread($file, $chunkSize);
echo $buffer;
flush();
$bytesSend += strlen($buffer);
}
fclose($file);
}
}
}
</code></pre>
| [
{
"answer_id": 386869,
"author": "OIS",
"author_id": 36175,
"author_profile": "https://Stackoverflow.com/users/36175",
"pm_score": 3,
"selected": false,
"text": "<?php\n\n$filename = $_GET['file'];\n\n// required for IE, otherwise Content-disposition is ignored\nif(ini_get('zlib.output_c... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5291/"
] |
386,854 | <p>I try to keep my fingers on home row as much as possible.</p>
<p>Typing all the parentheses makes me move away from there a fair bit. </p>
<p>I use Emacs; the parentheses themselves are no issue, I'm comfortable with them. And I don't like modes that type them for me automatically. </p>
<p>I've thought about remapping the square brackets to parentheses and vice versa. Is this a good idea? What does everyone else do? </p>
| [
{
"answer_id": 395961,
"author": "jamesnvc",
"author_id": 7699,
"author_profile": "https://Stackoverflow.com/users/7699",
"pm_score": 0,
"selected": false,
"text": "paredit-mode"
},
{
"answer_id": 397290,
"author": "jrockway",
"author_id": 8457,
"author_profile": "htt... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48419/"
] |
386,862 | <p>I've become very addicted to Project Euler recently and am trying to do <a href="http://projecteuler.net/index.php?section=problems&id=221" rel="nofollow noreferrer">this</a> one next! I've started some analysis on it and have reduced the problem down substantially already. Here's my working:</p>
<blockquote>
<p>A = pqr and</p>
<p>1/A = 1/p + 1/q + 1/r so pqr/A =
pq + pr + qr</p>
<p>And because of the first equation:</p>
<p>pq+pr+qr = 1</p>
<p>Since exactly two of p, q and r have
to be negative, we can simplify the
equation down to finding:</p>
<p>abc for which ab = ac+bc+1</p>
<p>Solving for c we get:</p>
<p>ab-1 = (a+b)c</p>
<p>c = (ab-1)/(a+b)</p>
<hr>
<p>This means we need to find a and b for
which:</p>
<p>ab = 1 (mod a+b)</p>
<p>And then our A value with those a and
b is:</p>
<p>A = abc = ab(ab-1)/(a+b)</p>
</blockquote>
<p>Sorry if that's a lot of math! But now all we have to deal with is one condition and two equations. Now since I need to find the 150,000th smallest integer written as ab(ab-1)/(a+b) with ab = 1 (mod a+b), ideally I want to search (a, b) for which A is as small as possible.</p>
<p>For ease I assumed a < b and I have also noticed that gcd(a, b) = 1.</p>
<p>My first implementation is straight forward and even finds 150,000 solutions fast enough. However, it takes far too long to find the 150,000 <em>smallest</em> solutions. Here's the code anyway:</p>
<pre><code>n = 150000
seen = set()
a = 3
while len(seen) < n:
for b in range(2, a):
if (a*b)%(a+b) != 1: continue
seen.add(a*b*(a*b-1)//(a+b))
print(len(seen), (a, b), a*b*(a*b-1)//(a+b))
a += 1
</code></pre>
<p>My next thought was to use Stern-Brocot trees but that is just too slow to find solutions. My final algorithm was to use the Chinese remainder theorem to check if different values of a+b yield solutions. That code is complicated and although faster, it isn't fast enough...</p>
<p>So I'm absolutely out of ideas! Anyone got any ideas?</p>
| [
{
"answer_id": 388796,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "[5, 8, 10, 13, 16, 17, 20, 25, 26, 29, 32, 34, 37, 40, 41, 50, 52, 53, 58, 61, 64, 65, 68, 73, 74, 80, 82, 85, 89, 97, 100]\n ... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
386,867 | <p>I'm using LINQ to SQL to pull records from a database, sort them by a string field, then perform some other work on them. Unfortunately the Name field that I'm sorting by comes out of the database like this</p>
<pre><code>Name
ADAPT1
ADAPT10
ADAPT11
...
ADAPT2
ADAPT3
</code></pre>
<p>I'd like to sort the Name field in numerical order. Right now I'm using the Regex object to replace "ADAPT1" with "ADAPT01", etc. I then sort the records again using another LINQ query. The code I have for this looks like </p>
<pre><code> var adaptationsUnsorted = from aun in dbContext.Adaptations
where aun.EventID == iep.EventID
select new Adaptation
{
StudentID = aun.StudentID,
EventID = aun.EventID,
Name = Regex.Replace(aun.Name,
@"ADAPT([0-9])$", @"ADAPT0$1"),
Value = aun.Value
};
var adaptationsSorted = from ast in adaptationsUnsorted
orderby ast.Name
select ast;
foreach(Adaptation adaptation in adaptationsSorted)
{
// do real work
}
</code></pre>
<p>The problem I have is that the foreach loop throws the exception</p>
<pre><code>System.NotSupportedException was unhandled
Message="Method 'System.String Replace(System.String, System.String,
System.String)' has no supported translation to SQL."
Source="System.Data.Linq"
</code></pre>
<p>I'm also wondering if there's a cleaner way to do this with just one LINQ query. Any suggestions would be appreciated.</p>
| [
{
"answer_id": 386912,
"author": "bruno conde",
"author_id": 31136,
"author_profile": "https://Stackoverflow.com/users/31136",
"pm_score": 1,
"selected": false,
"text": "IComparer<string> var adaptationsUnsorted = from aun in dbContext.Adaptations\n where aun.Eve... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18891/"
] |
386,874 | <p>I have to dump a large database over a network pipe that doesn't have that much bandwidth and other people need to use concurrently. If I try it it soaks up all the bandwidth and latency soars and everyone else gets messed up.</p>
<p>I'm aware of the --compress flag to mysqldump which help somewhat.</p>
<p>How can I do this without soaking up all the bandwidth over this connection?</p>
<p>Update:</p>
<p>The suggestion to copy a dumpfile using scp with the -l flag is a good one, but I should note that I don't have <a href="http://en.wikipedia.org/wiki/Secure_Shell" rel="nofollow noreferrer">SSH</a> access to the database server.</p>
| [
{
"answer_id": 397528,
"author": "dbr",
"author_id": 745,
"author_profile": "https://Stackoverflow.com/users/745",
"pm_score": 4,
"selected": true,
"text": "trickle nc nc -L 1234 > backup.sql mysqldump [database name] | trickle -u 20 nc backup.example.com:1234\n"
}
] | 2008/12/22 | [
"https://Stackoverflow.com/questions/386874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41613/"
] |
386,877 | <p>I've seen <a href="http://veloedit.sourceforge.net/" rel="noreferrer">Veloedit</a>, which seems to have good syntax highlighting but doesn't allow tab characters in the file being edited (wtf?) and also has no understanding of HTML.</p>
<p>With a little bit of googling I've found <a href="http://propsorter.sourceforge.net/" rel="noreferrer">Veloecipse</a>, which claims to build upon Veloedit and also add HTML support - <strike>but doesn't seem to be compatible with Eclipse 3.4</strike>.</p>
<p>Are there any other Velocity template editor plugins for Eclipse that anyone is using?</p>
<p>The ideal solution would have the following features:</p>
<ul>
<li>Syntax hightlighting of VTL</li>
<li>HTML syntax highlighting as well</li>
<li>Auto-complete of VTL syntax</li>
<li>Allows tabs!</li>
</ul>
<p><strong>Update</strong>: see my answer below</p>
| [
{
"answer_id": 18376563,
"author": "Jitendra Nandre",
"author_id": 1487697,
"author_profile": "https://Stackoverflow.com/users/1487697",
"pm_score": 1,
"selected": false,
"text": "http://code.google.com/p/veloeclipse/"
}
] | 2008/12/22 | [
"https://Stackoverflow.com/questions/386877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4249/"
] |
386,885 | <p>Are there any client-side JavaScript <a href="https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller" rel="noreferrer">MVC</a> (micro-)frameworks?</p>
<p>I have a rather complicated HTML form, and it would benefit from the MVC pattern.</p>
<p>I imagine a good solution would provide the following:</p>
<ul>
<li>Model and View update the Controller when values change (Observer pattern)</li>
<li>Populate the model from the form data when the page loads</li>
<li>Populate the form from the model when the model changes </li>
</ul>
<p>Ajax, comet, <a href="http://en.wikipedia.org/wiki/JSONP" rel="noreferrer">JSONP</a> and all that jazz are serious overkill.</p>
| [
{
"answer_id": 9032567,
"author": "Sam Hasler",
"author_id": 2541,
"author_profile": "https://Stackoverflow.com/users/2541",
"pm_score": 3,
"selected": false,
"text": "MyApp.president = Ember.Object.create({\n name: \"Barack Obama\"\n});\n\nMyApp.country = Ember.Object.create({\n // En... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386885",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48424/"
] |
386,914 | <p>I'm creating a site that allows users to submit quotes. How would I go about creating a (relatively simple?) search that returns the most relevant quotes?</p>
<p>For example, if the search term was "turkey" then I'd return quotes where the word "turkey" appears twice before quotes where it only appears once.</p>
<p>(I would add a few other rules to help filter out irrelevant results, but my main concern is that.) </p>
| [
{
"answer_id": 386986,
"author": "Jeffrey Martinez",
"author_id": 29703,
"author_profile": "https://Stackoverflow.com/users/29703",
"pm_score": 2,
"selected": false,
"text": "SELECT * FROM Quotes\nWHERE the_quote LIKE \"%turkeyt%\";\n"
},
{
"answer_id": 386996,
"author": "dco... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1615/"
] |
386,930 | <p>What is the best compression algorithm with the following features:</p>
<ul>
<li>should take less time to decompress (can take reasonably more time compress)</li>
<li>should be able to compress sorted data (approx list of 3,000,000 strings/integers ...)</li>
</ul>
<p>Please suggest along with metrics: compression ratio, algorithmic complexity for compression and decompression (if possible)?</p>
| [
{
"answer_id": 387011,
"author": "yogman",
"author_id": 24349,
"author_profile": "https://Stackoverflow.com/users/24349",
"pm_score": 1,
"selected": false,
"text": "1) Writes the literal \n2) for (backward position, length)=(m,n) pair, \n goes back, in the output buffer, m bytes, \n ... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34590/"
] |
386,934 | <p>I have a string representing a path. Because this application is used on Windows, OSX and Linux, we've defined environment variables to properly map volumes from the different file systems. The result is:</p>
<pre><code>"$C/test/testing"
</code></pre>
<p>What I want to do is evaluate the environment variables in the string so that they're replaced by their respective volume names. Is there a specific command I'm missing, or do I have to take <code>os.environ.keys()</code> and manually replace the strings?</p>
| [
{
"answer_id": 386978,
"author": "jblocksom",
"author_id": 20626,
"author_profile": "https://Stackoverflow.com/users/20626",
"pm_score": 8,
"selected": true,
"text": ">>> os.path.expandvars('$C/test/testing')\n'/stackoverflow/test/testing'\n"
},
{
"answer_id": 68277049,
"auth... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46914/"
] |
386,944 | <p>Can anyone send me JavaScript code on how I can construct a time delay from the time I click a button on a page to the time the function called by the button click is executed. I am a novice with JavaScript, and I have some code that performs a function when I click a button, and I just want to have a time delay.</p>
| [
{
"answer_id": 386951,
"author": "xtofl",
"author_id": 6610,
"author_profile": "https://Stackoverflow.com/users/6610",
"pm_score": 3,
"selected": false,
"text": " function myfunction() {\n alert( \"delayed\" );\n }\n\n var delay = 1000;\n\n setTimeout( myfunction, delay )\n < script ... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
386,945 | <p>I have the following problem: some processes, generated dynamically, have a tendency to eat 100% of CPU. I would like to limit all the process matching some criterion (e.g. process name) to a certain amount of CPU percentage.</p>
<p>The specific problem I'm trying to solve is harnessing folding@home worker processes. The best solution I could think of is a perl script that's executed periodically and uses the cpulimit utility to limit the processes (if you're interested in more details, check this <a href="http://dev.calyx.hr/blog/?p=143" rel="noreferrer">blog post</a>). It works, but it's a hack :/</p>
<p>Any ideas? I would like to leave the handling of processes to the OS :) </p>
<hr>
<p>Thanks again for the suggestions, but we're still missing the point :)</p>
<p>The "slowDown" solution is essentially what the "cpulimit" utility does. I still have to take care about what processes to slow down, kill the "slowDown" process once the worker process is finished and start new ones for new worker processes. It's precisely what I did with the Perl script and a cron job.</p>
<p>The main problem is that I don't know beforehand what processes to limit. They are generated dynamically.</p>
<p>Maybe there's a way to limit all the processes of one user to a certain amount of CPU percentage? I already set up a user for executing the folding@home jobs, hoping that i could limit him with the /etc/security/limits.conf file. But the nearest I could get there is the total CPU time per user...</p>
<p>It would be cool if to have something that enables you to say:
"The sum of all CPU % usage of this user's processes cannot exceed 50%". And then let the processes fight for that 50% of CPU regarding to their priorities... </p>
<hr>
<p>Guys, thanks for your suggestions, but it's not about priorities - I want to limit the CPU % even when there's plenty of CPU time available. The processes are already low priority, so they don't cause any performance issues.</p>
<p>I would just like to prevent the CPU from running on 100% for extended periods... </p>
| [
{
"answer_id": 387391,
"author": "blabla999",
"author_id": 48469,
"author_profile": "https://Stackoverflow.com/users/48469",
"pm_score": 4,
"selected": false,
"text": "loop\n wait for some time tR\n send SIGSTOP to the process you want to be scheduled\n wait for some time tP\n ... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386945",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/390180/"
] |
386,950 | <p>Can somebody point me to a tutorial and/or Getting Started document to get IronRuby running Rails? I'm particularly interested in a detailed, step-by-step reference, <em>not</em> general guidelines.</p>
| [
{
"answer_id": 388484,
"author": "Mike Woodhouse",
"author_id": 1060,
"author_profile": "https://Stackoverflow.com/users/1060",
"pm_score": 2,
"selected": false,
"text": "rails <projectName ironruby script/server"
}
] | 2008/12/22 | [
"https://Stackoverflow.com/questions/386950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37474/"
] |
386,981 | <p>So I have the following code:</p>
<pre><code> return from a in DBContext.Acts
join artist in DBContext.Artists on a.ArtistID equals artist.ID into art
from artist in art.DefaultIfEmpty()
select new Shared.DO.Act
{
ID = a.ID,
Name = a.Name,
Artist = new Shared.DO.Artist
{
ID = artist.ID,
Name = artist.Name
},
GigId = a.GigID
};
</code></pre>
<p>This loads an act object and adapts it from a linq object to my domain act object.</p>
<p>As you can see I have defined an outer join on the artist to act relationship.</p>
<p>I have done this because I always want the act, irrespective of if it has an artist.</p>
<p>This works really well if the act does indeed have an artist.</p>
<p>If it doesnt then the code dies. This is the the culprit:</p>
<pre><code> Artist = new Shared.DO.Artist
{
ID = artist.ID,
Name = artist.Name
},
</code></pre>
<p>If I remove it, its fine. Is it possible to do what I'm attempting?</p>
| [
{
"answer_id": 387010,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": true,
"text": " Artist = new Shared.DO.Artist\n {\n ID = artist == null ? Guid.NewGuid() : artist.ID,\n ... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46616/"
] |
386,982 | <p>I'm trying to use the library released by Novell (Novell.Directory.Ldap). Version 2.1.10.</p>
<p>What I've done so far: </p>
<ul>
<li><p>I tested the connection with an application (<a href="http://www.mcs.anl.gov/~gawor/ldap/index.html" rel="noreferrer">LdapBrowser</a>) and it's working, so its not a communication problem.</p></li>
<li><p>It's compiled in Mono, but I'm working with Visual Studio. So created a project with the sources. I also included a reference to Mono.Security, because the project depended on it.</p></li>
<li><p>I commented a call (freeWriteSemaphore(semId); ) in the error catching part of the connection, because it was throwing more exceptions. I checked what that call did, and its just a error tracing mechanism.</p></li>
<li><p>I followed the basics steps provided in the documentation by Novell (<a href="http://www.novell.com/coolsolutions/feature/11204.html" rel="noreferrer">http://www.novell.com/coolsolutions/feature/11204.html</a>). </p>
<p>// Creating an LdapConnection instance </p>
<p>LdapConnection ldapConn= new LdapConnection();
ldapConn.SecureSocketLayer = ldapPort == 636;</p>
<p>//Connect function will create a socket connection to the server</p>
<p>ldapConn.Connect(ldapHost,ldapPort);</p>
<p>//Bind function will Bind the user object Credentials to the Server</p>
<p>ldapConn.Bind(userDN,userPasswd);</p></li>
<li><p>Right now it's crashing at the Bind() function. I get the error 91. </p></li>
</ul>
<p>So, has someone ever used this library and seen it work? If so, what did you do to make it work, is there some special configuration needed? Is there a way to make it work in .NET environment without Mono (I can have references to Mono dlls, but I don't want it to be installed on the server)?</p>
<p>(UPDATE)
The connection is on port 636, thus using SSL. I checked with WireShark the communication and compared with what I get from LDAP Browser. I've seen that the step where the SSL certicate is communicated, is not done by the LDAP library. So, what is the best way to make it do what its supposed to?</p>
<p>(UPDATE) I checked the documentation and it's indicating that it doesn't support SSL. <a href="http://www.novell.com/coolsolutions/feature/11204.html" rel="noreferrer">http://www.novell.com/coolsolutions/feature/11204.html</a></p>
<blockquote>
<p>Authenticate to the LDAP server with
LdapConnection.Bind(). We support only
cleartext authentication. SSL/TLS
support is yet to be added.</p>
</blockquote>
<p>But the documentation date from 2004, and since then, many updates have been made. And there is a parameter in the library to define if the connection uses SSL. So now I'm confused.</p>
<p>(UPDATE) Found a more up-to-date documentation : <a href="http://developer.novell.com/documentation//ldapcsharp/index.html?page=/documentation//ldapcsharp/cnet/data/bqwa5p0.html" rel="noreferrer">http://developer.novell.com/documentation//ldapcsharp/index.html?page=/documentation//ldapcsharp/cnet/data/bqwa5p0.html</a>. The way the SSL connection is made, is by registering the certificate on the server. The problem is that what I'm doing is not bound to a specific Novell server, so the certificate must be obtained dynamically.</p>
| [
{
"answer_id": 440964,
"author": "ceetheman",
"author_id": 16154,
"author_profile": "https://Stackoverflow.com/users/16154",
"pm_score": 3,
"selected": true,
"text": "// This is the Callback handler - after \"Binding\" this is called\n public bool MySSLHandler(Syscert.X509Certific... | 2008/12/22 | [
"https://Stackoverflow.com/questions/386982",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16154/"
] |
387,006 | <p>I'm trying to use the MSBuild NUnit community task to force tests to run on each build, but I now see that when I use ReSharper's test runner and it builds the project I'm running the tests twice. It works but is not really desirable.</p>
<p>Does anyone know of a variable or condition I can check within MSBuild so that I can skip the community task if I know the test runner is going to execute the tests anyway?</p>
<p>Note: I'm using VS2008 and the MSBuild script is integrated with the solution/project files. I want the best of all worlds. <kbd>CTRL</kbd> + <kbd>SHIFT</kbd> + <kbd>B</kbd>, plus command-line, plus CI server. </p>
| [
{
"answer_id": 469924,
"author": "Aaron Wagner",
"author_id": 3909,
"author_profile": "https://Stackoverflow.com/users/3909",
"pm_score": 3,
"selected": true,
"text": "DebugResharperTest"
},
{
"answer_id": 732459,
"author": "Paul Alexander",
"author_id": 76456,
"autho... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3909/"
] |
387,028 | <p>I'm looking for a tool that, given a bit of C, will tell you what symbols (types, precompiler definitions, functions, etc) are used from a given header file. I'm doing a port of a large driver from Solaris to Windows and figuring out where things are coming from is getting to be difficult, so this would be a huge help. Any ideas?</p>
<p>Edit: Not an absolute requirement, but tools that work on Windows would be a plus.</p>
<p>Edit #2: To clarify what I'm trying to do, I have a codebase I'm trying to port, which brings in a large number of headers. What I'd like is a tool that, given foo.c, will tell me which symbols it uses from bar.h.</p>
| [
{
"answer_id": 393237,
"author": "dmckee --- ex-moderator kitten",
"author_id": 2509,
"author_profile": "https://Stackoverflow.com/users/2509",
"pm_score": 0,
"selected": false,
"text": "emacs etags"
}
] | 2008/12/22 | [
"https://Stackoverflow.com/questions/387028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4977/"
] |
387,070 | <p>Are there any conventions for formatting console output from a command line app for readability and consistency? For instance, do you indent sub-information, when do you print a blank line, if ever, how should you accent important statements.</p>
<p>I've found output can quickly degenerate into a chaotic blur. I'm interested in hearing about what other people do.</p>
<p><B>Update:</B> Really this is for embedded software which spits debug status out a terminal, but it's pretty much like a console app, and I figured everyone would be more familiar with that. Thanks so far.</p>
| [
{
"answer_id": 393237,
"author": "dmckee --- ex-moderator kitten",
"author_id": 2509,
"author_profile": "https://Stackoverflow.com/users/2509",
"pm_score": 0,
"selected": false,
"text": "emacs etags"
}
] | 2008/12/22 | [
"https://Stackoverflow.com/questions/387070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
387,076 | <p>How can I use Linq with Dataset.xsd files?</p>
<p>I've looked at Linq-to-Datasets and Linq-to-XSD but they don't really seem to work directly with the Visual Studio DataSet.xsd files.</p>
<p><strong>EDIT:</strong> I actually found a great link for this: <a href="http://msdn.microsoft.com/en-us/vbasic/bb738035.aspx" rel="nofollow noreferrer">link text</a> but I can't seem to figure out what to do if I want to query on related tables.</p>
<pre><code> Dim taFields As New TestDSTableAdapters.FieldTableAdapter()
Dim fields = taFields.GetData()
Dim results = From f In fields Select f
For Each field In results
Response.Write(field.FieldID & " " & field.Label & " " & field.FieldTypeRow.FieldTypeLabel)
Next
</code></pre>
<p>I get an "Object reference not set to an instance of an object." error when running the above code because, I guess, field.FieldTypeRow.FieldTypeLabel isn't actually part of the query of data. Do I have to create a method that returns data from that data also? I'm assuming this would be the case (that taFields.GetData has to return all the FieldType data results too if I'm going to reference it - in Linq to SQL it does all this for me so it's a little disappointing)</p>
| [
{
"answer_id": 387170,
"author": "Ryan Lundy",
"author_id": 5486,
"author_profile": "https://Stackoverflow.com/users/5486",
"pm_score": 3,
"selected": true,
"text": "Dim taFields As New TestDSTableAdapters.FieldTableAdapter()\nDim taFieldTypes As New TestDSTableAdapters.FieldTypesTableAd... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47167/"
] |
387,091 | <p>Here's my code:</p>
<pre><code>public class Sequence<T> {
protected List<T> sequence = new ArrayList<T>();
public Matrix<OrderedPair<T, ?>> createCartesianProduct(Sequence<?> secondSequence) {
Matrix<OrderedPair<T, ?>> result = new Matrix<OrderedPair<T, ?>>();
for (int rowIndex = 0; rowIndex < sequence.size(); rowIndex++) {
Sequence<OrderedPair<T, ?>> row = new Sequence<OrderedPair<T, ?>>();
for (int columnIndex = 0; columnIndex < secondSequence.length(); columnIndex++) {
row.add(new OrderedPair(sequence.get(rowIndex), secondSequence.sequence.get(columnIndex)));
}
}
return result;
}
}
</code></pre>
<p>This compiles in Eclipse, but on the line within the inner for loop ( row.add(...) ) I get the following three warnings:</p>
<ul>
<li><code>OrderedPair</code> is a raw type. References to generic type <code>OrderedPair()<T1, T2></code> should be parameterized.</li>
<li>Type Safety: The expression of type OrderedPair needs unchecked conversion to conform to <code>OrderedPair<T, ?></code></li>
<li>Type safety: The Constructor OrderedPair(Object, Object) belongs to the raw type OrderedPair. References to generic type OrderedPair<code><T1, T2></code> should be parameterized</li>
</ul>
<p>I would like to use generics to enforce strong type-checking here, but I guess my understanding of generics is not sufficient to allow me to see how. Could someone educate me?</p>
<p>Thanks,</p>
<p>-- Ken</p>
| [
{
"answer_id": 387129,
"author": "Yuval Adam",
"author_id": 24545,
"author_profile": "https://Stackoverflow.com/users/24545",
"pm_score": 0,
"selected": false,
"text": "row.add(new OrderedPair<T, ?>(sequence.get(rowIndex), secondSequence.sequence.get(columnIndex)));\n OrderedPair <T, ?> ... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
387,093 | <p>Every time I add a reference to a web project in visual studio 2008 that is in my GAC, it adds the reference as a GAC reference and doesn't copy the file to my bin directory. But for deployment purposes, I would like to add the reference as a non-GAC reference so it adds the dll to my bin directory. I've tried using the browse button to select the reference instead of picking from the list window, but that adds a GAC reference too.</p>
<p>These references all have the .refresh file with them and there is not an option to copy local in the properties of the file.</p>
<p>Any help please?!?</p>
| [
{
"answer_id": 3444724,
"author": "frank hadder",
"author_id": 3617,
"author_profile": "https://Stackoverflow.com/users/3617",
"pm_score": 1,
"selected": false,
"text": "<Reference Include=\"Microsoft.Data.Entity.CTP, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, pro... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2849/"
] |
387,104 | <p>Does anyone have a good implementation of a stream cipher written in pure portable C? I am not terribly concerned with the strength of the cipher at this point in time because it is only for a proof of concept, but speed would be important. I've thought about just Xor'ing with a constant if I cannot find a decent stream cipher.</p>
| [
{
"answer_id": 387254,
"author": "e.James",
"author_id": 33686,
"author_profile": "https://Stackoverflow.com/users/33686",
"pm_score": 1,
"selected": false,
"text": "CycleKey char #include <stdio.h>\n\nchar staticKey;\n\nvoid CycleKey(char data)\n{\n /* this is where the real magic sh... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42588/"
] |
387,112 | <p>Binding a List collection to a datagrid. How can you limit what properties will be displayed?</p>
<pre><code>DataGridViewAirport.DataSource = GlobalDisplayAirports
</code></pre>
| [
{
"answer_id": 387125,
"author": "JoshBerke",
"author_id": 26160,
"author_profile": "https://Stackoverflow.com/users/26160",
"pm_score": 3,
"selected": true,
"text": "<asp:GridView ID=\"myGrid\" runat=\"server\" AutoGenerateColumns=\"False\" CellSpacing=\"0\">\n <Columns>\n <asp:B... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38349/"
] |
387,113 | <p>I'm using VBA in the Excel VBE, but c# or vb are fine.
The concept should hold true across the languages.</p>
| [
{
"answer_id": 387700,
"author": "BradC",
"author_id": 21398,
"author_profile": "https://Stackoverflow.com/users/21398",
"pm_score": 3,
"selected": true,
"text": "Dim myrange As Range\nSet myrange = Range(\"B3:E10\")\n\nDim row As Integer, col As Integer\nFor row = myrange.Rows.Count To ... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25197/"
] |
387,128 | <p>I'm trying to do precedence matching on a table within a stored procedure. The requirements are a bit tricky to explain, but hopefully this will make sense. Let's say we have a table called books, with id, author, title, date, and pages fields. </p>
<p>We also have a stored procedure that will match a query with ONE row in the table.</p>
<p>Here is the proc's signature:</p>
<pre><code>create procedure match
@pAuthor varchar(100)
,@pTitle varchar(100)
,@pDate varchar(100)
,@pPages varchar(100)
as
...
</code></pre>
<p>The precedence rules are as follows:</p>
<ul>
<li>First, try and match on all 4 parameters. If we find a match return.</li>
<li>Next try to match using any 3 parameters. The 1st parameter has the highest precedence here and the 4th the lowest. If we find any matches return the match.</li>
<li>Next we check if any two parameters match and finally if any one matches (still following the parameter order's precedence rules).</li>
</ul>
<p>I have implemented this case-by-case. Eg: </p>
<pre><code> select @lvId = id
from books
where
author = @pAuthor
,title = @pTitle
,date = @pDate
,pages = @pPages
if @@rowCount = 1 begin
select @lvId
return
end
select @lvId = id
from books
where
author = @pAuthor
,title = @pTitle
,date = @pDate
if @@rowCount = 1 begin
select @lvId
return
end
....
</code></pre>
<p>However, for each new column in the table, the number of individual checks grows by an order of 2. I would really like to generalize this to X number of columns; however, I'm having trouble coming up with a scheme.</p>
<p>Thanks for the read, and I can provide any additional information needed.</p>
<hr>
<p><em>Added:</em></p>
<p>Dave and Others, I tried implementing your code and it is choking on the first Order by Clause, where we add all the counts. Its giving me an invalid column name error. When I comment out the total count, and order by just the individual aliases, the proc compiles fine.</p>
<p>Anyone have any ideas?</p>
<p>This is in Microsoft Sql Server 2005</p>
| [
{
"answer_id": 387169,
"author": "Tom H",
"author_id": 5696608,
"author_profile": "https://Stackoverflow.com/users/5696608",
"pm_score": 1,
"selected": false,
"text": "SELECT TOP 1\n author,\n title,\n date,\n pages\nFROM\n Books\nWHERE\n author = @author OR\n ... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27689/"
] |
387,130 | <p>Working in academia publishing CS/math, you sooner or later find yourself trying to publish in a journal that will only accept .doc/.rtf. This means tedious, boring hours of translating line after line, especially equations, from LaTeX to an inferior format. Over the years I have tried a number of export tools for LaTeX, but none, at least of the free ones, that I have been very satisfied with. I'd like this page to collect and monitor the best import/export tools for LaTeX, to .doc/.rtf, or to other useful (e.g. HTML, MATHML) formats.</p>
<p>Thus, what is your one favorite import or export LaTeX tool?</p>
| [
{
"answer_id": 387169,
"author": "Tom H",
"author_id": 5696608,
"author_profile": "https://Stackoverflow.com/users/5696608",
"pm_score": 1,
"selected": false,
"text": "SELECT TOP 1\n author,\n title,\n date,\n pages\nFROM\n Books\nWHERE\n author = @author OR\n ... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27126/"
] |
387,141 | <p>I'd like to check if the system is in standby mode, is there any Win32 API for that? I'm not sure if it's the same as the sleep mode.</p>
<p>There's some code that gets executed in my app, which causes it to hang when coming out of standby (it's executed during the standby mode), so I'd like to avoid running that code when the computer is sleeping/standing by.</p>
<p>Thanks in advance!</p>
<p>Dennis</p>
<p><strong>edit:</strong> perhaps it's impossible, because the program shouldn't be running as was pointed out in the answer below, so I'll count that as an answer :)</p>
| [
{
"answer_id": 387155,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 3,
"selected": true,
"text": "int is_in_standby() {\n return 0;\n}\n"
}
] | 2008/12/22 | [
"https://Stackoverflow.com/questions/387141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20208/"
] |
387,142 | <p>I am writing a web server and client test stub for it. I have questions regarding memory management of the parameters.</p>
<p>From my client I am calling a soap function ns1_func1(input * pInput, output* pOutput)
Now both input and output class contain pointers to other structs.</p>
<p>For e.g </p>
<p>class Output
{
class abc * p1;
class def * p2;
};</p>
<p>My question is - who is responsible for memory allocations? Is client responsible for input memory allocations and server responsible for output memory management?</p>
<p>Right now my client code looks somthing like this</p>
<pre><code>client_fn()
{
...
input inp1;
output * pOutput = NULL;
ns1_func1(&inp1, pOutput);
if(pOutput == NULL)
{
cout<<"pOut is NULL\n";
return ERR;
}
else
{
// retrive output values from pOutput
}
...
}
</code></pre>
<p>I am always getting pOutput as NULL after call to ns1_func1 in spite of allocating pOutput from the server using soap_new_Output(soap, -1).</p>
<p>Also, my understanding is that we should use soap_new_X to allocate memory which gets automatically deallocated when we call soap_destroy. Pls correct me if I am wrong.</p>
<p>Basically I am struggling with no knowledge about who is supposed to take care of memory allocation/deallocation in such cases. </p>
<p>Any help would be great.</p>
| [
{
"answer_id": 1634202,
"author": "benzado",
"author_id": 10947,
"author_profile": "https://Stackoverflow.com/users/10947",
"pm_score": 0,
"selected": false,
"text": "output * pOutput = NULL;\nns1_func1(&inp1, pOutput);\n output theOutput;\noutput * pOutput = &theOutput;\nns1_func1(&inp1... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
387,163 | <p>I know it might not be according to Apple's human interface guidelines for the iPhone, but I want to get rid of one level of pushing views and have a list of editable text fields. Further, I want the keyboard to be on screen from start when the view appears.</p>
<p>The problem is that when I have more than three such fields then the pop-up keyboard will cover the fields below. And the user can't scroll down to them. I think it's because the table view is full-screen. I've tried to make the list only as heigh as it would allow the keyboard to be visible all the time, but no luck.</p>
<p>Anyone knows how I should arrange things to get what I want?</p>
| [
{
"answer_id": 1985865,
"author": "God of Biscuits",
"author_id": 145425,
"author_profile": "https://Stackoverflow.com/users/145425",
"pm_score": 1,
"selected": false,
"text": "- (BOOL)textFieldShouldReturn:(UITextField *)textField\n {\n if ( textField == self.firstNameField )\... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44639/"
] |
387,167 | <p>I have a custom server control with a property of Title. When using the control, I'd like to set the value of the title in the aspx page like so:</p>
<pre><code><cc1:customControl runat="server" Title='<%= PagePropertyValue%>' >
more content
</cc1:customControl>
</code></pre>
<p>When I do this, however, I am getting the exact String <%= PagePropertyValue%> being displayed rather than the Property Value that I would like to see.</p>
<p>So after trying the databinding expression (as suggested below). I don't get the string literal that looked bad but I don't get anything else either. </p>
<pre><code><cc1:customControl runat="server" Title='<%# PagePropertyValue%>' >
more content
</cc1:customControl>
</code></pre>
<p>What do I need to do to my custom control to take this sort of value? Or is there something I need to do to the page.</p>
| [
{
"answer_id": 387179,
"author": "Zachary Yates",
"author_id": 8360,
"author_profile": "https://Stackoverflow.com/users/8360",
"pm_score": 1,
"selected": false,
"text": "<%# PagePropertyValue %>"
},
{
"answer_id": 387341,
"author": "jpsimard-nyx",
"author_id": 47109,
... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13100/"
] |
387,183 | <p>I've been a web developer for quite some time and what has helped me in learning is to visually see what is going on.</p>
<p>That's the reason for Tools like Aardvark, Web developer, Firebug and many others.</p>
<p>But when i saw the <a href="http://redivide.com/blog/gecko-reflow-awesome-visualization-of-web-page-layout/" rel="nofollow noreferrer">Gecko Reflow Videos</a> they just blew my mind.</p>
<p>Then my question is, is it possible to truly debug html (step through each element)? Or come close to it?</p>
<p>What i've been doing a lot is to use Aardvark and remove elements but Aardvark has its issues with "background" and same size elements and not being able to target those.</p>
<p>UPDATE: I've been trying to write a good update for this question since it has left me thinking about it more. But since English isn't my primary language its been tough.</p>
<p>In the past years it's been the browsers who have had the task of being compatible with the standards. As they get closer to that goal, it is us who should be thinking about what we can truly create when browser compatibility is minimal, and if there are techniques we can utilize that makes rendering a page faster.</p>
<p>We can think of the past decades as the early years of HTML/CSS, where the main goal was just to get the thing to work. Now we should be looking for techniques that speed up the current process. An example of this is in the video above where the Gecko engine is running through the code twice. Why is that? And are there other instances where its doing unnecessary things (even though they work and are compatible)</p>
<p>This is something that clearly needs to be tested to be confirmed, hence my original question of a true debugger.</p>
| [
{
"answer_id": 387251,
"author": "Steve Perks",
"author_id": 16124,
"author_profile": "https://Stackoverflow.com/users/16124",
"pm_score": 1,
"selected": false,
"text": "body { overflow: scroll; }"
},
{
"answer_id": 387295,
"author": "Kenan Banks",
"author_id": 43089,
... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22459/"
] |
387,198 | <p>I have an international company that has recently been added, which is named "BLA "BLAHBLAH" Ltd. (The double quotes are part of the name. )</p>
<p>Whenever a user tries to search for this company, by entering "Blah, or something to that affect, the search fails with a syntax error in SQL server.</p>
<p>How can I escape this so the search will not fail?</p>
<p>Sample SQL:</p>
<pre><code>SELECT c.companyID, c.companyName, c.dateAdded, count(cm.maxID) as NumDirect
FROM RussoundGeneral.dbo.Company c
LEFT JOIN RussoundGeneral.dbo.CompanyMax cm
ON (cm.companyId = c.companyId and cm.maxID is not null)
WHERE CONTAINS ( companyName, '"BLAH*' )
GROUP BY c.companyID, c.companyName, c.dateAdded
ORDER BY c.companyName ASC
</code></pre>
| [
{
"answer_id": 387218,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "// Bad code, do not use!\nstring sql = \"SELECT * FROM Foo WHERE X LIKE '\" + input + \"%'\";\n"
},
{
"answer_id... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32772/"
] |
387,223 | <p>In Rails, I'm coding a series of controllers to generate XML. Each time I'm passing a number of properties in to to_xml like:</p>
<pre><code>to_xml(:skip_types => true, :dasherize => false)
</code></pre>
<p>Is there a way I can set these as new default properties that will apply whenever to_xml is called in my app so that I don't have to repeat myself?</p>
| [
{
"answer_id": 387308,
"author": "csexton",
"author_id": 19839,
"author_profile": "https://Stackoverflow.com/users/19839",
"pm_score": 3,
"selected": true,
"text": "def to_default_xml\n self.to_xml(:skip_types => true, :dasherize => false)\nend\n module DefaultXml\n def to_default_xml\... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40956/"
] |
387,229 | <p>I'm using HTML emails for a client's newsletter. Not using HTML mails is <strong>not</strong> an option. I've used PHPMailer for mailing, but I've also tried using PHP's mail() function directly. In both instances, I get the same problem described below. I've tried sending as multipart as well as sending just the HTML version.</p>
<p>In every email client I tried, the emails arrive just fine. By that I mean the email is recognized as an HTML email and the content is rendered. Except on some accounts on <strong>Outlook Express</strong>. I've not been able to discern why it works for some people and why it doesn't work for others (all using Outlook Express). I have forwarded HTML emails to this account (from gmail as well as from outlook express) and they show up just fine. So the Outlook Express version is definitely capable of showing HTML emails.</p>
<p>Now, in these failing cases, the Outlook Express ignores a significant part of the mail header. I can actually see this: when I view the <strong>original source</strong> of the email, it shows a part in bold - the header - and a part not in bold - the body.</p>
<p>Below is the email message. I've redacted some "personal" parts.</p>
<p>This part is in bold, recognized by Outlook Express as the header:</p>
<pre><code>DomainKey-Status: no signature
Received: (qmail xxxx invoked by uid xxx); 22 Dec 2008 21:04:33 +0100
To: xxxxxxxxxxxxxxxxxx
Subject: Test
Date: Mon, 22 Dec 2008 21:04:33 +0100
</code></pre>
<p>And this part is not in bold, and shows up in the mail content panel of Outlook Express.</p>
<pre><code>From: Root User <xxxxxxxxxxxxxxxxxxxxxx>
Message-ID: <xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
X-Priority: 3
X-Mailer: PHPMailer (phpmailer.sourceforge.net) [version 2.0.3]
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="b1_cb79043f473b53e87bfa759755fce3ce"
--b1_cb79043f473b53e87bfa759755fce3ce
Content-Type: text/plain; charset = "iso-8859-1"
Content-Transfer-Encoding: 8bit
test
--b1_cb79043f473b53e87bfa759755fce3ce
Content-Type: text/html; charset = "iso-8859-1"
Content-Transfer-Encoding: 8bit
<p>Test</p>
--b1_cb79043f473b53e87bfa759755fce3ce--
</code></pre>
| [
{
"answer_id": 389044,
"author": "Chase Seibert",
"author_id": 7679,
"author_profile": "https://Stackoverflow.com/users/7679",
"pm_score": 0,
"selected": false,
"text": "DomainKey-Status: no signature\nReceived: (qmail xxxx invoked by uid xxx); 22 Dec 2008 21:04:33 +0100\nTo: xxxxxxxxxxx... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387229",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7927/"
] |
387,233 | <p>I am working with ASP.NET doing some client side javascript.<br>
I have the following javascript to handle an XMLHTTPRequest callback. In certain situations, the page will be posted back, using the __doPostBack() function provided by ASP.NET, listed in the code below. However, I would like to be able to set the focus a dropdownlist controls after the post back occurs. Is there a way to set this using Javascript, or do I need to rig that up some other way. </p>
<pre><code> function onCompanyIDSuccess(sender, e) {
if (sender == 0)
document.getElementById(txtCompanyIDTextBox).value = "";
document.getElementById(txtCompanyIDHiddenField).value = sender;
if (bAutoPostBack) {
__doPostBack(txtCompanyIDTextBox, '');
}
}
</code></pre>
| [
{
"answer_id": 401086,
"author": "stephenbayer",
"author_id": 18893,
"author_profile": "https://Stackoverflow.com/users/18893",
"pm_score": 1,
"selected": true,
"text": "protected void ddl_state_selectedValueChanged(Object sender, EventArgs e)\n{\n // ... here is all my code for the e... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18893/"
] |
387,234 | <p>There is a nice state machine tutorial called <a href="http://www.objectmentor.com/resources/articles/umlfsm.pdf" rel="nofollow noreferrer">UML Tutorial: Finite State Machines</a> by Robert C. Martin. But I can't compile the sample code it provides. I got *FsmTest.cpp(46) : error C2664: 'SetState' : cannot convert parameter 1 from 'class UnlockedState *' to 'class TurnstileState <em>'</em></p>
<p>Please, help. Thanks.</p>
<pre><code>class Turnstile
{
public:
virtual void Lock();
virtual void Unlock();
virtual void Thankyou();
virtual void Alarm();
};
class TurnstileFSM;
class LockedState;
class UnlockedState;
class TurnstileState
{
public:
virtual void Coin(TurnstileFSM*) = 0;
virtual void Pass(TurnstileFSM*) = 0;
protected:
static LockedState lockedState;
static UnlockedState unlockedState;
};
class TurnstileFSM : public Turnstile
{
public:
void SetState(TurnstileState* s) {itsState = s;}
void Coin() {itsState->Coin(this);}
void Pass() {itsState->Pass(this);}
private:
TurnstileState *itsState;
};
class LockedState : public TurnstileState
{
public:
virtual void Coin(TurnstileFSM* t)
{
t->SetState(&unlockedState);
t->Unlock();
}
virtual void Pass(TurnstileFSM* t)
{
t->Alarm();
}
};
class UnlockedState : public TurnstileState
{
public:
virtual void Coin(TurnstileFSM* t)
{
t->Thankyou();
}
virtual void Pass(TurnstileFSM* t)
{
t->SetState(&lockedState);
t->Lock();
}
};
LockedState TurnstileState::lockedState;
UnlockedState TurnstileState::unlockedState;
</code></pre>
| [
{
"answer_id": 387264,
"author": "jmucchiello",
"author_id": 44065,
"author_profile": "https://Stackoverflow.com/users/44065",
"pm_score": 1,
"selected": false,
"text": "class TurnstileFSM {\n void SetState(TurnstileState* s);\n};\n\nvoid TurnstileFSM::SetState(TurnstileState* s) {its... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
387,260 | <p>I would like to stop images from loading, as in not even get a chance to download, using greasemonkey. Right now I have </p>
<pre><code>var images = document.getElementsByTagName('img');
for (var i=0; i<images.length; i++){
images[i].src = "";
}
</code></pre>
<p>but I don't think this actually stops the images from downloading. Anyone know how to stop the images from loading?</p>
<p>Thanks for your time and help :)</p>
| [
{
"answer_id": 387388,
"author": "jfs",
"author_id": 4279,
"author_profile": "https://Stackoverflow.com/users/4279",
"pm_score": 3,
"selected": true,
"text": "// ==UserScript==\n// @name stop downloading images\n// @namespace http://stackoverflow.com/questions/387388\n// @... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41718/"
] |
387,309 | <p>We're migrating home folders to a new filesystem, and I am looking for a way to automate it using Perl or a shell script. I don't have much choice in programming languages as the systems are proprietary storage clusters that should remain as unchanged as possible.</p>
<p>Task: Under directory /home/ I have various users' home folders aaa, bbb, ccc, ... and they have certain permissions and user/group ownership that need to remain intact upon migration to /newhome/. Here's example of what needs to be migrated from /home:</p>
<pre><code>drwxr-xr-x 3 aaaaa xxxxxxxxx 4096 Feb 26 2008 aaaaa/
drwxrwxrwx 88 bbbbbbb yyyyyy 8192 Dec 16 16:32 bbbbbbb/
drwxr-xr-x 6 ccccc yyyyyy 4096 Nov 24 04:38 ccccc/
drwxr-xrwx 36 dddddd yyyyyy 4096 Jun 20 2008 dddddd/
drwxr-xr-x 27 eee yyyyyy 4096 Dec 16 02:56 eee/
</code></pre>
<p>So, exact same folders with permissions and ownerships should be created under /newhome. Copying/moving files should not be a concern, as it will be handled later.</p>
<p>Anyone has worked on such script? I am really new to Perl, so I need help.</p>
| [
{
"answer_id": 387319,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 4,
"selected": true,
"text": "cp for a in `ls /home`; do cp -a \"/home/$a\" \"/newhome/$a\" ; done\n sudo rsync -pgodt /home/ /newhome/\n find /home/ -... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18406/"
] |
387,318 | <p>After peeking at the SO <a href="http://view-source:" rel="nofollow noreferrer">source</a>, I noticed this tag:</p>
<pre><code><link rel="apple-touch-icon" href="/apple-touch-icon.png" />
</code></pre>
<p>Which after a quick Google <a href="http://allinthehead.com/retro/319/how-to-set-an-apple-touch-icon-for-any-site" rel="nofollow noreferrer">revealed</a> an Apple "favicon" type thing for display on your homepage ("WebClip Bookmark" to be exact).</p>
<p>The only other one that <a href="http://alexking.org/blog/2006/11/12/safari-search-boxes" rel="nofollow noreferrer">jumps to mind</a> is the:</p>
<pre><code><input type="search" results="5"/>
</code></pre>
<p><a href="https://i.stack.imgur.com/6mwtB.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6mwtB.gif" alt="alt text"></a><br>
<sub>(source: <a href="http://alexking.org/dev/safari-search-box.gif" rel="nofollow noreferrer">alexking.org</a>)</sub> </p>
<p>This type="search" causes the field to "inherit" the Apple search icon, and the optional results="x" enables a history of "x" keywords to be maintained.</p>
<p>I'm therefore wondering, what other Apple/Safari (iPhone/iPod Touch) specific HTML tags and attributes are out there that I'm not aware of! Curious minds need to know!</p>
| [
{
"answer_id": 387669,
"author": "Andy Bourassa",
"author_id": 44858,
"author_profile": "https://Stackoverflow.com/users/44858",
"pm_score": 5,
"selected": true,
"text": "<meta name=\"viewport\" content=\"width=320, initial-scale=2.3, user-scalable=no\">\n <meta name=\"apple-mobile-web-a... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6144/"
] |
387,334 | <p>I have a dataview defined as:</p>
<pre><code>DataView dvPricing = historicalPricing.GetAuctionData().DefaultView;
</code></pre>
<p>This is what I have tried, but it returns the name, not the value in the column:</p>
<pre><code>dvPricing.ToTable().Columns["GrossPerPop"].ToString();
</code></pre>
| [
{
"answer_id": 387354,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": false,
"text": "DataRow string val = table.Rows[rowIndex].Field<string>(\"GrossPerPop\");\n string val = (string)table.Rows[rowIndex]... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33690/"
] |
387,339 | <p>I am pretty well versed with SQL Server, MySQL, Oracle etc but putting these Database products aside, is there a resource that will help me design relational databases well? Is there something like patterns or best practices for database design?</p>
<p>I have seen a few times that database is often not scalable; people have personal preferences with keeping columns like isChecked column which is boolean in nature but stored as Char(1) with values like 'Y' and 'N' instead of 0 and 1 which to me sounds better. Ways not to commit common mistakes while doing database design?</p>
<p>Links to books or articles will be highly appreciated.</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 387484,
"author": "missaghi",
"author_id": 46706,
"author_profile": "https://Stackoverflow.com/users/46706",
"pm_score": 2,
"selected": false,
"text": "Select name from peeps where accountStatusId = 5\n Select name \nfrom peeps p \njoin accountStatus s \non p.accountStatus... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37494/"
] |
387,340 | <p>I am working on a .jar file library to implement a bunch of helper classes to interface a PC to a piece of external hardware. I'll also add some simple applications, either command-line or GUI, to handle common tasks using the library.</p>
<p>My question is, is there a recommended way to simplify the command-line instantiation of a JVM in a certain specific way?</p>
<p>e.g. instead of requiring a user to type a cryptic error-prone command like:</p>
<pre><code>java -cp TurboBlenderLib.jar -jar TurboBlenderApp.jar -DFoo=Bar arg1 arg2
</code></pre>
<p>instead I do</p>
<pre><code>TurboBlenderApp arg1 arg2
</code></pre>
<p>?</p>
<p>I suppose I could use shell scripts (incl. win32 Batch Files... gacckkk), it's just that I'm not good at those + I was wondering if there was a more straightforward platform-independent way of running a Java app from the commandline.</p>
| [
{
"answer_id": 387348,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 3,
"selected": false,
"text": "-jar -cp CLASSPATH java -jar TheApp <whateverargumentsyouwant> jar"
},
{
"answer_id": 387383,
"author": ... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44330/"
] |
387,356 | <p>Is there a utility out there that will create VB.NET classes from a Dataset.xsd file? And I don't mean like the XSD.exe utility does - all that does is convert the XML of an XSD file into classes in a .vb - it doesn't append any "extended" functionality. </p>
<p>I'm basically looking for something that will generate the beginnings of a business layer from the XSD file. Like creating a partial class for each datatable, then create a property for each of the datatable's columns as the right datatype and finally the basically CRUD methods as well. </p>
<p>This is something I have to do manually over and over again for each project. (I do lots of little projects and use VistaDB so I can't use Linq-To-SQL - wish I could)</p>
| [
{
"answer_id": 626077,
"author": "Paul G",
"author_id": 162,
"author_profile": "https://Stackoverflow.com/users/162",
"pm_score": 2,
"selected": false,
"text": "xsd.exe -c -l:vb -n:Purchasing purchaseorder.xsd\n"
}
] | 2008/12/22 | [
"https://Stackoverflow.com/questions/387356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47167/"
] |
387,389 | <p>I created a webservice when it hosted on my local computer it works fine, but when i publish it to the web host, it doesnt work any more, i guess its a question about how the webserver is configured, but can i make some changes in web.config so it will work?</p>
<h2>The error i get is below:</h2>
<p>Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. </p>
<p>Parser Error Message: Could not load file or assembly 'MySql.Data, Version=5.0.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The system cannot find the file specified.</p>
<p>Source Error: </p>
<p>Line 37:
Line 38:
Line 39:
Line 40:
Line 41:
<p>Source File: c:\webs\talkactive\gb1634\qaz.dk\web.config Line: 39 </p>
<h2>Assembly Load Trace: The following information can be helpful to determine why the assembly 'MySql.Data, Version=5.0.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' could not be loaded.</h2>
<p>The webservice uses a c# class placed in the app_code folder. That c# class uses mysql.
When i use the class in a normal .aspx file it works fine</p>
| [
{
"answer_id": 387422,
"author": "Dillie-O",
"author_id": 71,
"author_profile": "https://Stackoverflow.com/users/71",
"pm_score": 0,
"selected": false,
"text": "<compilation debug=\"false\">\n <assemblies> \n <add assembly=\"MySql.Data, Version=5.0.9.0, Culture=neutral, Publ... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36476/"
] |
387,417 | <p>I have several instances where that a section of legacy sql statements is based on a dependency. for example. </p>
<pre><code>if (x !=null)
{
SQL = "SELECT z WHERE x > y";
}
else
{
SQL = "SELECT z WHERE x <= y";
}
SQL2 = SQL + " JOIN a ON b";
</code></pre>
<p>I am creating PreparedStatements out of this legacy code. What is the best-practice here. Should I create a PreparedStatement for the var SQL and nest it inside of SQL2 of should there be multiple PreparedStatements based on SQL2 without nesting, or something totlly different? </p>
<p>The code is much more complex than the example, as the SQL var is reused inside many long and complex SQL queries.</p>
<p>EDIT: Project Design requires using PreparedStatements, I don't have the choice of using libraries at this moment.</p>
| [
{
"answer_id": 387538,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 1,
"selected": false,
"text": "Zend_Db_Select"
},
{
"answer_id": 387587,
"author": "serg",
"author_id": 20128,
"author_profile": ... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13491/"
] |
387,424 | <p>I'm always surprised that even after using C# for all this time now, I still manage to find things I didn't know about...</p>
<p>I've tried searching the internet for this, but using the "~" in a search isn't working for me so well and I didn't find anything on MSDN either (not to say it isn't there)</p>
<p>I saw this snippet of code recently, what does the tilde(~) mean?</p>
<pre><code>/// <summary>
/// Enumerates the ways a customer may purchase goods.
/// </summary>
[Flags]
public enum PurchaseMethod
{
All = ~0,
None = 0,
Cash = 1,
Check = 2,
CreditCard = 4
}
</code></pre>
<p>I was a little surprised to see it so I tried to compile it, and it worked... but I still don't know what it means/does. Any help??</p>
| [
{
"answer_id": 387427,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 5,
"selected": false,
"text": "public enum PurchaseMethod\n{ \n All = ~0, // all bits of All are 1. the ~ operator just inverts bits\... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387424",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17091/"
] |
387,434 | <p>In SQL server you can use the DATENAME function to get the day of week as a string</p>
<pre><code>declare @date datetime
set @date = '12/16/08'
select datename(dw, @date)
</code></pre>
<p>which returns "Tuesday"</p>
<p>and you can use the DATEPART function to get the day of week as an integer</p>
<pre><code>declare @date datetime
set @date = '12/16/08'
select datepart(dw, @date)
</code></pre>
<p>Which returns 3 </p>
<p>But say I have a varchar that contains the string "Tuesday" and I want to convert it to its integer representation of 3. Sure, I could write out the conversion without much hassle, but I'd much rather use a built-in function. Does such a function exist?</p>
| [
{
"answer_id": 387518,
"author": "Russ Bradberry",
"author_id": 48450,
"author_profile": "https://Stackoverflow.com/users/48450",
"pm_score": 4,
"selected": false,
"text": "\nCREATE FUNCTION dbo.WeekDay(@DayOfWeek Varchar(9))\nRETURNS INT\n AS\n BEGIN\n DECLARE @iDayofWe... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387434",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17917/"
] |
387,438 | <p>i wonder if i've found a compiler bug? i was removing some old code from my app and now i get stackoverflow at "begin" (see code & disassembly below).</p>
<pre><code>procedure TfraNewRTMDisplay.ShowMeasurement;
var
iDummy, iDummy2, iDummy3:integer;
begin // STACK OVERFLOW BEFORE MY CODE STARTS
iDummy:=0;
iDummy2:=0;
case iDummy2 of
1:
case iDummy of
1:m_SelectedRTMMenuData.ChannelMeasSet.MeasKV.ClearMeasurementData;
2:m_SelectedRTMMenuData.ChannelMeasSet.MeasKV.ClearMeasurementData;
end;
end;
end;
NewRTMDisplay.pas.1601: begin
00983BF8 55 push ebp
00983BF9 8BEC mov ebp,esp
00983BFB B9D4E40400 mov ecx,$0004e4d4
00983C00 6A00 push $00 // stack overflow loop
00983C02 6A00 push $00 // stack overflow loop
00983C04 49 dec ecx // stack overflow loop
00983C05 75F9 jnz $00983c00 // stack overflow loop
00983C07 56 push esi
00983C08 57 push edi
00983C09 8945FC mov [ebp-$04],eax
00983C0C 8D856005FFFF lea eax,[ebp-$0000faa0]
00983C12 8B153C789A00 mov edx,[$009a783c]
00983C18 E88B35A8FF call @InitializeRecord
00983C1D 8D85D00AFEFF lea eax,[ebp-$0001f530]
00983C23 8B153C789A00 mov edx,[$009a783c]
00983C29 E87A35A8FF call @InitializeRecord
00983C2E 33C0 xor eax,eax
00983C30 55 push ebp
00983C31 68F73C9800 push $00983cf7
00983C36 64FF30 push dword ptr fs:[eax]
00983C39 648920 mov fs:[eax],esp
NewRTMDisplay.pas.1602: iDummy:=0;
00983C3C 33C0 xor eax,eax
00983C3E 8945F8 mov [ebp-$08],eax
NewRTMDisplay.pas.1603: iDummy2:=0;
00983C41 33C0 xor eax,eax
00983C43 8945F4 mov [ebp-$0c],eax
NewRTMDisplay.pas.1605: case iDummy2 of
00983C46 8B45F4 mov eax,[ebp-$0c]
00983C49 48 dec eax
00983C4A 7571 jnz $00983cbd
NewRTMDisplay.pas.1607: case iDummy of
00983C4C 8B45F8 mov eax,[ebp-$08]
00983C4F 48 dec eax
00983C50 7405 jz $00983c57
00983C52 48 dec eax
00983C53 7436 jz $00983c8b
00983C55 EB66 jmp $00983cbd
NewRTMDisplay.pas.1608: 1:m_SelectedRTMMenuData.ChannelMeasSet.MeasKV.ClearMeasurementData;
00983C57 8D951872EBFF lea edx,[ebp-$00148de8]
00983C5D 8B45FC mov eax,[ebp-$04]
00983C60 8B80F0020000 mov eax,[eax+$000002f0]
00983C66 E895DBE9FF call TRTMMenuData.ChannelMeasSet
00983C6B 8DB52072EBFF lea esi,[ebp-$00148de0]
00983C71 8DBD6005FFFF lea edi,[ebp-$0000faa0]
00983C77 B9A43E0000 mov ecx,$00003ea4
00983C7C F3A5 rep movsd
00983C7E 8D856005FFFF lea eax,[ebp-$0000faa0]
00983C84 E81B3F0200 call TDeviceMeas.ClearMeasurementData
00983C89 EB32 jmp $00983cbd
NewRTMDisplay.pas.1609: 2:m_SelectedRTMMenuData.ChannelMeasSet.MeasKV.ClearMeasurementData;
00983C8B 8D9560D9D8FF lea edx,[ebp-$002726a0]
00983C91 8B45FC mov eax,[ebp-$04]
00983C94 8B80F0020000 mov eax,[eax+$000002f0]
00983C9A E861DBE9FF call TRTMMenuData.ChannelMeasSet
00983C9F 8DB568D9D8FF lea esi,[ebp-$00272698]
00983CA5 8DBDD00AFEFF lea edi,[ebp-$0001f530]
00983CAB B9A43E0000 mov ecx,$00003ea4
00983CB0 F3A5 rep movsd
00983CB2 8D85D00AFEFF lea eax,[ebp-$0001f530]
00983CB8 E8E73E0200 call TDeviceMeas.ClearMeasurementData
NewRTMDisplay.pas.1612: end;
</code></pre>
<p>any ideas?</p>
<p>thank you!
mp</p>
| [
{
"answer_id": 387493,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": false,
"text": "m_SelectedRTMMenuData.ChannelMeasSet.MeasKV.ClearMeasurementData;\n"
},
{
"answer_id": 387532,
"author": "X-R... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387438",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14031/"
] |
387,451 | <p>I have a C# public API that is used by many third-party developers that have written custom applications on top of it. In addition, the API is used widely by internal developers.</p>
<p>This API wasn't written with testability in mind: most class methods aren't virtual and things weren't factored out into interfaces. In addition, there are some helper static methods.</p>
<p>For many reasons I can't change the design significantly without causing breaking changes for applications developed by programmers using my API. However, I'd still like to give internal and external developers using this API the chance to write unit tests and be able to mock the objects in the API.</p>
<p>There are several approaches that come to mind, but none of them seem great:</p>
<ol>
<li><p>The traditional approach would be to force developers to create a proxy class that they controlled that would talk to my API. This won't work in practice because there are now hundreds of classes, many of which are effectively strongly typed data transfer objects that would be a pain to reproduce and maintain.</p></li>
<li><p>Force all developers using the API that want to unit test it to buy <a href="http://www.typemock.com/" rel="nofollow noreferrer">TypeMock</a>. This seems harsh to force people to pay $300+ per developer and potentially require them to learn a different mock object tool than what their used to.</p></li>
<li><p>Go through the entire project and make all the methods virtual. This would allow mock-ing of objects using free tools like <a href="http://code.google.com/p/moq/" rel="nofollow noreferrer">Moq</a> or <a href="http://ayende.com/projects/rhino-mocks.aspx" rel="nofollow noreferrer">Rhino Mocks</a>, but it could potentially open up security risks for classes that were never meant to be derived from. Additionally this could cause breaking changes.</p></li>
<li><p>I could create a tool that given an input assembly would output an assembly with the same namespaces, classes, and members, but would make all of the methods virtual and it would make the method body just return the default value for the return type. Then, I could ship this dummy test assembly each time I released an update to the API. Developers could then write tests for the API against the dummy assembly since it had virtual members that are very mock-able. This might work, but it seems a bit tedious to write a custom tool for this and I can't seem to find an existing one that does it well (especially that works well with generics). Furthermore, it has the complication that it requires developers to use two different assemblies that could possibly go out of date.</p></li>
<li><p>Similar to #4, I could go through every file and add something like "#ifdef UNITTEST" to every method and body to do the equivalent of what a tool would do. This doesn't require an external tool, but it would pollute the codebase with a lot of ugly "#ifdef"'s.</p></li>
</ol>
<p>Is there something else that I haven't considered that would be a good fit? Does a tool like what I mentioned in #4 already exist?</p>
<p>Again, the complicating factor is that this is a rather large API (hundreds of classes and ~10 files) and has existing applications using it which makes it hard to do drastic design changes.</p>
<p>There <a href="https://stackoverflow.com/questions/131806/mocking-classes-that-arent-interfaces">have</a> <a href="https://stackoverflow.com/questions/42785/how-do-you-retrofit-unit-tests-into-a-code-base">been</a> <a href="https://stackoverflow.com/questions/346345/how-do-you-unit-test-a-class-that-is-dependent-on-many-other-classes">several</a> <a href="https://stackoverflow.com/questions/107919/is-it-feasible-to-introduce-test-driven-development-tdd-in-a-mature-project">questions</a> on Stack Overflow that were generic about retrofitting an existing application to make it testable, but none seem to address the concerns I have (specifically in the context of a widely used API with many third-party developers). I'm also aware of "<a href="http://www.objectmentor.com/resources/articles/WorkingEffectivelyWithLegacyCode.pdf" rel="nofollow noreferrer">Working Effectively With Legacy Code</a>" and think it has good advice, but I am looking for a specific .net approach given the constraints mentioned above.</p>
<p><strong>UPDATE:</strong> I appreciate the answers so far. One that <a href="https://stackoverflow.com/users/46187/patrik-h228gne">Patrik Hägne</a> brought up is "why not extract interfaces?" This indeed works to a point, but has some problems such as the existing design has many cases where we take expose a concrete class. For example:</p>
<pre><code>public class UserRepository
{
public UserData GetData(string userName)
{
...
}
}
</code></pre>
<p>Existing customers that are expecting the concrete class (e.g. "UserData") would break if they were given an "IUserData." </p>
<p>Additionally, as mentioned in the comments there are cases where we take in a class and then expose it for convenience. This could cause problems if we took in an interface and then had to expose it as a concrete class.</p>
<p>The biggest challenge to a significant rewrite or redesign is that there is a huge investment in the current API (thousands of hours of development and probably just as much third party training). So, while I agree that a better <a href="http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod" rel="nofollow noreferrer">SOLID</a> design rewrite or abstraction layer (that eventually could become the new API) that focused on items like the <a href="http://www.objectmentor.com/resources/articles/isp.pdf" rel="nofollow noreferrer">Interface Separation Principle</a> would be a plus from a testability perspective, it'd be a large undertaking that probably can't be cost justified at the present time.</p>
<p>We do have testing for the current API, but it is more complicated integration testing rather than unit-testing. </p>
<p>Additionally, as mentioned by <a href="https://stackoverflow.com/users/10862/chadmyers">Chad Myers</a>, this is question addresses a similar problem that the .NET framework itself faces in some areas.</p>
<p>I realize that I'm probably looking for a "silver bullet" here that doesn't exist, but all help is appreciated. The important part is protecting the huge time investments by many third party developers as well as the huge existing development to create the current API.</p>
<p>All answers, especially those that consider the business side of the problem, will be carefully reviewed. Thanks!</p>
| [
{
"answer_id": 388838,
"author": "Patrik Hägne",
"author_id": 46187,
"author_profile": "https://Stackoverflow.com/users/46187",
"pm_score": 1,
"selected": false,
"text": "public interface IUserRepository\n{\n IUserData GetData(string userName);\n}\n\npublic class UserRepository \n ... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1869/"
] |
387,453 | <p>Does anyone know a way to display code in Microsoft Word documents that preserves coloring and formatting? Preferably, the method would also be unobtrusive and easy to update.</p>
<p>I have tried to include code as regular text which looks awful and gets in the way when editing regular text. I have also tried inserting objects, a WordPad document and Text Box, into the document then putting the code inside those objects. The code looks much better and is easier to avoid while editing the rest of the text. However, these objects can only span one page which makes editing a nightmare when several pages of code need to be added.</p>
<p>Lastly, I know that there are much better editors/formats that have no problem handling this but I am stuck working with MS word.</p>
| [
{
"answer_id": 2653406,
"author": "gargamel",
"author_id": 264597,
"author_profile": "https://Stackoverflow.com/users/264597",
"pm_score": 12,
"selected": true,
"text": "Insert Text Object OpenDocument Text"
},
{
"answer_id": 2653526,
"author": "Donal Fellows",
"author_id... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13054/"
] |
387,466 | <p>I've got a submission page in php with an html form that points back to the same page. I'd like to be able to check if the required fields in the form aren't filled so I can inform the user. I'd like to know how to do that with php and javascript each. However, I imagine this is a common issue so any other answers are welcome.</p>
| [
{
"answer_id": 387490,
"author": "Riho",
"author_id": 44715,
"author_profile": "https://Stackoverflow.com/users/44715",
"pm_score": 3,
"selected": true,
"text": " if(isset($_POST['save']))\n {\n $fields=array();\n $fields['Nimi'] = $_POST['name'];\n ... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25680/"
] |
387,469 | <p>Is JSF being used in the enterprise, or at least growing in use?</p>
| [
{
"answer_id": 387490,
"author": "Riho",
"author_id": 44715,
"author_profile": "https://Stackoverflow.com/users/44715",
"pm_score": 3,
"selected": true,
"text": " if(isset($_POST['save']))\n {\n $fields=array();\n $fields['Nimi'] = $_POST['name'];\n ... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13143/"
] |
387,471 | <p>In a Java web application I have a recurring message load of type A (e.g., 20,000 every hour). Then I have a second type of messages (type B) that show up occasionally but have a higher priority than type A (say, 3,000). I want to be able to process these messages on one or more machines using open source software.</p>
<p>It seems to me that I could do that with JMS if I had a JMS server that would send messages from its queue based on priorities (e.g., send three message of type B and then one of type A even though all messages of type A are at the top of the message queue).</p>
<p>Do you know a JMS server that can do that - or do you know another way to implement this?</p>
| [
{
"answer_id": 387828,
"author": "James Schek",
"author_id": 17871,
"author_profile": "https://Stackoverflow.com/users/17871",
"pm_score": 3,
"selected": true,
"text": "\"JMS does not require that a provider strictly implement priority ordering of messages; however, it should do its best... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3574/"
] |
387,476 | <p>I want our app to show the online help page (so it's always up to date) or even a local page. However, it's likely to be blocked by the Firewall (Zone Alarm).</p>
<p>BTW, I tested this with Zone Alarm. It blocked access to a local .html file as well as to an .asp file on the internet. (I.e., tried to display a page in Internet Explorer and got the Zone Alarm dialog asking if I wanted to give permission to display</p>
<p>Is there a way around this?
Perhaps displaying the web page in the Web Browser Control?</p>
| [
{
"answer_id": 387828,
"author": "James Schek",
"author_id": 17871,
"author_profile": "https://Stackoverflow.com/users/17871",
"pm_score": 3,
"selected": true,
"text": "\"JMS does not require that a provider strictly implement priority ordering of messages; however, it should do its best... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4906/"
] |
387,479 | <p>I've encountered a problem with my Netbeans 6.1 IDE.</p>
<p>After an unsuccessful update, Netbeans stopped recognizing Apache and Glassfish servers and requested me to resolve a missing server error, after which I opened a window to add a server, except there were none listed. Trying to add servers in the list yields no results as there isn't even a single server type to be chosen.</p>
<p>Reinstalling Netbeans didn't fix the problem. Does anyone have any idea how to fix this?</p>
| [
{
"answer_id": 387828,
"author": "James Schek",
"author_id": 17871,
"author_profile": "https://Stackoverflow.com/users/17871",
"pm_score": 3,
"selected": true,
"text": "\"JMS does not require that a provider strictly implement priority ordering of messages; however, it should do its best... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45651/"
] |
387,480 | <p>What is the best way to hide Tab headers when there is only a single visible Tab?</p>
<p>I want to hide TabControl chrome completely, while leaving the content of the Tab visible.</p>
| [
{
"answer_id": 387565,
"author": "Robert Macnee",
"author_id": 19273,
"author_profile": "https://Stackoverflow.com/users/19273",
"pm_score": 7,
"selected": true,
"text": "<Grid xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n xmlns:sys=\"clr-namespace:System;ass... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39068/"
] |
387,483 | <p>I'm trying to send an email to several recipients when a new row is inserted into a table. The list of recipients varies. I would like to be able to set this list using a select statement.
I also have installed Navicat which allows me to send email notifications but only to a predetermined set of people.</p>
<p>Thanks.</p>
| [
{
"answer_id": 4101782,
"author": "Tony",
"author_id": 497770,
"author_profile": "https://Stackoverflow.com/users/497770",
"pm_score": 5,
"selected": false,
"text": "CREATE TRIGGER test.autosendfromdrop BEFORE INSERT ON test.emaildrop\nFOR EACH ROW BEGIN\n /* START THE WRITING OF TH... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48488/"
] |
387,485 | <p>I have a sidebar on my webpage that is supposed to span 100% of the page (vertically). It is then supposed to stay there, so when the rest of the content scrolls it does not. To do this, I used:</p>
<pre><code>body
{
height: 100%;
}
#sidebar
{
height: 100%;
width: 120px;
position: fixed;
top: 0;
left: 0;
}
</code></pre>
<p>This works great in all modern browsers! Unfortunately, I have to code for IE6, which does not support position: fixed. Do you have any idea how I would do this?</p>
| [
{
"answer_id": 4101782,
"author": "Tony",
"author_id": 497770,
"author_profile": "https://Stackoverflow.com/users/497770",
"pm_score": 5,
"selected": false,
"text": "CREATE TRIGGER test.autosendfromdrop BEFORE INSERT ON test.emaildrop\nFOR EACH ROW BEGIN\n /* START THE WRITING OF TH... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
387,488 | <p>I am setting a cookie <code>Request.Cookies("TemplateName").value</code> on one of my pages(page 3) of my application. Now I can navigate from page 3 to page 4 and page 2 and retain the value of the cookie. But now when I logout and login again it still has the value, how can I reset the value of the cookie to be blank "" when I start a new instance?</p>
<p>I tried:</p>
<pre><code>Request.Cookies("TemplateName").Expires = Now
Request.Cookies("TemplateName").value = ""
</code></pre>
<p>On my homepage, but the cookie still retains the value on page 2 and 3.</p>
| [
{
"answer_id": 387522,
"author": "cgreeno",
"author_id": 6088,
"author_profile": "https://Stackoverflow.com/users/6088",
"pm_score": 4,
"selected": true,
"text": "Response.Cookies[\"TemplateName\"].Value = \"\";\n\nResponse.Cookies[\"TemplateName\"].Expires = DateTime.Now;\n Dim subkeyNa... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34219/"
] |
387,492 | <p>I am creating a MFC application in which there is a skin library which handles the UI effect of rendering the controls (it gets called in oninitdialog). But, meanwhile, I have also the requirement of displaying an icon on the buttons. For this, I am marking the buttons as ownerdrawn=true, and able to display icon, but in this case, skin effect is not taking place on those buttons whose ownerdrawing is done by me. So, my question is, how do I ensure that a control gets ownedrawn by me, and also by any other library.</p>
| [
{
"answer_id": 387522,
"author": "cgreeno",
"author_id": 6088,
"author_profile": "https://Stackoverflow.com/users/6088",
"pm_score": 4,
"selected": true,
"text": "Response.Cookies[\"TemplateName\"].Value = \"\";\n\nResponse.Cookies[\"TemplateName\"].Expires = DateTime.Now;\n Dim subkeyNa... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387492",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
387,514 | <p>I need to create a Windows service that works just like the task scheduler in that I can configure what time it runs and it basically just calls a .NET class at that scheduled time (recurring). What is the recommended way to do this? Also, any information on installing/removing that service would be appreciated!</p>
<p>Update: Using the task scheduler in not an option (customer requirement, something to do with their IT standards). That was my suggestion to them as well, but it's not going to work.</p>
<p>Solution: Thanks to everyone for your answers, the Quartz.Net solution especially looks good, however I found the following which has exactly what I need:</p>
<p><a href="http://www.c-sharpcorner.com/UploadFile/ajifocus/AppScheduler05262006074807AM/AppScheduler.aspx?ArticleID=b52f76da-943f-4807-9675-869f135ef2cd" rel="nofollow noreferrer">http://www.c-sharpcorner.com/UploadFile/ajifocus/AppScheduler05262006074807AM/AppScheduler.aspx?ArticleID=b52f76da-943f-4807-9675-869f135ef2cd</a></p>
| [
{
"answer_id": 392511,
"author": "faulty",
"author_id": 20007,
"author_profile": "https://Stackoverflow.com/users/20007",
"pm_score": 1,
"selected": false,
"text": "System.Threading.Timer"
}
] | 2008/12/22 | [
"https://Stackoverflow.com/questions/387514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47110/"
] |
387,534 | <p>I've got some javascript code that applies an alpha transparency. Before it does that it attempts to detect what type of transparency the browser supports and stores that in a variable for use later. Here's what the code looks like:</p>
<pre><code>// figure out the browser support for opacity
if (typeof br.backImg.style.opacity != 'undefined')
opacityType = 'opacity';
else if (typeof br.backImg.filters == 'object')
opacityType = 'filter';
else
opacityType = 'none';
</code></pre>
<p>For Firefox and Safari, the first condition is true, for IE7 the second condition is true, but for IE6 it falls to the last condition. Why would IE6 not have a filters object? Is there a better way of detecting this?</p>
| [
{
"answer_id": 388601,
"author": "some",
"author_id": 36866,
"author_profile": "https://Stackoverflow.com/users/36866",
"pm_score": 4,
"selected": true,
"text": "var opacityType=(\n (typeof o.style.opacity !== 'undefined') ? 'opacity' :\n /*@cc_on @if (@_jscript)\n (typeof o.filters... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387534",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48413/"
] |
387,536 | <p>I've been programming in Ruby for a few months now, and I'm wondering when it is appropriate to use constants over class variables and vice versa. (I'm working in Rails, thinking about constants in models).</p>
<pre><code>class Category
TYPES = %w(listing event business).freeze
end
</code></pre>
<p>OR</p>
<pre><code>class Category
@@types = %w(listing event business).freeze
cattr_reader :types
end
</code></pre>
<p>Are there circumstances where one is preferable to another? Or is it just a matter of taste/style?</p>
| [
{
"answer_id": 52559053,
"author": "berkos",
"author_id": 2819355,
"author_profile": "https://Stackoverflow.com/users/2819355",
"pm_score": 2,
"selected": false,
"text": "FOO = 18\nprivate_constant :FOO\n"
}
] | 2008/12/22 | [
"https://Stackoverflow.com/questions/387536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6705/"
] |
387,547 | <p>I ran into this today when unit testing a generic dictionary.</p>
<pre><code>System.Collections.Generic.Dictionary<int, string> actual, expected;
actual = new System.Collections.Generic.Dictionary<int, string> { { 1, "foo" }, { 2, "bar" } };
expected = new System.Collections.Generic.Dictionary<int, string> { { 1, "foo" }, { 2, "bar" } };
Assert.AreEqual(expected, actual); //returns false
</code></pre>
<p>fails except when <code>actual == expected</code> (object references are the same). Obviously, <code>actual.Equals(expected)</code> returns false as well.</p>
<p>Fine, but if the implementation of <code>System.Collections.Generic.Dictionary<int, string>.Equals</code> only does reference equality, what's the point of <code>IEquatable</code>? In other words, why is there no baked-in way to do value equality for generic collections?</p>
<p><strong>Edit</strong> Thanks for the responses so far. Obviously my example is using value types, but I think my complaint holds for all objects. Why can't a generic collection equality just be a union of equalities of its types? Unexpected behavior doesn't really cut it since there are separate provisions for finding reference equality. I suppose this would introduce the constraint of collections only holding object that implement <code>IEquatable</code>, as Konrad Rudolph points out. However, in an object like Dictionary, this doesn't seem too much to ask.</p>
| [
{
"answer_id": 387561,
"author": "Mike Scott",
"author_id": 43649,
"author_profile": "https://Stackoverflow.com/users/43649",
"pm_score": 2,
"selected": false,
"text": "Dictionary<T,T>.Equals"
},
{
"answer_id": 387569,
"author": "Lasse V. Karlsen",
"author_id": 267,
"... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2637/"
] |
387,589 | <p>Is there a method built in to NSString that tokenizes the string and searches the beginning of each token? the <code>compare</code> method seems to only do the beginning of a string, and using <code>rangeOfString</code> isn't really sufficient because it doesn't have knowledge of tokens. Right now I'm thinking the best way to do this is to call </p>
<pre><code>[myString componentsSeparatedByString:@" "]
</code></pre>
<p>and then loop over the resulting array, calling compare on each component of the string. Is this built-in and I just missed it?</p>
| [
{
"answer_id": 387604,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": true,
"text": "@\" \""
}
] | 2008/12/22 | [
"https://Stackoverflow.com/questions/387589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44858/"
] |
387,592 | <p>Hopefully, this will be an easy answer for someone with Javascript time behind them...</p>
<p>I have a log file that is being watched by a script that feeds new lines in the log out to any connected browsers. A couple people have commented that what they want to see is more of a 'tail -f' behavior - the latest lines will always be at the bottom of the browser page until the viewer scrolls back up to see something. Scrolling back to the bottom should return you to the auto-scrolling behavior.</p>
<p>My google strikeout on this one is - hopefully - just a matter of not knowing anything at all about javascript and therefore, not knowing what keywords to search for. I don't need a complete solution - just a 'close enough' that lets me jump in and get my hands dirty.</p>
<p>EDIT:</p>
<p>I've been attempting the scrollTop/scrollHeight idea, but am clearly missing something. I've done next to nothing with Javascript, so again I'm probably asking very low-level questions:</p>
<pre><code><html><body>
<script type="text/javascript">
for (i=0; i<100; i++)
{
document.write("" + i + "<br />");
document.scrollTop = document.scrollHeight;
}
</script>
</body></html>
</code></pre>
<p>This was one of many permutations. Obviously, I can't output the log line-by-line in javascript, but I'm just trying to see the correct behavior. What's the missing link I need here?</p>
<p>EDIT AGAIN:
This has turned into a far more interesting problem that I first expected. The code suggestion using window.scroll does do the trick. I started playing with restricting the scroll to only take place when the browser was at the bottom of the document body. This is easy enough to do in theory, but in practice it hits a snag:</p>
<p>Every time you get new text from the server, the size of the body increases and your current scroll position is no longer at the bottom of the document. You can no longer tell the difference (using scrollHeight, clientHeight and scrollTop) whether the user has scrolled up or if the text has just shot beyond their view.</p>
<p>I think that if this is going to work, I'm going to have to commit myself to having a JS event that fires when the user scrolls and turns off scrolling if they are above the bottom of the window, but turns it back on if they have scrolled down to the point where they are effectively at the bottom of the view. I'm looking at the onScroll event and, given that the math on the variables I mentioned works out pretty well, I think I am on the right path here. Thanks for your input, everyone!</p>
| [
{
"answer_id": 387610,
"author": "Russ Bradberry",
"author_id": 48450,
"author_profile": "https://Stackoverflow.com/users/48450",
"pm_score": 0,
"selected": false,
"text": "obj.scrollTop = obj.scrollHeight;\n"
},
{
"answer_id": 387734,
"author": "Adriana",
"author_id": 46... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30997/"
] |
387,594 | <p>I am considering releasing one of my class libraries written in C# as open source. Before doing that, I am trying to do some refactoring so that it meets the demands of the general public :)</p>
<p>I wonder what would be the best namespace schema to use? Basically, I see the following options:</p>
<ul>
<li>namespace <strong>MyTool</strong>: This just doesn't really look like organized for me. I mean, (almost) all the namespaces in the .NET Framework are prefixed with System so I guess it is not really a standard way to do it.</li>
<li>namespace <strong>MyOrganization.MyTool</strong>: The problem with that there is just simply no "MyOrganization". It is written in my spare time.</li>
<li>namespace <strong>MyName.MyTool</strong>: I would prefer something more humble. I mean really, I don't want to have my name in the namespace.</li>
</ul>
<p>Now there are a couple of related questions on Stackoverflow already, like <a href="https://stackoverflow.com/questions/240033/how-do-you-come-up-with-names-for-your-namespaces">this</a> and <a href="https://stackoverflow.com/questions/123114/how-do-you-organize-your-namespaces">this</a>, but none of them really answer my question.</p>
<p>Any suggestions?</p>
| [
{
"answer_id": 387615,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 0,
"selected": false,
"text": "MyTool MyCompany.MyTool net.madrat.MyTool TheirName.MyTool"
},
{
"answer_id": 387652,
"author": "Kev",
... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8954/"
] |
387,606 | <p>I need to design a program using python that will ask the user for a barcode. Then, using this barcode, it will search a mysql to find its corresponding product. </p>
<p>I am a bit stuck on how to get started. Does anyone have any tips for me?</p>
| [
{
"answer_id": 393356,
"author": "nosklo",
"author_id": 17160,
"author_profile": "https://Stackoverflow.com/users/17160",
"pm_score": 4,
"selected": true,
"text": "import MySQLdb\n\nuser_input = raw_input(\"Please enter barcode and press Enter button: \")\n\ndb = MySQLdb.connect(passwd=\... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47204/"
] |
387,619 | <p>I'm writing a script in python which basically queries WMI and updates the information in a mysql database. One of those "write something you need" to learn to program exercises.</p>
<p>In case something breaks in the middle of the script, for example, the remote computer turns off, it's separated out into functions.</p>
<p>Query Some WMI data<br>
Update that to the database<br>
Query Other WMI data<br>
Update that to the database </p>
<p>Is it better to open one mysql connection at the beginning and leave it open or close the connection after each update?</p>
<p>It seems as though one connection would use less resources. (Although I'm just learning, so this is a complete guess.) However, opening and closing the connection with each update seems more 'neat'. Functions would be more stand alone, rather than depend on code outside that function.</p>
| [
{
"answer_id": 387759,
"author": "adolfojp",
"author_id": 20137,
"author_profile": "https://Stackoverflow.com/users/20137",
"pm_score": 1,
"selected": false,
"text": "for dataItem in dataSet:\n update(dataItem)\n"
}
] | 2008/12/22 | [
"https://Stackoverflow.com/questions/387619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46063/"
] |
387,623 | <p>I have a file with 450,000+ rows of entries. Each entry is about 7 characters in length. What I want to know is the unique characters of this file.</p>
<p>For instance, if my file were the following;</p>
<blockquote>
<pre><code>Entry
-----
Yabba
Dabba
Doo
</code></pre>
</blockquote>
<p>Then the result would be</p>
<blockquote>
<p>Unique characters: {abdoy}</p>
</blockquote>
<p>Notice I don't care about case and don't need to order the results. Something tells me this is very easy for the Linux folks to solve.</p>
<h2>Update</h2>
<p>I'm looking for a very fast solution. I really don't want to have to create code to loop over each entry, loop through each character...and so on. I'm looking for a nice script solution.</p>
<h2>Update 2</h2>
<p>By <strong>Fast</strong>, I mean fast to implement...not necessarily fast to run.</p>
| [
{
"answer_id": 387630,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 3,
"selected": false,
"text": "set set"
},
{
"answer_id": 387650,
"author": "Jough",
"author_id": 48501,
"author_profile": "http... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
387,631 | <p>I know that a lot of us are familiar with setting the font size on the body element in our CSS to 62.5%. This means that 1em will equal 10px and helps for keeping things pixel perfect but also allows for scaling of fonts.</p>
<p>So wouldn't that mean that setting it to 6.25% would equate to 1em = 1px? Seems like an even simpler conversion rather than having to mess with decimals...</p>
<hr>
<p>Thanks guys! I'm quite aware of the em and it's history (design degree), but I'm sure others may find it helpful :)</p>
<p>As far as the 1em = 1px, I don't see how this is undesirable. The em is square, regardless of your units (be it points or pixels) and nobody would set their type at 1px (just like nobody would set printed type at 1pt). Furthermore, even your article concedes that in most digital typefaces, the capital "M" is usually smaller than 1em, and that the em is merely a reflection of the point size (48pt type would render a 48pt by 48pt square for the em, 12pt type would yield 12x12, etc.)</p>
<p>Besides, the reason people would do this would be more for setting dimensions of other elements on the page so that everything scales nicely when the user adjusts their font size. Sure, there will always be the rare few who set their default to something other than 16px, but well worth the price to pay for a pixel perfect layout that scales nicely.</p>
| [
{
"answer_id": 387693,
"author": "Phil.Wheeler",
"author_id": 15609,
"author_profile": "https://Stackoverflow.com/users/15609",
"pm_score": 3,
"selected": false,
"text": "<h1> <h2> <h4> font-size: 0.005em font-size: 40em"
},
{
"answer_id": 387722,
"author": "cowgod",
"aut... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/373916/"
] |
387,633 | <p>How should exceptions be dispatched so that error handling and diagnostics can be handled in a centralized, user-friendly manner?</p>
<p>For example:</p>
<ul>
<li>A DataHW class handles communication with some data acquisition hardware.</li>
<li>The DataHW class may throw exceptions based on a number of possible errors: intermittent signal, no signal, CRC failure, driver error. Each type of error gets its own exception class.</li>
<li>The DataHW class is called by a number of different pieces of code that do different types of acquisition and analysis.</li>
</ul>
<p>The proper error handling strategy depends on the type of exception and the operation being attempted. (On intermittent signal, retry X times then tell the user; on a driver error, log an error and restart the driver; etc.) How should this error handling strategy be invoked?</p>
<ul>
<li>Coding error recovery into each exception class: This would result in exception classes that are rather large and contain high-level UI and system management code. This seems bad.</li>
<li>Providing a separate <code>catch</code> block for each type of exception: Since the DataHW class is called from many different places, each <code>catch</code> block would have to be duplicated at each call site. This seems bad.</li>
<li>Using a single <code>catch</code> block that calls some <code>ExceptionDispatch</code> function with a giant RTTI-based <code>switch</code> statement: RTTI and <code>switch</code> usually indicates a failure to apply OO design, but this seems the least bad alternative.</li>
</ul>
| [
{
"answer_id": 387667,
"author": "fizzer",
"author_id": 18167,
"author_profile": "https://Stackoverflow.com/users/18167",
"pm_score": 4,
"selected": true,
"text": "f()\n{\n try\n {\n // something\n }\n catch (...)\n {\n handle();\n }\n}\n\nvoid handle()\n{... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25507/"
] |
387,636 | <p>Let's say I have a table called Product, with three columns: Id, CustomerId, Name. Id is the primary key. The schema is outside of the control of my group, and we now have a requirement to always provide CustomerId as a parameter for all queries (selects, updates, deletes). It's a long story I'd rather not get into ... it involves triggers :-P</p>
<p>So my question is, when I have an attached entity in LinqToEntities, and I want to save some updates (say I'm updating the name in this case). How can I get it to generate the SQL:</p>
<pre><code>update Product set Name = @Name where Id=@Id and CustomerId=@CustomerId
</code></pre>
<p>Where the customerId parameter is included in the where clause in addition to the primary key.</p>
<p>Thanks :-)</p>
| [
{
"answer_id": 389054,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": true,
"text": "UPDATE(...) var qry = from product in model.Products\n where Id == @Id && CustomerId == @CustomerId\n ... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387636",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5416/"
] |
387,638 | <pre><code>print("select CustomerNo, CustomerName, Address, City, State, Zip,
Phone, Fax, ContactName, Email
from Customers where CustomerName like '%field%'");
</code></pre>
<p>Hi all. This is a simple question but I wasn't able to figure since I'm pretty new to tsql and sql in general.</p>
<p>I use the above stored procedure to do search. My question is for '%field%'. What variable do you use or how does it work in tsql? for example, "where Customers = @CustomerNo". how about for wildcard? how do you pass in a variable along with wildcard? I guess i can do "%" + "field" + "%" in the code but is there a way not to do that?</p>
| [
{
"answer_id": 387643,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 0,
"selected": false,
"text": "WHERE CustomerID LIKE '%1'\n"
},
{
"answer_id": 387647,
"author": "Bill Karwin",
"author_id": 20860,
... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28647/"
] |
387,646 | <p>Why is the compiler unable to infer the correct type for the result from Collections.emptySet() in the following example?</p>
<pre><code>import java.util.*;
import java.io.*;
public class Test {
public interface Option<A> {
public <B> B option(B b, F<A,B> f);
}
public interface F<A,B> {
public B f(A a);
}
public Collection<String> getColl() {
Option<Integer> iopt = null;
return iopt.option(Collections.emptySet(), new F<Integer, Collection<String>>() {
public Collection<String> f(Integer i) {
return Collections.singleton(i.toString());
}
});
}
}
</code></pre>
<p>Here's the compiler error message:</p>
<pre><code>knuttycombe@knuttycombe-ubuntu:~/tmp/java$ javac Test.java
Test.java:16: <B>option(B,Test.F<java.lang.Integer,B>) in
Test.Option<java.lang.Integer> cannot be applied to (java.util.Set<java.lang.Object>,
<anonymous Test.F<java.lang.Integer,java.util.Collection<java.lang.String>>>)
return iopt.option(Collections.emptySet(), new F<Integer, Collection<String>>() {
^
1 error
</code></pre>
<p>Now, the following implementation of getColl() works, of course:</p>
<pre><code> public Collection<String> getColl() {
Option<Integer> iopt = null;
Collection<String> empty = Collections.emptySet();
return iopt.option(empty, new F<Integer, Collection<String>>() {
public Collection<String> f(Integer i) {
return Collections.singleton(i.toString());
}
});
}
</code></pre>
<p>and the whole intent of the typesafe methods on Collections is to avoid this sort of issue with the singleton collections (as opposed to using the static variables.) So is the compiler simply unable to perform inference across multiple levels of generics? What's going on?</p>
| [
{
"answer_id": 387661,
"author": "GaryF",
"author_id": 1035,
"author_profile": "https://Stackoverflow.com/users/1035",
"pm_score": 4,
"selected": true,
"text": "print(\"Collections.<String>emptySet();\");\n"
},
{
"answer_id": 387662,
"author": "bradheintz",
"author_id": 4... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/390636/"
] |
387,654 | <p>In Z80 machine code, a cheap technique to initialize a buffer to a fixed value, say all blanks. So a chunk of code might look something like this.</p>
<pre><code>LD HL, DESTINATION ; point to the source
LD DE, DESTINATION + 1 ; point to the destination
LD BC, DESTINATION_SIZE - 1 ; copying this many bytes
LD (HL), 0X20 ; put a seed space in the first position
LDIR ; move 1 to 2, 2 to 3...
</code></pre>
<p>The result being that the chunk of memory at DESTINATION is completely blank filled.
I have experimented with memmove, and memcpy, and can't replicate this behavior. I expected memmove to be able to do it correctly.</p>
<p><strong>Why do memmove and memcpy behave this way?</strong></p>
<p><strong>Is there any reasonable way to do this sort of array initialization?</strong></p>
<p>I am already aware of char array[size] = {0} for array initialization</p>
<p>I am already aware that memset will do the job for single characters.</p>
<p>What other approaches are there to this issue?</p>
| [
{
"answer_id": 387671,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 3,
"selected": false,
"text": "std::fill std::memset"
},
{
"answer_id": 387773,
"author": "Ned Batchelder",
"author_id": 14343,
... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7734/"
] |
387,672 | <p>I've just started using NHibernate and fluent-NHibernate which I think is great. I've been configuring all my mappings to use LazyLoading for any relationships between classes because generally I find it isn't neccesary to load everything upfront. However sometimes you know 100% you will be loading all of the relationships or at least one relationship and it will save the extra connection(s) if you get the data up front.</p>
<p>Is there anyway that you can tell NHibernate to load the relationship data for a relationship and override the initial setting?</p>
<p>I was using LinqToSql before, for that I would create repositories which would have an overload of what items should load in which relationships when neccesary. This worked really well so I would like something similar for NHibernate. </p>
| [
{
"answer_id": 402907,
"author": "John_",
"author_id": 26081,
"author_profile": "https://Stackoverflow.com/users/26081",
"pm_score": 4,
"selected": true,
"text": ".SetFetchMode(\"Prices\", FetchMode.Join)\n"
},
{
"answer_id": 2289821,
"author": "Gary Joynes",
"author_id":... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26081/"
] |
387,685 | <p>Here is the problem: We have all of our development under subversion, but our beta versions are just mish-mashed bits of exported files that were not all put there at the same time. Or, to put it another way, we make our changes to versioned files, and then when we think we are happy, we manually export them by simply copying them to a different directory.</p>
<p>Well, we would like to have the whole works managed by Subversion, with the beta version as a simple working copy of the head of the trunk. I know that I can start with the trunk head, and simply roll back specific areas until I reach the same files, but it would be nice to know what revision each file needs to get rolled back to.</p>
<p>Does such a tool, that will take a set of files/directories and compare it to a repository, giving revision numbers for each file/directory, exist? If not, how would I go about putting a script together to do this?</p>
| [
{
"answer_id": 898713,
"author": "Dan",
"author_id": 54852,
"author_profile": "https://Stackoverflow.com/users/54852",
"pm_score": 0,
"selected": false,
"text": "FOR EACH of the exported files\n ITERATE backwards through the revisions of that file\n IF the revisioned file matches your ... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20770/"
] |
387,686 | <ul>
<li>I have a <em>Client</em> and <em>Groupe</em> Model.</li>
<li>A <em>Client</em> can be part of multiple <em>groups</em>.</li>
<li><em>Clients</em> that are part of a group can use its group's free rental rate at anytime but only once. That is where the intermediary model (<em>ClientGroupe</em>) comes in with that extra data.</li>
</ul>
<p>For now, when I try to save the m2m data, it just dies and says I should use the ClientGroupe Manager...so what's missing?</p>
<h2>Here are my models:</h2>
<pre><code>class Groupe(models.Model):
nom = models.CharField(max_length=1500, blank=True)
class Client(models.Model):
nom = models.CharField(max_length=450, blank=True)
prenom = models.CharField(max_length=450, blank=True)
groupes = models.ManyToManyField(Groupe, null = True, blank = True, through='ClientGroupe')
class ClientGroupe(models.Model):
client = models.ForeignKey(Client)
groupe = models.ForeignKey(Groupe)
dt = models.DateField(null=True, blank=True) # the date the client is using its group's free rental rate
class Meta:
db_table = u'clients_groupes'
</code></pre>
<h2>and here's my view:</h2>
<pre><code>def modifier(request, id):
client = Client.objects.get(id=id)
form = ClientForm(instance = client)
dict = {
"form": form
, "instance" : client
}
if request.method == "POST":
form = ClientForm(request.POST, instance = client)
if form.is_valid():
client_mod = form.save()
id = client_mod.id
return HttpResponseRedirect(
"/client/%(id)s/?err=success" % {"id" : id}
)
else:
return HttpResponseRedirect(
"/client/%(id)s/?err=warning" % {"id" : id}
)
return render_to_response(
"client/modifier.html"
, dict
, context_instance=RequestContext(request)
)
</code></pre>
<p><strong>EDIT</strong>:</p>
<p>and here's the ClientForm code:</p>
<pre><code>class ClientForm(ModelForm):
class Meta:
model = Client
</code></pre>
<p><strong>EDIT #2</strong>:
here's the error message:</p>
<pre><code>AttributeError at /client/445/
Cannot set values on a ManyToManyField which specifies an intermediary model. Use ClientGroupe's Manager instead.
Request Method: POST
Request URL: http://localhost/client/445/
Exception Type: AttributeError
Exception Value: Cannot set values on a ManyToManyField which specifies an intermediary model. Use ClientGroupe's Manager instead.
Exception Location: C:\Python25\lib\site-packages\django\db\models\fields\related.py in __set__, line 574
Python Executable: C:\xampp\apache\bin\apache.exe
Python Version: 2.5.2
</code></pre>
| [
{
"answer_id": 478384,
"author": "Vladimir Prudnikov",
"author_id": 29364,
"author_profile": "https://Stackoverflow.com/users/29364",
"pm_score": 0,
"selected": false,
"text": "clientgroupe = ClientGroupe.objects.create(client=client_instance, groupe=groupe_instance, dt=datetime.datetime... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48500/"
] |
387,702 | <p>Here's a scenario. You have a large amount of legacy scripts, all using a common library. Said scripts use the 'print' statement for diagnostic output. No changes are allowed to the scripts - they range far and wide, have their approvals, and have long since left the fruitful valleys of oversight and control.</p>
<p>Now a new need has arrived: logging must now be added to the library. This must be done automatically and transparently, without users of the standard library needing to change their scripts. Common library methods can simply have logging calls added to them; that's the easy part. The hard part lies in the fact that diagnostic output from these scripts were always displayed using the 'print' statement. This diagnostic output must be stored, but just as importantly, processed. </p>
<p>As an example of this processing, the library should only record the printed lines that contain the words 'warning', 'error', 'notice', or 'attention'. The below Extremely Trivial and Contrived Example Code (tm) would record some of said output:</p>
<pre><code>sub CheckPrintOutput
{
my @output = @_; # args passed to print eventually find their way here.
foreach my $value (@output) {
Log->log($value) if $value =~ /warning|error|notice|attention/i;
}
}
</code></pre>
<p>(I'd like to avoid such issues as 'what should actually be logged', 'print shouldn't be used for diagnostics', 'perl sucks', or 'this example has the flaws x y and z'...this is greatly simplified for brevity and clarity. )</p>
<p>The basic problem comes down to capturing and processing data passed to print (or any perl builtin, along those lines of reasoning). Is it possible? Is there any way to do it cleanly? Are there any logging modules that have hooks to let you do it? Or is it something that should be avoided like the plague, and I should give up on ever capturing and processing the printed output?</p>
<p>Additional: This must run cross-platform - windows and *nix alike. The process of running the scripts must remain the same, as must the output from the script.</p>
<p>Additional additional: An interesting suggestion made in the comments of codelogic's answer:</p>
<blockquote>
<p>You can subclass <a href="http://perldoc.perl.org/IO/Handle.html" rel="noreferrer">http://perldoc.perl.org/IO/Handle.html</a> and create your
own file handle which will do the logging work. – Kamil Kisiel</p>
</blockquote>
<p>This might do it, with two caveats:</p>
<p>1) I'd need a way to export this functionality to anyone who uses the common library. It would have to apply automatically to STDOUT and probably STDERR too.</p>
<p>2) <a href="http://perldoc.perl.org/IO/Handle.html" rel="noreferrer">the IO::Handle</a> documentation says that you can't subclass it, and my attempts so far have been fruitless. Is there anything special needed to make sublclassing IO::Handle work? The standard 'use base 'IO::Handle' and then overriding the new/print methods seem to do nothing.</p>
<p>Final edit: Looks like IO::Handle is a dead end, but Tie::Handle may do it. Thanks for all the suggestions; they're all really good. I'm going to give the Tie::Handle route a try. If it causes problems I'll be back!</p>
<p>Addendum: Note that after working with this a bit, I found that Tie::Handle will work, if you don't do anything tricky. If you use any of the features of IO::Handle with your tied STDOUT or STDERR, it's basically a crapshoot to get them working reliably - I could not find a way to get the autoflush method of IO::Handle to work on my tied handle. If I enabled autoflush before I tied the handle it would work. If that works for you, the Tie::Handle route may be acceptable.</p>
| [
{
"answer_id": 387767,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 3,
"selected": false,
"text": "open my $fh, \">log.txt\";\nprint \"test1\\n\";\nmy $current_fh = select $fh;\nprint \"test2\\n\";\nselect $current_fh;\... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18097/"
] |
387,707 | <p>I prefer to use OOP in large scale projects like the one I'm working on right now. I need to create several classes in JavaScript but, if I'm not mistaken, there are at least a couple of ways to go about doing that. What would be the syntax and why would it be done in that way?</p>
<p>I would like to avoid using third-party libraries - at least at first.<br>
Looking for other answers, I found the article <em><a href="http://www.webreference.com/js/column79/" rel="noreferrer">Object-Oriented Programming with JavaScript, Part I: Inheritance - Doc JavaScript</a></em> that discusses object-oriented programming in JavaScript. Is there a better way to do inheritance? </p>
| [
{
"answer_id": 387733,
"author": "Kenan Banks",
"author_id": 43089,
"author_profile": "https://Stackoverflow.com/users/43089",
"pm_score": 11,
"selected": true,
"text": "// Define a class like this\nfunction Person(name, gender){\n\n // Add object properties like this\n this.name = n... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387707",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2494/"
] |
387,713 | <p>Java (and maybe the underlying C-ish code) has max capacity of Integer.MAX_VALUE (~ 2 billion) for arrays and containers in java.util. Are there other languages that feature containers with larger capacities?</p>
| [
{
"answer_id": 387718,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 2,
"selected": false,
"text": "long"
}
] | 2008/12/22 | [
"https://Stackoverflow.com/questions/387713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
387,736 | <p>Consider the following:</p>
<pre><code><div onclick="alert('you clicked the header')" class="header">
<span onclick="alert('you clicked inside the header');">something inside the header</span>
</div>
</code></pre>
<p>How can I make it so that when the user clicks the span, it does not fire the <code>div</code>'s click event?</p>
| [
{
"answer_id": 387750,
"author": "James",
"author_id": 21677,
"author_profile": "https://Stackoverflow.com/users/21677",
"pm_score": 9,
"selected": true,
"text": "<span onclick=\"event.stopPropagation(); alert('you clicked inside the header');\">something inside the header</span>\n windo... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387736",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43005/"
] |
387,772 | <p>I can't find the answer to this anywhere, and before I start pawing through generated code with Reflector I thought it'd be worth asking:</p>
<p>Suppose I have the following LINQ query run against DataTables in a DataSet:</p>
<pre><code>var list =
from pr in parentTable.AsEnumerable()
join cr in childTable.AsEnumerable() on cr.Field<int>("ParentID") equals pr.Field<int>("ID")
where pr.Field<string>("Value") == "foo"
select cr;
</code></pre>
<p>If there's a DataRelation between the parent table and the child table that uses the key fields shown, will LINQ use it? That is, will it find the rows in the parent table for which Value is "foo" and then call <code>GetChildRows</code> to project the child rows? </p>
<p>Or is this something that I have to specify explicitly? (And if so, how do I do this?)</p>
| [
{
"answer_id": 388620,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": true,
"text": "DataRelation"
},
{
"answer_id": 389938,
"author": "Robert Rossney",
"author_id": 19403,
"author_pr... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19403/"
] |
387,775 | <p>Why doesn't the following work?</p>
<pre><code>(apply and (list #t #t #f))
</code></pre>
<p>While the following works just fine.</p>
<pre><code>(apply + (list 1 3 2))
</code></pre>
<p>This seems to be the case in both R5RS and R6RS?</p>
| [
{
"answer_id": 387805,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 5,
"selected": true,
"text": "and and and"
},
{
"answer_id": 387868,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "h... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1925263/"
] |
387,783 | <p>I'm trying to get my head around DI/IoC, NHibernate and getting them to work nicely together for an application that i'm developing. I'm quite new to both NHibernate and DI/IoC so not quite sure whether what i'm doing is the sensible way to be going about it. This is the scenario:</p>
<p>The application provides users with the ability to calculate a particular value (known as the margin) for a particular financial transaction. The calculation of the marging value for each transaction is carried out by concrete implementations of an abstract MarginCalculator class and the concrete implementation to be used depends on the type of the product for the particular transaction (given by a certain field of the product object). The concrete calculator class is accessed via a property on the product class. i.e.</p>
<pre><code>public class Transaction
{
private double _margin;
private Product _product;
private Client _client;
public double Margin { get; }
public Product Product { get; }
public Client Client { get; }
public Transaction(Product p, Client c)
{
_product = p;
_client = c;
}
public void CalculateMargin()
{
_margin = _product.MarginCalculator.CalculateMargin();
}
}
public class Product
{
private string _id;
private string _productType;
... Other fields
public string Id { get; }
public string ProductType { get; }
public MarginCalculator MarginCalculator
{
get { return MarginCalculatorAssembler.Instance.CreateMarginCalculatorFor(this.ProductType); }
}
}
public class MarginCalculatorAssembler
{
public static readonly MarginCalculatorAssembler Instance = new MarginCalculatorAssembler();
private MarginCalculatorAssembler ()
{
}
public MarginCalculator CreateMarginCalculatorFor(string productType)
{
switch (productType)
{
case "A":
return new ConcreteMarginCalculatorA();
case "B":
return new ConcreteMarginCalculatorB();
default:
throw new ArgumentException();
}
}
}
public abstract class MarginCalculator
{
public abstract double CalculateMargin();
}
public class ConcreteMarginCalculatorA : MarginCalculator
{
public override double CalculateMargin
{
// Perform actual calculation
}
}
public class ConcreteMarginCalculatorB : MarginCalculator
{
public override double CalculateMargin
{
// Perform actual calculation
}
}
</code></pre>
<p>Users select a particular client and Product from dropdowns and the corresponding clientId and productId are passed to repositories that then use NHibernate to populate product and client objects before they're injected into the transaction object. In my current setup the Transaction receives its Product and Client dependencies via constructor dependency injection (no IoC container used as yet) i.e.</p>
<pre><code>public class ProductRepository : IRepository<Product>
{
public Product GetById(string id)
{
using (ISession session = NHibernateHelper.OpenSession())
return session.Get<Product>(id);
}
}
/* Similar repository for Clients */
IRepository<Client> clientRepository = new ClientRepository();
IRepository<Product> productRepository = new ProductRepository();
Client c = clientRepository.GetById(clientId);
Product p = productRepository.GetById(productId);
Transaction t = new Transaction(p, c);
</code></pre>
<p>The following are what i'm hoping to get ideas on:</p>
<p><strong>A.</strong> <strong><em>Is it considered OK to be accessing the MarginCalculator (which is essentially a service) through the Product domain object or should, as suggested here, (<a href="http://www.lostechies.com/blogs/jimmy_bogard/archive/2008/03/31/ptom-the-dependency-inversion-principle.aspx" rel="nofollow noreferrer">http://stackoverflow.com/questions/340461/dependency-injection-with-nhibernate-objects</a>) the code be restructured so as to remove service dependencies from the domain objects and instead create a new TransactionProcessor class that takes the abstract MarginCalculator as a dependency (along the lines of what's described here (<a href="http://www.lostechies.com/blogs/jimmy_bogard/archive/2008/03/31/ptom-the-dependency-inversion-principle.aspx" rel="nofollow noreferrer">http://www.lostechies.com/blogs/jimmy_bogard/archive/2008/03/31/ptom-the-dependency-inversion-principle.aspx</a>) i.e.</em></strong></p>
<pre><code>public class TransactionProcessor
{
private readonly MarginCalculator _marginCalculator;
public TransactionProcessor(MarginCalculator marginCalculator)
{
_marginCalculator = marginCalculator;
}
public double CalculateMargin(Transaction t)
{
return _marginCalculator.CalculateMargin(Transaction t);
}
}
public abstract class MarginCalculator
{
public abstract double CalculateMargin(Transaction t);
}
</code></pre>
<p><strong>B.</strong> <strong><em>Is it possible to use an IoC Container to get a Transaction object with NHibernate populated/generated Product and Client dependencies injected?</em></strong> i.e. Given a productId and clientId, both provided by the user, is it possible to have something like:</p>
<pre><code>// pseudocode
Transaction t = IoC.Resolve<Transaction>(productId, clientId);
</code></pre>
<p>such that the container resolves the Product and Client dependencies of the Transaction object, NHibernate is utilised to populate the Product and Client based on the productId and clientId and then the populated Product and Client are injected into the Transaction?</p>
<p><strong>C.</strong> In a typical DI scenario, if class A has a dependency on interface B then the following might be done:</p>
<pre><code>IInterfaceB b = new ClassB();
A a = new A(b);
interface IInterfaceB
{
}
class B : IInterfaceB
{
}
public class A
{
private IIntefaceB _b;
public A(IInterfaceB b)
{
_b = b;
}
}
</code></pre>
<p>However, this, which is virtually how all examples of DI are shown, assumes that the implementor of IInterfaceB (in this case Class B) is known at design time. <strong><em>Is there a way to use DI in such a way that the implementor is determined at runtime?</em></strong></p>
<p>Many thanks</p>
<p>Matthew</p>
| [
{
"answer_id": 389382,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "public abstract class MarginCalculator\n{\n public abstract double CalculateMargin();\n}\n public class ConcreteMarginCalcu... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.