instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>We have a service that has some settings that are supported only over net.tcp. What's the best way to add another endpoint? Do I need to create an entire new host?</p>
<p>A service may have multiple endpoints within a single host, but every endpoint must have a unique combination of address, binding and contract. For an IIS-hosted service (that is, an .SVC file), just set the address of the endpoint to a <strong>relative</strong> URI and make sure that your Visual Studio or wsdl.exe ...
<p>You will need to create an entire new host if you are currently using IIS as your host - IIS only supports HTTP and not TCP bindings. If however you are using WAS or a windows service, then you'll be able to get away with simply creating a new net.tcp endpoint.</p>
6,836
<p>I was writing a (seemingly) straight-forward SQL snippet that drops a column after it makes sure the column exists.<br> The problem: if the column does NOT exist, the code <em>inside</em> the IF clause complains that it can't find the column! Well, <em>doh</em>, that's why it's inside the IF clause!<br> So my questi...
<pre><code>IF exists (select * from syscolumns WHERE id=object_id('Table_MD') and name='timeout') BEGIN DECLARE @SQL nvarchar(1000) SET @SQL = N'ALTER TABLE [dbo].[Table_MD] DROP COLUMN timeout' EXEC sp_executesql @SQL END GO </code></pre> <p>Reason: When Sql server compiles the code, they check it for...
<p>It may never be executed, but it's parsed for validity by Sql Server. The only way to "get around" this is to construct a block of dynamic sql and then selectively execute it</p>
14,717
<p>I'm trying to animate a block level element using jQuery. The page loads with the element styled with <code>display: none</code>. Id like it to <code>slideDown</code> whilst transparent and then <code>fadeIn</code> the content using the callback, however <code>slideDown</code> appears to set the visibility to full b...
<p>a few probable issues with your code: are you setting the content to hide as well in the beginning? are you calling <code>fadeIn</code> during the <code>slideDown</code> callback?</p> <p>here's some example HTML/code that will <code>fadeIn</code> after the <code>slideDown</code></p> <pre><code>$('div').hide(); // ...
<p>How about:</p> <pre><code>$('#hiddenElement').css("opacity", 0).slideDown().animate({opacity:1}) </code></pre>
44,532
<p>I need to perform a HTTP GET from PHP. </p> <p>More specifically, from within /index.php I need to get the content of /trac/ and /svn/, find the "ul" element and then render then inline on the index.php.</p> <p>/trac and /svn are relative URLs and not filesystem folders. <a href="http://myserver/trac" rel="nofollo...
<p>The simplest way is <a href="http://www.php.net/file_get_contents" rel="noreferrer"><code>file_get_contents()</code></a>.</p> <pre><code>$str = file_get_contents('http://myserver/svn/'); // Or, if you don't want to hardcode the server $str = file_get_contents('http://' . $_SERVER['HTTP_HOST'] . '/svn/'); if ($str...
<p>Have a look at <a href="http://it.php.net/function.file-get-contents" rel="nofollow noreferrer">file_get_contents</a> - it can be used to open urls under some conditions as can some of the other <a href="http://it.php.net/manual/en/ref.filesystem.php" rel="nofollow noreferrer">filesystem functions</a>:</p> <blockqu...
38,711
<p>We've got products built both with GUI and CHUI. Going forward, we're looking at redesigning a lot of our software and mainly taking the route of going all GUI. My question to the group is, do we need to account for keeping a CHUI around? What are the advantages of CHUI over GUI? Many times in the past people have s...
<p>The primary benefits of a CHUI (that is something with forms and fields, not necessarily command line interfaces) is the keyboard for navigation and consistent layout. That is key.</p> <p>If your GUI can be completely, and efficiently, keyboard navigated, then your CHUI user base should be happy. This is because in...
<p>As soon as you present some data, someone's going to want to query against it. You can integrate that with a gui, no problem. If you think some of your customers are going to want to script certain tasks. set it up. Anything to do with automation is better done from the command line(y harlo thar cron job!)</p> <p>I...
31,618
<p>I have a file saved as UCS-2 Little Endian I want to change the encoding so I ran the following code:</p> <pre><code>cat tmp.log -encoding UTF8 &gt; new.log </code></pre> <p>The resulting file is still in UCS-2 Little Endian. Is this because the pipeline is always in that format? Is there an easy way to pipe this...
<p>As suggested <a href="https://stackoverflow.com/questions/64860/best-way-to-convert-text-files-between-character-sets#64937">here</a>:</p> <pre><code>Get-Content tmp.log | Out-File -Encoding UTF8 new.log </code></pre>
<p>PowerShell's get-content/set-content encoding flag doesn't handle all encoding types. You may need to use IO.File, for example to load a file using Windows-1252:</p> <pre><code>$myString = [IO.File]::ReadAllText($filePath, [Text.Encoding]::GetEncoding(1252)) </code></pre> <p><a href="https://learn.microsoft.com/en-...
10,211
<p>In my project I need to connect to an intra-net web service but we need SSL connection between the two machines. Because this is an intra-net site the certificate of the web service might be a self-signed certificate. The web service and the web page that loads my Flex application resides on the same web server (tom...
<p>When I put on my security hat the answer would be I hope not. I don't want browser plugins to bypass my browser security settings. I'd consider that a vulnerability.</p> <p>There might be a way for standalone Air applications, but in browser Flash should honor browser settings.</p>
<p>In your company, you could create your own root CA, add its certificate to all machines that will access the intranet, and then have the CA issue your web service a certificate. The certificate will no longer be self-signed. The two main issues are: (1) managing the private key of your CA, (2) distributing the CA's ...
23,719
<p>I have a template class like below.</p> <pre><code>template&lt;int S&gt; class A { private: char string[S]; public: A() { for(int i =0; i&lt;S; i++) { . . } } int MaxLength() { return S; } }; </code></pre> <p>If i instantiate the above class with different values of S, w...
<p>The template will be instantiated for each different values of S.</p> <p>If you move the method implementations to a different file, you'll need to #include that file. (Boost for instance uses the <code>.ipp</code> convention for such source files that need to be #included).</p> <p>If you want to minimise the amou...
<p>It will create two different versions of <code>A()</code> and <code>MaxLength()</code> that will return compile-time constants. The simple <code>return S;</code> will be compiled efficiently and even inlined where possible.</p>
45,379
<p>I am looking to distribute an open source iPhone app and I have a few questions about making the source distribution:</p> <ol> <li><p>How can I automate creating the source archive (or diskimage) with XCode? I want something along the lines of a build target which archives the source (cleaning targets first if nece...
<p>You can add a Run Script Build Phase to any target to do postprocessing of the build. The right approach is usually to create an Aggregate Target that first builds your build product target, then runs the script on the output. </p> <p>It's hard to identify all the "source" files. It's often everything in $(SRCRO...
<p>Well, I've had no answers on this so far so I'm going to approach it from the other direction, using make and the command line. I'm going to use the answer to this question:</p> <p><a href="https://stackoverflow.com/questions/377992/building-xcode-projects-from-the-command-line">Building Qt Xcode Projects From the ...
49,220
<p>Here is the basic situation.</p> <pre><code>Public Class MyEnumClass(of T) Public MyValue as T End Class </code></pre> <p>This is vast oversimplification of the actual class, but basically I know that T is an enumeration (if it is not then there will be many other problems, and is a logical error made by the pr...
<p>I was going to use a cool piece of reflection code but just a simple <a href="https://msdn.microsoft.com/en-us/library/system.convert.toint32(v=vs.110).aspx" rel="noreferrer"><code>Convert.ToInt32</code></a> works great... Forgive my VB I'm a C# guy</p> <pre><code>Public Function GetEnumInt(Of T)(enumVal As T) As ...
<p>Thanks to 'Jon Skeet'. But his code does not work in my Excel-2016. Minwhile the next code works fine:</p> <pre><code>Public Enum TypOfProtectWs pws_NotFound = 0 pws_AllowAll = 1 pws_AllowFormat = 2 pws_AllowNone = 3 End Enum Private Function TypOfProtectWs2I(pws As TypOfProtectWs) As Integer T...
49,621
<p>I've been asked to prepare a 3D model for 3D printing in sandstone. I've been told that it needs to be 3" tall and the walls have to be at least 2&nbsp;mm thick. It's an absolute pain in the neck having to make sure everything is the right thickness. So, I was wondering, can the whole model just be printed as a soli...
<p>Yes, you can just print it solid. However, it might be significantly more expensive to print your object entirely solid. For instance, Shapeways charges \$0.75 per cm³ of material for their full-color sandstone. A solid cube of 5x5x5 cm would cost \$96 to print, whereas it would only cost around \$6 if you printed i...
<p>To add to the selected answer, again, yes you can, however making all of the walls AT LEAST 2mm thick shouldn't be too hard, depending on your model and modelling app.</p> <p>If your modelling app doesn't have a good shell function (or if it's too finicky on your model) you could easily define SOME negative space w...
249
<p>I have a C# form into which I've placed a left-docked <code>MenuStrip</code>. This <code>MenuStrip</code> contains some menu items which contain submenus, and some menu items which are effectively buttons (clicking on them results in an action taking place; n.b., I realize this is not a good design).</p> <p>I woul...
<p>Why do you not look into using a System.Windows.Forms.ToolStrip rather than a MenuStrip. This will allow you to have the arrow functionality build in and will even solve the bad desing problem you are having.</p> <p>Should you want you can specify that the toolstrip items do not show images and only show text. In t...
<p>I was able to hack this together as a solution, but I'd still like something less obtuse:</p> <pre><code>protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) { base.OnRenderItemText(e); if (e.Item.GetType() == typeof(ToolStripMenuItem)) { ToolStripMenuItem tsmi = (ToolStr...
21,571
<p>Does anyone know any good tutorial about using NAnt for native code build process instructions?</p> <hr> <p>Is there any other tool for build process automation that is better suitable with native code environment?</p> <hr> <p>We are developing a win32 mobile application and it will be available online for downl...
<p>We tried a while ago to use NAnt to build a large VC++ (VS2005) project ... it didn't work. </p> <p>The problem was there is no way of capturing the dependencies outside of Visual Studio. Ie. which cpp files should be rebuilt when a given header file is modified.</p> <p>We could create nant tasks that threw all ...
<p>The thing with NAnt is that it can be made to do anything you want. Since I don't have the full details of what you're trying to do I can only go off of what we've used it for.</p> <p>We currently have many different systems that are hooked into the automated build. You mention <strong>native</strong> development ...
26,132
<p>While I don't think this is easily possible I am wondering if it can be done. So my spool of filament had a tangle and got pulled into the printer head. Some got melted together and after cutting I have a few strands. Would it be possible to mend the ends together to make one continuous strand instead of many small ...
<p>Sure, but you need to be careful not to have wide or narrow spots. A fixture for this is probably better than freehand welding.</p> <p>See some ideas for a homemade fuser at <a href="https://rigid.ink/blogs/news/how-to-join-or-fuse-filament-together" rel="nofollow noreferrer">https://rigid.ink/blogs/news/how-to-joi...
<p>As @davo says in his answer, this can be done rather easily, but the main problem with this kind of approach is reliability of the joint: sure, it must last only a short time, but during that time it will have to survive bending through your bowden tube (if applicable) and withstanding the grinding of the hobbed gea...
825
<p>Any list of Testing frameworks for ActionScript 2.0/3.0 around there?</p>
<p>FlexUnit is the "official" unit testing framework. It's owned by Adobe's Research guys I believe.</p> <p><a href="http://labs.adobe.com/wiki/index.php/ActionScript_3:resources:apis:libraries" rel="nofollow noreferrer">http://labs.adobe.com/wiki/index.php/ActionScript_3:resources:apis:libraries</a></p> <p>Here's a ...
<p>Try <a href="http://www.libspark.org/wiki/yossy/AS3Unit/en/index" rel="nofollow noreferrer">AS3Unit</a> from libspark. They also have an async beta test kit. </p>
42,934
<p>Today is officially my first day with C++ :P</p> <p>I've downloaded Visual C++ 2005 Express Edition and Microsoft Platform SDK for Windows Server 2003 SP1, because I want to get my hands on the open source <a href="http://code.google.com/p/enso" rel="nofollow noreferrer">Enso Project</a>. </p> <p>So, after install...
<p>Using the above recommendations will not work with scons: scons does not import the user environment (PATH and other variables). The fundamental problem is that scons does not handle recent versions of SDKs/VS .</p> <p>I am an occasional contributor to scons, and am working on this feature ATM. Hopefully, it will b...
<p>You show us how you configured Visual Studio for compilations within Visual Studio but you didn't show us what command line environment you tried. Sorry I haven't tried Express versions so I don't know if they create additional Start menu shortcuts like Pro and above do. If you open a suitable command prompt with ...
25,915
<p>Is anyone using Virtual PC to maintain multiple large .NET 1.1 and 2.0 websites? Are there any lessons learned? I used Virtual PC recently with a small WinForms app and it worked great, but then everything works great with WinForms. ASP.NET development hogs way more resources, requires IIS to be running, requires...
<p>I've used VirtualPCs for a few years for development of some fairly hefty web apps without much problem. Lots of RAM is important. I keep my VPCs on an external USB drive and they perform great from there. This gives me the flexibility to take the drive with me if I need to do work somewhere else... just install...
<p>As long as you have the resources (separate hard disk for the virtual machine, sufficient RAM), I don't see why you would have any problems.</p>
5,119
<p>I'm doing a Python script where I need to spawn several ssh-copy-id processes, and they need for me to type in a password, so i'm using PExpect.</p> <p>I have basically this:</p> <pre><code>child = pexpect.spawn('command') child.expect('password:') child.sendline('the password') </code></pre> <p>and then I want t...
<p>Fortunately or not, but OpenSSH client seems to be very picky about passwords and where they come from.</p> <p>You may try using <a href="http://www.lag.net/paramiko/" rel="nofollow noreferrer">Paramiko</a> Python SSH2 library. Here's a simple <a href="http://www.lag.net/pipermail/paramiko/2006-January/000180.html"...
<p>Reading <a href="http://pexpect.sourceforge.net/pexpect.html#spawn" rel="nofollow noreferrer">pexpect documentation for spawn</a>, I think it is waiting for the command to terminate.</p> <p>I would suggest a couple of different possibilities, depending on your needs:</p> <p>1) Kill the spawned process. However, th...
46,530
<p>I am using wordpress and use custom permalink structure: /%category%/%postname%/</p> <p>My problem is that a decent number of people link to the site without including the trailing slash in the URL, so users get a 404 page.</p> <p>I'm using the default .htaccess file that comes with wordpress because no solution I...
<p>A very good reference for all things .htaccess is PerishablePress.com</p> <p><a href="http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/" rel="nofollow noreferrer">http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/</a></p>
<p>Use:</p> <pre><code>/%category%/%postname%(/?) </code></pre> <p>in your .htaccess file.</p> <p>The question mark denotes an optional character sequence.</p>
24,618
<p>I have a question similar to the one here: <a href="https://stackoverflow.com/questions/341723/event-handlers-inside-a-javascript-loop-need-a-closure#341759">Event handlers inside a Javascript loop - need a closure?</a> but I'm using jQuery and the solution given seems to fire the event when it's bound rather than o...
<p>You're missing a function. The .click function needs a function as a parameter so you need to do this:</p> <pre><code>.click( function(indGroup,indValue) { return function() { jQuery(".IndicatorImage").removeClass("active"); _this.Indicator.TrueImage = DisplayGlobals...
<p><strong>Nikita</strong>'s answer works fine as long as you are using jQuery 1.4.3 and later. For versions previous to this (back to 1.0) you will have to use <strong><a href="http://api.jquery.com/bind/" rel="noreferrer">bind</a></strong> as follows:</p> <pre><code>.bind('click', {indGroup: i, indValue : j}, funct...
46,891
<p>Does anyone know how to initiate a POST request in a Grails applications using javascript. Specifically, I would like to be able to POST when a the selected item in a drop-down box is changed.</p> <p>I've tried using jQuery and the $.post() method. It successfully calls my controller action, but I'm not sure how t...
<p>Find the form object in the DOM you are looking for and cal .submit() on it. Do you have more than one form or multiples on your page?</p>
<p>You mention it is calling your controller action so it is getting information back to the page that is the issue, right?</p> <p>Try something like this:</p> <pre><code> def ajaxRandom = { def randomQuote = quoteService.getRandomQuote() response.outputStream &lt;&lt; "&lt;q&gt;${randomQuote.conte...
26,299
<p>I have balls bouncing around and each time they collide their speed vector is reduced by the Coefficient of Restitution.</p> <p>Right now my balls CoR for my balls is .80 . So after many bounces my balls have "stopped" rolling because their speed has becoming some ridiculously small number. </p> <p>In what stage ...
<p>A reasonable value for epsilon is going to depend on the constraints of your system. If you are representing the ball graphically, then your epsilon might correspond to, say, a velocity of .1 pixels a second (ensuring that your notion of stopping matches the user's experience of the screen objects stopping). If yo...
<p>IMO your epsilon approach is fine. I would just experiment to see what looks or feels natural to the animation in the game. </p>
46,208
<p>Currently I am designing a website and I am finding it VERY difficult to display the website perfect on ALL browsers. </p> <p>Is there any rules, suggestions etc to follow?</p> <p>Thanks</p>
<p>It is practically impossible to get a website to look exactly the same on all browsers and platforms. Number one reason is that fonts are rendered differently on Windows, Mac, Linux, Solaris, etc.</p> <p>There is a new thought we follow: Websites do not have to look exactly the same on different browsers and platf...
<p>Using strict doctype, valid xhtml/html and valid CSS are good starting points. Also, make sure you use reset/undo.css.</p> <p>In spite of all these, there would be catches but very few though</p>
49,211
<p>I'm trying to use GDB to debug (to find an annoying segfault). When I run:</p> <pre><code>gdb ./filename </code></pre> <p>from the command line, I get the following error:</p> <pre><code>This GDB was configured as "i686-pc-linux- gnu"..."/path/exec": not in executable format: File format not recognized </code><...
<p>The executable is 64-bit (x86-64) and the debugger is a 32 bit (i686-pc-linux) build. You may need to install a 64-bit (x86-64) version of the debugger.</p>
<p>It seems your GNU Debugger (<code>gdb</code>) doesn't support x86_64 architecture.</p> <p>So try <a href="https://en.wikipedia.org/wiki/LLDB_(debugger)" rel="nofollow">LLDB Debugger</a> (<code>lldb</code>) which aims to replace it. It supports i386, x86-64 and ARM instruction sets.</p> <p>It's available by default...
34,721
<p>I can't find much information on <code>const_cast</code>. The only info I could find (on Stack Overflow) is:</p> <blockquote> <p>The <code>const_cast&lt;&gt;()</code> is used to add/remove const(ness) (or volatile-ness) of a variable.</p> </blockquote> <p>This makes me nervous. Could using a <code>const_cast</...
<p><code>const_cast</code> is safe only if you're casting a variable that was originally non-<code>const</code>. For example, if you have a function that takes a parameter of a <code>const char *</code>, and you pass in a modifiable <code>char *</code>, it's safe to <code>const_cast</code> that parameter back to a <co...
<p>You're destroying any chance at thread-safety, if you start modifying things that the compiler thought were const.</p>
46,630
<p>I have a table that looks a bit like this actors(forename, surname, stage_name);</p> <p>I want to update stage_name to have a default value of</p> <pre><code>forename." ".surname </code></pre> <p>So that</p> <pre><code>insert into actors(forename, surname) values ('Stack', 'Overflow'); </code></pre> <p>would pr...
<p>MySQL does not support computed columns or expressions in the <code>DEFAULT</code> option of a column definition.</p> <p>You can do this in a trigger (MySQL 5.0 or greater required):</p> <pre><code>CREATE TRIGGER format_stage_name BEFORE INSERT ON actors FOR EACH ROW BEGIN SET NEW.stage_name = CONCAT(NEW.forena...
<p>As of <a href="https://dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html#data-type-defaults-explicit" rel="nofollow noreferrer">MySQL 8.0.13</a>, you can use DEFAULT clause for a column which can be a literal constant or an expression.</p> <p>If you want to use an expression then, simply enclose the required e...
47,046
<p>When I plug my HP Laserjet 3015, Windows detects the correct model and then tries to install the appropriate drivers.</p> <p>How can I detect the model of connected printer(s)? I don't want to use the list of installed printers because a Zebra printer can be installed with a Generic/Text only driver.</p> <p>I'm a ...
<p>You can send a</p> <pre><code>~HI </code></pre> <p>to the Zebra printer and it should return its model number and also fw version</p>
<p>Recently I made a little demo with this. Just put a <code>TComboBox</code> and a <code>TMemo</code> on a Form and replace the code with this:</p> <pre><code>unit Unit1; interface uses Windows, StdCtrls, Classes, Controls, Forms; type TForm1 = class(TForm) ComboBox1: TComboBox; Memo1: TMemo; proce...
25,572
<p>I have a large number of 2D points and I want to quickly get those that lie in a certain rectangle. Let's say a '.' is any point and 'X' is a point I want to find inside a rectangle which has 'T' as TopLeft and 'B' as BottomRight points:</p> <pre><code>. . . . . . . T-----+ . . | X X | . . +-----B . . . . . . . </c...
<p>You could store the points in a spatial index using quad or r-trees. Then given the rectangle you could find all the nodes of the tree that overlap it, you would then have to compare each point in this subset to see if it falls in the rectangle.</p> <p>In essence, the spatial tree helps you prune the search space....
<p>Your sort function could check points as they are added for inside-the-rectangle-ness, and sort all points inside the rectangle before all points outside the rectangle. You would have to keep track of how many of each exist, or use a binary search on the entire set to find the cutoff point at lookup time.</p>
38,959
<p>i'm currently doing some reports for SSRS, and i just confirm what i already knew, i suck at this thing of color matching and making things look pretty.</p> <p>Does anyone know a good site or something to help me figure out how a report should look. I need help! any website or recommendations would be highly apprec...
<p>Best option: don't use colour unless you have a specific need for it. Many years ago I worked as a typesetter for a while in the jobbing commercial print industry. Most of the clients did not want to pay for a colour print job due to the set-up costs, so the jobs tended to be black and white or two spot colours.</...
<p>I always use the default dark blue/light blue color scheme that comes when you use the report create wizard.</p> <p>I've been using it for reports for over a year and have never gotten a complaint.</p>
38,380
<p>Anyone using MozyPro to backup SQL Server databases?</p> <p>I'm concerned about the way it does the backup. It just copies data files the way they are. Not using the backup database command.</p> <p>Is it safe?</p>
<p>MozyPro uses the Volume Shadow Service (VSS) to create backups for SQL Server. SQL Server 2005 has been engineered so that VSS backups are consistent. So this is definitely a valid way to back up SQL Server databases.</p> <p><a href="http://www.microsoft.com/technet/prodtechnol/sql/2005/sqlwriter.mspx" rel="nofol...
<p><a href="https://github.com/candera/hobocopy" rel="nofollow">https://github.com/candera/hobocopy</a></p> <blockquote> <p>WHY DOES HOBCOPY USE THE VOLUME SHADOW SERVICE?</p> <p>Because HoboCopy copies from a VSS snapshot, it is able copy even files that are in locked by some other program. Further, certain ...
34,302
<p>What is the purpose of this Rails config setting...</p> <pre><code>config.action_controller.consider_all_requests_local = true </code></pre> <p>It's set to true by default in <code>config/environments/development.rb</code>.</p> <p>Thanks,</p> <p>Ethan</p>
<p>Non-local requests result in user-friendly error pages. Local requests, assumed to come from developers, see a more useful error message that includes line numbers and a backtrace. <code>consider_all_requests_local</code> allows your app to display these developer-friendly messages even when the machine making the...
<p>At development level we set:</p> <blockquote> <p>consider_all_requests_local set = true</p> </blockquote> <p>because developer needs to take a look at full error showing layout/view as you can see in the image below.</p> <p><a href="https://i.stack.imgur.com/s9U2y.png" rel="noreferrer"><img src="https://i.stack...
48,786
<p>How can I create an instance of the Java console inside of a GUI panel?</p>
<p>Here's a functioning class. You can install an instance of this into the system out and err using:</p> <pre><code>PrintStream con=new PrintStream(new TextAreaOutputStream(...)); System.setOut(con); System.setErr(con); </code></pre> <p><strong>Updated 2014-02-19</strong>: To use EventQueue.invokeLater() to avoid GUI...
<p>I recently use the <a href="https://stackoverflow.com/a/343007/363573">excellent code</a> provided by <a href="https://stackoverflow.com/a/343007/363573">Lawrence Dol</a> in one of my project.</p> <p>However, in my case the code consumed too many memory. I managed to reduce drastically the memory comsuption by repla...
44,591
<p>I am debugging some code in the Selenium-rc proxy server. It seems the culprit is the <code>HttpURLConnection</code> object, whose interface for getting at the HTTP headers does not cope with duplicate header names, such as:</p> <pre><code>Set-Cookie: foo=foo; Path=/ Set-Cookie: bar=bar; Path=/ </code></pre> <p>Th...
<p>My recommended workaround is to not use HttpUtilConnection at all, which is crude and unintuitive, but use commons-httpclient instead. </p> <p><a href="http://hc.apache.org/httpclient-3.x/" rel="nofollow noreferrer">http://hc.apache.org/httpclient-3.x/</a> </p>
<p>Without actually having tried it (can't remember to have handled that topic myself), there's also getHeaderFields, inherited from <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/net/URLConnection.html#getHeaderFields()" rel="nofollow noreferrer">UrlConnection</a>. Does this do what you need?</p>
18,936
<p>What does Mozilla Firefox's XPCSafeJSObject wrapper actually do?</p> <p><a href="https://developer.mozilla.org/en/XPConnect_wrappers#XPCSafeJSObjectWrapper" rel="nofollow noreferrer">MDC</a>'s documentation is as follows:</p> <blockquote> <p>This wrapper was created to address some problems with XPCNativeWrapper...
<p>The purpose of the wrappers in general is to protect Privileged code when interacting with unprivileged code. The author of the unprivileged code might redefine a JavaScript object to do something malicious, like redefine the getter of a property to execute something bad as a side effect. When the privileged code tr...
<p>The purpose of the wrappers in general is to protect Privileged code when interacting with unprivileged code. The author of the unprivileged code might redefine a JavaScript object to do something malicious, like redefine the getter of a property to execute something bad as a side effect. When the privileged code tr...
29,754
<p>Does anyone know if the AjaxHelper in the ASP.NET MVC framework deals with degradation?</p> <p>For example, if you have an ActionLink that updates the content of a div, if JavaScript unavailable, will the page do a full postback by renderubg the page (via an action on a controller) and call the action specified in ...
<p>One thing you could try is in your controller, override the OnActionExecuted method and change the filerContext.ActionResult for non-JavaScript enabled browsers. You can also add you own ActionFilters to different actions in the controller.</p>
<p>You can specify an <code>Url</code> parameter to the <code>AjaxOptions</code> object to the <code>Ajax.ActionLink</code> call:</p> <pre><code>@Ajax.ActionLink(role, "GetPeopleData", new { selectedRole = role }, new AjaxOptions { UpdateTargetId = "tbody", Url = Url.Action("GetPeopleData",...
42,231
<p>I am working on a project with peek performance requirements, so we need to bulk (batch?) several operations (for example persisting the data to a database) for efficiency.</p> <p>However, I want our code to maintain an easy to understand flow, like:</p> <pre><code>input = Read(); parsed = Parse(input); if (parsed...
<p>Common problem - instead of calling Persist I usually load up commands (or smt along those lines) into a Persistor class then after the loop is finished I call Persistor.Persist to persist the batch. </p> <p>Just a few pointers - If you're generating sql the commands you add to the persistor can represent your quer...
<p>I don't know if this is what you need, because it's sqlserver based, but have you tried taking a look to <a href="http://en.wikipedia.org/wiki/SQL_Server_Integration_Services" rel="nofollow noreferrer">SSIS</a> and or <a href="http://en.wikipedia.org/wiki/Data_Transformation_Services" rel="nofollow noreferrer">DTS</...
11,374
<p>I have a scenario where I need to upload a file from one web application and use it in another one. My setup is the following.</p> <ul> <li>One server, hosting two web applications in IIS - both are ASP.NET </li> <li>One of the applications is used to administer the other one + a bunch more stuff</li> <li>I need t...
<p>Since both applications are on the same server this should be straightforward:</p> <ul> <li>Save the uploaded file somewhere on the server.</li> <li>Create a virtual directory in any application needing to expose the files pointing to the physical path.</li> <li>Save the virtual path in the db for flexibility</li> ...
<p>Can I ask why you are not keeping the file in the DB? This would make passing it around much easier.</p>
17,874
<p>How do you expose a LINQ query as an ASMX web service? <br> Usually, from the business tier, I can return a typed <code>DataSet</code> or a <code>DataTable</code> which can be serialized for transport over ASMX.</p> <p>How can I do the same for a LINQ query? <br> Is there a way to populate a typed <code>DataSet</cod...
<p>As mentioned in the question, <code>IEnumerable</code> has a <code>CopyToDataTable</code> method:</p> <pre><code>IEnumerable&lt;DataRow&gt; query = from order in orders.AsEnumerable() where order.Field&lt;DateTime&gt;("OrderDate") &gt; new DateTime(2001, 8, 1) select order; // Create a table from the q...
<p>For the sake of completeness, these solutions do not work for EF Core (at least not for EF Core 2.2). Casting to <code>IEnumerable&lt;DataRow&gt;</code>, as suggested in the other answers here, fails. Implementing this class and extension methods worked for me <a href="https://learn.microsoft.com/en-us/dotnet/framew...
2,236
<p>There are times when I want to use <em>mootools</em> for certain things and Prototype &amp; <em><code>script.aculo.us</code></em> for others but within the same site. I've even considered adding others, but was concerned about conflicts. Anyone have experience, or am I just trying to make things too complicated fo...
<p>If you really, really want to do this, then you will be able to without too many problems - the main libraries are designed to behave well inside their own namespaces, with a couple of notable exceptions - from <a href="http://docs.jquery.com/Using_jQuery_with_Other_Libraries" rel="nofollow noreferrer">Using JQuery ...
<p>You are better off sticking with a single framework per application. Otherwise your client will spend too much time/bandwidth downloading the javascripts.</p> <p>That being said, Prototype and JQuery can work together. Information is on the JQuery web site.</p>
19,879
<p>I'm looking for an example algorithm of smart pagination. By smart, what I mean is that I only want to show, for example, 2 adjacent pages to the current page, so instead of ending up with a ridiculously long page list, I truncate it.</p> <p>Here's a quick example to make it clearer... this is what I have now:</p> ...
<p>Here is some code based on original code from <a href="https://www.strangerstudios.com/sandbox/pagination/diggstyle.php" rel="nofollow noreferrer">this very old link</a>. It uses markup compatible with Bootstrap's pagination component, and outputs page links like this:</p> <pre class="lang-none prettyprint-override"...
<p>I would use something simple on the page you are showing the paginator, like:</p> <pre><code>if ( $page_number == 1 || $page_number == $last_page || $page_number == $actual_page || $page_number == $actual_page+1 || $page_number == $actual_page+2 || $page_number == $actual_page-1 || $page_number == $actual_p...
19,805
<p>I'm trying to create an SSIS package that takes data from an XML data source and for each row inserts another row with some preset values. Any ideas? I'm thinking I could use a DataReader source to generate the preset values by doing the following:</p> <pre><code>SELECT 'foo' as 'attribute1', 'bar' as 'attribute2...
<p>I've never tried it, but it looks like you might be able to use a <a href="http://msdn.microsoft.com/en-us/library/ms141069(SQL.90).aspx" rel="nofollow noreferrer">Derived Column transformation</a> to do it: set the expression for attribute1 to <code>"foo"</code> and the expression for attribute2 to <code>"bar"</cod...
<p>I would probably switch to using a Script Task and place your logic in there. You may still be able leverage the File Reading and other objects in SSIS to save some code.</p>
7,407
<p>Which of these pieces of code is faster?</p> <pre><code>if (obj is ClassA) {} if (obj.GetType() == typeof(ClassA)) {} </code></pre> <p>Edit: I'm aware that they don't do the same thing.</p>
<p><a href="https://learn.microsoft.com/en-us/archive/blogs/vancem/drilling-into-net-runtime-microbenchmarks-typeof-optimizations" rel="nofollow noreferrer">This should answer that question, and then some.</a></p> <p>The second line, <code>if (obj.GetType() == typeof(ClassA)) {}</code>, is faster, for those that don't...
<p>I did some benchmarking where they do the same - sealed types.</p> <pre><code>var c1 = ""; var c2 = typeof(string); object oc1 = c1; object oc2 = c2; var s1 = 0; var s2 = '.'; object os1 = s1; object os2 = s2; bool b = false; Stopwatch sw = Stopwatch.StartNew(); for (int i = 0; i &lt; 10000000; i++) { b = c1...
22,335
<p>I have a simple WPF application with a menu. I need to add menu items dynamically at runtime. When I simply create a new menu item, and add it onto its parent MenuItem, it does not display in the menu, regardless of if UpdateLayout is called.</p> <p>What must happen to allow a menu to have additional items dynami...
<pre><code>//Add to main menu MenuItem newMenuItem1 = new MenuItem(); newMenuItem1.Header = "Test 123"; this.MainMenu.Items.Add(newMenuItem1); //Add to a sub item MenuItem newMenuItem2 = new MenuItem(); MenuItem newExistMenuItem = (MenuItem)this.MainMenu.Items[0]; newMenuItem2.Header = "Test 456"; newExistMenuItem.Ite...
<p>ASP.NET -> WEB Forms -> Create Menu</p> <pre><code>CREATE TABLE `webmenu` ( `idmenu` smallint(5) NOT NULL, `submenu` smallint(5) DEFAULT NULL, `menu_title` varchar(45) DEFAULT NULL, `menu_url` varchar(45) DEFAULT NULL, `status` enum('1','0') DEFAULT '1', PRIMARY KEY (`idmenu`) ) ENGINE=InnoDB DEFAULT CH...
37,182
<p>What's the different between SCSF and Acropolis ?</p>
<p>SCSF (Smart client Software Factory) is a set of tools (using the Guidance Automation Extensions to Visual Studio) for building apps using the Composite UI Application Block.</p> <p>The Composite UI Application Block is an application framework that is based on the Composite UI pattern, basically providing plumbing...
<p><a href="http://en.wikipedia.org/wiki/Microsoft_codename_Acropolis" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Microsoft_codename_Acropolis</a></p> <p><a href="http://msdn.microsoft.com/en-us/library/aa480482.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa480482.aspx</a></p> ...
37,917
<p>I'm using the Win32 <code>CreateProcess</code> function to perform a call to an external executable. The executable returns a string.</p> <p>Is there a way I can capture and interrogate the returned string after calling the executable? Failing that, I might have to write out the string to a file in the executable...
<p><a href="http://sourceforge.net/projects/jcl/" rel="nofollow noreferrer" title="Jedi Code Library">Jedi Code Library</a> contains function CreateDOSProcessRedirected which runs a process and provides it with input and output file. You can put required input (if any) into the input file and read process output (if an...
<p>You could use shared memory to communicate between the two applications.</p> <p>You can use the Win32 CreateFileMapping function, and perhaps use a mutex to synchronise calls to the memory mapped file.</p> <p>The following code creates the file.</p> <pre><code>var fMapping : THandle; pMapData : Pointer; fMap...
44,666
<p>I just started experimenting with SVG in web pages, and I discovered that it is only possible to add SVG images into HTML using <code>&lt;object /&gt;</code> tags, not <code>&lt;img /&gt;</code> like I would have expected. Most of the time, I add graphics to web pages through CSS because they are part of the present...
<p>SVG is supported in <code>&lt;img&gt;</code> and in CSS (list-image, background-image, content) since Opera 9. Opera 10 is better still. Webkit/Safari supports svg in <code>&lt;img&gt;</code> too.</p> <p>Some <a href="https://web.archive.org/web/20080420175708/http://my.opera.com/SVGraphics/forums/topic.dml?id=2038...
<p>Last time I tried, almost a year ago, it didn't work. You can, however, already mix svg and xhtml markup. Only problem there is that the page has to have correct mime type (application-xml or something like that) or browsers will ignore the svg.</p> <p>Inline svg is not a perfect solution if you want strict separat...
23,188
<p>We have 3 applications using 3 different spring configuration files. But we have one database and one datasource, so one session factory.Hhow can we import the session factory bean into the 3 different spring config files?</p>
<p>If you are using XML configuration:</p> <p>Put your database settings in a Spring configuration called "database-config.xml" and import it in the other configuration files.</p> <pre><code>&lt;import resource="database-config.xml"/&gt; </code></pre> <p>As to how you share it among three applications is more of a C...
<p>If you are using XML configuration:</p> <p>Put your database settings in a Spring configuration called "database-config.xml" and import it in the other configuration files.</p> <pre><code>&lt;import resource="database-config.xml"/&gt; </code></pre> <p>As to how you share it among three applications is more of a C...
32,438
<p>I have just received a 3D printer for Christmas (Robo R2). I am confused by the sheer amount of settings that I can tweak and I'm hesitant to do so until I know more about them. I was wondering if anybody has any recommendations for literature on:</p> <ul> <li>3D printing in general (geared towards beginners);</l...
<p>Welcome to the fantastic, sometimes frustrating but most often glorious world of 3D printing David! :)</p> <p>Your question is really very very broad, but here's my contribution to make your first steps a success. First of all: I don't have experience with the Robo R2, but judging from the specs available online, ...
<p>I have found that "Troubleshooting and Maintaining your 3d Printer" by Charles Bell has a good overview of:</p> <ul> <li><p>3d Printer Assembly and parts</p></li> <li><p>3d Printer Calibration</p></li> <li><p>3d Printer Software</p></li> <li><p>Filament materials</p></li> <li><p>3d Printer Maintenance (both prevent...
779
<p>What Windows code editors allow the use of <a href="https://en.wikipedia.org/wiki/Tab_stop#Elastic_tabstops" rel="nofollow noreferrer">elastic tabstops</a>, either natively or through a plugin?</p> <p>I know about a gedit plugin, but it only works on Linux.</p>
<p><a href="http://code-browser.sourceforge.net/news.html#link" rel="noreferrer">Code Browser</a> may be the first for windows. I would love to see this feature as a plugin for other editors as well.</p>
<p>The problem is that only a few toolkits/platforms have text widgets that offer the ability to set non-uniform tabstops on different lines. To my knowledge, those toolkits/platforms are Java Swing (used by the demo on the elastic tabstops page), GTK (used by Gedit and the Gedit plugin), and apparently the new version...
4,826
<p>I'm using python and I need to map locations like "Bloomington, IN" to GPS coordinates so I can measure distances between them. What Geocoding libraries/APIs do you recommend? Solutions in other languages are also welcome.</p>
<p><a href="http://code.google.com/p/geopy/" rel="noreferrer">Geopy</a> lets you choose from several geocoders (including Google, Yahoo, Virtual Earth).</p>
<p>You can use a web API like google maps to find the coordinates. Then if you just need to calculate distances (in a straight line), <a href="http://www.movable-type.co.uk/scripts/latlong.html" rel="nofollow noreferrer">there is a formula</a> you can apply to get pretty accurate results.</p>
48,834
<p>I am wanting to use ActiveScaffold to create <em>assignment</em> records for several <em>students</em> in a single step. The records will all contain identical data, with the exception of the student_id.</p> <p>I was able to override the default form and replace the dropdown box for selecting the student name with...
<p>I suppose you have defined your multi-select box adding :multiple => true to html parameters of select_tag. Then, in the controller, you need to access the list of names selected, what you can do like this:</p> <pre><code>params[:students].collect{|student| insert_student(student, params[:assignment_id]) } </code><...
<p>if your assingnments have <code>has_many :students</code> or <code>has_and_belongs_to_many :students</code>, then you can change the id of the multi-select box to assignment_student_ids[], and it should work.</p>
8,479
<p>We are currently developing a server whereby a client requests interest in changes to specific data elements and when that data changes the server pushes the data back to the client. There has vigorous debate at work about whether or not it would be better for the client to poll for this data. </p> <p>What is consi...
<p>There's probably no ideal method for every situation, but push is usually better and used more often. It allows to optimize server caching and data transfers, which helps performance and scalability, and cuts network traffic a bit by avoiding client requests and empty responses. It can be important advantage for a s...
<p>What do you have on the client's side? Many firewalls allow outgoing requests but block incoming requests. In other words, pull may be your only option if you are crossing the Internet unless you are sending out e-mails.</p>
8,321
<p>What options exist for accessing different databases from C++? Put differently, what alternatives are there to ADO? What are the pros and cons?</p>
<ol> <li><a href="http://msdn.microsoft.com/en-us/library/ms710252.aspx" rel="nofollow noreferrer">Microsoft ODBC</a>.</li> <li>The MFC ODBC classes such as <a href="http://msdn.microsoft.com/en-us/library/2dhc1abk.aspx" rel="nofollow noreferrer">CDatabase</a>.</li> <li><a href="http://msdn.microsoft.com/en-us/library/...
<p>One thing - if speed is important and your code doesn't need to be portable, then it may be worth it to use the native libraries. </p> <p>I don't know much about SQL Server, but I do know that the Oracle OCI calls are faster than using ODBC. But, they tie you to Oracle's version of SQL. It would make sense for SQL ...
7,277
<p>I have a PHP application and a need to generate a PDF with the result of query. The easiest way a found to do this was to use the DOMPDF to generate the PDF for me. So a made a function that generates the HTML for me then a pass this to DOMPDF. In the development and testing enviroment everything was fine but on pro...
<p>I once did a PHP project generating PDF. I used <a href="http://www.fpdf.org/" rel="noreferrer">FPdf</a>.</p> <p>I never had any memory problems. It's free, it's pure PHP code. You don't have to load any extensions.</p> <p>I don't know if there's some helpers to auto-generate document from a query, but in the webs...
<p>Fll out a latex template and call Xetex over it.</p> <p>I think you'll find the results pleasing at <a href="http://letterly.com/" rel="nofollow noreferrer">Letterly</a>.</p>
33,322
<p>Given a couple of simple tables like so:</p> <pre><code>create table R(foo text); create table S(bar text); </code></pre> <p>If I were to union them together in a query, what do I call the column?</p> <pre><code>select T.???? from ( select foo from R union select bar from S) as T; </code></pre...
<p>Although there is no spelled rule, we can use the column names from the first subquery in the union query to fetch the union results.</p>
<p>you only need column aliases only in first select (tested in SQl Server 2008 R2)</p> <pre><code>select T.Col1 from ( select 'val1' as Col1 union select 'val2' union select 'val3' ) as T; </code></pre>
41,386
<p>The majority of resources that I have for UI design all deal with the web world. There are a number of advantages there because of the dynamic nature of the presentation layer. </p> <p>However, I would like to design better windows form programs. I want a professional flow to my applications. Right now they look pr...
<p>Try considering WPF as the technology to develop Windows application then you can use lot of vector graphics(XAML) and so lot more than what you can do with windows forms. There is a great blog comparing both <a href="http://joshsmithonwpf.wordpress.com/2007/09/05/wpf-vs-windows-forms/" rel="nofollow noreferrer">ht...
<p><a href="http://windowsclient.net/" rel="nofollow noreferrer">http://windowsclient.net/</a> is a Microsoft site for windows forms. </p>
22,952
<p>What is the best way of handling trying to get data from a DataReader that has more than one column with the same name?</p> <p>Because of the amount of work involved and because we don't want to lose support from a vendor by changing the stored procedures we are using to retrieve the data, I am trying to find anoth...
<p>If you know the index of the column, then access it by the index.</p>
<p>Can't you use column ordinals? 0 for the 1st, 1 for the 2nd, and so on?</p>
46,667
<p>Is it possible to read and write Word (2003 and 2007) files in PHP without using a COM object? I know that I can:</p> <pre><code>$file = fopen('c:\file.doc', 'w+'); fwrite($file, $text); fclose(); </code></pre> <p>but Word will read it as an HTML file not a native .doc file.</p>
<p>Reading binary Word documents would involve creating a parser according to the published file format specifications for the DOC format. I think this is no real feasible solution.</p> <p>You could use the <a href="http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats#Word_XML_Format_example" rel="nofollow norefe...
<p>Would the .rtf format work for your purposes? .rtf can easily be converted to and from .doc format, but it is written in plaintext (with control commands embedded). This is how I plan to integrate my application with Word documents.</p>
22,849
<p>I'm researching game development in Flash and Flex. I've downloaded the Flex Builder trial and have worked with older versions of Flash. I see that generally, Flex Builder is a developer's tool, and Flash is a designer's tool. It's not clear to me whether one is better suited to game development than the other, o...
<p>Flex builder: Way better development/coding environment than Flash CS3/CS4</p> <p>Flash CS3/CS4: Way better design environment than Flex</p> <p>"Flash Style" application: (Sprites, MovieClips instead of flex UIComponents) Generally better performing for game type work.</p> <p>So how do you get all those benefits?...
<p>I have no experience with flash cs3, but quite a lot of experience with flex builder. I would be surprised if flex builder was the best choice. The only real reason to pay for flex builder is charting, which I wouldn't imagine would be present in a game. It may be the best actionscript editor (which is what I would ...
48,269
<p>By default, emacs 22.1.1 only shows the top of the compilation buffer when you first issue the compile command. I would like it to scroll to the bottom automatically when I use the compile command in order to save keystrokes. This way I can easily get a status of the current compilation by just looking at the comp...
<p>From Info > emacs > Compilation:</p> <blockquote> <p>If you set the variable <code>compilation-scroll-output</code> to a non-<code>nil</code> value, then the compilation buffer always scrolls to follow output as it comes in.</p> </blockquote>
<pre> (setq compilation-scroll-output t) </pre> <p>or</p> <pre> M-x set-variable compilation-scroll-output t RET </pre> <p>Also, if you get used to using <code>next-error</code> and <code>previous-error</code> before your compilation finishes, you will start to see why the default behavior is desirable.</p>
14,190
<p>How do I implement this method (see below)? I'm new to Objective-C and I'm just not getting it right.</p> <p>From: <a href="http://lists.apple.com/archives/Webkitsdk-dev/2008/Apr/msg00027.html" rel="nofollow noreferrer">http://lists.apple.com/archives/Webkitsdk-dev/2008/Apr/msg00027.html</a></p> <blockquote> <p>...
<p>In whatever class you've defined as the delegate for your WebView you need to implement that method, something like this:</p> <pre><code>- (void)webView:(WebView *)sender frame:(WebFrame *)frame exceededDatabaseQuotaForSecurityOrigin:(WebSecurityOrigin *)origin database:(NSString *)databaseIdentifier { unsigned...
<p>Here's the final answer.</p> <p>I was using the MiniBrowser sample app.</p> <p>In MyDocument.m I added this function:</p> <pre><code>- (void)webView:(WebView *)sender frame:(WebFrame *)frame exceededDatabaseQuotaForSecurityOrigin:(id)origin database:(NSString *)databaseIdentifier { static const unsigned long ...
46,089
<p>I am trying to use a StreamReader to read a file, but it is always in use by another process so I get this error:</p> <blockquote> <p>The process cannot access the file '\arfjwknasgmed17\C$\FLAG CONDITION\CP-ARFJN-FLAG.XLS' because it is being used by another process.</p> </blockquote> <p>Is there a way I ...
<p>You can read the file only if the program that opened the file first specified read sharing rights on that file. </p> <p>If the file does indeed have no read sharing rights though, you wouldn't be able to copy it in the first place. </p> <p>You may not be able to access a file if you are specifying a sharing right...
<p>try the below code.</p> <pre><code>FileStream fileStr = File.Open(&lt;full file name&gt;, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); fileStream = new StreamReader(fileStr); </code></pre> <p>I have tried it on Windows XP. If the file is already open in write mode by some other process &amp; it has not sp...
24,936
<p>Suppose I have the following declaration:</p> <pre><code>class Over1 { protected: class Under1 { }; }; </code></pre> <p>I know that I could do the following:</p> <pre><code>class Over2 : public Over1 { protected: class Under2 : public Under1 { }; }; </code></pre> <...
<p>Using templates and explicit specializations you can do this with just one additional class declaration in Over1.</p> <pre><code>class Over1 { protected: class Under1 { }; template &lt;typename T&gt; class UnderImplementor; }; struct Under2Tag; struct Under3Tag; struct Under4Tag; template &lt;&gt; clas...
<p>If you want to keep Under1 protected, then by definition, you need to inherit from Over1 to access it. I would suggest making Under1 public, or using namespaces as Douglas suggested.</p> <p>I don't have the compiler to test these out right now, so I'm not at all sure that these would work, but you could try this:<...
18,559
<p>How do I write an Excel workbook to a <code>MemoryStream</code> without first saving it to the file system?</p> <p>All options within the <code>Microsoft.Office.Interop.Excel.WorkBook</code> save options take a filename.</p>
<p>I have done extensive work with the PIA and with storing Excel files in a document repository and streaming it out to the browser, and I have not been able to find a solution to using the PIA without first writing the contents to the file system first.</p> <p>I think that you are going to have to swallow the bullet...
<p>If you only need basic functionality from Excel, you might want to create the Workbook as an Html stream. <a href="https://stackoverflow.com/questions/27288/how-do-i-save-a-datagrid-to-excel-in-vbnet">There is another question on SO that handless this</a>.</p> <p>This also solves some problems (you might not have y...
18,930
<p>When designing a lookup table (enum) in SqlServer 2005, if you know the number of entries will never get very high, should you use tinyint instead of int? I'm most concerned about performance, particularly efficiency of indexes.</p> <p>Let's say you have these representative tables:</p> <pre><code>Person ------ P...
<p>The narrower a table (or index node entry) is, the more records (or index nodes) can fit on a single IO page, and the fewer physical (and logical) reads IO operations are required for any query. Also, the more index nodes there are on a single page, the fewer levels there may be in the index, from root to leaf leve...
<p>I doubt that using smallint instead of int is going to have much performance benefit except in rare edge cases. You can easily build a test app for this though, create some test tables and do a million inserts/updates/selects and compare performance.</p>
38,950
<p><strong>Background:</strong><br> I have an old web CMS that stored content in XML files, one XML file per page. I am in the process of importing content from that CMS into a new one, and I know I'm going to need to massage the existing XML in order for the import process to work properly.</p> <p>Existing XML:</p> ...
<p>I'm afraid to say that it's not possible to pause the Javascript runtime in the same way that the "confirm" and "alert" dialogs pause it. To do it with a DIV you're going to have to break up your code into multiple chunks and have the event handler on the custom confirm box call the next section of code.</p> <p>Th...
<p>In my case, the goal was to display a <code>customConfirm</code> box whenever user clicks the delete link embedded within each row of a .Net Repeater</p> <p>Whenever user clicks the delete link of any particular row,the Custom Confirm function is called. Now inside the confirm function, in addition to rendering the...
46,706
<p>Not sure if anyone listened to Hanselminutes episodes 134 and 135, but at the end of show 135 Scott Hanselman had a lot of great advice on how to setup a baseline secure environment for a web application. As a developer, most of my time is focused on developing the application, not on the network facet of the proje...
<p><a href="http://www.owasp.org" rel="nofollow noreferrer">owasp</a> would be a good place to start.</p>
<p><a href="http://www.owasp.org" rel="nofollow noreferrer">owasp</a> would be a good place to start.</p>
32,327
<p>Using MSSQL2005, can I truncate a table with a foreign key constraint if I first truncate the child table (the table with the primary key of the FK relationship)?</p> <p>I know that I can either</p> <ul> <li>Use a <code>DELETE</code> without a where clause and then <code>RESEED</code> the identity (or)</li> <li>Re...
<p>Correct; you cannot truncate a table which has an FK constraint on it.</p> <p>Typically my process for this is:</p> <ol> <li>Drop the constraints</li> <li>Trunc the table</li> <li>Recreate the constraints.</li> </ol> <p>(All in a transaction, of course.)</p> <p>Of course, this only applies if the <em>child has a...
<p>You could try <code>DELETE FROM &lt;your table &gt;;</code>.</p> <p>The server will show you the name of the restriction and the table, and deleting that table you can delete what you need.</p>
31,650
<p>I'm trying to write a VB.Net program that saves 1-2 million 5-field records (plus an indexed ID) to an MSAccess table every day. The saving process currently takes 13-20 hours, which obviously can't be right.</p> <p>Its a flat table with minimal indexing, currently only 156MB. Except for one double field, the fie...
<p>A trick that can work on any DBMS to substantially speed up an insertion is to disable temporarily the indexes, foreign keys and constraints prior to bulk inserting the data - then enable them again after your data in the database.</p> <p>Especially indexes can be performance-killers for sequential insertion, it's ...
<p>(Disclaimer: I know nothing much about Access)</p> <p>What do any profiling tools say? (task manager will give you some clues - add more columns to the display to see I/Os, VM usage etc)? Is it doing a lot of disk accesses, or is it all CPU? Is it consuming huge amounts of memory?</p> <p>The mention of an index co...
42,469
<p>After I open something with emacsclient, when I kill that buffer (C-x k) I get a confirmation dialog:</p> <pre><code>Buffer `blah' still has clients; kill it? (yes or no) </code></pre> <p>But when I kill buffers opened directly from Emacs I don't. Is there a way not to get them when emacsclient opened them?</p>
<p>This worked for me:</p> <pre><code>(remove-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function) </code></pre> <p>There's more information on <a href="http://shreevatsa.wordpress.com/2007/01/06/using-emacsclient" rel="noreferrer">Using Emacsclient blog entry</a>.</p>
<p>For whatever reason, I have to manually launch the remove-hook solution on emacs23, perhaps because certain parts of the server are loaded after the .emacs is loaded. Adding a dummy (server-start) line to my .emacs before the (remove-hook ...) did not help. So I have opted for the following, less principled solution...
33,637
<p>Having recently discovered this method of development, I'm finding it a rather nice methodology. So, for my first project, I have a small DLL's worth of code (in C#.NET, for what it's worth), and I want to make a set of tests for this code, but I am a bit lost as to how and where to start.</p> <p>I'm using NUnit, a...
<p>See the book <a href="http://www.amazon.co.uk/Working-Effectively-Legacy-Robert-Martin/dp/0131177052" rel="noreferrer">Working Effectively with Legacy Code</a> by Michael Feathers.</p> <p>In summary, it's a lot of work to refactor existing code into testable and tested code; Sometimes it's too much work to be pract...
<p>Your DLL provides some sort of service. For every service, what do you have to do before getting this service, what parameters should you pass to get this service, how would you know that the requested service has correctly be executed ? </p> <p>Once you have the answers to those questions, you can write a first te...
20,177
<p>Is there a good way to have a <code>Map&lt;String, ?&gt;</code> get and put ignoring case?</p>
<p>TreeMap extends Map and supports custom comparators.</p> <p>String provides a default case insensitive comparator.</p> <p>So:</p> <pre><code>final Map&lt;String, ...&gt; map = new TreeMap&lt;&gt;(String.CASE_INSENSITIVE_ORDER); </code></pre> <p>The comparator does not take locale into account. Read more about it...
<p><a href="http://trove4j.sourceforge.net/html/overview.html" rel="nofollow noreferrer">Trove4j</a> can use custom hashing for a HashMap. This may however have performance implications given that hashcodes cannot be cached (although Trove4j may have found a way around this?). Wrapper objects (as described by John M) d...
26,124
<p>I'm currently using winforms databinding to wire up a data editing form. I'm using the netTiers framework through CodeSmith to generate my data objects. For database fields that allow nulls it creates nullable types. I've found that using winforms databinding the controls won't bind properly to nullable types.</p...
<p>In the comments section of the article referenced above one of the posters comes up with a simple solution.</p> <p>Instead of binding with: </p> <pre><code>textBox1.DataBindings.Add("Text", myClass, "MyTextProperty"); </code></pre> <p>Bind with:</p> <pre><code>textBox1.DataBindings.Add("Text", myClass, "MyTextPr...
<p>From <a href="http://www.thejoyofcode.com/Databinding_and_Nullable_types_in_WinForms.NET.aspx" rel="nofollow noreferrer">Databinding and Nullable types in WinForms.NET</a></p> <h1>Scenario</h1> <ul> <li>You have an Entity Type with a Nullable property.</li> <li>You have a TextBox which is bound to that property.</li...
49,263
<p>This is my code:</p> <pre><code>internal enum WindowsMessagesFlags { WM_EXITSIZEMOVE = 0x00000232, WM_DISPLAYCHANGE = 0x0000007e, WM_MOVING = 0x00000216, } protected override void WndProc(ref Message m) { switch(m.Msg) { case (int)WindowsMessagesFlags.WM_DISPLAYCHANGE: ...
<p>Sort of - cast m.Msg instead:</p> <pre><code>protected override void WndProc(ref Message m) { switch((WindowsMessagesFlags) m.Msg) { case WindowsMessagesFlags.WM_DISPLAYCHANGE: FixWindowSnapping(); break; case WindowsMessagesFlags.WM_EXITSIZEMOVE: ...
<p>One reason is because C# currently (4.0) doesn't allow you to write an implicit operator overload (a cast) within an extension method (<a href="https://stackoverflow.com/questions/5518468/is-it-possible-define-an-extension-operator-method">related question</a>) for any type including an enumeration. It would be nic...
42,247
<p>To what is the class path of a Servlet container set? </p> <p>As per my understanding there are three components involved. The JAR files in the <code>lib</code> directory of the Servlet container and then the classes in the <code>WEB-INF/classes</code> and JAR files in the <code>WEB-INF/lib</code> directory. The cl...
<p>The "dynamic" classpath will list <code>WEB-INF/classes</code> and each JAR file under <code>WEB-INF/lib</code> as a separate entry. Other folders under <code>WEB-INF</code> are <em>not</em> included.</p> <p>In your example, <code>bar.properties</code> will not be on the classpath. Move it to <code>WEB-INF/classes<...
<p>In your example bar.properties would need to be under the classes directory to be in the classpath.</p>
39,256
<p>I'd like to run a script that builds the documentation for my php project. It is basically just using wget to run phpdoc.</p>
<p>Here's a fairly extensive tutorial on <a href="http://wordaligned.org/articles/a-subversion-pre-commit-hook" rel="noreferrer">SVN hooks</a></p>
<p>You might want to check out <a href="http://phing.info/trac/" rel="nofollow noreferrer">Phing</a> for a complete build scripting tool. You can manage commits, documentation and other build related activities in one place.</p>
16,855
<p>Is there a way to change the context sensitive help in Visual Studio so that it will only search against the text under the caret instead of a compilation error in your code?</p> <p>More info: After you compile and receive a compilation error(underlined), placing the caret within the underlined text and pressing <kb...
<p>The only solution I've found is to fix the compile error ;-)</p> <p>A workaround is to <strong>use the 'Dynamic Help' window</strong> (from the help menu, or <kbd>CTRL</kbd>-<kbd>F1</kbd>, <kbd>D</kbd>), the compile error is top of the list but the usual item will be listed next.</p> <p>For those that don't understa...
<p>If I remember, after you compile, the default selected window is the message (error list) one. If you hit <kbd>F1</kbd> at this point, you will get help on the error message. But if you select the code window, you will get the help on the selected text.</p> <p>Is this the behavior your are experiencing???</p>
24,886
<p>I currently have two XSD schemes and one is a "light" version of the other. Right now I have everything in the "light" version repeated in the "complete" schema, but this becomes a pain when I need to make a change, and it goes against the DRY principle anyways, so I was wondering if there was an element that served...
<p>There are two methods for this.</p> <p><code>&lt;xsd:include schemaLocation="pathToFile" /&gt;</code> should be used for including files of the same namespace.</p> <p><code>&lt;xsd:import namespace="namespace" schemaLocation="pathToFile" /&gt;</code> should be used for include files in a different namespace. Usual...
<p>Use the &lt;include> element, see for example <a href="https://www.w3schools.com/xml/el_include.asp" rel="nofollow noreferrer">here</a>.</p>
43,126
<p>I am searching for a DateTimePicker control which can be used as a textbox so user can enter date/time data at will (ie; type in the string <strong>"11/09/2008 12:30:00")</strong> or can select date/time from a drop down list that contains a calendar/time box (what i meant is that this control can provide both optio...
<p>There's the <a href="http://windowsclient.net/wpf/wpf35/wpf-35sp1-toolkit-calendar-datepicker-walkthrough.aspx" rel="nofollow noreferrer">DatePicker and Calendar controls</a> from the WPF team, but I don't believe they handle times (as in your example) - just dates. Worth a look though.</p>
<p>I am not sure whether you don't want to use JQuery or not aware of it. But here is this free/open source <a href="http://docs.jquery.com/UI/Datepicker" rel="nofollow noreferrer">date time picker</a> from JQuery which does exactly what you are looking for, plus lot more. </p>
35,365
<p>I am trying to render a model in Direct3D using <code>DrawIndexedPrimitives</code>. However, I am not able to see it on screen. What are the usual methods used to debug a Direct3D model?</p> <p>I've tried the following:</p> <ul> <li>Switched off back face culling</li> <li>Used <code>PrimitiveType.LineStrip</code> ...
<ul> <li>Make the background color grey; then if it's white or black you'll see it.</li> <li>Check your transform matrices (world/view/projection). Use a standard math function for view &amp; projection, set world to identity.</li> <li>Make sure you setup your viewport; easy to forget this one and have 0 values in the...
<p>By default there is no light in D3D, May be everything is black. Try do turn the light on if you didn't.</p>
31,011
<p>Should developers avoid using <a href="http://msdn.microsoft.com/en-us/library/923ahwt1.aspx" rel="nofollow noreferrer">continue</a> in C# or its equivalent in other languages to force the next iteration of a loop? Would arguments for or against overlap with arguments about <a href="https://stackoverflow.com/questio...
<p>I think there should be more use of continue!</p> <p>Too often I come across code like:</p> <pre><code>for (...) { if (!cond1) { if (!cond2) { ... highly indented lines ... } } } </code></pre> <p>instead of </p> <pre><code>for (...) { if (cond1 || cond2) { continu...
<p><code>continue</code> feels wrong to me. <code>break</code> gets you out of there, but <code>continue</code> seems just to be spaghetti.</p> <p>On the other hand, you can emulate <code>continue</code> with <code>break</code> (at least in Java).</p> <pre><code>for (String str : strs) contLp: { ... break ...
8,194
<p>I want to do a conditional rendering at the layout level based on the actual template has defined <code>content_for(:an__area)</code>, any idea how to get this done?</p>
<p><code>@content_for_whatever</code> is deprecated. Use <code>content_for?</code> instead, like this:</p> <pre><code>&lt;% if content_for?(:whatever) %&gt; &lt;div&gt;&lt;%= yield(:whatever) %&gt;&lt;/div&gt; &lt;% end %&gt; </code></pre>
<p>I use @view_flow and value of the content method before checking if the content is present in the view like this:</p> <pre><code>@view_flow.content[:header_left_or_whatever_the_name_of_your_block_is].present? </code></pre> <p>Recently stumbled upon it when showing all local, global and instance variables of self in ...
23,558
<p>I'm using netbeans on ubuntu, I would like to add some fonts to it. Could anyone tell me how this is done ?</p>
<p>There are two possibilities for truly unobtrusive scripts:</p> <ul> <li>including an external script file via a script tag in the head section</li> <li>including an external script file via a script tag at the bottom of the body (before <code>&lt;/body&gt;&lt;/html&gt;</code>)</li> </ul> <p>The second one can be f...
<p>If you put it at the bottom, it loads last, hence speeding up the speed that the user can see the page. It does need to be before the final <code>&lt;/html&gt;</code> though otherwise it won't be part of the DOM.</p> <p>If the code is needed instantly though, then put it in the head.</p> <p>It's best to put things...
17,324
<p>I have recently discovered the incredibly useful <a href="http://www.eclipse.org/mat/" rel="nofollow noreferrer">Eclipse Memory Analysis Tool</a>, which makes quick work of finding memory leaks in Java applications. Unfortunately, after switching my JDK to 1.6 (under Mac OS 10.5), the JVM terminates immediately upo...
<p>To configure Eclipse to use another VM use this command line:</p> <pre><code>eclipse -vm &lt;path to java&gt; </code></pre> <p>You can also specify the path in Eclipse.app/Contents/Info.plist. There is a section like this:</p> <pre><code>&lt;!-- to use a specific Java version (instead of the platform's default) u...
<p>The official Java 6 for the Mac only has a 64 bit data model. Unfortunately, Eclipse uses Carbon on the Mac which is only available in 32 bits. In short, it is impossible to run Eclipse with the official Java 6 distribution.</p> <p>The classical solution to this is to set the default VM to Java 5, and then choose J...
30,497
<p>I have been looking at using TDD and implementing proper testing (only just started to learn how much better it makes your life) in any of my projects that I create in the future. So for the last couple of days I have been floating around on SO trying to learn about how to design your application for testability, b...
<p>I think you have the right idea, but I think you are making this into a bigger deal than it is. If you start doing TDD, your first reaction will probably be 'is this it?'. And then later, you should hopefully say 'aha'!</p> <p>The main thing is that you get nUnit, learn the tutorial, and then make sure you write a ...
<p>You are right with the Mocking part, if you actually are doing what you said. </p> <p>As for the interfaces, my personal method of development considering this point is that I first write what my application's main path should look like (using my ideal mock API that does nothing). Then after looking through my Mock...
40,867
<p>I need a small, portable framework for logging on embedded linux. Ideally it would output to a file or a socket, and having some sort of log rotation/compression would also be nice.</p> <p>So far, I've found a lot of frameworks, but almost all of them have daunting build procedures or require the use of applicatio...
<p>Use <a href="http://www.manpagez.com/man/3/syslog/" rel="noreferrer">syslog(3)</a> and syslogd from <a href="http://www.busybox.net/" rel="noreferrer">BusyBox</a>. BusyBox can be very compact when stripped down and doesn't depend on anything other than libc. You can strip out everything you don't want so it is perfe...
<p>Implementing very robust logging mechanism in C taking about 1000 code lines (from our code base). 90% of this defines of different sections. This includes different macros <code>DBG_E DBG_W DBG_TRACE</code> etc ... and spliting to the section, run time changing of debug level and debug modules (does not include com...
43,989
<p>Looks like here in StackOveflow there is a group of <strong>F#</strong> enthusiasts. </p> <p>I'd like to know better this language, so, apart from the <a href="http://en.wikipedia.org/wiki/Functional_programming" rel="noreferrer">functional programming theory</a>, can you point me to the better starting points to s...
<p>Not to whore myself horribly but I wrote a couple F# overview posts on my blog <a href="http://www.codegrunt.co.uk/blog/?p=58" rel="noreferrer">here</a> and <a href="http://www.codegrunt.co.uk/blog/?p=81" rel="noreferrer">here</a>. Chris Smith (guy on the F# team at MS) has an article called 'F# in 20 minutes' - <a ...
<p>Check out the <a href="http://msdn.microsoft.com/en-gb/fsharp/default.aspx" rel="nofollow noreferrer">F# Developer Center</a>. There is also <a href="http://cs.hubfs.net/forums/default.aspx" rel="nofollow noreferrer">hubFS</a>, a forum dedicated to F#.</p>
5,694
<p>We are sometimes getting an OutOfMemoryError in production and I would like to be able to analyse what caused the problem, or at least what was going on when it occurred. It seems that I should be able to get an HProf profile by using the -XX:+HeapDumpOnOutOfMemoryError option, but I have read that this is JVM speci...
<p>Oracle OC4J is certified for Sun JVM 1.3.1 and 1.4.2 (see <a href="http://www.oracle.com/technology/tech/java/oc4j/1012/collateral/OC4J-FAQ-101202.pdf" rel="nofollow noreferrer">this PDF</a>).</p> <p>The -XX:+HeapDumpOnOutOfMemoryError option was introduced in Java 6 and backported to Java 5.0 update 7 and Java 1.4...
<p>This option is specific to SUN/SAP/HP JVM's, and I doubt it would work if you use the JRockit VM. JRockit might also not support the hprof format at all, because it's not required by the Java spec. </p> <p>You may want to check <a href="http://www.yourkit.com/faq/index.jsp#jrockit" rel="nofollow noreferrer">Yourk...
46,020
<p>I was currently looking into memcached as way to coordinate a group of server, but came across <a href="http://hadoop.apache.org/zookeeper/" rel="noreferrer">Apache's ZooKeeper</a> along the way. It looks interesting, and Yahoo uses it, so it shouldn't be bad, but I'd never heard of it before, so I'm kind of skeptic...
<p>ZooKeeper and Memcached have different purposes. You can use memcached to do server coordination, but you'll have to do most of this work yourself. Memcached only allows coordination in that it caches common data lookups to be used by multiple clients. From reading ZooKeeper's documentation, it has a much broader fo...
<p>Zookeeper is great for coordinating data across servers. It does a good job of ordering every transaction and making guarantees that transactions happen in order. However when first breaking into it the documentation sucks; it's very 'high-level' without enough concrete examples or explanations as how to properly ha...
33,896
<p>Is there any way to import a database backup from 2005 into 2008 express edition. What I've had to resort to is doing a script the database, then import all the data through DTS. Whenever I tried to import straight from a backup file it says something about not being to import into a new version of sql server or I'l...
<p>SQL 2005 backups should be restored on 2008 without problem (have done that myself many times). What exact error message did you got about versions? The other error (Specified cast is not valid) seems to be Management Studio error, not server error. Have you full rights on 2008 server?</p> <p>Look at this question ...
<p>I imagine that you are in a development process where your data will have to be regularly copied to you SQL 2008 server.</p> <p>You can then think of configuring a replication between the SQL 2005 server (publisher) and SQL Server Express 2008 (suscriber). Depending on your requirements, you have the choice between...
37,545
<p>Currently I have the function CreateLog() for creating a a log4net Log with name after the constructing instance's class. Typically used as in:</p> <pre><code>class MessageReceiver { protected ILog Log = Util.CreateLog(); ... } </code></pre> <p>If we remove lots of error handling the implementation boil...
<blockquote> <p>Is there anyone who can show me how to implement a zero argument CreateLog() that gets the name from the subclass and not the declaring class?</p> </blockquote> <p>I don't think you'll be able to do it by looking at the stack frame. </p> <p>While your class is <code>IMReceiver</code>, the call to <c...
<p>Try the StackTrace.GetFrames method. It returns an array of all the StackFrame objects in the call stack. Your caller should be at index one.</p> <pre><code>class Program { static void Main(string[] args) { Logger logger = new Logger(); Caller caller = new Caller(); caller.FirstMetho...
43,981
<p>Which checksum algorithm can you recommend in the following use case?</p> <p>I want to generate checksums of small JPEG files (~8 kB each) to check if the content changed. Using the filesystem's <em>date modified</em> is unfortunately not an option.<br/> The checksum <strong>need not</strong> be cryptographically s...
<p>If you have many small files, your bottleneck is going to be file I/O and probably not a checksum algorithm.</p> <p>A list of hash functions (which can be thought of as a checksum) can be found <a href="http://en.wikipedia.org/wiki/List_of_hash_functions" rel="noreferrer">here</a>.</p> <p>Is there any reason you c...
<p>Just a postscript to the above; jpegs use lossy compression and the extent of the compression may depend upon the program used to create the jpeg, the colour pallette and/or bit-depth on the system, display gamma, graphics card and user-set compression levels/colour settings. Therefore, comparing jpegs built on diff...
14,967
<p>Currently, 3D Builder is telling me "one or more objects are invalidly defined. Click here to repair." What is this and what does it mean? When I click it, it totally messes up my model (I can't tell what it even did due to the orthogonal camera). Model stats: </p> <ul> <li>Made with Sketchup</li> <li>Used STL Expo...
<p>Those wavy lines could be artefacts caused by closely-spaced infill, but they could also be resonance patterns caused by noisy stepper motors and over-tight belts. Since you have said that you have your belts nice and tight, I would suggest reducing the tension on them and see what happens. I know that some pundits ...
<p>It is difficult to see with the lighting and the shiny green, but try printing a more complex object, like the usual <a href="https://www.thingiverse.com/thing:1278865" rel="nofollow noreferrer">XYZ cube</a>. Does it look like this one? which means big waves after a change of direction, but then getting smaller?</p>...
705
<p>Any good logging libraries that support .NET compact framework?</p>
<p>log4net is a good choice, I use it for all projects.</p>
<p>log4net actually supports compact framework 1.0, will try it out!</p> <p>Read more <a href="http://logging.apache.org/log4net/release/framework-support.html" rel="nofollow noreferrer">here</a></p>
25,447
<p>When I backup or restore a database using MS SQL Server Management Studio, I get a visual indication of how far the process has progressed, and thus how much longer I still need to wait for it to finish. If I kick off the backup or restore with a script, is there a way to monitor the progress, or do I just sit back ...
<p>I found this sample script <a href="http://sql-articles.com/scripts/estimated-time-for-backup-restore/" rel="noreferrer">here</a> that seems to be working pretty well:</p> <pre><code>SELECT r.session_id,r.command,CONVERT(NUMERIC(6,2),r.percent_complete) AS [Percent Complete],CONVERT(VARCHAR(20),DATEADD(ms,r.estimat...
<p>simply run bkp_status on master db you will get backup status</p>
18,395
<p>I don't see any obvious way to import ICS files into Google Calendar from the API docs here:</p> <p><a href="http://code.google.com/apis/calendar/developers_guide_protocol.html" rel="noreferrer">http://code.google.com/apis/calendar/developers_guide_protocol.html</a></p> <p>And I'd greatly prefer not to have to par...
<p>I have created a simple open source .net utility to do just that, available at <a href="http://gcalicsimporter.codeplex.com/" rel="noreferrer">http://gcalicsimporter.codeplex.com/</a>.</p>
<p>You shouldn't have to parse an ICS just to import it into Google Calendar, it is capable of importing them directly... From the end-user's web view, it's as easy as clicking Import Calendar. From the API, I would look at the <a href="http://code.google.com/apis/calendar/developers_guide_protocol.html#AddingSubscri...
16,388
<p>Does anyone have a good way of implementing something like a sequence in SQL server?</p> <p>Sometimes you just don't want to use a GUID, besides the fact that they are ugly as heck. Maybe the sequence you want isn't numeric? Besides, inserting a row and then asking the DB what the number is just seems so hackish.<...
<p>Sql Server 2012 has introduced <a href="http://msdn.microsoft.com/en-us/library/ff878058.aspx" rel="noreferrer"><code>SEQUENCE</code> objects</a>, which allow you to generate sequential numeric values not associated with any table.</p> <p>Creating them are easy:</p> <pre><code>CREATE SEQUENCE Schema.SequenceName A...
<p>I totally agree and did this last year on a project.</p> <p>I just created a table with the name of the sequence, current value, &amp; increment amount.</p> <p>Then I created a 2 procs to add &amp; delete them. And 2 functions to get next, &amp; get current.</p>
35,849
<p>I have a <em>huge list</em> of person's full names that I must search in a <em>huge text</em>.</p> <p>Only <em>part of the name</em> may appear in the text. And it is possible to be <em>misspelled</em>, <em>misstyped</em> or <em>abreviated</em>. The text has no tokens, so I don't know where a person name starts in ...
<p>Split everything on spaces removing special characters (commas, periods, etc). Then use something like <a href="http://en.wikipedia.org/wiki/Soundex" rel="nofollow noreferrer">soundex</a> to handle misspellings. Or you could go with something like <a href="http://lucene.apache.org/java/docs/" rel="nofollow noreferre...
<p>pure old regular expression scripting will do the job.</p> <p>use Ruby, it's quite fast. read lines and match words.</p> <p>cheers </p>
43,967
<p>If I'm reading a text file in shared access mode and another process truncates it, what is the easiest way to detect that? (I'm excluding the obvious choice of refreshing a FileInfo object periodically to check its size) Is there some convenient way to capture an event? (Filewatcher?)</p>
<p>There is, <strong>It's called <a href="http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx" rel="nofollow noreferrer">FileSystemWatcher</a></strong>.</p> <p>If you are developing a windows forms application, you can drag-and-drop it from the toolbox.</p> <p>Here's some usage example:</p> <pre...
<p>Just something to chew on; it may not apply to your situation:</p> <p>chakrit's solution is correct for what you asked for, but I have to ask -- why are you reading a file while another process truncates it?</p> <p>In particular, if you don't have some synchronization, reading/writing files concurrently is not par...
35,204
<p>Are there any prebuilt modules for this? Is there an event thats called everytime a page is loaded? I'm just trying to secure one of my more important admin sections.</p>
<p>As blowdart said, simple IP Address logging is handled by IIS already. Simply right-click on the Website in Internet Information Services (IIS) Manager tool, go to the Web Site tab, and check the Enable Logging box. You can customize what information is logged also. </p> <p>If you want to restrict the site or even ...
<p>A little more information please; do you want to log IPs or lock access via IP? Both those functions are built into IIS rather than ASP.NET; so are you looking for how to limit access via IP programatically?</p>
13,034