instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I'm doing a little app that I want to distribute in different platforms, at least the 3 major ones.</p> <p>Is it possible to use only Windows has the host OS to compile the binaries for Linux, Mac OS X and other supported platforms without resorting to virtual machines?</p> <p>Or should I ask around in some commun...
<p><strong>It is possible</strong> to compile from one plateform to another, it is called <strong><em>cross-compilation</em></strong>. You will find extensive informations at <a href="http://www.stack.nl/~marcov/buildfaq.pdf" rel="nofollow noreferrer">http://www.stack.nl/~marcov/buildfaq.pdf</a><br> The buildfaq above...
<p>I would virtualize Linux, as even if you can cross-compile, it means you're not testing the binaries on their native platforms. OS X is a trickier problem.</p>
26,062
<p>How do you associate a <code>-mouseUp:</code> event with the <code>-add:</code> method of a NSArrayController? The <code>-mouseUp:</code> event lives in a different object but is <code>#import</code>'ed and instantiated in the object that holds the array being controlled.</p> <p>Usually, with an NSButton you comma...
<p>Instead of</p> <pre><code>&gt;&gt;&gt; imap.authenticate('bobdole@gmail.com', 'Bob Dole likes your style!') </code></pre> <p>use</p> <pre><code>&gt;&gt;&gt; imap.login('bobdole@gmail.com', 'Bob Dole likes your style!') </code></pre>
<p>I found the solution on <a href="http://codeclimber.blogspot.com/2008/06/using-ruby-for-imap-with-gmail.html" rel="nofollow noreferrer">this helpful blog post</a>. Although Gmail doesn't support AUTHENTICATE, it does support the LOGIN capability, like so:</p> <pre><code>&gt;&gt;&gt; imap.login('bobdole@gmail.com', ...
45,827
<p>Here is the situation. I am creating some graphics (using GDI+) on an asp page running under mono xsp. This works great in my development environment as my development environment is running under a GUI, however when I try running it on a GUI-less server, it fails (I am assuming due to the fact that certain librar...
<p>I believe the name of the library you want is libgdiplus, though I'm not sure if it has a dependency on X11.</p>
<p>mono's implementation of System.Drawing is build on top of the cairo graphics library. See the mono documentation <a href="http://www.mono-project.com/Drawing" rel="nofollow noreferrer">here</a>.</p>
45,271
<p>In the GNOME Terminal, Bash does smart auto-completion. For example</p> <pre><code>apt-get in&lt;TAB&gt; </code></pre> <p>becomes</p> <pre><code>apt-get install </code></pre> <p>In Emacs shell-mode, this auto-completion doesn't work, even after I explicitly source <code>/etc/bash_completion</code>. The above exa...
<p>I know this question is three years old, but it's something that I've also been interested in solving. A Web search directed me to a piece of elisp that makes Emacs use bash for completion in shell mode. It works for me, in any case.</p> <p>Check it out at <a href="https://github.com/szermatt/emacs-bash-completion"...
<p>I make no claims to being an emacs expert but this should solve your problem:</p> <p>Create: ~/.emacs</p> <p>Add to it:</p> <p>(require 'shell-command) (shell-command-completion-mode)</p> <p>Emacs takes over the shell so BASH settings don't carry through. This will set auto completion for EMACS itself.</p>
19,778
<p>An RGB color is composed of three components: Red (0-255), Green (0-255) and Blue (0-255).</p> <p>What exactly is BGR color space? How is it different from RGB color space?</p>
<p>RGB stands for Red Green Blue. Most often, an RGB color is stored in a structure or unsigned integer with Blue occupying the least significant "area" (a byte in 32-bit and 24-bit formats), Green the second least, and Red the third least.</p> <p>BGR is the same, except the order of areas is reversed. Red occupies ...
<p>It's just RGB in a more tightly controlled order, independent of endianness. Converting between them is simple once you know the endianness of your environment.</p> <p>The BGR is a 24-bit representation where the lower-addressed 8 bits are blue, the next-addressed 8 are green and higher-addressed 8 are red.</p> <...
47,959
<p>Can you provide an example of a byte buffer transferred between two java classes via UDP datagram?</p>
<p>Hows' this ?</p> <pre> import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetSocketAddress; public class Server { public static void main(String[] args) throws IOException { DatagramSocket socket = new DatagramSocket(new InetSocketAddress(5000...
<p>@none</p> <p>The DatagramSocket classes sure need a polish up, DatagramChannel is slightly better for clients, but confusing for server programming. For example:</p> <pre> import java.io.IOException; import java.net.InetSocketAddress; import java.nio.ByteBuffer; import java.nio.channels.DatagramChannel; public c...
10,547
<p>I need to display a bunch of images on a web page using AJAX. All of them have different dimensions, so I want to adjust their size before displaying them. Is there any way to do this in JavaScript?</p> <p>Using PHP's <code>getimagesize()</code> for each image causes an unnecessary performance hit since there will ...
<p>I was searching a solution to get height and width of an image using JavaScript. I found many, but all those solutions only worked when the image was present in browser cache.</p> <p>Finally I found a solution to get the image height and width even if the image does not exist in the browser cache:</p> <pre><code>&...
<p>Do you want to adjust the images themselves, or just the way they display? If the former, you want something on the server side. If the latter, you just need to change image.height and image.width.</p>
13,240
<p>So the <a href="https://stackoverflow.com/questions/214215/user-drawn-controls-are-using-the-previous-forms-background">transparent background problem</a> is solved. Now, every time I show the form (or have to have it repainted), I get a lot of flickering. Is there any way I can not update the screen until the pai...
<p>Did you try setting the <a href="https://stackoverflow.com/questions/220100/how-do-i-enable-double-buffering-of-a-control-using-c-window-forms">DoubleBuffered</a> property for the form?</p>
<p>Set the DoubleBuffered Property on the form.</p>
27,133
<p>I need some info on how to use margins and how exactly <em>padding</em> works.</p> <p>For example: Should I put a line to occupy the whole width of the page (no matter what resolution is used to display the web page) letting just a small border on each side, how could I achieve this?</p>
<p>Have a look at this: <a href="http://redmelon.net/tstme/box_model/" rel="nofollow noreferrer">http://redmelon.net/tstme/box_model/</a></p> <p>Basically, an element consists of content, surrounded by its padding, then the border, then the margin. Background images only extend as far as the border. Margins are best d...
<p>I think this should do what you want:</p> <pre><code>&lt;table width="100%" cellpadding="5"&gt; &lt;tr&gt; &lt;td&gt; One, two, three ... One, two, three ... One, two, three ... One, two, three ... One, two, three ... One, two, three ... One, two, three ... One, two, three ... One, two, three ... &lt;/td...
13,000
<p>I have adjusted my z axis end stop via the paper test. However when I press to home all the axis the z axis hits the print bed moves it down slightly then goes to the postion I describe. Is this how its supose to be if not what do I need to do?</p>
<p>According to the RepRap.org <a href="http://reprap.org/wiki/G-code" rel="nofollow noreferrer">list of G-Code commands</a>, see <strong><a href="http://reprap.org/wiki/G-code#G0_.26_G1:_Move" rel="nofollow noreferrer">G0 &amp; G1: Move</a></strong>:</p> <blockquote> <p>The <code>Ennn</code> command is <em>The amou...
<p>Is the hotend temperature set correctly? If you only preheat the hotend but then turn it off, it will behave exactly as you described (while you're above <code>EXTRUDE_MINTEMP</code> it will behave normally, but once the temperature drops too low it will continue doing the XYZ-moves, but stop extruding). Perhaps you...
231
<p>I have stored a txt file as string in a database column. Now on one of my aspx page I have a link...I want to open a txt file when the user clicks on this link. How can i read a file from database. I know how to do this using streamreader for a file stored on the disk.</p> <p>Thanks</p>
<p>If you really have to store the file in a database (and I fully agree with Will on this, you shouldn't), you may want to think about implementing a separate download page (eg getfile.aspx) which is responsible for getting the string from the database based on an id, perhaps ( getfile.aspx?fileId=12345 ), setting the...
<p>Why do you want to store a file in a database column? Databases are better for the stuff you really need to query... It's useful for queries like 'give me all the given links from the last 30 days' or 'get all blue cars with fabric indoor decorations'.</p> <p>Files are simply better handled by the OS filesystem. If...
37,989
<p>I am having trouble with my Visual Studio 2005 IntelliSense for some time now.<br><br> It used to work fine, but for some reason the 'Updating IntelliSense...' does no longer seem to be able to complete for the solution I'm working on currenly- it simply gets stuck somewhere at about 3-bars of progress and blocks on...
<p>I have found that the best fix for Intellisense in VS2005 is to install SP1, and then this hotfix: <a href="http://support.microsoft.com/kb/947315" rel="noreferrer">947315</a>. It has the added benefit of fixing most of the multi-core build issues.</p> <p>This hotfix also includes the ability to control Intellise...
<p>Intellsense is problematic. Very problematic. When it works, it's great, but more often than not it will cause more problems than it's worth. It will hang up, it will parse through files while you are trying to compile code and will generally make VC 2005 sometimes run like a dog. As a previous poster suggested,...
9,511
<p>I have seen the following code:</p> <pre><code>[DefaultValue(100)] [Description("Some descriptive field here")] public int MyProperty{...} </code></pre> <p>The functionality from the above snippit seems clear enough, I have no idea as to how I can use it to do useful things. Im not even sure as to what name to gi...
<blockquote> <p>The functionality from the above snippit seems clear enough,</p> </blockquote> <p>Maybe not, as many people think that [DefaultValue()] <em>sets</em> the value of the property. Actually, all it does to tell some visual designer (e.g. Visual Studio), what the code is going to set the default value ...
<p>These attributes customize the design time experience.</p> <p><a href="http://msdn.microsoft.com/en-us/library/a19191fh.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/a19191fh.aspx</a></p>
25,606
<p>I have been trying to work my way through Project Euler, and have noticed a handful of problems ask for you to determine a prime number as part of it.</p> <ol> <li><p>I know I can just divide x by 2, 3, 4, 5, ..., square root of X and if I get to the square root, I can (safely) assume that the number is prime. Unfo...
<p>The first algorithm is quite good and used a lot on Project Euler. If you know the maximum number that you want you can also research Eratosthenes's sieve.</p> <p>If you maintain the list of primes you can also refine the first algo to divide only with primes until the square root of the number.</p> <p>With these ...
<p>The AKS prime testing algorithm: </p> <pre><code>Input: Integer n &gt; 1 if (n is has the form ab with b &gt; 1) then output COMPOSITE r := 2 while (r &lt; n) { if (gcd(n,r) is not 1) then output COMPOSITE if (r is prime greater than 2) then { let q be the largest factor of r-1 ...
22,846
<p>What is the the best JavaScript compressor available? I'm looking for a tool that:</p> <ul> <li>is easy to use</li> <li>has a high compression rate</li> <li>Produce reliable end results (doesn't mess up the code)</li> </ul>
<p>I recently released <a href="http://github.com/mishoo/UglifyJS" rel="noreferrer">UglifyJS</a>, a JavaScript compressor which is written in JavaScript (runs on the NodeJS <a href="http://en.wikipedia.org/wiki/Nodejs" rel="noreferrer">Node.js</a> platform, but it can be easily modified to run on any JavaScript engine,...
<p><a href="http://blog.madskristensen.dk/post/Optimize-WebResourceaxd-and-ScriptResourceaxd.aspx" rel="nofollow noreferrer">Here's the source code</a> of an HttpHandler which does that, maybe it'll help you</p>
4,857
<p>I was playing a bit with Windows Vista (still using XP) and I liked how the standard Control Panel worked. Do you think this design is good also for normal applications?</p> <p>I like the idea of showing main topics with large fonts + icons. Details within each main topic are displayed using a small font and are im...
<p>Wouldn't the session number tell you this ?</p> <p>ProcessIdToSessionId (GetCurrentProcessId(),&amp;dwSessionNum)</p> <p>You'd have to check the OS version as well, using GetVersionEx: for everything up to XP/Server 2003 session 0 is local (service or interactive console), anything higher is virtual. For Vista/200...
<p>Brian is correct, I have since encountered Vista reporting a session id of 2 for an interactive console, despite the fact that Fast User Switching was not in use. Of course, this may be just be a bug :-)</p>
30,307
<p>I've got an RMI call defined as:</p> <pre><code>public void remoteGetCustomerNameNumbers(ArrayList&lt;String&gt; customerNumberList, ArrayList&lt;String&gt; customerNameList) throws java.rmi.RemoteException; </code></pre> <p>The function does a database lookup and populates the two ArrayLists. The calling functio...
<p>Arguments in RMI calls a serialised. Deserialisation on the server creates a copy of the lists. If the lists remained on the client side, then the number of network calls would be quite high. You can pass remote objects, but beware of the performance implications.</p>
<p>You lose your references when you make the remote call. You'll need to return the lists rather than expect them to be populated by the remote call.</p>
11,062
<p>I'm trying to print out the date in a certain format:</p> <pre><code>NSDate *today = [[NSDate alloc] init]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyyMMddHHmmss"]; NSString *dateStr = [dateFormatter stringFromDate:today]; </code></pre> <p>If the iPhone is s...
<p>Using the code you posted on both the simulator and a phone with the 2.1 firmware and 24-hour time set to off, I never had an AM/PM appended to dateStr when I do:</p> <pre><code>NSLog(@"%@", dateStr); </code></pre> <p>Are you doing anything else with dateStr that you didn't post here? How are you checking the valu...
<p>This should also work (I am seeing some bizzare results though).</p> <pre><code>-(NSString*)lowLevTime:(NSString*)stringFormat { char buffer[50]; const char *format = [stringFormat UTF8String]; time_t rawtime; struct tm * timeinfo; time(&amp;rawtime); timeinfo = localtime(&amp;rawtime); ...
17,283
<p>Could you write a function that takes one argument (a positive integer) and</p> <ul> <li>divides it by two if it's even, or</li> <li>multiplies it by three and adds one if it's odd</li> </ul> <p>and then returns the resulting number.</p> <p>And then a separate function that takes one argument (a positive integer)...
<p>i believe this is a great unsolved question of number theory. There is a hypothesis that every number when it goes through this operation enough times will reduce to one.</p> <p>However i don't really think scheme is the right tool for this, plus since a lot of people have decided that this is homework and not a l...
<p>A function that performs one iteration:</p> <pre><code>(define (collatz x) (if (even? x) (/ x 2) (+ (* x 3) 1))) </code></pre> <p>This function takes an input and loops until it reaches 1. The function returns the number of iterations required to get to that state (try graphing this - it looks pretty...
31,987
<p>While setting up CruiseControl, I added a buildpublisher block to the publisher tasks:</p> <pre><code>&lt;buildpublisher&gt; &lt;sourceDir&gt;C:\MyBuild\&lt;/sourceDir&gt; &lt;publishDir&gt;C:\MyBuildPublished\&lt;/publishDir&gt; &lt;alwaysPublish&gt;false&lt;/alwaysPublish&gt; &lt;/buildpublisher&gt; </code...
<p>I set up a task to do this. I'm not aware of any way to make CruiseControl be that specific. I usually just chain a batch file to do the copy to the CC.net task.</p>
<p>The default build publisher in CC.NET does not provide a way to do this. You have a few options:</p> <ul> <li>Create your own build publisher with the desired functionality</li> <li>Create a custom NAnt/MSBuild task</li> <li>Use a scripting technology (RoboCopy, batch file, etc.) to create a script file and run an ...
4,302
<p>I have a web-app that I would like to extend to support multiple languages with new URLs. For example, www.example.com/home.do stays English, but www.example.com/es/home.do is Spanish. My first thought was to create a Filter which rewrites incoming urls like /es/home.do to /home.do (and sets the Locale in the Requ...
<p>I'm not sure that overriding <code>getContextPath()</code> is enough to solve your problem. What if Struts is calling <code>ServletContext.getContextPath()</code> under the covers, or uses <code>getRequestURI()</code>, etc?</p>
<p>As far as I know, the conventional way to do this is with the accept-language HTTP header. The presentation language is a presentation detail, which shouldn't be represented by the set of URLs to navigate through the application.</p>
32,524
<p>What software do you use when designing classes and their relationship, or just pen and paper?</p>
<p>I find pen and paper very useful, and I try to get as far away from a computer as possible. If I do it on the compy, I'm always too tempted to start programming the solution. That inevitably leads to me changing things later that I would have spotted in the planning phase had I actually spent a good measure of time ...
<p>Mostly pen and paper, although I occasionally break out Visio and just do some rough diagrams.</p> <p>Would be nice to have a fancy tool I guess, but it would just be another thing to learn.</p>
3,526
<p>I have an app where I create many uiviews and add them to the self.view of the UIViewController. My app is running really slowly. I am releasing all of my objects and have no memory leaks (I ran the performance tool). Can anyone tell me what could be making my app so slow? (code is below)</p> <p>[EDIT] The array ha...
<p>Having deep view hierarchies can lead to slow downs that you can often fix through flattening them some with custom views, but if you are using simple views you can have dozens on the screen with no perceptible performance impact, so in general I recommend ignoring how many views you have when you are developing, an...
<p>Don't forget to make as many of your views opaque as you can. Transparent views are a major source of performance issues.</p>
31,461
<pre><code>SELECT GETDATE() </code></pre> <p>Returns: <code>2008-09-22 15:24:13.790</code></p> <p>I want that date part without the time part: <code>2008-09-22 00:00:00.000</code></p> <p>How can I get that?</p>
<pre><code>SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, @your_date)) </code></pre> <p>for example</p> <pre><code>SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE())) </code></pre> <p>gives me</p> <pre><code>2008-09-22 00:00:00.000 </code></pre> <p>Pros:</p> <ul> <li>No varchar&lt;-&gt;datetime conversions required</li> <li>No ne...
<p>You can simply use the code below to get only the date part and avoid the time part in SQL:</p> <pre><code>SELECT SYSDATE TODAY FROM DUAL; </code></pre>
13,814
<p>So, the wife got me a Creality Ender-3 Pro 3d Printer for Christmas.</p> <p>Assembly was easy, axis movements are all solid... when I go to print the <a href="https://www.thingiverse.com/thing:2879047" rel="nofollow noreferrer">test-dog.gcode</a> file provided with the machine, it comes out looking... flat.</p> <p...
<p>It turned out that there's something wrong with the G-code file that came with my printer.</p> <p>I downloaded a calibration cube from Thingiverse and printed it - while it wasn't 100%, it did print viable. Now I need to get into details as to quality, and I suspect that too will be a factor for the G-code used in ...
<p>I had the same problem on an Ender 3. Totally bewildering, because G-code commands <code>G0</code> &amp; <code>G1</code> moved Z as expected, as did Pronterface commands, but Z did not advance during printing.</p> <p>It turned out to be binding in the Z-axis lead screw caused by installing a BondTech style extruder....
1,155
<p>I really don't like the VS2008 Start Page. I don't need the RSS reader, Getting started or Headlines. The only thing useful is "Recent Projects"</p> <p><strong>Is there a way to customize it or replace with a better one?</strong><br> It will be nice that the page contains Favorites Projects and Recent projects.</p>...
<p>Here's an article with a lot of detail on how to precisely customize the start page. Unfortunately, it looks to be a rather arduous process. But hey, if you have the time...</p> <p><a href="http://msdn.microsoft.com/en-us/library/aa290348.aspx" rel="nofollow noreferrer">Customizing the Visual Studio .NET 2003 Sta...
<p>One suggestion would be to follow the steps here: <a href="http://blogs.msdn.com/saraford/archive/2008/01/03/did-you-know-how-to-customize-what-visual-studio-opens-to-or-how-to-make-the-start-page-not-show-up-when-vs-opens.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/saraford/archive/2008/01/03/did-you-know...
22,081
<p>I want to use an image or icon as a custom cursor in WPF app. How can I do that?</p>
<p>You have two basic options:</p> <ol> <li>When the mouse cursor is over your control, hide the system cursor by setting <code>this.Cursor = Cursors.None;</code> and draw your own cursor using whatever technique you like. Then, update the position and appearance of your cursor by responding to mouse events. Here are t...
<p>This will convert any image stored in your project to a cursor using an attached property. The image must be compiled as a resource!</p> <p><strong>Example</strong></p> <pre><code>&lt;Button MyLibrary:FrameworkElementExtensions.Cursor=&quot;&quot;{MyLibrary:Uri MyAssembly, MyImageFolder/MyImage.png}&quot;&quot;/&gt;...
6,896
<p>On my Mac I've got two versions of Cura installed, in <code>/Applications/Cura250</code> and <code>/Applications/Cura262</code>.</p> <p>How can I copy my printer and profile settings from Cura 2.5 to Cura 2.6?</p>
<p>Much of the software used in 3D printing is open-source, and so are some slicers. Cura, for instance, does (or did, this source code is from an older branch) its print time estimation in <a href="https://github.com/smorloc/Curation/blob/master/Cura/util/gcodeInterpreter.py" rel="noreferrer">gcodeInterpreter.py</a>.<...
<p>Generally speaking, the typical algorithm takes into account the slicer's speed settings for specific features of the build, such as infill, perimeters, top/bottom layers, etc. The distance traveled by the nozzle at a specific speed for each feature is also part of the equations involved. There are some rather vague...
665
<p>I downloaded a couple of webapps and placed them in my /webapps folder. Some of them I could open by going to <code>http://localhost:8080/app1</code> and it would open. However, some others I would do the exact same thing and go to <code>http://localhost:8080/app2</code> and it will display "HTTP Status 404 - /app2/...
<p>I usually debug this by going the the manager page and making sure that all of the contexts are deployed (<a href="http://localhost:8080/manager/html" rel="noreferrer">http://localhost:8080/manager/html</a>). </p> <p>It sounds like app2 has not been deployed properly or is not starting up because of some other erro...
<p>If "/" is not accessible it means that there is no "index.html", "index.jsp" or whatever is defined in the welcome-files list of the web.xml Also no Servlet-Mapping for the context ROOT directory is present. Check the web.xml for Servlet-Mappings or try to figure out the name of the jsp/html /... file being in the c...
7,681
<p>Is there an easy way of finding out the host name of a machine that generated a user mode dump file via WinDbg? </p> <p>Or at least any piece of identifying information to try and confirm that two dump files came from the same system.</p>
<p>You can do so by analyzing the user dump file with WinDbg. Run the <code>!peb</code> command and look for the value of <code>COMPUTERNAME</code> in its output.</p>
<p><strong>For IP Address list:</strong><br> 3: kd> du poi(poi(srvnet!SrvAdminIpAddressList)) <br> ffffe001<code>d3d58450 "127.0.0.1" 3: kd&gt; du<br> ffffe001</code>d3d58464 "::1"<br> 3: kd><br> ffffe001<code>d3d5846c "169.254.66.248"<br> 3: kd&gt;<br> ffffe001</code>d3d5848a ""<br> 3: kd><br> ffffe001<code>d3d5...
12,902
<p>I want to reverse engineer (import into diagram form) the database definition dump of a database I have, then since no foreign keys are defined in this particular database, I want to be able to manually create the table to table key mappings (using crow feet notation if possible).</p> <p>I've taken a look at MySQL ...
<p>You might check out DBDesigner ...</p> <p>Now known as MySQL Workbench</p> <p><a href="http://dev.mysql.com/downloads/workbench/5.0.html" rel="noreferrer">http://dev.mysql.com/downloads/workbench/5.0.html</a></p>
<p>Generate ERD with PHPMyAdmin is also a better option. PHPMyadmin added this functionality from version 3.4</p> <p>detail step to generate ERD : <a href="http://goo.gl/0z3vFE" rel="nofollow">http://goo.gl/0z3vFE</a></p> <p>You can refer to PHPMyAdmin documentation for more info: <a href="http://www.phpmyadmin.net/d...
36,305
<p>In C++ you can disable a function in parent's class by declaring it as private in the child class. How can this be done in Python? I.E. How can I hide parent's function from child's public interface?</p>
<p>There really aren't any true "private" attributes or methods in Python. One thing you can do is simply override the method you don't want in the subclass, and raise an exception:</p> <pre><code>&gt;&gt;&gt; class Foo( object ): ... def foo( self ): ... print 'FOO!' ... &gt;&gt;&gt; class Bar( ...
<p>This is the cleanest way I know to do it.</p> <p>Override the methods and have each of the overridden methods call your disabledmethods() method. Like this:</p> <pre><code>class Deck(list): ... @staticmethod def disabledmethods(): raise Exception('Function Disabled') def pop(self): Deck.disabledmet...
28,698
<p>I'm new to NAnt but have some experience with Ant and CruiseControl.</p> <p>What I want to do is have my SVN project include all tools needed (like NUnit and Mocks etc) so I can check out onto a fresh machine and build. This strategy is outlined by J.P Boodhoo <a href="http://blog.jpboodhoo.com/NAntStarterSeries.as...
<p>This shouldn't be a particularly difficult excercise. We do some fairly similar stuff on one of my projects since half of it runs on Java using Ant to run relevant targets, and the other half is .Net (C#) for the UI. The projects get run on windows machines for development, but the servers (Java) run linux, but in t...
<p>I use the following template. It allows simple building on any platform (<code>build</code> on Win or <code>./build.sh</code> on linux) and minimises duplication in the build scripts.</p> <hr> <p>The NAnt executable is stored with the project in <code>tools\nant</code>.</p> <p>The build config file determines whi...
5,197
<p><strong>UPDATE:</strong> Obviously, you'd want to do this using templates or a base class rather than macros. Unfortunately for various reasons I can't use templates, or a base class.</p> <hr/> <p>At the moment I am using a macro to define a bunch of fields and methods on various classes, like this:</p> <pre><cod...
<p>This cries out for a template.</p> <pre><code>class Example&lt;class T&gt; { ...class definition... }; </code></pre> <p>The direct answer to the last part of your question - "given that I'm not in a macro definition any more, how do I get pasting and stringizing operators to work" - is "You can't". Those oper...
<p>No, you can't define class or function definitions on the fly. They have to be specified, either by typing them in directly or by defining them in the preprocessor.</p> <p>Typically, there is no need to generate classes like this, and the class definitions are created before compilation, whether by typing everythi...
44,739
<p>I have quite a few partials in my application, and some of them need to do some jQuery goodness at $(document).ready time.</p> <p>The problem is, if I put the $(document).ready directly into a script block for the partial, then this gets overridden if another partial does the same thing.</p> <p>It seems a solution...
<p>well, just plain old never mind!</p> <p><a href="http://www.learningjquery.com/2006/09/multiple-document-ready" rel="noreferrer">http://www.learningjquery.com/2006/09/multiple-document-ready</a></p>
<p>is there anything wrong with doing something like this:</p> <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;Myapp...SearchResultsViewModel&gt;" %&gt; &lt;script type="text/javascript"&gt; $(document).ready(function () { alert('partial is ready.'); }); &lt;/script...
40,304
<p>I'm using Linq To Sql to fill up a listbox with Segment objects, where Segment is designer created/ORM generated class.</p> <pre><code>&lt;Window x:Class="ICTemplates.Window1" ... xmlns:local="clr-namespace:ICTemplates" Title="Window1" Height="300" Width="300"&gt; &lt;Window.Resources&gt; &lt;...
<p>Ze Mistake is here</p> <pre><code>&lt;DataTemplate DataType="x:Type local:Segment"&gt; &lt;!-- doesn't work --&gt; </code></pre> <p>should be</p> <pre><code>&lt;DataTemplate DataType="{x:Type local:Segment}"&gt; </code></pre> <p>Came home... made a toy-sample and it worked with this change. Gotta try that @ wor...
<p>This is just a guess, but could it be because the context is set to an IQueryable? If you set the DataContext to a single instance of a Segment, do you get the same result?</p>
48,458
<p>What books would you guys recommend if one has been a java developer for years and is now trying to take the c#/asp.net route?</p>
<p>First read this whitepaper:</p> <p><a href="http://www.25hoursaday.com/CsharpVsJava.html" rel="nofollow noreferrer">C# From a Java Developers Perspective</a></p> <p>Then, you can move onto books that cover the .NET framework, as you'll see the langauges differences are very quick to learn.</p>
<p>I find </p> <blockquote> <p>Pro C# with .NET 3.0, Special Edition by Andrew Troelsen Apress © 2007 (1238 pages) ISBN:9781590598238</p> </blockquote> <p>to be an excellent book. </p>
40,781
<p>In my django application I am using a template to construct email body, one of the parameters is url, note there are two parametes separated by ampersand in the url.</p> <pre><code>t = loader.get_template("sometemplate") c = Context({ 'foo': 'bar', 'url': 'http://127.0.0.1/test?a=1&amp;b=2', }) print t.render...
<p>To turn it off for a single variable, use <code>mark_safe</code>:</p> <pre><code>from django.utils.safestring import mark_safe t = loader.get_template("sometemplate") c = Context({ 'foo': 'bar', 'url': mark_safe('http://127.0.0.1/test?a=1&amp;b=2'), }) print t.render(c) </code></pre> <p>Alternatively, to to...
<p>Or just use the "safe" filter in your template.</p> <p>Also, I cannot stress enough how important it is to be familiar with Django's documentation; many common questions like this have easy-to-find answers and explanations (<a href="http://docs.djangoproject.com/en/dev/topics/templates/#id2" rel="noreferrer">like t...
29,360
<p>Where can I find a list of all the C# Color constants and the associated R,G,B (Red, Green, Blue) values?</p> <p>e.g.</p> <p>Color.White == (255,255,255)</p> <p>Color.Black == (0,0,0)</p> <p>etc...</p>
<p>Run this program:</p> <pre><code>using System; using System.Drawing; using System.Reflection; public class Test { static void Main() { var props = typeof(Color).GetProperties(BindingFlags.Public | BindingFlags.Static); foreach (PropertyInfo prop in props) { Color color =...
<p>It looks like this <a href="http://www.flounder.com/csharp_color_table.htm" rel="noreferrer">page</a> has all of them. </p>
27,933
<p>In an AI application I am writing in C++, </p> <ol> <li>there is not much numerical computation </li> <li>there are lot of structures for which run-time polymorphism is needed </li> <li>very often, several polymorphic structures interact during computation</li> </ol> <p>In such a situation, are there any optimiz...
<p>Virtual functions are very efficient. Assuming 32 bit pointers the memory layout is approximately:</p> <pre><code>classptr -&gt; [vtable:4][classdata:x] vtable -&gt; [first:4][second:4][third:4][fourth:4][...] first -&gt; [code:x] second -&gt; [code:x] ... </code></pre> <p>The classptr points to memory that is typ...
<p>If an <strong>AI</strong> application does not require great deal of number crunching, I wouldn't worry about performance disadvantage of virtual functions. There will be a marginal performance hit, only if they appear in the complex computations which are evaluated repeatedly. I don't think you can force virtual ta...
18,899
<p>I need to use <code>FtpWebRequest</code> to put a file in a FTP directory. Before the upload, I would first like to know if this file exists. </p> <p>What method or property should I use to check if this file exists?</p>
<pre><code>var request = (FtpWebRequest)WebRequest.Create ("ftp://ftp.domain.com/doesntexist.txt"); request.Credentials = new NetworkCredential("user", "pass"); request.Method = WebRequestMethods.Ftp.GetFileSize; try { FtpWebResponse response = (FtpWebResponse)request.GetResponse(); } catch (WebException ex) {...
<p>I use FTPStatusCode.FileActionOK to check if file exists...</p> <p>then, in the "else" section, return false.</p>
45,272
<p>As someone who has spent around 10 years programming web applications with Adobe's ColdFusion, I have decided to add ASP.NET as a string to my bow.</p> <p>For someone who has spent so long with CF and the underlying Java, ASP.NET seems a little alien to me. How should I go about getting up to speed with ASP.NET so...
<p>I'm only maybe six months down the same path, but here are some thoughts from my experience so far:</p> <p>The C# language shouldn't give you much problem if you have very much experience with Java at all (or even CFScript). As a reference, though, when I was starting, I found <a href="http://www.csharp-station.co...
<p>Microsoft has a video called <a href="http://www.asp.net/Learn/videos/video-27.aspx" rel="nofollow noreferrer">ASP.NET for ColdFusion developers</a> you may be interested in.</p> <p>Edit, <a href="http://www.asp.net/learn/videos/video-28.aspx" rel="nofollow noreferrer">here's another</a> </p>
8,217
<p>How do you access a MySQL relation using RoR?</p>
<p>Toby is right. You need to learn about table relationships using ActiveRecord.</p> <p><strong>The gist</strong>. You need to put the following codes in your models. Here is an example.</p> <p>In User model:</p> <pre><code>has_many :addresses </code></pre> <p>In the Address model:</p> <pre><code>belongs_to :user...
<p>Your question doesn't really make sense. </p> <p>Rails works with ActiveRecord which handles all sorts of complex database relationships. Check the AR documentation for details. </p>
39,035
<p>As a programmer I need a place to store my stuff. I've been running a server in my parents closet for a long time, but I recently came across a decent 2U server.<br> I have no experience dealing with hosting companies, beyond the very cheap stuff, and I'm wondering what I should look for in a colo or if I should jus...
<p>There are three major factors here.</p> <ol> <li>Cost. The colo will obviously be more expensive than sticking a server in your parents' closet.</li> <li>Quality. The colo should be a lot more reliable than the server in your parents' closet. They aren't as likely to go down when there's a power surge. They sho...
<p>I'd absolutely go for the server that's located under my roof, as long as I don't need it to be connected to the internet with a static IP.</p> <p>Why:</p> <ul> <li>It's a target for hackers, as soon as it is reachable from the net</li> <li>Any problems with the machine? I'd rather walk to the closet instead of ca...
2,998
<p>I have a public static class in which I would like to have a ToString() method. </p> <p>I have defined it as public static string ToString(), but get the following warning: </p> <blockquote> <p>'Class.ToString()' hides inherited member 'object.ToString()'. To make the current member override that implementati...
<p>Yes, using the "new" modifier will effectively silence the compiler warning but you are <strong>explicitly hiding</strong> an instance method with a static method. (This is different than overriding the method.) Typically you don't want to hide an instance method except with very good reasons and you really shouldn'...
<p>Ok, so in asking the question, I found an answer:</p> <p>The new Modifier: </p> <blockquote> <p><a href="http://msdn.microsoft.com/en-us/library/51y09td4(VS.71).aspx#vclrfnew_newmodifier" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/51y09td4(VS.71).aspx#vclrfnew_newmodifier</a></p> </blockq...
35,156
<p>I once did a cursory search and found no good CVS bindings for Python. I wanted to be able to write helper scripts to do some fine-grained manipulation of the repository and projects in it. I had to resort to using <code>popen</code> and checking <code>stdout</code> and <code>stderr</code> and then parsing those. ...
<p>For cvs, <a href="http://pycvs.sourceforge.net/" rel="nofollow noreferrer">pyCVS</a> may be worth a look.</p> <p>For svn, there is <a href="http://pysvn.tigris.org/" rel="nofollow noreferrer">pysvn</a>, which is pretty good.</p>
<p><a href="http://progetti.arstecnica.it/tailor" rel="nofollow noreferrer">Tailor</a>, a Python program which lets different version control systems interoperate, simply calls the external programs <code>cvs</code> and <code>svn</code> when working with repositories of those formats. This seems pretty ugly, but reduc...
31,582
<p>I'm writing an app using asp.net-mvc deploying to iis6. I'm using forms authentication. Usually when a user tries to access a resource without proper authorization I want them to be redirected to a login page. FormsAuth does this for me easy enough.</p> <p>Problem: Now I have an action being accessed by a console a...
<p>Ok, I worked around this. I made a custom ActionResult (HttpForbiddenResult) and custom ActionFilter (NoFallBackAuthorize).</p> <p>To avoid redirection, HttpForbiddenResult marks responses with status code 403. FormsAuthentication doesn't catch responses with this code so the login redirection is effectively skippe...
<p>I did some googling and this is what I came up with:</p> <pre><code> HttpContext.Current.Response.StatusCode = 401; </code></pre> <p>Not sure if it works or not, I haven't tested it. Either way, it's worth a try, right? :)</p>
5,578
<p>Folks,</p> <p>I connect to a large number of SQL Server 2005 databases through SQL Server Management Studio 2005. I frequently check off "Remember password", yet the next time I try to connect it doesn't actually remember it. Have you had this experience? Any workarounds?</p>
<p>According to <a href="http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=124842" rel="noreferrer">the bug report</a> this is a known issue, still not fixed and there is no workaround.</p>
<p>This happens to me also, but it is most notable when I'm connecting to different servers. If you connect to the same server every time then it should remember your password every time.</p> <p>Maybe one day, SP3 perhaps, Microsoft will release a nice fix for this somewhat continuous annoyance.</p>
18,462
<p>I've inherited a .NET application that pulls together about 100 dlls built by two teams or purchased from vendors. I would like to quickly identify whether a given dll is a .NET assembly or a COM component. I realize that I could just invoke ildasm on each dll individually and make a note if the dll does not have a ...
<p>If you want to approach from the COM side, testing for COM objects in a DLL boils down to looking for an export named "DllGetClassObject". This is because an in-proc COM object is accessed by the COM runtime by calling <a href="http://msdn.microsoft.com/en-us/library/ms680760(VS.85).aspx" rel="nofollow noreferrer">...
<pre><code>System.Reflection.Assembly.ReflectionOnlyLoadFrom("mydll.dll") </code></pre> <p>will return a valid assembly reference to a .NET dll but will throw an error for a COM dll. </p>
24,616
<p>I've got a custom handler applied to a class (using the Policy Injection Application Block in entlib 4) and I would like to know whether the input method is a property when Invoke is called. Following is what my handler looks like.</p> <pre><code>[ConfigurationElementType(typeof(MyCustomHandlerData))] public class...
<p>You can also check IsSpecialName is true. this will be true in a property (amongst other things)</p> <p>At the il level the methods are exposed as follows (using Environment.ExitCode as example):</p> <pre><code>.method public hidebysig specialname static int32 get_ExitCode() cil managed .method public hidebysig sp...
<p>You could check the IsSpecialName property; it will be true for property getters and setters. However, it will also be true for other special methods, like operator overloads.</p>
9,911
<p>After the suggestion to use a library for <a href="https://stackoverflow.com/questions/34486/what-more-is-needed-for-ajax-than-this-function">my ajax needs</a> I am going to use one, the problem is that there are so many and I've no idea how to even begin telling them apart.</p> <p>Thus, can anybody <br /> A) Give ...
<p>To answer B:</p> <p><a href="http://en.wikipedia.org/wiki/Comparison_of_JavaScript_frameworks" rel="noreferrer"><strong>Comparison of JavaScript frameworks</strong></a></p> <hr> <p><strong>EDIT:</strong> Although everyone and their mom is apparently riding the <a href="http://jquery.com/" rel="noreferrer"><strong...
<p>I've been using <a href="http://www.prototypejs.org/" rel="nofollow noreferrer">Prototype</a> + <a href="http://script.aculo.us/" rel="nofollow noreferrer">Scriptaculous</a>. </p> <p>They have good API documentation and work great for me! The biggest benefits are:</p> <ul> <li>Cleans up messy javascript code</li...
5,550
<p>How do I test if two dates are within a certain tolerance in NUnit?</p>
<p>You may want to look at the "Within" method that lives off of the Constraint object.</p> <p>For example:</p> <pre><code>Assert.That(DateTime.Now, Is.EqualTo(DateTime.Now.AddMilliseconds(1000)).Within(101)); </code></pre> <p>It's usually used to give a tolerance to doubles and floats, but since in the end a DateTi...
<p>Convert your tolerance to Ticks and then use an And constraint. Something like;</p> <pre><code>long ticks = mydate.Ticks; long tolerance = 1000; Assert.That( ticks, Is.LessThan( ticks + tolerance ) &amp; Is.GreaterThan( ticks - tolerance ) ); </code></pre> <p>I would create an extension method or your own Assert t...
35,669
<p>Somehow my iPhone Simulator is unable to play sounds. First an app I'm working on using <code>AudioServicesPlaySystemSound()</code> stopped working.. I spent a while debugging this but sound is still working on the iPhone when I run the app on the device. I get the same results with other iPhone apps such as the s...
<p>On your Mac, go to System Preferences > Sound > Sound Effects and then uncheck and recheck "Play user interface sound effects".</p> <p>You need to re-activate your system sounds, see the end of <a href="http://discussions.apple.com/thread.jspa?messageID=8883401" rel="noreferrer">this</a> page.</p>
<p>I've found sound to be very inconsistent in the simulator (2.1 SDK). Sometimes it works, sometimes it doesn't. Even when it does work, it's usually very choppy and distorted (when playing audio files such as mp3).</p> <p>A few things to remember:</p> <ul> <li>call <code>AudioSessionInitialize</code> as soon as y...
38,827
<p>Unfortunately, there seems to be no string.Split(string separator), only string.Split(char speparator).</p> <p>I want to break up my string based on a multi-character separator, a la VB6. Is there an easy (that is, not by referencing Microsoft.VisualBasic or having to learn RegExes) way to do this in c#?</p> <p>E...
<p><code>String.Split()</code> has other overloads. Some of them take <code>string[]</code> arguments.</p> <pre><code>string original = "first;&amp;second;&amp;third"; string[] splitResults = original.Split( new string[] { ";&amp;" }, StringSplitOptions.None ); </code></pre>
<p>The regex version is probably prettier but this works too:</p> <pre><code>string[] y = { "bar" }; string x = "foobarfoo"; foreach (string s in x.Split(y, StringSplitOptions.None)) Console.WriteLine(s); </code></pre> <p>This'll print foo twice.</p>
18,705
<p>Other than the most obvious issue with the filament kinking in the tube, what other issues could arise when trying to print flexibles (<em>i.e. TPU/TPE, Nylon, etc.</em>) with a Bowden style extruder setup? </p> <p>Can the kinking issue be alleviated by a well-constrained filament path (<em>proper ID</em>) in a pro...
<p>As a user of an UM3E, which uses Bowden tubes and has TPU as an available material, I can tell you that the kinking issues can be alleviated or downright avoided. </p> <p>I've printed quite a few things with the Ultimaker-brand TPU 95, and never had problems with kinking in the tube. </p> <p>Ultimaker uses 2.85 mm...
<p>To also validate the first answer, I have been printing with TPU95A for a number of years and it has been one of the most reliable materials to use. The strength of the product alongside the flex makes it a test and production based outcome with fewer issues. My printer for the most part of this experience was the U...
1,057
<p>In general at a fairly high level, and without building an entire CMS, what do I need to know about storing web page content (e.g. say several hundred articles and text up to approx. 2500 words in length) and photos in sql server in a templated web page design?</p> <p>Do I store the actual content in the db or stor...
<p>Storing content in a db is very much an accepted way of doing things. The simplest examples I can think of for your question are to have a look at the source code of the smaller blog packages.</p> <ul> <li><a href="http://www.codeplex.com/blogengine/" rel="nofollow noreferrer">http://www.codeplex.com/blogengine/</a...
<p>It is possible to store the web page content in the database and many CMSs do just this. There are many many ways of achieving this.</p> <p>"...without building an entire CMS" sounds like famous last words to me though. I suggest you look into third party CMSs.</p>
27,217
<p>I'd like to create a &quot;universal&quot; debug logging function that inspects the JS namespace for well-known logging libraries.</p> <p>For example, currently, it supports Firebug's console.log:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippe...
<p>I personally use Firebug/Firebug Lite and on IE let Visual Studio do the debugging. None of these do any good when a visitor is using some insane browser though. You really need to get your client side javascript to log its errors to your server. Take a look at the power point presentation I've linked to below. ...
<p>Myself, I am a firm believer in the following:</p> <pre><code>alert('Some message/variables'); </code></pre>
12,053
<p>I'm writing this question in the spirit of answering your own questions, since I found a solution to the problem, but if anyone has a better solution I would gladly listen to it.</p> <p>In the application I am currently working on I am subclassing the ListView control to add some functionality of which some interac...
<p>The problem seems to be that the SelectedIndices and SelectedItems does not update properly if the ListView has not been drawn, as is stated in this comment from the MSDN documentation of the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.listviewitem.selected(VS.85).aspx" rel="noreferrer">Lis...
<p>"I found that calling a .CreateControl() on the ListView object refreshed the SelectedItems properties."</p> <p>True, but only if you use Multi-select as well.</p>
39,193
<p>When I open a file in eclipse it shows with the improper line spacing showing an extra line break between every line. When I open the file with notepad or wordpad it doesn't show these extra line breaks that only eclipse shows. How do I get eclipse to read these files like notepad and wordpad without those line brea...
<p>Eclipse should have a <code>File -&gt; Convert Line Delimiters To...</code> option that may correct this for you. (If it doesn't work on your file, <a href="http://www-01.ibm.com/support/docview.wss?rs=79&amp;context=SSJNRR&amp;context=SSNJU5&amp;context=SSSTY3&amp;uid=swg21315284&amp;loc=en_US&amp;cs=UTF-8&amp;lang...
<p>It's possible that the server (or something in-between) is replacing all your CR+LF with CR LF (separate)?</p> <p>Try specifically setting the Text File Encoding (Window->Preferences->General->Workspace), or alternatively use File->Convert Line Delimiters To->Windows every time you get the latest version (I know, n...
18,614
<p>When do you recommend integrating a custom view into Interface Builder with a plug-in? When skimming through Apple's <a href="http://developer.apple.com/documentation/DeveloperTools/Conceptual/IBPlugInGuide/CreatingPluginBundle/chapter_2_section_3.html#//apple_ref/doc/uid/TP40004323-CH4-DontLinkElementID_15" rel="no...
<p>It's perfectly reasonable to push the view and controller classes that your application uses out into a separate framework — embedded in your application wrapper — for which you also produce an Interface Builder plug-in.</p> <p>Among other reasons, classes that are commonly used in your application can then be conf...
<p>I think the Apple guidelines sum it up nicely.</p> <p>If you're writing a control that will be used in multiple applications and is completely generic, then creating a custom object is a good idea. You'll be able to visualize the look and set properties directly from Interface Builder.</p> <p>If your control is li...
7,199
<p>I have a multiple selection SELECT field which I don't want the end user to be able to change the value of. </p> <p>For UI reasons, I would like to be able to do this without using the disabled="true" attribute. I've tried using onmousedown, onfocus, onclick and setting each to blur or return false but with no succ...
<p>I know you mentioned that you don't want to, but I actually think that using the <code>disabled</code> attribute is a better solution:</p> <pre><code>&lt;select multiple="multiple"&gt; &lt;option value="volvo" selected="true" disabled="disabled"&gt;Volvo&lt;/option&gt; &lt;option value="saab" disabled="disa...
<p>@Jack &amp; @17 of 26, good point but the end user will be expecting the select box to be disabled so that confusion shouldn't be an issue. </p> <p>I should have been clearer about why I couldn't just disable the control. </p> <p>The application that will be using this will need to disable the selection of the opt...
6,551
<p>I have a process in erlang that is supposed to do something immediately after spawn, then send the result back to the parent when it is finished. How do I figure out the PID of the process that spawned it?</p>
<p>You should pass self() to the child as one of the arguments to the entry function.</p> <pre><code>spawn_link(?MODULE, child, [self()]). </code></pre>
<p>You can use the BIF register to give the spawning / parent process a name (an atom) then refer back to the registered name from other processes.</p> <blockquote> <p>FUNC() -></p> <blockquote> <p>%% Do something<br> %% Then send message to parent<br> parent ! MESSAGE.</p> </blockquote> <p>....
2,629
<p>In Ruby, like in many other OO programming languages, operators are overloadable. However, only certain character operators can be overloaded.</p> <p>This list may be incomplete but, here are some of the operators that cannot be overloaded: </p> <pre><code>!, not, &amp;&amp;, and, ||, or </code></pre>
<p>Methods are overloadable, those are part of the language syntax.</p>
<p>And let's not forget about <code>&lt;&lt;</code> for example:</p> <pre><code>string = "test" string &lt;&lt; "ing" </code></pre> <p>is the same as calling:</p> <pre><code>string.&lt;&lt;("ing") </code></pre>
11,839
<p>Can someone explain the structure of a Pid in Erlang?</p> <p>Pids looks like this: <code>&lt;A.B.C&gt;</code>, e.g. <code>&lt;0.30.0&gt;</code> , but I would like to know what is the meaning of these three &quot;bits&quot;: <code>A</code>, <code>B</code> and <code>C</code>.</p> <p><code>A</code> seems to be always <...
<p>Printed process ids &lt; A.B.C > are composed of <a href="http://github.com/mfoemmel/erlang-otp/blob/R13B/erts/emulator/beam/erl_term.h#L502" rel="noreferrer">6</a>:</p> <ul> <li>A, the node number (0 is the local node, an arbitrary number for a remote node) </li> <li>B, the first 15 bits of the process number (an ...
<p>Apart from what others have said, you may find this simple experiment useful to understand what is going on internally:</p> <pre><code>1&gt; node(). nonode@nohost 2&gt; term_to_binary(node()). &lt;&lt;131,100,0,13,110,111,110,111,100,101,64,110,111,104,111, 115,116&gt;&gt; 3&gt; self(). &lt;0.32.0...
30,149
<p>I would like to create a report designer that has the same functionality and ease of use as the Visual Studio IDE. The ability to drag controls onto a form, select various subsets of those controls, align left, evenly space, etc. </p> <p>The only tools I have ever encountered are really bad. Crystal Reports, the ...
<p>Um, sounds like you want to do ad-hoc reporting. I have never seen one of these done well outside of a COTS product like BusinessObjects Web Intelligence, which I am using right now on one of my projects.</p> <p><a href="http://www.businessobjects.com/product/catalog/web_intelligence/" rel="nofollow noreferrer">ht...
<p>There is an SQL MS Reports Solution. It's called SSRS and you may have heard of it, but what you might not know it there is an OK end user targeted reporting tool. It works especially well if you are using datasets. The reports can be saved as files and run and/or built inside a VS project, within SQL SSRS, or us...
29,557
<p>What is your favorite, lossless image format for games (namely 2d games)? And why?</p> <p>Some things to take into consideration are size on disk, overhead for converting to a usable format, and features of the format (ie alpha support).</p> <p>There is no best answer, but be sure to back yours up the best you can...
<p>I'd suggest PNG. Most software supports writing it, most libraries support reading it, it's lossless and supports alpha transparency. And it's a standard format.</p> <p>And, maybe important for hobbyist 2D games, very small images also result in very small files (i.e. a 16x16 icon can be 1KB or less).</p>
<p>PNG does NOT support alpha transparency, it has a translucency channel, which is different. This can lead to problems depending on how you are rendering sprites to the screen. TGA, hands down.</p>
17,575
<p>Replaces Question: <a href="https://stackoverflow.com/questions/184096/update-multiple-rows-into-sql-table">Update multiple rows into SQL table</a></p> <p>Here's a Code Snippet to update an exam results set. DB structure is as given, but I can submit Stored Procedures for inclusion (Which are a pain to modify, so I...
<p>A few things stand out:</p> <ul> <li><p>You don't show where the SqlConnection is instantiated, so it's not clear that you're disposing it properly.</p></li> <li><p>You shouldn't be swallowing exceptions in the loop - better to handle them in a top level exception handler.</p></li> <li><p>You're instantiating new p...
<p>emit a single update that goes against a values table:</p> <pre><code>UPDATE s SET ANSWER=a FROM dbo.STUDENTAnswers s JOIN ( SELECT 1 as q, 'answer1' as a UNION ALL SELECT 2, 'answer2' -- etc... ) x ON s.QuestionNum=x.q AND StudentID=@ID </code></pre> <p>so you just put this together like this:</p> <pre><code...
22,303
<p>My company change the domain from abc to xyz and now i can't log into my local sql2005 via Windows login nor sql login.</p> <p>both login gave me this error: An error has occured while establishing a connection to the server. blah blah blah...Sql server does not allow remote connection. Error:26 - Error locating S...
<p>It's weird but i find the solution. I select the database that i want to connect to which is the same instance on the login screen then using the sql authentication. i was able to login in. It turn out the my work station was renamed. that's why it can't find the server instance.</p>
<p>What server name are you using? If you're using anything other than (local), localhost, or . - then you probably need to change the server to NEWDOMAIN\HOSTNAME or hostname.newdomain.com.</p>
40,592
<p>I been waiting for sometime now to bring my Asp.net Preview 4 project up to snuff, totally skipping Preview 5 just because I knew I would have some issues.</p> <p>Anyhow, here is the question and dilemma.</p> <p>I have a few areas on the site which I have an ajax update type panel that renders content from a view ...
<p>Unfortunately, just calling submit() won't fire the onsubmit event so the MVC Ajax script won't run. When the <strong>browser</strong> calls onsubmit() for you (because the user clicked the submit button), it actually provides a parameter called <em>event</em> (which you can see if you look at the Html outputted by...
<p>I believe that calling someFormElement.onsubmit() simply invokes the event handlers registered for that event. To properly submit the form you should call someFormElement.submit() (without the "on" prefix).</p> <p>I don't think we changed anything in the AJAX helpers' behavior between ASP.NET MVC Preview 4 and ASP....
29,405
<p>In a WinForms UserControl, I would pass data to the main GUI thread by calling this.BeginInvoke() from any of the control's methods. What's the equivalent in a Silverlight UserControl?</p> <p>In other words, how can I take data provided by an arbitrary worker thread and ensure that it gets processed on the main di...
<p>Use the Dispatcher property on the UserControl class.</p> <pre><code>private void UpdateStatus() { this.Dispatcher.BeginInvoke( delegate { StatusLabel.Text = "Updated"; }); } </code></pre>
<pre><code> private void UpdateStatus() { // check if we not in main thread if(!this.Dispatcher.CheckAccess()) { // call same method in main thread this.Dispatcher.BeginInvoke( UpdateStatus ); return; } // in main thread now StatusLabel.Tex...
27,479
<p>I know that using <code>ls -l "directory/directory/filename"</code> tells me the permissions of a file. How do I do the same on a directory?</p> <p>I could obviously use <code>ls -l</code> on the directory higher in the hierarchy and then just scroll till I find it but it's such a pain. If I use <code>ls -l</code> ...
<p>Here is the short answer:</p> <pre><code>$ ls -ld directory </code></pre> <p>Here's what it does:</p> <pre><code>-d, --directory list directory entries instead of contents, and do not dereference symbolic links </code></pre> <p>You might be interested in <a href="http://en.wikipedia.org/wiki/Manpage" rel="no...
<p>To check the permission configuration of a file, use the command:</p> <pre><code>ls –l [file_name] </code></pre> <p>To check the permission configuration of a directory, use the command:</p> <pre><code>ls –l [Directory-name] </code></pre>
43,872
<p>I'm using a Response.Redirect to redirect users to another server to download a file, and the other server is checking the header to ensure it came from the correct server... however it seems Response.Redirect strips the headers from the Response.</p> <p>Does anybody know how i can add the headers back? I've tried...
<p>There is an HTML hack available.</p> <pre><code>&lt;form action="http://url.goes.here" id="test" method="GET"&gt;&lt;/form&gt; &lt;script type="text/javascript"&gt; document.getElementById("test").submit(); &lt;/script&gt; </code></pre> <p>If you need to trigger that from a code behind, that can be done too:</p>...
<p>+1 to inkel's comment above.</p> <p>Though if you don't care about the spec and just want to do it anyway, you can avoid using Response.Redirect and instead build the response headers yourself.</p> <pre><code>Response.StatusCode = 302; //temp redirect Response.Headers.Add("Location", "your/url/here"); Response.Hea...
30,102
<p>I'm currently working on a project that hooks into various system calls and writes things to a log, depending on which one was called. So, for example, when I change the permissions of a file, I write a little entry to a log file that tracks the old permission and new permission. However, I'm having some trouble p...
<p>History :-)</p> <p>Once a system call has been created it can't ever be changed, therefore when new functionality is required a new system call is created. (Of course this means there's a very high bar before a new system call is created).</p>
<p>History :-)</p> <p>Once a system call has been created it can't ever be changed, therefore when new functionality is required a new system call is created. (Of course this means there's a very high bar before a new system call is created).</p>
32,999
<p>Is it possible in c# to initialize an array in, for example, subindex 1?</p> <p>I'm working with Office interop, and every property is an object array that starts in 1 (I assume it was originally programed in VB.NET), and you cannot modify it, you have to set the entire array for it to accept the changes.</p> <p>A...
<p>You can use <a href="http://msdn.microsoft.com/en-us/library/system.array.createinstance%28v=vs.110%29.aspx" rel="nofollow noreferrer"><code>Array.CreateInstance</code></a>.</p> <p>See <a href="http://msdn.microsoft.com/en-us/magazine/cc301755.aspx" rel="nofollow noreferrer">Array Types in .NET</a></p>
<p>In VB6 you could change the array to start with 0 or 1, so I think VBScript can do the same. For C#, it's not possible but you can simply add NULL value in the first [0] and start real value at [1]. Of course, this is a little dangerous... </p>
10,861
<p>I run a browser based game at www.darknovagames.com. Recently, I've been working on reformatting the site with CSS, trying to get all of its pages to verify according to the HTML standard.</p> <p>I've been toying with this idea of having the navigation menu on the left AJAX the pages in (rather than taking the user...
<p>If you're going to enable AJAX, don't do it at the expense of having accessible URLs to every significant page on your site. This is the backbone of a navigable site that people can use.</p> <p>When you shovel all your functionality into AJAX calls and callbacks, you're basically forcing your users into a single p...
<p>I’d stick with simple hyperlinks. Your page furniture shouldn’t account for a big portion of the HTML, so it’s not a big win excluding it from page requests. Making each resource addressable (i.e. a URL for each bit of content a user might be interested in) is a key design feature of the web. It means caching can wo...
19,781
<p>We've had problems with a virus scanner murdering the performance of our app by slowing down writes to an <a href="http://en.wikipedia.org/wiki/H2_(DBMS)" rel="nofollow noreferrer">H2 db</a>. So we'd like to be able to detect the presence of any virus scanner and alert the user of the potential problem. It would be ...
<p>On Windows Vista, MS added some API calls to allow you to query the status of the Windows Security Centre, which should tell you if A/V software is installed. Obviously this is not a particularly generic solution, nor a Java-based one, but it's the only way I can think of, short of attempting to install a virus. Um ...
<p>Cant you tell the virus scanner to not scan the H2 DB files or at least scan them differently?</p> <p>It sounds like you are going to a lot of trouble to work around something that may be more directly fixable. (believe me... Mc Afee used to put my workstation into Lockdown when i started debugging sometimes. I ch...
26,952
<p>I’m trying to run Google earth inside WPF but I don’t know how. Basically I have managed to run Google Earth in a Windows Form Control inside a Windows Form, everything was OK. </p> <p>Trying to do the same thing in WPF, well, give strange result a small Google Earth screen placed anywhere in the form an not inside...
<p>If you have a Windows Forms control that already works exactly as you want, you could always use WindowsFormsHost to put that control on your WPF form. That might be the easiest thing to do... or is that what you're already doing that isn't working?</p>
<p>I also wrote an application that placed Google Earth inside a WinForms WebBrowserControl that was based on the more-or-less official example hosted by Google. It worked fine. I struggled to recreate the same application inside a WPF WebBrowserControl. My experience confirms what appears to be the general conse...
34,496
<p>What is the best way to manage the JavaScript files and the functions/objects context in an ASP.NET MVC app?</p>
<p>Google says <a href="http://javascriptmvc.com/" rel="nofollow noreferrer">http://javascriptmvc.com/</a></p>
<p>I put all my js files in the Content/Js folder. Then add URL helpers that allow me to change this in the future. My code isn't online, but I stole the idea from <a href="https://mvcsamples.svn.codeplex.com/svn/Commerce.Web/App/Helpers/AppHelper.cs" rel="nofollow noreferrer">Rob Conery MVC Commerce demo</a>.</p> <p>...
26,634
<p>I have mapped several java classes like Customer, Assessment, Rating, ... to a database with Hibernate. Now i am thinking about a history-mode for all changes to the persistent data. The application is a web application. In case of deleting (or editing) data another user should have the possibility to see the chang...
<p>One way to do it would be to have a "change history" entity with properties for entity id of the entity changed, action (edit/delete), property name, orginal value, new value. Maybe also reference to the user performing the edit. A deletion would create entities for all properties of the deleted entity with action "...
<p>Hmm I'm looking for an answer to this too. So far the best I've found is the www.jboss.org/envers/ framework but even that seems to me like more work than should be necessary.</p>
25,006
<p>I am getting C++ Compiler error C2371 when I include a header file that itself includes odbcss.h. My project is set to MBCS.</p> <blockquote> <p>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\odbcss.h(430) : error C2371: 'WCHAR' : redefinition; different basic types 1><br> C:\Program Files\Microsoft SD...
<p>This is a known bug - see the Microsoft Connect website:</p> <p><a href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=98699" rel="nofollow noreferrer">http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=98699</a></p> <p>The error doesn't occur if you c...
<p>This error happens when you redeclare a variable of the same name as a variable that has already been declared. Have you looked to see if odbcss.h has declared a variable you already have?</p>
6,352
<p>What alternatives do I have to implement a union query using hibernate? I know hibernate does not support union queries at the moment, right now the only way I see to make a union is to use a view table.</p> <p>The other option is to use plain jdbc, but this way I would loose all my example/criteria queries goodies...
<p>Use VIEW. The same classes can be mapped to different tables/views using entity name, so you won't even have much of a duplication. Being there, done that, works OK.</p> <p>Plain JDBC has another hidden problem: it's unaware of Hibernate session cache, so if something got cached till the end of the transaction and ...
<p>I too have been through this pain - if the query is dynamically generated (e.g. Hibernate Criteria) then I couldn't find a practical way to do it. </p> <p>The good news for me was that I was only investigating union to solve a performance problem when using an 'or' in an Oracle database. </p> <p>The solution Patri...
24,541
<p>During a long compilation with Visual Studio 2005 (version 8.0.50727.762), I sometimes get the following error in several files in some project: </p> <pre><code>fatal error C1033: cannot open program database 'v:\temp\apprtctest\win32\release\vc80.pdb' </code></pre> <p>(The file mentioned is either <code>vc80.pdb...
<p>It is possible that an antivirus or a similar program is touching the pdb file on write - an antivirus is the most likely suspect in this scenario. I'm afraid that I can only give you some general pointers, based on my past experience in setting nightly builds in our shop. Some of these may sound trivial, but I'm in...
<p>Are you using LinqToSql at all? Perhaps it is similar to the odd error I will experience occasionally as I asked in this question: <a href="https://stackoverflow.com/questions/28839/what-causes-visual-studio-to-fail-to-load-an-assembly-incorrectly">What causes Visual Studio to fail to load an assembly incorrectly?</...
15,418
<p>If I type the command:</p> <pre><code>mvn dependency:list </code></pre> <p>The <a href="http://maven.apache.org/plugins/maven-dependency-plugin/" rel="nofollow noreferrer">docs</a> suggest that I'll get a list of my project's dependencies. Instead though, I get this:</p> <pre><code>[INFO] Searching repository for...
<p>Have you tried <code>mvn -cpu dependency:list</code> (or: <code>mvn --check-plugin-updates dependency:list</code>)? Probably, you have older version of dependency plugin which does not have goal <code>list</code></p> <p>If this does not help, try upgrading Maven. Since 2.0.9 default versions are provided by the Sup...
<p>Try latest maven version, usually upgrades to newer versions solve issues.</p>
39,729
<p>How can I tell in JavaScript what path separator is used in the OS where the script is running?</p>
<p>Use <a href="http://nodejs.org/docs/latest/api/path.html" rel="noreferrer"><code>path</code></a> module in <code>node.js</code> returns the platform-specific file separator. <br/> example</p> <pre><code>path.sep // on *nix evaluates to a string equal to "/" </code></pre> <p>Edit: As per Sebas's comment below, to ...
<p>Just use "/", it works on all OS's as far as I know.</p>
15,298
<p>Imagine you have an executable foo.rb, with libraries bar.rb layed out in the following manner:</p> <pre><code>&lt;root&gt;/bin/foo.rb &lt;root&gt;/lib/bar.rb </code></pre> <p>In the header of foo.rb you place the following require to bring in functionality in bar.rb:</p> <pre><code>require File.dirname(__FILE__)...
<p>I know this is ages old, but I just found this:</p> <pre><code>require 'pathname' APP_ROOT = File.join(File.dirname(Pathname.new(__FILE__).realpath),'..') </code></pre>
<p>Probably worth mentioning that <code>+</code> works nicely with <code>Pathname</code> objects and also there is <code>Kernel.Pathname</code> method, so @Burke's original code could be made even shorter:</p> <pre><code>require 'pathname' APP_ROOT = Pathname.new(__FILE__).realpath + "../../lib" </code></pre>
41,772
<p>Can someone give me some example code that creates a surface with a transparent background in pygame?</p>
<p>This should do it:</p> <pre><code>image = pygame.Surface([640,480], pygame.SRCALPHA, 32) image = image.convert_alpha() </code></pre> <p>Make sure that the color depth (32) stays explicitly set else this will not work.</p>
<p>You have 3 possibilities:</p> <ul> <li><p>Set a transparent color key with <a href="https://www.pygame.org/docs/ref/surface.html#pygame.Surface.set_colorkey" rel="nofollow noreferrer"><code>set_colorkey()</code></a></p> <p>The color key specifies the color that is treated as transparent. For example, if you have an ...
42,529
<p>I'm trying to use “rusage” statistics in my program to get data similar to that of the <a href="http://en.wikipedia.org/wiki/Time_%28Unix%29" rel="nofollow noreferrer">time</a> tool. However, I'm pretty sure that I'm doing something wrong. The values seem about right but can be a bit weird at times. I didn't find go...
<p>What is the purpose of:</p> <pre><code>while (usec &gt;= 1000) usec /= 10; </code></pre> <p>I gather that you want the most significant three digits of the usec; in that case, the most straightforward way I can think of is to divide usec by 1000, and be done with that.</p> <p>Test cases:</p> <ul> <li>999999 ...
<p>I think there's probably a bug somewhere in your composition of sec and usec. I can't really say what exactly without knowing the kinds of errors you're seeing. A rough guess would be that usec can never be > 999999, so you're relying on overflow to know when to adjust sec. It could also just be a problem with your ...
4,395
<p>It seems MySQL does not support the flag "NO_ WRITE_ TO_ BINLOG" for TRUNCATE. So I have to wait until delay is 0, then stop the replication, make the TRUNCATE of the table/s, reset the master, and then start replication again. Really painful. Any other suggestion?</p>
<p>You can use the command to disable binary logging for a session to do what you want.</p> <pre> SET SQL_LOG_BIN = 0; TRUNCATE TABLE ; SET SQL_LOG_BIN = 1; </pre> <p>This does require that you have the SUPER privilege since you are effectively breaking replication by not sending the TRUNCATE to the slave.</p>
<p>TRUNCATE is pretty heavy-handed. Can you get by with just a DELETE query?</p>
21,241
<p>As of right now I believe only Firefox support <code>-moz-border-radius</code> property. I am surprised that twitter uses it.</p> <p>Are any other browsers planning on supporting this or does CSS3 have something like this in the works?</p> <p><strong>Edit:</strong> I also found <a href="http://www.css3.info/previe...
<p><a href="http://www.w3.org/TR/css3-background/#the-border-radius" rel="nofollow noreferrer">CSS3 has <code>border-radius</code></a>.</p> <p>For now, Mozilla- and WebKit-based browsers have experimental support, <code>-moz-border-radius</code> and <code>-webkit-border-radius</code>. It's not bad to use them now, as ...
<p>Any CSS property that starts with a dash (e.g. <code>-moz</code>, <code>-webkit</code>) is a browser-specific property.</p> <p>This allows browser vendors to experiment with new CSS properties. Doing so is a common part of the process for writing new CSS specs, to allow web developers to see how the properties work...
42,750
<p>I'm writing some tests in Perl which have a fair amount of set up. This setup all lives in a module that the test scripts <code>use</code>. I want to be able to print some diagnostics from the module, and intended to use the <code>diag</code> function from <code>Test::More</code>. Problem is, when you <code>use Test...
<p>"new" means you've got two completely different methods as far as the CLR is concerned - they happen to have the same name, but they're unrelated in terms of inheritance. That means that if you run:</p> <pre><code>Base b = new Derived(); Derived d = new Derived(); b.MyMethod(); // Calls Base.MyMethod d.MyMethod(); ...
<p>This is actually <em>not</em> a <em>choice</em> you have. This is imposed upon you by however created the base class. If there exists a method with the same name and it is marked as "virtual" then you should use override unless you want to have some seriously funny bugs appearing down the road when people starts cas...
44,249
<p>We need to write unit tests for a <em>wxWidgets</em> application using <em>Google Test Framework</em>. The problem is that <em>wxWidgets</em> uses the macro <strong>IMPLEMENT_APP(MyApp)</strong> to initialize and enter the application main loop. This macro creates several functions including <strong>int main()</stro...
<p>You want to use the function:</p> <pre><code>bool wxEntryStart(int&amp; argc, wxChar **argv) </code></pre> <p>instead of wxEntry. It doesn't call your app's OnInit() or run the main loop.</p> <p>You can call <code>wxTheApp-&gt;CallOnInit()</code> to invoke OnInit() when needed in your tests.</p> <p>You'll need t...
<p>You could possibly turn the situation around:</p> <p>Initialize and start the wxPython app including the main loop, then run the unit tests from within the app. I think there is a function called upon main loop entry, after all init stuff is done.</p>
25,561
<p>We create thumb images on our server and I'm looking for a way to save metadata (text) in that image. Is that possible?</p> <p>At this moment we use <code>PHP</code> and we create <code>JPG</code> images.</p>
<p>You question is the same as <a href="https://stackoverflow.com/questions/5384962/writing-exif-data-in-php">writing exif data in php</a>.</p> <p>My answer is: </p> <ul> <li><a href="https://github.com/pel/pel" rel="nofollow noreferrer">PEL(PHP Exif Library)</a>. A library for reading and writing Exif headers in JPE...
<p><a href="http://xml.coverpages.org/XMP-Embedding.pdf" rel="nofollow noreferrer">Embedding XMP Metadata in Application Files</a> (PDF)</p>
12,802
<p>Not every website exposes their data well, with XML feeds, APIs, etc</p> <p>How could I go about extracting information from a website? For example:</p> <pre><code>... &lt;div&gt; &lt;div&gt; &lt;span id="important-data"&gt;information here&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; ... </code></pre> <p>I com...
<p>There are several Open Source HTML Parsers out there for Java.</p> <p>I have used <a href="http://jtidy.sourceforge.net/" rel="nofollow noreferrer">JTidy</a> in the past, and have had good luck with it. It will give you a DOM of the html page, and you should be able to grab the tags you need from there.</p>
<p>Java seems like a fairly difficult constraint for such a task. Is that a hard requirement? Scripting languages are ideal for building what is really lots of last-mile code.</p> <p>If you're be open to it, ruby + <a href="http://code.whytheluckystiff.net/hpricot/" rel="nofollow noreferrer">hpricot</a> makes that co...
41,176
<p>I am not convinced - I think it might be useful to expose your data to different consumers that can build their front-end apps on top of your webservice.</p> <p>Can someone provide samples of when using web-services to wrap data-access layer is a bad idea?</p>
<p>Depending on what you define as a 'data access layer', there may or may not be a good reason to do it. Traditionally, distributed API's such as web services or RPC layers live on the next layer up. This has the following advantages:</p> <ol> <li><p>Without the tight coupling to the DB You can tune this layer to p...
<p>Well, if you are exposing your entire API over a web service with no security, that might be a bad idea.</p> <p>But if you are exposing the required parts of it, in a secure, read-only way, and your customers like it, that must surely be a good thing.</p> <p>If you ever need to persuade management remember that "G...
38,297
<p>I am using Oracle SQL (in SQLDeveloper, using the SQL Worksheet). I would like to print a statement before my select, such as</p> <pre><code>PRINT 'Querying Table1'; SELECT * from Table1; </code></pre> <p>What do I use to Print / show text output? It's not Print, because that gives me the error: Bind Variable <c...
<p><img src="https://i.stack.imgur.com/72MPn.png" alt="enter image description here"></p> <p>for simple comments:</p> <pre><code>set serveroutput on format wrapped; begin DBMS_OUTPUT.put_line('simple comment'); end; / -- do something begin DBMS_OUTPUT.put_line('second simple comment'); end; / </code></pre> ...
<p>If you don't want all of your SQL statements to be echoed, but you only want to see the easily identifiable results of your script, do it this way:</p> <blockquote> <p>set echo on</p> <p>REM MyFirstTable</p> <p>set echo off</p> <p>delete from MyFirstTable;</p> <p>set echo on</p> <p>REM MySecondTable</p> <p>set echo ...
23,471
<p>Given an absolute or relative path (in a Unix-like system), I would like to determine the full path of the target after resolving any intermediate symlinks. Bonus points for also resolving ~username notation at the same time.</p> <p>If the target is a directory, it might be possible to chdir() into the directory an...
<pre><code>readlink -f "$path" </code></pre> <p><sup>Editor's note: The above works with <em>GNU</em> <code>readlink</code> and <em>FreeBSD/PC-BSD/OpenBSD</em> <code>readlink</code>, but <em>not</em> on OS X as of 10.11.<br> <em>GNU</em> <code>readlink</code> offers additional, related options, such as <code>-m</code>...
<p>Here I present what I believe to be a cross-platform (Linux and macOS at least) solution to the answer that is working well for me currently.</p> <pre><code>crosspath() { local ref="$1" if [ -x "$(which realpath)" ]; then path="$(realpath "$ref")" else path="$(readlink -f "$ref" 2&gt; /d...
2,925
<p>I am looking to make a web control where I can register client startup scripts inline with my aspx because I hate registering in the codebehind!</p> <p>An example of what I have so far:</p> <pre><code>&lt;Ben:StartupScript runat=&quot;server&quot;&gt; var form = document.getElementById(&quot;&lt;% =form1.Client...
<p>it sounds like a good idea, but if you spend too much time fighting the inherited/default behaviors then it may be more trouble than it's worth</p> <p>if this is a one-shot issue, a cheap-hack solution is to just directly embed your scripts in the header of a master page ;-)</p> <p>on the other hand, allowing deve...
<p>If you are using master pages, add another control in your section. That way you can easily add css/js to your headers in your child pages.</p> <p>ClientScript.RegisterScript is mostly for user/server controls, </p>
42,303
<p>i have the following script</p> <pre><code>import getopt, sys opts, args = getopt.getopt(sys.argv[1:], "h:s") for key,value in opts: print key, "=&gt;", value </code></pre> <p>if i name this getopt.py and run it doesn't work as it tries to import itself</p> <p>is there a way around this, so i can keep this fi...
<p>You shouldn't name your scripts like existing modules. Especially if standard. </p> <p>That said, you can touch sys.path to modify the library loading order</p> <pre><code>~# cat getopt.py print "HI" ~# python Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type "help...
<pre><code>import getopt as bettername </code></pre> <p>This should allow you to call getopt as bettername.</p>
24,660
<p>For a web application, I want to build a WHERE clause AND submit it to the server. There I will append it to a query. The clause will be something like</p> <pre><code>LASTNAME LIKE 'Pep%' AND (DOB BETWEEN '19600101' AND '19601231 OR SALARY&lt;35000) </code></pre> <p>Can you propose a regular expression to validate...
<p>This is a monumentally bad idea. I would suggest you build a filter system instead where the user can select all kinds of options in a form, and then you build the correct sql server-side instead of opening yourself up to all kinds of injection attacks.</p> <p>As an example of what might go wrong, consider this:</p...
<p>The number of possibilities of elements in a where clause is immense. Obviously you've got your ANDs and ORs and BETWEENs and IN lists and other operators, plus parens, but you could also be calling system procedures, user-defined functions, and depending on the RDBMS you're working with, entire subqueries. Then the...
25,070
<p>Is it possible to create Selenium tests using the Firefox plugin that use randomly generated values to help do regression tests?</p> <p><strong>The full story:</strong> I would like to help my clients do acceptance testing by providing them with a suite of tests that use some smarts to create random (or at least ps...
<p>First off, the Selenium IDE is rather limited, you should consider switching to Selenium RC, which can be driven by Java or Perl or Ruby or some other languages.</p> <p>Using just Selenium IDE, you can embed JavaScript expressions to derive command parameters. You should be able to type a random number into a text ...
<p>Here another variation on the gmail example:</p> <pre><code>&lt;tr&gt; &lt;td&gt;runScript&lt;/td&gt; &lt;td&gt;emailRandom=document.getElementById('email');console.log(emailRandom.value);emailRandom.value=&amp;quot;myEmail+&amp;quot; + Math.floor(Math.random()*11111)+ &amp;quot;@gmail.com&amp;quot;;&lt;/td&gt;...
19,589