instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I want to allow users to upload avatar-type images in a variety of formats (<strong>GIF, JPEG, and PNG at least</strong>), but to save them all as <strong>PNG database BLOBs</strong>. If the images are oversized, pixelwise, I want to resize them before DB-insertion.</p> <p><strong>What is the best way to use GD to ...
<pre><code>&lt;?php /* Resizes an image and converts it to PNG returning the PNG data as a string */ function imageToPng($srcFile, $maxSize = 100) { list($width_orig, $height_orig, $type) = getimagesize($srcFile); // Get the aspect ratio $ratio_orig =...
<p><a href="http://www.phpit.net/article/image-manipulation-php-gd-part2/" rel="nofollow noreferrer">This article</a> seems like it would fit what you want. You'll need to change the saving imagejpeg() function to imagepng() and have it save the file to a string rather than output it to the page, but other than that i...
4,224
<p>I believe that we can allow Firefox to sent NTLM data to SharePoint sites to do automatic authentication, and I think that this is doable with IIS.</p> <p>I'd like to do the same thing with an internal Rails site.</p> <p>Does anyone know of way that I could authenticate NTLM type user information through a Apache/...
<p>I'm assuming you've already worked out which HTTP headers you need to send in order to get firefox and IE to send back the NTLM authentication stuff, and are just needing to handle that on the server side?</p> <p>You could use some of ruby's <a href="http://raa.ruby-lang.org/cat.rhtml?category_major=Library;categor...
<p>Check out <a href="http://waffle.codeplex.com" rel="nofollow noreferrer">Waffle</a>. It provides SSO on Windows to Java servers using Win32 API. There're a number of implemented filters (servlet, tomcat valve, spring-security).</p>
18,129
<p>I have never seen a way to do this nicely, i would be interested in seeing how others do it. Currently i format it like this:</p> <pre><code>public Booking createVehicleBooking(Long officeId, Long start, Long end, ...
<p>A large set of parameters like this is often (but not always) an indicator that you could be using an object to represent the parameter set. This is especially true if either:</p> <ul> <li><p>There are several methods with similar large parameter sets, that can be replaced with a single method taking a parameter ob...
<p>I like the one param per line approach that you're showing. I find it's very easy to scan it visually and see what's present.</p> <p>I find that when people use something like Guice you often end up with a large number of params and this makes it easier to read.</p>
23,023
<p>I want to create the 26 neighbors of a cubic-voxel-node in 3-d space. The inputs are the x,y,z position of the node and the size of the cube side . I am trying to do this using a for loop but haven't managed yet. I am quite newbie in programming please help me.</p>
<pre><code>for (int dz = z - 1; dz &lt;= z + 1; ++dz) { for (int dy = y - 1; dy &lt;= y + 1; ++dy) { for (int dx = x - 1; dx &lt;= x + 1; ++dx) { // all 27 if ((dx != x) || (dy != y) || (dz != z)) { // just the 26 neighbors } } } } </code></pre>
<pre><code>for(int i = 0; i &lt; 27, i++) { if(i == 13) continue; int dx = i%3 -1; int dy = (i/3)%3 -1; int dz = i/9 - 1; process(x+dx,y+dy,z+dz); } </code></pre>
42,351
<p>I'm looking for a regex that can pull out quoted sections in a string, both single and double quotes.</p> <p>IE:</p> <pre><code>"This is 'an example', \"of an input string\"" </code></pre> <p>Matches:</p> <ul> <li>an example</li> <li>of an input string</li> </ul> <p>I wrote up this:</p> <pre><code> [\"|'][A-Za...
<p>How does it handle single quotes inside of double quotes (or vice versa)?</p> <pre><code>"This is 'an example', \"of 'quotes within quotes'\"" </code></pre> <p>should match</p> <ul> <li>an example <li>of 'quotes within quotes' </ul> <p>Use a backreference if you need to support this.</p> <pre><code>(\"|')[A-Za-...
<p>It works but doesn't match other characters in quotes (e.g., non-alphanumeric, like binary or foreign language chars). How about this:</p> <pre><code>[\"']([^\"']*)[\"'] </code></pre> <p>My C# regex is a little rusty so go easy on me if that's not exactly right :)</p>
25,766
<p>I deleted millions of rows of old data from a production SQL database recently, and it didn't seem to shrink the size of the .MDF file much. We have a finite amount of disk space.</p> <p>I am wondering if there is anything else I can do to "tighten" the file (like something analogous to Access' Compact and Repair f...
<p>Use the Shrink File option in Sql Server Management Studio Right-click on Database > Tasks > Shrink > Database (or Files)</p>
<p>This worked for me and shrank my log files by a thousand.</p> <ol> <li>Using the SQL Server Manager.</li> <li>Right Click on the database in question.</li> <li>Choose Properties, then the options tab. </li> <li>Change the Recovery Model to Simple From Full.</li> </ol> <p>If you need it in full mode switch it back ...
19,691
<p><strong>EDIT:</strong> <em>I'm still waiting for more answers. Thanks!</em></p> <p>In SQL 2000 days, I used to use temp table method where you create a temp table with new identity column and primary key then select where identity column between A and B.</p> <p>When <strong>SQL 2005</strong> came along I found out...
<p>The row_number() technique should be quick. I have seen good results for 100,000 rows.</p> <p>Are you using row_number() similiar to the following:</p> <pre><code>SELECT column_list FROM (SELECT column_list ROW_NUMBER() OVER(ORDER BY OrderByColumnName) as RowNum FROM MyTable m ) as DerivedTableN...
<p>Well, for your sample query ROW_COUNT should be pretty fast with thousands of rows, provided you have an index on your PostDate field. If you don't, the server needs to perform a complete clustered index scan on your PK, practically load every page, fetch your PostDate field, sort by it, determine the rows to extrac...
20,474
<p>In Django 1.0, what is the best way to catch and show an error if user enters only whitespace (" ") in a form field?</p> <pre><code>class Item(models.Model): description = models.CharField(max_length=100) class ItemForm(ModelForm): class Meta: model = Item </code></pre> <p>if user enters only whit...
<pre><code>class ItemForm(forms.ModelForm): class Meta: model = Item def clean_description(self): if not self.cleaned_data['description'].strip(): raise forms.ValidationError('Your error message here') </code></pre> <p>The <a href="http://docs.djangoproject.com/en/dev/ref/forms/val...
<p>Figured it out. Just adding <strong>description = forms.RegexField(regex=r'[^(\s+)]')</strong> to class ItemForm will cause the form.is_valid() to fail and show the error</p> <pre><code>class ItemForm(ModelForm): description = forms.RegexField(regex=r'[^(\s+)]') class Meta: model = Item </code></pre...
43,020
<p>I imagine I can compile a C# DLL and then expose it as a COM object so that it can be CreateObject'd from VBscript. I'm just not sure the steps involved in doing this...</p>
<p>It can be very simple to do this. But there are a lot of places where it's not so simple. It depends a lot on what your class needs to be able to do, and how you intend to deploy it.</p> <p>Some issues to consider:</p> <ul> <li>Your class has to have a parameterless constructor.</li> <li>It can't expose static m...
<p>There's a "COM Accessible" option for each project you can select. Then, of course, you have to register the assembly to use it, but that's about it.</p> <hr> <p>I had to go hunting a bit to find it for C# (I'm used to VB.Net), but you can find the option by double-clicking on the <code>Properties</code> folder i...
46,606
<p>There's a lot to C# &amp; ASP.net. Where should I start? What should I not bother focusing on?</p> <p>Should I learn Winforms then WPF? Ditto for webforms / Silverlight? Should I learn ASP.MVC or classic ASP.NET? If both, which first?</p> <p>In the either/or cases - which will make more sense having known the othe...
<p>What do you want to write? If you want to write a Windows client-side app, look into WinForms and WPF (no real need to learn WinForms before WPF, other than the way that a lot of tutorials/books will probably compare WPF concepts with WinForms concepts). If you're looking at a web app, then ASP.NET or ASP.MVC - I do...
<p>I highly recommend the following books, for learning about whats new in ASP.NET 3.5</p> <ul> <li><a href="https://rads.stackoverflow.com/amzn/click/com/0470410957" rel="nofollow noreferrer" rel="nofollow noreferrer">ASP.NET MVC 1.0 Website Programming</a></li> <li><a href="https://rads.stackoverflow.com/amzn/click/...
35,712
<p>How to remove the program icon from the Programs folder?</p>
<p>A shortcut file is a normal file that happens to redirect (on click) the call to another file, program or directory. To remove a shortcut you can use the <a href="http://msdn.microsoft.com/en-us/library/system.io.file.delete.aspx" rel="nofollow noreferrer">File.Delete</a> method.</p> <pre><code>File.Delete(path_to_...
<p>1- Be sure to get actual file link use OpenFileDialog</p> <hr> <p>OpenFileDialog od = new OpenFileDialog(); od.DereferenceLinks = false; </p> <p><a href="http://www.vbforums.com/showthread.php?549631-RESOLVED-Shortcut-path-in-VB-NET" rel="nofollow noreferrer">use DereferenceLinks</a></p> <p>2 us...
26,012
<p><strong>Here is the updated question:</strong></p> <p>the current query is doing something like:<br></p> <pre><code>$sql1 = "TRUNCATE TABLE fubar"; $sql2 = "CREATE TEMPORARY TABLE IF NOT EXISTS fubar SELECT id, name FROM barfu"; </code></pre> <p>The first time the method containing this is run, it generates an er...
<p>shmuel613, it would be better to update your original question rather than replying. It's best if there's a single place containing the complete question rather than having it spread out in a discussion.</p> <p>Ben's answer is reasonable, except he seems to have a 'not' where he doesn't want one. Dropping the table...
<p>OK then, not bad. To be more specific, the current query is doing something like:</p> <pre> $sql1 = "TRUNCATE TABLE fubar"; $sql2 = "CREATE TEMPORARY TABLE IF NOT EXISTS fubar SELECT id, name FROM barfu"; </pre> <p>The first time the method containing this is run, it generates an error message on the truncate sin...
10,991
<p>I was going through some code and came across a scenario where my combobox has not been initialized yet. This is in .NET 2.0 and in the following code, this.cbRegion.SelectedValue is null.</p> <pre><code>int id = (int)this.cbRegion.SelectedValue; </code></pre> <p>This code threw a null reference exception instead...
<p>It has to do with <a href="http://www.csharphelp.com/archives/archive100.html" rel="noreferrer">Boxing</a> and unboxing. It is trying to pull an int out of the box (unbox), but the object is null, so you get a null reference exception before it ever gets the change to cast.</p>
<p>The exception is on the Selected Value which is null. It's never even getting to the cast.</p>
47,143
<p>I've been working on an embedded C/C++ project recently using the shell in Tornado 2 as a way of debugging what's going on in our kit. The only problem with this approach is that it's a complicated system and as a result, has a fair bit of output. Tornado 'helpfully' scrolls the window every time some new informatio...
<p>here is another potential way:</p> <pre> -> saveFd = open("myfile.txt",0x102, 0777 ) -> oldFd = ioGlobalStdGet(1) -> ioGlobalStdSet(1, saveFd) -> runmytest() ... -> ioGlobalStdSet(1, oldFd) </pre> <p>this will redirect <strong>all</strong> stdout activity to the file you opened. You might have to play around with ...
<p>rlogin vxWorks-target | tee redirected-output.txt</p>
13,199
<p>I would like to make custom insoles for my wife.</p> <p>This company makes a flexible filament that will be soft to stand on: <a href="http://recreus.com/en/" rel="noreferrer">http://recreus.com/en/</a></p> <p>I do not currently own a printer.</p> <p>How can I measure her feet and transfer the measurements to the...
<p>Here is a post that covers how to scan a foot and make a form fitting insole - <a href="https://web.archive.org/web/20180429035945/http://www.gyrobot.co.uk/blog/my-adventures-with-3d-printed-insoles-part-4-4" rel="nofollow noreferrer">https://web.archive.org/web/20180429035945/http://www.gyrobot.co.uk/blog/my-advent...
<p>Many questions in one post, but I'll address only the first. Consider to use a shoe with a flat insole, perhaps even what is commonly called a flip-flop. If your objective is to perfectly match the curve of her foot bottom, this should work. Apply a layer of polymer modeling clay, plasticine or similar material. It ...
226
<p>I have a website which uses the custom 404 error handling in PHP/Apache to display specific pages.<br> e.g. <a href="http://metachat.org/recent" rel="nofollow noreferrer">http://metachat.org/recent</a> </p> <p>I've a feeling this is a bad way of doing this, but it's code I inherited...</p> <p>Although the page dis...
<p>There's no way other than using URL rewriting (mod_rewrite) or creating the missing pages. What's happening is that the client requests a page which doesn't exist. Apache is configured to serve a special page upon 404 errors, but it still sends the 404 status code, then AVG traps that.</p> <p>So, you could do somet...
<p>Some browsers don't display the content of 404 pages if that content is quite small. If there's larger page content they do display it. This rule varies per browser. Try adding more content to your 404 page and see whether that helps.</p>
20,108
<p>I am wondering if there is a way to combine multiple images into a single image using only JavaScript. Is this something that Canvas will be able to do. The effect can be done with positing, but can you combine them into a single image for download?</p> <p><strong>Update Oct 1, 2008:</strong></p> <p>Thanks for t...
<p>I know this is an old question and the OP found a workaround solution, but this will work if the images and canvas are already part of the HTML page.</p> <pre><code>&lt;img id="img1" src="imgfile1.png"&gt; &lt;img id="img2" src="imgfile2.png"&gt; &lt;canvas id="canvas"&gt;&lt;/canvas&gt; &lt;script type="text/java...
<p>I don't think you can or would want to do this with client side javascript ("combing them into a single image for download"), because it's running on the client: even if you could combine them into a single image file on the client, at that point you've already downloaded all of the individual images, so the merge i...
19,203
<p>I have a table that was imported as all UPPER CASE and I would like to turn it into Proper Case. What script have any of you used to complete this?</p>
<p>Here's a UDF that will do the trick...</p> <pre><code>create function ProperCase(@Text as varchar(8000)) returns varchar(8000) as begin declare @Reset bit; declare @Ret varchar(8000); declare @i int; declare @c char(1); if @Text is null return null; select @Reset = 1, @i = 1, @Ret = ''; while (...
<p>I know the devil is in the detail (especially where people's personal data is concerned), and that it would be very nice to have properly capitalised names, but the above kind of hassle is why the pragmatic, time-conscious amongst us use the following: </p> <p><code>SELECT UPPER('Put YoUR O'So oddLy casED McWeird-n...
28,490
<p>Note: I am just consuming webservice I have no control over webservice code.</p> <p>So in .net 2.0 I reference the webservice and see a class in the webservice namespace, say foobar. It's defined as:</p> <pre><code>public class foobar : System.Web.Services.Protocols.SoapHttpClientProtocol </code></pre> <p>but in ...
<p>You can try using the <strong>Web Service Description Language Tool</strong> (<code>Wsdl.exe</code>) to generate an actual class file:</p> <blockquote> <p><code>wsdl.exe /language:cs http://www.example.com/FooService.wsdl</code></p> </blockquote> <p>You can get more information about the <a href="http://msdn.mic...
<p>I have a sneaky feeling that the properties will not be part of the service definition (WSDL) which would mean you may not be able to use them. If possible try to convince who ever maintains the service to expose the properties as actual methods.</p> <p>It is quite likely that you will be unable to access the prope...
27,662
<p>Here is the scenario: </p> <p>I have a table with a margin-bottom of 19px. Below that I have a form that contains some fieldsets. One of them is floated right. The problem is that the margin-bottom is not getting the full 19px in IE7. I've gone through all of the IE7 css/margin/float bugs that I can think of and ha...
<p>if you have floated and unfloated elements, the only surefire way to ensure vertical space between them cross-browser is padding-top on the subsequent element.</p>
<p>I wouldn't know for sure without testing but try placing this between the table and the fieldset:</p> <pre><code>&lt;br style="clear:both;" /&gt; </code></pre>
3,614
<p>Is there any performance to be gained these days from compiling java to native code, or do modern hotspot compilers end up doing this over time anyway?</p>
<p>There was a similar discussion here recently, for the question <a href="https://stackoverflow.com/questions/48144/what-are-advantages-of-bytecode-over-native-code">What are advantages of bytecode over native code?</a>. You can find interesting answers in that thread.</p>
<p>Tried Hello-World in with six different implementations just to check the overhead and the difference was staggering. Java was off the charts while the compiled languages did equally well. I could proved all the evidence (in a reproducible) if needed.</p>
7,430
<p>I have been trying to set up my Beta 1 MVC app on IIS 6 and cannot get it to run correctly. I have added a Wildcard mapping to the .net isapi DLL as suggested in other blog posts but get the following error when I access the root of the website:</p> <pre><code>The incoming request does not match any route. .. [Http...
<p>Here's what I did to get extensionless URLs working with IIS 6 and ASP.NET MVC Beta 1.</p> <ul> <li>Create a default ASP.NET MVC Beta project and compile it.</li> <li>Create a new IIS website pointing to the application directory.</li> <li>In the IIS properties for the website, click the HomeDirectory tab.</li> <li...
<p>Unfortunatly IIS 6 needs a file extension to map the request to the right handler which means you will have to use the .mvc suffix on your controller names, such as <em>/{controller}.mvc/{action}</em></p> <pre><code>routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); SimplyRestfulRouteHandler.BuildRoutes(routes); ...
34,779
<p>I'm learning Java and I'm wondering what everyone's Java rules are. The rules that you know intrinsically and if you see someone breaking them you try to correct them. Things to keep you out of trouble or help improve things. Things you should never do. Things you should always do. The rules that a beginner woul...
<p>Read <a href="http://java.sun.com/docs/books/effective/" rel="nofollow noreferrer">Effective Java</a> by Bloch.</p> <p>It's exactly what you're asking for, a set of rules for writing really great, idiomatic java code.</p>
<ol> <li><p>Use recursion as little as possible. There are uses for recursion, but most of the time a simple loop will do the same job without the overhead created with recursion. </p></li> <li><p>use Generics where possible. Many times a class can be used for an application that you never thought of when it was deve...
21,747
<p>I have always found this to be a very useful feature in Visual Studio. For those who don't know about it, it allows you to edit code while you are debugging a running process, re-compile the code <em>while the binary is still running</em> and continue using the application seamlessly with the new code, without the ...
<p>My understanding is that when the app is compiled with support for Edit and Continue enabled, the compiler leaves extra room around the functions in the binary image to allow for adding additional code. Then the debugger can compile a new version of the function, replace the existing version (using the padding space...
<p>My guess is all objects are aligned to a 4096 byte memory boundary. So if you make small changes to some code then the objects will still be within those boundaries and therefore run as before.</p> <p>I've had instances where changing a couple of lines will cause a full recompile and link and others where a fairly ...
27,740
<p>I've created a Silverlight project that produces [something].xap file to package a few silverlight UserControls. I would like to manipulate that .xap file through the use of javascript in the browser to show and hide user controls based upon java script events.</p> <p>Is it possible to do this?</p> <p>If so any s...
<p>Here's my solution...not sure if it's the "best-practices" way...comments????</p> <p>In the App class within my Silverlight application I have the following code:</p> <pre><code> private Page _page = null; private void Application_Startup(object sender, StartupEventArgs e) { _page = new Page(); ...
<p>Here is a my collections of my links for this subject.</p> <ul> <li><a href="http://weblogs.asp.net/albertpascual/archive/2008/08/13/javascript-communication-to-silverlight-2-0.aspx" rel="nofollow noreferrer">Javascript communication to Silverlight 2.0</a></li> <li><a href="http://www.wilcob.com/Wilco/Articles/silv...
32,317
<p>We recently had a problem where, after a series of commits had occurred, a backend process failed to run. Now, we were good little boys and girls and ran <code>rake test</code> after every check-in but, due to some oddities in Rails' library loading, it only occurred when we ran it directly from Mongrel in productio...
<p>This is really late, but here's how you can find where a method is defined:</p> <p><a href="http://gist.github.com/76951" rel="noreferrer">http://gist.github.com/76951</a></p> <pre><code># How to find out where a method comes from. # Learned this from Dave Thomas while teaching Advanced Ruby Studio # Makes the cas...
<p>You might be able to do something like this:</p> <p>foo_finder.rb:</p> <pre><code> class String def String.method_added(name) if (name==:foo) puts "defining #{name} in:\n\t" puts caller.join("\n\t") end end end </code></pre> <p>Then ensure foo_finder is loaded first with something...
21,162
<p>Can you have custom client-side javascript Validation for standard ASP.NET Web Form Validators?</p> <p>For instance use a asp:RequiredFieldValidator leave the server side code alone but implement your own client notification using jQuery to highlight the field or background color for example.</p>
<p>Yes I have done so. I used Firebug to find out the Dot.Net JS functions and then hijacked the validator functions</p> <p>The following will be applied to all validators and is purely client side. I use it to change the way the ASP.Net validation is displayed, not the way the validation is actually performed. It m...
<p>What you can do is hook into the validator and assign a new evaluate method, like this:</p> <pre><code> &lt;script type="text/javascript"&gt; rfv.evaluationfunction = validator; function validator(sender, e) { alert('rawr'); } &lt;/script&gt; </code></pre> <p>rfv is the ID...
15,166
<p>In college I've had numerous design and <a href="http://en.wikipedia.org/wiki/Unified_Modeling_Language" rel="noreferrer">UML</a> oriented courses, and I recognize that UML can be used to benefit a software project, especially <a href="http://en.wikipedia.org/wiki/Use_case" rel="noreferrer">use-case</a> mapping, but...
<p>In a sufficiently <strong>complex system</strong> there are some places where some <code>UML</code> is considered useful. </p> <p>The useful diagrams for a system, vary by applicability.<br> But the most widely used ones are: </p> <ul> <li>Class Diagrams</li> <li>State Diagrams</li> <li>Activity Diagrams</li> <li...
<p>UML is just one of methods for communication within people. Whiteboard is better.</p>
3,935
<p>I have a table named categories, which contains ID(long), Name(varchar(50)), parentID(long), and shownByDefault(boolean) columns. </p> <p>This table contains 554 records. All the shownByDefaultValues are 'false'.<br> When I execute 'select id, name from categories', pg returns me all the categories, orderer by its...
<p>That's not a problem. The order of rows returned by a SQL SELECT is undefined unless it has an <code>ORDER BY</code>. The order you get them is usually influenced by the order they are stored in the table and/or the indices that are used by the statement.</p> <p>So depending on that order without using <code>ORDER ...
<p>The rows are returned in whatever their physical order on disk is; you can reorder them physically using the <code>CLUSTER</code> SQL command, but due to the way Postgres works they'll become unordered as soon as you start modifying rows.</p> <p>For what you're doing an <code>ORDER BY</code> is the right answer.</p...
48,239
<p>I'm writing this question here hoping someone will be able to help me with the fixing process that I'm currently involved in!</p> <p>Last week during a printing session my Ultimaker original unexpectedly stop working. The problem was on the extruder step motor which push the filament from the back and literally is ...
<p>I'm not sure I know exactly what is wrong or what steps you've taken so far, but it seems like your extruder motor is broken and you've narrowed the problem down to electronics. <br> If so, replacing the Arduino, motor, and driver leaves only the Ultimaker PCB as the source of the problem. I would suggest ordering a...
<p>Your title says "x-axis" but your description leads me to think that your extruder is the part that's not working. Here are some tips which may (or may not) help...</p> <ul> <li>Make sure your extruder is not clogged.</li> <li>Make sure your temperature setting is high enough to allow the filament to melt quickly ...
379
<p>I am getting the following error when an event (Add/Edit/Delete) occurs on my databound control.</p> <blockquote> <p>Invalid postback or callback argument. Event validation is enabled using in configuration or &lt;%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature ver...
<p>The problem is loading the data for the control in the page Load event and calling the DataBind() method. However it appears that if the DataBind() method is called before the events are raised the above exception is generated as the control naming has changed.</p> <p>The solution is to change this to if(!IsPostba...
<p>I was experiencing the same issue and it took me few hours to solve my problem. Robert answer partially helped me and despite databinding my repeater regardless of post back or not, problem still persisted. After lot of research i came across a post which suggested setting <strong>UseSubmitBehavior="false"</strong>,...
37,486
<p>The company I work for is thinking of developing a LAMP SaaS Web application that would be plan based. We want to monitor usage because it involves external references, and would draw bandwidth through the placement of an iframe or JavaScript snippet on a third-party site. My first thought was relying only on a page...
<p>I think a web service gateway would be a good option. Most of them (IBM, Layer 7, Vordel) offer throttling and contract management features. They'll allow you to set thresholds on access to whatever is behind them. </p> <p>If you're using authorization and authentication for users and service, you can easily config...
<p>Maybe you should use cloud computing services, who will monitor the bandwidth usage for each client. It will allow you to set the cap for each client as well.</p> <p>I read <a href="http://www.mosso.com" rel="nofollow noreferrer">Mosso.com</a> can do this.</p> <p>regards</p>
34,467
<p>I have an application which <em>really</em> should be installed, but does work fine when deployed using JNLP.</p> <p>However, it would seem that some Java functions such as <code>Runtime.exec</code> don't work using the default security options.</p> <p>I would like to therefore <a href="http://www.joelonsoftware.c...
<p>You want to ask to the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/SecurityManager.html" rel="nofollow noreferrer">SecurityManager</a> if you have Exec right with the checkExec method.</p>
<p>For the specific example of Runtime.exec there is a method on the SecurityManager class checkExec(String cmd) that will throw an exception that can be caught to determine if the necessary command can be executed. For more information see the javadoc for Runtime.exec and SecurityManager.checkExec.</p> <p>The more g...
5,393
<p>when putting a ScrollViewer inside a window(not keeping all the window's size) inside the ScrollViewer there's (with other stuff) a WinFormsHost and a control inside (let's say a DateTimePicker). when scrolling, the inner winforms control keeps being visible when there's no longer a reason (it's outside of the scrol...
<p>According to <a href="http://msdn.microsoft.com/en-us/library/ms752027.aspx" rel="noreferrer">this msdn link</a> </p> <blockquote> <p>WindowsFormsHost elements are always drawn on top of other WPF elements, and they are unaffected by z-order</p> </blockquote> <p>I don't think there's an easy solution. You ...
<p>Just add in ScrollViewer control property:</p> <pre><code>VerticalScrollBarVisibility="Auto" </code></pre> <p>and set Height to Your max height. That's all.</p>
14,869
<p>Let's say I have an existing trivial XML file named 'MyData.xml' that contains the following:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;myElement&gt;foo&lt;/myElement&gt; </code></pre> <p>I want to change the text value of 'foo' to 'bar' resulting in the following:</p> <pre><code>&lt;?xml v...
<p>Use Python's <a href="http://docs.python.org/library/xml.dom.minidom.html" rel="nofollow noreferrer">minidom</a></p> <p>Basically you will take the following steps:</p> <ol> <li>Read XML data into DOM object</li> <li>Use DOM methods to modify the document</li> <li>Save new DOM object to new XML document</li> </ol>...
<p>You also might want to check out Uche Ogbuji's excellent XML Data Binding Library, Amara: <a href="http://uche.ogbuji.net/tech/4suite/amara" rel="nofollow noreferrer">http://uche.ogbuji.net/tech/4suite/amara</a></p> <p>(Documentation here: <a href="http://platea.pntic.mec.es/~jmorilla/amara/manual/" rel="nofollow n...
21,616
<p>I've an issue with the same piece of code running fine on my live website but not on my local development server.</p> <p>I've an Ajax function that updates a div. The following code works on the live site:</p> <pre>self.xmlHttpReq.open("POST", PageURL, true); self.xmlHttpReq.setRequestHeader("Content-type", "appli...
<p>Is there a reason you're explicitly setting the <code>Content-Length</code> header in the first example? You... <em>shouldn't</em> need to do this, and i wouldn't be surprised to find it causing problems. </p> <p>Oh, and check your encoding routine. The rules are not <em>quite</em> the same for querystrings and POS...
<p>I would guess that Shog9 is right, and that IIS 6 i smart enough to ignore your request and send the correct headers, while 5.2 throws an error.</p>
13,131
<p>We're doing a lot of large, but straightforward forms for a fairly big project (about 600 users using it throughout the day - that's big for me at least ;-) ).</p> <p>The forms have a lot of question/answer type sections, so it's natural for some people to type a sentence, while others type a novel. <strong>How be...
<p>If you have no limitations on the data size, then why worry. This doesn't sound like a mission critical project, even with 600 users and several thousand records. Use CLOB/BLOB and be done with it. I have doubts as to whether you would see any major gains in limiting sizes and risking data loss. That said, you shoul...
<p>from: <a href="http://www.making-the-web.com/2008/03/24/saving-bytes-efficient-data-storage-mysql-part-1/" rel="nofollow noreferrer">http://www.making-the-web.com/2008/03/24/saving-bytes-efficient-data-storage-mysql-part-1/</a></p> <p>There are a few variations of the TEXT and BLOB types which affect size; they are...
30,134
<p>I wonder if there is an example which html files and java files are resides in different folders. </p>
<p>I don't recommend using a separate page directory unless you are quite comfortable with how resource streams work, which I am not.</p> <p>The vast majority of wicket projects I have seen keep class and html files in the source directory. I tried separating them myself but then found that getting my hands on other ...
<p>This is one area where using Maven to manage your project is very nice. Since Maven has two locations that are included on the classpath, you can logically separate the Java source and the HTML files and still have them maintain the same package structure. The Java code goes into src/main/java and the HTML goes into...
34,490
<p>Let's say we have <code>index.php</code> and it is stored in <code>/home/user/public/www</code> and <code>index.php</code> calls the class <code>Foo-&gt;bar()</code> from the file <code>inc/app/Foo.class.php</code>. </p> <p>I'd like the bar function in the <code>Foo</code> class to get a hold of the path <code>/hom...
<p>Wouldn't this get you the directory of the running script more easily?</p> <pre><code>$dir=dirname($_SERVER["SCRIPT_FILENAME"]) </code></pre>
<p>Found it. getcwd().</p>
16,906
<p>When building a VS 2008 solution with 19 projects I sometimes get:</p> <pre><code>The "GenerateResource" task failed unexpectedly. System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.IO.MemoryStream.set_Capacity(Int32 value) at System.IO.MemoryStream.EnsureCapaci...
<p>From <a href="https://social.msdn.microsoft.com/Forums/vstudio/en-US/5154ef26-ccfe-44d5-a322-6804b61ac774/systemoutofmemoryexception?forum=clr" rel="nofollow noreferrer">https://social.msdn.microsoft.com/Forums/vstudio/en-US/5154ef26-ccfe-44d5-a322-6804b61ac774/systemoutofmemoryexception?forum=clr</a>:</p> <p>Try d...
<p>I have already passed by this erros sometimes. All you must do is delete all files in the obj path. After that clean and rebuild your solution and it´s done.</p>
3,580
<p>I'm using grails j2d which in turns uses <code>GraphicsBuilder</code> to make a simple service to scale an image. My problem is specifically accessing the downloaded image height and width attributes in order to pass the correct parameters to the scale method. How do I access these attributes inside the transformati...
<p>I don't know the J2D plugin at all, but you might check into what the delegate is for the closure you're passing to the image call. Add a line like "def d = delegate" before the transformations call, and debug this to see what type the delegate is. If it's an Image, then you ought to be able to get delegate.width ...
<p>The neswest j2d plugin exposes those values so you can pass as parameters normally.</p>
40,320
<p>we're have a client that needs to get interactive messages from a server, from clients that are distributed around the world behind all kinds of firewalls with all kinds of ports closed. The only thing we can rely on is HTTP port 80 (and HTTPS 443).</p> <p>The design is basically modeled after XMPP (the Jabber prot...
<p>I think you're hitting ASP.NET thread pool limits, rather than IIS ones. Look into creating a asynchronous HTTP handler (<code>IHttpAsyncHandler</code>) as when they block/wait they aren't tying up the thread pool (they use completion ports instead).</p> <p><strong>Update</strong>: Came across this recently that se...
<p>XMPP was never designed for high performance applications. The messages must traverse through the entire stack to the application layer, and there is a lot of XML parsing. Have you considered using some other standard besides XMPP?</p>
15,012
<p>Imagine an object you are working with has a collection of other objects associated with it, for example, the Controls collection on a WinForm. You want to check for a certain object in the collection, but the collection doesn't have a <code>Contains()</code> method. There are several ways of dealing with this.</p...
<p>I would have to say that this is pretty bad practice. Whilst some people might be happy to say that looping through the collection is less efficient to throwing an exception, there is an overhead to throwing an exception. I would also question why you are using a collection to access an item by key when you would be...
<p>The latter is an acceptable solution. Although I would definitely catch on the specific exception (ElementNotFound?) that the collection throws in that case.</p> <p>Speedwise, it depends on the common case. If you're more likely to find the element than not, the exception solution will be faster. If you're more lik...
2,977
<p>What is the best way to store a user name and password for a Windows Service?</p> <p>The service has to be able to access an MS SQL Server database on a remote machine. We have to support MS SQL Server authentication (mixed mode) instead of NT Authentication. </p>
<p>The <a href="http://en.wikipedia.org/wiki/Data_protection_API" rel="nofollow noreferrer">DP API</a> is the standard way of locally storing sensitive data on Windows. You didn't mention the programming language you're using, but in .NET this is exposed from the <a href="http://msdn.microsoft.com/en-us/library/system...
<p>While I agree that, ideally, you would not need to store this password, if you do, there is no need to hash it yourself. <a href="http://msdn.microsoft.com/en-us/library/aa380261(VS.85).aspx" rel="nofollow noreferrer">CryptProtectData</a>. Read the warnings at the bottom of this article. Though, I actually used <a h...
33,036
<p>I have a very eccentric, weird, unusual and strange idea. I need some advice and serious professional help.</p> <p>I'm interested in 3D printing in PLA a hollow complex structure with 0.2 thickness walls (Yes! That thin!). Fill it with very fine copper powder with a little borax powder thoroughly mixed. Use superglu...
<p><strong>I think this is just an overcomplicated lost-PLA (investment) casting.</strong></p> <p>What you're asking for is to create an object, create a mold around it, and then burn out the object and replace it with metal. Traditionally this is done with wax, <a href="https://en.wikipedia.org/wiki/Lost-wax_casting"...
<p>I don't see why it wouldn't work. It doesn't seem to be the optimal way but I haven't tried it.</p> <p>Only thing that might be an issue is that PLA doesn't burn away clean (not for me anyway) which can leave defects in the product. But there are filaments specifically made for casting which apparently burn away wit...
2,134
<p>I am trying to <strong>replace the current selection in Word (2003/2007)</strong> by some <strong>RTF string</strong> stored in a variable.</p> <p>Here is the current code:</p> <pre><code>Clipboard.SetText(strRTFString, TextDataFormat.Rtf) oWord.ActiveDocument.ActiveWindow.Selection.PasteAndFormat(0) </code></pre>...
<p>Put the RTF in a file instead of the clipboard, then insert from the file, e.g.</p> <blockquote> <p><code>Selection.InsertFile FileName:="myfile.rtf", Range :="", _ ConfirmConversions:=False, Link:=False, Attachment:=False</code></p> </blockquote>
<p>You can use a RichTextbox to convert RTF to text or vice versa.</p> <pre><code>RichTextBox r = new RichTextBox(); r.Rtf = strRTFString; Console.WriteLine(r.Text); </code></pre>
4,233
<p>I'm working on an application that is supposed to create products (like shipping insurance policies) when PayPal Instant Payment Notifications are received. Unfortunately, PayPal sometimes sends duplicate notifications. Furthermore, there is another third-party that is performing web-service updates simultaneously...
<p>It would be safer and cleaner if <code>insert into Policy</code> just hit some uniqueness table constraint on attempt to insert duplicate. Raising isolation level can lower concurrency and lead to other nasty issues like deadlocks.</p> <p>Another way is to always insert Policy row, then roll it back if Package has ...
<p>I agree with the "message queue" idea in aaronjensen's response. If you are concerned about multiple concurrent threads attempting to update the same row of data simultaneously, you should instead have the threads insert their data into a work queue, which is then processed sequentially by a single thread. This si...
15,125
<p>I work on a small web team where I am the only .NET developer currently using Visual Studio 2008 Professional to build and maintain a few web applications. I am about to start training another member of our team so we purchased him a copy of Visual Studio 2008 Professional. I've looked into Visual Source Safe, but ...
<p><a href="http://subversion.tigris.org/" rel="noreferrer">Subversion</a> has good integration with Visual Studio 2008 through <a href="http://www.visualsvn.com/" rel="noreferrer">VisualSVN</a> and <a href="http://ankhsvn.open.collab.net/" rel="noreferrer">Ankh</a>. </p> <p>SourceSafe is dangerous. You're right that ...
<p>Microsoft's Team Foundation Server integrates fully into VS2008 and uses SQL Server for its back end. The downside is that it's a very expensive solution.</p>
17,101
<p>I am looking for a way to clean up the mess when my top-level script exits.</p> <p>Especially if I want to use <code>set -e</code>, I wish the background process would die when the script exits.</p>
<p>To clean up some mess, <code>trap</code> can be used. It can provide a list of stuff executed when a specific signal arrives:</p> <pre><code>trap "echo hello" SIGINT </code></pre> <p>but can also be used to execute something if the shell exits:</p> <pre><code>trap "killall background" EXIT </code></pre> <p>It's ...
<p>So script the loading of the script. Run a <code>killall</code> (or whatever is available on your OS) command that executes as soon as the script is finished.</p>
47,007
<p>I'm using C and sometimes I have to handle paths like</p> <ul> <li>C:\Whatever</li> <li>C:\Whatever\</li> <li>C:\Whatever\Somefile</li> </ul> <p>Is there a way to check if a given path is a directory or a given path is a file?</p>
<p>stat() will tell you this.</p> <pre><code>struct stat s; if( stat(path,&amp;s) == 0 ) { if( s.st_mode &amp; S_IFDIR ) { //it's a directory } else if( s.st_mode &amp; S_IFREG ) { //it's a file } else { //something else } } else { //error } </code></pre>...
<p>Easier to try FileInfo.isDir() in qt</p>
17,689
<p>What is the best way to create a custom title for pages in a Rails app without using a plug-in?</p>
<p>In your views do something like this:</p> <pre><code>&lt;% content_for :title, "Title for specific page" %&gt; &lt;!-- or --&gt; &lt;h1&gt;&lt;%= content_for(:title, "Title for specific page") %&gt;&lt;/h1&gt; </code></pre> <p>The following goes in the layout file:</p> <pre><code>&lt;head&gt; &lt;title&gt;&lt;%...
<p>I would like to add my pretty simple variant.</p> <p>In the ApplicationController define this method:</p> <pre><code> def get_title @action_title_name || case controller_name when 'djs' 'Djs' when 'photos' ...
22,496
<p>I'm trying to insert a column into an existing DataSet using C#.</p> <p>As an example I have a DataSet defined as follows:</p> <pre><code>DataSet ds = new DataSet(); ds.Tables.Add(new DataTable()); ds.Tables[0].Columns.Add("column_1", typeof(string)); ds.Tables[0].Columns.Add("column_2", typeof(int)); ds.Tables[0]...
<p>You can use the <a href="http://msdn.microsoft.com/en-us/library/system.data.datacolumn.setordinal.aspx" rel="noreferrer">DataColumn.SetOrdinal()</a> method for this purpose.</p> <pre><code>DataSet ds = new DataSet(); ds.Tables.Add(new DataTable()); ds.Tables[0].Columns.Add("column_1", typeof(string)); ds.Tables[0]...
<p>Copy the first two columns into a new dataset, then add the third column, and add the remaining columns.</p> <p>You could wrap that in an InsertAfter function if necessary.</p>
45,776
<p>In a typical handheld/portable embedded system device Battery life is a major concern in design of H/W, S/W and the features the device can support. From the Software programming perspective, one is aware of MIPS, Memory(Data and Program) optimized code. I am aware of the H/W Deep sleep mode, Standby mode that are u...
<ul> <li>Like <code>1800 INFORMATION</code> said, avoid polling; subscribe to events and wait for them to happen</li> <li>Update window content only when necessary - let the system decide when to redraw it</li> <li>When updating window content, ensure your code recreates as little of the invalid region as possible</li>...
<p>also something that is not trivial to do is reduce precision of the mathematical operations, go for the smallest dataset available and if available by your development environment pack data and aggregate operations. </p> <p>knuth books could give you all the variant of specific algorithms you need to save memory or...
8,719
<p>Is it possible to embed a PowerPoint presentation (.ppt) into a webpage (.xhtml)?</p> <p>This will be used on a local intranet where there is a mix of Internet&nbsp;Explorer&nbsp;6 and Internet&nbsp;Explorer&nbsp;7 only, so no need to consider other browsers.</p> <hr> <p>I've given up... I guess Flash is the way ...
<p>Google Docs can serve up PowerPoint (and PDF) documents in it's document viewer. You don't have to sign up for Google Docs, just upload it to your website, and call it from your page:</p> <pre><code>&lt;iframe src="//docs.google.com/gview?url=https://www.yourwebsite.com/powerpoint.ppt&amp;embedded=true" style="wid...
<p>The first few results on Google all sound like good options:</p> <p><a href="http://www.pptfaq.com/FAQ00708.htm" rel="nofollow noreferrer">http://www.pptfaq.com/FAQ00708.htm</a></p> <p><a href="http://www.webdeveloper.com/forum/showthread.php?t=86212" rel="nofollow noreferrer">http://www.webdeveloper.com/forum/sho...
6,100
<p>It seems like drag and drop upload widgets disappeared from the face of Web 2.0. The last one of these I remember using was an activex widget, and inability of using it in anything other than IE doomed it. Have you used or seen one of these recently?</p>
<p>The <a href="http://dojotoolkit.org/" rel="nofollow noreferrer">Dojo Toolkit</a> JavaScript library supports some drag &amp; drop functionality that I've seen work in IE6+ and FF2+. The nice thing about Dojo and other JS libraries is that they abstract away all of the browser detection stuff.</p> <p>I'm sure other ...
<p><a href="http://widgets.yahoo.com/widgets/ftp-drop" rel="nofollow noreferrer">FTP Drop</a> for Yahoo Widgets allows you to drag files over the widget and the file will be sent to the defined ftp server.</p>
2,772
<p>I have a managed DLL (written in C++/CLI) that contains a class used by a C# executable. In the constructor of the class, I need to get access to the full path of the executable referencing the DLL. In the actual app I know I can use the Application object to do this, but how can I do it from a managed DLL?</p>
<pre><code>Assembly.GetCallingAssembly() </code></pre> <p>or</p> <pre><code>Assembly.GetExecutingAssembly() </code></pre> <p>or</p> <pre><code>Assembly.GetEntryAssembly() </code></pre> <p>Depending on your need.</p> <p>Then use Location or CodeBase property (I never remember which one).</p>
<p>@leppie: Thanks - that was the pointer I needed. </p> <p>For future reference, in C++/CLI this is the actual syntax that works:</p> <pre><code>String^ appPathString = Assembly::GetEntryAssembly()-&gt;Location; </code></pre> <p><code>GetExecutingAssembly()</code> provided the name of the DLL</p> <p><code>GetCalli...
14,730
<p>Anyone got an idea how to get from an Xserver the list of all open windows?</p>
<p>From the CLI you can use</p> <pre><code>xwininfo -tree -root </code></pre> <p>If you need to do this within your own code then you need to use the <code>XQueryTree</code> function from the <code>Xlib</code> library.</p>
<p>If your window manager implements EWMH specification, you can also take a look at the <code>_NET_CLIENT_LIST</code> value of the root window. This is set by most modern window managers:</p> <pre><code>xprop -root|grep ^_NET_CLIENT_LIST </code></pre> <p>That value can easily be obtained programmatically, see your X...
31,513
<p>I have a solution in Visual Studio 2008 which has multiple projects. One of the projects is a WCF project. Sometimes I just want to debug other projects, but when I press F5, Visual Studio has wcfsvchost.exe launched to host the WCF project even it is not "StartUp Project". </p> <p>Currently, every time I debugging...
<p>Go to WCF Options section in the property page of your WCF project and unselect the check box that says 'Start WCF Service Host when debugging another project in the same solution'.</p>
<p>Not sure if this would fix your issue or not, but if you click on the WCF project in solution explorer, see if it has a "Always Start When Debugging" property. If it does, set it to false. That property only shows up for some project types though, so it depends on exactly what type of project template you used.</p>
35,879
<p>I have implemented tracing based on System.Diagnostics. </p> <p>I am also using a System.Diagnostics.TextWriterTraceListener, and hooked the whole trace up to a MOSS 2007 Web Application. </p> <p>The trace for some reason is trying to (a) create the log file, and/or (b) write to the log file using <strong>the user...
<p>Obviously MOSS is configured to use windows authentication (kerberos) and imersonation. If you don't need to impersonate the current user logged into moss, turn off impersonation (its in web.config). You'll find that the log files will be created and written by the user under which your moss installation's applica...
<p>Please don't tell me this is necessary - <a href="http://www.15seconds.com/Issue/040511.htm?voteresult=5" rel="nofollow noreferrer">http://www.15seconds.com/Issue/040511.htm?voteresult=5</a></p>
45,429
<p>Let's say I'm working on a little batch-processing console app in VB.Net. I want to be able to structure the app like this:</p> <pre class="lang-vb prettyprint-override"><code>Sub WorkerMethod() 'Do some work Trace.WriteLine("Work progress") 'Do more work Trace.WriteLine("Another progress update") ...
<p>You can add the following to your exe's .config file.</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;configuration&gt; &lt;system.diagnostics&gt; &lt;trace autoflush="true"&gt; &lt;listeners&gt; &lt;add name="logListener" type="System.Diagnostics.TextWriterTraceListener" init...
<p>Great solution, but I have a situation where I have different dll's being run by the same calling exe, so I don't want to modify the calling exe's .config file. I want each dll to handle it's own alteration of the trace output.</p> <p>Easy enough:</p> <pre><code>Stream outResultsFile = File.Create ("output.txt"); ...
24,156
<p>Silverlight v2.0 is getting closer and closer to RTM but I have yet to hear any stats as to how many browsers are running Silverlight. If I ask Adobe (by googling "Flash install base") they're <a href="http://www.adobe.com/products/player_census/flashplayer/version_penetration.html" rel="nofollow noreferrer">only to...
<p>Quick Answer: <a href="http://www.riastats.com" rel="nofollow noreferrer">www.riastats.com</a></p> <p>This site compares the different RIA plugins using graphical charts and graphs.</p> <p>It gets its data from small snippets of javascripts running on sites accross the web (approx 400,000 last time I looked)</p> ...
<p>The larger question is how many users will your site lose if implemented in Silverlight. And, it very much depends on your audience.</p> <p>If you're running a site about the joys of Linux kernel hacking or the virtues of Internet security, you'll probably lose a significant chunk of your audience. If you're runnin...
8,494
<p>I have a datagrid getting bound to a dataset, and I want to display the average result in the footer for a column populated with integers.</p> <p>The way I figure, there's 2 ways I can think of:</p> <p>1."Use the <strong>Source</strong>, Luke"<br> In the code where I'm calling DataGrid.DataBind(), use the DataTabl...
<p>See this KB Article. <a href="http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277" rel="noreferrer">How to configure SQL Server 2005 to allow remote connections</a>.<br> Oh, and remember that the SQLServer name will probably be MyMachineName\SQLExpress</p>
<p>If you're running it on a 2k3 box, you need to install all updates for Sql Server and the 2003 server. </p> <p>Check the event logs after you start the Sql Server. It logs everything well, telling you if its being blocked, and where it is listening for connections.</p> <p>From a remote machine, you can use telne...
3,082
<p>I have tried both of :</p> <pre><code>ini_set('include_path', '.:/usr/share/php5:/usr/share/php5/PEAR:lib:app/classes'); </code></pre> <p>and also :</p> <pre><code>php_value include_path ".:/usr/share/php5:/usr/share/php5/PEAR:lib:app/classes" </code></pre> <p>in the .htaccess file.</p> <p>Both methods actually...
<p>It turned out the issue was related to a PHP bug in 5.2.5</p> <p>Setting an "admin_flag" for include_path caused the include path to be empty in some requests, and Plesk sets an admin_flag in the default config for something or other. An update of PHP solved the issue.</p> <p><a href="http://bugs.php.net/bug.php?i...
<p>Looks like you duplicated the current directory in your include path. Try removing one of the '.:' from your string.</p>
6,321
<p>Is there a way to mount a folder on the hard disk as a device in Finder. The intend here is to provide the user with an easy way to get to a folder that my application uses to store data. I don't want my user to go searching for data in Application Data. I would rather allow them to make this data available as a mou...
<p>Try looking into FUSE. You can have all sorts of psuedo filesystems with that.</p> <p>But I'd caution a little against what you are trying to do. It may make more sense to just have a button that opens the folder in your application, rather than create a new device. I personally would find it hard to continue to...
<p>I would also urge caution with this, seems potentially somewhat confusing to most users. That said, have you considered simply creating a softlink to the directory in question?</p>
41,859
<p>I've found Ruby to be very attractive; I like the fact that everything is an object and its syntax is very appealing. </p> <p>I was hoping that it would gain a lot of popularity this year, but I don't see lot of activity in Ruby. </p> <p>For instance if we take the number of tags added in SO there are only about 7...
<p>You're mistakenly attributing something to Ruby. <a href="http://rubyforge.org/" rel="nofollow noreferrer">RubyForge</a> alone reports over 1,000 open-source projects, let alone all Ruby on Rails apps that exist, and the projects hosted on Github, Sourceforge, and elsewhere.</p> <p>Unless you spend a lot of time on...
<p>More than likely because it is younger than a lot of other languages and, on the web side of things, isn't as easy to implement as PHP and Python. Ruby has also gained notoriety as a web scripting language due to Rails which may be turning off some developers who are looking for client-based languages to work with.<...
29,969
<p>We are repurposing an application server running WebSphere 6.0.2.23. I would like to rename the various application server to better reflect its new role. </p> <p>How can you rename an application server? </p> <p>It seems like wsadmin can do it, but I'm struggling with the object hierarchy.</p>
<p><a href="http://www.ibm.com/developerworks/websphere/library/samples/SampleScripts.html" rel="nofollow noreferrer">IBM Sample Scripts</a></p> <p>download: </p> <blockquote> <p>ConfigScripts.zip</p> </blockquote> <p>from command line execute: </p> <pre><code>/usr/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/ws...
<p>An easier option if you are running a clustered set up is to create a new cluster member with the required name. </p> <p>Delete the old server and keep note of all the ports for the original server and state them as the port numbers for this new server(if you need the same port numbers)</p> <p>If you are using a n...
35,280
<p>Very simply, what is tail-call optimization?</p> <p>More specifically, what are some small code snippets where it could be applied, and where not, with an explanation of why?</p>
<p>Tail-call optimization is where you are able to avoid allocating a new stack frame for a function because the calling function will simply return the value that it gets from the called function. The most common use is tail-recursion, where a recursive function written to take advantage of tail-call optimization can ...
<p>In a functional language, tail call optimization is as if a function call could return a partially evaluated expression as the result, which would then be evaluated by the caller.</p> <pre><code>f x = g x </code></pre> <p>f 6 reduces to g 6. So if the implementation could return g 6 as the result, and then call th...
40,073
<p>I have a button control style and I want to change the padding from whatever the data-bound version is to adjust for a glyph that needs a 2 pixel offset. I'll use SimpleButton from SimpleStyles.xaml as an example (... shows where the trigger code was removed for conciseness):</p> <pre><code>&lt;Style x:Key="Simple...
<p>Currently XAML does not parse expressions in Binding syntax, etc. However, you can use an <a href="http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter.aspx" rel="noreferrer">IValueConverter</a> or <a href="http://msdn.microsoft.com/en-us/library/system.windows.data.imultivalueconverter.aspx" ...
<p><strong>You can do some simple math by taking advantage of transforms.</strong></p> <p>Check out this trick that Charles Petzold came up with a long time ago: <a href="http://www.charlespetzold.com/blog/2006/04/060223.html" rel="nofollow">http://www.charlespetzold.com/blog/2006/04/060223.html</a></p> <p>Unfortunat...
42,493
<p>I've been hearing/reading a lot about the new language enhancements for C# 4. I'm a little curious if these same enhancements are also going to be applied to VB as well, or what. Does anyone know where I can get some insight here? With all the new changes happening to C#, it seems like there will very little reas...
<p>I'd actually overlook the dismissal of VB.Net by Lou Franco. Checkout Panopticon Central: </p> <ul> <li><a href="http://www.panopticoncentral.net/archive/2008/10/31/24803.aspx" rel="nofollow noreferrer">http://www.panopticoncentral.net/archive/2008/10/31/24803.aspx</a> </li> <li><a href="http://www.panopticoncen...
<p>Some of the changes to C# (e.g Named Optional Parameters) were already in VB. The main strength of VB.NET over C# was Office/COM integration, and the new C# is addressing that.</p> <p>If you need to target an older .NET version, VB.NET will still be the one to use if you need these features.</p>
32,386
<p>I know there are many ways to prevent image caching (such as via META tags), as well as a few nice tricks to ensure that the current version of an image is shown with every page load (such as image.jpg?x=timestamp), but is there any way to actually clear or replace an image in the browsers cache so that neither of t...
<p>If you're writing the page dynamically, you can add the last-modified timestamp to the URL:</p> <p><code>&lt;img src="image.jpg?lastmod=12345678" ...</code></p>
<p>I have tried something ridiculously simple:</p> <p>Go to FTP folder of the website and rename the IMG folder to IMG2. Refresh your website and you will see the images will be missing. Then rename the folder IMG2 back to IMG and it's done, at least it worked for me in Safari.</p>
41,664
<p>So while doing some research I stumbled upon a <a href="https://reprap.org/wiki/Glass_Nozzles#Step_1_Assemble_Parts_and_Tools" rel="nofollow noreferrer">wiki page on reprap</a> from a few years back where the user was creating a glass nozzle to replace the brass and PTFE assembly.<a href="https://reprap.org/wiki/Gla...
<p>First off, this is not a glass nozzle, it is a whole hotend design. A super simplistic one.</p> <p>Glass is, like ceramics, not a good thermal conductor but has a quite good thermal resistance - it only melts at about 1600 °C, which means you will never have to fight melting or warping of the filament path itself a...
<p>One shortcoming would be that when it comes back to lay down a new line next to an existing line, I would think that it would need to be able to melt the previously printed plastic, especially any bumps and strings.<br> High thermal conductivity for good heat flow seems important.</p>
1,503
<p>I want subversion to commit a file even if it's unchanged. Is there a way to do this?</p>
<p>If you want the file contents to remain unchanged (meaning that you can't merely change whitespace as johnstok suggested) you can always change one of the properties on the file.</p> <p>eg.</p> <pre> svn propset dummyproperty 1 yourfile svn commit yourfile </pre> <p>That will perform a commit without having to ch...
<p>I thought you could do it from the command line?</p> <pre><code>svn ci -force &lt;filename&gt; </code></pre> <p>I don't have a repository here to check that on, so I might be wrong.</p>
25,261
<p>Does C++ support '<a href="http://java.sun.com/docs/books/tutorial/essential/exceptions/finally.html" rel="noreferrer"><strong>finally</strong></a>' blocks?</p> <p>What is the <a href="http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization" rel="noreferrer"><strong>RAII idiom</strong></a>?</p> <p>What...
<p>No, C++ does not support 'finally' blocks. The reason is that C++ instead supports RAII: "Resource Acquisition Is Initialization" -- a <em>poor name</em><sup><strong>†</strong></sup> for a really useful concept. </p> <p>The idea is that an object's destructor is responsible for freeing resources. When the object...
<pre><code>try { ... goto finally; } catch(...) { ... goto finally; } finally: { ... } </code></pre>
19,481
<p>I get this error when I do an <code>svn update</code>:</p> <blockquote> <p>Working copy XXXXXXXX locked Please execute "Cleanup" command</p> </blockquote> <p>When I run cleanup, I get</p> <blockquote> <p>Cleanup failed to process the following paths: XXXXXXXX</p> </blockquote> <p>How do I get out of this...
<p>One approach would be to:</p> <ol> <li>Copy edited items to another location.</li> <li>Delete the folder containing the problem path.</li> <li>Update the containing folder through Subversion.</li> <li>Copy your files back or merge changes as needed.</li> <li>Commit</li> </ol> <p>Another option would be to delete t...
<p>Spotlight is its usual rubbish self at finding the lock files recursively. </p> <p>EasyFind on Mac App Store works</p> <pre><code>http://itunes.apple.com/gb/app/easyfind/id411673888?mt=12 </code></pre> <p>search for 'lock'</p> <p>Select all / Delete</p>
15,573
<p>I have a web-server, that serves different domain-names, but has only one IP-address assigned. That works fine with virtual hosts in Apache. Now I want SSL-encrypted connections for the websites. How can I set different SSL-certificates for the different vhosts?</p> <p>Using different IP's for the different hostnam...
<p><strong>UPDATE: 2013</strong></p> <p>It appears that SNI is finally beginning take hold as older browsers are falling away. Here are the <a href="http://wiki.apache.org/httpd/NameBasedSSLVHostsWithSNI" rel="nofollow noreferrer">docs for Apache SNI</a> and here is a <a href="http://en.wikipedia.org/wiki/Server_Nam...
<p>You will need a separate IP:port combination for each vhost.</p> <p>RFC 3546 is not feasible yet. IE only supports it when running under Vista, and last I checked Safari doesn't manage it either.</p>
34,816
<p>My company, a C++ house, is always looking to hire recent grads. However due to the Java Schools phenomenon, we typically end up interviewing strong Java programmers with maybe a minute smattering of C++. Often the C++ classes don't really prepare students for working in C++. Nevertheless, often these are bright kid...
<p>Well, if they don't understand data structures and algorithmic complexity, they aren't going to be much good at serious Java programming, so I don't see that the language is an issue here.</p> <p>They won't understand pointers, but good C++ programming typically doesn't use pointers in complicated ways. (There are...
<p>It's just another language. </p> <p>And if you stick with the relatively small subset of pure OOP features, there is really not that much to learn from a Java developers perspective. The only thing you should have to teach them in order for them to be generic OOP programmers is the fact that they have to implement ...
31,247
<p>My C code snippet takes the address of an argument and stores it in a volatile memory location (preprocessed code):</p> <pre><code>void foo(unsigned int x) { *(volatile unsigned int*)(0x4000000 + 0xd4) = (unsigned int)(&amp;x); } int main() { foo(1); while(1); } </code></pre> <p>I used an SVN version ...
<p>Once you return from <code>foo()</code>, <code>x</code> is gone, and any pointers to it are invalid. Subsequently using such a pointer results in what the C standard likes to call "undefined behavior," which means the compiler is absolutely allowed to assume you won't dereference it, or (if you insist on doing it a...
<blockquote> <p>Is this just expected/undefined behaviour? Have I done something wrong or have I in fact found a Compiler Bug™?</p> </blockquote> <p>No bug just the defined behaviour that optimisation options can produce odd code which might not work :)</p> <p>EDIT:</p> <p>If you think you have found a bug i...
4,816
<p>What tweaks / addins / themes do you have rigged up to make your IDE awesome? For example, in Visual Studio I <a href="http://www.hanselman.com/blog/VisualStudioProgrammerThemesGallery.aspx" rel="nofollow noreferrer">color themes</a>, <a href="http://www.devexpress.com/Products/Visual_Studio_Add-in/Coding_Assistanc...
<p><a href="http://www.jetbrains.com/resharper/" rel="noreferrer">ReSharper</a> 4.1 for Visual Studio 2008. It's a beautiful thing. It looks for all kinds of code errors, optimizations, etc. My code is cleaner thanks to this handy Visual Studio plugin.</p>
<p>I am using Vim <a href="http://cscope.sourceforge.net/" rel="nofollow noreferrer">Cscope</a> plugin.</p> <p>Cscope is like 'ctags' on steroids and makes traversing code much easier. I usually use it along with tags to find where a function is declared and then go directly to whatever code is calling this function.<...
29,007
<p>I have a C extension module and it would be nice to distribute built binaries. Setuptools makes it easy to build extensions modules on OS X and GNU/Linux, since those OSs come with GCC, but I don't know how to do it in Windows.</p> <p>Would I need to buy a copy of Visual Studio, or does Visual Studio Express work? ...
<p>You can use both MinGW and VC++ Express (free, no need to buy it).</p> <p>See:</p> <ol start="2"> <li><a href="http://eli.thegreenplace.net/2008/06/28/compiling-python-extensions-with-distutils-and-mingw/" rel="noreferrer">http://eli.thegreenplace.net/2008/06/28/compiling-python-extensions-with-distutils-and-mingw...
<p>Setuptools and distutils don't come with gcc, but they use the same compiler Python was built with. The difference is mostly that on the typical UNIX system that compiler is 'gcc' and you have it installed.</p> <p>In order to compile extension modules on Windows, you need a compiler for Windows. MSVS will do, even ...
12,641
<p>I am looking for an inverse version of "RunOnceEx".</p> <p>RunOnceEx does run some program, before the user's shell(desktop&amp;taskbar) start. The login progress will not continue before the runonceex complete.</p> <p>I want to do exact the same but on user logout. When she/he logout, all running program shutdown...
<p>Warning, as said <a href="http://www.eggheadcafe.com/software/aspnet/30020406/trouble-getting-logoff-sc.aspx" rel="nofollow noreferrer"><strong>here</strong></a>, <code>gpedit.msc</code> will allow you to configure a logoff script <strong>for <em>all</em> users</strong>.</p> <p>If you need that script only for one ...
<p>If you need something simple and working for a single (or any) user you can make a simple application in C++ or C# for example.</p> <p>The simplest is having a C# in tray (by simply adding the tray component to the form) and register and event handler for the <strong>FormClosing</strong> event. It'd look like this:...
41,986
<p>I have some complex stored procedures that may return many thousands of rows, and take a long time to complete.</p> <p>Is there any way to find out how many rows are going to be returned before the query executes and fetches the data?</p> <p>This is with Visual Studio 2005, a Winforms application and SQL Server 20...
<p>You mentioned your stored procedures take a long time to complete. Is the majority of the time taken up during the process of selecting the rows from the database or returning the rows to the caller?</p> <p>If it is the latter, maybe you can create a mirror version of your SP that just gets the count instead of the...
<p>make a stored proc to count the rows first.</p> <p>SELECT COUNT(*) FROM table</p>
31,662
<p>Are there any good books for a relatively new but not totally new *nix user to get a bit more in depth knowledge (so no "Linux for dummies")? For the most part, I'm not looking for something to read through from start to finish. Rather, I'd rather have something that I can pick up and read in chunks when I need t...
<p>I've wiki'd this post - could those with sufficient rep add in items to it.</p> <p>System administration, general usage books</p> <ul> <li><p>Nemeth et. al, <a href="https://rads.stackoverflow.com/amzn/click/com/0131480049" rel="noreferrer" rel="nofollow noreferrer">Linux System Administration</a></p></li> <li><p>...
<p>Big agreement for <em>Essential System Adminstration</em> and <em>Unix Power Tools</em>.</p> <p>Also, whichever editor you prefer, vim or emacs, learn it back &amp; forth. If you like vim, then get Steve Oualline's vim book.</p>
29,306
<p>I've just started working on an <code>ASP.NET</code> project which I hope to open source once it gets to a suitable stage. It's basically going to be a library that can be used by existing websites. My preference is to support <code>ASP.NET 2.0</code> through <code>3.5</code>, but I wondered how many people I would ...
<p>Increasingly I think not.</p> <p>The kind of large rigid organisation currently still clinging to 1.1 (probably because they're only just upgraded to it) is also the kind that's highly unlikely to look at open source solutions.</p> <p>If I were starting a new ASP.Net project right now I'd stick with .Net 3.5 and p...
<p>I think you would be perfectly fine with targeting just 2.0 and above, someone who would use your library would most likely be doing new development and using at least ASP.NET 2.0. I think it would be a very small group of people doing new development in 1.1.</p>
3,412
<p>I develop using MAMP pro on my Mac. When I start MAMP it prompts me for a password if I use port 80. If I use a higher port it doesn't prompt me, but I have to append the port number in the URL ( eg dev.local:8888 ). Does anyone know how to make it not prompt for password when using standard ports? Thank you.</p>
<p>According to a living-e rep they are considering adding an option to store the password in the keychain:</p> <p><a href="http://forum.webedition.de/phpBB/viewtopic.php?f=4&amp;t=5517&amp;p=12019" rel="nofollow noreferrer">http://forum.webedition.de/phpBB/viewtopic.php?f=4&amp;t=5517&amp;p=12019</a></p> <p>Update: I ...
<p>Its a security issue, and MacOS with its UNIX heritage like security (=Good Thing). That's why MacOS asks for passwords all the time. Not much you can do about it as far as I know.</p>
25,464
<p>Does anyone have some good hints for writing test code for database-backend development where there is a heavy dependency on state?</p> <p>Specifically, I want to write tests for code that retrieve records from the database, but the answers will depend on the data in the database (which may change over time).</p> ...
<p>You should look into DBUnit, or try to find a PHP equivalent (there must be one out there). You can use it to prepare the database with a specific set of data which represents your test data, and thus each test will no longer depend on the database and some existing state. This way, each test is self contained and...
<p>I have the exact same problem with my work and I find that the best idea is to have a PHP script to re-create the database and then a separate script where I throw crazy data at it to see if it breaks it.</p> <p>I have not ever used any Unit testing or suchlike so cannot say if it works or not sorry.</p>
2,506
<p>Is there a method for handling errors from COM objects in RDML? For instance, when calling Word VBA methods like <code>PasteSpecial</code>, an error is returned and the LANSA application crashes. I cannot find anything in the documentation to allow handling of these errors.</p> <p>Actually, error handling in genera...
<blockquote> <ol> <li>Does anyone know of anyway to reduce/optimize the PDF export phase and or the size of the PDF without lowering the total page count?</li> </ol> </blockquote> <p>I have a few ideas and questions:<br> 1. Is this a graphics-heavy report? If not, do you have tables that start out as text...
<blockquote> <ol> <li>Does anyone know of anyway to reduce/optimize the PDF export phase and or the size of the PDF without lowering the total page count?</li> </ol> </blockquote> <p>I have a few ideas and questions:<br> 1. Is this a graphics-heavy report? If not, do you have tables that start out as text...
3,613
<p>This is a pretty-much theoretical question, but..</p> <p><strong>How much of an operating system could be written in a language like Python, Ruby, Perl, or Lisp, Haskell etc?</strong></p> <p>It seems like a lot of the stuff like init.d could trivially be done in a scripting language. One of the firewall-device-OS'...
<p>Technically, any of it could be, if you write a compiler to do so. OSes have been done in Java (JNode), .NET (MOSA, Singularity, SharpOS, Cosmos), Haskell (HOUSE), Python (Unununium), etc.</p> <p>Edit: I see a lot of people talking about the very lowest level being an area where this couldn't be done; this isn't ...
<p>I would say this is not possible. Responses to this question keep referring to changes to the language or using the language to generated low level (kernel) code. This is just using one language to write another language. While I agree that both of these would allow you to then write an operating system, I would ...
23,113
<p>Exactly what the topic title says, </p> <p>In which cases would you prefer using public functions to change local variables over just defining that variable as public and modifying it directly?</p>
<p>Obviously if you want changing the variable to have some other effect on the object's state (like recalculating some other property of the object) you must use a mutator function.</p> <p>If it's possible to set the variable to something that places the object in an invalid state, you should probably also use a muta...
<p>If you want to change a variable inside a class, your best doing it through Properties.</p> <p>Its not good practice to have variable's modified on the outside.</p> <p>Think of future development too. You could put some logic behind a Property without changing the whole program.</p>
32,196
<p>I want to design a class that will parse a string into tokens that are meaningful to my application.</p> <p>How do I design it?</p> <ol> <li>Provide a ctor that accepts a string, provide a Parse method and provide methods (let's call them "minor") that return individual tokens, count of tokens etc. OR</li> <li>Pro...
<p>I would have a separate class with a Parse method that takes a string and converts it into a separate new object with a property for each value from the string.</p> <pre><code>ValueObject values = parsingClass.Parse(theString); </code></pre>
<p>If the sole purpose of the class is to parse the input string into a group of properties, then I don't see any real downside in option 3. The parse operation may be expensive, but you have to do it at some point if you're going to use it.</p> <p>You mention that option 2 is convenient because you can parse new valu...
39,911
<p>Is there an Eclipse command to surround the current selection with parentheses?</p> <p>Creating a template is a decent workaround; it doesn't work with the "Surround With" functionality, because I want to parenthesize an expression, not an entire line, and that requires <code>${word_selection}</code> rather than <c...
<p>Maybe not the correct answer, but at least a workaround:</p> <ol> <li><p>define a Java template with the name "parenthesis" (or "pa") with the following :</p> <p>(${word_selection})${cursor}</p></li> <li><p>once the word is selected, <kbd>ctrl</kbd>-<kbd>space</kbd> + <kbd>p</kbd> + use the arrow keys to select th...
<p>Easy, Window->Prefs, then select Java->Editor->Templates</p> <p>Create a new template with : (${line_selection}${cursor})</p> <p>The "line_selection" means you have to select more than one line.</p> <p>You can try creating another one with "word_selection", too.</p> <p>Then, select text, right click, Surround Wi...
9,255
<p>Always was interested why are <a href="http://msdn.microsoft.com/en-us/library/system.array.sort.aspx" rel="nofollow noreferrer">Array.Sort()</a> and <a href="http://msdn.microsoft.com/en-us/library/system.array.indexof.aspx" rel="nofollow noreferrer">Array.IndexOf()</a> methods made static and similar <a href="http...
<p>In my view Array class is basically a class representation of the fixed size arrays that we declare using [] in program (you can draw the analogy like int has it's class (structure) representation as System.Int32).</p> <p>Also Array class does not contain the actually array data in any instance variables but it pro...
<p>A collection class like <code>ArrayList</code> encapsules some kind of internal storage (presumably an array which is resized as needed, but it could also be a linked list or some other implementation). Metods like <code>IndexOf</code> and <code>Sort</code> needs access to the underlying private storage to be effici...
21,353
<p>I need to access a mysql database from c# code but I would prefer not to use ODBC for the reasons below.</p> <p>I have to create a demo and I am using xampp on a USB drive. My code (database Read/Write code) is written in C#. So to keep the USB drive isolated from the computer that the demo runs on I am moving awa...
<p><a href="http://dev.mysql.com/downloads/connector/net/5.2.html" rel="noreferrer">http://dev.mysql.com/downloads/connector/net/5.2.html</a></p> <p>Last time I tried it it worked fine but if you need to connect to, for example, MySQL and SQL Server you'll need to duplicate the code once using SqlConnection and the ot...
<p>Depending on your needs, you could also look at an ORM like <a href="http://subsonicproject.com/" rel="nofollow noreferrer">SubSonic</a>. It works with MySQL and will give you both database independence and ease of development.</p>
43,446
<p>It seems like <code>Info.plist</code> file has an ability to declare different roles for the same application bundle through the <code>UIRoleInfo</code> key. SpringBoard can recognize these roles after installing an app and may display separate icons for each application role.</p> <p>For instance, iPhone shows <cod...
<p>This isn't a supported feature, so if you do this you might have a hard time getting your app through the approval process. I wouldn't recommend using it.</p>
<p>Have you tried it to see if it works? If it doesn't work, you could create a second app that does nothing but launch the first one, with a custom URL scheme. The first app can recognize when it is being launched with that URL. This is not ideal as you will see the second app launch &amp; quit (though it should be re...
26,956
<p>I am a member of a team that is about to launch a beta of a python (Django specifically) based web site and accompanying suite of backend tools. The team itself has doubled in size from 2 to 4 over the past few weeks and we expect continued growth for the next couple of months at least. One issue that has started ...
<p>Setuptools may be capable of more of what you're looking for than you realize -- if you need a custom version of lxml to work correctly on MacOS X, for instance, you can put a URL to an appropriate egg inside your setup.py and have setuptools download and install that inside your developers' environments as necessar...
<p>Basically, you're looking for a <strong>cross-platform software/package installer</strong> (on the lines of apt-get/yum/etc.) I'm not sure something like that exists?</p> <p>An alternative might be specifying the list of packages that need to be installed via the OS-specific package management system such as Fink o...
19,435
<p>I have a middle tier containing several related objects and a data tier that is using a DataSet with several DataTables and relationships.</p> <p>I want to call a Save method on one of my objects (a parent object) and have its private variable data transformed into a DataRow and added to a DataTable. Some of the p...
<p>I will not start another debate whether datasets are good or evil. If you continue to use them, here are something to consider:</p> <ul> <li>You need to keep the original dataset and update that, in order to get correct inserts and updates.</li> <li>You want your parents to know their children, but not the other wa...
<p>So, What I am doing right now is passing a reference to the DataSet and a reference to the DataRow of the parent into the Save method of the Child Object.</p> <p>Here is a little code showing the concept of what I am doing.</p> <pre><code>// some random save event in a gui.cs// public void HandleSaveButtonClick() ...
18,079
<p>When starting a django application using <code>python manage.py shell</code>, I get an InteractiveConsole shell - I can use tab completion, etc.</p> <pre><code>Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more in...
<p>I may have found a way to do it.</p> <p>Create a file .pythonrc</p> <pre><code># ~/.pythonrc # enable syntax completion try: import readline except ImportError: print("Module readline not available.") else: import rlcompleter readline.parse_and_bind("tab: complete") </code></pre> <p>then in your ....
<p>For older versions (2.x) above script works like charm :)</p> <pre class="lang-sh prettyprint-override"><code>fernanr@crsatx4 ~ $ cat .bashrc | grep -i python #Tab completion for python shell export PYTHONSTARTUP=~/.pythonrc fernanr@crsatx4 ~ $ . ~/.bashrc fernanr@crsatx4 ~ $ echo $? 0 fernanr@crsatx4 ~ $ python2 P...
30,628
<p>Tag <a href="https://3dprinting.stackexchange.com/questions/tagged/nylon" class="post-tag" title="show questions tagged &#39;nylon&#39;" rel="tag">nylon</a> exists already, but I think it would be incredibly useful to have a TPE/TPU tag and a tag for all flexibles as a category.</p> <p><strong>EDIT:</strong> It has...
<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>
60
<p>I am downloading a text string from a web service into an RBuf8 using this kind of code (it works..)</p> <pre><code>void CMyApp::BodyReceivedL( const TDesC8&amp; data ) { int newLength = iTextBuffer.Length() + data.Length(); if (iTextBuffer.MaxLength() &lt; newLength) { iTextBuffer.ReAll...
<p>What you may need is something to the effect of:</p> <pre><code>RDebug::Print( _L( "downloaded text %S" ), &amp;buf ); </code></pre> <p><a href="http://wiki.forum.nokia.com/index.php/How_to_use_RDebug" rel="nofollow noreferrer">This tutorial</a> may help you.</p>
<p>As stated by quickrecipesonsymbainosblogspotcom, you need to pass a pointer to the descriptor.</p> <p><code>RDebug::Printf("downloaded text %S", &amp;buf); //note the address-of operator</code></p> <p>This works because <code>RBuf8</code> is derived from <code>TDes8</code> (and the same with the 16-bit versions).<...
42,836
<p>I'm using the code below to save a password to the registry, how do I convert it back? The code below isn't mine but it encrypts well.</p> <p>Thanks</p> <pre><code>using System.Security.Cryptography; public static string EncodePasswordToBase64(string password) { byte[] bytes = Encoding.Unicode.GetBytes(passwor...
<p>SHA1 is a <em>hash</em> algorithm, not an encryption algorithm. A hash algorithm is a one-way function which transforms data into a hash of that data, but the original data cannot be gotten back from the hash. An encryption algorithm is a two-way function which transforms data into encrypted data, and the encrypted ...
<p>Using your own code snippet above, what you want to do is call that method when the user initially chooses a password - but add to the password what is called a <a href="http://en.wikipedia.org/wiki/Salt_(cryptography)" rel="nofollow noreferrer">salt</a> somewhere in the password string (usually at the beginning or ...
33,793
<p>All of my users are a short walk down the hall, and all of my programs run on workstations on the same LAN. Some years ago, I had the staff write the log files for all of their programs to a shared folder hierarchy, naming each log file after the machine name in a sub-directory named after the app.</p> <p>But this ...
<p>In an IT environment which I worked in a few years back, we had each machine write it's log files locally and wipe them every five days. The server would log in every night to grab the latest logs from each machine. If the server went down, it would just grab two days worth of logs from everyone. If a client went...
<p>Can you have the log files writtin to peoples local machine and then have a script that pulls them to a common file server as a nightly batch job?</p>
17,149