instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I need to insert some data into a table in Oracle. </p> <p>The only problem is one of the fields is a timestamp(6) type and it is required data. I don't care about what actually goes in here I just need to get the right syntax for an entry so that the database will accept it.</p> <p>I'm using the gui web client to...
<p>I dunno if this helps at all, but in SQL*Plus I did this:</p> <pre><code>create table x ( a timestamp(6)); insert into x values ( current_timestamp ); select * from x; </code></pre> <p>getting me this:</p> <pre><code>T --------------------------------------------------------------------------- 15-OCT-08 02.01.25....
<p>Here are a couple of different TO_TIMESTAMP functions that worked for me...</p> <p>This TO_TIMESTAMP function worked on an INSERT against a column of type TIMESTAMP(6):</p> <pre><code>TO_TIMESTAMP('04/14/2015 2:25:55','mm/dd/yyyy hh24:mi.ss.ff') </code></pre> <p>This TO_TIMESTAMP function worked on an INSERT agai...
25,040
<p>My AS3-heavy project tests fine in the IDE, but some parts don't work in the browser when published. Any ideas what could be causing this?</p>
<p>It might help if you provide some more specific information on what's not working. Can you post a link? Furthermore, are any parts of your project referencing any remote objects? If so, you might want to make sure your remote objects are located where your app expects them to be. You may also need to add a cross...
<p>Cross domain issues?</p> <p>Case sensitivity on a non-windows server? </p> <p>You can always initiate a remote debug with the flash debugger to establish the cause. The docs explain how to do this.</p>
26,677
<p>I'm using <code>ColdFusion</code> to populate a template that includes HTML unordered lists (<code>&lt;ul&gt;</code>s).</p> <p>Most of these aren't that long, but a few have ridiculously long lengths and could really stand to be in 2-3 columns.</p> <p>Is there an HTML, ColdFusion or perhaps JavaScript (I'm accepti...
<p>So I dug up this article from A List Apart <a href="http://www.alistapart.com/articles/multicolumnlists" rel="noreferrer">CSS Swag: Multi-Column Lists</a>. I ended up using the first solution, it's not the best but the others require either using complex HTML that can't be generated dynamically, or creating a lot o...
<p>To output the list into multiple grouped tag you can loop in this fashion.</p> <pre><code>&lt;cfset list="1,2,3,4,5,6,7,8,9,10,11,12,13,14"&gt; &lt;cfset numberOfColumns = "3"&gt; &lt;cfoutput&gt; &lt;cfloop from="1" to="#numberOfColumns#" index="col"&gt; &lt;ul&gt; &lt;cfloop from="#col#" to="#listLen(list)#"...
2,692
<p>We're using Spring/Hibernate on a Websphere Application Server for AIX. On my Windows machine, the problem doesn't occur--only when running off AIX. When a user logs in with an account number, if they prefix the '0' to their login ID, the application rejects the login. In the DB2 table, the column is of numeric t...
<p><h1>SOLUTION</H1></p> <p>A co-worker did some research on Spring updates, and apparently this error was correct in v. 2.5.3:</p> <blockquote> <p>CustomNumberEditor treats number with leading zeros as decimal (removed unwanted octal support while preserving hex)</p> </blockquote> <p>We were using Spring 2.0.5. ...
<p>I don't know much about Java, but this might happen the string is interpreted as octal string because of the leading "0".</p> <p>You can probably work around this using Long.parseLong(a, 10).</p>
37,147
<p>I am doing something like this:</p> <pre><code>#include &lt;signal.h&gt; class myClass { public: void myFunction () { signal(SIGIO,myHandler); } void myHandler (int signum) { /** * Handling code */ } } </code></pre> <p>I am working on Ubuntu, using gcc. ...
<p>The second parameter of signal should be a pointer to a function accepting an int and returning void. What you're passing to signal is a pointer to a <em>member</em> function accepting an int and returning void (its type being <code>void (myClass::*)(int)</code>). I can see three possibilities to overcome this issue...
<p>You can use singleton pattern</p> <pre><code> static MyClass &amp;getInstance() { static MyClass instance; return instance; </code></pre>
44,633
<p>Here is the full error: <code>SqlException: A transport-level error has occurred when receiving results from the server. (provider: Shared Memory Provider, error: 1 - I/O Error detected in read/write operation)</code></p> <p>I've started seeing this message intermittently for a few of the unit tests in my applicati...
<p>I ran into this many moons ago. Bottom line is you are running out of available ports.</p> <p>First make sure your calling application has connection pooling on.</p> <p>If that does then check the number of available ports for the SQL Server.</p> <p>What is happening is that if pooling is off then every call tak...
<p>We saw this in our environment, and traced part of it down to the "NOLOCK" hint in our queries. We removed the NOLOCK hint and set our servers to use Snapshot Isolation mode, and the frequency of these errors was reduced quite a bit.</p>
7,599
<p>A colleague of mine states that <strong>booleans as method arguments are not acceptable</strong>. They shall be replaced by enumerations. At first I did not see any benefit, but he gave me an example.</p> <p>What's easier to understand?</p> <pre><code>file.writeData( data, true ); </code></pre> <p>Or</p> <pre><c...
<p>Boolean's represent "yes/no" choices. If you want to represent a "yes/no", then use a boolean, it should be self-explanatory.</p> <p>But if it's a choice between two options, neither of which is clearly yes or no, then an enum can sometimes be more readable.</p>
<p>It really depends on the exact nature of the argument. If it is not a yes/no or true/false then a enum makes it more readable. But with an enum you need to check the argument or have acceptable default behaviour since undefined values of the underlying type can be passed.</p>
16,450
<p>I'm having some trouble navigating Java's rule for inferring generic type parameters. Consider the following class, which has an optional list parameter:</p> <pre><code>import java.util.Collections; import java.util.List; public class Person { private String name; private List&lt;String&gt; nicknames; publ...
<p>The issue you're encountering is that even though the method <code>emptyList()</code> returns <code>List&lt;T&gt;</code>, you haven't provided it with the type, so it defaults to returning <code>List&lt;Object&gt;</code>. You can supply the type parameter, and have your code behave as expected, like this:</p> <pre...
<p>Since Java 8 this kind of code compiles as expected and the type parameter gets inferred by the compiler.</p> <pre><code>public Person(String name) { this(name, Collections.emptyList()); // Inferred to List&lt;String&gt; in Java 8 } public Person(String name, List&lt;String&gt; nicknames) { this.name = name...
39,458
<p>I know that attributes are extremely useful. There are some predefined ones such as <code>[Browsable(false)]</code> which allows you to hide properties in the properties tab. Here is a good question explaining attributes: <a href="https://stackoverflow.com/questions/20346/c-what-are-attributes">What are attributes i...
<p><code>[DebuggerDisplay]</code> can be really helpful to quickly see customized output of a Type when you mouse over the instance of the Type during debugging. example:</p> <pre><code>[DebuggerDisplay("FirstName={FirstName}, LastName={LastName}")] class Customer { public string FirstName; public string LastN...
<pre><code>// on configuration sections [ConfigurationProperty] // in asp.net [NotifyParentProperty(true)] </code></pre>
17,468
<p>So, I have a penchant for Easter Eggs... this dates back to me being part of the found community of the Easter Egg Archive.</p> <p>However, I also do a lot of open source programming.</p> <p>What I want to know is, what do you think is the best way to SYSTEMATICALLY and METHODICALLY obfuscate code.</p> <p>Example...
<p>In that case, you should use/write an "obfuscator". A program that does the job for you.<br></p> <p>The Salamander Obfuscator can be used to obfuscate .Net programs, but it is more to prevent decompilation, thus not exactly what you need.<br></p> <p>A good place to learn about obfuscation in C is <a href="http://...
<p>The question is how to create seemingly non-obfuscated code in plain sight (open source) without it appearing to perform another function. </p>
15,281
<p>I'm trying to add a custom font as a resource in my application. I have a "CustomFont" directory in the application and all the fonts inside of it are set to "Resource"</p> <pre><code>&lt;Window.Resources&gt; &lt;Style x:Key="Gotham-XLight"&gt; &lt;Setter Property="TextElement.FontFamily" ...
<p>You may want to check the name of the font, you need to specify the name of the font not the name of the file.</p> <p>Double click on the font file and it should show a "Font name:" that's what you want to make sure is specified in your style.</p>
<p>Late reply but worth mentioning. To add a custom font that will apply globally in your window you could add this in your csproj file to include the fonts from the Fonts folder of your project as resources.</p> <pre><code> &lt;ItemGroup&gt; &lt;Resource Include="Fonts\*.ttf" /&gt; &lt;/ItemGroup&gt; </code></pr...
46,750
<p>What is the minimum I need to add to a .NET 2.0 WebSite's web.config to make it .NET 3.5? </p> <p>Visual Studio adds all the config sections and script handlers, but if you aren't using those are they are really necessary?</p> <p>Is there a command line tool to "upgrade" a .NET 2.0 web.config to 3.5?</p>
<p>There is a good description of the 3.5 web.config available here: <a href="https://web.archive.org/web/20211020153237/https://www.4guysfromrolla.com/articles/121207-1.aspx" rel="nofollow noreferrer">https://web.archive.org/web/20211020153237/https://www.4guysfromrolla.com/articles/121207-1.aspx</a></p> <p>The assem...
<p>It depends on which features you want to include. Most of the 3.5 ASP.NET extensions are optional. You will want to include the assembly for System.Core and System.Xml.Linq. You will also to add compiler support for C# 3.0 if you plan to use that in your code behind. If you're deploying to IIS 7 there are HTTP handl...
5,408
<p>What SQL can be used to list the tables, and the rows within those tables in an SQLite database file - once I have attached it with the <code>ATTACH</code> command on the SQLite 3 command line tool?</p>
<p>There are a few steps to see the tables in an SQLite database:</p> <ol> <li><p>List the tables in your database:</p> <pre><code>.tables </code></pre></li> <li><p>List how the table looks:</p> <pre><code>.schema tablename </code></pre></li> <li><p>Print the entire table:</p> <pre><code>SELECT * FROM tablename; </...
<p>The ".schema" commando will list available tables and their rows, by showing you the statement used to create said tables:</p> <pre> sqlite> create table_a (id int, a int, b int); sqlite> .schema table_a CREATE TABLE table_a (id int, a int, b int); </pre>
10,853
<p>After researching on the topic of claims-Based security (or a federated security model). I've been coming across many examples that use <a href="http://en.wikipedia.org/wiki/Windows_CardSpace" rel="nofollow noreferrer">CardSpace</a> as an example. The main article that I read that gave a really great explanation of ...
<p>I think I found my answer :D</p> <p><a href="http://www.theserverside.net/tt/articles/showarticle.tss?id=ClaimsBasedSecurityModel" rel="nofollow noreferrer">http://www.theserverside.net/tt/articles/showarticle.tss?id=ClaimsBasedSecurityModel</a> <a href="http://www.theserverside.net/tt/articles/showarticle.tss?id=C...
<p>The best thing to implement an STS on on the Windows platform is to use <a href="http://en.wikipedia.org/wiki/Active_Directory_Federation_Services" rel="nofollow noreferrer">AD FS</a>.</p> <p>See this blog for details, <a href="http://blogs.msdn.com/vbertocci/archive/2007/11/19/developing-a-minimal-sts-with-adfs-2-...
28,812
<p>In a C++ Windows (XP and NT, if it makes a difference) application I'm working on, I need to get the network name associated with the computer the code is executing on, so that I can convert local filenames from C:\filename.ext to \\network_name\C$\filename.ext. How would I do this?</p> <p>Alternatively, if there's...
<p>You'll want Win32's GetComputerName:</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms724295(VS.85).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms724295(VS.85).aspx</a></p>
<p>I agree with Pascal on using winsock's gethostname() function. Here you go:</p> <pre><code>#include &lt;winsock2.h&gt; //of course this is the way to go on windows only #pragma comment(lib, "Ws2_32.lib") void GetHostName(std::string&amp; host_name) { WSAData wsa_data; int ret_code; char buf[MAX_PATH]...
3,230
<p>I have some Java code that uses curly braces in two ways</p> <pre><code>// Curly braces attached to an 'if' statement: if(node.getId() != null) { node.getId().apply(this); } // Curly braces by themselves: { List&lt;PExp&gt; copy = new ArrayList&lt;PExp&gt;(node.getArgs()); for(PExp e : copy) { ...
<p>The only purpose of the extra braces is to provide scope-limit. The <code>List&lt;PExp&gt; copy</code> will only exist within those braces, and will have no scope outside of them.</p> <p>If this is generated code, I assume the code-generator does this so it can insert some code (such as this) without having to worr...
<p>I think they just define an unnamed level of scope.</p>
29,834
<p>I am trying to understand some assembly.</p> <p>The assembly as follows, I am interested in the <code>testl</code> line:</p> <pre><code>000319df 8b4508 movl 0x08(%ebp), %eax 000319e2 8b4004 movl 0x04(%eax), %eax 000319e5 85c0 testl %eax, %eax 000319e7 7407 je 0x00...
<p>It tests whether <code>eax</code> is 0, or above, or below. In this case, the jump is taken if <code>eax</code> is 0.</p>
<p>we could see the <strong>jg</strong>,<strong>jle</strong> If <code>testl %edx,%edx. jle .L3</code>we could easy find <strong>jle</strong>is suit <code>(SF^OF)|ZF</code>,if %edx is zero ,ZF=1,but if %edx is not zero and is -1,after the testl ,the OF=0,and the SF =1,so the flag =true,that implement jump .sorry ,my ...
17,718
<p>I am considering adding validation on some insert and update statements for MS SQL Server 2005. I want to be able to check the values inserted before it is written into the table - in this particular case, it is an integer field where the data must conform to a rule. So a simple schema could be:</p> <pre><code>([id...
<p>Use constraints for this</p> <p>e.g</p> <pre><code>CREATE TABLE [dbo].[SalesHistory]( [SaleID] [int] NOT NULL, [Product] [char](150) NULL, [SaleDate] [datetime] NULL, [SalePrice] [money] NULL CHECK (SalePrice &gt; 4) ) </code></pre>
<p>Use constraints for this</p> <p>e.g</p> <pre><code>CREATE TABLE [dbo].[SalesHistory]( [SaleID] [int] NOT NULL, [Product] [char](150) NULL, [SaleDate] [datetime] NULL, [SalePrice] [money] NULL CHECK (SalePrice &gt; 4) ) </code></pre>
49,465
<p>How do you update your SQL sever database when installing your product's update? Are there any tools that will integrate with windows installer? My typical schema changes are:</p> <ul> <li>Adding/removing columns</li> <li>Adding/removing tables.</li> <li>Adding views.</li> <li>Adding/alter indexs.</li> </ul>
<p>Not sure about integration with the windows installer, but you might look into Red Gate's <a href="http://www.red-gate.com/products/SQL_Packager/index.htm" rel="nofollow noreferrer">SQL Packager</a></p>
<p><a href="http://www.acresso.com/products/installation/installshield.htm" rel="nofollow noreferrer">InstallShield</a> lets you execute SQL scripts as part of an installation. Not tried it though, just remember it was on the GUI last time I looked!</p>
14,067
<p>a colleague pointed me the other day to <a href="http://jakarta.apache.org/bcel/" rel="nofollow noreferrer">BCEL</a> which , as best I can tell from his explanation and a quick read, a way to modify at run time the byte code. My first thought was that it sounded dangerous, and my second thought was that it sounded ...
<p>It's a bit more low-level than classic monkey patching, and from what I read, the classes already loaded into the VM are not updated. It only supports saving it to class files again, not modifying run time classes.</p>
<p>You might look at it as monkey patching. I prefer not to use it (maybe I never faced a good use case for it?), but be familiar with it (to have an idea how Spring and Hibenrate use it and why).</p>
6,393
<p>What I'd like to do is produce an HTML/CSS/JS version of the following. The gridlines and other aspects are not important. It's more of a question how to do the background databars.</p> <p><a href="https://i.stack.imgur.com/tPLAD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tPLAD.png" alt="a...
<p>Make the bars as background images and position them to show values. eg. with a fixed column width of 100px:</p> <pre><code>&lt;div style="background: url(bg.gif) -50px 0 no-repeat;"&gt;5&lt;/div&gt; &lt;div style="background: url(bg.gif) -20px 0 no-repeat;"&gt;8&lt;/div&gt; </code></pre> <p>If your columns have t...
<p>A javascript-based solution like this <a href="http://slayeroffice.com/code/gradient/" rel="nofollow noreferrer">cross-browser gradient</a> might be a good start.</p> <p>With some DHTML, you can make a <a href="http://slayeroffice.com/code/gradientProgressBar/" rel="nofollow noreferrer">bar with a given length</a>....
36,581
<p>I have a client that thought a highly dynamic ASP.NET application was a very simple sytem, yet to implement it in the manner in which they needed for future grown it has grown to well over 100 different code files.</p> <p>I am looking for a way, most likely with some sort of static code analysis tool to put some nu...
<p>No - SQLite does not support concurrent write access to the same database file. SQLite will simply block one of the transactions until the other one has finished.</p>
<p>Not necessarily. If sqlite3 is compiled with the thread safe macro (check via the <pre>int sqlite3_threadsafe(void)</pre> function), then you can try to access the same DB from multiple threads without the risk of corruption. Depending on the lock(s) required, however, you may or may not be able to actually modify d...
46,312
<p>I have a KTerminalInterface (from kparts) in my qt/kdelib app, and I run a command within it.</p> <p>The problem is: how can I know if the program is terminated? I need to know it because at its end I must reset some variable.</p> <p>Does anyone got a similar problem?!?</p>
<p>It isn't possible to communicate with the process once launched via TerminalInterface in KDE 4, since KonsolePart (which implements TerminalInterface) no longer has processExited() or receivedData() signals. In KDE 4, KonsolePart is for interactive terminal sessions, not for your app to use.</p> <p>In KDE 4, use <...
<p>you might be able to use <a href="http://docs.python.org/library/os.html#os.waitpid" rel="nofollow noreferrer">os.waitpid</a>(-1) to wait for child processes (with another thread if you can't have the main one block).</p>
49,036
<p>Which Computer-aided Software Engineering tools do you use and why? In what ways do they increase your productivity or help you design your programs? Or, in case you do not use CASE tools, what are your reasons for this?</p>
<p>The best CASE tool I had to work with is the <a href="http://www.sparxsystems.com.au/products/ea/index.html" rel="nofollow noreferrer">Enterprise Architect</a> from <a href="http://www.sparxsystems.com.au/" rel="nofollow noreferrer">Sparx</a>.</p> <p>It's lightweight comparing to Rose (easier to buy and cheaper too...
<p>I have used Rational Rose and a few other similar packages in the past. Mostly I have used them for the UML diagram elements and have not gone into the more detailed functionality such as code generation etc.</p> <p>I mostly use them for aiding the design process and clarifying my own ideas. Often I find that, in t...
19,026
<p>Does any one know any good resources for creating Visual Slick macros?</p>
<p>I'd start with the <a href="http://community.slickedit.com/index.php?board=4.0" rel="nofollow noreferrer">official community forum</a> for SlickEdit macros.</p>
<p>This is a great resource to start with. I wrote my first one <a href="http://blog.slickedit.com/2010/04/lets-make-a-macro-part-1-outputting-debug-values/" rel="nofollow">here</a></p>
10,926
<p>I need to replace character (say) <strong>x</strong> with character (say) <strong>P</strong> in a string, but only if it is contained in a quoted substring. An example makes it clearer:</p> <pre><code>axbx'cxdxe'fxgh'ixj'k -&gt; axbx'cPdPe'fxgh'iPj'k </code></pre> <p>Let's assume, for the sake of simplicity, that...
<p>I was able to do this with Python:</p> <pre><code>&gt;&gt;&gt; import re &gt;&gt;&gt; re.sub(r"x(?=[^']*'([^']|'[^']*')*$)", "P", "axbx'cxdxe'fxgh'ixj'k") "axbx'cPdPe'fxgh'iPj'k" </code></pre> <p>What this does is use the non-capturing match (?=...) to check that the character x is within a quoted string. It looks...
<p>Sorry to break your hopes, but you need a push-down automata to do that. There is more info here: <a href="http://en.wikipedia.org/wiki/Pushdown_automaton" rel="nofollow noreferrer">Pushdown Automaton</a></p> <p>In short, Regular expressions, which are finite state machines can only read and has no memory while pus...
16,779
<p>I am having problems manually looping through xml data that is received via an HTTPService call, the xml looks something like this: </p> <pre><code>&lt;DataTable&gt; &lt;Row&gt; &lt;text&gt;foo&lt;/text&gt; &lt;/Row&gt; &lt;Row&gt; &lt;text&gt;bar&lt;/text&gt; &lt;/Row&gt; &lt;/DataT...
<p>The problem lies in this statement</p> <pre><code>event.result.DataTable.Row.length </code></pre> <p><code>length</code> is not a property of <code>XMLList</code>, but a method:</p> <pre><code>event.result.DataTable.Row.length() </code></pre> <p>it's confusing, but that's the way it is.</p> <p><em>Addition:</em...
<p>I would store it in an Xml object and then use its methods to search for the node value you need.</p> <pre><code>var returnedXml:Xml = new Xml(event.result.toString()); </code></pre>
6,219
<p>What do I have to do to convert a DIB to a BMP?</p>
<p>Check the API GdipCreateBitmapFromGdiDib</p> <p>Example: <a href="http://www.codeproject.com/KB/GDI-plus/DIBtoBitmap.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/GDI-plus/DIBtoBitmap.aspx</a></p>
<p><a href="http://www.imagemagick.org/www/formats.html" rel="nofollow noreferrer">Imagemagick's </a>convert function will do this (and many other conversions) for you on the command line. Free, open source, available on all major platforms. This is a great piece of software that should be in anyone's toolbox.</p>
34,249
<p>When developing custom ecommerce solutions, which "off the shelf" .NET based shipping components have you had luck with? </p> <p>It absolutely must give real-time shipping quotes and be easily integrated into a ASP.NET website. Ideally I'd like it to support most of the common US domestic shipping companies (UPS,...
<p>There's <a href="http://www.dotnetship.com/" rel="nofollow noreferrer">.net SHIP</a>, which I haven't used, but I have used their .net CHARGE product with success.</p>
<p>UPS has web services available which are easy to expose via .NET proxies, etc. That's what we have used. For other shippers like DHL, FedEx, and USPS, we have our own estimates based on our own shipping and handling costs.</p> <p>Typically you're going to want to pad their costs with your own costs. </p>
24,711
<p>I would like to update a dll for a server process without stopping the service. How do I do that? A bit like how asp.net automatically picks up new dlls placed in the bin folder.</p>
<p>Asp.Net uses a technique called <a href="http://www.odetocode.com/articles/305.aspx" rel="noreferrer">shadow copy</a></p> <p>If you copy an updated dll into an application’s bin subdirectory, the ASP.NET runtime recognizes there is new code to execute. Since ASP.NET cannot swap the dll into the existing AppDomain ,...
<p>When a process has loaded a dll it is not possible to change it.</p> <p>IIS does not keep a DLL loaded in memory when it is not being used (<a href="http://blogs.msdn.com/david.wang/archive/2006/01/29/HOWTO-Replace-an-ISAPI-DLL-on-a-Live-Server.aspx" rel="nofollow noreferrer">affected by the Cache property</a>) and...
28,023
<p>When attempting to compile my C# project, I get the following error:</p> <pre><code>'C:\Documents and Settings\Dan\Desktop\Rowdy Pixel\Apps\CleanerMenu\CleanerMenu\obj\Debug\CSC97.tmp' is not a valid Win32 resource file. </code></pre> <p>Having gone through many Google searches, I have determined that this is usua...
<p>I don't know if this will help, but from <a href="http://forums.msdn.microsoft.com/en-US/csharplanguage/thread/4217bec6-ea65-465f-8510-757558b36094/" rel="noreferrer">this forum</a>:</p> <blockquote> <p>Add an .ico file to the application section of the properties page, and recieved the error thats been described...
<p>Is this a file you created and added to the project or did it mysteriously show up?</p> <p>You can maybe check your .csproj file and see how it is being referenced (it should be a simple xml file and you can search for CSC97.tmp).</p> <p>Perhaps post the information you find so we can have more details to help sol...
2,865
<p>Can anyone recommend any programmer-friendly (i.e. extensible) frameworks or systems for performing network level packet <a href="http://en.wikipedia.org/wiki/Fuzzing" rel="noreferrer">fuzzing</a>?</p> <p>I'm looking for such a system where I can program in additional packet formats and various ways of breaking tho...
<p>You might be interested in <a href="http://lcamtuf.coredump.cx/afl/" rel="nofollow">American Fuzzy Lop</a> combined with <a href="https://github.com/zardus/preeny" rel="nofollow">Preeny</a>. It's a fuzzer that is quite simple to use and employs genetic algorithms, which in this case means that it's going to detect w...
<p>I know fuzzled is really good as a framework, if you fancy with Perl : <a href="http://www.securiteam.com/tools/5FP0Q1PKUS.html" rel="nofollow noreferrer">http://www.securiteam.com/tools/5FP0Q1PKUS.html</a></p> <p>JborFuzz and most of other fuzzers won't do it since they are not designed as a framework, certainly n...
45,510
<p>I'm using an SqlCommand object to insert a record into a table with an autogenerated primary key. How can I write the command text so that I get the newly created ID when I use the ExecuteScalar() method?</p>
<pre><code>INSERT INTO YourTable(val1, val2, val3 ...) VALUES(@val1, @val2, @val3...); SELECT SCOPE_IDENTITY(); </code></pre> <p>Don't forget the semicolons at the end of each statement.</p>
<p>Straight out of the <a href="http://forums.whirlpool.net.au/forum-replies-archive.cfm/699785.html" rel="nofollow noreferrer">Whirlpool</a>:</p> <blockquote> <p>If you're using MS SQL you can use &quot;SELECT @@IDENTITY as Value&quot; after your insert to get the last ID generated</p> </blockquote> <p>and:</p> <block...
42,842
<p>I am new to C#. I wanted to do a simple program with some type of loops. I wanted my program to loop through the numbers that the user enters and if it is less than a number then write keep guessing,but once they enter the number 25 i wanted it to say Merry Christmas.. Please Help</p> <pre><code>int number; do {...
<p>Try the following: </p> <pre><code>int number = 0; while (number != 25) { Console.WriteLine("Guess a number between 20 through 25"); number = int.Parse(Console.ReadLine()); if (number != 25) Console.WriteLine("Keep guessing"); else Console.WriteLine("Merry Christmas"); } </code></pr...
<pre><code>int number; do { Console.WriteLine("Guess a number between 20 through 25"); number = int.Parse(Console.ReadLine()); } while (number != 25); Console.WriteLine("Merry Christmas"); </code></pre> <p>Would be correct if you want them to be able to enter numbers higher than 25.</p>
37,119
<p>What do you think of <a href="http://quagga.net" rel="nofollow noreferrer">Quagga</a> compared to XORP as a dynamic software routing engine? What are the technical merits of each engine comparatively? Additionally, what do most people think of them from a programming view. Who has manipulated networks using these en...
<p>The following does not answer your question completely, but the Vyatta open source routers and the OpenSolaris customer gateway software for Amazon VPC both use quagga to implement BGP support.</p> <p>From <a href="http://en.wikipedia.org/wiki/XORP" rel="nofollow noreferrer">the wikipedia entry for XORP</a>,</p> <...
<blockquote> <p>What do you think of Quagga compared to XORP as a dynamic software routing engine? </p> </blockquote> <p>It is one of many options, but not particularly of very much use to you based upon your questions/information that you posted here. Have you tried looking into some of the alternatives such as (no...
10,697
<p>What tools are available to encrypt or password-protect a file stored on the IFS?</p> <p>*integrated file-system, accessible from Windows</p>
<ol> <li>You could setup object security so only certain users can view the file.</li> <li>There are encryption tools available for purchase. There is also some built-in APIs for encrypting. </li> </ol> <p>Here are some resources to look into:</p> <ol> <li><a href="http://publib.boulder.ibm.com/infocenter/iseries/v5r...
<p>You can set the authority to the file so only users in one group have access to it. I think its option 9 I don't have access to a iseries at this moment.</p>
25,020
<p>I want to be able to list only the directories inside some folder. This means I don't want filenames listed, nor do I want additional sub-folders.</p> <p>Let's see if an example helps. In the current directory we have:</p> <pre><code>&gt;&gt;&gt; os.listdir(os.getcwd()) ['cx_Oracle-doc', 'DLLs', 'Doc', 'include', ...
<p>Filter the result using os.path.isdir() (and use os.path.join() to get the real path):</p> <pre><code>&gt;&gt;&gt; [ name for name in os.listdir(thedir) if os.path.isdir(os.path.join(thedir, name)) ] ['ctypes', 'distutils', 'encodings', 'lib-tk', 'config', 'idlelib', 'xml', 'bsddb', 'hotshot', 'logging', 'doc', 'te...
<pre><code>-- This will exclude files and traverse through 1 level of sub folders in the root def list_files(dir): List = [] filterstr = ' ' for root, dirs, files in os.walk(dir, topdown = True): #r.append(root) if (root == dir): pass elif filterstr in root: ...
17,068
<p>A while ago I noticed I don't have a magnifying-glass next to my datatables. I used to have it, and somehow, sometime, it disappeared...<br> Has anyone seen this happen? Do you know how to help me view my datatables again? </p> <p><strong>Update:</strong> I'm still clueless about this. Could anyone point me in som...
<p>I was really bothered by the problem, so I turned to Microsoft support, and they solved my problem! The short solution is that apparently one of the DLL's in the My Documents\Visual Studio 2005\Visualizers folder was corrupted. I deleted all the contents of the folder, and the visualizer came back.<br> The long answ...
<p>I tried everything in this post but nothing worked for me. I am running Windows 7 64-bit. Eventually I was able to find a solution in <a href="https://stackoverflow.com/questions/8408234/visual-studio-dataset-and-datatable-visualizer-not-working-in-watch-window/8448629#8448629">this post</a></p>
29,593
<p>I'm attempting to use an existing CAS server to authenticate login for a Perl CGI web script and am using the <a href="http://search.cpan.org/dist/AuthCAS" rel="nofollow noreferrer">AuthCAS</a> Perl module (v 1.3.1). I can connect to the CAS server to get the service ticket but when I try to connect to validate the...
<p>As usually happens when I post questions like this, I found the problem. It turns out the <a href="http://search.cpan.org/dist/Crypt-SSLeay" rel="nofollow noreferrer">Crypt::SSLeay</a> module was not installed or at least not up to date. Of course the error messages didn't give me any clues. Updating it and all t...
<p>Well, from the <a href="http://search.cpan.org/src/OSALAUN/AuthCAS-1.3.1/lib/AuthCAS.pm" rel="nofollow noreferrer">module source</a> it looks like that IO::Socket error is coming from get_https2</p> <pre><code>[...] unless ($ssl_socket) { $errors = sprintf "error %s unable to connect https://%s:%s/\n",&amp;IO::...
4,645
<p>The title is self explanatory. Is there a way of directly doing such kind of importing?</p>
<p>The .BAK files from SQL server are in Microsoft Tape Format (MTF) ref: <a href="http://www.fpns.net/willy/msbackup.htm" rel="noreferrer">http://www.fpns.net/willy/msbackup.htm</a></p> <p>The bak file will probably contain the LDF and MDF files that SQL server uses to store the database.</p> <p>You will need to use...
<p>I highly doubt it. You might want to use DTS/SSIS to do this as Levi says. One think that you might want to do is start the process without actually importing the data. Just do enough to get the basic table structures together. Then you are going to want to change around the resulting table structure, because wh...
18,902
<p>I need to create a function that will produce a balloon popup in the taskbar using javascript. </p> <p>Is it possible? Whats the shortest and easiest way to do this?</p> <p>or else what will be the available method.. </p> <p>Thanks.</p>
<p>The closest you could get is to make one fixed to the bottom of the viewport of the browser. You could tailor it to appear as though it were part of the windows chrome, but this does tend to annoy users, who don't appreciate attempts to 'fool' them into believing a dialogue/popup/whatever is coming from their OS whe...
<p>Impossible from a browser. And a good thing.</p>
31,073
<p>I was reading the example chapter from <a href="http://www.manning.com/rahien/" rel="nofollow noreferrer">the book by Ayende</a> and on the website of <a href="http://boo.codehaus.org/" rel="nofollow noreferrer">the Boo language</a> I saw a reference to the <a href="http://specter.sourceforge.net/" rel="nofollow nor...
<p>Create one Message table, containing a unique MessageId and the various properties you need to store for a message.</p> <pre><code>Table: Message Fields: Id, TimeReceived, MessageDetails, WhateverElse... </code></pre> <p>Create two link tables - QuoteMessage and JobMessage. These will just contain two fields each,...
<p>Why not just have both QuoteId and JobId fields in the message table? Or does a message have to be regarding either a quote or a job and not both?</p>
3,999
<p>Recently I wrote a function to generate certain sequences with nontrivial constraints. The problem came with a natural recursive solution. Now it happens that, even for relatively small input, the sequences are several thousands, thus I would prefer to use my algorithm as a generator instead of using it to fill a li...
<pre><code>def getPermutations(string, prefix=""): if len(string) == 1: yield prefix + string else: for i in xrange(len(string)): for perm in getPermutations(string[:i] + string[i+1:], prefix+string[i]): yield perm </code></pre> <p>Or without an accumulator:</p> <pr...
<p>The interior call to getPermutations -- it's a generator, too.</p> <pre><code>def getPermutations(string, prefix=""): if len(string) == 1: yield prefix + string else: for i in range(len(string)): getPermutations(string[:i]+string[i+1:], prefix+string[i]) # &lt;----- </code></...
30,926
<p>I'm not sure whether I'm asking the question correctly, but I've been told SQL Server cannot run on a Novell server. Is this true? If yes, why not?</p>
<p>NOW I see your problem! Sorry dude!</p> <p>Yes, VERY easy. Kinda.</p> <p>SQL Server used to be able to talk IPX (the netware protocol) but I think Netware will now talk TCPIP, and you can run IPX and TCP/IP on the same network without an issue - windows clients can run both at the same time, 99% of routers handle ...
<p>The core issue is how are you authenticating to the SQL database. If you have an Active Directory tree, and an eDirectory you can easily link the two via Novell Identity Manager, which will synchronize users, groups, etc (any object you care to map between the two systems) as well as passwords.</p> <p>Thus the sam...
5,206
<p>Observing one year of estimations during a project I found out some strange things that make me wonder if evidence based scheduling would work right here?</p> <ul> <li>individual programmers seem to have favorite numbers (e.g. 2,4,8,16,30 hours) </li> <li>the big tasks seem to be underestimated by a fix value (abou...
<ul> <li>Yes, your observations are exatly the sort of problems EBS is designed to solve.</li> <li>Yes, it's important to break bigger tasks down. Shoot for 1-2 day tasks, more or less. <ul> <li>If you have things estimated at under 2 hrs, see if it makes sense to group them. (It might not -- that's ok!)</li> <li>If...
<p>"So, is it really a good idea to let the programmers break down the 30 hours task down to 4 or 2 hours steps during estimations? Won't this raise the standard deviation? (Ok, let them break it down - but perhaps after the estimations?!)"</p> <p>I certainly don't get this question at all.</p> <p>What it sounds like...
38,517
<p>I am working on a build system. The build system posts the results as a zip file in a directory. Unfortunately I have no easy way to know the name of the zip file, because it is timestamped. For the next operation, I must decompress this zip file to some specific location and then do some more file operations.</p...
<p>This should do it:</p> <pre><code>FOR /F usebackq %%i IN (`DIR /B /O-D *.ZIP`) DO UNZIP %%i &amp;&amp; GOTO DONE || GOTO DONE :DONE </code></pre> <p>This works as follows:</p> <ul> <li><code>DIR /B /O-D *.ZIP</code> lists all ZIP files in reverse date order in a "bare" - i.e. name only - format.</li> <li><code>FO...
<p>Why use bat files when you have powershell or console applications?</p>
21,576
<p>what's the easiest way to bulk load my iTunes library xml into an existing SQL Server database?</p>
<p>bcp with xml flag.</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms162802.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms162802.aspx</a></p> <p>It really depends how you want it in there and what you're purposes are, which you haven't explained.</p>
<p>I would recommend looking at the iTunes COM interface. There is an C# SDK that is straightforward to use and the documentation is good. You can download it here: <a href="http://developer.apple.com/sdk/itunescomsdk.html" rel="nofollow noreferrer">SDK</a></p>
36,689
<p>I have an ASP.NET application. Basically the delivery process is this one :</p> <ul> <li>Nant builds the application and creates a zip file on the developer's computer with the application files without SVN folders and useless files. This file is delivered with a Nant script.</li> <li>The zip and nant files are cop...
<p>You need to run the CACLS program in windows to grant permissions to files and folders. From Nant, you can do this with the EXEC task.</p> <p>Try a tag block like:</p> <pre><code>&lt;exec program="cacls"&gt; &lt;arg value="*" /&gt; &lt;arg value="/G IIS_WPG:F" /&gt; &lt;/exec&gt; </code></pre>
<p>We ended up writing our own task for this with some fairly straight forward code:</p> <pre><code>[TaskName("addusertodir")] public class AddUserToDirectorySecurity : Task { [TaskAttribute("dir", Required=true)] public string DirPath { get; set; } [TaskAttribute("user", Required=true)] public string...
28,879
<p>Why would IE 7 display HTTP Error "Bad request" 400 on the same page that Firefox loads without complaining?</p>
<p>When you get a message like this turn off friendly HTTP error messages in IE. To do this go to Tools -> Internet Options -> Advanced. Uncheck show friendly HTTP error messages. Once you have done this you should get a more detailed message which will point you to the real problem. </p> <p>Do you have a URL that you...
<p>Perhaps you're experiencing an <a href="http://blogs.msdn.com/ie/archive/2008/04/23/what-happened-to-operation-aborted.aspx" rel="nofollow noreferrer" title="IE7 bug">IE7 bug</a> <a href="http://weblogs.asp.net/infinitiesloop/archive/2006/11/02/Dealing-with-IE-_2600_quot_3B00_Operation-Aborted_2600_quot_3B002E00_-Or...
48,230
<p>I am writing a very specialized app in C# that floats as a mostly transparent window over the entire desktop. I want to be able to create and pass mouse events to applications behind mine, and have them appear to operate "normally", responding to those events. It would also be preferable if the window manager could ...
<p>After looking at System hooks and other low level solutions I found a much simpler method.</p> <p>First, set the TransparencyKey and BackColor of the form to be the same. This didn't make any visual difference to me as my form was visually transparent already, but this will help in letting mouse events through.</p>...
<p>If you disable the control and return you're able to pass the MouseDown event to the parent.</p>
20,912
<p>I purchased a (very) low tier printer a while back, and now I am looking to start upgrading. First on my list is to upgrade the controller<sup>1)</sup>.</p> <p>My initial plan was to upgrade to an Arduino Mega with a RAMPS 1.4 running Marlin, but as I started to try to find a RAMPS 1.4 board I started questioning m...
<p>If you own a Raspberry Pi , you may first want to try Klipper firmware. This firmware does the heavy lifting on the RPi itself and sends commands to the printer board via USB. </p> <p>My Ender 3 pro works much better with this firmware. </p>
<p>As per <a href="https://reprap.org/wiki/RAMPS_1.6" rel="nofollow noreferrer">https://reprap.org/wiki/RAMPS_1.6</a>,</p> <blockquote> <p>The RAMPS 1.6 is the second RAMPS iteration released by BIQU/BIGTREETECH. It replaces the original green power connector with a pair of screw terminals, adds a larger heatsink over ...
1,587
<p>I am working on a web application that is designed to display a bunch of data that is updated periodically with AJAX. The general usage scenario would be that a user would leave it open all day and take a glance at it now and then.</p> <p>I am encountering a problem where the browsers memory footprint is growing ...
<p>The biggest thing you can watch out for is events, and how you assign them.</p> <p>For instance, take this scenario (since you haven't provided one):</p> <pre><code>&lt;div id="ajaxResponseTarget"&gt; ... &lt;/div&gt; &lt;script type="text/javascript"&gt; $(someButton).observe('click', function() { ...
<p>I may be wrong but it sounds like you are creating closures around the response object. Each response object will be different which results in an increased memory footprint.</p>
34,807
<p>The error happens trying to do an insert from a stored proc. I tried running DBCC CHECKDB as suggested by the kb article that Jonathan Holland suggested and it returned with the all clear.</p>
<p>Bummer dude.</p> <p><a href="http://support.microsoft.com/kb/828337" rel="nofollow noreferrer">http://support.microsoft.com/kb/828337</a></p>
<p>Bummer dude.</p> <p><a href="http://support.microsoft.com/kb/828337" rel="nofollow noreferrer">http://support.microsoft.com/kb/828337</a></p>
18,687
<p>I'm responsible for some test database servers. Historically, too many other poeple have access to them. They run on <code>SQL Server 2005</code>. </p> <p>I've been writing queries and wrapping them in scripts so I can run a regular audit of rights. Finding out which users had Administrator rights on the server...
<p>Check out this msdn reference article on <a href="http://msdn.microsoft.com/en-us/library/ms189802.aspx" rel="nofollow noreferrer">Has_Perms_By_Name</a>. I think you're really interested in examples D, F and G</p> <hr> <p>Another idea... I fired up SQL profiler and clicked on the ObjectExplorer->Security->Users. ...
<pre><code> select * from Master.dbo.syslogins l inner join sys.sysusers u on l.sid = u.sid </code></pre> <p>This will get you what users are mapped to which logins within a single database.</p>
9,180
<p>Working with an Oracle 9i database from an ASP.NET 2.0 (VB) application using OLEDB. Is there a way to have an insert statement return a value? I have a sequence set up to number entries as they go into the database, but I need that value to come back after the insert so I can do some manipulation to the set I jus...
<p>Some possibilities:</p> <p>1) Use the RETURNING clause:</p> <pre><code>INSERT INTO emp (empno, ename) VALUES (emp_seq.NEXTVAL, 'ANDREWS') RETURNING empno INTO :variable; </code></pre> <p>2) Use the sequence CURRVAL:</p> <pre><code>INSERT INTO emp (empno, ename) VALUES (emp_seq.NEXTVAL, 'ANDREWS'); SELECT emp_seq...
<p>If this value is the key the database creates, you've ran into a good example why you should use UUIDs as your table key, and generate them in code.</p> <p>This method will give you faster performance in your setup.</p>
34,032
<p>For the umpteenth time my laptop just shut down in the middle of my game because my power cable had disconnected without me noticing it.</p> <p>Now I want to write a little C# program that detects when my power cable disconnects and then emits a nice long System beep. What API could I use for that?</p>
<p>This should be trivial to implement using the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.systeminformation.powerstatus.aspx" rel="noreferrer">SystemInformation.PowerStatus</a> property. And even though that lives in Windows.Forms, it should be perfectly usable from a system service.</p> <...
<p>This may very much depend on your exact operating system. Here are some calls for windows XP, I am sure you can find the Vista equivalents:</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms704147(VS.85).aspx" rel="nofollow noreferrer" title="MSDN link">http://msdn.microsoft.com/en-us/library/ms704147(VS.85...
45,267
<p>I have an Ender 3 pro. In my country electricity outage is an issue, though it comes back pretty instantaneously, when I hit the resume button on the Ender 3 pro after heating the hot end and the bed when the hot end lifts the Y-axis or X-axis shifts a little bit, I do not understand why as when there is no power ou...
<p>Not sure on your exact firmware, but it could be that it is using a <a href="https://marlinfw.org/docs/gcode/M413.html" rel="nofollow noreferrer">M413 power loss recovery</a> rather than a power loss interrupt pin. Possible you might be able to change this with your current firmware, but worst case you could install...
<p>you'll need a UPS with EMI filter. I had this same issue and I opt to a regular desktop UPS and the problem was still there. So, I connected a EMI filter and it worked.</p>
2,095
<p>I want to put a <code>Canvas</code> with an image in my window, and then I want to <em>pack</em> widgets on top of it, so the Canvas acts as a background. </p> <p>Is it possible to have two states for the <code>pack</code> manager: one for one set of widgets and another for another set?</p>
<p>The answer to your specific question is no. You can't have two states or otherwise use pack two different ways in the same parent. </p> <p>However, what I think you want to accomplish is simple. Use the built-in features of the canvas to create an image item that is part of the canvas, then pack things into the can...
<p>Not without swapping widget trees in and out, which I don't think can be done cleanly with Tk. Other toolkits can do this a little more elegantly.</p> <ul> <li>COM/VB/MFC can do this with an ActiveX control - you can hide/show multiple ActiveX controls in the same region. Any of the containers will let you do thi...
13,742
<p>Is there a way to 'pre-build' a snippet of HTML before adding it to the DOM?</p> <p>For example:</p> <pre><code>$mysnippet.append("&lt;h1&gt;hello&lt;/h1&gt;"); $mysnippet.append("&lt;h1&gt;world&lt;/h1&gt;"); $("destination").append($mysnippet); </code></pre> <p>where <strong>$mysnippet</strong> doesnt exist in ...
<p>Yes pretty much exactly how you have done it</p> <p>Some extension of this...</p> <pre><code>$('&lt;div&gt;').attr('id', 'yourid').addClass('yourclass').append().append()... </code></pre> <p>and then finally</p> <pre><code>.appendTo($("#parentid")); </code></pre>
<p>Sure, just build them as a string:</p> <pre><code>$mysnippet = "&lt;h1&gt;hello&lt;/h1&gt;"; $mysnippet = $mysnippet + "&lt;h1&gt;world&lt;/h1&gt;"; $("destination").append($mysnippet); </code></pre>
43,774
<p>Here is the sample code for my accordion:</p> <pre><code>&lt;mx:Accordion x="15" y="15" width="230" height="599" styleName="myAccordion"&gt; &lt;mx:Canvas id="pnlSpotlight" label="SPOTLIGHT" height="100%" width="100%" horizontalScrollPolicy="off"&gt; &lt;mx:VBox width="100%" height="80%" paddingTop="2" ...
<p>Thanks, I got it working using <a href="http://code.google.com/p/flexlib/" rel="nofollow noreferrer">FlexLib</a>'s CanvasButtonAccordionHeader.</p>
<p>You will have to create a custom header renderer, add a button to it and position it manually. Try something like this:</p> <pre><code>&lt;mx:Accordion&gt; &lt;mx:headerRenderer&gt; &lt;mx:Component&gt; &lt;AccordionHeader xmlns="mx.containers.accordionClasses.*"&gt; &lt;mx:S...
3,274
<p>I use <em>Eclipse 3.3</em> in my daily work, and have also used <em>Eclipse 3.2</em> extensively as well. In both versions, sometimes the Search options (Java Search, File Search, etc) in the menu get disabled, seemingly at random times. However, with <kbd>Ctrl</kbd>+<kbd>H</kbd>, I am able to access the search fu...
<p>window > close all perspective works for me.</p>
<p>I had this problem too. It appeared when I installed the m2eclipse plugin.</p> <p>I had not found a solution, but you can use <kbd>Ctrl</kbd>+<kbd>H</kbd> shortcut instead. And you can navigate between tabs with <kbd>Ctrl</kbd>+<kbd>PgDown</kbd> or <kbd>Ctrl</kbd>+<kbd>PgUp</kbd> keys.</p> <p>I've uninstalled the ...
16,118
<p>Something's slowing down my Javascript code in IE6 to where there's a noticeable lag on hover. It's fine in FF, so using firebug isn't that helpful. What tools are out there to help debug this in IE?</p> <p><strong>A little more info:</strong> I don't think there's actually any JS running on the objects that I'm mo...
<p>Just a tip of what that "something" could be...</p> <p><strong>String concatenation</strong> in IE is (or at least was when I <a href="http://forums.thedailywtf.com/forums/p/8931/169331.aspx" rel="noreferrer">tested</a>) very slow. Opera finished after 0.2s, Firefox after 4.1s and Internet Explorer 7 still hadn’t f...
<p>The lag could also be from a DOM update. When IE needs to re-render a page due to a DOM change, it can be noticeably slower than Firefox. Typically the cursor will freeze when this happens.</p>
38,501
<p>Should we really close this question: <a href="https://3dprinting.stackexchange.com/questions/10200/3d-printer-part-clones-from-china-legality">3d printer part clones from china - legality</a>..? </p> <p>Are legal questions on topic? We have a legal section in the <a href="https://3dprinting.meta.stackexchange.com...
<p><strong>I say allow them.</strong> </p> <p>To let you know what's out there, I work at <a href="http://hyrel3d.com" rel="nofollow noreferrer">Hyrel</a>. </p> <p>Our printers can take <a href="https://www.youtube.com/watch?v=B0lvN-aPYHI" rel="nofollow noreferrer">spindle (milling) heads and additional axes</a>, and...
<p>This is a tricky one, as 3d printers are starting to be bundled with lasers. Note those kits will totally blind you. 3d printers are being bundled with everything, really if you look at the things <a href="http://diabasepe.com/" rel="nofollow noreferrer">http://diabasepe.com/</a> is making. (Cool guys btw)</p> <p>H...
67
<p>Suppose someone is building you a CMS (Content Management System) from scratch. What are the most important features to include and why?</p>
<ul> <li>security - <a href="http://www.owasp.org/index.php/Top_10_2007" rel="noreferrer">OWASP Top 10</a></li> <li>user management & user roles</li> <li>action and view permissions</li> <li>content versioning and audit</li> <li>some form of workflow and notifications</li> <li>i18n support on literals and object versio...
<p>When working with clients, I often heard a number of requirements that, in my opinion, had little to do with what a modern CMS really needs. Far too often emphasis was on features that should have been in the domain of template designers, such as support for responsive design (whatever that really means), the abilit...
49,834
<p>As I build *nix piped commands I find that I want to see the output of one stage to verify correctness before building the next stage but I don't want to re-run each stage. Does anyone know of a program that will help with that? It would keep the output of the last stage automatically to use for any new stages. I us...
<p>Use 'tee' to copy the intermediate results out to some file as well as pass them on to the next stage of the pipe, like so:</p> <pre><code>cat /var/log/syslog | tee /tmp/syslog.out | grep something | tee /tmp/grep.out | sed 's/foo/bar/g' | tee /tmp/sed.out | cat &gt;&gt;/var/log/syslog.cleaned </code></pre>
<p><code>tee</code>(1) is your friend. It sends its input to both the specified file and stdout. </p> <p>Stick it between your pipes. For example:</p> <pre><code>ls | tee /tmp/out1 | sort | tee /tmp/out2 | sed 's/foo/bar/g' </code></pre>
8,921
<p>Is there an equivalent of svn's blame for Perforce on the command line? <code>p4 annotate</code> doesn't display usernames -- only changeset numbers (without ancestor history!).</p> <p>I currently have to track code back through ancestors and compare against the filelog, and there just has to be an easier way -- ma...
<p>I'm not overly familiar with the blame command, but I assume that you are looking for who changes a particular line of code. The easiest way is to use Perforce's 'time lapse view' available from both p4win and p4v.</p> <p>This tool uses annotate and some other commands to give you a view of the code line over time...
<p>@alanw123: p4pr is close to what I'm looking for, but it doesn't cross branch boundaries:</p> <pre><code>last if $type eq 'branch'; </code></pre> <p>That was the main problem I had when I tried writing my own utility -- you can't (easily) tell how the lines map back to the file that was branched from.</p>
8,169
<p>I'm trying to draw a graph on an ASP webpage. I'm hoping an API can be helpful, but so far I have not been able to find one. </p> <p>The graph contains labeled nodes and unlabeled directional edges. The ideal output would be something like <a href="http://en.wikipedia.org/wiki/Image:6n-graf.svg" rel="noreferrer">th...
<p>Definitely <a href="http://graphviz.org" rel="nofollow noreferrer">graphviz</a>. The image on the wikipedia link you are pointing at was made in graphviz. From its description page the graph description file looked like this:</p> <pre><code>graph untitled { graph[bgcolor="transparent"]; node [fontname="Bits...
<p>You might be able to pull this off with <a href="http://code.google.com/apis/chart/" rel="nofollow noreferrer">Google's Chart API</a>. It is very easy to get started with.</p>
9,467
<p>I am trying to get simple jQuery to execute on my Content page with no luck below is what I am trying to do:</p> <pre><code>&lt;asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server"&gt; &lt;script src="../../Scripts/jquery-1.2.6.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script t...
<p>It may be that the JQuery file can't be found, try this for the script reference:</p> <pre><code>&lt;script src="&lt;%= Url.Content ("~/Scripts/jquery-1.2.6.js") %&gt;" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>The Url.Content will build the correct path regardless of whether the app is running in...
<p>Try putting the javascript references in your Master Page. Then you don't have to worry about attempting to load the scripts multiple times.</p>
48,564
<p>everyone.</p> <p>I'm a relative newcomer to 3D printing, so I don't know what constitutes an unacceptably bad spool of filament.</p> <p>About 1/6 of the way into a roll of PETG (and maybe 4 hours into a 6-hour print), an over/under wrap brought things to a screeching halt. I aborted the print, then snipped the fil...
<p>Filament should come off of the roll without overlapping itself. That being said depending on what you paid for it would determine if you should complain. Normally you get what you pay for. If you paid \$10 for it, I would think that is why it was so cheap, but if you paid >\$25 it should be nice stuff.</p>
<p>Knot happens when you loosen the filament yourself and then leave it like that or try to manually re-spool it. To avoid this kind of situation as well as the curly filament coming off the spool and getting tangled there, try to not loosen it and also build or print a "spool guide" for your 3d printer: <a href="http:...
194
<p>This is a program I'm writing (myself as opposed to copying someone else's and thus not learning) as part of the ObjectiveC and Cocoa learning curve. I want to draw simple shapes on a NSView (limiting it to ovals and rectangles for now). The idea is that I record each NSBezierPath to an NSMutableArray so I can also ...
<p>You said your init method was:</p> <pre><code>-(void)init { [super init]; //set default color = black toolColor.rd=1.0; toolColor.grn=1.0; toolColor.blu=1.0; toolColor.alp=1.0; //set default size toolSize=0.8; //set default toolType toolType=0; //oval NSLog(@"Init %@",self); } </code></pre> <p>This is <strong><em>...
<p>What do you mean by “crash”?</p> <p>Does anything appear in the Debugger Console (⇧⌘R)?</p> <p>Does a stack trace appear in the Debugger window?</p> <p>If there's a stack trace, where in your code does it crash?</p>
42,084
<p>I need a way to build C++ code from UML diagrams and vice versa. </p> <p>Should be simple too hopefully. I don't mind paying too much.</p>
<p>You could try <a href="http://www.sparxsystems.com.au/products/ea/index.html" rel="nofollow noreferrer">Sparx Enterprise Architect</a> but the code quality would be average, not excellent.</p> <p>I am not aware of any great automatic code generators for C++</p> <p>Prices start from $135</p>
<p>Visio also supports this.</p>
26,176
<p>We are deciding the naming convention for tables, columns, procedures, etc. at our development team at work. The singular-plural table naming <em>has already been decided</em>, we are using singular. We are discussing whether to use a prefix for each table name or not. I would like to read suggestions about using a ...
<p>I prefer prefixing tables and other database objects with a short name of the application or solution.</p> <p>This helps in two potential situations which spring to mind:</p> <ol> <li><p>You are less likely to get naming conflicts if you opt to use any third-party framework components which require tables in your ...
<p>If you're worried about mixing up your table names, employ a hungarian notation style system in your code. Perhaps "s" for string + "tn" for table name:</p> <pre><code> stnUsers = 'users'; stnPosts = 'posts'; </code></pre> <p>Of course, the prefix is up to you, depending on how verbose you like your code... <code...
41,974
<p>I've created a model for executing worker tasks in a server application using a thread pool associated with an IO completion port such as shown in the posts below:</p> <p><a href="http://weblogs.asp.net/kennykerr/archive/2008/01/03/parallel-programming-with-c-part-4-i-o-completion-ports.aspx" rel="noreferrer">http:...
<p>Not really, at least, not last time I looked. I mean, boost::thread_group might make things marginally tidier in places, but not so as would make much of a difference, I don't think.</p> <p>Boost's thread support seems marginally useful when writing something that's cross-platform, but given that what you're writi...
<p><a href="http://www.cs.wustl.edu/~schmidt/ACE.html" rel="nofollow noreferrer">ACE</a> has some reactors that you can use to model things around your IOCPs. Some of these could have been added to boost, but boost makes building them pretty easy. </p>
5,773
<p>I was trying to insert new data into an existing XML file, but it's not working. Here's my xml file:</p> <pre><code>&lt;list&gt; &lt;activity&gt;swimming&lt;/activity&gt; &lt;activity&gt;running&lt;/activity&gt; &lt;list&gt; </code></pre> <p>Now, my idea was making two files: an index page, where it displa...
<p>is your code block copy and pasted from your existing files? if so i see two potential issues:</p> <pre><code>&lt;form name='input' action'insert.php' method='post'&gt; // should be: &lt;form name="input" action="insert.php" method="post"&gt; </code></pre> <p>note: you're missing <code>action</code><strong>=</stro...
<p>I think I know what is the problem with your code. You should not write like that: <code>&lt;?xml-stylesheet type="text/xsl" href="sample.xsl" ?&gt;</code> The right code is:</p> <pre><code>&lt;?xml:stylesheet type="text/xsl" href="sample.xsl" ?&gt; </code></pre>
23,644
<p>Can someone provide a regular expression for parsing name/value pairs from a string? The pairs are separated by commas, and the value can optionally be enclosed in quotes. For example:</p> <pre><code>AssemblyName=foo.dll,ClassName="SomeClass",Parameters="Some,Parameters" </code></pre>
<ul> <li><p><strong>No escape:</strong></p> <pre><code>/([^=,]*)=("[^"]*"|[^,"]*)/ </code></pre></li> <li><p><strong>Double quote escape for both key and value:</strong></p> <pre><code>/((?:"[^"]*"|[^=,])*)=((?:"[^"]*"|[^=,])*)/ key=value,"key with "" in it"="value with "" in it",key=value" "with" "spaces </code></p...
<p>This is how I would do it if you can use <code>Perl 5.10</code>.</p> <pre> qr/ (?&lt;key&gt; (?: [^=,\\] | (?&escape) )++ # Prevent null keys ) \s*+ = \s*+ (?&lt;value&gt; (?&quoted) | (?: [^=,\s\\] | (?&escape) )++ # Prevent null value ( use quote...
20,309
<p>How to Programmatically Inject JavaScript in PDF files?</p> <p>Can it be done without Adobe Professional?</p> <hr> <p>My goal is: I want to show up the print dialog immediately when I open the PDF. </p> <p>I know that this can be done with JavaScript code embedded in the document.</p>
<p>If you're developing in Java have a look at iText: <a href="http://www.lowagie.com/iText/" rel="nofollow noreferrer">http://www.lowagie.com/iText/</a> I think it supports what you are looking for.</p> <p>There are also some .Net versions around: <a href="http://www.ujihara.jp/iTextdotNET/en/" rel="nofollow noreferr...
<p>I've done studing the <a href="http://www.adobe.com/devnet/acrobat/pdfs/PDF32000_2008.pdf" rel="nofollow noreferrer">PDF Specifications</a>.</p> <p>Turns out that the PDF file format isn't that hard.</p> <p>It has a nice feature that ables to modify the document just by appending new content in the end of the file...
25,774
<p>I'm trying to generate a unique ID in php in order to store user-uploaded content on a FS without conflicts. I'm using php, and at the moment this little snippet is responsible for generating the UID:</p> <pre><code>$id = tempnam (".", ""); unlink($id); $id = substr($id, 2); </code></pre> <p>This code is hideous:...
<pre><code>string uniqid ([ string $prefix [, bool $more_entropy ]] ) </code></pre> <p>Gets a prefixed unique identifier based on the current time in microseconds.</p> <pre><code>USAGE: $id = uniqid(rand(), true); </code></pre>
<p>uniqid() is what you're looking for in most practical situations.</p> <p>You can make it even more "uniq" by adding a large random number after it.</p>
21,859
<p>This is my first real question of need for any of those Gridview experts out there in the .NET world.</p> <p>I an creating a Gridview from codebehind and I am holding a bunch of numerical data in the columns. Although, I do add the comma in the number fields from codebehind. When I load it to the Gridview, I have...
<p>If you do end up implementing your own comparer and sorting them as strings, the algorithm for treating numbers 'properly' is called Natural Sorting. Jeff wrote a pretty good entry on it here:<br> <a href="https://blog.codinghorror.com/sorting-for-humans-natural-sort-order/" rel="nofollow noreferrer">Sorting for Hum...
<p>Depending on exactly how you are doing sorting you could use one of the above methods, or you could return to the DB and get the sorting done there if the columns are actually a number type, then add your decoration to it later.</p>
10,513
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/153152/resizing-an-iframe-based-on-content">Resizing an iframe based on content</a> </p> </blockquote> <p>I'm loading an iFrame and want the parent to automatically change the height based upon the height of th...
<p>On any other element, I would use the <code>scrollHeight</code> of the DOM object and set the height accordingly. I don't know if this would work on an iframe (because they're a bit kooky about everything) but it's certainly worth a try.</p> <p>Edit: Having had a look around, the popular consensus is setting the he...
<p>Actually - Patrick's code sort of worked for me as well. The correct way to do it would be along the lines of this:</p> <p>Note: there's a bit of jquery ahead:</p> <pre><code> if ($.browser.msie == false) { var h = (document.getElementById("iframeID").contentDocument.body.offsetHeight); } else { var h = (d...
30,692
<p>How can I get a list of the IP addresses or host names from a local network easily in Python?</p> <p>It would be best if it was multi-platform, but it needs to work on Mac OS X first, then others follow.</p> <p><strong>Edit:</strong> By local I mean all <strong>active</strong> addresses within a local network, suc...
<p>If by "local" you mean on the same network segment, then you have to perform the following steps:</p> <ol> <li>Determine your own IP address</li> <li>Determine your own netmask</li> <li>Determine the network range</li> <li>Scan all the addresses (except the lowest, which is your network address and the highest, whi...
<p>One of the answers in <a href="https://stackoverflow.com/questions/166506/finding-local-ip-addresses-in-python">this question</a> might help you. There seems to be a platform agnostic version for python, but I haven't tried it yet.</p>
25,391
<p>I've never used a printer with auto bed leveling, but my understanding is that most or all of them don't actually level anything, but rather compensate for the unlevel bed in firmware by transforming the coordinates. It seems to me this would necessarily introduce aliasing artifacts in all your prints by making it s...
<p>Automatic bed levelling is not magic; it still requires you to level the bed properly (as level as possible). The upside of automatic bed levelling is that it compensates for small deviations like a slightly slanted surface or a (somewhat large) dent in the surface (as long it is probed and can be digitized by the f...
<p>The only 'consumer' approach to this would be providing adjustment feedback to the user, after the bed has been probed to determine an optimal position so that most of the bed is in the same plane.</p> <p>This seems to me like a 'free' enhancement, but users don't seem to be overly worried by the distortions introd...
1,381
<p>I have create a WCF service and am utilising netMsmqBinding binding.</p> <p>This is a simple service that passes a Dto to my service method and does not expect a response. The message is placed in an MSMQ, and once picked up inserted into a database.</p> <p>What is the best method to make sure no data is being lost....
<p>I think with MSMQ (avaiable only on Vista) you might be able to to do like this:</p> <pre><code>&lt;bindings&gt; &lt;netMsmqBinding&gt; &lt;binding name="PosionMessageHandling" receiveRetryCount="3" retryCycleDelay="00:05:00" maxRetryCycles="3" receive...
<p>Unfortunately I'm stuck on Windows XP and Windows Server 2003 so that isn't an option for me. - (I will re-clarify that in my question as I found this solution after posting and realised i couldn't use it)</p> <p>I found that one solution was to setup a custom handler which would move my message onto another queue ...
10,779
<p>I have a page using .NETs server-side input validation controls. This page also has a javascript confirm box that fires when the form is submitted. Currently when the Submit button is selected, the javascript confirm box appears, and once confirmed the ASP.NET server-side validation controls are fired. I would li...
<p>This seems to be a very common problem.</p> <p>The workaround:</p> <p>Validate the page first, then call <code>confirm</code>, as shown <a href="http://www.codedigest.com/CodeDigest/73-Fire-Validator-Controls-Before-JavaScript-Confirm-Box-Fires-in-ASP-Net-Page.aspx" rel="noreferrer">here</a> and <a href="http://ww...
<p>You should validate the page on the client itself.</p> <pre><code>function validate() { Page_ClientValidate(); if (Page_IsValid) // do your processing here return Page_IsValid; } </code></pre> <p>This method can be called on the "onClientClick" event of the button and in the code-behind, you c...
16,928
<p>I have a Rails app with some basic models. The website displays data retrieved from other sources. So I need to write a Ruby script that creates new instances in my database. I know I can do that with the test hooks, but I'm not sure that makes sense here.</p> <p>I'm not sure what this task should look like, how I ...
<p>You can load the entire rails environment in any ruby script by simply requiring environment.rb:</p> <pre><code>require "#{ENV['RAILS_ROOT']}/config/environment" </code></pre> <p>This assumes the RAILS_ROOT environment variable is set, see my comment for other ways of doing this.</p> <p>This has the added bonus ...
<p>Nice Joyent write up of using rake to run rails tasks from a cron job - <a href="http://wiki.joyent.com/accelerators:kb:rails:cron" rel="nofollow noreferrer">http://wiki.joyent.com/accelerators:kb:rails:cron</a></p>
37,434
<p>A product that I am working on collects several thousand readings a day and stores them as 64k binary files on a NTFS partition (Windows XP). After a year in production there is over 300000 files in a single directory and the number keeps growing. This has made accessing the parent/ancestor directories from window...
<p>NTFS performance severely degrades after 10,000 files in a directory. What you do is create an additional level in the directory hierarchy, with each subdirectory having 10,000 files.</p> <p>For what it's worth, this is the approach that the SVN folks took in <a href="http://subversion.tigris.org/svn_1.5_releaseno...
<p>Consider pushing them to another server that uses a filesystem friendlier to massive quantities of small files (Solaris w/ZFS for example)?</p>
14,128
<p>What's the best way to automate testing the UI in an Asp.net Page?</p>
<p><a href="http://wtr.rubyforge.org/" rel="nofollow noreferrer">Watir</a> or <a href="http://sourceforge.net/projects/watin/" rel="nofollow noreferrer">Watin</a> are a great place to start.</p> <p>More info <a href="http://www.hanselman.com/blog/WATIRForNETWatiNApproaches08ReleaseAndAutomatingIEFromPowerShell.aspx" r...
<p>Not sure about the "best" way, that's probably quite a loaded question...</p> <p>One way is to use the Web Tests in the Test edition of Visual Studio, see <a href="http://msdn.microsoft.com/en-us/library/ms182536(VS.80).aspx" rel="nofollow noreferrer">MSDN documentation.</a> Also here's a <a href="http://blogs.vert...
11,986
<p>In FogBugz 6, how do I represent the concepts of a "feature" versus a "task"? As <a href="http://www.joelonsoftware.com/articles/fog0000000245.html" rel="nofollow noreferrer">defined by Joel Spolsky</a>, the owner of Fog Creek Software (which makes FogBugz), a feature is essentially a user-visible capability. To e...
<p><a href="https://stackoverflow.com/questions/88455/how-do-i-represent-features-v-tasks-in-fogbugz-6/406118#406118">Responding to AviD's comment/question to Joel</a>:</p> <blockquote> <p>So, if you have 10 new features coming in the next version, with each feature needing 5 tasks to implement, you recommend ...
<p>haha, that article has a disclaimer, but I understand what you are saying.</p> <p>We use Fogbugz and the only 'Feature' that I am aware of is under category and I don't think you can associated it with sub-tasks.</p> <p>You can type in 'Case N' is the feature for this task if you just wanted to reference it in the...
11,406
<p>This works, but is it the proper way to do it???</p> <p>I have a custom server control that has an [input] box on it. I want it to kinda mimic the ASP.NET TextBox, but not completely. When the textbox is rendered i have a javascript that allows users to select values that are then placed in that input box.</p> <...
<p>I find using IStateManager works the best. </p> <p>For example:</p> <pre><code>partial class MyControl : System.Web.UI.UserControl, IStateManager { [Serializable()] protected struct MyControlState { public bool someValue; public string name; } protected MyControlState state; ...
<p>If you need to maintain state on postback, you must provide your own methods of recording what the user has done with your control on the client side and either update the server control later on the server with the changes, or redo the changes on the client side when the page refreshes. </p>
27,153
<p>In our application, we are using RMI for client-server communication in very different ways:</p> <ol> <li>Pushing data from the server to the client to be displayed.</li> <li>Sending control information from the client to the server.</li> <li>Callbacks from those control messages code paths that reach back from the...
<p>You can do this with a custom RMI Socket Factory. </p> <p>The socket factories create the sockets for RMI to use at both the client and server end so if you write your own you've got full control over the ports used. The client factories are created on the server, Serialized and then sent down to the client which...
<p>I've been having various problems implementing an RMI Server/Client architecture, with Client Callbacks. My scenario is that both Server and Client are behind Firewall/NAT. In the end I got a fully working implementation. Here are the main things that I did:</p> <h2>Server Side , Local IP: 192.168.1.10. Public (Int...
8,073
<p>Lasty, I tried to implements an hybrid structure in Java, something that looks like:</p> <pre><code>public class MapOfSet&lt;K, V extends HasKey&lt;K&gt;&gt; implements Set&lt;V&gt;, Map&lt;K, Set&lt;V&gt;&gt; </code></pre> <p>Where HasKey is the following interface:</p> <pre><code>public interface HasKey&lt;K&gt...
<p>What are you trying to accomplish? <code>Map</code> already exposes its keys as a <code>Set</code> via its [keySet()](<a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Map.html#keySet())" rel="nofollow noreferrer">http://java.sun.com/j2se/1.5.0/docs/api/java/util/Map.html#keySet())</a> method. If you want a...
<p>I would say that something that is meant to be sometimes used as a Map and sometimes as a Set should implement Map, since that can be viewed as a set of keys or values as well as a mapping between keys and values. That is what the Map.containsKey() and Map.containsValue() methods are for.</p>
9,617
<p>I've found syntax highlighters that highlight pre-existing code, but I'd like to do it as you type with a WYSIWYG-style editor. I don't need auto-completed functions, just the highlighting.</p> <p>As a follow-up question, what is the WYSIWYG editor that stackoverflow uses?</p> <p>Edit: Thanks to the answer below, ...
<p>Here is a really interesting article about how to write one: (Even better, he gives the full source to a JavaScript formatter and colorizer.)</p> <p><a href="http://marijn.haverbeke.nl/codemirror/story.html" rel="noreferrer">Implementing a syntax-higlighting JavaScript editor in JavaScript</a> or A brutal odyssey t...
<p>I dont program a lot of javascript but JSEclipse has been pretty helpful for me in the past. It comes as an Eclipse plug-in.</p> <p>I've been using it for years for free</p> <p><a href="http://www.interaktonline.com/products/eclipse/jseclipse/overview/" rel="nofollow noreferrer">http://www.interaktonline.com/produ...
8,688
<p>I am the .Net specialist in a consultancy with many difference flavors of developers using many different languages and frameworks. Because everyone is pretty much trying to push their own agendas with our different clients in terms of what technology to propose, I'm constantly finding myself in the classic argument...
<p>when you call settimeout, it returns you a variable "handle" (a number, I think)</p> <p>if you call settimeout a second time, you should first </p> <pre><code>clearTimeout( handle ) </code></pre> <p>then:</p> <pre><code>handle = setTimeout( ... ) </code></pre> <p>to help automate this, you might use a wrapper t...
<p>you can always overwrite the buttons onclick to return false. example:</p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="UTF-8"&gt; &lt;head&gt; &lt;title&gt;Javascript example&lt;/title&gt; &lt;script type="text/javascript"&gt; var count = 0; function annoy() {...
40,670
<p>Not so long ago I was in an interview, that required solving two very interesting problems. I'm curious how would you approach the solutions.</p> <p>Problem 1 :</p> <p><strong>Product of everything except current</strong> </p> <p>Write a function that takes as input two integer arrays of length len, input and in...
<p>First question: </p> <pre><code>int countZeroes (int[] vec) { int ret = 0; foreach(int i in vec) if (i == 0) ret++; return ret; } int[] mysticCalc(int[] values, int[] indexes) { int zeroes = countZeroes(values); int[] retval = new int[values.length]; int product = 1; if (zeroes &gt;= 2) { // 2 o...
<p>Vaibhav, unfortunately we have to assume, that there could be a 0 in the input table.</p>
8,009
<p>I need a type which can contain a position of an object in a 3D environment - my house.</p> <p>I need to know the floor it is on, and the x and Y coordinates on that floor.</p> <p>The System.Windows.Point(int, int) only represent a two-dimensional space, but does .NET have a type for three-dimensional space?</p> ...
<p>In managed Direct3D there is a vector3 type that describes a point in space. It would be trivial to implement one yourself.</p> <pre><code>public struct Vector3 { public float x; public float y; public float z; } </code></pre>
<p>I don't think there is built in functionality like that. </p> <p>But check out this CodeProject article <a href="http://www.codeproject.com/KB/vb/3D_Graphics_-_Net.aspx" rel="nofollow noreferrer">3D Geometry Library (Basic Classes) and 3D Drawing using VB.Net</a></p>
40,093
<p>i am trying to use an ASP conditional here:</p> <pre><code>if (Request.Cookies("username")) and (Request.Cookies("password")) &lt;&gt; "" Then </code></pre> <p>And i keep getting this error:</p> <blockquote> <p>Type mismatch: '[string: ""]'</p> </blockquote> <p>Any ideas what I am getting that?</p>
<p>try</p> <pre><code>if (Request.Cookies("username") &lt;&gt; "") and (Request.Cookies("password") &lt;&gt; "") Then </code></pre>
<p>Actually, I would do the following..</p> <pre><code>if (!string.IsNullOrEmpty(Request.Cookies("username")) &amp;&amp; !string.IsNullOrEmpty(Request.Cookies("password"))) { // Do your stuff, here :) } </code></pre> <p>Get into the habit of using <code>string.IsNullOrEmpty</code> for testing variables and <c...
45,145
<p>I just had a conversation with my lead developer who disagreed that unit tests are all that necessary or important. In his view, functional tests with a high enough code coverage should be enough since any inner refactorings (interface changes, etc.) will not lead to the tests being needed to be rewritten or looked ...
<p>Off the top of my head</p> <ul> <li>Unit tests are repeatable without effort. Write once, run thousands of times, no human effort required, and much faster feedback than you get from a functional test</li> <li>Unit tests test small units, so immediately point to the correct "sector" in which the error occurs. Funct...
<p>If you use a pure Extreme Programing / Agile Development methodology the Unit tests are always required as they are the requirements for development.</p> <p>In pure XP/Agile one makes all requirements based on the tests which are going to be performed to the application</p> <ul> <li>Functional tests - Generate fun...
22,035
<p>Is it possible to obtain the maximum column length for a VARCHAR, CHAR etc?</p>
<p>Here's a way which avoids touching the database:</p> <ul> <li>Using Reflection, get the property of the entity class that corresponds to the column in question.</li> <li>Then, retrieve the System.Data.Linq.Mapping.Column attribute of the property.</li> <li>Then, parse the DbType property of this attribute (eg <stro...
<p>In pure T-SQL you can use this query:</p> <pre><code>select max_length from sys.columns as c inner join sys.objects o on c.object_id = o.object_id where o.name = 'myTable' and c.name = 'myColumn' </code></pre> <p>For linq-to-sql you need it rewrite into linq.</p>
32,777
<p>I am working on a windows form application. How do i use the find method of a datatable to find a row if the datatable has a compound key?</p> <p>Table Structure Col A, Col B, Col C</p> <p>Col A and Col B make up the compound key. I want to find the row where the value in Col A is 6 and Col B is 5</p>
<p>When you "set" the Primary key of the datatable, the parameter value is an array of DataColumns... </p> <p>if your datatable is in variable dt...,</p> <pre><code>dt.PrimaryKey = new DataColumn[] {dt.Columns["ColA"], dt.Columns["ColB"]}; </code></pre> <p>Then pass an array of object values to the Find() method</p...
<p>When you "set" the Primary key of the datatable, the parameter value is an array of DataColumns... </p> <p>if your datatable is in variable dt...,</p> <pre><code>dt.PrimaryKey = new DataColumn[] {dt.Columns["ColA"], dt.Columns["ColB"]}; </code></pre> <p>Then pass an array of object values to the Find() method</p...
40,633
<p>Is there a public/government web service that I can call to find out what the national holidays are for a given year? (For the US and/or any country in the world.)</p> <p>Edit: Does anybody have a set of formulas to calculate US holidays? (C# would be my language of choice if there is a choice.)</p>
<p>There's a web service at <a href="http://www.holidaywebservice.com" rel="noreferrer">http://www.holidaywebservice.com</a> which will provide dates of holidays for the USA, Republic of Ireland, England and Scotland. They also sell a DLL and source code.</p> <p>As for details of algorithms, you could do worse than ch...
<p>Some parsing may be required, and it's not 100% complete, but you can use <a href="http://en.wikipedia.org/wiki/List_of_holidays_by_country" rel="nofollow noreferrer">wikipedia</a>.</p>
8,469
<p>How can I get a query which uses an OR in the WHERE clause to split itself into two queries with a UNION during compilation? If I manually rewrite it, the query using the UNION is 100x faster than the single query, because it can effectively use different indices in each query of the union. Is there any way I can ...
<p>You can group</p> <pre><code>select columnlist from table1 join table2 on joincond2 join table3 on joincond3 </code></pre> <p>into a view, and then use union.</p> <p>but if you can migrate to sql2005/8, you can use common table expression.</p> <pre><code>with cte ( columnlist ) as ( select columnlist fro...
<p>Try adding OPTION (RECOMPILE) to the query. If it's in a stored procedure then add WITH RECOMPILE to that as well. It may be that the first time that you run the query SQL Server comes up with a plan and caches it but then the second time through it's still using the old (and now poor) query plan.</p> <p>You will t...
48,658