instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>Greetings,</p> <p>The VBA code below will create an Excel QueryTable object and display it starting on Range("D2"). The specific address of this target range is immaterial.</p> <p>My question is -- is it possible to manually feed in values to an in-memory Recordset, and then have the table read from it? In other...
<p>Yes, sure.</p> <pre><code> Dim vConnection As Variant, vCommandText As Variant Dim r As ADODB.Recordset Dim i As Long 'Save query table definition vConnection = QueryTable.Connection vCommandText = QueryTable.CommandText Set r = New ADODB.Recordset &lt;populate r&gt; Set QueryTable.Recordset = ...
<p>From the Excel VB Help The connection parameter can be:</p> <p>"An ADO or DAO Recordset object. Data is read from the ADO or DAO recordset. Microsoft Excel retains the recordset until the query table is deleted or the connection is changed. The resulting query table cannot be edited"</p> <p>So yes it looks like yo...
28,434
<p>I have a form with several checkboxes which values are pulled from a database. I managed to display them in the form, assign an appropriate value to each, but cannot insert their values into other database.</p> <p>Here's the code:</p> <pre><code>&lt;form id=&quot;form1&quot; name=&quot;form1&quot; method=&quot;post&...
<p>You can tell if a checkbox is selected because it will have a value. If it's not selected, it won't appear in the request/get/post in PHP at all.</p> <p>What you may want to do is check for the value of it and work based on that. The value is the string 'on' by default, but can be changed by the value='' attribu...
<p>Also something that few people use but that is quite nice in HTML, is that you can have:</p> <pre><code>&lt;input type="hidden" name="my_checkbox" value="N" /&gt; &lt;input type="checkbox" name="my_checkbox" value="Y" /&gt; </code></pre> <p>and <em>voila!</em> - default values for checkboxes...!</p>
29,978
<p>I run a social networking / blogging website ( <a href="http://www.obsidianportal.com" rel="nofollow noreferrer">http://www.obsidianportal.com</a> ), and currently the users are identified by their unique (and unchangeable) username everywhere. Many have requested the ability to have a display name as well that the...
<p>I'd go with the <a href="http://en.wikipedia.org/wiki/Principle_of_least_astonishment" rel="nofollow noreferrer">principle of least astonishment</a>, in this case "Don't allow users to choose a display name that overlaps with an existing unique username OR an existing display name." Otherwise you could have 10 diffe...
<p>If the account is linked to a profile with some <strong>statistic</strong> I think you doesn't require to have to be unique username. If at StackOverFlow someone try to use my name and he is under 1 000 reps, I think it's obvious that I am the real. Of course, someone can use my name here and try to be me, in that c...
37,334
<p>I've been a professional software engineer for about a year now, having graduated with a CS degree. I've known about assertions for a while in C++ and C, but had no idea they existed in C# and .NET at all until recently.</p> <p>Our production code contains no asserts whatsoever and my question is this...</p> <p>Sh...
<p>In <a href="https://rads.stackoverflow.com/amzn/click/com/0735622027" rel="noreferrer" rel="nofollow noreferrer">Debugging Microsoft .NET 2.0 Applications</a> John Robbins has a big section on assertions. His main points are:</p> <ol> <li>Assert liberally. You can never have too many assertions.</li> <li>Assertions...
<p>I don't know how it is in C# and .NET, but in C will assert() only work if compiled with -DDEBUG - the enduser will never see an assert() if it's compiled without. It's for developer only. I use it really often, it's sometimes easier to track bugs.</p>
15,700
<p>What Visual Studio settings and .emacs macros improve the likelihood that code written on Windows (in visual studio) will still look good in Emacs (and vice versa)? I've recently taken to turning off tabs in emacs (so tabs are rendered via spaces) and this at least makes the code look the same (tho people who like c...
<p>Always use tabs for <em>indenting only</em> and nothing else, and there's no problem.</p> <p>Anything involving aligning characters across lines (not indenting) should use spaces.</p> <p>Just do that, then people can set their tab size to whatever they like, and everything will all be fine.</p>
<p>Emacs's idea of tabs is that they're a compression scheme, that they're always size 8, and they're normally a different size from the indent size. This leads to things like it indenting 4 spaces at the first indent, then 1 tab at the next, then 1 tab and 4 spaces at the third indent level.<p> Your options for making...
23,821
<p>I've successfully installed <code>mjpg-streamer-experimental</code> from <a href="https://github.com/jacksonliam" rel="nofollow noreferrer">jacksonliam</a>/<a href="https://github.com/jacksonliam/mjpg-streamer" rel="nofollow noreferrer"><strong>mjpg-streamer</strong></a>.</p> <p>I just can't figure out how to set th...
<p><strong>Edit: Having now installed Octopi myself, I have found that they made it easy to rotate the image right from the interface. If you open the &quot;Settings&quot; and look under &quot;Webcam &amp; Timelapse&quot;, there are settings for flipping the image horizontally or vertically and for rotating 90 degrees....
<p>From the <code>help</code> for input plugin &quot;<strong>raspicam</strong>&quot;, the following parameters can be passed to this plugin:</p> <pre><code>[-fps | --framerate]...: set video framerate, default 5 frame/sec [-x | --width ]........: width of frame capture, default 640 [-y | --height]........: height of fr...
715
<p>You may have seen JavaScript sliders before:</p> <p><a href="http://dev.jquery.com/view/tags/ui/1.5b2/demos/ui.slider.html" rel="nofollow noreferrer">http://dev.jquery.com/view/tags/ui/1.5b2/demos/ui.slider.html</a></p> <p>What I'm envisioning is a circular slider. It would consist of a draggable button at one poi...
<p>define a center point c current mouse point at m</p> <p>in your mouse drag event handler, you'd have</p> <pre><code>var dx = m.x-c.x; var dy = m.y-c.y; var scale = radius/Math.sqrt(dx*dx+dy*dy); slider.x = dx*scale + c.x; slider.y = dy*scale + c.y; </code></pre> <p>radius would be some preset value of the slide...
<p>I have written a <a href="https://github.com/princejwesley/circular-slider" rel="nofollow">jQuery plugin</a> which supports full/half circle sliders.</p> <p><a href="http://www.toolitup.com/circular-slider.html" rel="nofollow">Demo Page</a> &amp; <a href="https://github.com/princejwesley/circular-slider/blob/master...
45,743
<p>Similar to <a href="https://stackoverflow.com/questions/288794/does-c-optimize-the-concatenation-of-string-literals">this</a> question, but for VB.NET since I learned this is a language thing.</p> <p>For instance, would the compiler know to translate</p> <blockquote> <p>Dim s As String = "test " + "this " + "f...
<p>Yes. It Does. I only tested VS 2008 but I strongly suspect previous versions did as well.</p> <p>VB.NET</p> <pre><code>Public Class Class1 Dim s As String = "test " + "this " + "function" Public Function test() As String Return s End Function End Class </code></pre> <p>I.L. - Notice the st...
<p>The compiler will optimize a string concatenation when appropriate. However, you should consider using the StringBuilder class if you don't know how many concatenations there may be.</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx" rel="nofollow noreferrer">http://msdn.microso...
37,034
<p><a href="http://en.wikipedia.org/wiki/Aspect-oriented_programming" rel="noreferrer">AOP</a> is an interesting programming paradigm in my opinion. However, there haven't been discussions about it yet here on stackoverflow (at least I couldn't find them). What do you think about it in general? Do you use AOP in your p...
<p>Yes.</p> <p>Orthogonal concerns, like security, are best done with AOP-style interception. Whether that is done automatically (through something like a dependency injection container) or manually is unimportant to the end goal.</p> <p>One example: the "before/after" attributes in <a href="http://www.codeplex.com/x...
<p>Yes, we do use AOP in application programming . I preferably use AspectJ for integrating aop in my Spring applications. Have a look at this article for getting a broader prospective for the same.</p> <p><a href="http://codemodeweb.blogspot.in/2018/03/spring-aop-and-aspectj-framework.html" rel="nofollow noreferrer">...
4,098
<p>I have <code>ci</code>, so our staging environment builds itself.<br> Should I have a script that not only builds production but does all the branching for it as well?<br> When you have one code base on two different urls with skinning, should they be required to build at once?</p>
<p>The only way to be too automated is if you are spending more time fighting with building or fixing automation scripts than you would just doing the job manually. As long as your automation scripts take less time and produce fewer errors than doing the job manually, then automation is great.</p> <p>Scripts to build...
<p>In my opinion it's only too automated if no one in your production support group can deploy an application manually in a pinch. Automated deployments really cut down on simple but common errors such as configuration mistakes. However, a manual deployment must always be an option. </p>
4,906
<p>I am writing some new code that will throw a custom exception - I want to include an error string and a status code. Which class should be exception derive from? <code>std::exception</code>? <code>std::runtime_error</code>? Any other 'gotchas' to worry about? I'm thinking of something like the following:</p> <p...
<p>Boost has a great document on <a href="http://www.boost.org/community/error_handling.html" rel="nofollow noreferrer">error and exception</a> handling which talks about common gotchas and how to properly inherit from std::exception(s).</p>
<p>Both the destructor and what() methods should be marked no throw.<br> In MS-Studio it ignores the throw qualifier and compiles fine, but for compliance with the standard and portability you should add it to your code.</p> <pre><code>// What is a no throw operation. virtual const char* what() const throw () { re...
43,648
<p>I find working on the command line in Windows frustrating, primarily because the console window is wretched to use compared to terminal applications on linux and OS X such as "rxvt", "xterm", or "Terminal". Major complaints:</p> <ol> <li><p>No standard copy/paste. You have to turn on "mark" mode and it's only ava...
<p>Sorry for the self-promotion, I'm the author of another Console Emulator, not mentioned here.</p> <p><a href="http://www.fosshub.com/ConEmu.html" rel="nofollow noreferrer">ConEmu</a> is opensource console emulator with tabs, which represents multiple consoles and simple GUI applications as one customizable GUI wind...
<p>Take a look at <a href="http://www.jpsoft.com" rel="nofollow noreferrer">Take Command</a>.</p> <blockquote> <p>Take Command is a comprehensive interactive GUI and command line environment that makes using the Windows command prompt and creating batch files easy and far more powerful.</p> </blockquote> <p>(Take C...
8,606
<p>If I have an xmlreader instance how can I use it to read its current node and end up with a xmlElement instance?</p>
<p>Not tested, but how about via an <code>XmlDocument</code>:</p> <pre><code> XmlDocument doc = new XmlDocument(); doc.Load(reader); XmlElement el = doc.DocumentElement; </code></pre> <p>Alternatively (from the cmoment), something like:</p> <pre><code> doc.LoadXml(reader.ReadOuterXml()); </code></pre> ...
<p>Assuming that you have XmlDocument, where you need to attach the newly created XmlElement:</p> <pre><code>XmlElement myElement; myXmlReader.Read(); if (myXmlReader.NodeType == XmlNodeType.Element) { myElement = doc.CreateElement(myXmlReader.Name); myElement.InnerXml = myXmlReader.InnerXml; } </code></pre> <p...
36,062
<p>Say I have this given XML file:</p> <pre><code>&lt;root&gt; &lt;node&gt;x&lt;/node&gt; &lt;node&gt;y&lt;/node&gt; &lt;node&gt;a&lt;/node&gt; &lt;/root&gt; </code></pre> <p>And I want the following to be displayed:</p> <pre><code>ayx </code></pre> <p>Using something similar to:</p> <pre><code>&lt;xsl...
<p>Easy!</p> <pre><code>&lt;xsl:template match="/"&gt; &lt;xsl:apply-templates select="root/node"&gt; &lt;xsl:sort select="position()" data-type="number" order="descending"/&gt; &lt;/xsl:apply-templates&gt; &lt;/xsl:template&gt; &lt;xsl:template match="node"&gt; &lt;xsl:value-of select="."/&gt; &l...
<pre><code>&lt;xsl:template match="/"&gt; &lt;xsl:apply-templates select="root/node[3]"/&gt; &lt;xsl:apply-templates select="root/node[2]"/&gt; &lt;xsl:apply-templates select="root/node[1]"/&gt; &lt;/xsl:template&gt; &lt;xsl:template match="node"&gt; &lt;xsl:value-of select="."/&...
7,246
<p>I have an <a href="http://en.wikipedia.org/wiki/EXE" rel="noreferrer">EXE</a> file that I should like to sign so that Windows will not warn the end user about an application from an "unknown publisher". I am not a Windows developer. The application in question is a screensaver generated from an application that gene...
<p>You can try using <a href="http://msdn.microsoft.com/en-us/library/aa387764.aspx" rel="noreferrer">Microsoft's Sign Tool</a></p> <p>You download it as part of the Windows SDK for Windows Server 2008 and .NET 3.5. Once downloaded you can use it from the command line like so:</p> <blockquote> <p>signtool sign /a M...
<p>And yet another option, if you're developing on Windows 10 but don't have Microsoft's signtool.exe installed, you can use Bash on Ubuntu on Windows to sign your app. Here is a run down:</p> <p><a href="https://blog.synapp.nz/2017/06/16/code-signing-a-windows-application-on-linux-on-windows/" rel="noreferrer">https:...
31,424
<p>I'm struggling to find out an enclosed 3D printer that allow to load the common 1 kg filament bobbins. Most of the enclosed ones accept only proprietary bobbins (like Dremel or Flashforge).</p> <p>Do these bobbins ( = 1 kg) rely on a specific standard I can search for? How to filter out the printers that match my re...
<h1>There are standards for spools/bobbins/reels</h1> <p>Looking for standards for spools, I started at Alibaba and then came to an actual European manufacturer or retailer of reels: <a href="https://www.hafner-spools.com/en/products/spools/spools-for-3d-printer/" rel="nofollow noreferrer">Häfner</a>. They manufacture ...
<p>QIDI Tech makes a series of enclosed printers, which would narrow your search a bit. I own an X-Max model which has an internal spool spindle as standard equipment, along with an &quot;ordinary&quot; external mount. The internal spindle will take a standard one kilogram spool. It's considered good practice when prin...
2,203
<p>How do I get the modified date/time of a file in Python?</p>
<pre><code>os.path.getmtime(filepath) </code></pre> <p>or</p> <pre><code>os.stat(filepath).st_mtime </code></pre>
<p>Formated:</p> <pre><code>import time print time.strftime("%m/%d/%Y %I:%M:%S %p",time.localtime(os.path.getmtime(fname))) </code></pre>
14,722
<p>Of course, the immediate answer for most situations is <strong>"yes"</strong>, and I am a firm believer that a process should correctly cleanup any resources it has allocated, but what I have in my situation is a long-running system daemon that opens a fixed number of file descriptors at the startup, and closes them...
<p>Closing file descriptors when you are done using them makes your code more reusable and easier to extend. This sounds to me like a case where you have a valid reason for letting them get closed automatically.</p>
<p>man 3 exit:</p> <pre><code>.... All open stdio(3) streams are flushed and closed. Files created by tmpfile(3) are removed. </code></pre> <p>So i believe leaving main effectively calls the exit function with main's return value. Though I would argue that it is bad style. Personally, I <em>always</em> explicitly fr...
35,854
<p>What is the simplest way to send mail using Ruby on Rails? Is there a way to send mail directly via ruby and skip all the rails models and complexity, just like php's mail() function?</p> <p>Thanks for your help.</p>
<p>The simplest way in <em>plain old ruby</em> is to use net/smtp. However rails has it's own built in mailing facilities, because sending mail is something that is pretty common. The best way to do it in rails, is to use a <a href="http://api.rubyonrails.com/classes/ActionMailer/Base.html" rel="noreferrer">Mailer mode...
<p>I'm concerned that if you don't want to use ActionMailer that maybe you just don't get rails. ActionMailer makes sending email with good templating and the like very very easy, you really should look into it.</p>
29,339
<p>I want to do something like </p> <pre><code>insert into my table (select * from anothertable where id &lt; 5) </code></pre> <p>What is the correct MSSQL syntax?</p> <p>Thanks!</p>
<p>Is this what you're looking for?</p> <pre><code>INSERT INTO MyTable SELECT * FROM AnotherTable WHERE AnotherTable.ID &lt; 5 </code></pre>
<p><code>Insert Into MyTable ( Col1, Col2, Col3 ) Select Col1, Col2, Col3 From AnotherTable Where ID &lt; 5 </code></p>
27,554
<p>I am trying to execute this SQL query prior to restoring a .BAK file in SQL Express. Initially, I had the file on the Desktop of my user account. I am logged in as Administrator.</p> <p>When I try to access the .BAK file on the desktop like this</p> <pre><code>RESTORE FILELISTONLY FROM DISK= 'C:\Documents and Sett...
<p>Try granting read permission to <strong>Users</strong> or <strong>LOCAL SERVICE</strong> to the folder C:\Documents and Settings\Administrator\Desktop\ in your Policy Editor (right click the folder and in the Security tab click Add... then Advanced...|Find Now</p>
<p>When you are running the restore script, it is executing under the context of the service account that the SQL Express is running under. Go to the Services Management Console ( or run Services.msc) and find the SQL Express service and look at what account it is configured to run under and then look at the permission...
30,009
<p>I've got a web form with Password and Confirm Password text boxes. I've got a RegularExpressionValidator attached to the first one and CompareValidator to the second one. Now the problem is when i have something in the Password field and nothing in Confirm Password field it does not display an error that fields don'...
<p>FWIW, if you make the Password box the ControlToValidate, and the Confirm Password box the ControlToCompare, then it will work because the password box will have something in it and hence will run the validation.</p> <p>Of course, this could allow them to submit a form with an empty Password box and a filled-in Con...
<p>CompareValidator, RegularExpressionValidator and RangeValidator validation controls are working on non-empty string values. This is useful for situations where we have an non-required field that needs to satisfy some condition when entered. </p> <p> For example we have a form with two fields: primary email that mus...
33,605
<p>Is there a way to define a generic constraint in Java which would be analogous to the following C# generic constratint ?</p> <pre><code>class Class1&lt;I,T&gt; where I : Interface1, Class2 : I </code></pre> <p>I'm trying to do it like this:</p> <pre><code>class Class1&lt;I extends Interface1, T extends I &amp; Cl...
<p>My rule is that <strong>if it's too slow to do what I want, then it's too big</strong>, and your data probably needs to be moved to some other format... database or such.</p> <p>Traversing XML nodes or using XPath can be a dog.</p>
<p>I worked on a project in 2010 where by i had to move a newspaper website from Typo 3 to Drupal 7 and the fastest way around at the time was to export all the content as xml and then parse them into drupal(Xpath). We tried doing it in one go but we had problems at 4Gigs .. So we divided the xmls per year and had each...
16,048
<p>I am wondering what are the best community resources for MFC development- such as forums, IRC channels, etc. Currently the only resource I have for finding answered questions on MFC is using google which comes up with Codeproject results or the occasional result on MSDN or some other web page. Now that there is st...
<p><a href="http://www.flounder.com/mvp_tips.htm" rel="nofollow noreferrer">MVP Tips</a> is a treasure trove of articles and information that relate to visual c++ and MFC. There's not much out there beyond codeplex and the Microsoft news groups/forums</p>
<p>irc #winprog on efnet</p>
34,744
<p>We have a WCF service deployed on a Windows 2003 server that is exhibiting some problems. The configuration is using <code>wsHttpBinding</code> and we are specifying the IP address. The services is being hosted by a Windows Service.</p> <p>When we start the service up, most of the time it grabs the wrong IP addre...
<p>Your WCF configuration looks OK to me. This might be an issue with the binding order of your NIC cards. Make sure that the NIC with correct address is first. Here is an article that discuss how to set and view nic binding orders: </p> <p><a href="http://theregime.wordpress.com/2008/03/04/how-to-setview-the-nic-bind...
<p>More information: I removed the xx.xx.xx.4 IP address from the NIC altogether and turned off IIS. Now when I try to start the service it fails and I find this in the System event log.</p> <pre><code>Description: Unable to bind to the underlying transport for xx.xx.xx.4:80. The IP Listen-Only list may contain a re...
18,582
<p>I need to switch among 3 different environments when developing my web app - Development, UAT, and Prod. I have different database connections in my configuration files for all 3. I have seen switching these settings done manually by changing all references and then rebuilding the solution, and also done with prepro...
<p>To me it seems that you can benefit from the <a href="http://msdn.microsoft.com/en-us/asp.net/aa336619.aspx" rel="nofollow noreferrer">Visual Studio 2005 Web Deployment Project</a>s.</p> <p>With that, you can tell it to update/modify sections of your web.config file depending on the build configuration.</p> <p>Tak...
<p>I have adopted the <a href="http://blog.jpboodhoo.com/AutomatingYourBuildsWithNAntPart6.aspx" rel="nofollow noreferrer">Jean Paul Boodhoo Method</a> of changing configurations. The general idea is to have one or more TOKENIZED configuration TEMPLATE files instead of the configuration files themselves. Then you have...
16,099
<p>I recently bought a Creality Ender 3 V2. I have heard that it is best to use a raft when printing. I have tried to use a raft a few different times using PLA, with different settings each time. When I try to peel the raft off of the print, it will snap around the bottom of the print. Are there any recommended slicer...
<blockquote> <p>I have heard that it is best to use a raft</p> </blockquote> <p>Actually, it is not best to use a raft, a raft is an aid that can best be used in special cases, e.g. for filaments that shrink reasonably (PLA is not such a filament).</p> <p>A raft always caused a rough bottom of your print and is frequen...
<p>Rafts fuse with models because the filament gets overheated. To avoid this, keep the temperature in the room between between 23 and 28 °C. Malfunctioning extruder fans, a heater &amp; thermocouple, extruder printed circuit board (PCB), extruder cable, and motherboard can be also to blame.</p>
2,161
<p>Is there a better way to debug JavaScript than MS Script Editor? I am searching for something like Firebug. Firebug Lite doesn't offer this functionality, though. ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p>
<p>Use Visual Studio 2008.</p> <p>The Web Development Helper from Nikhilk is useful as is the Internet Explorer Developer Toolbar (<a href="http://www.microsoft.com/en-us/download/details.aspx?id=18359" rel="nofollow noreferrer">http://www.microsoft.com/en-us/download/details.aspx?id=18359</a>). They are not as good a...
<p>You can download the <a href="http://www.microsoft.com/express/vwd/" rel="nofollow noreferrer">Microsoft Visual Web Developer 2008 Express Edition</a> for free.</p>
20,536
<p>I have an issue that is driving me a bit nuts: Using a UserProfileManager as an non-authorized user.</p> <p>The problem: The user does not have "Manage User Profiles" rights, but I still want to use the UserProfileManager. The idea of using SPSecurity.RunWithElevatedPrivileges does not seem to work, as the UserProf...
<p>The permission that needs set is actually found in the Shared Service Provider.</p> <ol> <li>Navigate to Central Admin</li> <li>Navigate to the Shared Service Provider</li> <li>Under <b>User Profiles and My Sites</b> navigate to Personalization services permissions .</li> <li>If the account doesn't already exist, a...
<p>Here's the answer. Its a stupid Microsoft bug, and there is a hotfix. I'm downloading now to test it.</p> <p><a href="http://support.microsoft.com/kb/952294/en-us" rel="nofollow noreferrer">http://support.microsoft.com/kb/952294/en-us</a></p>
10,841
<p>I have an XML file, which I open in F# like this:</p> <pre><code>let Bookmarks(xmlFile:string) = let xml = XDocument.Load(xmlFile) </code></pre> <p>Once I have the XDocument I need to navigate it using LINQ to XML and extract all specific tags. Part of my solution is:</p> <pre><code>let xname (tag:string) = ...
<pre><code>#light open System open System.Xml.Linq let xname s = XName.Get(s) let bookmarks (xmlFile : string) = let xd = XDocument.Load xmlFile xd.Descendants &lt;| xname "bookmark" </code></pre> <p>This will find all the descendant elements of "bookmark". If you only want direct descendants, use the Elemen...
<p>Caveat: I've never done linq-to-xml before, but looking through other posts on the topic, this snippet has some F# code that compiles and does <em>something</em>, and thus it may help you get started:</p> <pre><code>open System.IO open System.Xml open System.Xml.Linq let xmlStr = @"&lt;?xml version='1.0' encoding...
23,781
<p>I am trying to recreate a Perl script in C# but have a problem creating a checksum value that a target system needs.</p> <p>In Perl this checksum is calculated using the <code>unpack</code> function:</p> <pre><code>while (&lt;PACKAGE&gt;) { $checksum += unpack("%32C*", $_); } $checksum %= 32767; close(PACKAGE)...
<p>There seems to be a library in Mono called <a href="http://www.mono-project.com/Mono_DataConvert" rel="nofollow noreferrer">DataConvert</a> that was written to provide facilities similar to Perl's pack/unpack. Does this do what you need?</p>
<p>In my testing here, unpack with %32C appears to be the additive sum of the bytes, limited to 32 bits.</p> <pre><code>print unpack("%32C*", 'A'); 65 print unpack("%32C*", 'AA'); 130 </code></pre> <p>It shouldn't be hard to reproduce that.</p>
22,021
<p>i have a wcf service that does an operation. and in this operation there could be a fault. i have stated that there could be a fault in my service contract. </p> <p>here is the code below;</p> <pre><code>public void Foo() { try { DoSomething(); // throws FaultException&lt;FooFault&gt; ...
<p>Are you consuming the WCF service from Silverlight? If so, a special configuration is needed to make the service return a HTTP 200 code instead of 500 in case of error. The details are here: <a href="http://msdn.microsoft.com/en-us/library/dd470096%28VS.96%29.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com...
<p>@yapiskan,</p> <p>C# is a strong typed language Foo&lt; X> != Foo. So if you need to catch some exception, provide <em>exact</em> type in <em>catch</em> clause.</p> <p>You can learn more on exception handling reading <a href="http://msdn.microsoft.com/en-us/library/ms229005.aspx" rel="nofollow noreferrer">this</a>...
7,076
<p>I have a rails application running on a Linux server. I would like to interact with Outlook/Exchange 2003 appointments from the rails application. For example, certain actions should trigger sending an appointment, and then preferably accepting/canceling the appointment in Outlook should trigger events in the applic...
<p>Outlook appointments are just e-mails with special header information. There's some information in <a href="http://www.terminally-incoherent.com/blog/2008/04/14/generate-outlook-calendar-events-with-php-and-icalendar/" rel="noreferrer">this tutorial</a> on the required parts. I sent a few meeting invites from my Ou...
<p>For accessing appointments, you can just access the Calendar folder on Exchange using WebDav. For creating appointments, please refer to RFC2445 for details.</p>
10,905
<p>I would like to setup an open source solution for calendaring in a medium sized enterprise. We would be using this from Thunderbird (lightning add-on), Microsoft Outlook. I want to see others' free/busy schedule, invite them to meetings etc.</p> <p>It would be really nice if I could have a calendar for resources li...
<p><a href="http://www.open-xchange.com/" rel="nofollow noreferrer">Open Exchange</a> does this. Look for the community edition, and check out the community edition FAQ for how to connect thunderbird and other calenders with the WebDav publisher.</p> <p>-Adam</p>
<p>I'd second <a href="http://www.google.com/calendar/" rel="nofollow noreferrer">Google Calendar</a> - it's free, easy to set up and allows free SMS notifications of meetings in a number of countries, although in some countries <a href="http://www.google.com/support/calendar/bin/answer.py?hl=en&amp;answer=37173" rel="...
26,045
<p>How do you find the version of an installed Perl module?</p> <p>This is in an answer down at the bottom, but I figure it important enough to live up here. With these suggestions, I create a function in my <code>.bashrc</code></p> <pre><code>function perlmodver { perl -M$1 -e 'print "Version " . $ARGV[0]-&gt;V...
<p>Why are you trying to get the version of the module? Do you need this from within a program, do you just need the number to pass to another operation, or are you just trying to find out what you have?</p> <p>I have this built into the <code>cpan</code> (which comes with perl) with the <code>-D</code> switch so you ...
<p>You can also take a look at <a href="https://metacpan.org/pod/module-version" rel="nofollow">App::module::version</a></p> <pre><code>$ module-version The version of App::module::version in /home/yourself/perl5/lib/perl5 is 1.004 </code></pre>
16,436
<p>Store everything in GMT?</p> <p>Store everything the way it was entered with an embedded offset?</p> <p>Do the math everytime you render?</p> <p>Display relative Times "1 minutes ago"?</p>
<p>You have to store in UTC - if you don't, your historic reporting and behaviour during things like Daylight Savings goes... funny. GMT is a local time, subject to Daylight Savings relative to UTC (which is not).</p> <p>Presentation to users in different time-zones can be a real bastard if you're storing local time....
<p>I like storing in GMT and showing only relative ("about 10 seconds ago", "5 months ago"). Users don't need to see actual timestamps for most use cases.</p> <p>There are certainly exceptions, and an individual application might have many of them, so it can't be a 'one-true-way' answer. Things that need strong audi...
3,309
<p>Using Python I want to be able to draw text at different angles using PIL.</p> <p>For example, imagine you were drawing the number around the face of a clock. The number <strong>3</strong> would appear as expected whereas <strong>12</strong> would we drawn rotated counter-clockwise 90 degrees.</p> <p>Therefore, I...
<p>Draw text into a temporary blank image, rotate that, then paste that onto the original image. You could wrap up the steps in a function. Good luck figuring out the exact coordinates to use - my cold-fogged brain isn't up to it right now. </p> <p>This demo writes yellow text on a slant over an image:</p> <pre...
<p>If you a using aggdraw, you can use settransform() to rotate the text. It's a bit undocumented, since effbot.org is offline.</p> <pre><code># Matrix operations def translate(x, y): return np.array([[1, 0, x], [0, 1, y], [0, 0, 1]]) def rotate(angle): c, s = np.cos(angle), np.sin(angle) return np.array(...
30,449
<p>Consider:</p> <pre><code>int testfunc1 (const int a) { return a; } int testfunc2 (int const a) { return a; } </code></pre> <p>Are these two functions the same in every aspect or is there a difference?</p> <p>I'm interested in an answer for the C language, but if there is something interesting in the C++ lang...
<p><code>const T</code> and <code>T const</code> are identical. With pointer types it becomes more complicated:</p> <ol> <li><code>const char*</code> is a pointer to a constant <code>char</code></li> <li><code>char const*</code> is a pointer to a constant <code>char</code></li> <li><code>char* const</code> is a consta...
<p>Yes, they are same for just <code>int</code></p> <p>and different for <code>int*</code></p>
19,648
<p>Using CSS,</p> <p>I'm trying to specify the height of a <code>span</code> tag in Firefox, but it's just not accepting it (IE does).</p> <p>Firefox accepts the <code>height</code> if I use a <code>div</code>, but the problem with using a <code>div</code> is the annoying line break after it, which I can't have in th...
<pre><code>&lt;style&gt; #div1 { float:left; height:20px; width:20px; } #div2 { float:left; height:30px; width:30px } &lt;/style&gt; &lt;div id="div1"&gt;FirstDiv&lt;/div&gt; &lt;div id="div2"&gt;SecondDiv&lt;/div&gt; </code></pre> <p>As long as the container for whatever is holding <code>div's</code> 1 and 2 is wide...
<p><code>height</code> in <code>em</code> = <code>relative line-height</code></p> <p>for example <code>height:1.1em</code> with <code>line-height:1.1</code></p> <p>= 100% filled</p>
4,468
<p>I tried doing this but this only display the radiobutton without text beside it..</p> <pre><code>&lt;% foreach (string s in Html.RadioButtonList("rbl")) {%&gt; &lt;% =s %&gt; &lt;% } %&gt; </code></pre>
<p><a href="https://stackoverflow.com/users/4481/elijah-manor">Elijah Manor</a> wrote about the same trouble in ASP.NET MVC 1.0: </p> <p><a href="http://www.elijahmanor.com/asp-net-mvc-html-radiobuttonlist-blues/" rel="nofollow noreferrer">ASP.NET MVC Html.RadioButtonList Blues</a></p> <p>He decided to loop through ...
<p>Check out the MVC Futures DLL available in the <a href="http://www.codeplex.com/aspnet" rel="nofollow noreferrer">MVC source</a> on codeplex. In it there is an HtmlHelper extension to render RadioButton lists. It can automatically render a SelectList in the ViewData or you can pass it explicitly. Several overload...
44,939
<p>I have configured my default page to be say "abcd.aspx" and is under ~/View//abcd.aspx and I have my javascripts under ~/Contents/Scripts/.js</p> <p>For some reason, only "../Content/Scripts/.js" works for including the js file on the page and "~/Contents/Scripts/.js" does not. This works only when i access the pag...
<p>Using /Content/Scripts works, but has issues when you have installed your application under a virtual directory/application. If you are looking for the same type of behavior as in webforms, try using the Url helper:</p> <p>&lt;%=Url.Content("~/Content/Scripts/jquery-ui.js")%>"</p>
<p>The easiest way would be to use "/Content/Scripts", the "~/" shortcut won't work in a standard script tag and using relative paths will break once the perceived path changes with different routes.</p>
43,117
<p>If I want to compile my .NET applications for a 64 bit environment. Do I need </p> <ul> <li>64 bit OS version<br> or </li> <li>64 bit Visual Studio version<br> Or both?</li> </ul>
<p>You actually need neither of those for <em>building</em> the application. A pure .NET 2.0+ application will -- in the absence of specific compiler flags to the contrary -- run as a 64-bit application under a 64-bit OS and as a 32-bit application under a 32-bit OS.</p> <p><strong>Edit:</strong> Also, there's no su...
<p>This should have all you need:</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms241066.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms241066.aspx</a></p> <p>I'd start though, by installing a 64-bit OS (which obviously must be running on a 64-bit CPU!).</p>
15,609
<p>Today I had an idea of writing a unit testing framework for stored procedures in MySQL. The full idea is written on a recent post on my blog. In short it goes like this: I want to automate my procedure testing, I want to use a standardized way to test my procedures. Unit testing is widely documented, and there are ...
<p>There's already one testing framework for Sql Server - <a href="http://tsqlunit.sourceforge.net/" rel="nofollow noreferrer">TSQLUnit</a>. Maybe you can get some useful info from it.</p>
<p>One of the benefits would be that the test would be written in the same envirment the stored procedures written and executed, maintaned by a specialized databse developer outside the main application. There is no need for the application developer to be a master of programming a relational database nor for the data...
30,893
<p>Most of the documentation available for building Python extension modules uses distutils, but I would like to achieve this by using the appropriate python autoconf &amp; automake macros instead.</p> <p>I'd like to know if there is an open source project out there that does exactly this. Most of the ones I've found ...
<p>Supposing that you have a project with a directory called <code>src</code>, so let's follow the follow steps to get a python extension built and packaged using autotools:</p> <h2>Create the Makefile.am files</h2> <p>First, you need to create one Makefile.am in the root of your project, basically (but not exclusive...
<p>All PyGTK extensions use autotools, so if the PyGTK aspects don't kill the whole thing for you, it might be worth having a look at the <a href="http://svn.gnome.org/viewvc/pygtk/trunk/" rel="nofollow noreferrer">PyGTK source code</a>. Additionally, <a href="http://bazaar.launchpad.net/~poppler-python/poppler-python/...
32,696
<p>I need to generate random tokens so that when I see them later I can determine absolutely that they were actually generated by me, i.e. it should be near impossible for anyone else to generate fake tokens. It's kind of like serial number generation except I don't need uniqueness. Actually, its a lot like a digital s...
<p>Check out <a href="http://en.wikipedia.org/wiki/HMAC" rel="nofollow noreferrer">HMAC</a>.</p>
<p>That's not too simplistic, that's certainly a valid way to implement a simple digital signature.</p> <p>Of course, you can't prove to anybody <em>else</em> that you generated the signature without revealing your secret key S, but for that purpose you would want to use a more sophisticated protocol like PKI.</p>
41,809
<p>I want to have a "select-only" <code>ComboBox</code> that provides a list of items for the user to select from. Typing should be disabled in the text portion of the <code>ComboBox</code> control.</p> <p>My initial googling of this turned up an overly complex, misguided suggestion to capture the <code>KeyPress</code...
<p>To make the text portion of a ComboBox non-editable, set the DropDownStyle property to "DropDownList". The ComboBox is now essentially select-only for the user. You can do this in the Visual Studio designer, or in C# like this:</p> <pre><code>stateComboBox.DropDownStyle = ComboBoxStyle.DropDownList; </code></pre> ...
<p>for winforms .NET change DropDownStyle to DropDownList from Combobox property</p>
11,124
<p>What's the best way to extract the key and value from a string like this:</p> <pre><code>var myString = 'A1234=B1234'; </code></pre> <p>I originally had something like this:</p> <pre><code>myString.split('='); </code></pre> <p>And that works fine, BUT an equal (=) sign could be used as a key or value within the ...
<p>What I've tended to do in config files is ensure that there's <strong>no</strong> possibility that the separator character can get into either the key or value.</p> <p>Sometimes that's easy if you can just say "no '=' characters allowed" but I've had to resort to encoding those characters in some places.</p> <p>I ...
<p>can't help with a one-liner, but I'll suggest the naive way:</p> <pre><code>var inQuote = false; for(i=0; i&lt;str.length; i++) { if (str.charAt(i) == '"') { inQuote = !inQuote; } if (!inQuote &amp;&amp; str.charAt(i)=='=') { key = str.slice(0,i); value = str.slice(i+1); break; }...
46,708
<p>I was looking for a generic method in .Net to encode a string for use in an Xml element or attribute, and was surprised when I didn't immediately find one. So, before I go too much further, could I just be missing the built-in function? </p> <p>Assuming for a moment that it really doesn't exist, I'm putting toget...
<p>Depending on how much you know about the input, you may have to take into account that <a href="http://www.w3.org/TR/xml11/#charsets" rel="noreferrer">not all Unicode characters are valid XML characters</a>.</p> <p>Both <em>Server.HtmlEncode</em> and <em>System.Security.SecurityElement.Escape</em> seem to ignore il...
<p>Brilliant! That's all I can say.</p> <p>Here is a VB variant of the updated code (not in a class, just a function) that will clean up and also sanitize the xml</p> <pre><code>Function cXML(ByVal _buf As String) As String Dim textOut As New StringBuilder Dim c As Char If _buf.Trim Is Nothing OrElse _buf...
19,065
<p>I usually do not have difficulty to read JavaScript code but for this one I can’t figure out the logic. The code is from an exploit that has been published 4 days ago. You can find it at <a href="https://web.archive.org/web/20100412164007/http://www.milw0rm.com/exploits/7477" rel="nofollow noreferrer">milw0rm</a>.</...
<p>The shellcode contains some x86 assembly instructions that will do the actual exploit. <code>spray</code> creates a long sequence of instructions that will be put in <code>memory</code>. Since we can't usually find out the exact location of our shellcode in memory, we put a lot of <code>nop</code> instructions befor...
<p>This is from metasploit, that means it's using one of metasploit shell codes. It's open source so you can go and grab it : <a href="http://www.metasploit.com/" rel="nofollow noreferrer">http://www.metasploit.com/</a></p>
49,961
<p>I have a CSV file that holds about 200,000 - 300,000 records. Most of the records can be separated and inserted into a MySQL database with a simple </p> <pre><code>$line = explode("\n", $fileData); </code></pre> <p>and then the values separated with</p> <pre><code>$lineValues = explode(',', $line); </code></pre> ...
<p>If the csv data is in a file, you can just use fgetcsv() as others have pointed out. fgetcsv handles embedded newlines correctly.</p> <p>However if your csv data is in a string (like $fileData in your example) the following method may be useful as str_getcsv() only works on a row at a time and cannot split a whole ...
<p>If you could be guaranteed that each new line beginning with a number is a valid new-line (i.e. not in the middle of a text description) then you could try something like the below:</p> <pre><code>// Replace all new-line then id patterns with new-line 0+id $line = preg_replace('/\n(\d)/',"\n0$1",$line); // Split o...
22,652
<p>How could you calculate the minimum width needed to display a string in X lines, given that text should break on whitespace?</p>
<p>Possible Hint: Perhaps some sort of binary search using Graphics.MeasureString()?</p>
<p><strong>Edit:</strong> Didn't realize you wanted to try and fit the text to a fixed number of lines. This was a tough one to try and solve. This is the best I could come up with and may not be the most elegant, but it seems to work:</p> <pre><code>public SizeF CalculateWidth(Font font, Graphics graphics, int numOfL...
35,335
<p><a href="https://stackoverflow.com/questions/32149/does-anyone-have-a-good-proper-case-algorithm">Using this question</a> as the base is there an alogrithm or coding example to change some text to Pascal or Camel casing.</p> <p>For example:</p> <pre><code>mynameisfred </code></pre> <p>becomes</p> <pre><code>Came...
<p>I found a thread with a bunch of Perl guys arguing the toss on this question over at <a href="http://www.perlmonks.org/?node_id=336331" rel="nofollow noreferrer">http://www.perlmonks.org/?node_id=336331</a>.</p> <p>I hope this isn't too much of a non-answer to the question, but I would say you have a bit of a probl...
<p>The only way to do that would be to run each section of the word through a dictionary.</p> <p>"mynameisfred" is just an array of characters, splitting it up into my Name Is Fred means understanding what the joining of each of those characters means.</p> <p>You could do it easily if your input was separated in some...
5,216
<p>As you may already know, the .NET Framework's <a href="http://msdn.microsoft.com/en-us/library/ms173121.aspx" rel="noreferrer"><em>protected internal</em></a> access modifier works in a strange way: It doesn't mean the class is <em>protected</em> <strong>AND</strong> <em>internal</em>, it says the class is <em>prote...
<p>I have rarely needed to use this access modifier combination as I think that in all but the most extreme circumstances, it's an indicator of poor design. However, sometimes it is necessary to have helper classes like type converters and editors access the method inside your assembly, but only allow derived classes t...
<p>I've used it for internal methods that you wanted to be able to use in a separate name space for unit testing, the unit test name space contained a subclass of the class. which allowed the protected methods to be accessed.</p> <p>That said there is an argument to make everything public for unit testing. </p>
25,134
<p>I'm developing a webapp where the user is given the chance to upload his resume in pdf format. I'm using NHibernate as a data mapper and MS SQL SERVER 2005.</p> <p>I want to be able to save the .pdf file to a given table... any ideas?</p> <p>Thank you very much!</p>
<p>We are doing exactly that with the "original" Java Hibernate3. You just map a byte array property of your persistable class to an column of Type "image".</p> <pre><code>package com.hibernate.pdf.sample; public class TPDFDocument implements java.io.Serializable { private Integer pdfDocumentId; pri...
<p>INSERT INTO Table (DocumentId, PDF) VALUES (newid(), 0x12345667)</p> <p>where the hex constant is the hex-encoded bytestream of the PDF.</p> <p>I'm sure someone can find a better way, but this is obvious to me.</p>
23,435
<p>I'm scouring the internet for a definition of the term &quot;Internal Node.&quot; I cannot find a succinct definition. Every source I'm looking at uses the term without defining it, and the usage doesn't yield a proper definition of what an internal node actually is.</p> <p>Here are the two places I've been mainly l...
<pre><code> I ROOT (root is also an INTERNAL NODE, unless it is leaf) / \ I I INTERNAL NODES / / \ o o o EXTERNAL NODES (or leaves) </code></pre> <p>As the wonderful picture shows, internal nodes are nodes located between the root of the tree and the leaves. Note that the root...
<p>A node which has at least one child.</p>
33,331
<p>Terminals and shells are very powerful but can be complicated to learn, especially to get the best out of them. Does anyone know of a more GUI based command shell that helps a user or displays answers in a more friendly way? I'm aware of IPython, but even the syntax of that is somewhat convoluted, although it's a st...
<p><a href="http://hotwire-shell.org" rel="noreferrer">Hotwire</a> is an attempt to combine the power of the traditional command line interface with GUI elements. So it has a GUI side, and tries to be helpful in suggesting commands, and in showing you possible matches from your history. (While there are keyboard shor...
<p>Check out <a href="http://hotwire-shell.org/" rel="nofollow noreferrer">http://hotwire-shell.org/</a></p>
5,022
<p>How do you determine the collation of a database in SQL 2005, for instance if you need to perform a case-insensitive search/replace?</p>
<p>Why not inherit from <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.usercontrol.aspx" rel="nofollow noreferrer">UserControl</a> to define a custom control that has properties like Text and Image?</p>
<p>You are probably better off using just a generic collection anyways. Bieng Control Collection doesnt really do anything special for it.</p> <pre><code>puclic class MyCollection : Collection&lt;Control&gt; </code></pre>
13,905
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/216007/how-to-determine-total-number-of-open-active-connections-in-ms-sql-server-2005">How to determine total number of open/active connections in ms sql server 2005</a> </p> </blockquote> <p>In Oracle, there's...
<p>Plain old <code>sp_who</code>.</p>
<p>select * from sys.sysprocesses </p> <p>can be used instead of v$session in oracle</p> <p><a href="http://silverlightedworld.blogspot.com/2009/04/vsession-for-oracle-and-sql-server.html" rel="nofollow noreferrer">http://silverlightedworld.blogspot.com/2009/04/vsession-for-oracle-and-sql-server.html</a></p> <p>Rega...
32,175
<p>In PHP 5, what is the difference between using <code>self</code> and <code>$this</code>?</p> <p>When is each appropriate?</p>
<h1>Short Answer</h1> <blockquote> <p>Use <code>$this</code> to refer to the current object. Use <code>self</code> to refer to the current class. In other words, use <code>$this-&gt;member</code> for non-static members, use <code>self::$member</code> for static members.</p> </blockquote> <h1>Full Answer</h1...
<p>According to php.net there are three special keywords in this context: <code>self</code>, <code>parent</code> and <code>static</code>. They are used to access properties or methods from inside the class definition.</p> <p><code>$this</code>, on the other hand, is used to call an instance and methods of any class as...
18,322
<p>I need to have a summary field in each page of the report and in page 2 and forward the same summary has to appear at the top of the page. Anyone know how to do this? Ex:</p> <pre><code>&gt; &gt; Page 1 &gt; &gt; Name Value &gt; a 1 &gt; b 3 &gt; Total 4 &gt; &gt; Page 2 &gt; Name Valu...
<p>Create a new Running Total Field called, for example "RTotal". In "Field to summarize" select "Value", in "Type of summary" select "sum", under "Evaluate" select "For each record". You can then drag this field into your report to use as the "Total" at the bottom of each page.</p> <p>You cannot use this running tota...
<p>I do not understand your question all the way.</p> <p>If you need an overall summary that is repeated, you would need a sub-report that have shown in the report multiple times.</p>
4,550
<p>When writing a switch statement, there appears to be two limitations on what you can switch on in case statements.</p> <p>For example (and yes, I know, if you're doing this sort of thing it probably means your <a href="https://en.wikipedia.org/wiki/Object-oriented_programming" rel="noreferrer">object-oriented</a> (...
<p>This is my original post, which sparked some debate... <strong>because it is wrong</strong>:</p> <blockquote> <p>The switch statement is not the same thing as a big if-else statement. Each case must be unique and evaluated statically. The switch statement does a constant time branch regardless of how ...
<p>I suppose there is no fundamental reason why the compiler couldn't automatically translate your switch statement into:</p> <pre><code>if (t == typeof(int)) { ... } elseif (t == typeof(string)) { ... } ... </code></pre> <p>But there isn't much gained by that.</p> <p>A case statement on integral types allows the co...
6,666
<p>For example, Convert.ToDouble("0.1234567890123456789") = 0.123456789012346</p> <p>What is the maximum number of significant figures? Couldn't find it in the docs.</p>
<p>From <a href="http://msdn.microsoft.com/en-us/library/678hzkk9(VS.71).aspx" rel="nofollow noreferrer">MSDN</a>:</p> <p>Precision: 15-16 digits.</p>
<p><a href="http://en.wikipedia.org/wiki/Double_precision" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Double_precision</a></p> <p>A double only has 64 bits of storage, and some of them are used for the sign and exponent, so there are a limited number of digits (usually 15) for the fractional part. A float ...
28,045
<p>I've been working on a comprehensive build system that performs distributed builds on multiple machines for quite some time now. It correctly handles dependencies and seemed to scale reasonably well, so we've added more projects and more machines, but it looks like it could perform better.</p> <p>The problem I have...
<p>The problem you are trying to solve is equivalent to the classic Job Shop Scheduling problem. Finding an optimal schedule is NP-hard.</p> <p>People have invented lots of heuristics to generate schedules, but which ones are good is highly problem-dependent.</p> <p>A couple of common heuristics are:</p> <ul> <li>S...
<p>At first thought, I'd recommend running a Windows Service on each machine, where one machine also runs the Master service to coordinate the assignments. The Master Service polls each machine for whether or not it is processing an assignment, and if it is not, then begin processing whichever assignment is in the que...
45,612
<p>I am coding a basic traffic light control which will be displayed on the monitor. <p>In that i need an external interrupt (event ) to happen and change the state of the current traffic light. I am trying to do it without any board or external peripheral. <p>Now I think i have the following choices . tell me which i...
<p>You could just make a multithreaded application and have some treads act like interrupts when thay awake.</p> <p>Thread one: Traffic controle Thread two: Simulate traffic approching from east and requesting a change in ligthing, and randomly sleeping from 1 to 60 seconds before awakening again. Thread X use imagina...
<p>Get hold of a copy of <strong>Microsoft® Win32® Programmer's Reference</strong> Help File: <strong><em>Win32.hlp</em></strong></p> <p>Seek <strong>SetTimer</strong> and related functions. This function registers on windows that you want a function to be called after a specific interval (from the moment you're calli...
35,886
<p>I am looking for information on handling search in different ORMs.</p> <p>Currently I am redeveloping some old application in PHP and one of requirements is: make everything or almost everything searchable, so user just types "punkrock live" and the app finds videos clips, music tracks, reviews, upcoming events or ...
<p>I have recently integrated the <a href="http://www.compass-project.org/" rel="nofollow noreferrer">Compass</a> search engine into a Java EE 5 application. It is based on <a href="http://lucene.apache.org/java/docs/index.html" rel="nofollow noreferrer">Lucene Java</a> and supports different ORM frameworks as well as ...
<p>In a Propel 1.3 schema.xml file, you can specify that you'd like all your models to extend a "BaseModel" class that YOU create.</p> <p></p> <p>In that BaseModel, you're going to re-define the save() method to be something like this:</p> <pre><code>public function save(PropelPDO $con = null) { if($this-&gt;get...
4,245
<p>I am starting to work on a hobby project with a <strong>Python</strong> codebase and I would like to set up some form of continuous integration (i.e. running a battery of test-cases each time a check-in is made and sending nag e-mails to responsible persons when the tests fail) similar to <strong>CruiseControl</stro...
<p>We run <a href="http://buildbot.net/trac" rel="noreferrer">Buildbot - Trac</a> at work. I haven't used it too much since my codebase isn't part of the release cycle yet. But we run the tests on different environments (OSX/Linux/Win) and it sends emails — and it's written in Python.</p>
<p>We are using <a href="http://bitten.edgewall.org/" rel="noreferrer">Bitten</a> wich is integrated with trac. And it's python based.</p>
2,295
<p>with jquery, or with simple just javascript, I want to populate a 2nd dropdown from the choice of the first dropdown. The value of the first dropdown is the condition to get rows for the second dropdown.</p> <p>How does the onChange event look like?</p>
<p>there is actually a plugin that does just that ...</p> <p><a href="http://code.google.com/p/jqueryselectcombo/" rel="nofollow noreferrer">http://code.google.com/p/jqueryselectcombo/</a></p>
<p>there is actually a plugin that does just that ...</p> <p><a href="http://code.google.com/p/jqueryselectcombo/" rel="nofollow noreferrer">http://code.google.com/p/jqueryselectcombo/</a></p>
37,527
<p>In a VS2008 web site project, I have a page open in split view. I try to drag an Infragistics web control onto the page's design surface. Nothing happens. I try to drag same onto the htmlz. Dialog box with </p> <blockquote> <p>The operation could not be completed. Invalid formatetc structure. </p> </blockquote> ...
<p>The assembly reference to the control library dll is incorrect/absent in the project's web.config. Add/correct the dll reference to fix.</p>
<p>I have Visual Web Developer 2008 (VWDExpress) and I was having same problem on dragging and dropping Silverlight controls. Based on advise from n8wrl, I closed VWDExpress and deleted all .tbd files from C:\Documents and Settings\\Local Settings\Application Data\Microsoft\VWDExpress\9.0 folder. Started VWDExpress aga...
21,695
<p>So far I have encountered adjacency list, nested sets and nested intervals as models for storing tree structures in a database. I know these well enough and have migrated trees from one to another.</p> <p>What are other popular models? What are their characteristics? What are good resources (books, web, etc) on thi...
<p>A variation is where you use a direct hierarchical representation (ie. parent link in node), but also store a path value.</p> <p>ie. for a directory tree consisting of the following:</p> <pre><code>C:\ Temp Windows System32 </code></pre> <p>You would have the following nodes</p> <pre><code>Key N...
<p>A variation is where you use a direct hierarchical representation (ie. parent link in node), but also store a path value.</p> <p>ie. for a directory tree consisting of the following:</p> <pre><code>C:\ Temp Windows System32 </code></pre> <p>You would have the following nodes</p> <pre><code>Key N...
4,752
<p>I using GWT and have created a login form. I've tried all sorts of ways to get IE7 to prompt to remember the login info but with no success. I thought that maybe this would have worked (but it didn't):</p> <pre><code> TextBox submit = new TextBox(); submit.getElement().setAttribute("type", "submit"); </cod...
<p>You can simply assign values:</p> <pre><code>private TextBox mName = new TextBox(); private PasswordTextBox mPassword = new PasswordTextBox(); mName.setText("username"); mPassword.setText("password"); </code></pre> <p>In your case I would store the values in cookies, and read them out on startup.</p> <pre><code>...
<p>I don't know GWT, but you might need to somehow set an attribute on the form tag -<br> autocomplete="on", which has worked for me on a few occasions. </p> <p>More info here: <a href="http://msdn.microsoft.com/en-us/library/ms533486.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms533486.a...
41,347
<p>I'm currently working on a ray-tracer in C# as a hobby project. I'm trying to achieve a decent rendering speed by implementing some tricks from a c++ implementation and have run into a spot of trouble.</p> <p>The objects in the scenes which the ray-tracer renders are stored in a KdTree structure and the tree's node...
<p>Firstly, if you're using C# normally, you can't suddenly get a null reference due to the garbage collector moving stuff, because the garbage collector also updates all references, so you don't need to worry about it moving stuff around.</p> <p>You can pin things in memory but this may cause more problems than it so...
<p>Is it really prohibitive to store the pair of array reference and index?</p>
5,920
<p>I've been wondering whether there is a good &quot;git export&quot; solution that creates a copy of a tree without the <code>.git</code> repository directory. There are at least three methods I know of:</p> <ol> <li><code>git clone</code> followed by removing the <code>.git</code> repository directory.</li> <li><a hr...
<p>Probably the simplest way to achieve this is with <a href="https://git-scm.com/docs/git-archive" rel="noreferrer"><code>git archive</code></a>. If you really need just the expanded tree you can do something like this.</p> <pre><code>git archive master | tar -x -C /somewhere/else </code></pre> <p>Most of the time t...
<p>i have the following utility function in my .bashrc file: it creates an archive of the current branch in a git repository.</p> <pre><code>function garchive() { if [[ "x$1" == "x-h" || "x$1" == "x" ]]; then cat &lt;&lt;EOF Usage: garchive &lt;archive-name&gt; create zip archive of the current branch into &lt;a...
19,416
<p>I am trying to write an installer (by creating a .vdproj) that will work on both Windows Vista and XP. The only thing I am finding is that when I try to run it on Vista, the files that I include in the installer are installed with Read-only permissions for the Users groups. This is a problem because the applicatio...
<p>The Program Files folder and it's contents are read only for standard users. This is by design, and you'll find that <strong>this is the case on Windows XP as well.</strong> It's just that on windows xp, so many people run with administrator rights all the time that you might get away with it. If you ever want to...
<p>To add some detail to Joel's answer:</p> <ul> <li><p>In Win2K and XP, CSIDL_APPDATA should be used for <strong>per-user, roaming</strong>. In Vista, this is the FOLDERID_RoamingAppData. </p></li> <li><p>In Win2K and XP, CSIDL_LOCAL_APPDATA should be used for <strong>per-user, non-roaming</strong>. In Vista, this is...
37,809
<p>In our code base we have a dependency on the ant version used in eclipse.</p> <p>In the the ant.jar has been set up as a library which the project uses</p> <p>This is a pain when moving versions of eclipse as the Ant plugin folder name changes (although I see it is now just called Ant1.7)</p> <p>Is there a way to...
<p>Your project should not have a dependency on eclipse's version of Ant in the first place, you should keep your own version so as to decouple your project from eclipse. What if a developer or yourself decides to use intelliJ?</p> <p>Although i don't know what the nature of your project is, i would have thought all ...
<p>One possible suggestion would be to :</p> <ul> <li>transform your project into a plugin project (properties on your project / PDE tools / convert Project to Plug-in Projects...) and </li> <li>add to its dependencies the 'ant' required plugin.</li> </ul> <p>That would be easier to manage when you change the version...
33,684
<p>I'm a little confused about how the standard library will behave now that Python (from 3.0) is unicode-based. Will modules such as CGI and urllib use unicode strings or will they use the new 'bytes' type and just provide encoded data?</p>
<p>Logically a lot of things like MIME-encoded mail messages, URLs, XML documents, and so on should be returned as <code>bytes</code> not strings. This could cause some consternation as the libraries start to be nailed down for Python 3 and people discover that they have to be more aware of the <code>bytes</code>/<code...
<p>There will be a two-step dance here. See <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=227041" rel="nofollow noreferrer">Python 3000 and You</a>.</p> <p>Step 1 is to get running under 3.0.</p> <p>Step 2 is to rethink your API's to, perhaps, do something more sensible.</p> <p>The most likely course i...
11,656
<p>How would you write a non-recursive algorithm to compute <code>n!</code>?</p>
<p>Since an Int32 is going to overflow on anything bigger than 12! anyway, just do:</p> <pre><code>public int factorial(int n) { int[] fact = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600}; return fact[n]; } </code></pre>
<pre><code>int fact(int n){ int r = 1; for(int i = 1; i &lt;= n; i++) r *= i; return r; } </code></pre>
28,626
<p>I have a git repository with remote foo.</p> <p>foo is a web app, is contains some files and dirs directly in its root:</p> <pre><code>Rakefile app ... public script </code></pre> <p>My main git repository is a larger system which comprises this web app. I want to pull the commits from foo, but I need the files t...
<p>This answers my question:</p> <p><a href="http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html" rel="nofollow noreferrer">http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html</a></p>
<p>This answers my question:</p> <p><a href="http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html" rel="nofollow noreferrer">http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html</a></p>
33,381
<p>I don't know how to say this but during the print, the printer will randomly have difficulty extruding the filament. I will have to give the filament a <em>boost</em> for it to keep going. Once I done the <em>boost</em>, the extruder keeps going perfectly fine for a while.</p> <p>I am using a Prusa I3 clone bought ...
<p>If you have <a href="http://www.openscad.org" rel="noreferrer">OpenSCAD</a> installed, this shell script will generate 100x100 pixel PNG images for each STL file in your current directory.</p> <pre><code>for i in *.stl; do T=__tmp__<span class="math-container">$i b=`basename $</span>i` echo import\(\"<span cl...
<p>You can use OpenSCAD, as stated in the accepted answer. Here is a version of that script that works for Windows for anyone who needs it, as I did.</p> <pre><code># Change height and width to the desired output image dimensions, in pixels. # The path to openscad.exe may also have to be adjusted based on your instal...
916
<p>I´m not sure if this is really a programming question, but it's related to what I'm doing which is... I'm developing a web site that will have a lot of .domain.com, and based on what contain, the web site will show diffrent content.</p> <p>Anyone knows how to do that? Maybe it requires changes in the DNS server.</...
<p>You need a wildcard DNS entry to point all of those subdomains to the same IP (the one your web server uses). Then sort it out in your application code which site to show based on the host header.</p>
<p>After you have the DNS entries all pointing to the same box, you can use <a href="http://httpd.apache.org/docs/2.0/vhosts/examples.html" rel="nofollow noreferrer">Apache virtual hosting</a> to make them behave and appear as separate web servers, without the overhead of multiple Apache instances.</p>
21,798
<p>I'm writing a web service, and I want to return the data as XHTML. Because it's data, not markup, I want to keep it very clean - no extra <code>&lt;div&gt;</code>s or <code>&lt;span&gt;</code>s. However, as a convenience to developers, I'd also like to make the returned data reasonably readable in a browser. To do s...
<p>It'd be best to wrap all of your elements in label elements, then apply css to the labels. The :before and :after pseudo classes are not completely supported in a consistent way.</p> <p>Label tags have a lot of advantages including increased accessibility (on multiple levels) and more.</p> <pre><code>&lt;label&gt;...
<p>Use javascript. If you're using the jQuery library, try something like this:</p> <pre><code>$("input.a").after("&lt;br/&gt;") </code></pre> <p>Or whatever you need.</p>
9,150
<p>I am trying to write a function that will pull the name of a property and the type using syntax like below:</p> <pre><code>private class SomeClass { Public string Col1; } PropertyMapper&lt;Somewhere&gt; propertyMapper = new PropertyMapper&lt;Somewhere&gt;(); propertyMapper.MapProperty(x =&gt; x.Col1) </code></...
<p>Here's enough of an example of using <a href="http://msdn.microsoft.com/en-us/library/system.linq.expressions.aspx" rel="noreferrer">Expressions</a> to get the name of a property or field to get you started:</p> <pre><code>public static MemberInfo GetMemberInfo&lt;T, U&gt;(Expression&lt;Func&lt;T, U&gt;&gt; express...
<p>I found this very useful.</p> <pre><code>public class PropertyMapper&lt;T&gt; { public virtual PropertyInfo PropertyInfo&lt;U&gt;(Expression&lt;Func&lt;T, U&gt;&gt; expression) { var member = expression.Body as MemberExpression; if (member != null &amp;&amp; member.Member is PropertyInfo) ...
34,513
<p>I have a VB.NET Windows Forms project that at one point paints text directly to onto the form at runtime. Before I paint with the font though, I want to make sure that the font and font-size exists on the user's machine. If they don't, I'll try a few other similar fonts, eventually defaulting with Arial or something...
<p>From an MSDN article titled "How To: Enumerate Installed Fonts", I found this code:</p> <pre> <code> InstalledFontCollection installedFontCollection = new InstalledFontCollection(); // Get the array of FontFamily objects. FontFamily[] fontFamilies = installedFontCollection.Families; </code> </pre>
<p>Arial Bold Italic is unlikely to be a font. It's a subclass of the Arial family.</p> <p>Try keeping it simple and test for 'Arial'.</p>
13,230
<p>.Net contains a nice control called <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.documentviewer.aspx" rel="noreferrer"><code>DocumentViewer</code></a>. it also offers a subcontrol for finding text in the loaded document (that's at least what it is supposed to do).</p> <p>When inserting <...
<p>I had this same problem with FixedDocuments. If you convert your FixedDocument to an XPS document then it works fine.</p> <p>Example of creating an XPS Document in memory from a FixedDocument then displaying in a DocumentViewer. </p> <pre class="lang-cs prettyprint-override"><code>// Add to xaml: &lt;DocumentViewe...
<p>I had trouble with searching text in richtextbox, it was too slow. What I did was crunch the xaml every time I wanted to search. I improved several orders of magnitude.</p> <p>It's a big workaround based in a part of the Chris Anderson's <a href="https://rads.stackoverflow.com/amzn/click/com/0321374479" rel="nofoll...
22,153
<p>What would be the best way to expose certain functionality in a Dotnet VSTO Excel add-in to VBA, without requiring the user to be a local administrator (i.e. no COM registration, <a href="http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework/topic49734.aspx" rel="nofollow noreferrer">no HttpListener</...
<p>If I may interpret your question as broadly as "How do I expose functionality in a .Net assembly to Excel without COM registration" then an excellent solution is to use Excel's XLL interface. Basically one deploys an xll shim and an associated .Net dll. When the xll is loaded it reflects over the dll and exposes the...
<p>Just for reference for future readers: You might also want to have a look to this question:</p> <p><a href="https://stackoverflow.com/questions/1474205/accessing-a-vsto-application-addin-types-from-vba-excel">Accessing a VSTO application-addin types from VBA (Excel)</a></p> <p>and, in particular, to the blog that ...
14,659
<p>I am looking in to ways to enable a site to basically have something like:</p> <p><a href="http://mysite.com/" rel="nofollow noreferrer">http://mysite.com/</a><strong>en-US</strong>/index.aspx`</p> <p>Where the "en-US" can vary by culture..</p> <p>This culture in the URL will then basically set the <code>CurrentU...
<p>Is storing the choice in a cookie out of the question? Nice of you to give the users a choice but why not just default to the users client/web browser settings?</p> <p>If they bookmark a page and have lost the cookie you could fall back to the default and if that is a culture you do not support then fallback furthe...
<p>Just try to add that parameter</p> <pre><code>http://yoursite/yourPage.aspx?lang=en-US </code></pre> <p>If you were utilizing resources files it will work automatically.</p> <p>Good Luck</p>
46,807
<p>When 'val' below is not a <code>bool</code> I get an exception, I believe I can use <code>TryParse</code> but I'm not sure how best to use it with my code below. Can anyone help?</p> <pre><code>checkBox.Checked = Convert.ToBoolean(val); </code></pre> <p>Thanks</p>
<p>The code is as follows to determine whether the string <code>val</code> is a valid Boolean value and use it to set the <code>Checked</code> property if so. You need to decide what action you would take if it does not represent a valid value.</p> <pre><code>bool result; if (bool.TryParse(val, out result)) { // v...
<p>Just posted this same snippet for another question, but here is the code I use across projects for doing a much better job of handling booleans in all their assorted versions:</p> <pre><code>bool shouldCheck; TryParseBool(val, out shouldCheck); checkBox.Checked = shouldCheck; /// &lt;summary&gt; /// Legal values: ...
21,796
<p>For many years I have used two great tools <a href="http://www.compuware.com/products/devpartner/visualc.htm" rel="noreferrer">BoundsChecker</a> &amp; <a href="http://www-01.ibm.com/software/awdtools/purify/win/" rel="noreferrer">Purify</a>, but the developers of these applications have let me down, they no longer p...
<p>Viva64 (<a href="http://www.viva64.com/viva64-tool/" rel="noreferrer">http://www.viva64.com/viva64-tool/</a>) tool provides detection of errors typical of 64-bit Windows applications. Viva64 is a lint-like static analyzer of C/C++ code. Viva64 integrates into Visual Studio 2005/2008 environment and provides user-fri...
<p>I've used bounds checking and other dynamic analysis tools, and while the architectures are different it's the code that you're checking - in theory you could run bounds checking on any backend and the result would be the same - the code either steps outside its bounds or it does not.</p> <p>The only complications ...
7,225
<p>How can I test for the <code>EOF</code> flag in R? </p> <p>For example:</p> <pre><code>f &lt;- file(fname, "rb") while (???) { a &lt;- readBin(f, "int", n=1) } </code></pre>
<p>The <a href="http://wiki.r-project.org/rwiki/doku.php?id=rdoc:base:readlines" rel="noreferrer">readLines</a> function will return a zero-length value when it reaches the EOF.</p>
<p>The <a href="http://wiki.r-project.org/rwiki/doku.php?id=rdoc:base:readlines" rel="noreferrer">readLines</a> function will return a zero-length value when it reaches the EOF.</p>
12,886
<p>We have TFS installed in a US server. We need to login into VPN to access the TFS server. TFS is configured to use with company's domain user account. However my system is part of the domain. Hence I couldn't access the TFS. I have Visual Studio Team System Developer edition. Can someone here help how to access TFS ...
<p>Yes, it's not well documented or publicized as S3. But dude it has CDN support which S3 is lack off (unless you willing to pay extra of course). Bad thing is you can't FTP into Mosso CloudFile, you will either have to upload it through web-based control panel or API. Yet, it's still cheap and worth especially with C...
<p>We use it for all our client sites, from images to podcasts, and it's hand down, the best way to distribute content and make it highly available - especially at this price!</p> <p>cheers</p>
37,659
<p>I had an idea, if I add a python .py file to my C# project, and tag the file with a custom generator that would execute the python file, and treat the output as the result of the code generation, ie. put it into a C# file, that would allow me to do quite a lot of code generation as part of the build process.</p> <p...
<p>OK, I see. Well, as far as I know there isn't any code generator for Python. There is a good introduction on how to roll your own <a href="http://www.drewnoakes.com/snippets/WritingACustomCodeGeneratorToolForVisualStudio/" rel="nofollow noreferrer">here</a>.</p> <p>Actually, that's quite an under-used part of the e...
<p>I don't understand what you are trying to do here. Are you trying to execute a Python script that generates a C# file and then compile that with the project? Or are you trying to compile a Python script to C#?</p>
4,392
<p>I have inherited a poorly written web application that seems to have errors when it tries to read in an xml document stored in the database that has an "&amp;" in it. For example there will be a tag with the contents: "Prepaid &amp; Charge". Is there some secret simple thing to do to have it not get an error parsi...
<p>The problem is the xml is not well-formed. Properly generated xml would list the data like this:</p> <blockquote> <p><code>Prepaid &amp;amp; Charge</code></p> </blockquote> <p>I've fixed the same problem before, and I did it with this regex:</p> <pre><code>Regex badAmpersand = new Regex(&quot;&amp;(?![a-zA-Z]{2,6};|...
<p>You can replace &amp; with <code>&amp;amp;</code></p> <p>Or you might also be able to use <a href="http://en.wikipedia.org/wiki/CDATA" rel="nofollow noreferrer">CDATA</a> sections.</p>
14,777
<p>MS SQL Server 2000</p> <p>I have a column in Table A called Name. I wish to sort the Name field. Many but not all of the records for Name start will KL and are followed by a number (KL 1234, KL 2, KL 323, etc).</p> <h2>Table A</h2> <h2>Name</h2> <p>Able<br> Bravo<br> KL 2<br> KL 323<br> KL 1234<br> Zebra</p> <p...
<p>Try this:</p> <pre><code>Order By Case When Left(name, 2) = 'KL' Then 'KL' + Replace(Str(Cast(replace(name, 'KL', '') as BigInt), 12), ' ', '0') Else name End </code></pre>
<pre><code>ORDER BY CASE WHEN CHARINDEX(' ', name)=0 THEN name ELSE LEFT(name, CHARINDEX(' ', name)) END, CASE WHEN CHARINDEX(' ', name)=0 THEN 0 ELSE CONVERT(BIGINT, SUBSTRING(name, CHARINDEX(' ', name)+1, LEN(name))) END </code></pre> <p>updated wrong closing ) after comment</p...
46,485
<p><strong>Update:</strong> Check out this follow-up question: <a href="https://stackoverflow.com/questions/134581/gem-update-on-windows-is-it-broken"><strong>Gem Update on Windows - is it broken?</strong></a></p> <hr> <p>On Windows, when I do this:</p> <pre><code>gem install sqlite3-ruby </code></pre> <p>I get the...
<p>As Nathan suggests, this does appear to be related to the fact that the latest versions of the sqlite3-ruby and hpricot gems don't appear to have Windows versions. Here's what to do when faced with this situation (note, the name of the gem is automatically wildcarded, so you can type just <em>sql</em> and get a list...
<p>I also ran into this problem. It's worth knowing that the difference between 1.2.3 and 1.2.4 is not significant. Here are the 1.2.4. release notes:</p> <blockquote> <p><strong>Release Name: 1.2.4</strong></p> <p>Notes: This release only updates the generated C file to reflect the compatibility changes...
6,537
<p>I am running into an issue I had before; can't find my reference on how to solve it.</p> <p>Here is the issue. We encrypt the connection strings section in the app.config for our client application using code below:</p> <pre><code> config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.No...
<p>I found a more elegant solution that in my original answer to myself. I found if I just logged in as th euser who orignally installed the application and caused the config file connectionstrings to be encrypted and go to the .net framework directory in a commadn prompt and run </p> <pre><code>aspnet_regiis -pa "Net...
<p>Sounds like a permissions issue. The (new) user in question has write permissions to the app.config file? Was the previous user a local admin or power user that could have masked this problem? </p>
6,349
<p>From Apache, you can use the "mod_jk" module to send HTTP requests to Tomcat using the "AJP" protocol, which is far more efficient that HTTP itself.</p> <p>I want to do the same, but from a Java program. I want to use "AJP" because of its good performances (and Tomcat is not bad after all).</p> <p>Does someone kno...
<p>Doesn't the tomcat-ajp.jar present in %TOMCAT_HOME%/server/lib have the AJP implementation?</p>
<p>Whithout any real idea, but have you looked into Tomcat's source code, yet? Maybe Tomcat doesn't just implement the receiving end of AJP.</p>
18,037
<p>You'd like to call a stored proc on MS SQL that has a parameter type of TIMESTAMP within T-SQL, not ADO.NET using a VARCHAR value (e.g. '0x0000000002C490C8').</p> <p>What do you do?</p> <p>UPDATE: This is where you have a "Timestamp" value coming at you but exists only as VARCHAR. (Think OUTPUT variable on anothe...
<p>Since timestamp is compatible with varbinary the solution will be this in SQL Server 2008:</p> <pre><code>declare @hexstring varchar(max); set @hexstring = '0xabcedf012439'; select CONVERT(varbinary(max), @hexstring, 1); set @hexstring = 'abcedf012439'; select CONVERT(varbinary(max), @hexstring, 2); </code></pre> ...
<p>A timestamp datatype is managed by SQL Server. I've never seen it used anywhere other than as a table column type. In that capacity, the column of type timestamp will give you a rigorous ordinal of the last insert/update on the row in relation to all other updates in the database. To see the most recent ordinal a...
23,210
<p>Below is the command I tried executing, without success:</p> <pre><code>exec('ln -s ' . PLUGIN_DIR . '/.htaccess ' . ABSPATH . '/.htaccess'); </code></pre> <p>When you add a die() at the end, it catches that there's an error:</p> <pre><code>exec('ln -s ' . PLUGIN_DIR . '/.htaccess ' . ABSPATH . '/.htaccess') or d...
<p>You can receive the output result of the <a href="http://www.php.net/function.exec" rel="nofollow noreferrer">exec function</a> by passing an optional second parameter:</p> <pre><code>exec('ln -s ' . PLUGIN_DIR . '/.htaccess ' . ABSPATH . '/.htaccess',$output); var_dump($output); </code></pre>
<p>This in not a direct answer to your question, but is very useful, if you want to know what exactly happened by returned error code.</p> <p>If error code ($res), returned by command:</p> <pre><code>exec('command', $out, $res); </code></pre> <p>was in range 1-2, 126-165, 255, than it was returned by shell (eg. BASH...
44,991
<p>I am a complete beginner trying to develop for FCKeditor so please bear with me here. I have been tasked with developing a custom plugin that will allow users to browse a specific set of images that the user uploads. Essentially the user first attaches images, then uses the FCKeditor to insert those images.</p> <p>...
<p>You don't need the lang directory unless you're planning on supporting multiple languages. But even then, I would get the plugin working in one language first.</p> <p>I would probably put mybrowser.asp in the plugin directory.</p> <p>Here's some code for fckplugin.js to get you started. </p> <pre><code>// Registe...
<p>You might not need to write your own file browser as this functionality is built in. If you check the fckconfig.js file and search for <strong>var _FileBrowserLanguage</strong> you can specify your server language and it should hopefully use the equivalent file in the <strong>editor -> filemanager -> connectors</str...
24,151
<p>when i have a many-to.many relation with nhibernate and let nhibernate generate my db schema, it adds an aditional table that contains the primary keys of the related entities. is it possible to add additional fields to this and access them without having to hassle around with sql manually?</p>
<p>I don't think thats possible. If you are saying that the relation has some state than in essence it is an object in it's own right and should be treated (mapped) as such.</p>
<p>Agree with Jasper. What you are modeling in that case is not a relation but an entity itself, with 1-N and N-1 relations to the other two entities.</p> <p>It is not that NHibernate cannot handle it, it is that you simply cannot model it.</p>
20,102
<p>In a few weeks, we'll be teaching a crash course on C++ for Java programmers straight out of college. They have little or no experience yet with C or C++.</p> <p>Previous editions of this course were just 1 or 2 half-day sessions and covered topics including:</p> <ul> <li>new language features, e.g. <ul> <li>header ...
<p>I can only once again point to <a href="http://www.research.att.com/~bs/new_learning.pdf" rel="nofollow noreferrer">Stroustrup</a> and preach: Don't teach the C subset! It's important, but not for beginners! C++ is complex enough as it is and the standard library classes, especially the STL, is much more important a...
<p>You should take some time on memory management, and especially RAII.</p>
7,096