instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>My group has a source analysis tool that enforces certain styles that we have to comply with. I can't change it, and some of the rules are just a pain. One example is that all properties have to come before methods, and all constructors must come before properties. It seems silly to me that I have to take time to... | <p>You have different possibilities, depending on what exactly you want to do:</p>
<p>Resharper: There is a auto-format function which formats the source code of a single file or all files in the project / solution depending on your selected rules. So you set the settings for braces, naming, whitespaces, operators, la... | <p>Unless they bake it into VS2010, Resharper has the auto formatting capabilities you're probably looking for. CodeSmith probably has it too, I just haven't used it...</p>
| 31,696 |
<p>I want to force Apache to use HTTPS for a particular URL in the following form:</p>
<pre><code>https://www.example.com/signup/*
</code></pre>
<p>so</p>
<p>if someone goes to any of the following example URLs directly, Apache will forward the URL over to the HTTPS equivalent site.</p>
<p>e.g.</p>
<pre><code>http... | <p>Thank Murat,</p>
<p>Yours almost worked but figured out how to get it to exactly work.</p>
<p>The following is what works:</p>
<pre><code>RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} ^/somefolder/?
RewriteRule ^(.*)$ https://www.domain.com/$1 [R,L]
</code></pre>
<p>Notice that I didn't include somef... | <p>You can do this with mod_rewrite -</p>
<p>RewriteCond %{SERVER_PORT} !^443$</p>
<p>RewriteRule ^/signup <a href="https://example.com/signup" rel="nofollow noreferrer">https://example.com/signup</a></p>
<p>RewriteRule ^/signup/(.*)$ <a href="https://example.com/signup/" rel="nofollow noreferrer">https://example.co... | 32,182 |
<p>It should be hands-on, complete, targeted to programmers and detailed on layout techniques!</p>
| <p>Check out www.css-tricks.com. They have excellent screen casts.</p>
<p>Another place to check out is the various web design podcasts. Go to iTunes and search the podcasts and you will probably find a few to check out.</p>
| <p>Are you looking for a free screen cast? If not, Eric Meyer (one of the gods of web standards) has a video called <a href="http://www.lynda.com/store/productinfo.aspx?productid=532" rel="nofollow noreferrer">CSS Web Design</a> which will tell you everything you need to be fluent with CSS. </p>
<p>It also covers som... | 16,287 |
<p>Are there any tools that can tell me what percentage of a XSL document get actually executed during tests?</p>
<p><strong>UPDATE</strong></p>
<p>I could not find anything better than Oxygen's XSL debugger and profiler, so I'm accepting Mladen's answer.</p>
| <p>This didn't exist back when this question was asked, but now there is ONE option for finding code coverage of XSLT documents:</p>
<p><a href="http://code.google.com/p/cakupan/" rel="noreferrer">http://code.google.com/p/cakupan/</a></p>
<p>I'll admit that I haven't used it yet, as I'm still gathering information ri... | <p>If anyone is still interested, Saxon has a <a href="http://www.saxonica.com/html/documentation/using-xsl/performanceanalysis.html" rel="nofollow noreferrer">performance analysis</a>, which has a functionality that gives you a breakdown of each template and the number of times they are used (which is great for optimi... | 12,562 |
<p>I have a custom control and it works fine...except that the control cannot be rendered on Design Time. ( I am using VS 2008)</p>
<p>I am thinking many people who develop custom controls encounter this problem...The error I get is "Error Creating Control - CustomControlName" Object reference not set to an instance ... | <p>BFree's comment is the most likely issue, for a control to display in the design view it needs a parameterless constructor as the design viewer doesn't know how you would normally instantiate the control.</p>
<p>If you do have a parameterless constructor, can you paste some code in to show what's happening?</p>
| <p>As Glenn mentioned the first issue could be no parameterless constructor.</p>
<p>The second could be you are calling methods during the OnLoad or other methods you mentioned that have parameters that are not initialized or some sort of attempt at database calls etc that is normally done at run-time.</p>
<p>Unless ... | 49,702 |
<p>I am looking to 3D print some small molds that will allow wood glue to dry but <em><strong>not</strong></em> stick.</p>
<p>Is there a recommended filament that is known to <em><strong>resist</strong></em> binding to simple wood glue?</p>
<p>Alternately, is there an inexpensive adhesive (like wood glue) I could use i... | <p>You are looking for a filament that does not bond to wood glue, or as weak as possible. You misunderstand how wood glue "bonds" to plastics:</p>
<p>Wood glue is typically PVA. It <em>bonds</em> to wood and paper by seeping into them before curing and hardening. The mesh of the glue entangles fibers of the ... | <p>You are looking for a filament that does not bond to wood glue, or as weak as possible. You misunderstand how wood glue "bonds" to plastics:</p>
<p>Wood glue is typically PVA. It <em>bonds</em> to wood and paper by seeping into them before curing and hardening. The mesh of the glue entangles fibers of the ... | 1,837 |
<p>In C++, what's the generic way to convert any floating point value (float) to <a href="http://en.wikipedia.org/wiki/Fixed-point_arithmetic" rel="noreferrer"><strong>fixed point</strong></a> (int, 16:16 or 24:8)?</p>
<p><strong>EDIT:</strong> For clarification, fixed-point values have two parts to them: an integer p... | <p>Here you go:</p>
<pre><code>// A signed fixed-point 16:16 class
class FixedPoint_16_16
{
short intPart;
unsigned short fracPart;
public:
FixedPoint_16_16(double d)
{
*this = d; // calls operator=
}
FixedPoint_16_16& operator=(double d)
{
intPart = static_ca... | <p>There isn't any built in support in C++ for fixed point numbers. Your best bet would be to write a wrapper 'FixedInt' class that takes doubles and converts them.</p>
<p>As for a generic method to convert... the int part is easy enough, just grab the integer part of the value and store it in the upper bits... decima... | 22,744 |
<p>I have been reading the proper article in MSDN, <em><a href="http://msdn.microsoft.com/en-us/library/wd40t7ad.aspx" rel="noreferrer">Strong-Named Assemblies</a></em> and a related Stack Overflow question, <em><a href="https://stackoverflow.com/questions/308756">Checking an assembly for a strong name</a></em>.</... | <p>When you sign an assembly with a strong name based on a private key that you create, this has the following benefits:</p>
<ul>
<li>A strong name guarantees the uniqueness of an assembly's identity by adding a public key token and a digital signature to the assembly.</li>
<li>A strong name can be matched to a public... | <p>I believe there is a way to use strong name for the purpose of "Trust". I understand Microsoft only recommends strong name to ensure assembly contents have not been modified and suggests using "Authenticode" for trust.</p>
<p>But if the loader application (the application which loads these assemblies/programs) main... | 48,224 |
<p>I was testing on a customer's box this afternoon which has Windows Vista (He had home, but I am testing on a Business Edition with same results).</p>
<p>We make use of a .DLL that gets the Hardware ID of the computer. It's usage is very simple and the sample program I have created works. The Dll is <a href="http://... | <p>@<a href="https://stackoverflow.com/questions/29284/windows-vista-unable-to-load-dll-xdll-invalid-access-to-memory-location-dllnotf#29400">Martín</a></p>
<p>The reason you were not getting the UAC prompt is because UAC can only change how a process is <strong>started</strong>, once the process is running it must st... | <p>Have you made a support request to the vendor? Perhaps there's something about the MacBook Pro hardware that prevents the product from working.</p>
| 4,893 |
<p>I have been looking at getting some painters tape to use on the glass plate for better print adhesion, and everything I read suggests the <em>blue</em> painters tape, such as this:</p>
<p><a href="https://i.stack.imgur.com/WNCHm.jpg" rel="noreferrer" title="Blue painters tape"><img src="https://i.stack.imgur.com/WN... | <h1>read first</h1>
<p>When you use painters tape, you need to level your printer <strong>with</strong> the tape applied. You need to relevel if you change the tape type.</p>
<h1>Basics</h1>
<p>It's not <em>any</em> blue tape that printers love. There are basically two factors that make a tape useful:</p>
<ul>
<li>It h... | <p>The second image isn't exactly painter's tape. Both images are types of masking tape, but the common manila/cream-colored masking tape vs the blue or green painter's tape <em>typically</em> has three features that make it less desirable for bed adhesion:</p>
<ol>
<li>Stronger glue holding the tape to the bed, that ... | 1,318 |
<p>Is there any way of knowing if the user closes a tab in a web browser? Specifically IE7, but also FireFox and others as well. I would like to be able to handle this situation from our asp code if the current tab containing our web site closes.</p>
| <p>Attach an "<a href="http://msdn.microsoft.com/en-us/library/ms536907(VS.85).aspx" rel="nofollow noreferrer">onbeforeunload</a>" event. It can execute code just before the browser/tab closes.</p>
| <p>If you need to know when the page is closed at the server side, your best bet is to ping the server periodically from the page (via <code>XMLHttpRequest</code>, for example). When pinging stops, the page is closed. This will also work if the browser crashed, was terminated or the computer was turned off.</p>
| 16,757 |
<p>Say I have a C program which is broken to a set of *.c and *.h files. If code from one file uses functions from another file, where should I include the header file? Inside the *.c file that used the function, or inside the header of that file?</p>
<p>E.g. file <code>foo.c</code> includes <code>foo.h</code>, which ... | <p>You should include foo.h inside foo.c. This way other c files that include foo.h won't carry bar.h unnecessarily. This is my advice for including header files:</p>
<ul>
<li>Add include definitions in the c files - this way the file dependencies are more obvious when reading the code.</li>
<li>Split the foo.h in two... | <p>I include the most minimal set of headers possible in the <code>.h</code> file, and include the rest in the <code>.c</code> file. This has the benefit of sometimes reducing compilation times. Given your example, if <code>foo.h</code> doesn't really need <code>bar.h</code> but includes it anyway, and some other file ... | 34,853 |
<p>I am taking a class in C++ programming and the professor told us that there is no need to learn C because C++ contains everything in C plus object-oriented features. However, some others have told me that this is not necessarily true. Can anyone shed some light on this?</p>
| <p><strong>Overview:</strong></p>
<p>It is almost true that C++ is a superset of C, and your professor is correct in that there is no need to learn C separately. </p>
<p>C++ adds the whole object oriented aspect, generic programming aspect, as well as having less strict rules (like variables needing to be declared at... | <p>If any of the students in the class intend to become embedded software engineers, then they may have no choice but to program in C (see <a href="https://stackoverflow.com/questions/812717/is-there-any-reason-to-use-c-instead-of-c-for-embedded-development/815197#815197">this question</a>, and <a href="https://stackov... | 17,495 |
<p>I like jQuery and I was wondering if anyone have used a good plugin or (non-jQuery) JavaScript library that allows for auto-formatting of structured fields like phone numbers or dates. I know of the jquery-ui-datapicker plugin, and not what I am looking for here. You may type in a phone number as 123 which then be... | <p>Does <a href="http://digitalbush.com/projects/masked-input-plugin/" rel="noreferrer">the Masked Input plugin</a> do what you need or that one you have already found to be unreliable?</p>
| <p>Allan,</p>
<p>I do believe your best bet would be to use regular expressions inside of two separate formatting methods in order to achieve the desired results. This will be rather straight forward for phone numbers and I'll post a code example if one isn't posted by the time I sit back and have 10 minutes straight ... | 13,509 |
<p>As a web developer, a number of the projects I work on fall under government umbrellas and hence are subject to 508 Accessibility laws, and sometimes W3C accessibility guidelines. To what extent can Flash be used while still meeting these requirements?</p>
<p>For using javascript, the mantra is "Degrade gracefully"... | <p>I'm visually impaired to the point where I use magnification tools and TTS for convenience but not as a necessity. I can tell you that Flash just doesn't work with the majority of accessibility tools out there. I believe JAWS (the market leader for Windows but not overwhelmingly dominant by any means) says it has F... | <p>Flash can be made accessible to visually impaired, but it takes some time and effort. It's not automaticly a no-go area. It's still important to check if the different browsers play along with flash in this way, as Alxp notes. </p>
<p>There is one additional problem with flash: it steals the keyboard shortcuts. Wit... | 33,883 |
<p>This is always a pain, no matter what source control system I have used (<a href="https://en.wikipedia.org/wiki/Microsoft_Visual_SourceSafe" rel="nofollow noreferrer">Visual SourceSafe</a>, <a href="https://en.wikipedia.org/wiki/Concurrent_Versions_System" rel="nofollow noreferrer">CVS</a>, <a href="https://en.wikip... | <p>You need to just bite the bullet and include them in version control system. Unfortunately, they <em>do</em> contain information that isn't available anywhere else in the source. (The bitmaps added to ImageList controls, for example.) If you lose those files, you can't rebuild the application correctly.</p>
| <p>Frx merges are a major pain. Which I why I recommend if your version control system allows locking, make sure you use it on the frx files to avoid merges. For example, Subversion supports locking to avoid issues with editing bitmaps and other binary files.</p>
<p>With that being said, my company and I have been usin... | 41,743 |
<p>How much database performance overhead is involved with using C# and LINQ compared to custom optimized queries loaded with mostly low-level C, both with a SQL Server 2008 backend?</p>
<p>I'm specifically thinking here of a case where you have a fairly data-intensive program and will be doing a data refresh or updat... | <p>As Daniel McPherson said, this is caused when SSPs are deleted but the associated
job are not and attempt to communicate with the deleted database.<br><br>If the SSP
database has been deleted or a problem occurred when deleting an SSP, the job may
not be deleted. When the job attempts to run, it will fail since t... | <p>Have you tried removing the SSP using the command line? I found this worked once when we had a broken an SSP and just wanted to get rid of it.</p>
<p>The command is:</p>
<pre><code>stsadm.exe -o deletessp -title <sspname> [-deletedatabases]
</code></pre>
<p>The <code>deletedatbases</code> switch is optional... | 2,676 |
<p>I've just built my son's A6 and have connected all cables apart from the last power cables. The mainboard says hotbed line and extruder line but the cable says heatbed.</p>
<p>The cables are two red which are crimped together and two black crimped together.</p>
<p>All of the videos online show a different mainboar... | <p>The manual appears to be available here, <a href="https://www.elektor.com/amfile/file/download/file/1606/product/8457/&usg=AOvVaw3bQeEWg--MsnW9KbsTKc_c" rel="nofollow noreferrer">Installation Instruction_Anet A6 3D Printer - Elektor</a></p>
<p>However, according to <a href="https://www.thingiverse.com/groups/ane... | <p>Thanx for the help, got it running now.
The board in the pic is the older version, my problem was the wires for the extruder had been cut really short for some reason and not labled.</p>
| 1,455 |
<p>A software package I'm working on installs its own Windows theme and as part of the install tries to make it the current theme. We managed to get this working on Windows XP with a great many registry edits during the install (a reboot applies the changes) but Vista seems to require even more reqistry changes.</p>
... | <p>Sorry to necro an old thread, but I still see this question around the internets.</p>
<p>Windows is still not very far removed from its DOS roots. You can shell this command to open the control panel and load your theme.</p>
<p>This works for Windows 7, but can be modified for Vista. Just shell this, or type it ... | <p>Here's a dirty hack:
If all else fails, you could try UI Automation Toolkit to automatically "click" on the OK button. :)</p>
| 37,190 |
<p>I'm seeing a current trend towards many questions only receiving a single answer, and according the the <a href="http://area51.stackexchange.com/proposals/82438/3d-printing">Area 51</a> stats, we ought to have an <em>average</em> closer to 2.5. Granted that some questions are really only in need of a single (obvious... | <p>Well done for bringing this up. I was looking at those numbers too. </p>
<p>Referring to <a href="https://3dprinting.meta.stackexchange.com/questions/264/what-does-it-take-to-get-out-of-beta-stage/265#265">this post</a>, almost all of the stats are improving (albeit) slowly, except for one, the ApQ </p>
<blockquot... | <p>Something to realize is, ApQ is one of the least dependent factors for graduation. I don't think this site lends to having a huge amount of ApQ's, because usually there is only going to really be one answer which will work. I think the ApQ category was based more towards the programming/tech sites. I mean, when prog... | 54 |
<p>I would like to confirm that the following analysis is correct:</p>
<p>I am building a web app in RoR. I have a data structure for my postgres db designed (around 70 tables; this design may need changes and additions during development to reflect Rails ways of doing things. EG, I designed some user and role tables ... | <p>Proposition 1 is false in at least two situations - you can use plugins like <a href="http://github.com/vigetlabs/foreign_key_migrations/tree" rel="noreferrer">foreign_key_migrations</a> to do the following:</p>
<pre><code>def self.up
create_table :users do |t|
t.column :department_id, :integer, :references =... | <p>Since you are using Postgres and may not want to install the foreign_key_migrations plugin, here is what I do when I want to use both migrations and foreign key constraints.</p>
<p>I add a SchemaStatements method to ActiveRecord::SchemaStatements called "add_fk_constraint".
This could go in some centralized file, b... | 14,647 |
<p>I are using EJB 3 on a fairly large J2EE project, by default with Netbeans sets the persistent provider for the entity beans to TopLink. There is the option to change the provider to one of the following or even add a new persistence library:</p>
<ul>
<li>Hibernate</li>
<li>KODO</li>
<li>OpenJPA</li>
</ul>
<p>Whic... | <p>Theres only two JPA providers I'd consider using:</p>
<p>If you want to stick to standard JPA I'd use EclipseLink. Whereas Toplink Essentials is the reference implementation of JPA 1.0, EclipseLink basically inherited the TopLink Essentials code and will be the reference implementation of JPA 2.0 (and bundled with... | <p>I recently worked on a large enterprise application built with Kodo JPA framework. The SQLs produced by Kodo were generally not very scalable with large amount of data. In my opinion it produced too many queries with outer joins. Considering how many mappings we had to change when trying to scale kodo, I would not r... | 12,353 |
<p>I doing a function in Javascript like the VisualBasic DateDiff.</p>
<p>You give two dates and the returning time interval (Seconds, Minutes, Days, etc...)</p>
<pre><code>DateDiff(ByVal Interval As Microsoft.VisualBasic.DateInterval, _
ByVal Date1 As Date, ByVal Date2 As Date) as Long
</code></pre>
<p>So what's ... | <p>Use the <a href="http://w3schools.com/jsref/jsref_obj_date.asp" rel="noreferrer">Date object</a> like so:</p>
<pre><code>function DateDiff(var /*Date*/ date1, var /*Date*/ date2) {
return date1.getTime() - date2.getTime();
}
</code></pre>
<p>This will return the number of milliseconds difference between the tw... | <p>If you follow this <a href="http://www.javascriptkit.com/javatutors/datedifference.shtml" rel="nofollow noreferrer">tutorial</a>, one way is to use:</p>
<pre><code>Date.getTime()
</code></pre>
<p>You will find a full <a href="http://web.archive.org/web/20081202142917/http://javascript.internet.com/math-related/dat... | 42,429 |
<p>I'm trying to create and retrieve a BLOB in a MySQL table via Kohana's ORM library.</p>
<p>The code looks something like:</p>
<pre><code>$attachment = new Attachment_Model();
$attachment->name = $info['FileName'];
$attachment->size = strlen($info['Data']);
$attachment->data = $info['Data'];
$attachment-&g... | <p>It turns out that, in this case, I was using the BLOB data type.</p>
<p>The BLOB data type truncates data at 65535 characters (silently, without throwing an error!)</p>
<p>I've upped it to a MEDIUMBLOB (which has a max length of 16777215 characters), and it seems to work OK!</p>
| <p>Wild guess, but: probably because the kohana model layer inserts all data as character data instead of binary, which will cause you troubles when saving/retrieving BLOB objects.</p>
| 24,006 |
<p>Edit: Ryan raised a good point. I specifically want to be able to map to and from while still storing human-readable values in the database. That is, I don't want a bunch of enumeration integers in my database.</p>
| <p>According to the <a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/mapping.html#mapping-declaration-property" rel="noreferrer">documentation</a> you can either leave the type attribute of the property in your mapping file blank or you define it and specify the class name of the enumeration.... | <p>I've never used NHibernate, but can't you just set the SQL datatype to int? </p>
| 19,891 |
<p>I've spent a good part of the day searching, writing and finally scrapping a script that I can use with my Inno Setup install script that will download and install the appropriate .NET 2.0 Framework if needed.</p>
<p>There are definitely a number of examples out there, but they:</p>
<ol>
<li><p>Want to install Int... | <p><a href="http://www.codeproject.com/KB/install/dotnetfx_innosetup_instal.aspx" rel="nofollow noreferrer">.NET Framework 1.1/2.0/3.5 Installer for InnoSetup</a></p>
| <p>I have recently been looking into this issue but without the same requirements that you have. I haven't seen a script that does what you want but have you considered instead checking if .NET 2.0 is installed and if not then prompt them to download it. You can open a URL in the default browser and get the user to a... | 15,748 |
<p>There is a webpage loaded in the firefox sidebar and another webpage loaded in the main document. Now, how do I ask access the main document object through the Firefox sidebar? An example to do this through Javascript code in the firefox sidebar document to access the main document would be helpful.</p>
<p>Thanks f... | <p>As far as I can tell, you are actually loading a web site in the sidebar (checked the 'Load this bookmark in Sidebar'). If this is the case, AND if the sidebar is opening the main window page. You can use the window.postMessage to communicate between them. But like I said, the sidebar page has to open the main page ... | <p>Accessing the main window from a sidebar is much trickier than going back the other way.</p>
<p>The DOM tree you'll need to traverse, according to <a href="http://developer.mozilla.org/en/Working_with_windows_in_chrome_code#Accessing_the_elements_of_the_top-level_document_from_a_child_window" rel="nofollow noreferr... | 17,571 |
<p>Some issues with timezones in PHP have been in the back of my mind for a while now, and I was wondering if there are better ways to handle it than what I'm currently doing.</p>
<p>All of the issues revolve around reformating database stored dates:</p>
<p>When dealing with a site that has to support multiple timezo... | <p>Few months ago we spent some time thinking about this. The technique we ended up with is pretty simple:</p>
<ol>
<li>Store dates in GMT/UTC (e.g. 0 timezone offset).</li>
<li>Apply current user timezone offset after retrieval from the database (e.g. before showing to the user or whenever you want).</li>
</ol>
<p>W... | <p>I didn't found any elegant solution online so I have created a <a href="https://github.com/dlucian/Timezone-Generator-PHP" rel="nofollow" title="Timezone-Generator-PHP on GitHub">Timezone HTML select generator</a> script and here's the <a href="https://gist.github.com/dlucian/5752015" rel="nofollow" title="Generated... | 45,117 |
<p>What's the best way to get the last inserted id using sqlite from Java? Google is giving me different answers--some say select the last-insert-rowid; others say call statement.getGeneratedKeys(). What's the best route to take? (I just want to return the id, not use it for other inserts or anything.)</p>
| <p>Use <code>getGeneratedKeys()</code> if your JDBC driver supports it. You don't want to muck around trying to get the key yourself after the insert. If your driver does not support <code>getGeneratedKeys()</code> then I would get the next value from the key before the insert.</p>
| <p>Use <code>getGeneratedKeys()</code> if your JDBC driver supports it. You don't want to muck around trying to get the key yourself after the insert. If your driver does not support <code>getGeneratedKeys()</code> then I would get the next value from the key before the insert.</p>
| 26,649 |
<p>I'd like to know if it is possible to redirect StreamWriter output to a variable</p>
<p>Something like</p>
<pre><code>String^ myString;
StreamWriter sw = gcnew StreamWriter([somehow specify myString])
sw->WriteLine("Foo");
</code></pre>
<p>then myString will contain Foo.
The reason I would like to do this is t... | <p><a href="http://msdn.microsoft.com/en-us/library/system.io.streamwriter.aspx" rel="noreferrer">StreamWriter</a> and <a href="http://msdn.microsoft.com/en-us/library/system.io.stringwriter.aspx" rel="noreferrer">StringWriter</a> both extend TextWriter, perhaps you could refactor your method that uses StreamWriter to ... | <p>Refactor the method to return string as you mentioned you could. Hacking it the way you are attempting, while academically interesting, will muddy the code and make it very hard to maintain for anyone that follows you.</p>
| 29,105 |
<p><strong>Area :</strong>
Textbox in Silverlight</p>
<p><strong>Question:</strong>
I need to know what "line number" that is currently edited.</p>
<p><strong>I've tried:</strong>
As a workaround I've tried splitting with textBox.Split("\r") and counting matches on Regex with similar performance. Performance during t... | <p>As I see it, you don't really need to use <code>string.Split</code> or <code>Regex</code>. Just iterate over the string and count <code>'\r'</code>s up to the caret position.</p>
<pre><code>var s = ...the string...
var r = 0;
var c = ...caret position...
for (var i = 0; i < c; i++)
if (s[i] == '\r')
r++;
... | <p>Here's the solution. Feel free to improve the code.</p>
<p>Demo -> <a href="http://briggs69.blogspot.com/2011/08/solution-maxlines-property-in.html" rel="nofollow">http://briggs69.blogspot.com/2011/08/solution-maxlines-property-in.html</a></p>
<p>Source -> <a href="http://www.codeproject.com/KB/edit/XTextBox.aspx"... | 49,664 |
<p>Looking for something to smooth out a PLA print. Would Mod Podge be a good solution? Will it stick? </p>
| <p>From what I've read about Mod Podge, it is an adhesive with a vinyl acetate base. As such it is similar to both PVA (used for wash-away support) and ordinary white glue. One of the more common references to the product refers to it not being water proof, although the outdoor version of the product presents as being ... | <p>I have used Ponal Express, a woodglue, as a smoothing layer inbetween a somewhat sanded PLA and an acrylic paint. It had a good result to get it almost perfectly smooth. It stuck quite well, no problem with it getting off under painting. DO note though, that sanding the glue layer can tear of larger pieces of the fi... | 1,567 |
<p>I have a large set of 3rd order polynomials in 3D.</p>
<p>in matrix form</p>
<blockquote>
<p>Pn = [1,t,t<sup>2</sup>,t<sup>4</sup>]*[An]</p>
<p><code>[Pn]</code> and <code>[An]</code> are <code>1xN</code> and <code>4xN</code> matrices respectively</p>
</blockquote>
<p>each function has a weight Wn. I want to, for so... | <p>Not knowing if this is solvable through analytic means, there are many approaches to searching a space and trying to find any t that meets that criteria. </p>
<p>Genetic algorithms, simulated annealing and other algorithms for optimization spring to mind.</p>
| <p>OK to seed the pot:</p>
<ul>
<li>Using some form of "close pair finder" algorithm seed a heap with those pairs at t0 and other times.</li>
<li>Pull the closest pair found</li>
<li>if close enough and sooner than the best so far, keep </li>
<li>find if they are closer or further apart</li>
<li>split the difference b... | 20,627 |
<p>I'm working on getting an Introduction to <a href="http://en.wikipedia.org/wiki/Groovy_%28programming_language%29" rel="nofollow noreferrer">Groovy</a> presentation ready for my local Java User's Group and I've pretty much got it together. What I'd like to see is what you all think I just have to cover. </p>
<p>R... | <p>I don't know anything about groovy so in a sense I've qualified to answer this...</p>
<p>I would want you to:</p>
<ul>
<li>Tell me why I would want to use Scripting (in general) as opposed to Java-- what does it let me do quicker (as in development time), what does it make more readable. Give tantalising examples ... | <p>You should definitely show them how to create a quick Grails application. Two domain classes that are related. Build a basic CRUD app. Explain that tables are being created behind the scenes using GORM(Hibernate). Then explain that you can create a war file and deploy it as you would any other Java war file. You... | 4,911 |
<p>What are the different approaches for creating scheduled tasks for web applications, with or without a separate web/desktop application?</p>
| <p>If we're talking Microsoft platform, then I'd always develop a separate Windows Service to handle such batch tasks.</p>
<p>You can always reference the same assemblies that are being used by your web application to avoid any nasty code duplication.</p>
| <p>I think there are easier ways than using cron (Linux) or Task Scheduler (Windows). You can build this into your web-app using:
(a) quartz scheduler, </p>
<p>or if you don't want to integrate another 3rd party library into your application:
(b) create a thread on startup which uses the standard Java 'java.util.Time... | 4,335 |
<p>This is kind of hard to explain, I hope my English is sufficient:</p>
<p>I have a class "A" which should maintain a list of objects of class "B" (like a private List). A consumer of class "A" should be able to add items to the list. After the items are added to the list, the consumer should not be able to modify th... | <p>To prevent editing the list or its items you have to make them <a href="http://en.wikipedia.org/wiki/Immutable_object" rel="nofollow noreferrer">immutable</a>, which means you have to return a new instance of an element on every request. </p>
<p>See Eric Lippert's excellent series of "Immutability in C#": <a href="... | <p><strong>EDIT:</strong> Added support for edition contexts. Caller can only add elements inside an edition context. You can aditionally enforce that only one edition context can be created for the lifetime of the instance.</p>
<hr>
<p>Using encapsulation you can define any set of policies to access the inner privat... | 15,371 |
<p>i have a string that looks like</p>
<pre><code>"<input id=a/>"<input id=b/>"<input id=c/>etc.
</code></pre>
<p>I need to change it to</p>
<pre><code>"<input id='a'/>"<input id='b'/>"<input id='c'/>etc,
</code></pre>
<p>any ideas how? </p>
| <p>In C# you could write it as:</p>
<pre><code>resultString = Regex.Replace(subjectString, @"(<.*?id\s*=\s*)(\w+)(.*?>)", "$1'$2'$3", RegexOptions.Multiline);
</code></pre>
<p>In VB.Net it would simply be:</p>
<pre><code>ResultString = Regex.Replace(SubjectString, "(<.*?id\s*=\s*)(\w+)(.*?>)", "$1'$2'$3"... | <p>It's hard to really answer this with just one small sample. For the given sample text, you can search for the regex:</p>
<pre><code>=(\w)
</code></pre>
<p>and replace it with:</p>
<pre><code>='$1'
</code></pre>
<p>or:</p>
<pre><code>='\1'
</code></pre>
<p>Depending on whether the programming language you're w... | 47,782 |
<p>I am collecting logs from several custom made applications. Each application has it's own log format. What I'm looking for is a central tool which would allow me to search through all of my logs. This means the tool would have to be able to define a different regex (or alike) for each log file (marking where a recor... | <p>You can try <a href="http://lucene.apache.org/java/docs/" rel="nofollow noreferrer">Lucene</a>. It is free. It is written in Java, and it allows full-text search over large amount of data. It is not a complete application, but rather a library, so you have to write code that uses it to index and to search your logs.... | <p>If you can use Windows, try out Microsoft's best tool ever, <a href="http://www.microsoft.com/technet/scriptcenter/tools/logparser/default.mspx" rel="nofollow noreferrer">Logparser</a>. I wish there was such a simple tool for Unix. But there isn't. And although I've kept wanting to get around to making a Unix versio... | 21,406 |
<p>I've been trying this a couple of different ways, but it's not working for some reason. Is it even possible?</p>
| <p>Yes. Separate them in your declaration by semicolons. </p>
| <p>You can use multiple parameters by separating them by a semicolon, but you have to implement the logic of splitting them yourself. <strong>This means you can use any character as your separator, because you need to parse it yourself.</strong> </p>
<p>You probably overriding <code>GetVaryByCustomString(HttpContext c... | 16,348 |
<p>I am using a perl script to POST to Google Appengine application. I post a text file containing some XML using the -F option.</p>
<p><a href="http://www.cpan.org/authors/id/E/EL/ELIJAH/bget-1.1" rel="nofollow noreferrer">http://www.cpan.org/authors/id/E/EL/ELIJAH/bget-1.1</a></p>
<p>There is a version 1.2, already... | <p>Is the number of extra bytes you need equal to the number of lines in the file? I ask because perhaps its possible that somehow carriage-returns are being introduced but not counted.</p>
| <p>How are you getting the number of bytes? .. By looking at the size of the file on the filesystem?</p>
<p>You can use "-s" to get the size of the file.</p>
<p>Or, if you want to do more, you may use <a href="http://search.cpan.org/~rgarcia/perl-5.10.0/lib/File/stat.pm" rel="nofollow noreferrer">File::Stat</a></p>
| 6,852 |
<p>I'm looking for a similar control to the InputFormSection control in Sharepoint that I want to use in a regular web page that doesn't run in the context of Sharepoint. Here's how the inputformsection looks like : <a href="http://graegert.com/wp-content/uploads/2008/01/moss_adminarea_page_structure1.png" rel="nofollo... | <p>So do I understand your question correctly? You want to have a control that looks and behave like the InputFormSection control of SharePoint, but it should be able to run outside the context of a SharePoint site?</p>
<p>If so, one approach that you could take is to rip out the generated HTML and use it in your own ... | <p>It is quite easy to reproduce the control (it is a user control and you have access to the .ascx files). Actually, that's exactly what I ended up doing yesterday.</p>
| 21,767 |
<p>How can I replace Line Breaks within a string in C#?</p>
| <p>Use replace with <code>Environment.NewLine</code></p>
<pre><code>myString = myString.Replace(System.Environment.NewLine, "replacement text"); //add a line terminating ;
</code></pre>
<p>As mentioned in other posts, if the string comes from another environment (OS) then you'd need to replace that particular environ... | <p>Based on @mark-bayers answer and for cleaner output:</p>
<pre><code>string result = Regex.Replace(ex.Message, @"(\r\n?|\r?\n)+", "replacement text");
</code></pre>
<p>It removes <code>\r\n</code> , <code>\n</code> and <code>\r</code> while perefer longer one and simplify multiple occurances to on... | 29,441 |
<p>I just recently installed <a href="http://www.oddsock.org/tools/gen_songrequester/" rel="nofollow noreferrer">Winamp Song Requester</a> wich is a Winamp web song requester plugin with a built in minimal HTTP CGI Server.</p>
<p>What the plugin does is that it runs a web server, serves a html page with some special v... | <p><strong>edit</strong>: ok i think this works (at least it worked in my test environment, see revisions for previous attempt)</p>
<pre><code>$.ajaxSetup({
'beforeSend' : function(xhr) {
xhr.overrideMimeType('text/html; charset=UTF-8');
},
});
$('#stuff').load('/yourresource.file'); // your ajax load
... | <p>At first, it would be better if you've used the more general $.ajax() function.</p>
<p>According to the <a href="http://docs.jquery.com/Ajax/jQuery.ajax#options" rel="nofollow noreferrer">documentation</a> there is the scriptCharset option, however it is only applicable in certain data types. It is also stated that... | 42,789 |
<p>I was recently approached by a network-engineer, co-worker who would like to offload his minor network admin duties to a junior-level helpdesk tech. The specific location in need of management acts as an ISP for tenants on its single-site property, so there's a lot of small adjustments being made on a daily basis.... | <p>SNMP is great for getting information <em>out</em> of a Cisco device, but is not very useful controlling the device. (although technically, you <em>can</em> push a new config to a Cisco IOS device using a combination of SNMP and TFTP. But sending a whole new config is a pretty blunt instrument for controlling your... | <p>Sidenote: before you reinvent the wheel writing another service provisioning system/network management system, try looking for existing ones. I know quite a lot of commercial solutions of various degrees of flexibility/functionality, but I am sure there are quite a lot opensource ones.</p>
| 29,050 |
<p>I have an XML file that's the output from a database. I'm using the Java SAX parser to parse the XML and output it in a different format. The XML contains some invalid characters and the parser is throwing errors like 'Invalid Unicode character (0x5)'</p>
<p>Is there a good way to strip all these characters out b... | <p>I used Xalan <code>org.apache.xml.utils.XMLChar</code> class:</p>
<pre><code>public static String stripInvalidXmlCharacters(String input) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < input.length(); i++) {
char c = input.charAt(i);
if (XMLChar.isValid(c)) {
sb... | <p>Is it possible your invalid characters are present only within the values and not the tags themselves i.e. the XML notionally meets the schema but the values have not been properly sanitized? If so, what about overriding InputStream to create a CleansingInputStream that replaces your invalid characters with their XM... | 11,923 |
<p>I have a WCF service which includes UI components, which forces me to be in STA mode.</p>
<p>How do I set the service behaviour to STA-mode?</p>
<hr>
<p>The service uses a reference to a WPF DLL file which opens a UI window (used as view port) for picture analysis. When the service is trying to create an instance... | <p>I'm doing something similar to you.</p>
<p>My solution was to route all calls through an STA thread queue. I used a threadsafe collection from the new <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=348F73FD-593D-4B3C-B055-694C50D2B0F3&displaylang=en" rel="nofollow noreferrer">parallel framew... | <p>I would investigate using the [STAThread] attribute to switch the threading model.
e.g.</p>
<pre><code>[STAThread]
static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[] { new Host() };
ServiceBase.Run(ServicesToRun);
}
</code></pre>
<p><a href="http://msdn.micr... | 7,200 |
<p>I was wonder if any knows how to open up a windows *.dmp file after a application crash written C/C++.</p>
| <p>Using Visual Studio's <em>File>Open Project</em> or the free WinDbg's (part of <a href="http://www.microsoft.com/whdc/DevTools/Debugging/default.mspx" rel="noreferrer">Debugging Tools for Windows</a>) <em>File>Open Crash Dump</em> select the dmp file.</p>
<p>Make sure to configure the tools to include a path to the... | <p>You should be able to just double click the .dmp file to automatically open it in Visual Studio. If the .pdb file that was generated when the program was compiled is still around, Visual Studio should be able to automatically load the symbols from that. From then on, you can just hit Run/Debug (F5) to start peeking ... | 19,175 |
<p>I have a container div with a fixed <code>width</code> and <code>height</code>, with <code>overflow: hidden</code>.</p>
<p>I want a horizontal row of float: left divs within this container. Divs which are floated left will naturally push onto the 'line' below after they read the right bound of their parent. This wil... | <p>You may put an inner div in the container that is enough wide to hold all the floated divs.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>#container {
background-c... | <p>Float them left. In Chrome, at least, you don't need to have a wrapper, <code>id="container"</code>, in LucaM's example.</p>
| 5,780 |
<p>I am working with Rails fixtures for testing my rails application. It is all good except one of my database columns is supposed to hold YAML content. But, I am sure how to put the YAML markup I want to load into my database inside the YAML file. Here is an example:</p>
<pre><code>mvnforum:
name: mvnforum
... | <p>If you want to put YAML code inside a YAML document, you need to treat it like a string:</p>
<pre><code>url: "src: test username: admin"
</code></pre>
<p>If you need a multiline string, you can do</p>
<pre><code>mvnforum:
name: mvnforum
abstraction_type: SVN
url: "
src: test\n
username: admin\n
"
sour... | <p>You may want to look into using the <a href="http://en.wikipedia.org/wiki/Factory_pattern" rel="nofollow noreferrer">Factory pattern</a> to replace your fixtures for your tests and use something like <a href="http://textmode.at/2008/6/12/factory-girl-rails-fixture-replacement" rel="nofollow noreferrer">Factory Girl<... | 38,665 |
<p>I have a webapp that uses JNDI lookups to get a connection to the database.</p>
<p>The connection works fine and returns the query no problems. The issue us that the connection does not close properly and is stuck in the 'sleep' mode (according to mysql administrator). This means that they become unusable nad then ... | <p>You seem to be closing the connection properly - except for the case where prepStmt.close() throws a SQLException, I can't find a connection leak.</p>
<p>What pool implementation are you using? When you close a connection, the pool need not close the underlying MySQL connection immediately - after all that is the p... | <p>One thing that @binil missed, you are not closing the result set in the case of an exception. Depending on the driver implementation this may cause the connection to stay open. Move the result.close() call to the finally block. </p>
| 7,655 |
<p>If starting a new project what would you use for your ORM NHibernate or LINQ and why. What are the pros and cons of each.</p>
<p>edit: LINQ to SQL not just LINQ (thanks @Jon Limjap)</p>
| <p>I have asked myself a very similar question except that instead of NHibernate I was thinking about WilsonORM which I have consider pretty nice.</p>
<p>It seems to me that there are many important differences.</p>
<p>LINQ:</p>
<ul>
<li>is not a complete ORM tool (you can get there with some additional libraries li... | <p>I don't use (or even know) NHibernate, I just want to give my testimony: I use LINQ to SQL since about 2 years with MySQL and PostgreSQL databases (using <a href="http://code.google.com/p/dblinq2007/" rel="nofollow">DbLinq</a> on Windows, using <a href="http://www.mono-project.com/" rel="nofollow">Mono</a> on Linux ... | 7,685 |
<p>I can handle the process that file part, but before I go crazy, has someone built a simple wcf service & client (running under windows services or IIS) that I can use to upload a file, and download that file back? with the fewest lines of code? (C# or VB)</p>
<p>compression & encryption would be cool, but i... | <p>You should be able to do this fairly easily. The service contract would probably look like this: </p>
<pre><code>[ServiceContract]
public interface IFileService
{
[OperationContract]
byte[] ProcessFile(byte[] FileData);
}
</code></pre>
<p>The encryption part could be handled natively by WCF using transport le... | <p>Use WCF transport in streamed mode or/and long-running active object pattern.
Please, follow this <a href="http://www.koolzers.net/en/us/articles/long-running-active-object-part1.aspx" rel="nofollow noreferrer">article</a> for more details or contact me.</p>
| 39,952 |
<p>In VB.NET is there a library of template dialogs I can use? It's easy to create a custom dialog and inherit from that, but it seems like there would be some templates for that sort of thing.</p>
<p>I just need something simple like Save/Cancel, Yes/No, etc. </p>
<p>Edit: MessageBox is not quite enough, because I ... | <p>Do you need something more than what can be provided by MsgBox?</p>
<pre><code>MsgBox("Do you want to see this message?", MsgBoxStyle.OkCancel + MsgBoxStyle.Information, "Respond")
</code></pre>
| <p>Are you unable to use the <a href="http://msdn.microsoft.com/en-us/library/aa335422(VS.71).aspx" rel="nofollow noreferrer">MessageBox class</a>?</p>
| 8,839 |
<p>I need to be able to serialize a string and then have it save in a .txt or .xml file. I've never used the implementation to read/write files, just remember I am a relative beginner. Also, I need to know how to deserialize the string to be printed out in terminal as a normal string. </p>
| <p>XStream has facilities to read from and write to files, see the simple examples (Writer.java and Reader.java) <a href="https://web.archive.org/web/20090206084754/http://ibm.com/developerworks/library/x-xstream/index.html" rel="nofollow noreferrer">in this article</a>.</p>
| <p>Is there any particular reason to use XStream? This would be extremely easy to do with something like <a href="http://www.jdom.org/" rel="nofollow noreferrer">JDOM</a> if all you are doing is trying to serialize a string or two.</p>
<p>Ie, something like:
Document doc = new Document();</p>
<pre><code>Element root... | 43,495 |
<p>How do I create a self signed SSL certificate for an Apache Server to use while testing a web app?</p>
| <blockquote>
<p><strong>How do I create a self-signed SSL
Certificate for testing purposes?</strong></p>
</blockquote>
<p>from <a href="http://httpd.apache.org/docs/2.0/ssl/ssl_faq.html#selfcert" rel="noreferrer" title="How do I create a self-signed SSL Certificate for testing purposes?">http://httpd.apache.org/do... | <p>Use OpenSSL (<a href="http://www.openssl.org/" rel="nofollow noreferrer">http://www.openssl.org/</a>)</p>
<p>Here's a tutorial: <a href="http://novosial.org/openssl/self-signed/" rel="nofollow noreferrer">http://novosial.org/openssl/self-signed/</a></p>
<p>Here is the good tutorial to start with: <a href="http://w... | 3,865 |
<p>Where is .mobi headed? Will the mobile devices use proprietary browsers that simplify a .com site or are they going to use browsers on a .mobi basis? I have a feeling it will be a flop... not sure though.</p>
<p>Thanks</p>
| <p>My feeling is that smart phone browsers are getting more and more like desktop browsers, so the whole concept of .mobi is flawed from the start. Plus, a lot of sites can now detect that you're using an inferior browser and redirect you automatically to a less functional version of their web site - no special domain... | <p>.Mobi is worthwhile if you do not own or cannot afford to buy a your ideal .com domain. You can get massively more bang for your buck with a mobi domain. Let's say you need a site to promote your app, you can often just register the exact name as a mobi domain for registration price or a low price if its already tak... | 41,131 |
<p>I have an announcements list on one site. I want to add it as a web part to the top of each subsite. How can I do this in MOSS?</p>
| <p>I've used the Data View Web Part in this case. Create a web service data source to get the data from the other site's list.</p>
<p>Much like this:</p>
<p><a href="http://www.sharepointblogs.com/ssa/archive/2007/02/23/showing-web-service-data-in-a-data-view-web-part.aspx" rel="nofollow noreferrer">http://www.share... | <p>You should be getting the SPList object of that particular list using SharePoint Object Model. Once u get the same, you can render the list using the RenderAsHtml() Method. Please note that the RenderAsHtml() Method takes an SPQuery Object as parameter. You need to create an SPQuery object with the appropriate Query... | 11,832 |
<p>I have a web site which I download 2-3 MB of raw data from that then feeds into an ETL process to load it into my data mart. Unfortunately the data provider is the US Dept. of Ag (USDA) and they do not allow downloading via FTP. They require that I use a web form to select the elements I want, click through 2-3 scre... | <p>A tamperer's best friends (these are firefox extensions, you could also use something like <a href="http://www.wireshark.org/" rel="nofollow noreferrer">Wireshark</a>)</p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/6647" rel="nofollow noreferrer">HTTPFox</a></p>
<p><a href="https://addons.mozilla.o... | <p>As with the other responses, except my tool of choice is <a href="http://www.charlesproxy.com/" rel="nofollow noreferrer">Charles</a></p>
| 38,367 |
<p>I want to create a .bat file so I can just click on it so it can run:</p>
<pre><code>svcutil.exe /language:cs /out:generatedProxy.cs /config:app.config http://localhost:8000/ServiceModelSamples/service
</code></pre>
<p>Can someone help me with the structure of the .bat file?</p>
| <p>To start a program and then close command prompt without waiting for program to exit:</p>
<pre><code>start /d "path" file.exe
</code></pre>
| <p>Well, the important point it seems here is that svcutil is not available by default from command line, you can run it from the vs xommand line shortcut but if you make a batch file normally that wont help unless you run the vcvarsall.bat file before the script.
Below is a sample</p>
<pre>
"C:\Program Files\Microsof... | 27,336 |
<p>So I have this c# application that needs to ping my web server thats running linux/php stack.<br>
I am having problems with the c# way of base 64 encoding bytes.</p>
<p>my c# code is like:</p>
<pre><code>byte[] encbuff = System.Text.Encoding.UTF8.GetBytes("the string");
String enc = Convert.ToBase64String(encbuff)... | <p>You should probably URL Encode your Base64 string on the C# side before you send it.</p>
<p>And URL Decode it on the php side prior to base64 decoding it.</p>
<p>C# side</p>
<pre><code>byte[] encbuff = System.Text.Encoding.UTF8.GetBytes("the string");
string enc = Convert.ToBase64String(encbuff);
string urlenc = ... | <p>in c#</p>
<pre><code>this is a <B>long</b>string. and lets make this a3214 ad0-3214 0czcx 909340 zxci 0324#$@#$%%13244513123
</code></pre>
<p>turns into </p>
<pre><code>dGhpcyBpcyBhIDxCPmxvbmc8L2I+c3RyaW5nLiBhbmQgbGV0cyBtYWtlIHRoaXMgYTMyMTQgYWQwLTMyMTQgMGN6Y3ggOTA5MzQwIHp4Y2kgMDMyNCMkQCMkJSUxMzI0NDUxM... | 32,127 |
<p>I have a program in which the user adds multiple objects to a scene. These objects are all represented as a classes.
Now I want the user to be able to save the scenario, so it can be loaded again.</p>
<p>Is there some genereic save method I can use, or do I have to write my own that saves the values of all propert... | <p>Assuming your objects have all values available as public properties, you can use an XMLSerializer to convert the object to an XML string, then use a XMLDeserializer to re-create the object.</p>
<p>There is an extension method to accomplish this <a href="https://stackoverflow.com/questions/271398/post-your-extensio... | <p>.NET Serialization is the simplest way to do this, although versioning can be a problem as was previously mentioned. This may not be a big problem depending on how complicated your objects are. Your serialization/deserialization logic needs to be smart enough to handle cases where attributes are missing, or have d... | 39,291 |
<p>If I have a char which holds a hex value such has 0x53, (S), how can I display this as "S"?</p>
<p>Code:</p>
<pre><code>char test = 0x53;
cout << test << endl;
</code></pre>
<p>Thanks!</p>
| <p>There's no such thing as a variable that stores a hex value, or a decimal or octal value. Hex, octal, and decimal are just different ways of representing numbers to the compiler. The compiled code will represent everything in binary.</p>
<p>These statements all have the <strong>exact</strong> same effect (assuming ... | <p>Just use the following, you have already answered your question:</p>
<pre><code>using namespace std;
int main() {
char test = 0x53;
std::cout << test << std::endl;
return 0;
}
</code></pre>
| 34,742 |
<p>I need to add text string to a TIFF image. I am planning to use libTIFF for editing the TIFF image. The plan is to convert text to image using freetype2 and then somehow render the text image on to TIFF. Is this the right approach?</p>
<p>Any pointers on how to convert text to image? I saw the sample code of ft2 - ... | <p>One way could be using <a href="http://www.imagemagick.org" rel="nofollow noreferrer">ImageMagick</a>. They have tools for image composition and text rendering. (and many more)</p>
<p>Although ImageMagick is primarily used from the command line (especially in web environments) several language interfaces are availa... | <p>You don't tell us which language you need to use, should it be portable or for a given platform, etc.<br>
Using a ready to use existing graphic library, like the (big!) ImageMagick or others like libGD or <a href="http://openil.sourceforge.net/" rel="nofollow noreferrer" title="DevIL">DevIL</a> might be the easiest ... | 25,984 |
<p>Using <strong>only MySQL</strong>, I'm seeing if it's possible run an insert statement ONLY if the table is new. I successfully created a user variable to see if the table exists. The problem is that you can't use "WHERE" along with an insert statement. Any ideas on how to get this working?</p>
<pre><code>// See if... | <pre><code>IF @TableExists > 0 THEN
BEGIN
INSERT INTO country (name) VALUES ('Afghanistan'),('Aland Islands');
END
</code></pre>
| <p>Use an if statement instead of the where clause:</p>
<p><a href="http://dev.mysql.com/doc/refman/5.0/en/if-statement.html" rel="nofollow noreferrer">http://dev.mysql.com/doc/refman/5.0/en/if-statement.html</a></p>
| 37,341 |
<p>What needs to happen before we can open Web Application Projects hosted in IIS7 with Visual Studio 2008 without running as Administrator? Are we talking about waiting for the next version of Visual Studio? Are there any existing workarounds?</p>
<p>I think it's implied by the above, but this pertains to Vista.</p... | <p>Never is a bad option - pretty much all other development I can do as a non-admin. Its not as if the code under IIS requires admin rights either.</p>
| <p>My <strong>guess</strong> is never. I think admin rights will always be needed to change websites and virtual directories in IIS.</p>
| 47,194 |
<p>Is Eclipse at all theme-able? I would like to install a dark color scheme for it, since I much prefer white text on dark background than the other way around.</p>
| <p>As posted to a few related questions already, I'm working on a plugin for easy, cross-editor color theme management:</p>
<p><a href="http://marketplace.eclipse.org/content/eclipse-color-theme" rel="noreferrer">http://marketplace.eclipse.org/content/eclipse-color-theme</a></p>
<p>It is still work in progress, but a... | <p>I played with customizing the colors. I went with the yellow text/blue background I've liked from Turbo Pascal. The problem I ran into was it let you set the colors of the editors but then the other views like Package Explorer or Navigator stayed with the default black-on-white colors. I'm sure you could do it prog... | 14,666 |
<p>While developing a C++ application, I had to use a third-party library which produced a huge amount of warnings related with a harmless #pragma directive being used.</p>
<pre class="lang-none prettyprint-override"><code>../File.hpp:1: warning: ignoring #pragma ident
In file included from ../File2.hpp:47,
... | <p>I believe you can compile with </p>
<pre><code>-Wno-unknown-pragmas
</code></pre>
<p>to suppress these.</p>
| <p>In my case, I work with <a href="https://en.wikipedia.org/wiki/Qt_%28software%29" rel="nofollow noreferrer">Qt</a> under <a href="https://en.wikipedia.org/wiki/MinGW" rel="nofollow noreferrer">MinGW</a>. I need to set the flag another way, in my <em>.PRO</em> file:</p>
<pre><code>QMAKE_CXXFLAGS_WARN_ON += -Wno-unkno... | 16,083 |
<p>I've been using OpenGL extensions on Windows the <a href="https://stackoverflow.com/questions/14413/using-opengl-extensions-on-windows">painful way</a>. Is GLEW the easier way to go? How do I get started with it?</p>
| <p>Yes, the <strong>OpenGL Extension Wrangler Library</strong> (GLEW) is a painless way to use OpenGL extensions on Windows. Here's how to get started on it:</p>
<p>Identify the OpenGL extension and the extension APIs you wish to use. OpenGL extensions are listed in the <a href="http://www.opengl.org/registry/" rel="n... | <p>I lost some time, but finally I managed to get GLEW working.
I'm using Windows7 (x64), Eclipse CDT and MinGW, and the way is that:</p>
<p>Download MSYS (for MinGW) and rember to have MinGW installed correctly (PATH enviroinment variable set correctly):
<a href="http://sourceforge.net/projects/mingw/files/MSYS/Base/... | 3,803 |
<p>First off I understand that it is a horrible idea to run extremely large/long running reports. I am aware that Microsoft has a rule of thumb stating that a SSRS report should take no longer than 30 seconds to execute. However sometimes gargantuan reports are a preferred evil due to external forces such complying wi... | <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,612 |
<p>I have a need to display a <code>UITableView</code> containing a user's account credentials. For this, I'm using <code>UILabels</code> in <code>UITableViewCell</code>. When I display their password, I'd obviously like to just display a placeholder password character instead of their actual password, similar to a <co... | <p>Why not just use a UITextField, make the field non-editable and change the border style to make it look like a UILabel?</p>
| <p>The password character is probably a bullet. On a Mac, option-8 will insert one wherever you are typing. The Character Palette says it is Unicode <strong>2022</strong> and UTF8 <strong>E2 80 A2</strong>.</p>
| 10,924 |
<p>In a multi-server environment, users will be able to use a page to put, update or delete files on the servers. I was considering using a webservice (on each server) called by the IIS thread to do that work (with an aspx management page).</p>
<p>However, for obvious reasons, I don't really want anyone to be able to ... | <p>You can associate a SHA1 hash with the IP address for each incoming request generated by the combination of the browser (e.g MSIE6.0 or FireFox3), IP address, username(if possible) and/or time, and store this in a DB (sqlite maybe) with an expiry time that is suitable to let the file uploads/transfer complete (say 1... | <p>You can associate a SHA1 hash with the IP address for each incoming request generated by the combination of the browser (e.g MSIE6.0 or FireFox3), IP address, username(if possible) and/or time, and store this in a DB (sqlite maybe) with an expiry time that is suitable to let the file uploads/transfer complete (say 1... | 48,231 |
<p>I have a berkeley db file (*.bdb) which is created by the C implementation(python bsddb module). Is it possible to read this file by a pure java implementation of Berkeley Db? I tried to read it using berkeley db java edition (je) but could not. je throws out an exception saying that it could not detect the berkeley... | <p>No.</p>
<p>According to the <a href="http://www.oracle.com/technetwork/database/berkeleydb/je-faq-096044.html#CanaBerkeleyDBdatabasebeusedbyBerkeleyDBJavaEdition" rel="nofollow noreferrer">Berkeley DB Java Edition FAQ</a>, Berkeley DB and Berkeley DB Java Edition are not compatible with one another because they hav... | <p>I haven't researched the definite answer, but I have the same experience. A database created with pythons bdb, and also accessible with the cli utils, is not detected at all by the Java API. The reverse was also true.</p>
| 23,775 |
<p>I'd like to implement a simple class (in Java) that would allow me to register and deregister strings, and on the basis of the current set of strings auto-complete a given string. So, the interface would be:</p>
<ul>
<li>void add(String)</li>
<li>void remove(String)</li>
<li>String complete(String)</li>
</ul>
<p>W... | <p>you should consider to use a PATRICIA trie for the data structure. Search for 'patricia trie' on google and you'll find a lot of information...</p>
| <p>Regular expressions.</p>
| 9,877 |
<p>Reading through the Flickr API documentation it keeps stating I require an API key to use their REST protocols. I am only building a photo viewer, gathering information available from Flickr's <a href="http://www.flickr.com/services/feeds/docs/photos_public/" rel="noreferrer">public photo feed</a> (For instance, I a... | <blockquote>
<p>To use the Flickr API you need to have an application key. <strong>We use this to track API usage.</strong></p>
<p>Currently, commercial use of the API is allowed only with prior permission. Requests for API keys intended for commercial use are reviewed by staff. If your project is personal, artistic, f... | <p>The Flickr API is very nice and easy to use and will be much easier than scraping the feed yourself.</p>
<p>Getting a key takes about 2 minutes - you fill in a form on the website and then email it to you.</p>
| 11,167 |
<p>In my mock class, I'm mocking method foo(). For some test cases, I want the mock implementation of foo() to return a special value. For other test cases, I want to use the real implementation of foo(). I have a boolean defined in my mock class so that I can determine in the mock method whether I want to return th... | <p>I think you can do this with the <code>@Mock</code> annotation. From the docs, <code>@Mock(reentrant=true)</code> on your mock class should do it.</p>
<p>See <a href="http://jmockit.googlecode.com/svn/trunk/www/javadoc/mockit/Mock.html" rel="noreferrer">http://jmockit.googlecode.com/svn/trunk/www/javadoc/mockit/Mo... | <p>Whomever is still interested, there is a support for that in <a href="https://jmockit.github.io/tutorial/Mocking.html#partial" rel="nofollow noreferrer">Jmockit docs</a></p>
<p>So given this question as an example, it can be achieved as follows:</p>
<pre><code>SomeClass someClass = new SomeClass("fakevalue"... | 46,570 |
<p>I'm looking for suggestions for 3D design software which support designing multi-material parts.</p>
<p>I will be printing on a multi-extruder machine based on RepRap firmware. The printer will handle the files when given a proper g-code file. Slic3r will produce a proper g-code file given the right input. STL s... | <h2>A Scriptable Process for Generating Multi-Material STL Files:</h2>
<p>I am now using interactive CAD software to define the more complex features of the object I am printing (in the current case, clock faces), and then using OpenSCAD to do the boolean volume operations. </p>
<p>To print the composite object, I n... | <p>You do not necessarily need a specific design tool, you can use any tool you want to create your multiple material product. It is the slicer software that manages the materials by assigning the correct extruder. E.g. Cura is able to join 2 STL files that fit together and assign each part a specific extruder and thus... | 860 |
<p>Python is installed in a local directory. </p>
<p>My directory tree looks like this:</p>
<pre><code>(local directory)/site-packages/toolkit/interface.py
</code></pre>
<p>My code is in here:</p>
<pre><code>(local directory)/site-packages/toolkit/examples/mountain.py
</code></pre>
<p>To run the example, I write ... | <p>Based on your comments to orip's post, I guess this is what happened:</p>
<ol>
<li>You edited <code>__init__.py</code> on windows.</li>
<li>The windows editor added something non-printing, perhaps a carriage-return (end-of-line in Windows is CR/LF; in unix it is LF only), or perhaps a CTRL-Z (windows end-of-file).<... | <p>After just suffering the same issue I found my resolution was to delete all <code>pyc</code> files from my project, it seems like these cached files were somehow causing this error.</p>
<p>Easiest way I found to do this was to navigate to my project folder in Windows explorer and searching for <code>*.pyc</code>, t... | 43,985 |
<p>I'm running an c# .net app in an iframe of an asp page on an older site. Accessing the Asp page's session information is somewhat difficult, so I'd like to make my .net app simply verify that it's being called from an approved page, or else immediately halt.</p>
<p>Is there a way for a page to find out the url of i... | <pre><code>top.location.href
</code></pre>
<p>But that will only work if both pages (the iframe and the main page) are being served from the same domain.</p>
| <pre><code>parent.location.href
</code></pre>
| 14,087 |
<p>I'm looking for a tool that can pretty-print (AKA tidy or beautify) source code in as many languages as possible. Those I'm particularly keen on include:</p>
<ul>
<li>Java </li>
<li>JSP </li>
<li>HTML </li>
<li>JavaScript </li>
<li>SQL</li>
<li>JSON</li>
<li>XML</li>
</ul>
<p>Ideally, the tool should be able to up... | <p>I use Vim to do this all the time. It doesn't handle HTML very well, but it does the others. It's easy to use the Vim commands to automate running it on a number of files.</p>
| <p>I use <a href="http://www.ultraedit.com/" rel="nofollow noreferrer">UltraEdit</a> and find it's generally pretty good. It's not free, but it's also not that expensive. </p>
| 31,343 |
<p>The company I work for is protective of IP and has security procedures for disposing of anything that could be stolen for industrial espionage. Paper gets shredded and sent to trusted recycling center, all old data storage media gets obliterated, but what do we do with 3D prints? For any functional prototype, I ha... | <p>Big batches need you to be time efficient - or use a method that uses little work. So my suggestions are mainly needing oversight. Keep a fire extinguisher and safety gear handy though!</p>
<h1>Melting together</h1>
<p>Most filaments are melting at or around 200 °C.</p>
<p>I recently got rid of my box of (PLA) waste... | <p>If your company has a shredder which would handle large amounts of paper at one time, it should be able to handle the plastics from 3D printing. Most larger shredders can handle paper clips and staples. 3D plastics would be even less of a burden than them. You may need to break the pieces down into smaller chunks, b... | 1,028 |
<p>Does anyone have experience with using very large heaps, 12 GB or higher in Java?</p>
<ul>
<li>Does the GC make the program unusable?</li>
<li>What GC params do you use?</li>
<li>Which JVM, Sun or BEA would be better suited for this?</li>
<li>Which platform, Linux or Windows, performs better under such conditions?<... | <p>If your application is not interactive, and GC pauses are not an issue for you, there shouldn't be any problem for 64-bit Java to handle very large heaps, even in hundreds of GBs. We also haven't noticed any stability issues on either Windows or Linux.</p>
<p>However, when you need to keep GC pauses low, things get... | <p>The max memory that XP can address is 4 gig(<a href="http://www.microsoft.com/whdc/system/platform/server/PAE/PAEmem.mspx" rel="nofollow noreferrer">here</a>). So you may not want to use XP for that(use a 64 bit os).</p>
| 26,350 |
<p>I am currently try to use the <a href="http://code.google.com/p/sutekishop/" rel="nofollow noreferrer">sutekishop .Net CMS product</a> but am getting the error
"Could not load type 'System.Web.HttpContextWrapper2'..."
Is this an MVC assembly mismatch? i have uninstalled mvc 5 and installed 3 (required according to ... | <p>Have you recently upgraded to .NET 3.5 SP1? We did, and it caused this exact error message on our MVC website (we were using MVC Preview 2).</p>
<p>After uninstalling .NET 3.5 SP1, the problem went away.</p>
| <p>Thanks , but i have (possibly foolishy) attempted to port the whole thing to MVC 5. Being an ASP.net MVC noob this could get very interesting...
At this stage the project builds but the tests dont. I really wish there was some decent documentation or at least a breaking changes document to go by. :(</p>
| 17,545 |
<p>Is it possible to 3D print an axial turbine 2 - 4 inches (50 - 100 mm) in radius, capable withstanding temperatures about 800 - 1000°C and rotation speeds of 100 - 120 x 10<sup>3</sup> rpm?</p>
<p>How expensive is that? Is it cheaper to mill such a turbine from a whole piece of alloy?</p>
<p>What technologies and ... | <p>You ask some very interesting questions! Firstly, when researching topics such as this, you will have far more luck using 'additive manufacturing' as a search term rather than '3D printing'. In the professional industrial environment, '3D printing' is not a term that is really used to describe the manufacturing you ... | <p>Some companies are already on the move with this idea. I think I remember hearing that <a href="http://optics.org/news/6/4/7" rel="nofollow noreferrer">Pratt and Whitney</a> and Boeing are 3D printing some of the smaller air foils.</p>
<p>The advantages being that they can achieve manufacturing of more complex, mor... | 439 |
<p>What's the best method to pass parameters to SQLCommand? You can do:</p>
<pre><code>cmd.Parameters.Add("@Name", SqlDbType.VarChar, 20).Value = "Bob";
</code></pre>
<p>or</p>
<pre><code>cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = "Bob";
</code></pre>
<p>or</p>
<pre><code>cmd.Parameters.Add("@Name").Va... | <p>You can also use <code>AddWithValue()</code>, but be aware of the possibility of the wrong implicit type conversion.</p>
<pre><code>cmd.Parameters.AddWithValue("@Name", "Bob");
</code></pre>
| <p>It depends on your application. I actually like 2, because I don't lke to have to change my DAO if I change the length of a stored proc parameter. That's just me though. I don't know if there are any performance penalties or anything.</p>
| 37,435 |
<p>If I do a <strong>Create Table If Not Exists</strong>, and a table with the same name exists with fewer rows (or columns), what would happen?</p>
| <p>The table will not be created if a table with the same name already exists regardless of table layout.</p>
| <p>Nothing. If the "IF Not Exists" clause fails, the rest of the create is skipped.</p>
| 29,761 |
<p>I have this C# extension method that will extend any dictionary where the <em>Value</em> type is an <em>IList</em>. When I write the equivalent code in VB.Net I get the following compile error:</p>
<blockquote>
<p><em>"Extension method 'Add' has some type constraints that can never be satisfied".</em></p>
</bloc... | <p>The problem only happens when <code><System.Runtime.CompilerServices.Extension()></code> is present.
The VB compiler imposes a restriction that the constraints must be verifiable with the first argument alone. Since the first argument for the extension method (<code>Dictionary(Of KeyType, ListType)</code>) is... | <p>I would suspect that the problem is that you used ValueType for as the name for one of the type parameters, which is an actual type in the .NET class library (System.ValueType). I can imagine that C# and VB.NET handles this differently. Try it with a different name, like TValue (and TKey just to be consistent).</p>
| 44,320 |
<p>I want to know what are the options to do some scripting jobs in windows platform.
I need functionality like file manipulations, registry editing etc. Can files be edited using scripting tools?
What other functionality does windows scripting tools offer?
Can everything that can be done using the Windows GUI be done ... | <p>I think <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" rel="nofollow noreferrer">Windows PowerShell</a> from Microsoft is the current favourite for this sort of thing.</p>
| <p>Yesterday I could have repaired this for you ;)</p>
<blockquote>
<p>What all are the tools/languages for
windows shell scripting?</p>
</blockquote>
<p>Would read better as</p>
<blockquote>
<p>What tools and languages are available
for windows shell scripting?</p>
</blockquote>
| 5,204 |
<p>I would like to extend some existing applications' drag and drop behavior, and I'm wondering if there is any way to hack on drag and drop support or changes to drag and drop behavior by monitoring the app's message loop and injecting my own messages.</p>
<p>It would also work to monitor for when a paste operation i... | <p>My best suggestion would be to create a webservice on each site that the other could call with the information that needs to get passed. If security is necessary, it's easy to add an SSL-like authentication scheme (or actual SSL even, if you like) to this system to ensure that only the two servers are able to talk t... | <p>@jmein - you've described how to create a modal popup (which is exactly what jqModal does) however you've missed that the content of the modal window is served from another domain. The two domains involved belong to two separate companies so can't be combined in the way you describe.</p>
| 5,311 |
<p>Please note - I am not looking for the "right" way to open/read a file, or the way I should open/read a file every single time. I am just interested to find out what way most people use, and maybe learn a few new methods at the same time :)*</p>
<p>A very common block of code in my Perl programs is opening a file a... | <p>There are no universal standards, but there are reasons to prefer one or another. My preferred form is this:</p>
<pre><code>open( my $input_fh, "<", $input_file ) || die "Can't open $input_file: $!";
</code></pre>
<p>The reasons are:</p>
<ul>
<li>You report errors immediately. (Replace "die" with "warn" if tha... | <p>Damian Conway does it this way:</p>
<pre><code>$data = readline!open(!((*{!$_},$/)=\$_)) for "filename";
</code></pre>
<p>But I don't recommend that to you.</p>
| 41,210 |
<p>I am writing a managed custom action. I am using the DTF Framework from Windows Installer Xml to wrap the managed dll into a usable CA dll. The CA does what it is supposed to, but I am still having trouble with error handling:</p>
<pre><code>Dim record As New Record(1)
' Field 0 intentionally left blank
' Field 1 ... | <p>MSI can do this, but you need to OR in some extra values for the messageType argument.</p>
<p>eg.</p>
<pre><code>Record record = new Record();
record.FormatString = string.Format("Something has gone wrong!");
session.Message(
InstallMessage.Error | (InstallMessage) ( MessageBoxIcon.Error ) |
(InstallMessa... | <p>If you want a dialog to show up that contains the message, you must do it yourself. </p>
<p>Here's some code I use to do error handling in managed custom actions that run SQL.
It shows a messagebox if the installation is operating with a full UI.
It's in c# but hopefully you'll get the idea.</p>
<pre><code> pri... | 48,510 |
<p>How can I stop Visual Studio (both 2005 and 2008) from crashing (sometimes) when I select the "Close All But This" option?This does not happen all the time either.</p>
| <p>First, check <a href="http://www.windowsupdate.com" rel="nofollow noreferrer">Windows Update</a> and make sure both VS environments are up to date.</p>
<p>If that doesn't help, uninstall them both completely, reinstall only 2005, update and test it. If 2005 doesn't crash, install 2008, update and test them both. Do... | <p>Another alternative:</p>
<ol>
<li>Study for 10 years to become a really good programmer</li>
<li>Apply for (and get) a job at Microsoft in the Visual Studio team</li>
<li>Fix the bug</li>
</ol>
| 9,435 |
<p>I am running Ubuntu8.041. Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.3 with Suhosin-Patch configured </p>
<p>Can't get file uploading to work at all. Have tested locally on the Ubuntu box... and from my Vista Box. Ubuntu is running inside VMWare on the Vista box.</p>
<p>Here is uploadTestBrowse.php</p>
<pre><code... | <blockquote>
<p>"I would probably create a new file, seek in the old file, do a buffered read/write from old file to new file, rename the new file over the old one."</p>
</blockquote>
<p>I think you'd be better off simply:</p>
<pre><code>#include <fstream>
std::ifstream ifs("logfile"); //One call to start it... | <p>I don't think it is anything computer related, but how you guys have written your logging class. It sounds strange to me that you read the last 500k into a string, why would you do that?</p>
<p>Just append to the logfile.</p>
<pre><code> fstream myfile;
myfile.open("test.txt",ios::app);
</code></pre>
| 44,970 |
<p>I created a simple batch file (.bat) containing a bunch of commands to be triggered automatically into the command window. The batch looks like this:</p>
<pre><code>mmd dll1.dll -mf -aW
mmd dll2.dll -mf -aW
mmd dll3.dll -mf -aW
</code></pre>
<p>If I copy and paste the bunch of cmds into the command window, they ar... | <p>It is executing the dragged in file with a path relative to the .bat file (and not where those dlls actually are)?</p>
| <p>Are you putting quotes around the file names you are calling? And are the file names on different lines? (If not, they should be)</p>
| 39,263 |
<p>Which one would you use to draw stuff on a winform? Format32bppRgb or Format24bppRgb or something else?</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.drawing.imaging.pixelformat.aspx" rel="nofollow noreferrer">in any .net version</a></p>
<pre><code>Format24bppRgb
Specifies that the format is 24 bi... | <p>It depends on how much of the text in your codebase is using characters outside the ASCII range of 0..127.</p>
<p>You might want to scan for those first, to see how much impact it will have. If your codebase is primarily in English, then you probably don't have much to worry about.</p>
| <p>Something useful I just discovered is that you can right-click on a file on Source Control Explorer, then choose Properties. You can then see/modify the encoding as far as TFS is concerned.</p>
| 41,915 |
<p>I have a new app I'll be working on where I have to generate a Word document that contains tables, graphs, a table of contents and text. What's a good API to use for this? How sure are you that it supports graphs, ToCs, and tables? What are some hidden gotcha's in using them?</p>
<p>Some clarifications:</p>
<ul... | <p>In 2007 my project successfully used OpenOffice.org's <a href="https://www.openoffice.org/udk/common/man/uno.html" rel="noreferrer">Universal Network Objects</a> (UNO) interface to programmatically generate MS-Word compatible documents (*.doc), as well as corresponding PDF documents, from a Java Web application (a S... | <p>After a little more research, I came across <a href="http://www.lowagie.com/iText/" rel="nofollow noreferrer">iText</a>, a PDF and RTF-file creation API. I think I can use the RTF generation to create a Doc-readable file that can then be edited using Doc and re-saved.</p>
<p>Anyone have any experience with iText, ... | 24,853 |
<p>I'm getting a strange effect in Jena 2.5.5 (on Linux) where I am playing around with the inference API. The following code is a stripped down version. I am creating an initially empty Model and a generic rule reasoner. I add a reflexivity rule for a certain statement. I attach the reasoner to the model to get an Inf... | <p>Had a quick look at the relevant source and it appears that you have two options:</p>
<ul>
<li><p>If you want to make changes to the base <em>model</em> and then be sure that they propagate to the <em>infModel</em>, then you have to call <em>infModel.rebind()</em> after having made the changes and before you "ask" ... | <p>It's likely that model.toString() has side-effects. I have not looked at the JENA source, so I can't be sure, though.</p>
| 45,491 |
<p>Is there a better way to develop Java Swing applications?</p>
<p>SWIXML? JavaFX? Anything else that developers out here have liked and recommend?</p>
| <p><a href="http://community.java.net/javadesktop/" rel="nofollow noreferrer">JavaDesktop</a> is a very complete source of information for this kind of question.</p>
<p>Lately, I found (but not used it directly myself) the <a href="https://flamingo.dev.java.net/" rel="nofollow noreferrer">Flamingo swing component suit... | <p>The <a href="https://appframework.dev.java.net/" rel="nofollow noreferrer">Swing Application Framework</a> is a light framework that simplifies the creation and maintaining of small- to medium-sized Java desktop applications. The framework consists of a Java class library that supports constructs for things such as ... | 44,161 |
<p>I need fire a filter method with all string in GET or POST value from http request before it was bind into controller action</p>
<p>Can i do it in Global.asax.cs? and if yes, can u give me more details or example (great) about this?</p>
| <p>You can do it in Global.asax.cs for <em>all</em> requests by </p>
<pre><code>protected void Application_BeginRequest(object sender, EventArgs e) {
//Look at HttpContext.Current.Request to grab request values
}
</code></pre>
<p>Model binding occurs before action filters run. If you want to write a filter that r... | <p>I believe you can with an action filter.</p>
<p>Try this <a href="http://www.singingeels.com/Articles/Logging_with_ASPNET_MVC_Action_Filters.aspx" rel="nofollow noreferrer">article</a>.</p>
| 49,940 |
<p>I have a site that usually has news items at the top of the homepage, and sometimes (for specific periods) will have one or more 'quicklinks' beneath the news items, to guide users to pages of topical interest. Beneath those is the usual blurb.</p>
<p>We have alternative language versions of these sites, which ofte... | <pre><code>.top100 {top: 100px;}
.top150 {top: 150px;}
.top200 {top: 200px;}
.top250 {top: 250px;}
</code></pre>
<p>Is a bad practice, because you now add style information into the HTML.
Better use descriptive names and link them together. Like:</p>
<pre><code>.news {top: 100px; etc...;}
.news2, .ql {top: 150px; etc... | <p>Actually, the best solution is probably this:</p>
<pre><code>.news, .news2 {top: 100px; etc...;}
.news2 {top: 150px;}
.ql, .ql2 {top: 150px; etc...;}
.ql2 {top: 200px;}
.main, .main2 {top: 200px; etc...;}
.main2 {top: 250px;}
</code></pre>
<p>But I take your point(s) GameCat...</p>
<p>Thanks</p>
| 34,197 |
<p>Does anyone know a way to open up an instance of the platform's (Windows/Linux/Mac) browser within a Swing window that is integrated into a Java application. No other actions would be preformed other than opening a given URL. Currently, we open a new browser window because the Java embedded browsers have been insuff... | <p><a href="https://jdic.dev.java.net/" rel="nofollow noreferrer">JDIC</a></p>
| <p>use <a href="http://docs.oracle.com/javase/1.4.2/docs/api/javax/swing/JEditorPane.html" rel="nofollow noreferrer">JEditorPane</a> </p>
<blockquote>
<p>A text component to edit various kinds of content. By default, the following types of content are known: text/plain, text/html and text/rtf</p>
</blockquote>
<p>o... | 37,637 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.