instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>We have a View (call it X) that is the base view called by 2 other views(call them Y and Z).</p> <p>Today we made a change to view X, after that view Y and Z started bringing back data that was incorrect. When we were in Management Studio and ran <code>SELECT * FROM Y</code>(which is exactly how the view is called i...
<p>See the <a href="http://msdn.microsoft.com/en-us/library/ms187821.aspx" rel="noreferrer">sp_refreshview</a> command.</p> <blockquote> <p>Updates the metadata for the specified non-schema-bound view. Persistent metadata for a view can become outdated because of changes to the underlying objects upon which the ...
<p>SQL Server does not cache view data (at least, not in the way you are referring to it).</p> <p>If a view definition contains 'SELECT *', then the actual column list is defined when the view is created, i.e. the 'SELECT *' is replaced by the actual column list than exists at the time you create the view. That means ...
48,787
<p>You can limit "Check-In Policy" rules via the "Custom Paths" policy. But the "Check-in Notes" tab doesn't seem to fit in to the same system. Why isn't "Check-In notes" just another "Check-In policy"??</p> <p>I'm using Team Foundation Server 2008 SP1</p>
<p>We had a similar problem some time ago. For some sub tree we wanted to require entering a code reviewer. I ended up implementing a custom policy and used the Custom Path Policy to restrict it to certain folders. That works well, except that you have to deploy your policy assembly and TFS has no built-in mechanism fo...
<p>That's an interesting question - the short answer is you cannot. </p> <p>I have ran into the issue myself a lot where people get check-in notes and check-in policies confused because, while very different in implementation on the server, they often serve similar purposes.</p> <p>Check-in notes are bits of structu...
18,879
<p>I am trying to create a file in the <code>/tmp</code> directory (working on a Linux UBUNTU 7.10), that has read/write/execute access for any user.</p> <p>So I am using the</p> <pre><code>open(fileName,O_CREAT|O_RDWR,0777) </code></pre> <p>function to create the file (from a C program) in <code>user1</code> account a...
<p>You have to set your umask to 000. The bits on the umask are removed from the permission you have chosen, and the default umask is usually 022 or 002.</p> <p>Note that things like default ACLs and SELinux labels might also affect the readability and writability of files. Use getfacl to see ACLs and ls -Z to see SEL...
<p>FWIW, it's a security risk to create anything in /tmp (or /var/tmp, etc.) with a fixed name. A symlink can be setup in /tmp with the same name pointing to anything, and your program will destroy the target file if the user running your program has permissions to do so.</p> <p>Things created programmatically in /tm...
26,463
<p>I need to generate multiple random values under SQL Server 2005 and somehow this simply wont work</p> <pre><code>with Random(Value) as ( select rand() Value union all select rand() from Random )select top 10 * from Random </code></pre> <p>Whats the preffered workaround?</p>
<p>have you tries something like this (found at <a href="http://weblogs.sqlteam.com/jeffs/archive/2004/11/22/2927.aspx" rel="nofollow noreferrer">http://weblogs.sqlteam.com</a> ) :</p> <pre><code>CREATE VIEW vRandNumber AS SELECT RAND() as RandNumber GO </code></pre> <p>create a function </p> <pre><code>CREATE FUNCT...
<p>I'm currently using this:</p> <pre><code>with Random(Value) as ( select rand(checksum(newid())) Value union all select rand(checksum(newid())) from Random )select top 10 * from Random </code></pre> <p>but that seems overly hackish :S Why doesnt rand get reevaluated in the first version?</p>
22,139
<p>I am trying to implement NTLM authentication on one of our internal sites and everything is working. The one piece of the puzzle I do not have is how to take the information from NTLM and authenticate with Active Directory.</p> <p>There is a <a href="http://www.innovation.ch/personal/ronald/ntlm.html" rel="nofollow...
<p>What you're really asking is: Is there any way to validate the "WWW-Authenticate: NTLM" tokens submitted by IE and other HTTP clients when doing Single Sign-On (SSO). SSO is when the user enters their password a "single" time when they do Ctrl-Alt-Del and the workstation remembers and uses it as necessary to transpa...
<p>Hm, I'm not sure what you're trying to accomplish.</p> <p>Usually implementing NTLM on an internal site is as simple as unchecking "Enable Anonymous Access" in "Authentication and Access Control" in the "Directory Security" tab of website properties in IIS. If that is cleared, then your web application users will s...
4,212
<p>I have a XML schema that I will need to create Java classes for. It is not a particularly large schema, I'd say it will result in around 20 classes. I am trying to weigh up whether to use an automatic binding program (like the one supplied in JAXB or JiBX) or whether to manually write my own classes and use somethin...
<p>I don't think there is a definitive answer to your question. But I can give you some hard won advice. Here are some things to consider:</p> <ol> <li><p>It is time consuming to write marshalling and unmarhsalling code, especially the first time.</p></li> <li><p>You will have to spend quite a bit of time learning t...
<p>I do not want to start a long and endless holly war on the question but from my experience - if you can use tool that generates all code for you and do not require JAR dependable. The code that will be generated will be ugly but it will work until you will clearly see a need to handcraft the handwritten code. In mos...
32,723
<p>I'm using Castle ActiveRecord for persistence, and I'm trying to write a base class for my persistence tests which will do the following:</p> <ul> <li>Open a transaction for each test case and roll it back at the end of the test case, so that I get a clean DB for each test case without me having to rebuild the sche...
<p>Not too sure about ActiveRecord, but in NHibernate a transaction belongs to a session, not the otherway round.</p> <p>If you've used ADO.Net a lot, this will make more sense, as to create an <code>IDbTransaction</code> you need to use the connection. ActiveRecord's <code>TransactionScope</code> (and NHibnerate's <c...
<p>Using <code>SessionScope.Flush()</code> makes my third test fail. As I understand it, <code>Flush()</code> executes the SQL to push my records into the DB, but does not evict objects from the session. That fits with what you say about <code>FindAll()</code> causing a flush.</p> <p>What I really want is <code>Sessio...
31,940
<p>I have a several webapps which use java.util.logging. Tomcat 5.5 is configured to use the Juli logger so that each webapp has its own log file. The problem is that Juli does not have properties for maximum file size and file count. Using Juli the files will grow unbounded and only roll at the end of the day. Als...
<p>Visual Studio 2005 is known for not uninstalling so well (especially the Express editions). Use the technique found <a href="http://support.microsoft.com/kb/907965" rel="nofollow noreferrer">here</a> to manually uninstall all of Visual Studio.</p>
<p>A hell of a lot of luck. I have tried many times to pull this off and each time I ended up just restoring to before I installed it or doing a fresh install.</p>
16,498
<p>Multistrings (double null-terminated string of null-separated strings) are common in the Windows API. What's a good method for converting a multistring returned from an API to a C# string collection and vice versa?</p> <p>I'm especially interested in proper handling of character encoding (Windows XP an later).</p> ...
<p>This might be naïve, but how about:</p> <pre><code>static string[] MultiStringToArray(string multiString) { return multiString.TrimEnd('\0').Split('\0'); } </code></pre> <p><strike> Also - aren't you missing the final <code>\0</code> (you state double-null-terminated) in <code>StringArrayToMultiString</code>?<...
<p>In the MSDN documentation for RegistryKey.SetValue() and RegistryKey.GetValue(), the examples simply pass in, or cast to, string[], respectively. Is there something wrong with that?</p>
33,757
<p>Is there a system stored procedure to get the version #?</p>
<p>Try </p> <pre><code>SELECT @@VERSION </code></pre> <p>or for SQL Server 2000 and above the following is easier to parse :) </p> <pre><code>SELECT SERVERPROPERTY('productversion') , SERVERPROPERTY('productlevel') , SERVERPROPERTY('edition') </code></pre> <p>From: <a href="http://support.microsoft.com/k...
<p>Try this:</p> <pre><code>SELECT 'the sqlserver is ' + substring(@@VERSION, 21, 5) AS [sql version] </code></pre>
8,404
<p>How would I expose an <em>Objective-C</em> method within JavaScript when using the <em>iPhone SDK</em> when using the <code>UIWebView</code>?</p> <p>Any help would be appreciated!</p>
<p>The best way to do this would be through a custom link, and then use the UIWebView delegate method <code>-webView:shouldStartLoadWithRequest:navigationType:</code> to trap requests. When you see a request come through with your link in it, you know your action has been triggered.</p>
<p>To see an example of this check out the PhoneGap source code from Github:</p> <p><a href="http://github.com/sintaxi/phonegap/tree/master/iphone/Classes/GlassAppDelegate.m" rel="nofollow noreferrer">http://github.com/sintaxi/phonegap/tree/master/iphone/Classes/GlassAppDelegate.m</a></p>
30,162
<p>Does anyone known of a a good reference for canonical CS problems?</p> <p>I'm thinking of things like "the sorting problem", "the bin packing problem", "the travailing salesman problem" and what not.</p> <p><strong>edit:</strong> websites preferred</p>
<p>You can probably find the best in an algorithms textbook like <a href="https://rads.stackoverflow.com/amzn/click/com/0262032937" rel="nofollow noreferrer" rel="nofollow noreferrer">Introduction to Algorithms</a>. Though I've never read that particular book, it's quite renowned for being thorough and would probably c...
<p>@rcreswick those sound like good references but fall a bit shy of what I'm thinking of. (However, for all I know, it's the best there is)</p> <p>I'm going to not mark anything as accepted in hopes people might find a better reference.</p> <p>Meanwhile, I'm going to list a few problems here, fell free to add more</...
5,603
<p>Is it possible to change the destination port of a UDP packet using iptables?</p> <p>I'm trying to get an SNMP agent to send out traps on 1620 instead of 162. Unfortunately so far I've only managed to change the source port:</p> <blockquote> <p>iptables -t nat -A POSTROUTING -p udp --dport 162 -j SNAT --to :16...
<p>This usage is apparently not supported. Taken from <a href="http://www.netfilter.org/documentation/HOWTO/NAT-HOWTO.txt" rel="nofollow noreferrer">http://www.netfilter.org/documentation/HOWTO/NAT-HOWTO.txt</a>:</p> <blockquote> <p>6.3.7. Altering the Destination of Locally-Generated Connections</p> <p>The N...
<p>Instead of making SNAT, try with DNAT. The source port gets changed because SNAT means SourceNAT, so DNAT will work for you.</p>
30,067
<p>I'm in the process of learning WPF coming from WinForms development.</p> <p>I have a TextChanged event assigned to one of my TextBox's in my WPF application. If the user enters invalid data, I want to be able to revert to the previous text value.</p> <p>In the old forms day, I would replace NewValue with OldValue...
<p>You can do this two ways:</p> <ol> <li><p>Listen to the <code>PreviewTextInput</code> event and set <code>e.Handled = true</code> to stop the TextChanged event. </p></li> <li><p>Use WPF validation. There is a <a href="http://www.codeproject.com/KB/WPF/wpfvalidation.aspx" rel="nofollow noreferrer">great post by Paul...
<p>I would use PreviewTextInput, most events in WPF have a Preview sibling. If you set the e.Handled = true it will stop the event from bubbelig/tunneling further.</p> <p>I'm not sure if you are aware of it but Preview events are said to be tunneling, ie. they start from the outermost container and is posted in every...
43,463
<p>After reading Martin Fowler's <a href="http://martinfowler.com/articles/mocksArentStubs.html" rel="nofollow noreferrer">Mocks Aren't Stubs</a>, I've discovered I've been practicing TDD in the "mockist" fashion.</p> <p>But I'm wondering if even in mockist TDD if one can take mocking too far.</p> <p>Here's an <stron...
<p>The technique is called "mock objects", not "mock methods" for a reason. It encourages designs that divide the system into easily composed, collaborating objects and away from procedural code. The aim is to raise the level of abstraction so that you mostly program by composing objects and rarely write low-level cont...
<p>Can you take mocking too far? I don't know about too far but it can be done badly such that you are actually testing the mocks instead of the code, or worse so that you have brittle tests.</p> <p>But as long as you're writing good tests — tests that confirm your expected behavior, tests that are helping you write t...
22,344
<p>I've looked around for a good example of this, but I haven't run into one yet. I want to pass a custom string array from java to oracle and back, using the IBATIS framework. Does anyone have a good link to an example? I'm calling stored procs from IBATIS.</p> <p>Thanks</p>
<p>You've got to start with a custom instance of <code>TypeHandler</code>. We'd prefer to implement the simpler <code>TypeHandlerCallback</code>, but in this scenario we need access to the underlying <code>Connection</code>.</p> <pre><code>public class ArrayTypeHandler implements TypeHandler { public void setPar...
<p>Try using <code>statement.getObject(i)</code> and then casting to an array.</p>
16,468
<p>We have a fairly complex web application (.NET 3.5) that need to be launched from a CD-ROM (or DVD, or from an USB key). </p> <p>I'm thinking of using Cassini and SqlCe for the database (we use LinqToSql for data access, so I think it's the only choice without rewriting the entire data access classes). Is anyone ev...
<p>Where are you going to get the web server to serve the ASP.NET pages? You can open stuff like straight HTML, Flash or Silverlight directly in the browser, but unless I am missing something, you need IIS to do the server side ASP.NET.</p> <p>I don't know your requirements, but you might want to consider a WinForms a...
<p>Where are you going to get the web server to serve the ASP.NET pages? You can open stuff like straight HTML, Flash or Silverlight directly in the browser, but unless I am missing something, you need IIS to do the server side ASP.NET.</p> <p>I don't know your requirements, but you might want to consider a WinForms a...
32,466
<p>I've seen <a href="https://stackoverflow.com/questions/49156/importing-javascript-in-jsp-tags">this question</a> regading the importing of js-files related to the tag content itself. I have a similar problem, here I have a jsp tag that generates some HTML and has a generic js-implementation that handles the behavior...
<p>You should strive for javascript in its own files. This is usually done with <a href="http://accessites.org/site/2007/02/graceful-degradation-progressive-enhancement/" rel="noreferrer">Progressive Enhancement</a>. But some times you don't have a choice, for instance when the same JSP renders pages in different langu...
<p>Although I agree that it's not entirely elegant, I've been known to do it a few times when combining server-side decisions with an AJAX-integrated environment. Echoing inline &lt;script&gt; tags in order to initialize some variables isn't a terrible thing, as long as no one sees it.</p> <p>As for better methods, I ...
28,438
<p>How do you connect to Oracle using PHP on MAC OS X?</p>
<p>I would think OCI would be the way to go. PHP has a <a href="http://us3.php.net/manual/en/book.oci8.php" rel="nofollow noreferrer">module</a> for it.</p>
<p>I dont know the Mac specifically, nor PHP, but you usually need to install the Oracle Client tools (Instant Client). </p> <p><a href="http://www.oracle.com/technology/tech/oci/instantclient/index.html" rel="nofollow noreferrer">http://www.oracle.com/technology/tech/oci/instantclient/index.html</a></p> <p>Once ins...
11,335
<p>I've read a number of books and websites on the subject of TDD, and they all make a lot of sense, especially Kent Beck's book. However, when I try to do TDD myself, i find myself staring at the keyboard wondering how to begin. Is there a process you use? What is your thought process? How do you identify your fir...
<p>I used to have the same problem. I used to start most development by starting a window-designer to create the UI for the first feature I wanted to implement. As the UI is one of the hardest things to test this way of working doesn't translate very well to TDD.</p> <p>I found the atomic object papers on Presenter Fi...
<p>I don't think you should really begin with TDD. Seriously, where are your specs? Have you agreed on a general/rough overall design for your system yet, that <em>may</em> be appropriate for your application? I know TDD and agile discourages Big Design Up-Front, but that doesn't mean that you shouldn't be doing Design...
25,966
<p>What is the best definition of a thread and what is a process? If I call a function, how do I know that a thread is calling it or a process (or am I not understanding it??!). This is in a multi-core system (quadcore).</p>
<p>From <a href="http://wiki.answers.com/Q/What_is_the_difference_between_a_computer_process_and_thread" rel="nofollow noreferrer">http://wiki.answers.com/Q/What_is_the_difference_between_a_computer_process_and_thread</a>:</p> <p>A single process can have multiple threads that share global data and address space with ...
<p>A process is composed of one or more threads (one by default for most environments). A process can create additional threads though.</p> <p>Like the previous answer says, each Process has its own memory space (each can have a pointer to 0x12345, with that memory location having different values for each process), ...
44,833
<p>Due to the way my serverside script outputs I receive multiple JSON objects. <code>{jsonhere}{jsonhere1}{jsonhere2}{jsonhere3} etc..</code> They aren't seperated by anything. If I would do a split based <code>}{</code> I would lose those brackets. So is there an outerloop I can put over the regular <code>$.each</cod...
<p>Rough algorithm:</p> <pre><code>Define a stack Define an array LOOP on each character in the string IF the top item of the stack is a single or double quote THEN LOOP through each character until you find a matching single or double quote, then pop it from the stack. ELSE IF "{", push onto t...
<p>Unless you can guarantee that any strings in the data will not contain "}{", you can't even safely split it without parsing the JSON at least enough to keep track of whether you are in a string or not. For example if you just split this:</p> <pre><code>{"foo": "}{", "bar": 42} </code></pre> <p>around "}{", you wou...
43,835
<p>The same way DOS morphed into Windows?</p> <p>We seem to have ended up supporting and developing for three platforms from Microsoft, and I'm not sure where the boundaries are supposed to lie.</p> <p>Why can't the benefits of the CLR (such as type safety, memory protection, etc.) be built into Windows itself?</p> ...
<p>And let's not forget that DOS didn't morph into Windows, at least not the Windows we know and love today. DOS was the operating system, Windows 3.1 a GUI shell resting atop said operating system.</p> <p>When Windows 95 came out, it is true that there was no more boxed product labeled "Microsoft DOS," but Windows 95...
<p>What language would the CLR itself use? What APIs would it call? Say it needed to open a file or allocate memory or create a process, you think the CLR is going to do that? The CLR is built on top of native code. A managed OS would create overhead.</p> <p>CLR is for app development, it is there to make it easy to m...
45,008
<p>Looking for good techniques to justify "great than normal" machine for developers. The company I work for buys the same underpowered $500 dollar systems for everyone, and looking for ways to prove ROI or arguments to use. Sorry, I didn't say this in the initial question, the stack is VS 2008, SQL 2005/2008. As du...
<p>Figure out how long you spend in the edit -> build -> debug cycle, then total that up over the course of a year. Then guesstimate (with some justifiable inflation) what a good computer would do to that number. Multiply the time improvement by your hourly rate, and present it as a business case.</p>
<p>Tell them that you will pay the difference between their cheap machines and the machine that you want. If you are confident that it will boost your productivity significantly then you will make the money back easily in performance bonuses / salary increases. </p> <p>Also, if you put your money where your mouth i...
18,625
<p>I have a Rails app that sets a cookie and does a redirect to another server once the user is logged in. However, the cookie that the Rails app sets isn't seen by the server for some reason. I've tried setting http_only to false but I still can't even see the cookie unless the domain is the same as my Rails app. Here...
<p>What are the redirecting and redirected-to servers? You can only set ‘domain’ to the current hostname or a parent domain, so if you're on a.example.com and you're redirecting to b.example.com, you have to set ‘domain’ to .example.com, <em>not</em> b.example.com as implied in the code snippet.</p> <p>(And open domai...
<p>You can get around this in development mode by editing your /etc/hosts file and creating host names for your apps</p> <p><code>127.0.0.1 app1.localdev.com, app2.localdev.com</code></p> <p>Then, when the cookie is created set the domain to '.localdev.com' (note the preceeding period') which will allow any app at a...
28,197
<p>I'm writing a C/C++ DLL and want to export certain functions which I've done before using a .def file like this</p> <pre><code>LIBRARY "MyLib" EXPORTS Foo Bar </code></pre> <p>with the code defined as this, for example:</p> <pre><code>int Foo(int a); void Bar(int foo); </code></pre> <p>However, what if I wan...
<p>In the code itself, mark the functions you want to export using __declspec(dllexport). For example:</p> <pre><code>#define DllExport __declspec(dllexport) int DllExport Foo( int a ) { // implementation } int DllExport Foo( int a, int b ) { // implementation } </code></pre> <p>If you do this, you do not need ...
<p>There isn't a language or version agnostic way of exporting an overloaded function since the mangling convention can change with each release of the compiler.</p> <p>This is one reason why most WinXX functions have funny names like *Ex or *2.</p>
4,568
<ul> <li>What is the main difference between <code>int.Parse()</code> and <code>Convert.ToInt32()</code>?</li> <li>Which one is to be preferred</li> </ul>
<ul> <li><p>If you've got a string, and you expect it to always be an integer (say, if some web service is handing you an integer in string format), you'd use <a href="http://msdn.microsoft.com/en-us/library/system.int32.parse.aspx" rel="noreferrer"><strong><code>Int32.Parse()</code></strong></a>.</p> </li> <li><p>If y...
<p>for clarification open console application, just copy below code and paste it in <code>static void Main(string[] args)</code> method, I hope you can understand </p> <pre><code>public class Program { static void Main(string[] args) { int result; bool status; ...
24,311
<p>I can add custom version strings to a C++ DLL in Visual Studio by editing the .rc file by hand. For example, if I add to the VersionInfo section of the .rc file</p> <pre><code>VALUE "BuildDate", "2008/09/19 15:42:52" </code></pre> <p>Then that date is visible in the file explorer, in the DLL's properties, under t...
<p>Expanding on the Khoth's answer, In AssemblyInfo.cs:</p> <p>You can do:</p> <pre><code>[assembly: CustomResource("Build Date", "12/12/2012")] </code></pre> <p>Where CustomResource is defined as:</p> <pre><code>[AttributeUsage(AttributeTargets.Assembly)] public class CustomResourceAttribute : Attribute { ...
<p>In AssemblyInfo.cs, you can put:</p> <pre><code>[assembly: System.Reflection.AssemblyInformationalVersion("whatever you want")] </code></pre> <p>It's a compiler warning if it's not a number like 1.2.3.4, but I'm fairly sure everything will work.</p>
14,709
<p>When you run <code>top</code> and see all running processes, I've always wanted to know just what everything actually means. e.g. all the various single-letter state codes for a running process (R = Running, S = Sleeping, etc...)</p> <p>Where can I find this?</p>
<p>The <a href="https://www.man7.org/linux/man-pages/man1/top.1.html" rel="noreferrer">man page</a> says what the state codes are mapped to, but not what they actually mean. From the <code>top</code> man page:</p> <pre><code>'D' = uninterruptible sleep 'R' = running 'S' = sleeping 'T' = traced or stopped 'Z' = zombie <...
<p>Programs like <code>top</code> and <code>ps</code> takes these values from the kernel itself. You can find its definitions in the source code here:</p> <p><a href="https://github.com/torvalds/linux/blob/3950e975431bc914f7e81b8f2a2dbdf2064acb0f/fs/proc/array.c#L129-L143" rel="noreferrer">https://github.com/torvalds/l...
39,579
<p>What options are there in the industry for enterprise reporting? I'm currently using SSRS 2005, and know that there is another version coming out with the new release of MSSQL.</p> <p>But, it seems like it might also be a good time to investigate the market to see what else is out there.</p> <p>What have you enco...
<p>I've used Cognos Series 7, Cognos Series 8, Crystal Reports, Business Objects XI R2 WebIntelligence, Reporting Services 2000, Reporting Services 2005, and Reporting Services 2008. Here's my feedback on what I've learned:</p> <p><strong>Reporting Services 2008/2005/2000</strong></p> <p>PROS</p> <ol> <li><p>Cost: ...
<p>Crystal Reports by <a href="http://businessobjects.com" rel="nofollow noreferrer">Business Objects</a> seems to be a popular choice.</p> <p>I never wrote any reports in it myself, but others in my team who did sometimes struggled getting the more complex reports to work.</p> <p>It also might be a bit pricey, depen...
3,748
<p>I need a Javascript which monitors keyboard and mouse events to track how much time a user spends on the page. Specifically, actively using the page by typing, or moving/clicking with the mouse.</p> <p>Thought I'd ask if anybody knows of something that might work for me to save some time. Otherwise, Javascript and ...
<p>Example of recording mouse movement: <a href="http://pure.rednoize.com/movelogger/" rel="nofollow noreferrer">http://pure.rednoize.com/movelogger/</a></p> <ul> <li>General information about detecting keystrokes: <a href="http://www.quirksmode.org/js/keys.html" rel="nofollow noreferrer">http://www.quirksmode.org/js/...
<p>Theoretically all DOM elements can react on events like onClick, onMouseOver, onKeyPress etc. From a whole page down to each element. I would start that way, with any JavaScript library you like.</p>
43,672
<p>What level of CPU usage should be considered high for SQL Server? ie 80% 90% 100%?</p>
<p>if under normal loads the CPU averages above 40% I start to get nervous. However, that's because I know the nature of our traffic and the spikes we get. Your mileage may vary.</p>
<p>It really depends on your machine. The best thing is to monitor the server using perfmon and see when things start to run slowly. It is normal for SQL to use a lot of CPU under load.</p>
19,623
<p>Simple question that keeps bugging me.</p> <p>Should I HTML encode user input right away and store the encoded contents in the database, or should I store the raw values and HTML encode when displaying?</p> <p>Storing encoded data greatly reduces the risk of a developer forgetting to encode the data when it's bein...
<p>i'd strongly suggest encoding information on the way out. storing raw data in the database is useful if you wish to change the way it's viewed at a certain point. the flow should be something similar to:</p> <pre><code>sanitize user input -&gt; protect against sql injection -&gt; db -&gt; encode for display </code>...
<p>Keep in mind that you may need to access the database with something that doesn't understand HTML encoded text (e.g., a reporting tool). I agree that space is a non-issue, but IMHO, putting HTML encoding in the database moves knowledge of your view/front end into the lowest tier in the application, and that is a de...
27,596
<p>I use the Autocomplete extender feature to get the list of suggestions from my database. There is no scroll bar for this control, so I have added a scroll bar in a panel (MS .net 2.0) which i attach to my autocomplete extender.Now the issue is with the srcoll bar. like this </p> <pre><code>&lt;asp:Panel ID="autocom...
<p>This does not directly answer your question - but I would ask if you're sure that the autocomplete extender is the best control to be using in this scenario.</p> <p>From a usability perspective the great thing about autocomplete is that I can type a 3-4 characters, see a few available inputs and easily select them ...
<p>the click on the scrollbar issue was in my case fixed by setting <code>AutoPostBack=false</code> on the textbox. But then the functionality of the AutoCompleteExtender were gone. Using the <code>OnClientItemSelected</code> property I could call a javascript function that triggered a postback and all the IE browser u...
38,650
<p>All the documentation I've found so far is to update keys that are already created:</p> <pre><code> arr['key'] = val; </code></pre> <p>I have a string like this: <code>&quot; name = oscar &quot; </code></p> <p>And I want to end up with something like this:</p> <pre><code>{ name: 'whatever' } </code></pre> <p>That i...
<p>Somehow all examples, while work well, are overcomplicated:</p> <ul> <li>They use <code>new Array()</code>, which is an overkill (and an overhead) for a simple associative array (AKA dictionary).</li> <li>The better ones use <code>new Object()</code>. It works fine, but why all this extra typing?</li> </ul> <p>This ...
<pre><code>var myArray = new Array(); myArray['one'] = 1; myArray['two'] = 2; myArray['three'] = 3; // Show the values stored for (var i in myArray) { alert('key is: ' + i + ', value is: ' + myArray[i]); } </code></pre> <p>This is ok, but it iterates through every property of the array object.</p> <p>If you want t...
45,765
<p>How do I create a new webpage in the Documentum front end Webtop? </p>
<p>Why WebTop? You should use Web Publisher which is built on WebTop with the specific purpose of managing web content. Is this an OOTB installation? Web Publisher / WebTop requires significant amount of customization in order to start being useful. Do you have templates defined? If so, then just go to File New and...
<p>Why WebTop? You should use Web Publisher which is built on WebTop with the specific purpose of managing web content. Is this an OOTB installation? Web Publisher / WebTop requires significant amount of customization in order to start being useful. Do you have templates defined? If so, then just go to File New and...
6,119
<p>I'm a big fan of <a href="http://highscalability.com/" rel="nofollow noreferrer">http://highscalability.com/</a> and have been looking in my current development to decompose my application along functional boundaries as a route to being able to scale out the server side, specifically the database layer. What this in...
<p>Functional decomp is a bad design strategy.</p> <p>Think of trying to build a kitchen blender using functional decomp. To whip, mix, stir and blend, you'd have four bowls, four motors, four blades, four switches, four power supplies and four bases to hold each "function".</p> <p>Functional decomp is for analysis ...
<p>I think it depends - doesn't SOA basically mean functional decomp.?</p> <p>Problem is when different functions need access to the same data, that probably is a smell that somethings wrong. Perhaps there needs to be another function to handle access to the common data, or perhaps functionl decomposition is the wrong...
31,104
<p>The HTML standard defines a clear separation of concerns between CSS (presentation) and HTML (semantics or structure).</p> <p>Does anyone use a coding standards document for CSS and XHTML that has clauses which help to maintain this separation? What would be good clauses to include in such a coding standards docume...
<p>We don't have a physical document we all adhere to where I work. There are a number of guidelines we try and keep in mind but there isn't really enough information to require a physcial document. <a href="http://www.louddog.com/bloggity/2008/03/css-best-practices.php" rel="nofollow noreferrer">This article</a> sums...
<p>The article referred to by @Lee Theobald is a good start.</p> <p>Some basic ideas I try to keep in mind when marking up:</p> <p><strong>Regarding html:</strong></p> <p>Try to write for the next person - that is, think about how easy or difficult it might be for someone else to come and pick up your work and carry...
5,102
<p>I wanted to build a 4-wheel ground robot vehicle with a payload of 25 kg for outdoor use, but I wanted to make the frame/chassis using a 3D printer. The outside temperature ranges between 30 °C-35 °C and the humidity is 70-90%. I think the vehicle would be outside for 4 hours at a time. The dimensions of the vehicle...
<p>The application doesn't look to be demanding at all from a material point of view. Operation below 40 °C and 70-90% RH is not that special.</p> <p>Once taken out PLA for creep, most rigid filaments would work. Nylon deform under constant stress, so screws may get loose over time.</p> <p>PETG, ABS, ABS+ (TitanX/niceA...
<p>My first choice for this would be PET. Not PETG, which is a mess of blobbing, stringing, warping, creep under load, etc., but real PET, also known as BPET (bottle PET) or HTPET (high temperature PET, because it needs high temperatures to print and has high HDT)</p> <p>Unlike ASA, PC, and nylon, PET is easy to print....
2,195
<p>Is there an easy way (in .Net) to test if a Font is installed on the current machine?</p>
<pre><code>string fontName = "Consolas"; float fontSize = 12; using (Font fontTester = new Font( fontName, fontSize, FontStyle.Regular, GraphicsUnit.Pixel)) { if (fontTester.Name == fontName) { // Font exists } else { // Font doesn't exist } } </...
<p>In my case I need to check font filename with extension</p> <p>ex: verdana.ttf = Verdana Regular, verdanai.ttf = Verdana Italic</p> <pre><code>using System.IO; IsFontInstalled("verdana.ttf") public bool IsFontInstalled(string ContentFontName) { return File.Exists(Path.Combine(Environment.GetFolderPath(Enviro...
13,918
<p>One of the biggest issues I have, from a UI standpoint, when building a new website is figuring out what colors I will use and of those colors, do they actually work well together. <br /><br /> I found this site that has really helped me out and I figured I would share it with all of you and also get some responses...
<p>Kuler is pretty nice. I also like <a href="http://www.degraeve.com/color-palette/" rel="nofollow noreferrer">http://www.degraeve.com/color-palette/</a> for just creating a color scheme based on an image, and <a href="http://www.colourlovers.com/" rel="nofollow noreferrer">http://www.colourlovers.com/</a> for pickin...
<p>Color scheme from logo or any image: online tool where you can upload image/logo and it gives you out a suggested color scheme that matches your logo/image.</p> <p>Here is the link <a href="http://www.pictaculous.com/" rel="nofollow noreferrer">http://www.pictaculous.com/</a></p>
38,846
<p>I heard that if you use port 443 (the port usually used for https) for ssh, the encrypted packets look the same to your isp.</p> <p>Could this be a way to avoid traffic shaping/throttling?</p>
<p>I'm not sure it's true that any given ssh packet "looks" the same as any given https packet.</p> <p>However, over their lifetime they don't behave the same way. The session set up and tear down don't look alike (SSH offer a plain text banner during initial connect, for one thing). Also, typically wouldn't an http...
<p>Your ISP is probably more likely to traffic shape port 443 over 22, seeing as 22 requires more real-time responsiveness.</p> <p>Not really a programming question though, maybe you'll get a more accurate response somewhere else..</p>
4,692
<p>We have a project with over 500,000 lines of VB.NET that we need to convert to C#. Any recommendations, based on experience, for tools to use? We are using Visual Studio 2008 and we're targeting 3.5 .</p>
<p>I would concur with the comment. You have 500,000 lines of tried and true VB.NET code. Why on earth would you waste any time changing that? No one says that you can't write all new components in C#.</p> <p>I would consider not worrying about a tool and instead ask yourself, truly, why you are doing this?</p>
<p>I've used <a href="http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx" rel="nofollow noreferrer">this site</a> for a while now for some of my smaller conversions. It has been quite reliable.</p> <p>According to the site, their converter is based off an <a href="http://www.icsharpcode.net/OpenSource/SD/Feat...
9,278
<p>Ok, strange setup, strange question. We've got a Client and an Admin web application for our SaaS app, running on asp.net-2.0/iis-6. The Admin application can change options displayed on the Client application. When those options are saved in the Admin we call a Webservice on the Client, from the Admin, to flush our...
<p>Would it be:</p> <pre>rbServer.Items.Add(ServerDeveloper)</pre> <p>Ok, so since you want to do it from presentation...It is possible, but horribly ugly:</p> <pre> &lt;div&gt; &lt;% rbServer.Items.Add(new ListItem("Dev", ServerDeveloper)); %&gt; &lt;asp:RadioButtonList ID="rbServer" runat="server"&gt; &lt;asp:...
<p>In retrospect, the better solution would be to add it from the codebehind using rbServer.Items.Add()</p>
24,654
<p>I make a lot of use of boost::scoped_ptr in my code and it is great but I'm currently working with software that uses shared_ptr all over the place and I'm wondering if I'm missing something. </p> <p>AFAIK a shared_ptr is only useful if different threads are going to be accessing the same data and you don't know wh...
<p>Threads are irrelevant here. What's relevant is whether it's easy to specify a point at which the object is no longer of use.</p> <p>Suppose several different objects want to use the same object. It might be a pack of data, or for input/output, or some geometric object, or whatever. You want the shared object to...
<p>As answered already, shared_ptr is about shared ownership. However, I would argue that shared ownership is generally a bad thing (exceptions exists, such as flyweight pattern) and it is better to identify an owner and put a scoped_ptr there.</p>
44,742
<p>I want to change the title showing in a page based on information I pick up from within the page (eg to show the number of inbox messages)</p> <p><code>document.getElementsByTagName('title')[0].innerHTML="foo";</code> does change the title tag, but firefox does not update the displayed title (in window and tags) wh...
<p>Try using this instead: </p> <pre> document.title = "MyTitle"; </pre>
<p>Try setting <a href="http://developer.mozilla.org/en/DOM/document.title" rel="nofollow noreferrer">document.title</a> to the new value</p>
17,322
<p>I'm attempting to check for the existence of a node using the following .NET code:</p> <pre><code>xmlDocument.SelectSingleNode( String.Format("//ErrorTable/ProjectName/text()='{0}'", projectName)); </code></pre> <p>This always raises:</p> <blockquote> <p>XPathException: Expression must evaluate to a nod...
<p>The expression given evaluates to a boolean, not a node-set. I assume you want to check whether the ProjectName equals the parametrized text. In this case you need to write</p> <pre><code>//ErrorTable/ProjectName[text()='{0}'] </code></pre> <p>This gives you a list of all nodes (a nodeset) matching the given condi...
<p>Try:</p> <pre><code>Node node = xmlDocument.SelectSingleNode(String.Format("//ErrorTable/ProjectName = '{0}'", projectName)); if (node != null) { // and so on } </code></pre> <p>Edit: silly error</p>
19,006
<p>I am searching for "o" then prints all lines with "o". Any suggestion/code I must apply?</p> <p>data.txt:</p> <pre><code>j,o,b: a,b,d: o,l,e: f,a,r: e,x,o: </code></pre> <p>desired output:</p> <pre><code>j,o,b: o,l,e: e,x,o: </code></pre>
<pre><code>grep o data.txt perl -ne 'print if (/o/);' &lt;data.txt </code></pre>
<p>In Perl:</p> <pre><code>while (&lt;&gt;) { print if /o/; } </code></pre> <p>or with grep:</p> <pre><code>grep 'o' data.txt </code></pre>
25,631
<p>I want to just store the year in one of my models. At the moment I just have a database field called year of type date, but it seems to want to take a whole date (yyyy-mm-dd) rather than just a year.</p> <p>What's the best way to store this? In a date field but using some way of just getting it to store the date bi...
<p>It depends on the range of dates that are possible. If your dates go from BC to far future (negative to more then 4 digits), it would be easiest to store an integer (just for sorting reasons). This is also true if you want to make calculations or compare dates. </p> <p>Otherwise I would probably go with a string.</...
<p>I'd advise against using an arbitrary chosen date in a date field on the basis of maintainability. You will know you have arbitrarily chosen this but will subsequent maintainers of your app? </p> <p>I'd go with an int because that way you are not storing anything other than what you mean to store and there can't ...
24,729
<p>I am setting up an Oracle connection for NHibernate for the first time. I have copied the Oracle.DataAccess.dll file into my bin folder. No matter what I try, I keep getting the same error:</p> <pre><code>Could not load type &gt;NHibernate.Driver.OracleDataClientDriver. Possible cause: no assembly name specified. ...
<p>Did you copy and paste the code? because there's an extra > in there, in the connection.driver_class line</p>
<p>Once I had a similar problem, and I fixed it by adding <code>hibernate</code> to the property names, in your case:</p> <pre><code>&lt;property name="hibernate.connection.provider"&gt;NHibernate.Connection.DriverConnectionProvider&lt;/property&gt; &lt;property name="hibernate.dialect"&gt;NHibernate.Dialect.Oracle9Di...
29,833
<p>Please excuse my lack of knowledge... I know there is a lot of documentation on the internet related to this but I still don't understand.</p> <p>My situation is this:</p> <p>I have an XML file that I need import and eventually replace daily with.</p> <pre><code> &lt;item&gt; &lt;model&gt;AA311-Pink&lt...
<p>You should a read on this - load a XML into MySQL <a href="http://dev.mysql.com/doc/refman/5.5/en/load-xml.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.5/en/load-xml.html</a></p> <p>This allow you to do something like this:</p> <pre><code>mysql&gt; LOAD XML LOCAL INFILE 'items.xml' -&gt; INTO TABLE...
<p>No paying required, <a href="http://web.archive.org/web/20100105150533/http://dev.mysql.com/tech-resources/articles/xml-in-mysql5.1-6.0.html#xml-5.1-importing" rel="nofollow noreferrer">Using XML in MySQL 5.1 and 6.0</a> will answer most of your questions. Also, go back to the top and read the entire page, you can d...
37,629
<p>I need to read from a variety of different text files (I've some delimited files and some fixed width files). I've considered parsing the files line by line (slow using the File.ReadLine type methods) and reading the file using the ODBC text driver (faster) but does anyone have any other (better) suggestions? I'm us...
<p>I'm not sure you could really do a text-and-Excel file parser, not unless by Excel file you mean a comma/pipe/tab delimited file, which is actually just another text file. Reading actual excel files require you to use the MS Office libraries.</p> <p>For delimited text file parsing, you could look into <a href="http...
<p>The File reading process is not slow if you read all file at once using the File class and the methods suggested by John. Depending upon the file's size and what you want to do with them, it may use more or less memory. I'd suggest you try with File.ReadAllText (or whatever is appropriate for you)</p>
5,436
<p>Looking for feedback on :</p> <p><a href="http://code.google.com/p/google-perftools/wiki/GooglePerformanceTools" rel="nofollow noreferrer">http://code.google.com/p/google-perftools/wiki/GooglePerformanceTools</a></p>
<p>There's a <a href="http://web.archive.org/web/20090227051320/http://xtalk.msk.su:80/%7Eott/en/writings/prog-checking/GooglePT.html" rel="nofollow noreferrer">pretty good post</a> that I read a while back that outlines some testing and analysis of GPT in a variety of scenarios</p>
<p>I use GPT at work since 2007, and I totally satisfied. I use it to monitor and optimize a Linux network library, and I have obtained a significant results.</p> <p>The main flaw of GPT is the lack of precision. Due to the design, you only got the main time consuming functions, but this is often what you need when yo...
2,864
<p>Html Textarea elements only wrap when they reach a space or tab character. This is fine, until the user types a looooooooooooooooooooooong enough word. I'm looking for a way to strictly enforce line breaks (eg.: even if it results in "loooooooooooo \n ooooooooooong").</p> <p><img src="https://i.stack.imgur.com/sUmH...
<p>The CSS settings <code>word-wrap:break-word</code> and <code>text-wrap:unrestricted</code> appear to be CSS 3 features. Good luck finding a way to do this on current implementations.</p>
<p>I tested the <strong>&lt;wbr&gt;</strong>, <strong>&amp;#8203;</strong> and <strong>&amp;shy;</strong> techniques. All three worked well in IE 7, Firefox 3 and Chrome. </p> <p>The only one that did not break the copy/paste was the <strong>&lt;wbr&gt;</strong> tag.</p>
7,007
<p>Alright, so I'm working on an application which will use a Linux back-end running PostgreSQL to serve up images to a Windows box with the front end written in C#.NET, though the front-end should hardly matter. My question is:</p> <ul> <li><strong>What is the best way to deal with storing images in Postgres?</stron...
<p>Re jcoby's answer:</p> <p>bytea being a "normal" column also means the value being read completely into memory when you fetch it. Blobs, in contrast, you can stream into stdout. That helps in reducing the server memory footprint. Especially, when you store 4-6 MPix images.</p> <p>No problem with backing up blobs. ...
<p>If your images are small, consider storing them as base64 in a plain text field. </p> <p>The reason is that while base64 has an overhead of 33%, with compression that mostly goes away. (See <a href="https://lemire.me/blog/2019/01/30/what-is-the-space-overhead-of-base64-encoding/" rel="noreferrer">What is the space ...
7,810
<p>I work for a .NET/MSSQL shop that has trouble supporting customers running Novell, partially because we don't have Novell (or the money for it) and partially because we have no one with Novell experience. This question could easily be expanded to "How can we improve our support of technology X when we don't have tec...
<p>There is a <a href="https://secure-www.novell.com/center/regadmin/jsps/eval_app.jsp?buildid=GsODlkBPM2g~" rel="nofollow noreferrer">60 day evaluation trial of Open Enterprise Server 2</a> available (requires free registration). If you install it in a VM, there's nothing stopping you from reinstalling it after 60 day...
<p>There used to be some relatively cheap developers network which we used to belong to before the Novell questions all whithered and died away (famous last words, now I bet we will get one tomorrow), there is never any substitute for having the software / hardware, the only alternative is to write a test program and g...
5,893
<p>I'm running a simple batch file which is generated by a vbscript to delete individual files, however when I execute it, it is deleting entire subdirectories. Anyone have any ideas on this? Below is the batch file. </p> <pre><code>rem 2008-12-15D:\DP-Production\Administrative\BUSINESS\FileLink del D:\DP-Production...
<p>Put filenames between double quotes... (e.g. "D:\My Program\test.exe")</p>
<p>I'm going to assume it is because of this line:</p> <pre><code>del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\ BOBBSS LIST COUNT - DRIBOX 2008-06 ejs.msg /q/ </code></pre> <p>Notice the space there, it says: Delete everything in that folder, then delete the file called BOBBSS, then the file called ...
48,562
<p>On a quest to migrate some new UI into Managed/C# land, I have recently turned on Common Language Runtime Support (/clr) on a large legacy project, which uses MFC in a Shared DLL and relies on about a dozen other projects within our overall solution. This project is the core of our application, and would drive any m...
<p>Make sure the <a href="http://msdn.microsoft.com/en-us/library/ms924287.aspx" rel="noreferrer">Enable String Pooling</a> option under C/C++ Code Generation is turned on.</p> <p>That usually fixes this issue, which is one of those "huh?" MS limitations like the 64k limit on Excel spreadsheets. Only this one affects ...
<p>I have done this with very large mixed-mode (C#/C++) applications three times (3x) and once putting the above fix into place have never seen the error again.</p> <p>And no, if anything this should result in slightly faster run-time execution (nothing you could ever measure, however.)</p> <p>But I agree it's somewh...
3,562
<p>I have a list of integers in C#. I wish to remove duplicates. In C++ I would run it through the std::sort and then std::unique algorithms for a very efficient way of obtaining the unique list.</p> <p>What's the best way to do the same thing in C#? In other words, I'm looking for a more elegant way to do the follow...
<p>What version of .NET are you using?</p> <p>In .NET 3.5 that's as simple as calling the <a href="http://msdn.microsoft.com/en-us/library/system.linq.enumerable.distinct.aspx" rel="noreferrer">Distinct()</a> extension method and then <a href="http://msdn.microsoft.com/en-us/library/bb298736.aspx" rel="noreferrer">ToA...
<p>Alas I only have .NET 2.0 to work with</p>
33,234
<p>I want to be able to load a serialized xml class to a Soap Envelope. I am starting so I am not filling the innards so it appears like: <br /> </p> <pre><code>&lt;Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" /&gt; </code></pre> <p>I want it to appear like: <br/></p> <pre><code>&lt;Envelope x...
<p>The main issue here is that the <code>XmlSerializer</code> calls <code>WriteEndElement()</code> on the <code>XmlWriter</code> when it would write an end tag. This, however, generates the shorthand <code>&lt;tag/&gt;</code> form when there is no content. The <code>WriteFullEndElement()</code> writes the end tag sep...
<p>The two representations are equiavalent. Why do you need it to appear in the latter form?</p>
31,791
<p>Vi and Vim allow for really awesome customization, typically stored inside a <code>.vimrc</code> file. Typical features for a programmer would be syntax highlighting, smart indenting and so on.</p> <p><strong>What other tricks for productive programming have you got, hidden in your .vimrc?</strong></p> <p>I am mos...
<p>You asked for it :-)</p> <pre><code>"{{{Auto Commands " Automatically cd into the directory that the file is in autocmd BufEnter * execute "chdir ".escape(expand("%:p:h"), ' ') " Remove any trailing whitespace that is in the file autocmd BufRead,BufWrite * if ! &amp;bin | silent! %s/\s\+$//ge | endif " Restore c...
<p>I put my .vimrc at <a href="http://dotfiles.org/~petdance/.vimrc" rel="nofollow noreferrer">http://dotfiles.org/~petdance/.vimrc</a>, and I have <a href="http://dotfiles.org/~petdance/" rel="nofollow noreferrer">some other files at dotfiles.org, too</a>.</p>
19,924
<p>I am trying to block Google Reader:</p> <p>reader.google.com </p> <p><strong>www.google.com/reader</strong></p> <p><strong>The hard part is blocking the reader directory</strong></p> <p>I blocked reader.google.com by changing my /etc/hosts file (this is for a Mac)</p> <p>Is there any way to block www.google.com...
<p>You can use <a href="http://www.privoxy.org/" rel="nofollow noreferrer">Privoxy</a> to filter about anything.</p>
<p>What about at the router level? My router as an URL blocker built in.</p>
8,867
<p>Good afternoon,</p> <p>This should be an easy one. I've done the cookie-cutter default ASP.NET 2.0 installation, but I have a couple of programming errors in my application.</p> <p>When I access the webpage on the server itself, I get a detailed ASP error message. However, when i try to run the same thing from a...
<p>Set the <a href="http://msdn.microsoft.com/en-us/library/h0hfz6fc.aspx" rel="nofollow noreferrer">CustomErrors</a> mode to Off. I hope this is not for public facing websites.</p> <p>Off - Specifies that custom errors are disabled. The detailed ASP.NET errors are shown to the remote clients and to the local host. </...
<p>You dont want to do that. Its a security practice violation. </p> <p>Just think how much easier you make it for an attacker, when your source code and app version (among other things) are displayed on the screen.</p>
29,056
<p>I was browsing the <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c">Hidden Features of C#</a> question and thought I would try out one of the features I was unfamiliar with. Unfortunately I use Visual Studio 2005 and the feature in question was introduced later. Is there a good list for new...
<p>This is not a comprehensive list but these are some of my favorite new features of C# 3.0:</p> <p>New type initializers. Instead of saying this: </p> <pre><code>Person person = new Person(); person.Name = "John Smith"; </code></pre> <p>I can say this:</p> <pre><code>Person person = new Person() { Name = "John S...
<p>One of the unknown but powerful feature of Visual Studio 2008 is <a href="http://msdn.microsoft.com/en-us/library/bb126445.aspx" rel="nofollow noreferrer">T4 (Text Template Transformation Toolkit)</a>. T4 is a code generator built right into Visual Studio 2008.</p> <p>Check the <a href="http://weblogs.asp.net/scott...
30,981
<p>Just because I'm curious--is there any C analog to the functionality of the STL in C++? I've seen mention of a <a href="http://www.gtk.org" rel="noreferrer">GTK+</a> library called glib that a few people consider fills the bill but are there other libraries that would provide STL functionality in C?</p>
<p>Yes, <code>glib</code> is a pretty good choice: it includes a lot of utilities for manipulating containers like linked lists, arrays, hash tables, etc. And there is also an object-oriented framework called <code>GObject</code> that you can use to make objects with signals and slots in C (albeit with rather verbose ...
<p>Well since STL's very nature is based on templates which C doesn't have, it would be difficult to even come close to the STL in C. The best you could hope for is some collection classes which manipulate void* pointers to unknown object.</p>
24,593
<p>I have been using code similar to this</p> <pre><code>MessageDlg('', mtWarning, [mbOK], 0); </code></pre> <p>throughout my project, (thanks to the GExperts Message Dialog tool :) ) and i was wondering if anyone knows of a way do override the call and show my own custom Form.</p> <p>The only way i can think to do ...
<p>BTW, you want to add it after the <strong>Dialogs</strong> unit in your uses clause. </p> <p>You have three choices in my opinion:</p> <ol> <li>Add your own unit after the <em>Dialogs</em> unit that has a method called MessageDlg and has the same signature to create your own form.</li> <li>Or create a whole new m...
<p>You can <strong>hijack the MessageDlg function</strong> and make it point to your own MyMessageDlg function (with same signature) but I think it would the least safe of all the solutions.<br> <strong>A bad hack in lieu of clean code IMO.</strong></p> <p>Save the original opcodes of MessageDlg (asm generated by the ...
27,122
<p>I don't have much experience with databases, so I don't know which is better for long-term performance, better practice, etc.</p> <p>Here is my (hypothetical) case: imagine you have a database of customer information and history of purchase orders for each. You want to keep track of how much each customer is buying...
<p>In database terms, there is no elegance in option 2 - it would be considered a hack that you might use as a last resort if your database gets to be truly humongous - not likely to happen for a novice setting it up for the first time (but possible).</p> <p>There would be a lot of work maintaining the totals; and you...
<p>Kudos for thinking ahead, but the question that begs asking, is your sales data going to stay in the transactional database for 20 years? </p> <p>There comes a point where it's going to be a lot easier to move that data into a data warehouse, and just keep your frontline database current. </p> <p>If this is ...
41,323
<p>I want to make a link call a Javascript function through the onclick event and not do anything else (follow the link). What is the best way to do that? I usually do this:</p> <pre><code>&lt;a href="#" onclick="foo()"&gt;Click&lt;/a&gt; </code></pre> <p>But I'm not sure that is the best way and in this case it is n...
<p>Usually, you should always have a fall back link to make sure that clients with JavaScript disabled still has some functionality. This concept is called unobtrusive JavaScript. Example... Let's say you have the following search link:</p> <pre><code>&lt;a href="search.php" id="searchLink"&gt;Search&lt;/a&gt; </code>...
<p>If you include</p> <pre><code>return false; </code></pre> <p>from the onclick event, then the page won't load at all. For example:</p> <pre><code>&lt;a href="#" onclick="foo();return false;"&gt;Click&lt;/a&gt; </code></pre> <p>Or in the function itself:</p> <pre><code>function foo() { // other stuff return...
22,356
<p>In a PHP project I'm developing I have a couple of requests that can be either POST or GET. Currently, I'm using the $_SERVER[REQUEST_METHOD] value to determine, which request array to use. I know that $_REQUEST values can be manipulated with cookies, is the $_SERVER superglobal vulnerable to attacks? </p>
<p>The $_SERVER superglobal is filled by PHP with data it gets from the web server.</p> <p>So unless the attacker replaces the web server with his own, or manages an extremely lucky buffer overflow against the server, you are fine.</p>
<p>REQUEST_METHOD isn't limited to POST and GET though - you also need to handle HEAD (IIRC PHP will terminate the script at the first sign of output when it sees that header) and (on unlikely setups) you might get a few WebDAV ones.</p>
45,160
<p>We are in a Windows environment and looking to automate this process for non-company machines. If a vendor comes on site, we'd like to be able to have him/her hit a website that can perform a quick scan of the workstation to determine if they have the proper MS KB patches and if their virus scanner dats are up to d...
<p>In Windows Vista there are some new APIs to interface with the Security Center component status: <a href="http://msdn2.microsoft.com/en-us/library/bb963845(VS.85).aspx" rel="nofollow noreferrer">http://msdn2.microsoft.com/en-us/library/bb963845(VS.85).aspx</a></p> <p>Through WMI, here's a VBS code snippet I checked...
<p>For AVs that don’t report to WMI or for AVs which WMI retains state info after the AV is uninstalled (there are instances of both cases) you may wish to consider the OPSWAT library. You will need to write and deploy a light client from your website to utilize the library to machines to be interrogated. The library u...
33,404
<p>I have my web browsers set to save what I type into text boxes on forms. I have a lot of search terms stored in the text box of my browser and would like to get at it via a program of some sort before I clear these values out. There are far too many for me to go through one at a time. </p> <p>The web browser mus...
<p>It's tricky. What you have to do is set the Response.Filter property to a custom stream class that you implement. The MVC Contrib project actually has examples of doing this. I'd poke around in there.</p>
<p>Moreover testing, it can be useful for components such as HTML to PDF converters. These components usually uses 2 ways of transformation.</p> <ul> <li>Passing a URL to the conversion method</li> <li>Passing a HTML content (and you can optionally specify the baseUrl to resolve virtual paths)</li> </ul> <p>I am usin...
14,036
<p>I'm working on a side project that would be a simple web application to maintain a list of classes and their upcoming schedules.</p> <p>I would really like to use Linq to SQL for this project, but unfortunately the server environment I'm developing for only has MySql available. I've dabbled briefly with Subsonic bu...
<p>Take a look at Microsoft SQL Server Compact Edition. I believe you can work with MDF files without having to run a server. All code runs in process. I believe it has some limitations but it may work for you and I think it's free.</p>
<p>I don't understand... what do you mean by "having an MDF file in App_Data"? You need a proper SQL Server installation for that to work. You can always use the free SQL Server Express for developing the application, and then move the database to the proper SQL Server once you are done. Check <a href="http://www.micro...
5,567
<p>In .Net you can read a string value into another data type using either <code>&lt;datatype&gt;.parse</code> or <code>Convert.To&lt;DataType&gt;</code>. </p> <p>I'm not familiar with the fundamentals of parse versus convert so I am always at a loss when asked which one is better/faster/more appropriate. </p> <p>So ...
<p>The <code>Convert.ToXXX()</code> methods are for objects that might be of the correct or similar type, while <code>.Parse()</code> and <code>.TryParse()</code> are specifically for strings:</p> <pre><code>//o is actually a boxed int object o = 12345; //unboxes it int castVal = (int) 12345; //o is a boxed enum obj...
<p>There is also the DirectCast method which you should use only if you are sure what the type of the object is. It is faster, but doesn't do any proper checks. I use DirectCast when I'm extracting values from a loosely typed DataTable when I know the type for each column.</p>
3,906
<p>I have a Linux web server farm with about 5 web servers, web traffic is about 20Mbps.</p> <p>We currently have a Barracuda 340 Load Balancer (keep away from this device - piece of crap!) that is acting as a firewall. I want to put in a dedicated firewall and I'd like to know what peoples opinions are on building ve...
<p>As they say - "there are more than one way to skin a cat":</p> <p>Build it yourself, running something like Linux or *BSD. The benefit of this, is that it makes it easy to do the dynamic part of your question, it's just a matter of a few well-placed shell/python/perl/whatever scripts. The drawback is that your ceil...
<p>Don't know much about this field, but maybe an <a href="http://www.astaro.com/" rel="nofollow noreferrer">Astaro security gateway</a>?</p>
7,095
<p>Trends data from Twitter Search API in JSON.</p> <p>Grabbing the file using:</p> <pre><code>$jsonurl = "http://search.twitter.com/trends.json"; $json = file_get_contents($jsonurl,0,null,null); $json_output = json_decode($json); </code></pre> <p>How do I work with data from this object. As an array? Only really ne...
<p>You mean something like this?</p> <pre><code>&lt;?php $jsonurl = "http://search.twitter.com/trends.json"; $json = file_get_contents($jsonurl,0,null,null); $json_output = json_decode($json); foreach ( $json_output-&gt;trends as $trend ) { echo "{$trend-&gt;name}\n"; } </code></pre>
<p>Just use it like it was an object you defined. i.e.</p> <pre><code>$trends = $json_output-&gt;trends; </code></pre>
32,976
<p>my question is similar to other friend posted here...we are trying to develop an application that supports possibly terabytes of information based on a land registry in Paraguay with images and normal data.</p> <p>The problem is that we want to reduce the cost of operation to minimum as possible because it´s like ...
<p><a href="http://www.postgresql.org/" rel="nofollow noreferrer">Postgresql</a>, <a href="http://www.microsoft.com/SQL/default.mspx" rel="nofollow noreferrer">SQL Server 2008</a> and <a href="http://www.oracle.com/database/index.html" rel="nofollow noreferrer">Any recent version of Oracle</a> all have spatial indexing...
<p>Whilst not meeting your criteria of being free, I would strongly recommend you consider using SQL Server 2008, because of two Gfeatures in this version which could help:</p> <ul> <li><p>FILESTREAM - allows you to store your binary images within the filesystem, rather than within the database itself. This will make ...
25,470
<p>I've just added one of the new (MFC Feature Pack) CVSListBox controls to a project. The list of items in the control is tracked by some other objects in my application, so I need to take lots of notifications from the list-box when anything changes so that I can update other stuff. For those that don't know the co...
<p>Assuming that the item will truly be removed every time, you could either:</p> <ul> <li>Do the handling in the OnBeforeRemoveItem override as if the item was already removed</li> <li>Raise your own OnAfterItemRemoved event</li> <li>See if you can get a handle on the underlying list control (whatever it may be) and ...
<p>Try something like this:</p> <pre><code>class my_lbox : public CVSListBox { protected: BOOL OnBeforeRemoveItem(int what_item) { CString txt = GetItemText(what_item); DWORD_PTR idata = GetItemData(what_item); if(true) //up to you to check if this item can be ...
49,945
<p>Does anyone know in .Net 2.0 - .Net 3.5 how to load a jpeg into a System.Windows.Forms.WebControl as a byte-array and with the right mimetypes set so it will show?</p> <p>Something like:<br></p> <pre><code>webBrowser1.DocumentStream = new MemoryStream(File.ReadAllBytes("mypic.jpg")); webBrowser1.DocumentType = "ap...
<p>You have to implement an async pluggable protocol, e.g. IClassFactory, IInternetProtocol... Then you use CoInternetGetSession to register your protocol. When IE calls your implementation, you can serve your image data from memory/provide mime type.</p> <p>It's a bit tedious, but doable. Look at IInternetProtocol an...
<p>You cannot do it. You cannot stuff images into Microsoft's web-browser control.</p> <p>The limitation comes from the IWebBrowser control itself, which .NET wraps up.</p>
36,958
<h2>Edit - New Question</h2> <p>Ok lets rephrase the question more generically. </p> <p>Using reflection, is there a way to dynamically call at runtime a base class method that you may be overriding. You cannot use the 'base' keyword at compile time because you cannot be sure it exists. At runtime I want to list my a...
<p>The standard pattern is for your base class to implement IDisposable and the non-virtual Dispose() method, and to implement a virtual Dispose(bool) method, which those classes which hold disposable resources must override. They should always call their base Dispose(bool) method, which will chain up to the top class ...
<p>If you wanted to use [basetype].Invoke("Dispose"...) then you could implement the function call without the debugger complaining. Then later when the base type actually implements the IDisposable interface it will execute the proper call.</p>
10,359
<p>I'm writing an application which has to be configurable to connect to Oracle, SQL Server and MySQL depending on client whim.</p> <p>Up till now I'd been planning on using the JDBC-ODBC bridge and just connecting to the databases using different connection strings.</p> <p><strong>I'm told this is not very efficient...
<p>I would suggest that you make it configurable and include the three drivers. You can use a pattern like this: Create a super class (lets call it DAO) that provides the functionality of connecting to the database. This could be abstract.</p> <p>Create a concrete sub class for each type of database that you wish to c...
<p>Take a look at <a href="http://docs.oracle.com/javase/7/docs/api/javax/sql/DataSource.html" rel="nofollow noreferrer">Datasource</a>. This is the preferred mechanism for obtaining a database connection.</p> <p>IMO this provides an adminstrator the greatest flexibility for choosing database, connection pooling, and ...
37,790
<p>In T-SQL, you can do this:</p> <pre><code>SELECT ProductId, COALESCE(Price, 0) FROM Products </code></pre> <p>How do you do the same thing in Access SQL? I see examples for doing it with Nz in VBA, but I'm looking for the SQL equivalent.</p> <p>Thanks.</p>
<p>Access supports the <code>Nz</code> function and allows you to use it in a query. Note though that <code>Nz</code> is the same as the T-SQL <code>ISNULL</code> function. It can not take an arbitrary number of parameters like <code>COALESCE</code> can.</p>
<p>COALESCE or NULLIF function are the standard used on sql server for a good migration to access. ISNULLor IIF or CHOOSE are nonstandard function.</p>
30,792
<p>What is the best way to randomize the order of a generic list in C#? I've got a finite set of 75 numbers in a list I would like to assign a random order to, in order to draw them for a lottery type application.</p>
<p>Shuffle any <code>(I)List</code> with an extension method based on the <a href="http://en.wikipedia.org/wiki/Fisher-Yates_shuffle" rel="noreferrer">Fisher-Yates shuffle</a>:</p> <pre><code>private static Random rng = new Random(); public static void Shuffle&lt;T&gt;(this IList&lt;T&gt; list) { int n = li...
<p>A very simple approach to this kind of problem is to use a number of random element swap in the list.</p> <p>In pseudo-code this would look like this:</p> <pre><code>do r1 = randomPositionInList() r2 = randomPositionInList() swap elements at index r1 and index r2 for a certain number of times </code>...
34,430
<p>Visual Basic code does not render correctly with <a href="https://code.google.com/archive/p/google-code-prettify" rel="nofollow noreferrer">prettify.js</a> from Google.</p> <p>on Stack Overflow:</p> <pre><code>Partial Public Class WebForm1 Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As ...
<p>/EDIT: I've rewritten the whole posting.</p> <p>Below is a pretty complete solution to the VB highlighting problem. If SO has got nothing better, <em>please</em> use it. VB syntax highlighting is definitely wanted.</p> <p>I've also added a code example with some complex code literals that gets highlighted correctl...
<p>In the meantime, you can put an extra comment character at the end of your comments to get it to look okay. For example:</p> <pre><code>Sub TestMethod() 'Method body goes here' End Sub </code></pre> <p>You also need to escape internal comment characters in the normal vb-fashion:</p> <pre><code>Sub TestMethod...
5,100
<p>Is anyone aware of a (preferablly free) webservice that would accept a SOAP or REST request.</p> <p>This request would contain an IP address, and the service would return an approximation of that IP's location.</p> <p>EDIT: I need resolution down to the city of possible.</p>
<p><a href="http://www.maxmind.com" rel="nofollow noreferrer">MaxMind</a> do a fairly cheap one. You send the IP as a query string parameter, then it sends you back either a 2 letter code or an error code. We used it for quite a while before moving to our own lookup tables, and it's quick and reliable.</p> <p>Found th...
<p>There is <a href="http://countries.nerd.dk" rel="nofollow noreferrer">http://countries.nerd.dk</a> which provides country information by IP. How much resolution do you need?</p>
14,355
<p>I'm trying to make a proxy object in IronPython, which should dynamically present underlying structure. The proxy itself shouldn't have any functions and properties, I'm trying to catch all the calls in the runtime. Catching the function calls is easy, I just need to define <strong>getattr</strong>() function for my...
<p>Only thousands of values? Do you really need to optimise this further? I can't imagine it's actually a bottleneck at the moment. Have you profiled the app to check that this is really an issue?</p> <p>Given that the method is O(1), you're not going to make the most drastic kind of optimisation you normally aim at -...
<p>You code appears more complex than it really needs to be. The formula is:</p> <pre><code>intervalTop + (intervalBottom - intervalTop) * (val - min) / (max - min); </code></pre> <p>which is much simpler than your version (and works for integral types). There's no conditional branches in there (the Math.Min call) or...
44,172
<p><a href="https://stackoverflow.com/questions/116090/how-do-i-kill-a-process-using-vbnet-or-c">This</a> only helps kills processes on the local machine. How do I kill processes on remote machines?</p>
<p>You can use <a href="http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept04/hey0927.mspx" rel="nofollow noreferrer">wmi</a>. Or, if you don't mind using external executable, use <a href="http://technet.microsoft.com/en-us/sysinternals/bb896683.aspx" rel="nofollow noreferrer">pskill</a></p>
<p>I use the following code. psKill is also a good way to go but sometimes you need to check the some other stuff, for example in my case remote machine was running multiple instances of same process but with different command line arguments, so following code worked for me. </p> <pre><code>ConnectionOptions connectop...
45,296
<p>I have created a foreign key (in SQL Server) by:</p> <pre><code>alter table company add CountryID varchar(3); alter table company add constraint Company_CountryID_FK foreign key(CountryID) references Country; </code></pre> <p>I then run this query:</p> <pre><code>alter table company drop column CountryID; </code...
<p>Try</p> <pre><code>alter table company drop constraint Company_CountryID_FK alter table company drop column CountryID </code></pre>
<p>You can also Right Click on the table, choose modify, then go to the attribute, right click on it, and choose drop primary key.</p>
11,877
<p>I have the following script. It replaces all instances of @lookFor with @replaceWith in all tables in a database. However it doesn't work with text fields only varchar etc. Could this be easily adapted?</p> <pre><code>------------------------------------------------------------ -- Name: STRING REPLACER -- Author: A...
<p>Yeah. What I ended up doing is I converted to varchar(max) on the fly, and the replace took care of the rest.</p> <pre><code> -- PREPARE SET NOCOUNT ON -- VARIABLES DECLARE @tblName NVARCHAR(150) DECLARE @colName NVARCHAR(150) DECLARE @tblID int DECLARE @first bit DECLARE @lookFor nv...
<p>You can not use REPLACE on text-fields. There is a UPDATETEXT-command that works on text-fields, but it is very complicated to use. Take a look at this article to see examples of how you can use it to replace text:</p> <p><a href="http://www.sqlteam.com/article/search-and-replace-in-a-text-column" rel="nofollow nor...
6,079
<p>I would really love to push for TDD development inside the shop I'm working in. Lots of the seniors over there didn't work with unit testing or did unit testing that was hitting the database.</p> <p>I would love to bring some good arguments, books for training, possible coach to ease the transition.</p>
<p>I have found that it is often very hard to push TDD from the developer up. What I tend to do is talk about the benefits of TDD as much as possible and wherever possible, introduce elements of TDD myself bit by bit.</p> <p>If they don't mind, start a new project with unit tests in it (managers seldom mind more test ...
<p>A great challenge with TDD that is brought in "bottom up" is that, when push comes to shove (as it inevitably does when a deadline approaches), management is going to over-ride the emphasis on tests: "We can't afford to test! We have to finish the project!" </p> <p>Of course, this is the very situation (deadline lo...
29,060
<p>I have just realized I've been coercing binding/dependency properties and not really fundamentally understanding the concept.</p> <p>Heres the dependency property:</p> <pre><code>public string Problem { get { return (string)GetValue(ProblemProperty); } set { SetValue(ProblemProperty, value); } } public st...
<p>The problem your having is definitely related to your DataContext. The {Binding} extension needs to know where the property lives that you are binding to. The default location it looks at is the elements DataContext which by default is always set to the DataContext of it's parent element. If you walk the DataContext...
<p>Its a Window this is set in.</p> <pre><code>public partial class Window1 : Window { public string Problem { get { return (string)GetValue(ProblemProperty); } set { SetValue(ProblemProperty, value); } } public static readonly DependencyProperty ProblemProperty = D...
41,082
<p>Are there any libraries out there for Java that will accept two strings, and return a string with formatted output as per the *nix diff command?</p> <p>e.g. feed in </p> <pre><code>test 1,2,3,4 test 5,6,7,8 test 9,10,11,12 test 13,14,15,16 </code></pre> <p>and </p> <pre><code>test 1,2,3,4 test 5,6,7,8 test 9,10,...
<p>I ended up rolling my own. Not sure if it's the best implementation, and it's ugly as hell, but it passes against test input. </p> <p>It uses <a href="http://www.incava.org/projects/java/java-diff/" rel="nofollow noreferrer">java-diff</a> to do the heavy diff lifting (any apache commons StrBuilder and StringUtils i...
<p>Busybox has a diff implementation that is very lean, should not be hard to convert to java, but you would have to add the two-column functionality.</p>
41,306
<p>I'm maintaining a library that contains compiled objects that need to be linked into a 3rd party executable. sometimes the executable has been compiled for Solaris, sometimes as a 32bit Linux Application, sometimes its a 64bit linux application. What I'd love to do is pass one "path" to the library, and have the a...
<p>Use the system info given from "uname" to set the paths automatically?<br> 'uname -s' gives you the kernel name (eg Linux / SunOS)<br> 'uname -i' will give you the architecture (eg x86 / x86_64) </p>
<p>I don't know which simulator you are using but you might try putting the path in the <code>LD_LIBRARY_PATH</code> environment variable. I believe both Cadence and Mentor simulators will look in there. I'm not sure abut VCS. Your simulator's user manual will have details.</p>
20,294
<p>I am slicing with Cura and Slic3r and one important thing that I recently took my attention is that cura positions head in start point of the new layer and then lifts the nozzle. That caused my few printouts to fall as they collided with the nozzle. </p> <p>Slic3r behavior is different: it raises the nozzle in last...
<p>To lift the head to prevent the nozzle to tip over your print you could use an option called <code>Z hop</code> in Cura. Just enter `hop' in the search box on the right side to make those options magically appear (in a recent version of Cura, e.g. version 3.x.x).</p> <p>Other than <code>Z hop</code> there is no def...
<p>OK, after going via all the options I found that CURA has a combing mode which reduces retraction and offers another option which is <code>Avoid Printed Parts When Traveling</code>.</p> <p>That solves my problem.</p>
954
<p>How do people approach mocking out TcpClient (or things like TcpClient)?</p> <p>I have a service that takes in a TcpClient. Should I wrap that in something else more mockable? How should I approach this?</p>
<p>When coming to mock classes that are not test friendly (i.e. sealed/not implementing any interface/methods are not virtual), you would probably want to use the <a href="http://en.wikipedia.org/wiki/Adapter_pattern" rel="noreferrer">Adapter</a> design pattern.</p> <p>In this pattern you add a wrapping class that imp...
<p>Using the Adapter pattern is most definitely the standard TDD approach to the problem. You could, however, also just create the other end of the TCP connection and have your test harness drive that.</p> <p>IMO the widespread use of adapter class obfuscates the most important parts of a design, and also tends to rem...
18,117
<p>Wordpress provides a function called "the_permalink()" that returns, you guessed it!, the permalink to a given post while in a loop of posts.</p> <p>I am trying to URL encode that permalink and when I execute this code:</p> <pre><code>&lt;?php print(the_permalink()); $permalink = the_permalink(); print($permalink)...
<p>According to the docs, <a href="http://codex.wordpress.org/Template_Tags/the_permalink" rel="noreferrer"><code>the_permalink</code></a> prints the permalink vs returns it. So, <code>urlencode</code> isn't getting anything to encode.</p> <p>Try <a href="http://codex.wordpress.org/Template_Tags/get_permalink" rel="no...
<p>@Jonathan has the reason why, and the way you should deal with it in WordPress (ie. use the right function for the job).</p> <p>Here is how to fix it when there isn't a function that returns a string:</p> <pre><code>ob_start(); the_permalink(); $permalink = ob_get_clean(); print(urlencode($permalink)); </code></pr...
34,537
<p>What's the best way to animate a background image sliding to the left, and looping it? Say I've got a progress bar with a background I want to animate when it's active (like in Gnome or OS X).</p> <p>I've been playing with the <code>$(...).animate()</code> function and trying to modify the relevant CSS property, bu...
<p>As soon as I posted this I figured it out. In case it helps anyone else, here's the function I came up with:</p> <pre><code>function animateBar(self) { // Setup var bar = self.element.find('.ui-progress-bar'); bar.css('background-position', '0px 0px'); bar.animate({ backgroundPosition: '-2...
<p>You can use the <a href="http://www.spritely.net/documentation/" rel="nofollow">Spritely</a> plugin , and for your case of animating a sliding background and repeating it, you can use the pan() method which makes the background image pan continually to the left or right and then repeat.</p>
47,906
<p>If I had a phone number like this </p> <pre><code>string phone = "6365555796"; </code></pre> <p>Which I store with only numeric characters in my database <strong>(as a string)</strong>, is it possible to output the number like this: </p> <pre><code>"636-555-5796" </code></pre> <p>Similar to how I could if I we...
<p>Best I can think of without having to convert to a long/number and so it fits one line is:</p> <pre><code>string number = "1234567890"; string formattedNumber = string.Format("{0}-{1}-{2}", number.Substring(0,3), number.Substring(3,3), number.Substring(6)); </code></pre>
<p>To control string format of a number for display in an ASP.NET Gridview or another control, you can wrap your item in a helper class for display purposes:</p> <pre><code>public class PhoneDisplay { long phoneNum; public PhoneDisplay(long number) { phoneNum = number; } public override str...
30,719
<p>Sometimes my meshes turn out with artifacts Which can be seen in the bottom image. What is the cause? The first image shows my mesh which its generated from. I've tried multiple slicers. This tends to occur sometimes. Any help appreciated. Is there something going over my head???</p> <p><a href="https://i.stack.img...
<p>Hardboard is called <em>Masonite</em> here in the States because that is the trade name of the product. If you look up the <a href="http://www.gunnersens.co.nz/images/stories/products/Masonite%20Standard/specs/Australian_Hardboards_Masonite_MSDS.pdf" rel="noreferrer">Material Safety Data Sheet</a> you will see Mason...
<p>Masonite or hardboard is a high-density board without a resin. It is <a href="https://www.chromaluxe.com/wp-content/uploads/SDS-Hardboard-Universal-Woods.pdf" rel="nofollow noreferrer">listed</a> at around 200 to 275 °C for its autoignition temperature. Just for comparison, let's look at similar products.</p> <p>Med...
1,240
<p>As I don't use vi all that much and certainly not for my primary editor, I can't remember any of the vi commands. Does anyone have a recommendation for a quick start guide or command summary?</p>
<p>This is the best to keep in your desk, full of coffee works great :-)</p> <p><a href="https://i.stack.imgur.com/aJ7Pk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aJ7Pk.jpg" alt="Vi Mug"></a><br> <sub>(source: <a href="https://www.thinkgeek.com/images/products/front/vi_mug.jpg" rel="nofollow n...
<p>Excellent book, and links in other answers. If you are in Vim, don't forget the old faithful:</p> <pre><code>&lt;ESC&gt;:he&lt;Return&gt; </code></pre>
32,159
<p>In a tic-tac-toe implementation I guess that the challenging part is to determine the best move to be played by the machine.</p> <p>What are the algorithms that can pursued? I'm looking into implementations from simple to complex. How would I go about tackling this part of the problem?</p>
<p>The strategy from Wikipedia for playing a perfect game (win or tie every time) seems like straightforward pseudo-code:</p> <blockquote> <p><strong>Quote from <a href="http://en.wikipedia.org/wiki/Tic-tac-toe" rel="noreferrer">Wikipedia (Tic Tac Toe#Strategy)</a></strong></p> <p>A player can play a perfect ga...
<p>This answer assumes you understand implementing the perfect algorithm for P1 and discusses how to achieve a win in conditions against ordinary human players, who will make some mistakes more commonly than others.</p> <p>The game of course should end in a draw if both players play optimally. At a human level, P1 pla...
15,263