instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I'm trying to create a Zip file from .Net that can be read from Java code.</p> <p>I've used SharpZipLib to create the Zip file but also if the file generated is valid according to the CheckZip function of the #ZipLib library and can be successfully uncompressed via WinZip or WinRar I always get an error when trying...
<p>I have used <a href="http://www.codeplex.com/DotNetZip" rel="noreferrer">DotNetZip library</a> and it seems to work properly. Typical code:</p> <pre><code>using (ZipFile zipFile = new ZipFile()) { zipFile.AddDirectory(sourceFolderPath); zipFile.Save(archiveFolderName); } </code></pre>
<p>To judge whether it's really a conformant ZIP file, see PKZIP's <a href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT" rel="nofollow noreferrer">.ZIP File Format Specification</a>.</p> <p>For what it's worth I have had no trouble using SharpZipLib to create ZIPs on a Windows Mobile device and open them w...
9,643
<p>I'm looking into writing a audio syntesizer in Java, and was wondering if anybody has any advice or good resources for writing such a program. I'm looking for info on generating raw sound waves, how to output them into a usable form (playing over speakers), as well as general theory on the topic. Thanks guys.</p>
<ol> <li><p>This problem is basically about mapping functions to arrays of numbers. A language that supports first-class functions would come in really handy here.</p></li> <li><p>Check out <a href="http://www.harmony-central.com/Computer/Programming" rel="nofollow noreferrer">http://www.harmony-central.com/Computer/P...
<p>I dont't know if that helps, but if you can use MIDI for anything, you should check out <a href="http://www.jfugue.org/" rel="nofollow noreferrer">JFuge</a>.</p>
5,717
<p>Following on from <a href="https://3dprinting.stackexchange.com/questions/6342/what-level-of-voltage-does-the-creality-ender-3-run-at/6521#comment9993_6521">What level of voltage does the Creality Ender-3 run at?</a></p> <p><a href="https://3dprinting.stackexchange.com/questions/6342/what-level-of-voltage-does-the-...
<p>I own the Ender 3, and it runs on 24V, as this photo of the power supply shows: <a href="https://i.stack.imgur.com/3VrGx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3VrGx.jpg" alt="Ender3 Power supply" /></a></p> <p>From power supply to the board, it uses a 2-wire line connected with a XT60 p...
<p>This answer addresses the input voltage. If you look up the official replacement board at the official Creality store the board features a single pair of connectors next to it says: 12 V / 24 V. So you can either use 12 V, or 24 V, not both. An internal regulator will most probably reduce the voltage anyways. </p> ...
981
<p>My app open file in subdirectory of directory where it is executed, subdirectory is called <code>sample</code> and it contains files:</p> <ul> <li><code>example.raf</code> (example extension, non significant)</li> <li><code>background.gif</code></li> </ul> <p><code>example.raf</code> contains relative path to <cod...
<p>Next code from my project ZipSolution (<a href="http://zipsolution.codeplex.com/" rel="nofollow noreferrer">http://zipsolution.codeplex.com/</a>) shows how to resolve and create relative pathes in .net</p> <pre><code>using System; using System.Collections.Generic; using System.Text; using System.IO; namespace ZipS...
<p>You can try to change the current directory to the directory containing your executable using Environment.CurrentDirectory before reading from relative paths. Or instead if you have a relative path (Path.IsPathRooted) you can combine (Path.Combine) your root directory with the relative path to have an absolute one.<...
19,901
<p>In interpreted programming languages, such as PHP and JavaScript, what are the repercussions of going with an Object Oriented approach over a Procedural approach?</p> <p>Specifically what I am looking for is a checklist of things to consider when creating a web application and choosing between Procedural and Object...
<p>Maybe I'm crazy but worrying about speed in cases like this using an interpretive language is like trying to figure out what color to paint the shed. Let's not even get into the idea that this kind of optimization is entirely pre-mature.</p> <p>You hit the nail on the head when you said 'maintainability'. I'd choos...
<p>I've actually done a small test like this in python on a website I maintain and found that they are almost equivalent in speed, with the procedural approach winning by something like ten-thousandths of a second, but that the OO code was so significantly cleaner I didn't continue the exercise any longer than one iter...
2,520
<p>We recently had a project where we released beta of a big web app on our client's server. Our client requested us to do bug fixes as they come, and we tried to do it same way. Normally while building an app on our prototype server is way easier, as I just have to issue simple 'svn up' command which takes a second. <...
<p>Depending on the tools available on the server, you could either do a <code>svn diff -r x:y</code> where x is the revision you last updated too and y the last revision you want to update to (probably the last revision on your repository) to generate a patch and then apply the patch with the <code>patch</code> comman...
<p>Depends on the programming environment you use. In Smalltalk and the web application server like <a href="http://www.aidaweb.si" rel="nofollow noreferrer">Aida/Web</a> we can upgrade the live web applications on the fly, without stopping it. </p> <p>The server is connected to the SCM of choice like Monticello for S...
43,732
<p>I want to get the results of a stored procedure and place them into a CSV file onto an FTP location.</p> <p>The catch though is that I cannot create a local/temporary file that I can then FTP over.</p> <p>The approach I was taking was to use an SSIS package to create a temporary file and then have a FTP Task withi...
<p>This step-by-step example is for others who might stumble upon this question. This example uses <em>Windows Server 2008 R2 server</em> and <em>SSIS 2008 R2</em>. Even though, the example uses <em>SSIS 2008 R2</em>, the logic used is applicable to <em>SSIS 2005</em> as well. Thanks to <code>@Kev</code> for the <em>FT...
<p>Try using a CLR stored procedure. You might be able to come up with something, but without first creating a temporary file, it might still be difficult. Could you set up a share on another machine and write to that, and then ftp from there?</p>
4,092
<p>As a primarily Windows developer, perhaps I'm missing something cultural in the Linux community, but it has always confused me.</p> <p>When downloading something that the files are first put into a <code>.tar</code> archive then <em>zipped</em>. Why the two-step process? Doesn't <em>zipping</em> achieve the file gr...
<p><code>bzip</code> and <code>gzip</code> work on single files, not groups of files. Plain old <code>zip</code> (and <code>pkzip</code>) operate on groups of files and have the concept of the archive built-in.</p> <p>The *nix philosophy is one of the small tools that do specific jobs very well and can be chained toge...
<p>Tar is not only a file format, but it is a tape format. Tapes store data bit-by-bit. Each storage implementation was custom. Tar was the method by which you could take data off a disk, and store it onto tape in a way that other people could retrieve it without your custom program.</p> <p>Later, the compression pr...
37,830
<p>need help in Fortran...</p> <p>This is the main loop of the program..</p> <pre><code>do iStep=0,nStep write(7,*)iStep !* Compute new temperature using FTCS scheme. do i=1,N if( istep==0) then !only for t=0 tt_new(i)=250 write(7,*)tt_new(i) else if(i==1) the...
<p>For <code>i=1</code> and <code>i=N</code>, you are printing <code>tt(i)</code> instead of <code>tt_new(i)</code> - the calculation is being performed correctly, but the results will not be displayed properly. Stepping through the code with a debugger is quite helpful in cases like this.</p> <p>I would also suggest...
<p>Try formatting your inner <code>IF ELSE</code> in a more readable way:</p> <pre><code>if( istep==0) then !only for t=0 tt_new(i)=250 write(7,*)tt_new(i) else if(i==1) then tt_new(i)=2*coeff*(tt(i+1)+35.494)-0.036*tt(i) write(7,*)tt(i) else if(i==N) then tt_new(i)=2*coeff*(tt(i-1)+35.494)-0.036*...
45,191
<p>I'm not of the Perl world, so some of this is new to me. I'm running Ubuntu Hardy LTS with apache2 and mod_fcgid packages installed. I'd like to get MT4 running under fcgid rather than mod-cgi (it seems to run OK with plain-old CGI).</p> <p>I can't seem to get even a simple Perl script to run under fcgid. I creat...
<p>I use CGI::Fast more than FCGI, but the idea is the same, I think. The goal of fast cgi is to load the program once, and iterate in a loop for every request.</p> <p>FCGI's man page says :</p> <pre><code>use FCGI; my $count = 0; my $request = FCGI::Request(); while($request-&gt;Accept() &gt;= 0) { print("Cont...
<p>Anyway, based on your server's error logs, it looks like FCGI is working, and being invoked properly, but your script just isn't running in a loop, waiting for the next request to come along. So your test script did accomplish the task -- reporting whether FastCGI is configured or not. So now you should be able to r...
44,024
<p>Is there a way to log(/var/log) commands executed by users in the Unix shell?</p>
<p>Assuming you're doing this for security purposes, take a look at process accounting. You didn't say which UNIX variant you're on, but for Linux, take a look at <a href="http://www.gnu.org/software/acct/" rel="nofollow noreferrer">http://www.gnu.org/software/acct/</a> Beware that you will generate a lot of data as pr...
<p>Dumb idea off the top of my head:</p> <p><code>script</code> will copy the session to a file. You could send it to a named pipe which is being read by a logging process---only thing is, you'll get the output as well as the commands.</p>
45,183
<p>How do I select one or more random rows from a table using SQLAlchemy? </p>
<p>This is very much a database-specific issue.</p> <p>I know that PostgreSQL, SQLite, MySQL, and Oracle have the ability to order by a random function, so you can use this in SQLAlchemy:</p> <pre><code>from sqlalchemy.sql.expression import func, select select.order_by(func.random()) # for PostgreSQL, SQLite selec...
<p>Theres a couple of ways through SQL, depending on which data base is being used.</p> <p>(I think SQLAlchemy can use all these anyways)</p> <p>mysql:</p> <pre><code>SELECT colum FROM table ORDER BY RAND() LIMIT 1 </code></pre> <p>PostgreSQL:</p> <pre><code>SELECT column FROM table ORDER BY RANDOM() LIMIT 1 </cod...
8,583
<p>I read this: <a href="https://stackoverflow.com/questions/184254/type-systemwebuiwebcontrolssessionparameter-does-not-have-a-public-property-nam">link text</a></p> <p>My dev box , everything runs fine. On production server, they installed V3.5 framework and i got to my site and i got this error.</p> <p>Do I have t...
<p>Once connected to Sql Server 2005 Database, From Object Explorer Window, right click on the database which you want to import table into. Select Tasks -> Import Data. This is a simple tool and allows you to 'map' the incoming data into appropriate table. You can save the scripts to run again when needed.</p>
<p>The import wizard does offer that option. You can either use the option to write your own query for the data to import, or you can use the copy data option and use the "Edit Mappings" button to ignore columns you do not want to import.</p>
49,202
<p>I'm using MinGW with GCC 3.4.5 (mingw-special vista r3).</p> <p>My C application uses a lot of stack so I was wondering is there any way I can tell programatically how much stack is remaining so I can cleanly handle the situation if I find that I'm about to run out.</p> <p>If not what other ways would you work aro...
<p>The getrusage function gets you the current usage . (see <a href="http://www.kernel.org/doc/man-pages/online/pages/man2/getrusage.2.html" rel="noreferrer"><code>man getrusage</code></a>).</p> <p>The <code>getrlimit</code> in Linux would help fetching the stack size with the <code>RLIMIT_STACK</code> parameter.</p> ...
<p>maybe this will help for Windows platform only:</p> <p>in the PE header (IMAGE_NT_HEADERS) of your exe there are some records such as:</p> <pre> typedef struct _IMAGE_NT_HEADERS { DWORD Signature; IMAGE_FILE_HEADER FileHeader; IMAGE_OPTIONAL_HEADER32 OptionalHeader; } IMAGE_NT_HEADERS32, *PIMAGE_NT_HE...
7,742
<p>How would you write (in C/C++) a macro which tests if an integer type (given as a parameter) is signed or unsigned?</p> <pre> #define is_this_type_signed (my_type) ... </pre>
<p>If what you want is a simple macro, this should do the trick:</p> <pre><code>#define is_type_signed(my_type) (((my_type)-1) &lt; 0) </code></pre>
<p>You could do this better with a template function, less macro nasty business.</p> <pre><code> template &lt;typename T&gt; bool IsSignedType() { // A lot of assumptions on T here T instanceAsOne = 1; if (-instanceAsOne &gt; 0) { return tr...
9,051
<p>Which GUI framework/library would you choose if you were to start your new project <strong>now</strong> or in the near future?</p> <p>It has to be free for commercial use and cross platform.</p> <p>I have been a happy swing user, but Sun seems like pushing <strong>swing</strong> to deprecation, while pushing <stro...
<p>I think that despite Sun's mismanagement, Swing is still an excellent framework. You can do a <em>lot</em> with it, especially if that "lot" involves custom rendered UI controls. If your application needs a branded LAF, or even just a few complex custom controls here and there, Swing is exactly what you want.</p> ...
<p>I still use Swing, and will continue to do so until it is no longer supported at all. Thanks for the heads up about Javafx, I'll have to look into that one now.</p>
35,593
<p>I know of many utilities that can tell me the bitrate of an MP3 file, but I've never seen one that can tell me whether or not the MP3 file is VBR (variable bit rate - the bit rate fluctuates within the file) or a CBR (constant bit rate - the bit rate stays the same within the file). My guess is that most programs ar...
<p>MP3 files are essentially build of so called frames. Each frame has a small header that stores information about the frame. The header also stores which bitrate was used for the frame. In CBR files, all frames use the same bitrate and therefore every header has the same bitrate information.</p> <p>To detect if a fi...
<p>Check this <a href="http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=79" rel="nofollow noreferrer">MP3Header Class</a>, it has a method that tells you if the mp3 file is VBR, and all the mp3 header information...</p> <pre><code>... boolVBitRate = LoadVBRHeader(bytVBitRate); ... </code></pre>
23,860
<p>I am getting an 'access is denied' error when I attempt to delete a folder that is not empty. I used the following command in my attempt: <code>os.remove("/folder_name")</code>. </p> <p>What is the most effective way of removing/deleting a folder/directory that is not empty?</p>
<pre><code>import shutil shutil.rmtree('/folder_name') </code></pre> <p><a href="http://docs.python.org/library/shutil.html#shutil.rmtree" rel="noreferrer">Standard Library Reference: shutil.rmtree</a>.</p> <p>By design, <code>rmtree</code> fails on folder trees containing read-only files. If you want the folder to ...
<p>You can use os.system command for simplicity:</p> <pre><code>import os os.system("rm -rf dirname") </code></pre> <p>As obvious, it actually invokes system terminal to accomplish this task.</p>
38,954
<p>I have a table in my MYSQL database which does not have a primary key, but has a unique key on two columns. When using MyEclipse's Hibernate reverse engineer tool to create a mapping for that table, it generates two classes, one for named after the table itself, and one with an "Id" suffix. It seems most of the us...
<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,459
<p>Do you generally assume that toString() on any given object has a low cost (i.e. for logging)? I do. Is that assumption valid? If it has a high cost should that normally be changed? What are valid reasons to make a toString() method with a high cost? The only time that I get concerned about toString costs is wh...
<p>No it's not. Because ToString() can be overloaded by anyone, they can do whatever they like. It's a reasonable assumption that ToString() SHOULD have a low cost, but if ToString() accesses properties that do "lazy loading" of data, you might even hit a database inside your ToString().</p>
<p>Possibly the largest cost with naive toString() chaining is appending all those strings. If you want to generate large strings, you should use an underlying representation that supports an efficient append. If you know the append is efficient, then toString()s probably have a relatively low cost.</p> <p>For examp...
11,301
<p>I want to find a linux command that can return a part of the string. In most programming languages, it's the <code>substr()</code> function. Does bash have any command that can be used for this purpose. I want to be able to do something like this... <code>substr "abcdefg" 2 3</code> - prints <code>cde</code>.</p> <...
<p>If you are looking for a shell utility to do something like that, you can use the <code>cut</code> command.</p> <p>To take your example, try:</p> <pre><code>echo "abcdefg" | cut -c3-5 </code></pre> <p>which yields</p> <pre><code>cde </code></pre> <p>Where <code>-cN-M</code> tells the cut command to return colum...
<pre><code>${string:position:length} </code></pre>
27,004
<p>I use VNC to connect to a Linux workstation at work. At work I have a 20" monitor that runs at 1600x1200, while at home I use my laptop with its resolution of 1440x900. If I set the vncserver to run at 1440x900 I miss out on a lot of space on my monitor, whereas if I set it to run at 1600x1200 it doesn't fit on the...
<p>Real VNC server 4.4 includes support for Xrandr, which allows resizing the VNC. Start the server with:</p> <pre><code>vncserver -geometry 1600x1200 -randr 1600x1200,1440x900,1024x768 </code></pre> <p>Then resize with:</p> <pre><code>xrandr -s 1600x1200 xrandr -s 1440x900 xrandr -s 1024x768 </code></pre>
<p>I think that depends on your window manager.</p> <p>I'm a windows user, so this might be a wrong guess, but: Isn't there something called <a href="http://de.wikipedia.org/wiki/X-Server" rel="nofollow noreferrer">X-Server</a> running on linux machines - at least on ones that might be interesting targets for VNC - th...
3,663
<p>I have the following Python code: </p> <pre><code>import xml.dom.minidom import xml.parsers.expat try: domTree = ml.dom.minidom.parse(myXMLFileName) except xml.parsers.expat.ExpatError, e: return e.args[0] </code></pre> <p>which I am using to parse an XML file. Although it quite happily spots simple XML ...
<p>See <a href="https://stackoverflow.com/questions/15798/how-do-i-validate-xml-against-a-dtd-file-in-python">this question</a> - the accepted answer is to use <a href="http://codespeak.net/lxml/validation.html" rel="nofollow noreferrer">lxml validation</a>.</p>
<p>I believe you need to switch from expat to xmlproc.<br> See: <a href="http://code.activestate.com/recipes/220472/" rel="nofollow noreferrer">http://code.activestate.com/recipes/220472/</a></p>
38,263
<p>I'm trying to use <code>mysqldump</code> to dump a schema, and it mostly works but I ran into one curiosity: the <code>-p</code> or <code>--password</code> option seems like it is doing something other than setting the password (as the <code>man</code> page and <code>--help</code> output say it should).</p> <p>Spec...
<p>From man mysqldump:</p> <blockquote> <p>--password[=password], -p[password]</p> <p>The password to use when connecting to the server. If you use the short option form (-p), you cannot have a space between the option and the password. If you omit the password value following the --pa...
<p>Maybe your user "test" doesn't have the permission to access your "lose" database?</p>
17,946
<p>What is the Perl equivalent of <code>strlen()</code>?</p>
<p><code>length($string)</code></p> <pre>perldoc -f length length EXPR length Returns the length in characters of the value of EXPR. If EXPR is omitted, returns length of $_. Note that this cannot be used on an entire array or hash to find out how many elements these have. For ...
<p>You shouldn't use this, since length($string) is simpler and more readable, but I came across some of these while looking through code and was confused, so in case anyone else does, these also get the length of a string:</p> <pre><code>my $length = map $_, $str =~ /(.)/gs; my $length = () = $str =~ /(.)/gs; my $len...
27,584
<p>Header, footer and sidebars have fixed position. In the center a content area with both scroll bars. No outer scroll bars on the browser. I have a layout that works in IE7 and FF. I need to add IE6 support. How can I make this work?</p> <p>Here is an approximation of my current CSS.</p> <pre class="lang-html prettyp...
<p>Might be overkill for your project, but <a href="http://dean.edwards.name/IE7/" rel="noreferrer">Dean Edwards' IE7 javascript adds support for fixed positioning to IE6</a>.</p>
<p>Try IE7.js. Should fix your problem without having to make any modifications.</p> <p>Link: <a href="http://code.google.com/p/ie7-js/" rel="nofollow noreferrer">IE7.js</a></p>
5,027
<p>My master page has a contentplaceholder in the head tag.</p> <p>Because I want my page's title to represent the function of the current page and because I want the title to be translated in the user's language I have added a title tag in the page's head's contentplaceholder. All jolly and good except that now there...
<p>I ran into the same problem and <a href="http://blogs.lotterypost.com/speednet/2007/07/aspnet-tip-how-to-prevent-the-title-tag-fro.htm" rel="noreferrer">found a solution</a> that seems to work. It's pretty hacky but at the same time pretty simple. Just add another title tag in the head, put a runat="server" attribut...
<p>There is an attribute in the @Page directive called Title for setting the title of the page. It is also available accessible as a property on the Page control.</p> <p>You do not need to explicitly declare a within the tag via the content place holder.</p> <p>At least it is for basic ASP.NET pages using MasterPa...
48,446
<p>I have a function that passes an array to another function as an argument, there will be multiple data types in this array but I want to know how to pass a function or a reference to a function so the other function can call it at any time.</p> <p>ex.</p> <p>function A:</p> <pre><code>add(new Array("hello", some ...
<p>Simply pass the function name as an argument, no, just like in AS2 or JavaScript?</p> <pre><code>function functionToPass() { } function otherFunction( f:Function ) { // passed-in function available here f(); } otherFunction( functionToPass ); </code></pre>
<p>You can do the following:</p> <pre><code>add(["string", function():void { trace('Code...'); }]); </code></pre> <p>...or...</p> <pre><code>... add(["string", someFunction]); ... private function someFunction():void { trace('Code...'); } </code></pre>
17,952
<p>Does anyone know of a good tool that converts .pst to .csv files through command line? </p>
<p>Can you assume Outlook is installed on the computer? If so, I believe it can be background scripted using OLE or something similar. I've done file conversions through Excel using Ruby that way.</p> <p>And here's a <a href="http://www.unur.com/comp/ppp/perl-win32-ole-outlook-ex1.html" rel="nofollow noreferrer">Perl ...
<p>one time only? or programmatically?</p> <p>if one time only, import into a mail program that handles mbox (e.g. Thunderbird), at which point you just have text files, manipulate as desired.</p> <p>otherwise, no idea, best of luck.</p>
41,200
<p><strong>What in C#.NET makes it more suitable</strong> for some projects than VB.NET?</p> <p>Performance?, Capabilities?, Libraries/Components?, Reputation?, Reliability? Maintainability?, Ease?</p> <hr> <p>Basically anything <strong>C# can do, that is impossible using VB,</strong> or vice versa. Things you just ...
<p>C# and VB are basically the same however there are some minor differences. Aside from the obvious grammar differences you have the following differences:</p> <ol> <li>C# can call unsafe code</li> <li>VB has optional parameters (Coming in C#4.0)</li> <li>VB is easier to use when making late bound calls (Coming in C#...
<p>for the moment VB.Net has a very poor implementation of lambda expressions. Meaning that you can't do the neat things that you can in C#. Well you can, but it needs a very ugly workaround in most cases.</p> <p>This is solved in VB.Net 10.0.</p>
49,836
<p><strong>Let's share Java based web application architectures!</strong></p> <p>There are lots of different architectures for web applications which are to be implemented using Java. The answers to this question may serve as a library of various web application designs with their pros and cons. While I realize that t...
<p>Ok I'll do a (shorter) one:</p> <ul> <li>Frontend : <a href="https://tapestry.apache.org/index.html" rel="noreferrer">Tapestry</a> (3 for older projects, 5 for newer projects)</li> <li>Business layer: Spring</li> <li>DAO's : Ibatis</li> <li>Database : Oracle</li> </ul> <p>We use Sping transaction support, and star...
<p>I've worked on projects that use that rigid manager pattern. Historically, I was a huge proponent of the rigid hierarchy where everything fit into a neat box. As I progress in my career I find it to be forced in a lot of cases. I believe that adopting a more agile mindset towards application design leads to a bette...
36,473
<p>I am following the <a href="http://blogs.msdn.com/johngossman/archive/2005/10/08/478683.aspx" rel="noreferrer">M-V-VM</a> pattern for my WPF UI. I would like to hook up a command to the TextChanged event of a TextBox to a command that is in my ViewModel class. The only way I can conceive of completing this task is t...
<p>First off, you've surely considered two-way data binding to your viewmodel, with an UpdateSourceTrigger of PropertyChanged? That way the property setter of the property you bind to will be called every time the text is changed?</p> <p>If that's not enough, then I would tackle this problem using Attached Behaviours....
<p>Can you not just handle the TextChanged event and execute the command from there?</p> <pre><code>private void _textBox_TextChanged(object sender, EventArgs e) { MyCommand.Execute(null); } </code></pre> <p>The alternative, as you say, is to create a <code>TextBox</code> that acts as a command source, but that d...
7,968
<p>I am using the YUI layout manager which seems to work at an OK speed. However if the page contains a large <code>&lt;Table&gt;</code> with about 500 rows, the YUI <code>render()</code> function takes about a <strong>minute</strong> longer to run.</p> <p>When I open the same page without the layout manager it opens ...
<p>I finally figured it out myself.</p> <p>The trick is to hide the content that should be ignored by the layout manager.</p> <p>Before calling <code>render()</code> set the <code>style.display = 'none'</code> for a tag that contains a large chunk of the page you don't need the layout manager to manage. Set it back t...
<p>Do you mean the render() method of your large table is taking a long time?</p> <p>the YUI DataTable has a <a href="http://developer.yahoo.com/yui/datatable/#renderLoop" rel="nofollow noreferrer">renderLoopSize</a> property specifically for this kind of situation. It makes the table render to the DOM every X rows, r...
22,628
<p>I have a sprite loaded as a texture and I need to animate it, allowing it to "face" left or right -- essentially sometimes I need to "flip" it. I know that OpenGL has a gltranslate which repositions an object, and glrotate which rotates it. Is there a method that simply flips it across one axis? If not, how wou...
<p>I haven't messed around with point sprites, but I believe that they are textures. Textures have texture matrices, which means you can use <code>glTranslatef()</code>, <code>glScalef()</code> and <code>glRotatef()</code> on them.</p> <p>I would try out something along the lines of <code>glScalef(-1,1,1);</code> whic...
<p>You can't do this with OpenGL point-sprites; although you can move the center of the sprite around, the shape of it is always oriented the same way.</p> <p>What you <em>can</em> do is draw your sprites as quads, which lets you flip, rotate and mess with them any way you want. There are tutorials on manually drawing...
12,897
<p>I have a MySQL database that I want to <em>archive</em>. What is the best way to do this?</p> <p>Note: I <em>don't</em> want to just do a <em>backup</em>. I want to do a one time export of the data for long term storage in a way that I can get at on a later date. Particularly, I want to not be tied to MySQL, a data...
<p>Exporting to CSV, encoding binary data with Base64 encoding, and then compressing with gzip sounds like a good way to go. I'd advise you to think well about your choice of DVDs though. Recordable media tends to deteriorate rapidly over the years.</p>
<pre><code>mysql&gt; ALTER TABLE arch2 ENGINE='ARCHIVE'; </code></pre> <p><img src="https://i.stack.imgur.com/zdQ41.jpg" alt="enter image description here"></p>
43,626
<p>Is it possible to use an UnhandledException Handler in a Windows Service?</p> <p>Normally I would use a custom built Exception Handling Component that does logging, phone home, etc. This component adds a handler to System.AppDomain.CurrentDomain.UnhandledException but as far as I can tell this doesn’t achieve anyth...
<p>Ok, I’ve done a little more research into this now. When you create a windows service in .Net, you create a class that inherits from System.ServiceProcess.ServiceBase (In VB this is hidden in the .Designer.vb file). You then override the OnStart and OnStop function, and OnPause and OnContinue if you choose to. The...
<p>You can subscribe to the <a href="http://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception.aspx" rel="nofollow noreferrer">AppDomain.UnhandledException event</a>. If you have a message loop, you can tie to the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.application.threa...
8,264
<p>When implementing an +initialize or +load method in one of your Objective-C classes, should you <em>always</em> start with this kind of guard?:</p> <pre><code>@implementation MyClass + (void)initialize { if (self == [MyClass class]) { ... } } ... @end </code></pre> <p>Seems like code in +load and...
<p>Yes, you should do this in your intialize and load methods if you are initializing globals that should only be initialized once.</p> <p>That said, there are a number of cases where you may avoid it...</p> <p>You shouldn't wrap with this conditional if the work needs to be performed on every inheritant of every cla...
<p>YES!!!! </p> <p>Because the initialize method of a class may be invoked many times. e.g. when you implement initialize in parent class, and don't implement in sub class, then you call sub class first, the initialize of parent will invoked twice.</p> <pre><code>@implementation BaseClass + (void)initialize { N...
42,043
<p>Most XML parsers will give up after the first error in a document. In fact, IIRC, that's actually part of the 'official' spec for parsers. </p> <p>I'm looking for something that will break that rule. It should take a given schema (assuming a valid schema) and an xml input and attempt to keep going after the firs...
<p>In a different question on SO (<a href="https://stackoverflow.com/questions/41908/customizing-visual-studio">link</a>), someone mentioned the VS 2005 / VS 2008 add-in "RockScroll". It seems to provide the "error bar" feature I was inquiring about in my question above.</p> <p><a href="http://www.hanselman.com/blog/...
<p>The "error bar" functionality is provided in JetBrains ReSharper. I'm not sure if it does highlighting of references to the currently selected identifier.</p>
5,244
<p>I was wondering if it is possible to generate a "core" file, copy if to another machine and then continue execution of the a core file on that machine?</p> <p>I have seen the gcore utility that will make a core file from a running process. But I do not think gdb can continue execution based on a core file.</p> <p>...
<p>it's called <a href="http://www.google.com/search?q=process+migration" rel="nofollow noreferrer">process migration</a>.</p> <p><a href="http://www.mosix.com/" rel="nofollow noreferrer">mosix</a> and <a href="http://openmosix.sourceforge.net/" rel="nofollow noreferrer">OpenMosix</a> used to be able to do that. nowa...
<p>I don't believe this is possible. However, you might want to look into virtualization software - e.g. <a href="http://xen.org" rel="nofollow noreferrer">Xen</a> - which make it possible to freeze and move entire system images fromone machine to another.</p>
23,433
<p>In smarty div position fixed is not working. While this one is working in simple php.</p>
<p>This will hardly be a Smarty problem. Just save both HTML pages and locally and compare. What's the difference? Maybe you could even use a diff tool for this. Have you tried to validate the <a href="http://validator.w3.org/" rel="nofollow noreferrer">HTML</a> and the <a href="http://jigsaw.w3.org/css-validator/" rel...
<p>you can see what's wrong using FireBug with Firefox.</p>
48,405
<p>We happily use SVN for SCM at work. Currently I've got our binary assets in the same SVN repository as our code. SVN supports very large files (it transmits them 'streamily' to keep memory usage sane), but it is SLOOWWWWW.</p> <p>What asset management software do you recommend, for about a GB (and growing) worth ...
<p>Please be very aware that it is almost impossible to merge binary files! At least automatically. At least I've never heard of a program that supports three-way merging on a binary format. Let alone conflict resolving.</p> <p>That's why most asset management tools don't have branching, since it makes little sense si...
<p>If you need to manage HUGE files, give a try to Plastic SCM (www.plasticscm.com). AFAIK Perforce is also an option but branching and merging are not that strong.</p>
34,673
<p>I need to set the text within a DIV element dynamically. What is the best, browser safe approach? I have prototypejs and scriptaculous available.</p> <pre><code>&lt;div id="panel"&gt; &lt;div id="field_name"&gt;TEXT GOES HERE&lt;/div&gt; &lt;/div&gt; </code></pre> <p>Here's what the function will look like:</p> ...
<p>You can simply use:</p> <pre><code>fieldNameElement.innerHTML = "My new text!"; </code></pre>
<pre><code>function showPanel(fieldName) { var fieldNameElement = document.getElementById(field_name); fieldNameElement.removeChild(fieldNameElement.firstChild); var newText = document.createTextNode("New Text"); fieldNameElement.appendChild(newText); } </code></pre>
14,814
<p>Is there a way to guarantee that a file on Windows (using the NTFS file system) will use contiguous sectors on the hard disk? In other words, the first chunk of the file will be stored in a certain sector, the second chunk of the file will be stored in the next sector, and so on.</p> <p>I should add that I want to ...
<p>I would start here:</p> <p><a href="http://technet.microsoft.com/en-us/sysinternals/bb897428.aspx" rel="nofollow noreferrer">http://technet.microsoft.com/en-us/sysinternals/bb897428.aspx</a></p> <p>and follow Mark's documentation of the defrag stuff:</p> <p><a href="http://technet.microsoft.com/en-us/sysinternals...
<p>I believe there's no way to achieve that. You can only defragment the file after it's been written.</p>
7,897
<p>How do I change font size on the DataGridView?</p>
<pre><code> private void UpdateFont() { //Change cell font foreach(DataGridViewColumn c in dgAssets.Columns) { c.DefaultCellStyle.Font = new Font("Arial", 8.5F, GraphicsUnit.Pixel); } } </code></pre>
<p>Go to designer.cs file of the form in which you have the grid view and comment the following line: - //this.dataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;</p> <p>if you are using vs 2008 or .net framework 3.5 as it will be by default applied to alternating rows.</p>
8,954
<p>I need help with the best practice to localize asp mvc apps, I saw Oxite having a base method named Localize in the BaseController, but is the Localization a task for the view or the Controller? Or should I use resx files / or use db tables?</p>
<p>Create your own Html helper and use it like <code>&lt;%= Html.Resource("Name") %&gt;</code> </p> <p>Details are in <a href="https://web.archive.org/web/20081222191210/http://blog.eworldui.net/post/2008/05/ASPNET-MVC---Localization.aspx" rel="nofollow noreferrer">blog</a> post.</p>
<p>If the string to be localized is generated by the view (eg a label in front of a text field), then its localization should be in the View.</p> <p>If the string is generated by the Controller, its localization should be there as well.</p>
49,942
<p>What is the best way to quickly get up to speed on Microsoft Expressions Blend 2? </p> <p>Are there some good web sites that can get me started or does someone have a good book that they would recommend?</p>
<p>Expression Blend is used in creating Sliverlight XAML. I would start with <a href="http://silverlight.net" rel="nofollow noreferrer">sliverlight.net</a> </p> <p>This is where you should get started.</p> <p><a href="http://silverlight.net/GetStarted/" rel="nofollow noreferrer">http://silverlight.net/GetStarted/</...
<p>There is a decent book: <strong>Foundation Expression Blend 2</strong> by Victor Gaudioso.</p> <p>It covers the basics of what the various widgets in Blend do. FWIW, it worked for me.</p>
48,268
<p>I am configure log4net to use a composite RollingFileAppender so that the current file is always named <strong>logfile.log</strong> and all subsequent files are named <strong>logfile-YYYY.MM.dd.seq.log</strong> where <strong>seq</strong> is the sequence number if a log exceeds a certain size within a single day. Un...
<p>We use the following (in Log4J):</p> <pre><code>&lt;appender name="roller" class="org.apache.log4j.DailyRollingFileAppender"&gt; &lt;param name="File" value="Applog.log"/&gt; &lt;param name="DatePattern" value="'.'yyyy-MM-dd"/&gt; &lt;layout class="org.apache.log4j.PatternLayout"&gt; &lt;param n...
<p>Note that is this case the</p> <pre><code> &lt;maxSizeRollBackups value="10"/&gt; </code></pre> <p>will be ignored. </p> <p>See this <a href="https://stackoverflow.com/questions/95286/log4net-set-max-backup-files-on-rollingfileappender-with-rolling-date#97641">answer</a> to a similar log4net question<...
30,177
<p>I have an iMac, and I want to be able to turn off the monitor when I go to sleep,. Alas, the iMac has no switch for this. I do not want to put the iMac into sleep mode, i want to write a "expose" like application or service, which when the mouse is put into the upper left hand corner of my screen, the display will...
<p>In Leopard, you can just go to "System Preferences" and "Desktop &amp; Screensaver". Click the Screensaver tab, click "Hot Corners", selected the corner you want to change, then chose "Sleep display". Does that not work?</p>
<p>Not really the answer you seem to be looking for, but cant you do this via the power save option and/or the screen saver - can it be set to nothing.</p>
9,534
<p>We put all of our unit tests in their own projects. We find that we have to make certain classes public instead of internal just for the unit tests. Is there anyway to avoid having to do this. What are the memory implication by making classes public instead of sealed?</p>
<p>If you're using .NET, the <a href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx" rel="noreferrer">InternalsVisibleTo</a> assembly attribute allows you to create "friend" assemblies. These are specific strongly named assemblies that are allowed to access in...
<p>Classes can be both public AND sealed.</p> <p>But, don't do that.</p> <p>You can create a tool to reflect over internal classes, and emit a new class that accesses everything via reflection. MSTest does that.</p> <p>Edit: I mean, if you don't want to include -any- testing stuff in your original assembly; this als...
13,248
<p>how to get GIF Transparency color in vc++ 6.0 and vc++ 2005 ?</p>
<p>See the <a href="http://www.martinreddy.net/gfx/2d/GIF89a.txt" rel="nofollow noreferrer">GIF specification</a>. GIFs have a palette of up to 256 possible colors. The palette index of the background color can be found at offset 11 from the beginning of the file, and consists of a single byte (value 0-255). To find...
<p>I just implemented the GIF decoder. Here are the details - In case the </p> <p>if(Graphics_Render_Block->transperencyflag) FrameInfo->transperencyindex=Graph_Renderblk.Transp_Clr_Index; else FrameInfo->transperencyindex='\0';</p> <p>The logic is simple. Whil...
44,123
<p>I really like Xml for saving data, but when does sqlite/database become the better option? eg, when the xml has more than <em>x</em> items or is greater than <em>y</em> MB?</p> <p>I am coding an rss reader and I believe I made the wrong choice in using xml over a sqlite database to store a cache of <em>all</em> the...
<p>I basically agree with <a href="https://stackoverflow.com/questions/77726/xml-or-sqlite-when-to-drop-xml-for-a-database#77750">Mitchel</a>, that this can be highly specific depending on what are you going to do with XML and SQLite. For your case (cache), it seems to me that using SQLite (or other embedded databases)...
<p>I say it's not a matter of data size, but of data type. If your data is <em>structured</em>, use a relational database. If your data is <em>semi-structured</em>, use XML or - if the data amounts really grow too large - an XML database.</p>
10,319
<p>I was following along with the railscast regarding the restful_authentication plugin.</p> <p>He recommended running the command:</p> <p>script/generate authenticated user session</p> <p>Which I did, and everything generated "fine", but then sessions wouldn't work. Checking the site again, he mentions a naming sta...
<p>Actually, <code>script/destroy</code> works for any generator - generators work by reading a script of sorts on what files to create; <code>script/destroy</code> just reads that script in reverse and removes all the files created, as long as you give it the same arguments you passed to <code>script/generate</code>.<...
<p>You can just roll back to the previous revision in subversion, and start again, right? right? :-)</p> <p>rails has <code>script/destroy</code> for 'ungenerating' stuff, but I suspect that will only work for the stuff rails ships with, not the restful authentication plugin.</p> <p>I'd say your best bet is find-in-f...
11,501
<p>I have uncovered another problem in the effort that we are making to port several hundreds of ksh scripts from AIX, Solaris and HPUX to Linux. See <a href="https://stackoverflow.com/questions/74372/how-to-overcome-an-incompatibility-between-the-ksh-on-linux-vs-that-installed-o">here</a> for the previous problem.</p>...
<p>I wouldn't use pdksh on Linux anymore. Since AT&amp;T ksh has become OpenSource there are packages available from the various Linux distributions. E.g. RedHat Enterprise Linux and CentOS include ksh93 as the "ksh" RPM package.<p> pdksh is still mentioned in many installation requirement documentations from software ...
<p>You do realize that [ is an alias (often a link, symbolic or hard) for <code>/usr/bin/test</code>, right? So perhaps the actual problem is different versions of <code>/usr/bin/test</code> ?</p> <p>OTOH, ksh overrides it with a builtin. Maybe there's a way to get it to not do that? or maybe you can explicitly ali...
12,170
<p>I have a set of 2D pictures from a CT scan.</p> <p>How can I convert them into a 3D model for 3D printing? An example looks like this:</p> <p><a href="https://i.stack.imgur.com/EV9Q8.jpg" rel="nofollow noreferrer" title="CT-Scan of a mouse&#39;s bones"><img src="https://i.stack.imgur.com/EV9Q8.jpg" alt="CT-Scan of...
<p>Using the terms "convert CT scan to 3D model," I found a number of links of tutorials. One of them is described as free, with registration and appears to be web based. The link, <a href="https://www.embodi3d.com/blogs/entry/345-a-ridiculously-easy-way-to-convert-ct-scans-to-3d-printable-bone-stl-models-for-free-in-m...
<p>Knowing the layer thickness, you can <strong>manually</strong> re-engineer/design the object:</p> <ul> <li>take your CAD or 3D modeling program of choice <ol> <li>import one picture into the XY axis</li> <li>trace the outline on that layer</li> <li>add a construction layer one layer thickness above</li> </ol></li>...
1,164
<p>I have some old C code that I would like to combine with some C++ code.</p> <p>The C code used to have has the following includes:</p> <pre><code>#include &lt;windows.h&gt; #include &lt;stdio.h&gt; #include &lt;string.h&gt; #include &quot;mysql.h&quot; </code></pre> <p>Now I'm trying to make it use C++ with iostream...
<p>The C <code>string.h</code> header and the C++ <code>string</code> header are not interchangeable.</p> <p>Overall, though, your problem is that the file is getting properly compiled, but the wrong runtime library is getting linked in.</p> <p>Dev-C++ uses GCC. GCC can correctly determine the language in a file bas...
<p>You need to link against your C++ runtime. It depends on your platform and compiler, but adding -lC to your linkline might do it. </p> <p>So might linking using your C++ compiler rather than ld.</p> <p>In any case, you probably have to link using the C++ compiler rather than ld if you want your C++ code to work ...
33,071
<p>I'm beginning to plan a complete redesign of our departments intranet pages. As it stands, every department gets their own folder within root. They all share the same look and feel but don't use CSS everything in each file is straight up static text. Basically, if a change has to be made to the header, <em>every</em...
<p>If you are already working in .NET 2.0, then you shouldn't need to do any upgrades, and there won't be any additional infrastructure cost.</p> <p>I would highly recommend using Master pages, as they do make it painless to have a common look and feel for your entire site.</p> <p>Another cool feature of Master pages...
<p>I'll start with the cost question. You need to be using ASP.NET 2.0 or higher to take advantage of master pages. Technically the .NET framework is free, however Visual Studio is not. Visual Web Developer is free, but the license might be for non-commercial projects only. I'm not sure. IIS is also free, Windows ...
47,050
<p>How can you prematurely exit from a function without returning a value if it is a void function? I have a void method that needs to not execute its code if a certain condition is true. I really don't want to have to change the method to actually return a value.</p>
<p>Use a return statement!</p> <pre><code>return; </code></pre> <p>or</p> <pre><code>if (condition) return; </code></pre> <p>You don't need to (and can't) specify any values, if your method returns <code>void</code>.</p>
<p>You mean like this?</p> <pre><code>void foo ( int i ) { if ( i &lt; 0 ) return; // do nothing // do something } </code></pre>
45,098
<p>How can I represent the following in XSD.</p> <pre><code>&lt;price-update&gt; &lt;![CDATA[ arbitrary data goes here ]]&gt; &lt;/price-update&gt; </code></pre>
<pre><code>&lt;element name="price-update" type="string"&gt;&lt;/element&gt; </code></pre> <p>is about as close as you can get.</p> <p>(I thought it best to move the answer out of the comments and into an actual answer).</p>
<p>A CDATA tag is merely a means of escaping data as a text node. Therefore you cannot stipulate that you require a CDATA node.</p> <p>From a DOM perspective, the following documents are identical:</p> <pre><code>&lt;doc&gt;value&lt;/doc&gt; </code></pre> <p>and</p> <pre><code>&lt;doc&gt;&lt;![CDATA[value]]&gt;&lt...
21,166
<p>Looking at <code>System.Collections.Generic.Dictionary&lt;TKey, TValue&gt;</code>, it clearly implements <code>ICollection&lt;KeyValuePair&lt;TKey, TValue&gt;&gt;</code>, but doesn't have the required "<code>void Add(KeyValuePair&lt;TKey, TValue&gt; item)</code>" function.</p> <p>This can also be seen when trying t...
<p>The expected API is to add via the two argument <code>Add(key,value)</code> method (or the <code>this[key]</code> indexer); as such, it uses explicit interface implementation to provide the <code>Add(KeyValuePair&lt;,&gt;)</code> method.</p> <p>If you use the <code>IDictionary&lt;string, int&gt;</code> interface in...
<p>It doesn't implement <code>ICollection&lt;KeyValuePair&lt;K,V&gt;&gt;</code> directly. It implements <code>IDictionary&lt;K,V&gt;</code>.</p> <p><code>IDictionary&lt;K,V&gt;</code> derives from <code>ICollection&lt;KeyValuePair&lt;K,V&gt;&gt;</code>.</p>
33,633
<p>I printed parts for a Harry Potter wand with HatchBox Wood PLA, now I want to apply stain. I intended to try MinWax PolyShades wood stain, then noticed Varathane water-based wood stain is available at my local Rona hardware store. This seems a "healthier" option, maybe not as fussy to apply as PolyShades, anyone had...
<p>I ended up using Saman brand water-based wood stain, also from Rona hardware (a brand of Lowe's Canada). The selection of colours for Saman stains was greater than the Varathane stains. </p> <p>I applied a single coat of colour #117 "Chamois" to the stem portion of the wand, and two coats of colour #120 "Dark Walnu...
<p>Wood stains (as opposed to dyes, paints, etc.) work by having large particles that become lodged in the grain of the wood, yielding a result that varies in intensity with the grain of the wood and thereby brings out its beauty. It's unlikely that they will do what you want, or anything reasonable, on PLA that has wo...
1,309
<p>As per the title.</p> <p>I think .Net libraries would definitely benifit from some sort of community development; perhaps something like the Java Community Process. This is where an analogue would be very helpful.</p> <p>EDIT: I think people are believing that I need to use some libraries. That's not what I'm talk...
<p>The closest thing that there is is Micorosft's <a href="http://connect.microsoft.com/" rel="nofollow noreferrer">Connect site</a>, which is a formal feedback site that the internal teams really do use and respond to. You can also vote on feature requests.</p>
<p>Not sure about the Boost libraries, </p> <p>but there are a large number of open source .NET projects on <a href="http://codeplex.com" rel="nofollow noreferrer">http://codeplex.com</a> also check out the "open source" home at Microsoft <a href="http://www.microsoft.com/opensource/default.aspx" rel="nofollow norefer...
27,193
<p>I want to implement a two-pass cache system:</p> <ul> <li><p>The first pass generates a PHP file, with all of the common stuff (e.g. news items), hardcoded. The database then has a cache table to link these with the pages (eg "index.php page=1 style=default"), the database also stores an uptodate field, which if fa...
<p>I second Ken's rec of PEAR's <a href="http://pear.php.net/package/Cache_Lite" rel="noreferrer">Cache_Lite</a> library, you can use it to easily cache either parts of pages or entire pages.</p> <p>If you're running your own server(s), I'd strongly recommend <a href="http://www.danga.com/memcached/" rel="noreferrer">...
<p>I would recommend using existing caching mechanism. Depending on what you really need, You might be looking for APC, memcached, various template caching libs... It easier/faster to tune written/tested code to please your need than to write everything from scratch. (usually, although there might be situations when yo...
18,941
<p>I ran into an issue when installing Team Foundation Server 2008 Workgroup Edition. I have a Windows Server 2003 SP2 machine that's practically new. I have installed SQL Server 2008 with almost all of the options. When I run through the TFS installation, it allows me to enter my SQL instance name and then goes throug...
<p>To install Team Foundation Server 2008 against SQL Server 2008, you must use TFS 2008 Service Pack 1. However, currently Microsoft do not provide a "TFS with SP1" download - you must created your own slipstreamed installation by downloading the TFS 2008 media and then applying the service pack to the media before r...
<p>You need the Tfs 2008 Sp1 for support for SQL Server 2008. See this post <a href="https://web.archive.org/web/20210126150345/http://geekswithblogs.net/etiennetremblay/archive/2008/08/11/sql-2008--tfs-2008-sp1-the-lowdownhellip.aspx" rel="nofollow noreferrer">Link</a></p> <p>Hth., /Gert</p>
15,017
<p>I am using a fictional example for this. Say, I have a Widget class like:</p> <pre><code>abstract class Widget { Widget parent; } </code></pre> <p>Now, my other classes would be derived from this Widget class, but suppose I want to put some constraint in the class while defining the derived types such that only a ...
<p>You should be able to use the code you've got by still having the non-generic class <code>Widget</code> and making <code>Widget&lt;T&gt;</code> derive from it:</p> <pre><code>public abstract class Widget { } public abstract class Widget&lt;T&gt; : Widget where T : Widget { } </code></pre> <p>You then need to work...
<p>I don't think there is a language mechanism that would allow you to do that.</p> <p>However, you might want to use a <strong><a href="http://en.wikipedia.org/wiki/Factory_method_pattern" rel="nofollow noreferrer">Factory pattern</a> to separate the construction of the class from the class itself</strong>.</p> <p>S...
32,642
<p>My place of employment is looking into buying a third party tool, for batch based US and Canadian Address correction, with Geo-coding.</p> <ul> <li>What Products have you used?</li> <li>What do you like about them?</li> <li>What do you not like about them?</li> </ul> <p>Note that, We are a C/C++ Unix Shop.</p>
<p>We use <a href="http://www.melissadata.com/" rel="noreferrer">Melissa Data</a>, they have a number of solutions including geocoding and address normalization. They have good APIs and the support has been great. Their solutions work on many platforms and languages including C and C++ on Unix. Can't think anything ...
<p>We use Trillium in our office. They provide C# libraries that you can incorporate into your projects. It will take an address and return a pretty complex standardized address object but does include information like geocodes (which are important for calculating tax). </p>
26,645
<p>I'm wondering whether anyone here has ever used a <a href="http://en.wikipedia.org/wiki/Skip_list" rel="nofollow noreferrer">skip list</a>. It looks to have roughly the same advantages as a balanced binary tree but is simpler to implement. If you have, did you write your own, or use a pre-written library (and if so,...
<p>Years ago I implemented my own for a probabilistic algorithms class. I'm not aware of any library implementations, but it's been a long time. It is pretty simple to implement. As I recall they had some really nice properties for large data sets and avoided some of the problems of rebalancing. I think the implemen...
<p>Skip Lists are easy to implement. But, adjusting the pointers on a skip list in case of insertion and deletion you have to be careful. Have not used this in a real program but, have doen some runtime profiling. Skip lists are different from search trees. The similarity is that, it gives average log(n) for a period o...
29,033
<p>Is there any easy web application or user control that allows math equations to be easily created and stored as a text string?</p> <p><strong>Update:</strong> An ASP.NET control would be ideal.</p>
<p>This may be a starting point: <a href="http://thornahawk.unitedti.org/equationeditor/equationeditor.php" rel="nofollow noreferrer">http://thornahawk.unitedti.org/equationeditor/equationeditor.php</a></p>
<p>This may be a starting point: <a href="http://thornahawk.unitedti.org/equationeditor/equationeditor.php" rel="nofollow noreferrer">http://thornahawk.unitedti.org/equationeditor/equationeditor.php</a></p>
21,555
<p>I have a flash file that loads an XML file at runtime. When the <code>.swf</code> file is run locally or on an Apache server it works fine but when hosted on an IIS6 based server the file won't load. </p> <p>Can anyone help with this?</p>
<p>In code behind just change protected void btnSubmit_Click(object sender, EventArgs e)</p> <p>with protected void btnSubmit_Click(object sender, ImageClickEventArgs e)</p>
<p>Why are you using an ImageButton ... why not just use a regular button, and change the background with CSS. </p>
38,189
<p>We are using an Oracle 11 database and a java development environment (using Eclipse) and would like to migrate several xml schemas to SQL schemas.</p> <p>Have looked ax xsd but really need something that we can run from ant/ Eclipse without SQL Server installed.</p> <p>Regards,</p> <p>Andy</p>
<p>You may want to give an example. If your code focuses too much on language specifics that are not part of the algorithm, then Understandably, it could be said you had non-algorithm mixed with your algorithm, resulting in an incorrect result. </p> <p>I Feel for the reasoning, the whole point of learning is to show y...
<p>All I know is you shouldn't write any code until after you have an algorithim.</p>
33,040
<p>I have built a class library project, that references a couple dll's. In the constructor of my class library project I use some enums from one of the referenced dll's. When using my class library in another project is it possible to not have to add references to my dll and the ones my class library project refere...
<p>It depends on what you mean by <em>reference internally</em>.</p> <p>If your application project uses type A from your class library, and that class does not expose any public types from other libraries, 3rd party or not, you don't need to add any references to more than your class library containing type A.</p> <...
<p>I'm not sure what are you trying to do but you don't have to reference any assembly if you don't want to . You can use reflection. It is usually regarded as a hack and is not recommendable but sometimes necessary. <a href="http://www.codeproject.com/KB/cs/DynLoadClassInvokeMethod.aspx" rel="nofollow noreferrer">Here...
46,528
<p>Is there any GUI-based tools to assist you with writing and maintaining the configuration file? Any code tools to codegen the config file? What are the best ways to make this a little bit easier? Are most people just using Castle ActiveRecord now?</p>
<p>For code/mapping generation there are a number of templates for <a href="http://www.mygenerationsoftware.com" rel="nofollow noreferrer">MyGeneration</a> for creating configuration files and/or classes from a database. <a href="http://www.codesmithtools.com/" rel="nofollow noreferrer">CodeSmith</a> has NHibernate tem...
<p>I'm just learning NHibernate myself (from the <a href="http://www.summerofnhibernate.com/" rel="nofollow noreferrer">excellent Summer of NHibernate</a> series). I don't know of any GUI tools, but I thought that I'd point out that if you install the NHibernate schmema files (found in the root folder of the installat...
39,945
<p>In a page, on the load event, I am dynamically creating controls for display on the page. This is all working properly. the trouble I am having is when adding extenders from the AJAX control toolkit, specifically I am trying to add rounded corners to a button control. No errors are thrown, but the AJAX Extension fun...
<p>You need to add the "editRoundedCorners" to the page, or containers, Controls collection, so try adding the line:</p> <pre><code>Controls.Add(editRoundedCorners) </code></pre> <p>just before "'add them to page control collection" as you may only be adding the edit button, whereas both are required.</p>
<p>You need to add the "editRoundedCorners" to the page, or containers, Controls collection, so try adding the line:</p> <pre><code>Controls.Add(editRoundedCorners) </code></pre> <p>just before "'add them to page control collection" as you may only be adding the edit button, whereas both are required.</p>
22,644
<p>Is there a way to tell Enterprise Library to use prepared statements? If so, how?</p>
<p>The short answer is to use DbCommand.Prepare();</p> <p>The long answer is that it is completely irrelevant, and results in a noop, when calling stored procedures. </p> <p>Also, it should only really be used when the code is about to make several calls (as in a loop) with the same query.</p>
<p>You should be able to obtain the sqlConnection / Command being executed -> can't you set the relevant setting here before executing ?? </p> <p>Hope I've got the right end of the stick...</p>
23,474
<p>Given <em>test.txt</em> containing:</p> <pre><code>test message </code></pre> <p>I want to end up with:</p> <pre><code>testing a message </code></pre> <p>I think the following should work, but it doesn't:</p> <pre><code>Get-Content test.txt |% {$_-replace "t`r`n", "ting`r`na "} </code></pre> <p>How can I do a ...
<p>A CRLF is two characters, of course, the CR and the LF. However, <code>`n</code> consists of both. For example:</p> <pre><code>PS C:\&gt; $x = "Hello &gt;&gt; World" PS C:\&gt; $x Hello World PS C:\&gt; $x.contains("`n") True PS C:\&gt; $x.contains("`r") False PS C:\&gt; $x.replace("o`nW","o There`nThe W") Hello T...
<p>You can use <code>"\\r\\n"</code> also for the new line in <code>powershell</code>. I have used this in servicenow tool.</p> <p>In my case <code>"\r\n"</code> s not working so i tried <code>"\\r\\n"</code> as <code>"\"</code> this symbol work as escape character in <code>powershell</code>.</p>
42,229
<p>I'm looking for a code library that converts ANSI escape sequences into HTML color, via plain tags or CSS. For example, something that would convert this:</p> <pre>ESC[00mESC[01;34mbinESC[00m ESC[01;34mcodeESC[00m ESC[01;31mdropbox-lnx.x86-0.6.404.tar.gzESC[00m ESC[00mfooESC[00m</pre> <p>Into this:</p> <pre><cod...
<p><code>aha</code> is a C-language program, available in an Ubuntu package, at <a href="http://ziz.delphigl.com/tool_aha.php" rel="noreferrer">http://ziz.delphigl.com/tool_aha.php</a> or on github <a href="https://github.com/theZiz/aha" rel="noreferrer">https://github.com/theZiz/aha</a>, that takes an input with termi...
<p>There seems to be <a href="http://search.cpan.org/perldoc?HTML::FromANSI" rel="noreferrer">an HTML::FromANSI Perl module</a>.</p>
30,407
<p>I would like to do remote deployment from my build machine onto a server. The remoting can be done via ssh commands from a script, but I would rather use phing and a deploy.xml file that would do the automation.</p> <p>What alternatives do I have to do ssh (and also scp) tasks from within a phing build file?</p>
<p><a href="https://www.phing.info/docs/guide/stable/ScpTask.html" rel="nofollow noreferrer">SCPTask</a> in Phing:</p> <blockquote> <p>copies files to and from a remote host using scp. This task requires the <strong><a href="http://web.archive.org/web/20101219161808/http://pecl.php.net/package/ssh2" rel="nofollow no...
<p>If you really need phing, then afaik there's only exec. If you are open for other tools, have a look at <a href="http://www.capify.org/" rel="nofollow noreferrer">capistrano</a> and my answer in "<a href="https://stackoverflow.com/questions/220638/setting-up-a-php-web-project-the-infrastructure#225524">Setting up a ...
28,371
<p>I'm trying to serialize objects from a database that have been retrieved with Hibernate, and I'm only interested in the objects' actual data in its entirety (cycles included).</p> <p>Now I've been working with <a href="http://xstream.codehaus.org/" rel="nofollow noreferrer">XStream</a>, which seems powerful. The pr...
<p>solution described here worked well for me: <a href="http://jira.codehaus.org/browse/XSTR-226" rel="nofollow noreferrer">http://jira.codehaus.org/browse/XSTR-226</a></p> <p>the idea is to have custom XStream converter/mapper for hibernate collections, which will extract actual collection from hibernate one and will...
<p>What generally seems to be the best way to do it, and the way I am currently doing it is to have another layer of DTO objects. This way you can exclude data that you don't want to go over the channel as well as limit the depth to which the graph is serialized. I use Dozer for my current DTO (Data Transfer Object) fr...
22,034
<p>In an asp.net application, i would like to use a webservice to return the username associated with the session id passed as a parameter. We're currently using InProc session store.</p> <p>Is it possible to do this ?</p> <p>Edit: what i'm trying to do is get information about another session than the current one. I...
<p>There is frankly no way to mechanically and meaningfully translate C to Python without suffering an insane performance penalty. As we all know Python isn't anywhere near C speed (with current compilers and interpreters) but worse than that is that what C is good at (bit-fiddling, integer math, tricks with blocks of ...
<p>You can always compile the C code, and load in the libraries using ctypes in python.</p>
16,058
<p>How much should one DataSet represent? Using the example of an ordering system: While showing your order I also show a list of items similar to one of yours as well as a list of our most popular items. While your items are tangled in a web of relationships involving you and your past orders, preferred suppliers, an...
<p>The DataSet is vastly overrated and overused. Use strongly-typed collections (thank you, generics and automatic properties!). As icing on the cake, you can now even do cool query things against your custom objects with LINQ. </p> <p>Good Esposito article on datasets versus custom objects:</p> <p><a href="http://ms...
<p>The DataSet is vastly overrated and overused. Use strongly-typed collections (thank you, generics and automatic properties!). As icing on the cake, you can now even do cool query things against your custom objects with LINQ. </p> <p>Good Esposito article on datasets versus custom objects:</p> <p><a href="http://ms...
5,692
<p>I'm trying to grasp the concept of continuations and I found several small teaching examples like this one from the <a href="http://en.wikipedia.org/wiki/Continuation" rel="noreferrer">Wikipedia article</a>:</p> <pre><code>(define the-continuation #f) (define (test) (let ((i 0)) ; call/cc calls its first fun...
<p>In Algo &amp; Data II we used these all the times to "exit" or "return" from a (long) function</p> <p>for example the BFS algorthm to traverse trees with was implemented like this:</p> <pre><code>(define (BFS graph root-discovered node-discovered edge-discovered edge-bumped . nodes) (define visited (make-vector ...
<p>Continuations can be used to implement exceptions, a debugger.</p>
5,434
<p>How do I generate a range of consecutive numbers (one per line) from a MySQL query so that I can insert them into a table?</p> <p>For example:</p> <pre><code>nr 1 2 3 4 5 </code></pre> <p>I would like to use only MySQL for this (not PHP or other languages).</p>
<p>If you need the records in a table and you want to avoid concurrency issues, here's how to do it.</p> <p>First you create a table in which to store your records</p> <pre><code>CREATE TABLE `incr` ( `Id` int(11) NOT NULL auto_increment, PRIMARY KEY (`Id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; </code></pre> <...
<p>The idea I want to share is not a precise response for the question but can be useful for some so I would like to share it.</p> <p>If you frequently need only a limited set of numbers then it can be beneficial to create a table with the numbers you may need and just use that table every time. For example:</p> <pre...
22,603
<p>In the case when I want to check, if a certain entry in the database exists I have two options.</p> <p>I can create an sql query using COUNT() and then check, if the result is >0...</p> <p>...or I can just retrieve the record(s) and then count the number of rows in the returned rowset. For example with $result->nu...
<p>YMMV, but I suspect that if you are only checking for existence, and don't need to use the retrieved data in any way, the COUNT() query will be faster. How much faster will depend on how much data.</p>
<p>I would definitely do it in the PHP to decrease load on the database.</p> <p>In order to get a count <strong>and</strong> get the returned rows in SQL you would have to do two queries.. a COUNT and then a SELECT</p> <p>The PHP way gives you everything you need in one result object.</p>
43,803
<p>I have a sql query that runs super fast, around one second, when not using variables, like:</p> <pre><code>WHERE id BETWEEN 5461094 and 5461097 </code></pre> <p>But when I have:</p> <pre><code>declare @firstId int declare @lastId int set @firstId = 5461094 set @lastId = 5461097 ... WHERE id BETWEEN @firstId...
<p>It's because when the values are hard coded, it can look up <a href="http://www.microsoft.com/technet/prodtechnol/sql/2005/qrystats.mspx" rel="noreferrer">the statistics</a> it has on the data in the table, and figure out the best query to run. Have a look at the execution plans of each of these queries. It must be ...
<p>Is ID in an Index (eg Primary Key)? If not, try adding one.</p> <p>Another thing could be that in the first (fast) instance the query is getting executed slightly differently. The most common thing I've seen happen is that the joins get done in an inefficient order. Try re-ordering the joins, or converting some to ...
40,488
<p>How do I convert an SQL Server SMALLDATETIME to Unix Timestamp? </p> <p>date was stored as CAST(0x96040474 AS SmallDateTime) in MS Access DB. Data was dumped to SQL and I'm looking to convert those times to Unix Timestamps for MySQL.</p> <p>Thanks AO</p>
<p>select datediff(ss, '1/1/1970', your_date_here)</p> <p>e.g. </p> <p>select datediff(ss, '1/1/1970', cast('1/1/1989' as smalldatetime))</p>
<p>From <em>SQL Server 2005 Books Online</em>, "Transact SQL Reference"</p> <blockquote> <p>The Database Engine stores <code>smalldatetime</code> values as two 2-byte integers. The first 2 bytes store the number of days after January 1, 1900. The other 2 bytes store the number of minutes since midnight.</p> </blockq...
39,544
<p>I need to get authentication credentials from the users within a Windows script but the classic "first Google result" approach:</p> <pre><code>SET /P USR=Username: SET /P PWD=Password: </code></pre> <p>is less than satisfying, so I was wondering if there's let's say an "equivalent" to <strong>HTML's input type="...
<p>check out this </p> <p><a href="http://www.netikka.net/tsneti/info/tscmd052.htm" rel="noreferrer">http://www.netikka.net/tsneti/info/tscmd052.htm</a> </p> <pre><code>@echo off &amp; setlocal enableextensions :: Build a Visual Basic Script set vbs_=%temp%\tmp$$$.vbs set skip= findstr "'%skip%VBS" ...
<p><a href="http://ss64.net/westlake/nt/" rel="nofollow">ConSet</a> is a free tool written by Frank P. Westlake. It is an extended version of standard Windows command <strong>set</strong>.</p> <blockquote> <p>ConSet.exe - Displays, sets, or deletes cmd.exe environment variables, modifies console parameters, and perf...
36,481
<p>I am looking for a cross-platform solution for saving and viewing 3D scenes (visualizations of engineering simulation models and results) but there (still) doesn't seem to be much out there.</p> <p>I looked into this almost 10 years ago and settled on VRML then (and started the project that eventually turned in <a ...
<p>The closest thing that I'm aware of is <a href="http://en.wikipedia.org/wiki/Collada" rel="nofollow noreferrer">Collada</a>. Many 3D engines can read it, and most 3D design tools can read and write it. I believe the <a href="http://http:/www.ogre3d.org" rel="nofollow noreferrer">Ogre</a> engine has pretty good supp...
<p>If you are using OpenGL, <a href="http://glintercept.nutty.org/" rel="nofollow noreferrer">GLIntercept</a> will save all OpenGL calls (with the data they were called with) to a XML file. It's only half the solution, though, but it shouldn't be hard to parse it and recreate the scene yourself.</p>
34,940
<p>As we all know that javascript is an open source language and we are using Mozilla FireFox 3 and in this browser the mozilla foundation has released a newer version of the javascript but i am still unable to figure out that really where is the javascript source code in the FireFox 3 browser and where is the list of ...
<p><a href="http://code.google.com/p/v8/" rel="nofollow noreferrer">Source code for V8</a> (google chrome's javascript engine)</p> <p>Can be run standalone too.</p>
<p>The Mozilla source code is available from <a href="https://developer.mozilla.org/en/Download_Mozilla_Source_Code" rel="nofollow noreferrer">developer.mozilla.org</a> </p>
47,687
<p>In ActivePerl, "ppm" installs a package from the Internet, "ppm install x.ppd" installs from a ppd file, but most CPAN packages are distributed as <em>.tar.gz</em></p> <p>How do you supply modules to a machine running ActivePerl that doesn't have an Internet connection? ("make" will probably not be available.)</p>...
<p>See: <a href="http://docs.activestate.com/activeperl/5.10/faq/ActivePerl-faq2.html#zip_files" rel="nofollow noreferrer">http://docs.activestate.com/activeperl/5.10/faq/ActivePerl-faq2.html#zip_files</a></p>
<p>You might be interested in <a href="http://www.perlmonks.org/?node_id=434813" rel="nofollow noreferrer">A guide to installing modules for Win32</a>. It's a bit outdated (it talks about the command-line ppm) but the principles remain the same.</p>
26,960
<p>If you type</p> <pre><code>nslookup -type=SRV _xmpp-server._tcp.gmail.com </code></pre> <p>(or use the dig command in OSX) you get some SRV records relating to google chat</p> <p>I would like to replicate this functionality in PHP, does anyone have any good ideas how to do this?</p> <p>I would like to avoid usin...
<p>You could use <a href="http://pear.php.net/package/Net_DNS" rel="nofollow noreferrer">Pear Net_DNS</a>. I managed to get this to work on Linux, but haven't tested it on Windows or any others:</p> <pre><code>require_once('Net/DNS.php'); $resolver = new Net_DNS_Resolver(); $response = $resolver-&gt;query('_xmpp-serve...
<p>There is <a href="http://php.net/manual/en/function.dns-get-record.php" rel="nofollow noreferrer"><code>dns_get_record()</code></a>. According to the docs it can take an <code>int $type</code> argument, which refers to a set of constants, one of them being <code>DNS_SRV</code>.</p>
40,478
<p>I have found many tutorials about using Windows Server 2003 as a development machine, and very little information about Windows Server 2008 for the same purpose.</p> <p>For a nicer experience, I have followed the steps from <a href="http://www.win2008workstation.com/wordpress/" rel="nofollow noreferrer">Convert you...
<p><strong><code>SQL Server 2005 - installation order</code></strong> (thank you Anthony)</p> <ul> <li>IIS 7 with IIS 6 backwards compatibility (for reporting services)</li> <li>KB 950636</li> <li>SQL Server 2005</li> <li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=ae7387c3-348c-4faa-8ae5-949fdfb...
<p><strong>IIS 7 - installation order</strong></p> <ul> <li>IIS 7 (Windows Server 2008 role)</li> <li><a href="http://support.microsoft.com/kb/946517/en-us" rel="nofollow noreferrer">You may be unable to manage IIS by using Server Manager if two threads access IIS at the same time</a></li> </ul> <p><strong>IIS 7 - li...
42,431
<p>Let say I have a project that I have released under GPL, with the sources available to anyone. Later I find a very similar product, but as closed source, distributed binary-only by someone else.</p> <p>Is there a good way to find out they are using my source code in their product?</p> <p>If the solution is to some...
<p>Bugs.</p> <p>If the closed source release shares most of it's bugs with your project, it's probably 'lifted'.</p> <p>You could also try decompiling your own binary with a decompiled version of the closed source binary... though this would probably not be reliable.</p>
<p>The most surefire way I can think of is similar to the word <a href="http://en.wikipedia.org/wiki/Esquivalience" rel="nofollow noreferrer">'Esquivalience'</a> in the oxford dictionary.<br> Simply add some binary array with a unique content somewhere in the code and don't forget to make some simple use of it so the l...
44,138
<p>It's not obvious to me..</p>
<p>If you do kill TSVNCache, you don't need to manually restart it, the shell-extension will do that next time it needs it.</p> <p>If you're trying to restart the shell-extension, you might achieve it by killing all Explorer.exe processes, and anything else which has ended-up with TSVN in-process. This is basically a...
<p>The background process that watches your file system for SVN related files and folders is TSVNCache.exe. You can kill that process and start it again, or just reboot your machine :)</p>
34,915
<p>I am importing data from MS Excel spreadsheets into a php/mySQL application. Several different parties are supplying the spreadsheets and they are in formats ranging from Excel 4.0 to Excel 2007. The trouble is finding a technique to read ALL versions.</p> <p>More info: </p> <pre><code> - I am currently using php...
<p>Depending on the nature of your data and the parties that upload the excel files, you might want to consider having them save the data in .csv format. It will be much easier to parse on your end.</p> <p>Assuming that isn't an option a quick google search turned up <a href="http://sourceforge.net/projects/phpexcelr...
<p>The open-source ETL tool Talend (<a href="http://wwww.talend.com" rel="nofollow noreferrer">http://wwww.talend.com</a>) will generate Java or Perl code and package such code with the necessary 3rd party libraries. </p> <p>Talend should be able to handle all versions of Excel and output the result set in any format ...
9,826
<p>I know I can access environment variables in PowerShell using <code>$Env</code>. For example, I can access <code>FOO</code> with <code>$Env:FOO</code>.</p> <p>I can't figure out how to access the environment variable called <code>FOO.BAR</code>.</p> <p><code>$Env:FOO.BAR</code> doesn't work. How can I access this ...
<p>To access any kind of PowerShell variable where the name contains non-alphanumeric characters, use the ${…} notation as in:</p> <pre><code>${env:variable.with.dots} = "Hi there" ${env:variable.with.dots} </code></pre> <p>This works for variables in any drive (registry, filesystem, etc.) </p>
<p>Use:</p> <pre><code>Get-WMIObject Win32_Environment -filter "name='foo.bar'" </code></pre>
40,252
<p>We were offered to <a href="https://3dprinting.meta.stackexchange.com/questions/314/can-we-get-mathjax-enabled">get MathJax enabled</a>.</p> <p>Now, we need to decide on which character to have text between them parsed into MathJax! So please either add your suggestion or cast your vote!</p>
<p>Let's stay with the classic $.</p> <p>Example: \$\$\frac{1 \times 2}{2} = 1\$\$</p> <hr> <p><em>Now that MathJax is enabled, it renders to: $$\frac{1 \times 2}{2} = 1$$</em></p>
<p>An alternative character could be the Tilde <code>~</code>.</p>
59
<p>How do I cast an <code>int</code> to an <code>enum</code> in C#?</p>
<p>From an int:</p> <pre><code>YourEnum foo = (YourEnum)yourInt; </code></pre> <p>From a string:</p> <pre><code>YourEnum foo = (YourEnum) Enum.Parse(typeof(YourEnum), yourString); // The foo.ToString().Contains(&quot;,&quot;) check is necessary for // enumerations marked with a [Flags] attribute. if (!Enum.IsDefined(...
<p>I need two instructions:</p> <pre><code>YourEnum possibleEnum = (YourEnum)value; // There isn't any guarantee that it is part of the enum if (Enum.IsDefined(typeof(YourEnum), possibleEnum)) { // Value exists in YourEnum } </code></pre>
4,913
<p>I'm trying to do a JOIN in Linq using lambda expressions ... and running into some problems. </p> <p>I have two entities, Comments and CommentSources. CommentSources are associated to Comments. I have the following code, which does work:</p> <pre><code>01 IQueryable&lt;Data.Comment&gt; query = ctx.DataContext.C...
<p>You need to specify five things (at least):</p> <ul> <li>The "outer" sequence (Comments) (this is the implicit first parameter)</li> <li>The "inner" sequence (CommentSource)</li> <li>How to get from a CommentSource to a key</li> <li>How to get from a Comment to a key</li> <li>What you want the result to be for a Co...
<p>Here is my final code:</p> <pre><code> var query = ctx.DataContext.Comments.Join(ctx.DataContext.CommentSources, c =&gt; c.CommentId, s =&gt; s.CommentId, (c, s) =&gt; new {Comment = c, CommentSource = s}); if (criteria.SourceId != null ...
45,062
<p>My Techie Bretheren (and Sisteren, of course!),</p> <p>I have a LinqToSql data model that has the following entities: <a href="http://danimal.acsysinteractive.com/images/advisor.jpg" rel="nofollow noreferrer">data model http://danimal.acsysinteractive.com/images/advisor.jpg</a></p> <p>I need to retrieve all adviso...
<p>Maybe use <a href="http://docs.google.com/" rel="nofollow noreferrer">Google Docs</a> to share the document. That would be as turn-key as it gets. :)</p>
<p>Webdav can do this. Might be a hassle to set it up.</p>
18,726
<p>Big problem. I'm not sure what it was that I did, but it seems that I can no longer debug into functions.</p> <p>It happens in no particular place, just all throughout the code. I set a breakpoint, and then try to "step over" in order to go to the next like of code. Now, the debugger seems to interpret that as "...
<p>quite a few possibilities<br> - Your compiling in release without debug symbols instead of in debug - Check which configuration you're compiling<br> - For some other reason you don't have debug symbols - check the settings<br> - The binary version you are running is not the same as the one which is being compiled -...
<p>Ah! I figured it out!</p> <p>This may or may not be a bug in visual studio.</p> <p>Suppose I have an enumeration of cases from 0 to 5. Suppose I then have a dictionary with the enumeration as a key and another integer as the value. If I then have a combo box with all the possible values in the dictionary as the...
30,441
<p>I'm trying to display an array of files in order of date (last modified).</p> <p>I have done this buy looping through the array and sorting it into another array, but is there an easier (more efficient) way to do this?</p>
<blockquote> <p><strong>Warning</strong> <code>create_function()</code> has been DEPRECATED as of PHP 7.2.0. Relying on this function is highly discouraged.</p> </blockquote> <p>For the sake of posterity, in case the forum post linked in the accepted answer is lost or unclear to some, the relevant code needed is: </...
<p>This can be done with a better performance. The <code>usort()</code> in the accepted answer will call <code>filemtime()</code> a lot of times. PHP uses quicksort algorithm which has an average performance of <code>1.39*n*lg(n)</code>. The algorithm calls <code>filemtime()</code> twice per comparison, so we will have...
15,191